nim-ethers/ethers/transaction.nim

32 lines
874 B
Nim
Raw Normal View History

2022-01-20 11:56:18 +00:00
import pkg/stew/byteutils
import ./basics
type Transaction* = object
2022-01-24 13:40:47 +00:00
sender*: ?Address
2022-01-20 11:56:18 +00:00
to*: Address
data*: seq[byte]
2023-07-03 13:50:24 +00:00
value*: UInt256
2022-01-25 09:25:09 +00:00
nonce*: ?UInt256
chainId*: ?UInt256
gasPrice*: ?UInt256
maxFee*: ?UInt256
maxPriorityFee*: ?UInt256
2022-01-25 09:25:09 +00:00
gasLimit*: ?UInt256
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 & ", "
2022-01-24 13:40:47 +00:00
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
2022-01-24 13:40:47 +00:00
result &= ")"