mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-04 00:05:22 +00:00
keep in sync with eth_common#23
This commit is contained in:
parent
03ca4ef24a
commit
af84be0eea
@ -349,24 +349,25 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
|
|||||||
transaction = getBlockBody(blockHash).transactions[quantity]
|
transaction = getBlockBody(blockHash).transactions[quantity]
|
||||||
populateTransactionObject(transaction, quantity, header, blockHash)
|
populateTransactionObject(transaction, quantity, header, blockHash)
|
||||||
|
|
||||||
proc populateReceipt(receipt: Receipt, cumulativeGas: GasInt, transaction: Transaction, txIndex: int, blockHeader: BlockHeader): ReceiptObject =
|
proc populateReceipt(receipt: Receipt, gasUsed: GasInt, transaction: Transaction, txIndex: int, blockHeader: BlockHeader): ReceiptObject =
|
||||||
result.transactionHash = transaction.rlpHash
|
result.transactionHash = transaction.rlpHash
|
||||||
result.transactionIndex = txIndex
|
result.transactionIndex = txIndex
|
||||||
result.blockHash = blockHeader.hash
|
result.blockHash = blockHeader.hash
|
||||||
result.blockNumber = blockHeader.blockNumber
|
result.blockNumber = blockHeader.blockNumber
|
||||||
result.sender = transaction.getSender()
|
result.sender = transaction.getSender()
|
||||||
result.to = some(transaction.to)
|
result.to = some(transaction.to)
|
||||||
result.cumulativeGasUsed = cumulativeGas
|
result.cumulativeGasUsed = receipt.cumulativeGasUsed
|
||||||
result.gasUsed = receipt.gasUsed
|
result.gasUsed = gasUsed
|
||||||
# TODO: Get contract address if the transaction was a contract creation.
|
# TODO: Get contract address if the transaction was a contract creation.
|
||||||
result.contractAddress = none(EthAddress)
|
result.contractAddress = none(EthAddress)
|
||||||
result.logs = receipt.logs
|
result.logs = receipt.logs
|
||||||
result.logsBloom = blockHeader.bloom
|
result.logsBloom = blockHeader.bloom
|
||||||
# post-transaction stateroot (pre Byzantium).
|
# post-transaction stateroot (pre Byzantium).
|
||||||
result.root = blockHeader.stateRoot
|
if receipt.hasStateRoot:
|
||||||
# TODO: Respond to success/failure
|
result.root = some(receipt.stateRoot)
|
||||||
# 1 = success, 0 = failure.
|
else:
|
||||||
result.status = 1
|
# 1 = success, 0 = failure.
|
||||||
|
result.status = some(receipt.status)
|
||||||
|
|
||||||
rpcsrv.rpc("eth_getTransactionReceipt") do(data: HexDataStr) -> ReceiptObject:
|
rpcsrv.rpc("eth_getTransactionReceipt") do(data: HexDataStr) -> ReceiptObject:
|
||||||
## Returns the receipt of a transaction by transaction hash.
|
## Returns the receipt of a transaction by transaction hash.
|
||||||
@ -380,11 +381,12 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
|
|||||||
body = getBlockBody(header.hash)
|
body = getBlockBody(header.hash)
|
||||||
var
|
var
|
||||||
idx = 0
|
idx = 0
|
||||||
cumulativeGas: GasInt
|
prevGasUsed = GasInt(0)
|
||||||
for receipt in chain.getReceipts(header, Receipt):
|
for receipt in chain.getReceipts(header, Receipt):
|
||||||
cumulativeGas += receipt.gasUsed
|
let gasUsed = receipt.cumulativeGasUsed - prevGasUsed
|
||||||
|
prevGasUsed = receipt.cumulativeGasUsed
|
||||||
if idx == txDetails.index:
|
if idx == txDetails.index:
|
||||||
return populateReceipt(receipt, cumulativeGas, body.transactions[txDetails.index], txDetails.index, header)
|
return populateReceipt(receipt, gasUsed, body.transactions[txDetails.index], txDetails.index, header)
|
||||||
idx.inc
|
idx.inc
|
||||||
|
|
||||||
rpcsrv.rpc("eth_getUncleByBlockHashAndIndex") do(data: HexDataStr, quantity: int) -> Option[BlockObject]:
|
rpcsrv.rpc("eth_getUncleByBlockHashAndIndex") do(data: HexDataStr, quantity: int) -> Option[BlockObject]:
|
||||||
|
@ -26,7 +26,7 @@ type
|
|||||||
gasPrice*: GasInt # (optional, default: To-Be-Determined) integer of the gasPrice used for each paid gas.
|
gasPrice*: GasInt # (optional, default: To-Be-Determined) integer of the gasPrice used for each paid gas.
|
||||||
value*: int # (optional) integer of the value sent with this transaction.
|
value*: int # (optional) integer of the value sent with this transaction.
|
||||||
data*: EthHashStr # TODO: Support more data. The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI.
|
data*: EthHashStr # TODO: Support more data. The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI.
|
||||||
nonce*: int # (optional) integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce
|
nonce*: int # (optional) integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce
|
||||||
|
|
||||||
EthCall* = object
|
EthCall* = object
|
||||||
# Parameter from user
|
# Parameter from user
|
||||||
@ -102,8 +102,8 @@ type
|
|||||||
contractAddress*: Option[EthAddress] # the contract address created, if the transaction was a contract creation, otherwise null.
|
contractAddress*: Option[EthAddress] # the contract address created, if the transaction was a contract creation, otherwise null.
|
||||||
logs*: seq[Log] # list of log objects which this transaction generated.
|
logs*: seq[Log] # list of log objects which this transaction generated.
|
||||||
logsBloom*: BloomFilter # bloom filter for light clients to quickly retrieve related logs.
|
logsBloom*: BloomFilter # bloom filter for light clients to quickly retrieve related logs.
|
||||||
root*: Hash256 # post-transaction stateroot (pre Byzantium).
|
root*: Option[Hash256] # post-transaction stateroot (pre Byzantium).
|
||||||
status*: int # 1 = success, 0 = failure.
|
status*: Option[int] # 1 = success, 0 = failure.
|
||||||
|
|
||||||
FilterDataKind* = enum fkItem, fkList
|
FilterDataKind* = enum fkItem, fkList
|
||||||
FilterData* = object
|
FilterData* = object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user