public ResultWrapper <Data> eth_sendTransaction(Transaction transaction) { Core.Transaction tx = _modelMapper.MapTransaction(transaction); Keccak txHash = _blockchainBridge.SendTransaction(tx); return(ResultWrapper <Data> .Success(new Data(txHash))); }
private BigInteger GetTransactionIndex(Core.Transaction transaction, Core.Block block) { for (var i = 0; i < block.Transactions.Length; i++) { var trans = block.Transactions[i]; if (trans.Hash.Equals(transaction.Hash)) { return(i); } } throw new Exception($"Cannot find transaction in block transactions based on transaction hash: {transaction.Hash}, blockHash: {block.Hash}."); }
public Transaction MapTransaction(Core.TransactionReceipt receipt, Core.Transaction transaction) { return(new Transaction { Hash = new Data(transaction.Hash), Nonce = new Quantity(transaction.Nonce), BlockHash = new Data(receipt.BlockHash), BlockNumber = new Quantity(receipt.BlockNumber), TransactionIndex = new Quantity(receipt.Index), From = new Data(receipt.Sender), To = new Data(receipt.Recipient), Value = new Quantity(transaction.Value), GasPrice = new Quantity(transaction.GasPrice), Gas = new Quantity(transaction.GasLimit), Data = new Data(transaction.Data) }); }
public Transaction MapTransaction(Core.Transaction transaction, Core.Block block) { return(new Transaction { Hash = new Data(transaction.Hash.Bytes), Nonce = new Quantity(transaction.Nonce), BlockHash = block != null ? new Data(block.Hash.Bytes) : null, BlockNumber = block?.Header != null ? new Quantity(block.Header.Number) : null, TransactionIndex = block?.Transactions != null ? new Quantity(GetTransactionIndex(transaction, block)) : null, From = new Data(_signer.RecoverAddress(transaction, block.Number).Bytes), To = new Data(transaction.To.Bytes), Value = new Quantity(transaction.Value), GasPrice = new Quantity(transaction.GasPrice), Gas = new Quantity(transaction.GasLimit), Data = new Data(transaction.Data) }); }
private static Transaction MapTransactionWithOptionalValues(Keccak blockHash, UInt256?blockNumber, int?index, Core.Transaction transaction) { return(new Transaction { Hash = new Data(transaction.Hash), Nonce = new Quantity(transaction.Nonce), BlockHash = new Data(blockHash), BlockNumber = blockNumber == null ? null : new Quantity(blockNumber.Value), TransactionIndex = index == null ? null : new Quantity(index.Value), From = new Data(transaction.SenderAddress), To = new Data(transaction.To), Value = new Quantity(transaction.Value), GasPrice = new Quantity(transaction.GasPrice), Gas = new Quantity(transaction.GasLimit), Data = new Data(transaction.Data) }); }
public Transaction MapTransaction(Core.Transaction transaction, Core.Block block) { throw new NotImplementedException(); // TODO: look at new transaction recover (that takes block number) return(new Transaction { Hash = new Data(transaction.Hash.Bytes), Nonce = new Quantity(transaction.Nonce), BlockHash = block != null ? new Data(block.Hash.Bytes) : null, BlockNumber = block?.Header != null ? new Quantity(block.Header.Number) : null, TransactionIndex = block?.Transactions != null ? new Quantity(GetTransactionIndex(transaction, block)) : null, From = new Data(_signer.RecoverAddress(transaction, block.Number).Hex), To = new Data(transaction.To.Hex), Value = new Quantity(transaction.Value), GasPrice = new Quantity(transaction.GasPrice), Gas = new Quantity(transaction.GasLimit), Data = new Data(transaction.Data) }); }
public Core.Transaction MapTransaction(Transaction transaction) { Core.Transaction tx = new Core.Transaction(); tx.GasLimit = transaction.Gas?.Value.ToUInt256() ?? 90000; tx.GasPrice = transaction.GasPrice?.Value.ToUInt256() ?? 0; tx.Nonce = transaction.Nonce?.Value.ToUInt256() ?? 0; // here pick the last nonce? tx.To = transaction.To == null ? null : new Address(transaction.To.Value); tx.SenderAddress = transaction.From == null ? null : new Address(transaction.From.Value); tx.Value = transaction.Value?.Value.ToUInt256() ?? UInt256.Zero; if (tx.To == null) { tx.Init = transaction.Data.Value; } else { tx.Data = transaction.Data.Value; } return(tx); }
public Transaction MapTransaction(Keccak blockHash, UInt256 blockNumber, int index, Core.Transaction transaction) => MapTransactionWithOptionalValues(blockHash, blockNumber, index, transaction);
public TransactionReceipt MapTransactionReceipt(Core.TransactionReceipt receipt, Core.Transaction transaction, Core.Block block) { return(new TransactionReceipt { TransactionHash = new Data(transaction.Hash.Bytes), TransactionIndex = block?.Transactions != null ? new Quantity(GetTransactionIndex(transaction, block)) : null, BlockHash = block != null ? new Data(block.Hash.Bytes) : null, BlockNumber = block?.Header != null ? new Quantity(block.Header.Number) : null, //CumulativeGasUsed = new Quantity(receipt.GasUsed), GasUsed = new Quantity(receipt.GasUsed), ContractAddress = transaction.IsContractCreation && receipt.Recipient != null ? new Data(receipt.Recipient.Hex) : null, Logs = receipt.Logs?.Select(MapLog).ToArray(), LogsBloom = new Data(receipt.Bloom?.Bytes), Status = new Quantity(receipt.StatusCode) }); }