コード例 #1
0
        private async void btnKMSSetItem_Click(object sender, EventArgs e)
        {
            if (ValidateKMSSet() == false)
            {
                return;
            }

            if (contractHandler == null &&
                !string.IsNullOrEmpty(txtKMSContractAddress.Text.Trim()))
            {
                Web3 web3 = GetWeb3();
                contractHandler = web3.Eth.GetContractHandler(txtKMSContractAddress.Text.Trim());
            }

            if (contractHandler == null)
            {
                MessageBox.Show("Problem in getting an instance of the Contract Handler. " +
                                "Please try specifying a valid Contract Address", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            StartProgressBar();

            btnKMSSetItem.Enabled = false;
            var encryptedText = RSAEncryptionHelper.Encrypt(txtValue.Text.Trim(), filteredCert);
            var account       = new Nethereum.Web3.Accounts.Account(privateKey);

            var setItemRequest = new SetItemFunction
            {
                Key         = txtKeyName.Text.Trim(),
                Value       = encryptedText,
                FromAddress = account.Address
            };

            // Set the Gas value
            var estimate = await contractHandler
                           .EstimateGasAsync(setItemRequest);

            setItemRequest.Gas = estimate.Value;

            var setItemFunctionTxnReceipt = await contractHandler
                                            .SendRequestAndWaitForReceiptAsync(setItemRequest);

            if (setItemFunctionTxnReceipt != null &&
                setItemFunctionTxnReceipt.BlockNumber.Value > 0)
            {
                string[]     keyCollection = new string[3];
                ListViewItem listItem;
                keyCollection[0] = txtKeyName.Text.Trim();
                keyCollection[1] = encryptedText;
                keyCollection[2] = "";
                listItem         = new ListViewItem(keyCollection);
                listView1.Items.Add(listItem);
            }

            btnKMSSetItem.Enabled = true;

            StopProgressBar();
        }
コード例 #2
0
        private string DeployContract()
        {
            try
            {
                Web3 web3 = GetWeb3();

                // Deploy Iterable Mapping Library
                TransactionReceipt transactionReceiptDeployment;
                string             contractAddress;

                RSKContractHelper.DeployIterableMappingContract(web3,
                                                                out transactionReceiptDeployment,
                                                                out contractAddress,
                                                                out contractHandler);

                System.Console.WriteLine($"Iterable Mapping Contarct Address: {contractAddress}");
                System.Console.WriteLine("Deploying the RSK KMS Contract");

                // Deploy the RSK Contract
                contractHandler = RSKContractHelper.DeployRSKKeyManagmentContract(web3,
                                                                                  transactionReceiptDeployment,
                                                                                  out contractAddress);

                System.Console.WriteLine("Trying to set a value in RSK KMS Contract");

                return(contractAddress);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(string.Empty);
        }
コード例 #3
0
 public QueryResult(ContractHandler contractHandler, TFunctionOuputDTO result, INethereumTestLogger testLogger, Stateprinter stateprinter)
 {
     ContractHandler = contractHandler;
     Result          = result;
     TestLogger      = testLogger;
     Stateprinter    = stateprinter;
 }
コード例 #4
0
        public ContractNodeHandler(TreeNode node, ContractHandler contract)
        {
            this.IsFirstClick = true;

            Node     = node;
            Contract = contract;
        }
コード例 #5
0
        public WonkaEthContractTriggerBase(Web3 poWeb3, CancellationTokenSource poCancelToken = null)
        {
            moWeb3 = poWeb3;

            moContract    = null;
            moCancelToken = poCancelToken;
        }
コード例 #6
0
        protected TransactionResult GivenATransaction <TTransactionMessage>(TTransactionMessage transactionMessage) where TTransactionMessage : FunctionMessage, new()
        {
            TestLogger.LogGivenSendTransaction(transactionMessage);
            var transactionReceipt = ContractHandler.SendRequestAndWaitForReceiptAsync <TTransactionMessage>(transactionMessage).Result;

            return(new TransactionResult(ContractHandler, transactionReceipt, TestLogger, Stateprinter));
        }
コード例 #7
0
        public WonkaEthContractTriggerBase(Web3 poWeb3, string psContractAddress, CancellationTokenSource poCancelToken = null)
        {
            moWeb3 = poWeb3;

            moContract    = moWeb3.Eth.GetContractHandler(psContractAddress);
            moCancelToken = poCancelToken;
        }
コード例 #8
0
        public UDSHandler(ProjectHandler project, XmlElement source)
        {
            Parent       = project;
            Contracts    = new List <ContractHandler>();
            AllContracts = new List <ContractHandler>();

            XmlHelper     ph   = new XmlHelper(project.Preference);
            List <string> list = new List <string>();

            foreach (XmlElement e in ph.GetElements("Property/Contract"))
            {
                string name = e.GetAttribute("Name");
                list.Add(name);
            }

            XmlHelper h = new XmlHelper(source);

            foreach (XmlElement contractElement in h.GetElements("Contract"))
            {
                ContractHandler ch = new ContractHandler(contractElement);

                if (list.Contains(ch.Name))
                {
                    Contracts.Add(ch);
                }

                AllContracts.Add(ch);
            }
        }
コード例 #9
0
        public ENSRegistryService(IEthApiContractService ethApiContractService, string contractAddress)
        {
            ContractAddress = contractAddress;
#if !DOTNET35
            ContractHandler = ethApiContractService.GetContractHandler(contractAddress);
#endif
        }
コード例 #10
0
        internal void JoinProject(ContractHandler contract)
        {
            List <ContractHandler> cs = new List <ContractHandler>();

            cs.Add(contract);
            JoinProjects(cs);
        }
コード例 #11
0
        internal ContractHandler AddContract(string ContractName, ExtendType extend)
        {
            XmlHelper req = new XmlHelper("<Request/>");

            req.AddElement(".", "ContractName", ContractName);

            req.AddElement(".", "Definition");
            XmlElement authElement = req.AddElement("Definition", "Authentication");

            if (extend == ExtendType.open)
            {
                XmlElement e = req.AddElement("Definition/Authentication", "Public");
                e.SetAttribute("Enabled", "true");
            }
            else
            {
                if (extend != ExtendType.none && extend != ExtendType.open)
                {
                    authElement.SetAttribute("Extends", extend.ToString());
                }
            }

            Parent.SendRequest("UDSManagerService.CreateContract", new Envelope(req));

            ContractHandler contract = ContractHandler.CreateNew(ContractName, extend);

            JoinProject(contract);
            return(contract);
        }
コード例 #12
0
        public PublicResolverService(IEthApiContractService ethApiContractService, string contractAddress)
        {
            ContractAddress = contractAddress;
#if !DOTNET35
            ContractHandler = ethApiContractService.GetContractHandler(contractAddress);
#endif
        }
 public TransactionResult(ContractHandler contractHandler, TransactionReceipt transactionReceipt, INethereumTestLogger testLogger, Stateprinter stateprinter)
 {
     ContractHandler    = contractHandler;
     TransactionReceipt = transactionReceipt;
     TestLogger         = testLogger;
     Stateprinter       = stateprinter;
 }
コード例 #14
0
ファイル: RhodeITService.cs プロジェクト: Brianspha/Rhode-IT
 public RhodeITService()
 {
     Web3            = new Web3(Variables.RPCAddressNodeGenesis);
     Contract        = Web3.Eth.GetContract(Variables.ABI, Variables.ContractAddress);
     ContractHandler = Web3.Eth.GetContractHandler(Variables.ContractAddress);
     Client          = new HttpClient();
 }
コード例 #15
0
        protected QueryResult <TOuputDTO> WhenQuerying <TQueryFunction, TOuputDTO>(TQueryFunction queryFunction) where TQueryFunction : FunctionMessage, new()
            where TOuputDTO : IFunctionOutputDTO, new()
        {
            TestLogger.LogWhenQueryFunction(queryFunction);
            var result = ContractHandler.QueryDeserializingToObjectAsync <TQueryFunction, TOuputDTO>(queryFunction).Result;

            return(new QueryResult <TOuputDTO>(ContractHandler, result, TestLogger, Stateprinter));
        }
        public Task <GetEshopOutputDTO> GetEshopQueryAsync(string eShopId, BlockParameter blockParameter = null)
        {
            var getEshopFunction = new GetEshopFunction();

            getEshopFunction.EShopId = eShopId.ConvertToBytes32();

            return(ContractHandler.QueryDeserializingToObjectAsync <GetEshopFunction, GetEshopOutputDTO>(getEshopFunction, blockParameter));
        }
        public Task <GetSellerOutputDTO> GetSellerQueryAsync(string sellerId, BlockParameter blockParameter = null)
        {
            var getSellerFunction = new GetSellerFunction();

            getSellerFunction.SellerId = sellerId.ConvertToBytes32();

            return(ContractHandler.QueryDeserializingToObjectAsync <GetSellerFunction, GetSellerOutputDTO>(getSellerFunction, blockParameter));
        }
コード例 #18
0
        /// <summary>
        /// Gets a transaction out of the transactions mapping on the contract and decodes it.
        /// </summary>
        /// <param name="web3">The web3 interface instance to use.</param>
        /// <param name="contractAddress">The address of the deployed multisig wallet contract.</param>
        /// <param name="transactionId">The multisig wallet transaction identifier.</param>
        /// <returns>A decoded transaction object.</returns>
        public static async Task <TransactionDTO> GetTransactionAsync(Web3 web3, string contractAddress, BigInteger transactionId)
        {
            ContractHandler handler = web3.Eth.GetContractHandler(contractAddress);

            return(await handler.QueryDeserializingToObjectAsync <TransactionsFunction, TransactionDTO>(new TransactionsFunction()
            {
                TransactionId = transactionId
            }).ConfigureAwait(false));
        }
コード例 #19
0
        public async Task <IList <BigInteger> > GetAllContentIdsStruct()
        {
            var contract   = GetContract();
            var contentIds = await ContractHandler.QueryAsync <ContentIdsStructFunction, List <BigInteger> >(new ContentIdsStructFunction()
            {
            });

            return(contentIds);
        }
コード例 #20
0
        /// <summary>
        /// Checks whether the given transaction identified by the transactionId has been confirmed by the given address.
        /// </summary>
        /// <param name="web3">The web3 interface instance to use.</param>
        /// <param name="contractAddress">The address of the deployed multisig wallet contract.</param>
        /// <param name="transactionId">The multisig wallet transaction identifier.</param>
        /// <param name="address">The address to check the transaction's confirmation status with.</param>
        /// <returns>An object containing the boolean confirmation state.</returns>
        public static async Task <ConfirmationsDTO> AddressConfirmedTransactionAsync(Web3 web3, string contractAddress, BigInteger transactionId, string address)
        {
            ContractHandler handler = web3.Eth.GetContractHandler(contractAddress);

            return(await handler.QueryDeserializingToObjectAsync <ConfirmationsFunction, ConfirmationsDTO>(new ConfirmationsFunction()
            {
                TransactionId = transactionId, Address = address
            }).ConfigureAwait(false));
        }
コード例 #21
0
        public async Task <bool> DoesModeratorExist(string address)
        {
            var isModerator = await ContractHandler.QueryAsync <ModeratorFunction, bool>(new ModeratorFunction()
            {
                Address = address
            });

            return(isModerator);
        }
コード例 #22
0
        public Task <BigInteger> GetPoNumberByEshopIdAndQuoteQueryAsync(string eShopId, BigInteger quoteId, BlockParameter blockParameter = null)
        {
            var getPoNumberBySellerAndQuoteFunction = new GetPoNumberByEshopIdAndQuoteFunction();

            getPoNumberBySellerAndQuoteFunction.EShopId = eShopId.ConvertToBytes32();
            getPoNumberBySellerAndQuoteFunction.QuoteId = quoteId;

            return(ContractHandler.QueryAsync <GetPoNumberByEshopIdAndQuoteFunction, BigInteger>(getPoNumberBySellerAndQuoteFunction, blockParameter));
        }
コード例 #23
0
        public void ShouldCheckForNewupdate()
        {
            string lookupContractAddress = "0xa454963c7a6dcbdcd0d3fb281f4e67262fb71586";
            string ncContractAddress     = "0x5f51f49e25b2ba1acc779066a2614eb70a9093a0";
            string rpc = Environment.GetEnvironmentVariable("TEST_RPC") ?? "http://localhost:8545";
            string validatorAddress      = "0xc3681dfe99730eb45154208cba7b0df7e705f305";
            string fileToPersistBlockNum = Path.GetTempFileName();

            ResetToSnapshot(rpc);

            // no new update should be seen
            ContractWrapper cw        = new ContractWrapper(lookupContractAddress, rpc, validatorAddress, new MockLogger(), "test", _keyjson, fileToPersistBlockNum);
            bool            hasUpdate = cw.HasNewUpdate().Result;

            hasUpdate.Should().Be(false);


            // Send an update
            // prepare RPC connection to play some tx

            string  contractOwnerPk = "ae29ab491cf53d8b63f281cc5eecdbbac4a992b2a4bf483bacae66dfff0740f0";
            Account account         = new Account(contractOwnerPk);

            // create a web 3 instance
            Web3 web3 = new Web3(account, rpc);

            // hook up to the contract and event
            ContractHandler contractHandler = web3.Eth.GetContractHandler(ncContractAddress);

            // contract gets primed with by ganache start
            // const valAddr = "0xc3681dfe99730eb45154208cba7b0df7e705f305"; // first addr in ganache
            // contract.updateValidator(valAddr, '0x123456', 'parity/parity:v2.3.3', '0x123456', 'https://chainspec', true);

            TransactionReceipt confirmResponse = contractHandler.SendRequestAndWaitForReceiptAsync(new UpdateValidatorFunction
            {
                DockerSha        = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x23 },
                DockerName       = "parity/parity:v2.3.4",
                ChainspecSha     = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x23 },
                ChainspecUrl     = "https://example.com" + new Random().Next(),
                IsSigning        = true,
                ValidatorAddress = validatorAddress
            }).Result;


            bool?hasErrors = confirmResponse.HasErrors();

            if (hasErrors.HasValue && hasErrors.Value)
            {
                throw new ContractException("Unable to confirm update");
            }

            // now an update should be seen
            bool hasUpdate2Nd = cw.HasNewUpdate().Result;

            hasUpdate2Nd.Should().Be(true);
        }
コード例 #24
0
 private void ContractEditor_Load(object sender, EventArgs e)
 {
     txtName.Text = Contract.Name;
     ChangeType(Contract.ExtendType);
     this.ContractNodeHandler.Contract.Renamed += delegate(object s, EventArgs arg)
     {
         ContractHandler ch = s as ContractHandler;
         txtName.Text = ch.Name;
     };
 }
コード例 #25
0
        public async Task <bool> SetInfo(string name, string symbol)
        {
            var infoFunction = new SetTokenInformationFunction();

            infoFunction.Name   = name;
            infoFunction.Symbol = symbol;
            var complete2 = await ContractHandler.SendRequestAsync <SetTokenInformationFunction>(infoFunction);

            return(true);
        }
コード例 #26
0
        public async Task <BigInteger> CountAllContentForSubArticle(long subArticleId)
        {
            var contract     = GetContract();
            var contentCount = await ContractHandler.QueryAsync <CountSubArticleContentFunction, BigInteger>(new CountSubArticleContentFunction()
            {
                SubArticleId = subArticleId
            });

            return(contentCount);
        }
コード例 #27
0
        /// <summary>
        /// Gets a transaction out of the transactions mapping on the contract without decoding it.
        /// </summary>
        /// <param name="web3">The web3 interface instance to use.</param>
        /// <param name="contractAddress">The address of the deployed multisig wallet contract.</param>
        /// <param name="transactionId">The multisig wallet transaction identifier.</param>
        /// <returns>The transaction data in hex format. No decoding is applied.</returns>
        public static async Task <string> GetRawTransactionAsync(Web3 web3, string contractAddress, BigInteger transactionId)
        {
            ContractHandler handler = web3.Eth.GetContractHandler(contractAddress);

            byte[] rawTransaction = await handler.QueryRawAsync <TransactionsFunction>(new TransactionsFunction()
            {
                TransactionId = transactionId
            }).ConfigureAwait(false);

            return(Encoders.Hex.EncodeData(rawTransaction));
        }
コード例 #28
0
        protected QueryResult <TOuputDTO> WhenQueryingThen <TQueryFunction, TOuputDTO>(TQueryFunction queryFunction, TOuputDTO expectedOutput) where TQueryFunction : FunctionMessage, new()
            where TOuputDTO : IFunctionOutputDTO, new()
        {
            TestLogger.LogWhenQueryFunctionThen(queryFunction, expectedOutput);
            var result = ContractHandler.QueryDeserializingToObjectAsync <TQueryFunction, TOuputDTO>(queryFunction).Result;

            Stateprinter.Assert.AreEqual(
                Stateprinter.PrintObject(expectedOutput),
                Stateprinter.PrintObject(result));
            return(new QueryResult <TOuputDTO>(ContractHandler, result, TestLogger, Stateprinter));
        }
コード例 #29
0
        public Task <TransactionReceipt> SetPoItemAcceptedRequestAndWaitForReceiptAsync(string eShopIdString, BigInteger poNumber, byte poItemNumber, string soNumber, string soItemNumber, CancellationTokenSource cancellationToken = null)
        {
            var setPoItemAcceptedFunction = new SetPoItemAcceptedFunction();

            setPoItemAcceptedFunction.EShopIdString = eShopIdString;
            setPoItemAcceptedFunction.PoNumber      = poNumber;
            setPoItemAcceptedFunction.PoItemNumber  = poItemNumber;
            setPoItemAcceptedFunction.SoNumber      = soNumber.ConvertToBytes32();
            setPoItemAcceptedFunction.SoItemNumber  = soItemNumber.ConvertToBytes32();

            return(ContractHandler.SendRequestAndWaitForReceiptAsync(setPoItemAcceptedFunction, cancellationToken));
        }
コード例 #30
0
        static void Main(string[] args)
        {
            string          buffer = Console.In.ReadToEnd();
            ContractHandler c      = new ContractHandler();

            string responseValue = c.Handle(buffer);

            if (responseValue != null)
            {
                Console.Write(responseValue);
            }
        }