コード例 #1
0
        public async Task <string> GetWalletAdress(string CustomerId)
        {
            _walletcontract = _walletcontract ?? await _contracts.GetContract("Wallet", _config.GetSection("NetworkId").Value);

            _account = _account ?? _web3Backend.GetDefaultAccount();
            _web3    = _web3 ?? _web3Backend.GetDefaultWeb3();

            GetCustomerAddressInputFunction customeradressFunction = new GetCustomerAddressInputFunction()
            {
                customerId  = CustomerId,
                FromAddress = _account.Address,
            };

            var handler = _web3.Eth.GetContractQueryHandler <GetCustomerAddressInputFunction>();
            var result  = await
                          handler.QueryDeserializingToObjectAsync <GetCustomerAddressOutputFunction>(
                customeradressFunction,
                _walletcontract.Address);

            var adress = result?.Address;

            return(await Task.FromResult(adress));
        }
コード例 #2
0
        public async Task <bool> AddCheckCustomer(string CustomerId)
        {
            var ischeckCustomer = await IsCheckCustomer(CustomerId);

            if (ischeckCustomer)
            {
                return(true);
            }

            _account = _account ?? _web3Backend.GetDefaultAccount();
            _web3    = _web3 ?? _web3Backend.GetDefaultWeb3();

            var address = await _walletService.GetWalletAdress(CustomerId);

            var addr = address?.RemoveHexPrefix().Trim('0');

            if (string.IsNullOrEmpty(addr))
            {
                address = await _walletService.CreateAndAddAdressToWallet(CustomerId);
            }

            _checkcontract = _checkcontract ??
                             await _contracts.GetContract("PostdatedCheckManager",
                                                          _config.GetSection("NetworkId").Value);

            CheckModels.AddCustomerInputFunction inputFunc = new CheckModels.AddCustomerInputFunction()
            {
                Address     = address,
                FromAddress = _account.Address
            };

            var handler = _web3.Eth.GetContractTransactionHandler <CheckModels.AddCustomerInputFunction>();
            var result  =
                await handler.SendRequestAndWaitForReceiptAsync(_checkcontract.Address, inputFunc);


            if (result.Status == BigInteger.One)
            {
                return(await Task.FromResult(true));
            }
            else
            {
                return(await Task.FromResult(false));
            }
        }
コード例 #3
0
 public PartialViewResult _Contracts()
 {
     return(PartialView(_contractFacade.GetContract()));
 }