mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-03 14:13:10 +00:00
* Add EIP-1559 implementation for gas price * Improve logs * Improve comment * Rename maxFee and maxPriorityFee to use official EIP-1559 names * Delete gas price when using EIP-1559 * Allow override maxFeePerGas * Code style * Remove useless specific EIP1559 test because Hardhart support it so all transactions are using EIP1559 by default * Restore test to check legacy transaction * Update after rebase * Call eth_maxPriorityFeePerGas and returns a manual defined maxPriorityFeePerGas as a fallback * Catch JsonRpcProviderError instead of ProviderError * Improve readability * Set none value for maxFeePerGas in case of non EIP-1559 transaction * Assign none to maxPriorityFeePerGas for non EIP-1559 transaction to avoid potential side effect in wallet signing * Remove upper bound version for stew and update contractabi
41 lines
1.2 KiB
Nim
41 lines
1.2 KiB
Nim
import pkg/serde
|
|
import pkg/stew/byteutils
|
|
import ./basics
|
|
|
|
type
|
|
TransactionType* = enum
|
|
Legacy = 0,
|
|
AccessList = 1,
|
|
Dynamic = 2
|
|
Transaction* {.serialize.} = object
|
|
sender* {.serialize("from").}: ?Address
|
|
to*: Address
|
|
data*: seq[byte]
|
|
value*: UInt256
|
|
nonce*: ?UInt256
|
|
chainId*: ?UInt256
|
|
gasPrice*: ?UInt256
|
|
maxPriorityFeePerGas*: ?UInt256
|
|
maxFeePerGas*: ?UInt256
|
|
gasLimit*: ?UInt256
|
|
transactionType* {.serialize("type").}: ?TransactionType
|
|
|
|
func `$`*(transaction: Transaction): string =
|
|
result = "("
|
|
if sender =? transaction.sender:
|
|
result &= "from: " & $sender & ", "
|
|
result &= "to: " & $transaction.to & ", "
|
|
result &= "value: " & $transaction.value & ", "
|
|
result &= "data: 0x" & $(transaction.data.toHex)
|
|
if nonce =? transaction.nonce:
|
|
result &= ", nonce: " & $nonce
|
|
if chainId =? transaction.chainId:
|
|
result &= ", chainId: " & $chainId
|
|
if gasPrice =? transaction.gasPrice:
|
|
result &= ", gasPrice: " & $gasPrice
|
|
if gasLimit =? transaction.gasLimit:
|
|
result &= ", gasLimit: " & $gasLimit
|
|
if txType =? transaction.transactionType:
|
|
result &= ", type: " & $txType
|
|
result &= ")"
|