Skip gas estimation on sign tx - #802
Conversation
WalkthroughThis pull request modifies the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant PayoutUtil
Caller->>PayoutUtil: getExecutePayoutSafeTransaction(..., skipGasEstimation)
alt skipGasEstimation = true
PayoutUtil->>PayoutUtil: Set options = { safeTxGas: "200000" }
else skipGasEstimation = false
PayoutUtil->>PayoutUtil: Set options = undefined
end
PayoutUtil->>Caller: Return transaction object
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/shared/src/utils/payouts.utils.ts (3)
60-61: Consider a more descriptive parameter name and add documentation.The parameter name
signOnlyis somewhat clear but could be more descriptive. Consider renaming it toskipGasEstimationto better reflect its purpose. Additionally, adding a JSDoc comment would help explain the parameter's purpose and usage.export const getExecutePayoutSafeTransaction = async ( providerUrl: string, committee: string, - payout: IPayoutResponse, - signOnly: boolean = false + payout: IPayoutResponse, + skipGasEstimation: boolean = false ): Promise<{ tx: SafeTransaction; txHash: string }> => {With documentation:
+/** + * Creates a Safe transaction to execute a payout + * @param providerUrl The URL of the provider + * @param committee The address of the committee Safe + * @param payout The payout response object + * @param skipGasEstimation If true, uses a fixed gas value instead of estimating gas + * @returns The Safe transaction and transaction hash + */ export const getExecutePayoutSafeTransaction = async ( providerUrl: string, committee: string, payout: IPayoutResponse, - signOnly: boolean = false + skipGasEstimation: boolean = false ): Promise<{ tx: SafeTransaction; txHash: string }> => {
115-115: Extract magic number to a named constant.The fixed gas value
"200000"is a magic number that should be extracted to a named constant at the top of the file for better maintainability and documentation.+// Safe gas estimation default value when skipping gas estimation +const DEFAULT_SAFE_TX_GAS = "200000"; export const getExecutePayoutSafeTransaction = async ( providerUrl: string, committee: string, payout: IPayoutResponse, - signOnly: boolean = false + skipGasEstimation: boolean = false ): Promise<{ tx: SafeTransaction; txHash: string }> => { // ... const safeTransaction = await protocolKit.createTransaction({ transactions: [ { to: contractAddress, data: encodedExecPayoutData, value: "0", }, ], - options: signOnly ? { safeTxGas: "200000" } : undefined, + options: skipGasEstimation ? { safeTxGas: DEFAULT_SAFE_TX_GAS } : undefined, });
254-254: Replace duplicate magic number with the same constant.For consistency, use the same named constant here as well.
const safeTransaction = await protocolKit.createTransaction({ transactions: [ { to: paymentSplitterFactoryAddress, data: encodedPaymentSplitterCreation, value: "0", }, { to: vaultContract.address, data: encodedExecutePayout, value: "0", }, ], - options: signOnly ? { safeTxGas: "200000" } : undefined, + options: skipGasEstimation ? { safeTxGas: DEFAULT_SAFE_TX_GAS } : undefined, });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/shared/src/utils/payouts.utils.ts(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/shared/src/utils/payouts.utils.ts (1)
packages/shared/src/types/payout.ts (1)
IPayoutResponse(28-43)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
packages/shared/src/utils/payouts.utils.ts (1)
57-62:Details
❓ Verification inconclusive
Verify impact of providing fixed gas value.
Providing a fixed gas value might lead to failed transactions if the actual gas required exceeds this value. Consider if this is an acceptable trade-off for your use case, especially for more complex transactions like split payouts that might require more gas.
🏁 Script executed:
#!/bin/bash # Look for other occurrences of safeTxGas in the codebase to understand common usage patterns rg "safeTxGas" --type tsLength of output: 520
Evaluate the fixed gas value for signOnly transactions
The function currently uses a hardcoded
safeTxGasvalue of"200000"whensignOnlyis true. A search in the codebase confirms that this fixed value is consistently used (see occurrences inpackages/shared/src/utils/payouts.utils.tsand the type definition inpackages/shared/src/types/safe.ts). However, this fixed gas value might not cover complex scenarios—such as split payouts—where the actual gas requirement could exceed 200,000, leading to potential transaction failures.
- Action Items:
- Confirm that the fixed
safeTxGasvalue is sufficient for all intended transaction types.- Consider implementing a dynamic gas estimation or a fallback mechanism if future transactions are expected to be more complex.
Deploying dapp with
|
| Latest commit: |
76d56d3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f1f6369a.dapp-a9y.pages.dev |
| Branch Preview URL: | https://skip-gas-estimation-on-sign.dapp-a9y.pages.dev |
Summary by CodeRabbit
New Features
Chores
.envto the.gitignorefile to prevent it from being tracked by Git.Bug Fixes
LOGROCKET_APP_ID, streamlining application configuration by eliminating unused constants.