Esempio n. 1
0
        public void Setup()
        {
            Web3 web3 = new Web3(new Account(privateKey), (ganacheURL));
            //var testClassSimpleDeployTask =  TestClassSimpleService.DeployContractAsync(web3, new TestClassSimpleDeployment());

            var deploymentCallerHandler = web3.Eth.GetContractDeploymentHandler <TestPackingDeployment>();
            var deploymentReceiptCaller = deploymentCallerHandler.SendRequestAndWaitForReceiptAsync();

            deploymentReceiptCaller.Wait();
            testClassSimpleAddr = deploymentReceiptCaller.Result.ContractAddress;

            MultiKeyDecodeList.ClearAll();

            /*  Json content if it was in the config file
             *     "simpleMap": [ "4", "8", "10","12" ],
             *      "complexMap": [ "1,2", "2,2" ],
             *      "structMap": [ "1", "4" ] */
            MultiKeyDecodeList.AddKey("simpleMap", "4");
            MultiKeyDecodeList.AddKey("simpleMap", "8");
            MultiKeyDecodeList.AddKey("simpleMap", "10");
            MultiKeyDecodeList.AddKey("simpleMap", "12");
            MultiKeyDecodeList.AddKey("structMap", "4");
            MultiKeyDecodeList.AddKey("structMap", "1");
            DeployContract();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if(! File.Exists(@"settings.json"))
            {
                Console.WriteLine("Error a settings.json file must be provided with required settings");
                return;
            }
            Console.WriteLine("Settings file is " + Path.GetFullPath("settings.json"));
            IConfiguration config = new ConfigurationBuilder()
              .AddJsonFile(Path.GetFullPath("settings.json"), true, true)
              .Build();

            /*"searchpath": [ "C:\\inuka_proj\\gitStorageDecodegit\\contracttest\\contracts" ],
               "inputfile": "C:\\inuka_proj\\gitStorageDecodegit\\contracttest\\contracts\\TestClassSimple.sol",
               "MapVariables": {
                    "simpleMap": [ "4", "5", "6", "7" ],
                    "var2": [ "7", "8", "9" ]
            }*/
            List<string> searchpath = config.GetSection("searchpath").Get<List<string>>();
            String inputfile = config.GetSection("inputfile").Value;
            Console.WriteLine("inuput file is " + inputfile);
            var varsection = config.GetSection("MapVariables").GetChildren();
            foreach(var chld in varsection)
            {
                List<string> keys= chld.Get<List<string>>();
                foreach (string ky in keys)
                    MultiKeyDecodeList.AddKey(chld.Key, ky);
                //SolidityMap.
            }
            string address = config["address"];
            string ethURL = config["ethURL"];
            if(string.IsNullOrEmpty(address))
            {
                Console.WriteLine("address field is required");
                return;
            }
            if(string.IsNullOrEmpty(ethURL))
            {
                Console.WriteLine("URL to the ethereum node or Ganache must be provided");
                return;
            }
            /*check node and web3 connectivity */
            Web3 web = new Web3(ethURL);
            try
            {
                var currentBlock = web.Eth.Blocks.GetBlockNumber.SendRequestAsync();
                currentBlock.Wait();
            }
            catch(Exception exp)
            {
                Console.WriteLine("ERROR: not able to connect to Ethereum node or Ganache with the following error "+exp.Message);
                return;
            }
            string className = config["className"]; //for the case where multiple contracts are in the same file.
            string isdebug = config["debug"];
            if(!string.IsNullOrEmpty(isdebug) && isdebug.ToLower()=="true")
            {
                ethGlobal.IsDebug = true;
            }
            if (!File.Exists(inputfile))
            {
                Console.WriteLine("Error the input file does not exist :" + inputfile);
                return;
            }
            searchpath.Add(Path.GetDirectoryName(inputfile));
            Dictionary<string, string> subContracts = SplitContractFiles(inputfile);
            if(subContracts.Keys.Count>1 && String.IsNullOrEmpty(className))
            {
                Console.WriteLine("Error class name needs to be provied for file containing multiple contracts");
                return;
            }
            RunDecodingAndPrint(inputfile, address, ethURL, searchpath, subContracts, className);

        }