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
|
2022-07-12 18:22:31 +00:00
|
|
|
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:
|
2023-09-14 23:54:08 +00:00
|
|
|
result &= ", nonce: " & $nonce
|
2022-01-25 09:25:09 +00:00
|
|
|
if chainId =? transaction.chainId:
|
|
|
|
result &= ", chainId: " & $chainId
|
|
|
|
if gasPrice =? transaction.gasPrice:
|
2023-09-14 23:54:08 +00:00
|
|
|
result &= ", gasPrice: " & $gasPrice
|
2022-01-25 09:25:09 +00:00
|
|
|
if gasLimit =? transaction.gasLimit:
|
2023-09-14 23:54:08 +00:00
|
|
|
result &= ", gasLimit: " & $gasLimit
|
2022-01-24 13:40:47 +00:00
|
|
|
result &= ")"
|