Пример #1
0
        public Task <ResultWrapper <Keccak> > baseline_insertLeaf(Address address, Address contractAddress, Keccak hash)
        {
            if (hash == Keccak.Zero)
            {
                return(Task.FromResult(ResultWrapper <Keccak> .Fail("Cannot insert zero hash", ErrorCodes.InvalidInput)));
            }

            var txData = _abiEncoder.Encode(
                AbiEncodingStyle.IncludeSignature,
                ContractMerkleTree.InsertLeafAbiSig,
                hash);

            Transaction tx = new Transaction();

            tx.Value         = 0;
            tx.Data          = txData;
            tx.To            = contractAddress;
            tx.SenderAddress = address;
            tx.GasLimit      = 1000000;
            tx.GasPrice      = 0.GWei();

            Keccak txHash = _txPoolBridge.SendTransaction(tx, TxHandlingOptions.ManagedNonce);

            return(Task.FromResult(ResultWrapper <Keccak> .Success(txHash)));
        }
Пример #2
0
        public ValueTask <ResultWrapper <Keccak> > deposit_deploy(Address senderAddress)
        {
            Transaction tx = new Transaction();

            tx.Value         = 0;
            tx.Init          = _abiDefinition.Bytecode;
            tx.GasLimit      = 2000000;
            tx.GasPrice      = 20.GWei();
            tx.SenderAddress = senderAddress;

            Keccak txHash = _txPoolBridge.SendTransaction(tx, TxHandlingOptions.ManagedNonce);

            if (_logger.IsInfo)
            {
                _logger.Info($"Sent transaction at price {tx.GasPrice} to {tx.SenderAddress}");
            }

            return(new ValueTask <ResultWrapper <Keccak> >(ResultWrapper <Keccak> .Success(txHash)));
        }
Пример #3
0
        public async Task send_own_transaction_should_invoke_blockchain_bridge_send_transaction_and_return_hash()
        {
            var transaction = Build.A.Transaction.TestObject;
            var hash        = TestItem.KeccakA;

            _txPoolBridge.SendTransaction(transaction, TxHandlingOptions.PersistentBroadcast | TxHandlingOptions.ManagedNonce).Returns(hash);
            var result = await _ndmBridge.SendOwnTransactionAsync(transaction);

            _txPoolBridge.Received().SendTransaction(transaction, TxHandlingOptions.PersistentBroadcast | TxHandlingOptions.ManagedNonce);
            result.Should().Be(hash);
        }
Пример #4
0
        public ValueTask <ResultWrapper <Keccak> > deposit_deploy(Address senderAddress)
        {
            ResultWrapper <Keccak> result;

            if (_depositContract == null)
            {
                result = ResultWrapper <Keccak> .Fail("Deposit contract address not specified.", ErrorCodes.InternalError);

                return(new ValueTask <ResultWrapper <Keccak> >(result));
            }

            Transaction tx     = _depositContract.Deploy(senderAddress);
            Keccak      txHash = _txPoolBridge.SendTransaction(tx, TxHandlingOptions.ManagedNonce);

            if (_logger.IsInfo)
            {
                _logger.Info($"Sent transaction at price {tx.GasPrice} to {tx.SenderAddress}");
            }

            result = ResultWrapper <Keccak> .Success(txHash);

            return(new ValueTask <ResultWrapper <Keccak> >(result));
        }
Пример #5
0
 private Task <ResultWrapper <Keccak> > SendTx(Transaction tx)
 {
     try
     {
         Keccak txHash = _txPoolBridge.SendTransaction(tx, TxHandlingOptions.PersistentBroadcast);
         return(Task.FromResult(ResultWrapper <Keccak> .Success(txHash)));
     }
     catch (SecurityException e)
     {
         return(Task.FromResult(ResultWrapper <Keccak> .Fail(e.Message, ErrorCodes.AccountLocked)));
     }
     catch (Exception e)
     {
         return(Task.FromResult(ResultWrapper <Keccak> .Fail(e.Message, ErrorCodes.TransactionRejected)));
     }
 }
Пример #6
0
 public Task <Keccak?> SendOwnTransactionAsync(Transaction transaction)
 => Task.FromResult <Keccak?>(_txPoolBridge.SendTransaction(transaction, TxHandlingOptions.ManagedNonce | TxHandlingOptions.PersistentBroadcast));