Skip to content

Commit

Permalink
fix(common): allow overriding fees in writeContract and sendTransacti…
Browse files Browse the repository at this point in the history
…on (#3288)
  • Loading branch information
alvrs authored Oct 14, 2024
1 parent af72530 commit fe98442
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/spotty-crabs-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@latticexyz/common": patch
---

The `transactionQueue` decorator internally keeps an updated reference for the recommended `baseFeePerGas` and `maxPriorityFeePerGas` from the connected chain to avoid having to fetch it right before sending a transaction.
However, due to the way the fee values were overridden, it wasn't possible for users to explicitly pass in custom fee values.
Now explicitly provided fee values have precedence over the internally estimated fee values.
2 changes: 1 addition & 1 deletion packages/common/src/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export async function sendTransaction<
const params = {
// viem_sendTransaction internally estimates gas, which we want to happen on the pending block
blockTag: "pending",
...feeRef.fees,
...request,
nonce,
...feeRef.fees,
} as const satisfies SendTransactionParameters<chain, account, chainOverride, request>;
debug("sending tx to", request.to, "with nonce", nonce);
return await getAction(client, viem_sendTransaction, "sendTransaction")(params as never);
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/writeContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export async function writeContract<
const params = {
// viem_writeContract internally estimates gas, which we want to happen on the pending block
blockTag: "pending",
...feeRef.fees,
...request,
nonce,
...feeRef.fees,
} as const satisfies WriteContractParameters<abi, functionName, args, chain, account, chainOverride>;
debug("calling", params.functionName, "at", params.address, "with nonce", nonce);
return await getAction(client, viem_writeContract, "writeContract")(params as never);
Expand Down

0 comments on commit fe98442

Please sign in to comment.