public async Task <byte[]> CallAsync(Transaction transaction, long blockNumber)
        {
            var result = await _proxy.eth_call(CallTransactionModel.FromTransaction(transaction),
                                               BlockParameterModel.FromNumber(blockNumber));

            return(result?.IsValid == true ? result.Result ?? Array.Empty <byte>() : Array.Empty <byte>());
        }
Пример #2
0
        public async Task eth_getBlockByNumber_should_invoke_client_method()
        {
            var        blockParameter = BlockParameterModel.FromNumber(1L);
            const bool returnFullTransactionObjects = true;
            await _proxy.eth_getBlockByNumber(blockParameter, returnFullTransactionObjects);

            await _client.Received().SendAsync <BlockModel>(nameof(_proxy.eth_getBlockByNumber),
                                                            blockParameter.Number, returnFullTransactionObjects);
        }
Пример #3
0
        private static BlockParameterModel MapBlockParameter(BlockParameter blockParameter)
        {
            if (blockParameter is null)
            {
                return(null);
            }

            if (blockParameter.Type == BlockParameterType.BlockNumber && blockParameter.BlockNumber.HasValue)
            {
                return(BlockParameterModel.FromNumber(blockParameter.BlockNumber.Value));
            }

            return(new BlockParameterModel
            {
                Type = blockParameter.Type.ToString()
            });
        }
        public async Task <Block?> FindBlockAsync(long blockNumber)
        {
            var result = await _proxy.eth_getBlockByNumber(BlockParameterModel.FromNumber(blockNumber));

            return(result?.IsValid == true?result.Result?.ToBlock() : null);
        }
Пример #5
0
        private async Task GetEstimateGasAsync()
        {
            _estimateGasLabel = new Label(PositionX, 21, "eth_estimateGas: fetching...");
            _window.Add(_estimateGasLabel);

            var gasLimit = await Extensions.TryExecuteAsync(() =>
                                                            _ethJsonRpcClientProxy.eth_estimateGas(_transaction,
                                                                                                   BlockParameterModel.FromNumber(_latestBlock.Number)));

            SetEstimateGas(gasLimit);
            _window.Remove(_estimateGasLabel);
            _estimateGasLabel = new Label(PositionX, 21, $"Gas limit: {_estimateGas}");
            _window.Add(_estimateGasLabel);
        }