Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(common): allow overriding fees in writeContract and sendTransaction #3288

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading