Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds an unsafe flag to transaction workflows to allow bypassing safe-mode restrictions (delegate calls and self-calls).
- Extends the transaction API (
ManagerandTransactions) with anunsafeoption. - Implements safe-mode checks in
Wallet.prepareTransaction, throwing if delegate calls or self-calls occur whenunsafeis unset. - Adds tests to verify that self-calls are rejected in safe mode and allowed in unsafe mode.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/wallet/wdk/test/transactions.test.ts | New tests for rejecting self-calls in safe mode and allowing in unsafe mode |
| packages/wallet/wdk/src/sequence/transactions.ts | Added unsafe option to the requestTransaction method signature |
| packages/wallet/wdk/src/sequence/manager.ts | Updated Manager.request signature to include unsafe |
| packages/wallet/core/src/wallet.ts | Added safe-mode validation logic in prepareTransaction and unsafe option |
Comments suppressed due to low confidence (4)
packages/wallet/wdk/test/transactions.test.ts:465
- [nitpick] The test description mentions 'unsafe transactions' but specifically covers self-calls. Consider renaming to 'Should reject self-call transactions in safe mode' for clarity.
it('Should reject unsafe transactions in safe mode (call to self)', async () => {
packages/wallet/wdk/test/transactions.test.ts:482
- Consider adding a parallel test to verify that
delegateCall: trueis rejected in safe mode, ensuring coverage of both restriction rules.
it('Should allow transactions to self in unsafe mode', async () => {
packages/wallet/core/src/wallet.ts:256
- [nitpick] Capitalize the message and optionally guide override: 'Delegate calls are not allowed in safe mode. To override, set
unsafe: true.'
throw new Error('delegate calls are not allowed in safe mode')
packages/wallet/core/src/wallet.ts:259
- [nitpick] Capitalize the message and suggest override: 'Calls to the wallet contract itself are not allowed in safe mode. To override, set
unsafe: true.'
throw new Error('calls to the wallet contract itself are not allowed in safe mode')
Comment on lines
+249
to
+251
| // If safe mode is set, then we check that the transaction | ||
| // is not "dangerous", aka it does not have any delegate calls | ||
| // or calls to the wallet contract itself |
There was a problem hiding this comment.
[nitpick] Consider replacing the informal 'aka' with 'i.e.' and clarifying: 'When unsafe is unset, disallow delegate calls or self-calls.'
Suggested change
| // If safe mode is set, then we check that the transaction | |
| // is not "dangerous", aka it does not have any delegate calls | |
| // or calls to the wallet contract itself | |
| // If safe mode is set (i.e., when `unsafe` is unset), disallow | |
| // delegate calls and calls to the wallet contract itself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.