nim-ethers/ethers/transaction.nim

40 lines
1.1 KiB
Nim
Raw Normal View History

2022-01-20 11:56:18 +00:00
import pkg/stew/byteutils
import ./basics
type
TransactionType* = enum
Legacy = 0,
AccessList = 1,
Dynamic = 2
Transaction* = object
sender*: ?Address
to*: Address
data*: seq[byte]
value*: UInt256
nonce*: ?UInt256
chainId*: ?UInt256
gasPrice*: ?UInt256
maxFee*: ?UInt256
maxPriorityFee*: ?UInt256
gasLimit*: ?UInt256
transactionType*: ?TransactionType
2022-01-20 11:56:18 +00:00
func `$`*(transaction: Transaction): string =
2022-01-24 13:40:47 +00:00
result = "("
if sender =? transaction.sender:
result &= "from: " & $sender & ", "
result &= "to: " & $transaction.to & ", "
2023-07-03 13:50:24 +00:00
result &= "value: " & $transaction.value & ", "
result &= "data: 0x" & $(transaction.data.toHex)
2022-01-25 09:25:09 +00:00
if nonce =? transaction.nonce:
result &= ", nonce: " & $nonce
2022-01-25 09:25:09 +00:00
if chainId =? transaction.chainId:
result &= ", chainId: " & $chainId
if gasPrice =? transaction.gasPrice:
result &= ", gasPrice: " & $gasPrice
2022-01-25 09:25:09 +00:00
if gasLimit =? transaction.gasLimit:
result &= ", gasLimit: " & $gasLimit
if txType =? transaction.transactionType:
result &= ", type: " & $txType
2022-01-24 13:40:47 +00:00
result &= ")"