示例#1
0
        public ContractABI DeserialiseContract(string abi)
        {
            var            convertor   = new ExpandoObjectConverter();
            var            contract    = JsonConvert.DeserializeObject <List <ExpandoObject> >(abi, convertor);
            var            functions   = new List <FunctionABI>();
            var            events      = new List <EventABI>();
            ConstructorABI constructor = null;

            foreach (IDictionary <string, object> element in contract)
            {
                if ((string)element["type"] == "function")
                {
                    functions.Add(BuildFunction(element));
                }
                if ((string)element["type"] == "event")
                {
                    events.Add(BuildEvent(element));
                }
                if ((string)element["type"] == "constructor")
                {
                    constructor = BuildConstructor(element);
                }
            }

            var contractABI = new ContractABI();

            contractABI.Functions   = functions.ToArray();
            contractABI.Constructor = constructor;
            contractABI.Events      = events.ToArray();

            return(contractABI);
        }
示例#2
0
        public ConstructorABI BuildConstructor(IDictionary <string, object> constructor)
        {
            var constructorABI = new ConstructorABI();

            constructorABI.InputParameters = BuildFunctionParameters((List <object>)constructor["inputs"]);
            return(constructorABI);
        }
示例#3
0
        public ConstructorABI BuildConstructor(dynamic constructor)
        {
            var constructorABI = new ConstructorABI();

            constructorABI.InputParameters = BuildFunctionParameters(constructor.inputs);
            return(constructorABI);
        }