status-lib/status/types/transaction.nim

43 lines
1.7 KiB
Nim
Raw Normal View History

2021-09-08 18:05:39 +00:00
{.used.}
import strutils
2021-09-10 17:27:49 +00:00
import web3/ethtypes, options, stint
2021-09-08 18:05:39 +00:00
include pending_transaction_type
type
Transaction* = ref object
id*: string
typeValue*: string
address*: string
blockNumber*: string
blockHash*: string
contract*: string
timestamp*: string
gasPrice*: string
gasLimit*: string
gasUsed*: string
nonce*: string
txStatus*: string
value*: string
fromAddress*: string
to*: string
2021-09-10 17:27:49 +00:00
type
TransactionData* = object
source*: Address # the address the transaction is send from.
to*: Option[Address] # (optional when creating new contract) the address the transaction is directed to.
gas*: Option[Quantity] # (optional, default: 90000) integer of the gas provided for the transaction execution. It will return unused gas.
gasPrice*: Option[int] # (optional, default: To-Be-Determined) integer of the gasPrice used for each paid gas.
maxPriorityFeePerGas*: Option[Uint256]
maxFeePerGas*: Option[Uint256]
value*: Option[Uint256] # (optional) integer of the value sent with this transaction.
data*: string # the compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI.
nonce*: Option[Nonce] # (optional) integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce
txType*: string
2021-09-08 18:05:39 +00:00
proc cmpTransactions*(x, y: Transaction): int =
# Sort proc to compare transactions from a single account.
# Compares first by block number, then by nonce
result = cmp(x.blockNumber.parseHexInt, y.blockNumber.parseHexInt)
if result == 0:
result = cmp(x.nonce, y.nonce)