Update to option types instead of refs
This commit is contained in:
parent
18d62d8c79
commit
f3df5156d9
|
@ -1,9 +1,9 @@
|
|||
import eth_common, hexstrings
|
||||
import eth_common, hexstrings, options
|
||||
|
||||
#[
|
||||
Notes:
|
||||
* Some of the types suppose 'null' when there is no appropriate value.
|
||||
To allow for this, currently these values are refs so the JSON transform can convert to `JNull`.
|
||||
To allow for this, you can use Option[T] or use refs so the JSON transform can convert to `JNull`.
|
||||
* Parameter objects from users must have their data verified so will use EthAddressStr instead of EthAddres, for example
|
||||
* Objects returned to the user can use native Nimbus types, where hexstrings provides converters to hex strings.
|
||||
This is because returned arrays in JSON is
|
||||
|
@ -39,14 +39,14 @@ type
|
|||
|
||||
## A block object, or null when no block was found
|
||||
## Note that this includes slightly different information from eth_common.BlockHeader
|
||||
BlockObject* = ref object
|
||||
BlockObject* = object
|
||||
# Returned to user
|
||||
number*: ref BlockNumber # the block number. null when its pending block.
|
||||
hash*: ref Hash256 # hash of the block. null when its pending block.
|
||||
number*: Option[BlockNumber] # the block number. null when its pending block.
|
||||
hash*: Option[Hash256] # hash of the block. null when its pending block.
|
||||
parentHash*: Hash256 # hash of the parent block.
|
||||
nonce*: uint64 # hash of the generated proof-of-work. null when its pending block.
|
||||
sha3Uncles*: Hash256 # SHA3 of the uncles data in the block.
|
||||
logsBloom*: ref BloomFilter # the bloom filter for the logs of the block. null when its pending block.
|
||||
logsBloom*: Option[BloomFilter] # the bloom filter for the logs of the block. null when its pending block.
|
||||
transactionsRoot*: Hash256 # the root of the transaction trie of the block.
|
||||
stateRoot*: Hash256 # the root of the final state trie of the block.
|
||||
receiptsRoot*: Hash256 # the root of the receipts trie of the block.
|
||||
|
@ -63,47 +63,47 @@ type
|
|||
|
||||
TransactionObject* = object # A transaction object, or null when no transaction was found:
|
||||
# Returned to user
|
||||
hash*: Hash256 # hash of the transaction.
|
||||
nonce*: UInt256 # the number of transactions made by the sender prior to this one.
|
||||
blockHash*: ref Hash256 # hash of the block where this transaction was in. null when its pending.
|
||||
blockNumber*: ref BlockNumber # block number where this transaction was in. null when its pending.
|
||||
transactionIndex*: ref int64 # integer of the transactions index position in the block. null when its pending.
|
||||
source*: EthAddress # address of the sender.
|
||||
to*: ref EthAddress # address of the receiver. null when its a contract creation transaction.
|
||||
value*: UInt256 # value transferred in Wei.
|
||||
gasPrice*: GasInt # gas price provided by the sender in Wei.
|
||||
gas*: GasInt # gas provided by the sender.
|
||||
input*: Blob # the data send along with the transaction.
|
||||
hash*: Hash256 # hash of the transaction.
|
||||
nonce*: UInt256 # the number of transactions made by the sender prior to this one.
|
||||
blockHash*: Option[Hash256] # hash of the block where this transaction was in. null when its pending.
|
||||
blockNumber*: Option[BlockNumber] # block number where this transaction was in. null when its pending.
|
||||
transactionIndex*: Option[int64] # integer of the transactions index position in the block. null when its pending.
|
||||
source*: EthAddress # address of the sender.
|
||||
to*: Option[EthAddress] # address of the receiver. null when its a contract creation transaction.
|
||||
value*: UInt256 # value transferred in Wei.
|
||||
gasPrice*: GasInt # gas price provided by the sender in Wei.
|
||||
gas*: GasInt # gas provided by the sender.
|
||||
input*: Blob # the data send along with the transaction.
|
||||
|
||||
FilterLog* = object
|
||||
# Returned to user
|
||||
removed*: bool # true when the log was removed, due to a chain reorganization. false if its a valid log.
|
||||
logIndex*: ref int # integer of the log index position in the block. null when its pending log.
|
||||
transactionIndex*: ref int # integer of the transactions index position log was created from. null when its pending log.
|
||||
transactionHash*: ref Hash256 # hash of the transactions this log was created from. null when its pending log.
|
||||
blockHash*: ref Hash256 # hash of the block where this log was in. null when its pending. null when its pending log.
|
||||
blockNumber*: ref BlockNumber # the block number where this log was in. null when its pending. null when its pending log.
|
||||
address*: EthAddress # address from which this log originated.
|
||||
data*: seq[Hash256] # contains one or more 32 Bytes non-indexed arguments of the log.
|
||||
topics*: array[4, Hash256] # array of 0 to 4 32 Bytes DATA of indexed log arguments.
|
||||
# (In solidity: The first topic is the hash of the signature of the event.
|
||||
# (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
|
||||
removed*: bool # true when the log was removed, due to a chain reorganization. false if its a valid log.
|
||||
logIndex*: Option[int] # integer of the log index position in the block. null when its pending log.
|
||||
transactionIndex*: Option[int] # integer of the transactions index position log was created from. null when its pending log.
|
||||
transactionHash*: Option[Hash256] # hash of the transactions this log was created from. null when its pending log.
|
||||
blockHash*: Option[Hash256] # hash of the block where this log was in. null when its pending. null when its pending log.
|
||||
blockNumber*: Option[BlockNumber] # the block number where this log was in. null when its pending. null when its pending log.
|
||||
address*: EthAddress # address from which this log originated.
|
||||
data*: seq[Hash256] # contains one or more 32 Bytes non-indexed arguments of the log.
|
||||
topics*: array[4, Hash256] # array of 0 to 4 32 Bytes DATA of indexed log arguments.
|
||||
# (In solidity: The first topic is the hash of the signature of the event.
|
||||
# (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
|
||||
|
||||
ReceiptObject* = object
|
||||
# A transaction receipt object, or null when no receipt was found:
|
||||
transactionHash*: Hash256 # hash of the transaction.
|
||||
transactionIndex*: int # integer of the transactions index position in the block.
|
||||
blockHash*: Hash256 # hash of the block where this transaction was in.
|
||||
blockNumber*: BlockNumber # block number where this transaction was in.
|
||||
sender*: EthAddress # address of the sender.
|
||||
to*: ref EthAddress # address of the receiver. null when its a contract creation transaction.
|
||||
cumulativeGasUsed*: GasInt # the total amount of gas used when this transaction was executed in the block.
|
||||
gasUsed*: GasInt # the amount of gas used by this specific transaction alone.
|
||||
contractAddress*: ref 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.
|
||||
logsBloom*: BloomFilter # bloom filter for light clients to quickly retrieve related logs.
|
||||
root*: Hash256 # post-transaction stateroot (pre Byzantium).
|
||||
status*: int # 1 = success, 0 = failure.
|
||||
transactionHash*: Hash256 # hash of the transaction.
|
||||
transactionIndex*: int # integer of the transactions index position in the block.
|
||||
blockHash*: Hash256 # hash of the block where this transaction was in.
|
||||
blockNumber*: BlockNumber # block number where this transaction was in.
|
||||
sender*: EthAddress # address of the sender.
|
||||
to*: Option[EthAddress] # address of the receiver. null when its a contract creation transaction.
|
||||
cumulativeGasUsed*: GasInt # the total amount of gas used when this transaction was executed in the block.
|
||||
gasUsed*: GasInt # the amount of gas used by this specific transaction alone.
|
||||
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.
|
||||
logsBloom*: BloomFilter # bloom filter for light clients to quickly retrieve related logs.
|
||||
root*: Hash256 # post-transaction stateroot (pre Byzantium).
|
||||
status*: int # 1 = success, 0 = failure.
|
||||
|
||||
FilterDataKind* = enum fkItem, fkList
|
||||
FilterData* = object
|
||||
|
|
Loading…
Reference in New Issue