Пример #1
0
    public Task <ResultWrapper <Keccak> > eth_sendTransaction(TransactionForRpc rpcTx)
    {
        Transaction       tx      = rpcTx.ToTransactionWithDefaults(_blockchainBridge.GetChainId());
        TxHandlingOptions options = rpcTx.Nonce == null ? TxHandlingOptions.ManagedNonce : TxHandlingOptions.None;

        return(SendTx(tx, options));
    }
Пример #2
0
            public ResultWrapper <TResult> ExecuteTx(
                TransactionForRpc transactionCall,
                BlockParameter?blockParameter)
            {
                SearchResult <BlockHeader> searchResult = _blockFinder.SearchForHeader(blockParameter);

                if (searchResult.IsError)
                {
                    return(ResultWrapper <TResult> .Fail(searchResult));
                }

                BlockHeader header = searchResult.Object;

                if (!HasStateForBlock(_blockchainBridge, header))
                {
                    return(ResultWrapper <TResult> .Fail($"No state available for block {header.Hash}",
                                                         ErrorCodes.ResourceUnavailable));
                }

                FixCallTx(transactionCall);

                using CancellationTokenSource cancellationTokenSource = new(_rpcConfig.Timeout);
                Transaction tx = transactionCall.ToTransaction(_blockchainBridge.GetChainId());

                return(ExecuteTx(header, tx, cancellationTokenSource.Token));
            }
Пример #3
0
        public async Task get_network_id_should_invoke_blockchain_bridge_get_network_id()
        {
            const int networkId = 1;

            _blockchainBridge.GetChainId().Returns(networkId);
            var result = await _ndmBridge.GetNetworkIdAsync();

            _blockchainBridge.Received().GetChainId();
            result.Should().Be(networkId);
        }
Пример #4
0
 public ResultWrapper <long> eth_chainId()
 {
     try
     {
         long chainId = _blockchainBridge.GetChainId();
         return(ResultWrapper <long> .Success(chainId));
     }
     catch (JsonRpcException ex)
     {
         return(ResultWrapper <long> .Fail(ex.Message, ex.ErrorType, 0L));
     }
 }
Пример #5
0
        public void Eth_chain_id()
        {
            IBlockchainBridge bridge = Substitute.For <IBlockchainBridge>();

            bridge.GetChainId().Returns(1);

            IEthModule module = new EthModule(NullLogManager.Instance, bridge);

            string serialized = RpcTest.TestSerializedRequest(EthModuleFactory.Converters, module, "eth_chainid");

            Assert.AreEqual("{\"id\":67,\"jsonrpc\":\"2.0\",\"result\":\"0x1\"}", serialized);
        }
Пример #6
0
 public ResultWrapper <long> eth_chainId()
 {
     try
     {
         long chainId = _blockchainBridge.GetChainId();
         return(ResultWrapper <long> .Success(chainId));
     }
     catch (Exception ex)
     {
         return(ResultWrapper <long> .Fail(ex.Message, ErrorCodes.InternalError, 0L));
     }
 }
 public Task <long> GetNetworkIdAsync() => Task.FromResult(_blockchainBridge.GetChainId());