Exemplo n.º 1
0
        public static List <DecodedContainer> DecodIntoContainer(List <SolidityVar> variableList, Web3 connect,
                                                                 string address, BigInteger index, int offset = 0, string className = "")
        {
            List <DecodedContainer> decodeList = new List <DecodedContainer>();

            for (int i = 0; i < variableList.Count; i++)
            {
                SolidityVar var = variableList[i];
                var         currentContainer = var.DecodeIntoContainer(connect, address, index, offset);
                currentContainer.key = i.ToString();
                decodeList.Add(currentContainer);
                if (i + 1 < variableList.Count)
                {
                    SolidityVar next = variableList[i + 1];
                    if (var.getByteSize() > -1 && next.getByteSize() > -1 && (offset + var.getByteSize() + next.getByteSize() < 32))
                    {
                        offset += var.getByteSize();
                    }
                    else
                    {
                        index += var.getIndexSize();
                        offset = 0;
                    }
                }
            }
            return(decodeList);
        }
Exemplo n.º 2
0
        public static List <DecodedContainer> DecodIntoContainerInstances(SolidityVar var, Web3 connect, string address, int numInstances, BigInteger index, int offset = 0)
        {
            List <DecodedContainer> decodeList = new List <DecodedContainer>();

            for (int i = 0; i < numInstances; i++)
            {
                ethGlobal.DebugPrint(String.Format("[{0}]", i));
                var currContainer = var.DecodeIntoContainer(connect, address, index, offset);
                currContainer.key = i.ToString();
                decodeList.Add(currContainer);
                if (i + 1 < numInstances)
                {
                    SolidityVar next = var;
                    if (!(next is SolidityStruct) && next.getByteSize() > -1 && (offset + var.getByteSize() + next.getByteSize() < 32))
                    {
                        offset += var.getByteSize();
                    }
                    else
                    {
                        index += var.getIndexSize();
                        offset = 0;
                    }
                }
            }
            return(decodeList);
        }