-
Notifications
You must be signed in to change notification settings - Fork 26
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
add txServiceUrl in safe config #253
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes in this pull request encompass updates to several files, primarily focusing on the Changes
Possibly related PRs
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
src/evm/schemas/multisig.ts(node:10249) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///eslint.config.js?mtime=1731520853630 is not specified and it doesn't parse as CommonJS. Oops! Something went wrong! :( ESLint: 8.57.1 TypeError: Key "rules": Key "@typescript-eslint/quotes": Could not find "quotes" in plugin "@typescript-eslint". Did you mean "@/quotes"? Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (9)
src/scripts/execute-multisig-tx.ts (1)
24-27
: Consider adding logging for better operational visibility.Since this is a CLI script handling critical multisig operations, it would be helpful to add logging statements that indicate:
- The transaction being executed (txIndex)
- The multisig account being used
- The RPC endpoint being used
Example addition:
+ console.log(`Executing transaction ${txIndex} for multisig ${multisigAccount.address} via RPC ${rpcUrl}`); executeMultisigTx( multisigAccount, rpcUrl, txIndex );
src/evm/schemas/multisig.ts (2)
21-21
: Consider adding URL validation and documentation.While the
txServiceUrl
addition is well-typed, consider enhancing it with:
- URL format validation using Zod's string validation
- JSDoc comments describing the expected URL format and usage
- txServiceUrl: z.string().optional(), + /** Safe transaction service URL (e.g., https://safe-transaction-mainnet.safe.global) + * @see https://docs.safe.global/safe-core-api/available-services + */ + txServiceUrl: z.string().url().optional(),
41-41
: Maintain consistent validation with config schema.The
txServiceUrl
validation should match the config schema for consistency.- txServiceUrl: z.string().optional(), + /** Safe transaction service URL (e.g., https://safe-transaction-mainnet.safe.global) + * @see https://docs.safe.global/safe-core-api/available-services + */ + txServiceUrl: z.string().url().optional(),src/multisig/safe.ts (4)
60-60
: Fix console.log output.The log statement will print
[object Object]
fortxProposer
. Consider logging relevant properties instead.- `proposing transaction from ${txProposer} @safe ${initializedMultisig.safeAddress} + `proposing transaction from safe ${initializedMultisig.safeAddress}
99-103
: Remove redundant return type annotation.The Promise return type annotation is redundant as TypeScript can infer it from the async function.
- ):Promise<TransactionResult> => { + ) => {
104-105
: Consider adding error handling for API initialization.The code assumes the Safe API kit initialization will always succeed. Consider adding error handling to provide better feedback when the service is unavailable.
+ try { const apiKit = new SafeApiKit({ chainId: BigInt(initializedMultisig.chainId), txServiceUrl: initializedMultisig.txServiceUrl, }); + } catch (error) { + throw new Error(`Failed to initialize Safe API kit: ${error.message}`); + }Also applies to: 110-111, 114-114
42-50
: Add JSDoc documentation for txServiceUrl.Since this PR introduces support for custom transaction service URLs, consider adding documentation explaining the purpose and expected format of
txServiceUrl
./** * - * @param data Propose a transaction from a signer account + * @param initializedMultisig Configuration object containing Safe details + * @param initializedMultisig.txServiceUrl Optional URL for the transaction service. + * If not provided, defaults to Safe's transaction service. * @param toAddress Destination address for the transaction * @param txData Transaction data */src/tx.ts (2)
79-84
: Consider adding URL validation for txServiceUrl.Since we're now supporting custom transaction service URLs through the account object, it would be good to validate the URL format before attempting to use it.
proposeTransaction( account, deployedContractAddress, callData, chain.rpc, updatedNonces[account.safeAddress] + ).catch(error => { + if (error.message.includes('txServiceUrl')) { + throw new Error(`Invalid transaction service URL in account config: ${error.message}`); + } + throw error; + });
Line range hint
78-85
: Add documentation for txServiceUrl configuration.Since this change introduces support for custom transaction service URLs, it would be helpful to add code comments explaining:
- The purpose of custom txServiceUrl
- When and why it might be needed
- Example configuration
+ // Propose the transaction using the Safe transaction service. + // If a custom txServiceUrl is configured in the account, it will be used instead of + // the default Safe transaction service. This is useful when working with custom + // deployments of the Safe infrastructure. proposeTransaction( account, deployedContractAddress, callData, chain.rpc, updatedNonces[account.safeAddress] );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
package.json
(1 hunks)src/evm/schemas/multisig.ts
(2 hunks)src/multisig/safe.ts
(4 hunks)src/scripts/execute-multisig-tx.ts
(1 hunks)src/tx.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- package.json
🔇 Additional comments (5)
src/scripts/execute-multisig-tx.ts (1)
24-27
: LGTM! Parameter consolidation improves safety and extensibility.
The change to pass the entire multisigAccount
object instead of individual parameters is a good improvement. It:
- Encapsulates all multisig-related configuration
- Enables the addition of custom txServiceUrl support
- Reduces the risk of parameter mishandling
src/multisig/safe.ts (2)
4-4
: LGTM! Import changes are well-structured.
The new imports for MetaTransactionData
and InitializedMultisig
are properly organized and align with the refactoring changes.
Also applies to: 10-10
42-42
: Verify txServiceUrl availability before usage.
The function should validate that txServiceUrl
is available before using it, as it's an optional property in the schema.
Also applies to: 50-50, 51-51
src/tx.ts (2)
79-84
: LGTM! Good refactoring to improve encapsulation.
The change to pass the complete account
object instead of individual parameters is a good improvement. This approach allows for better extensibility (like adding txServiceUrl) while maintaining type safety through isInitializedMultisig
.
79-84
: Verify consistent usage of new account object pattern.
Let's verify that all other files calling proposeTransaction
have been updated to use the new pattern of passing the complete account object.
✅ Verification successful
Let me gather more context about these usages to verify the pattern.
Let me check the account object pattern by looking at the type definition and its usage.
Let me try a different approach to understand the account object structure.
Let me check one final thing to understand the relationship between the implementation and usage.
Based on the gathered information, I can now provide the final response:
The account object pattern is consistently implemented across the codebase
The verification shows that:
- The
proposeTransaction
function insrc/multisig/safe.ts
is the main implementation that acceptsInitializedMultisig
type - The calling code in
src/tx.ts
correctly passes the account object with the expected properties (as seen inaccount.safeAddress
usage) - There are no other direct calls to
proposeTransaction
in the codebase that would need updating
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for all calls to proposeTransaction to ensure they use the new pattern
rg "proposeTransaction\(" --type ts
Length of output: 193
Script:
#!/bin/bash
# Get more context around proposeTransaction calls
rg "proposeTransaction\(" --type ts -B 5 -A 5
Length of output: 1535
Script:
#!/bin/bash
# Look for InitializedMultisig type definition and usage
ast-grep --pattern 'type InitializedMultisig = {
$$$
}'
# Also get the context of the account parameter usage
rg "account: InitializedMultisig" --type ts -B 2 -A 2
Length of output: 115
Script:
#!/bin/bash
# Look for the account type/interface definition
rg "interface.*Multisig" --type ts -B 2 -A 5
# Also check the actual usage in tx.ts
rg "account\." --type ts -B 2 -A 2 src/tx.ts
Length of output: 503
Script:
#!/bin/bash
# Look at the full implementation of proposeTransaction in safe.ts
rg "export.*proposeTransaction" --type ts -B 10 -A 30 src/multisig/safe.ts
# And check for any type definitions related to the account
rg "type.*safe" --type ts -i
Length of output: 1185
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are txServiceUrls "trustworthy"?
I think they are, because they tend to be operated by chains themselves (e.g. the urls are superchain or gobob.xyz) But also, we don't need a lot of trust assumptions here. We only use this api service to sign and persist transactions which we can assume are public. So since there aren't any concerns with leaking the info we send them (in fact, the last step is broadcasting the signed tx publicly), the only way they could grief us is through losing our txs. But that seems unlikely |
2e4b040
to
0ca3824
Compare
PR to add support for directly integrating wiht tx service urls that aren't the default operated by safe.
this is required for adding multisig to bob & mode
Summary by CodeRabbit
Release Notes
New Features
txServiceUrl
property in multisig configuration schemas for enhanced flexibility.Improvements
proposeTransaction
andexecuteMultisigTx
, consolidating multisig configuration into a single object.Bug Fixes