public static ContractInterface Unserialize(BinaryReader reader) { var len = reader.ReadByte(); var methods = new ContractMethod[len]; for (int i = 0; i < len; i++) { methods[i] = ContractMethod.Unserialize(reader); } return(new ContractInterface(methods)); }
public void UnserializeData(BinaryReader reader) { var len = reader.ReadByte(); _methods.Clear(); for (int i = 0; i < len; i++) { var method = ContractMethod.Unserialize(reader); _methods[method.name] = method; } len = reader.ReadByte(); this._events = new ContractEvent[len]; for (int i = 0; i < len; i++) { _events[i] = ContractEvent.Unserialize(reader); } }
/// <summary> /// Checks if this ABI implements a specific method /// </summary> public bool Implements(ContractMethod method) { if (!_methods.ContainsKey(method.name)) { return(false); } var thisMethod = _methods[method.name]; if (thisMethod.parameters.Length != method.parameters.Length) { return(false); } for (int i = 0; i < method.parameters.Length; i++) { if (thisMethod.parameters[i].type != method.parameters[i].type) { return(false); } } return(true); }
public static VMObject CallContext(this IRuntime runtime, string contextName, ContractMethod method, params object[] args) { runtime.Expect(method != null, "trying to call null method for context: " + contextName); NativeContractKind nativeKind; if (Enum.TryParse <NativeContractKind>(contextName, true, out nativeKind)) { return(runtime.CallContext(contextName, 0, method.name, args)); } runtime.Expect(method.offset >= 0, "invalid offset for method: " + method.name); return(runtime.CallContext(contextName, (uint)method.offset, method.name, args)); }
public static VMObject CallNFT(this IRuntime runtime, string symbol, BigInteger seriesID, ContractMethod method, params object[] args) { //var series = Nexus.GetTokenSeries(this.RootStorage, symbol, seriesID); var contextName = $"{symbol}#{seriesID}"; return(runtime.CallContext(contextName, (uint)method.offset, method.name, args)); }