public async Task get_network_id_should_invoke_proxy_eth_chainId()
        {
            const int networkId = 1;

            _proxy.eth_chainId().Returns(RpcResult <UInt256> .Ok(networkId));
            var result = await _ndmBridge.GetNetworkIdAsync();

            await _proxy.Received().eth_chainId();

            result.Should().Be(networkId);
        }
Ejemplo n.º 2
0
        public async Task <ResultWrapper <Keccak> > eth_sendTransaction(TransactionForRpc rpcTx)
        {
            Transaction transaction = rpcTx.ToTransactionWithDefaults();

            if (transaction.Signature is null)
            {
                RpcResult <UInt256> chainIdResult = await _proxy.eth_chainId();

                ulong chainId = chainIdResult?.IsValid == true ? (ulong)chainIdResult.Result : 0;
                RpcResult <UInt256?> nonceResult =
                    await _proxy.eth_getTransactionCount(transaction.SenderAddress, BlockParameterModel.Pending);

                transaction.Nonce = nonceResult?.IsValid == true ? nonceResult.Result ?? UInt256.Zero : UInt256.Zero;
                _wallet.Sign(transaction, chainId);
            }

            return(ResultWrapper <Keccak> .From(await _proxy.eth_sendRawTransaction(Rlp.Encode(transaction).Bytes)));
        }
Ejemplo n.º 3
0
        public async Task <ResultWrapper <Keccak> > eth_sendTransaction(TransactionForRpc transactionForRpc)
        {
            var transaction = transactionForRpc.ToTransaction();

            if (transaction.Signature is null)
            {
                var chainIdResult = await _proxy.eth_chainId();

                var chainId     = chainIdResult?.IsValid == true ? (int)chainIdResult.Result : 0;
                var nonceResult =
                    await _proxy.eth_getTransactionCount(transaction.SenderAddress, BlockParameterModel.Pending);

                transaction.Nonce = nonceResult?.IsValid == true ? nonceResult.Result ?? UInt256.Zero : UInt256.Zero;
                _wallet.Sign(transaction, chainId);
            }

            return(ResultWrapper <Keccak> .From(await _proxy.eth_sendRawTransaction(Rlp.Encode(transaction).Bytes)));
        }
Ejemplo n.º 4
0
        public async Task eth_chainId_should_invoke_client_method()
        {
            await _proxy.eth_chainId();

            await _client.Received().SendAsync <UInt256>(nameof(_proxy.eth_chainId));
        }
        public async Task <ulong> GetNetworkIdAsync()
        {
            RpcResult <UInt256>?result = await _proxy.eth_chainId();

            return(result?.IsValid == true ? (ulong)result.Result : 0ul);
        }
        public async Task <int> GetNetworkIdAsync()
        {
            var result = await _proxy.eth_chainId();

            return(result?.IsValid == true ? (int)result.Result : 0);
        }