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); }
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); }
public override object Clone() { SolidityVar basecopy = (SolidityVar)basevar.Clone(); SolidityArray copy = new SolidityArray(basecopy, name); return(copy); }
public SolidityArray(SolidityVar _baseVar, string _name) { basevar = _baseVar; name = _name; }
private void parseVariables(ParserRuleContext context) { if (inFunction) { return; } SolidityVar currentVar = null; switch (typename) { case "address": currentVar = new SolidityAddress(name); break; case "uint": currentVar = new SolidityUint(typesize, name); break; case "string": currentVar = new SolidityStringVar(name); break; case "bool": currentVar = new SolidityUintBool(name); break; default: if (structDefs.ContainsKey(typename)) { currentVar = (SolidityVar)structDefs[typename].Clone(); } else if (enumDefs.ContainsKey(typename)) { currentVar = (SolidityVar)enumDefs[typename].Clone(); } else { // throw new NotSupportedException("unknwon type " + typename); Console.WriteLine(" uknown type " + typename + " at adding as address" + context.Start.Line); currentVar = new SolidityAddress(name); } break; } if (isarray) { SolidityVar oldvar = currentVar; currentVar = new SolidityArray(currentVar, name); isarray = false; } if (currStruct != null && currentVar != null) { currStruct.AddType(currentVar); } else if (currentVar != null) { if (startMap > 0) { SolidityMap mapvar = new SolidityMap(currentVar, name, startMap); /*for(int i = 1; i < startMap; i++) * { * SolidityMap newMap = new SolidityMap(mapvar, ""); * mapvar = newMap; * } * mapvar.name = name;*/ variableList.Add(mapvar); startMap = 0; } else { variableList.Add(currentVar); } ethGlobal.DebugPrint("added " + name); } }
public void AddType(SolidityVar type) { typesList.Add(type); }
public SolidityMap(SolidityVar _baseVar, string _name, int _depth = 1) { basevar = _baseVar; name = _name; depth = _depth; }