Rename maxFee and maxPriorityFee to use official EIP-1559 names

This commit is contained in:
Arnaud 2025-04-02 09:43:16 +02:00
parent f71f5bd11b
commit 8750c66a44
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F
5 changed files with 14 additions and 18 deletions

View File

@ -33,9 +33,8 @@ type
nonce*: ?UInt256 nonce*: ?UInt256
chainId*: ?UInt256 chainId*: ?UInt256
gasPrice*: ?UInt256 gasPrice*: ?UInt256
maxFee*: ?UInt256
maxPriorityFee*: ?UInt256
maxPriorityFeePerGas*: ?UInt256 maxPriorityFeePerGas*: ?UInt256
maxFeePerGas*: ?UInt256
gasLimit*: ?UInt256 gasLimit*: ?UInt256
CallOverrides* = ref object of TransactionOverrides CallOverrides* = ref object of TransactionOverrides
blockTag*: ?BlockTag blockTag*: ?BlockTag
@ -81,8 +80,7 @@ proc createTransaction(contract: Contract,
nonce: overrides.nonce, nonce: overrides.nonce,
chainId: overrides.chainId, chainId: overrides.chainId,
gasPrice: overrides.gasPrice, gasPrice: overrides.gasPrice,
maxFee: overrides.maxFee, maxFeePerGas: overrides.maxFeePerGas,
maxPriorityFee: overrides.maxPriorityFee,
maxPriorityFeePerGas: overrides.maxPriorityFeePerGas, maxPriorityFeePerGas: overrides.maxPriorityFeePerGas,
gasLimit: overrides.gasLimit, gasLimit: overrides.gasLimit,
) )

View File

@ -32,11 +32,11 @@ func toSignableTransaction(transaction: Transaction): SignableTransaction =
signable.value = transaction.value signable.value = transaction.value
signable.payload = transaction.data signable.payload = transaction.data
if maxFee =? transaction.maxFee and if maxFeePerGas =? transaction.maxFeePerGas and
maxPriorityFee =? transaction.maxPriorityFee: maxPriorityFeePerGas =? transaction.maxPriorityFeePerGas:
signable.txType = TxEip1559 signable.txType = TxEip1559
signable.maxFeePerGas = GasInt(maxFee.truncate(uint64)) signable.maxFeePerGas = GasInt(maxFeePerGas.truncate(uint64))
signable.maxPriorityFeePerGas = GasInt(maxPriorityFee.truncate(uint64)) signable.maxPriorityFeePerGas = GasInt(maxPriorityFeePerGas.truncate(uint64))
elif gasPrice =? transaction.gasPrice: elif gasPrice =? transaction.gasPrice:
signable.txType = TxLegacy signable.txType = TxLegacy
signable.gasPrice = GasInt(gasPrice.truncate(uint64)) signable.gasPrice = GasInt(gasPrice.truncate(uint64))

View File

@ -15,8 +15,6 @@ type
nonce*: ?UInt256 nonce*: ?UInt256
chainId*: ?UInt256 chainId*: ?UInt256
gasPrice*: ?UInt256 gasPrice*: ?UInt256
maxFee*: ?UInt256
maxPriorityFee*: ?UInt256
maxPriorityFeePerGas*: ?UInt256 maxPriorityFeePerGas*: ?UInt256
maxFeePerGas*: ?UInt256 maxFeePerGas*: ?UInt256
gasLimit*: ?UInt256 gasLimit*: ?UInt256

View File

@ -107,17 +107,17 @@ for url in ["ws://" & providerUrl, "http://" & providerUrl]:
check (await token.connect(provider).balanceOf(accounts[1])) == 25.u256 check (await token.connect(provider).balanceOf(accounts[1])) == 25.u256
check (await token.connect(provider).balanceOf(accounts[2])) == 25.u256 check (await token.connect(provider).balanceOf(accounts[2])) == 25.u256
test "takes custom values for nonce, gasprice and gaslimit": test "takes custom values for nonce, gasprice and maxPriorityFeePerGas":
let overrides = TransactionOverrides( let overrides = TransactionOverrides(
nonce: some 100.u256, nonce: some 100.u256,
gasPrice: some 200.u256, maxPriorityFeePerGas: some 200.u256,
gasLimit: some 300.u256 gasLimit: some 300.u256
) )
let signer = MockSigner.new(provider) let signer = MockSigner.new(provider)
discard await token.connect(signer).mint(accounts[0], 42.u256, overrides) discard await token.connect(signer).mint(accounts[0], 42.u256, overrides)
check signer.transactions.len == 1 check signer.transactions.len == 1
check signer.transactions[0].nonce == overrides.nonce check signer.transactions[0].nonce == overrides.nonce
check signer.transactions[0].gasPrice == overrides.gasPrice check signer.transactions[0].maxPriorityFeePerGas == overrides.maxPriorityFeePerGas
check signer.transactions[0].gasLimit == overrides.gasLimit check signer.transactions[0].gasLimit == overrides.gasLimit
test "can call functions for different block heights": test "can call functions for different block heights":

View File

@ -80,8 +80,8 @@ suite "Wallet":
to: wallet.address, to: wallet.address,
nonce: some 0.u256, nonce: some 0.u256,
chainId: some 31337.u256, chainId: some 31337.u256,
maxFee: some 2_000_000_000.u256, maxFeePerGas: some 2_000_000_000.u256,
maxPriorityFee: some 1_000_000_000.u256, maxPriorityFeePerGas: some 1_000_000_000.u256,
gasLimit: some 21_000.u256 gasLimit: some 21_000.u256
) )
let signedTx = await wallet.signTransaction(tx) let signedTx = await wallet.signTransaction(tx)
@ -105,7 +105,7 @@ suite "Wallet":
let wallet = !Wallet.new(pk_with_funds, provider) let wallet = !Wallet.new(pk_with_funds, provider)
let overrides = TransactionOverrides( let overrides = TransactionOverrides(
nonce: some 0.u256, nonce: some 0.u256,
gasPrice: some 1_000_000_000.u256, maxPriorityFeePerGas: some 1_000_000_000.u256,
gasLimit: some 22_000.u256) gasLimit: some 22_000.u256)
let testToken = Erc20.new(wallet.address, wallet) let testToken = Erc20.new(wallet.address, wallet)
await testToken.transfer(wallet.address, 24.u256, overrides) await testToken.transfer(wallet.address, 24.u256, overrides)
@ -115,8 +115,8 @@ suite "Wallet":
let wallet = !Wallet.new(pk_with_funds, provider) let wallet = !Wallet.new(pk_with_funds, provider)
let overrides = TransactionOverrides( let overrides = TransactionOverrides(
nonce: some 0.u256, nonce: some 0.u256,
maxFee: some 1_000_000_000.u256, maxFeePerGas: some 1_000_000_000.u256,
maxPriorityFee: some 1_000_000_000.u256, maxPriorityFeePerGas: some 1_000_000_000.u256,
gasLimit: some 22_000.u256) gasLimit: some 22_000.u256)
let testToken = Erc20.new(wallet.address, wallet) let testToken = Erc20.new(wallet.address, wallet)
await testToken.transfer(wallet.address, 24.u256, overrides) await testToken.transfer(wallet.address, 24.u256, overrides)