-
Notifications
You must be signed in to change notification settings - Fork 629
Fetch minimal account address from bundler #7919
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
Fetch minimal account address from bundler #7919
Conversation
|
Cursor Agent can help with this pull request. Just |
|
WalkthroughResolves delegation contract via bundler RPC with 24h caching and uses it in 7702 minimal account detection, signing, and transaction construction; updates MinimalAccount ABI (events, errors, receiver callbacks, supportsInterface, receive, executeWithSig); and updates generated event arg names (signer → newSigner) and tests to match. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant A as create7702MinimalAccount
participant D as getDelegationContractAddress
participant Cache as Cache (24h)
participant B as Bundler RPC
participant I as is7702MinimalAccount
participant S as Signer/Wallet
participant N as Network
C->>A: start minimal account flow
A->>D: request delegationContractAddress
alt cached
D->>Cache: lookup
Cache-->>D: address
else miss
D->>B: tw_getDelegationContract
B-->>D: { delegationContract }
D->>Cache: store (24h)
end
D-->>A: delegationContractAddress
A->>I: compare account target vs delegationContractAddress
I-->>A: isMinimal
A->>S: sign authorization using delegationContractAddress
Note over A,S: addresses normalized via getAddress(...)
alt sponsorGas
A->>N: submit sponsored tx (target = normalized to)
N-->>A: result
else user-pays
A->>N: get nonce (normalized address)
A->>N: submit tx (target = normalized to)
N-->>A: result
end
A-->>C: return setup/tx result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
size-limit report 📦
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7919 +/- ##
==========================================
+ Coverage 56.53% 56.54% +0.01%
==========================================
Files 904 904
Lines 58626 58677 +51
Branches 4146 4150 +4
==========================================
+ Hits 33145 33181 +36
- Misses 25375 25389 +14
- Partials 106 107 +1
🚀 New features to boost your workflow:
|
packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts
Outdated
Show resolved
Hide resolved
packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts
Outdated
Show resolved
Hide resolved
Merge activity
|
``` <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Replaces the hardcoded `MINIMAL_ACCOUNT_IMPLEMENTATION_ADDRESS` with a dynamic fetch from the bundler using the `tw_getDelegationContract` RPC method. This change: - Introduces an async function `getDelegationContractAddress` to fetch the address. - Implements caching for the fetched address to prevent redundant RPC calls. - Updates `_sendTxWithAuthorization` and `is7702MinimalAccount` to handle the async nature and use the dynamically fetched address. - Ensures type safety for address fields. ## How to test Unit tests cover the functionality. A temporary test was created and verified during development. ``` pnpm test packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts ``` --> ``` --- [Slack Thread](https://thirdwebdev.slack.com/archives/C085FEPFLN9/p1756220164604699?thread_ts=1756220164.604699&cid=C085FEPFLN9) <a href="https://cursor.com/background-agent?bcId=bc-874d9753-17ac-4429-8dfb-c3d6776f6711"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"> <img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"> </picture> </a> <a href="https://cursor.com/agents?id=bc-874d9753-17ac-4429-8dfb-c3d6776f6711"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"> <img alt="Open in Web" src="https://cursor.com/open-in-web.svg"> </picture> </a> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the `MinimalAccount` implementation in the `erc7702` extension of the `thirdweb` package. It includes changes to event signatures, function inputs/outputs, and the addition of a delegation contract feature for improved account management. ### Detailed summary - Updated event signatures in `Executed.ts`, `SessionCreated.ts`, and `ValueReceived.ts` to use `user` and `newSigner` instead of `signer`. - Modified function inputs/outputs in multiple files to maintain consistency with new event structures. - Introduced `getDelegationContractAddress` function to fetch delegation contract addresses from the bundler. - Adjusted `create7702MinimalAccount` to utilize the new delegation contract address. - Enhanced error handling in delegation contract fetching. - Updated `execute` and `executeWithSig` methods to accommodate new input structures. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Minimal account updated: token-receiver callbacks, interface support check, payable receive, new executeWithSig entrypoint, and a ValueReceived event; SessionCreated/Executed events now include user/newSigner. - Bug Fixes - Delegation contract resolved dynamically via bundler with caching and improved error handling. - Address normalization for transactions and nonce lookups to reduce mismatch errors. - Removed a redundant error from the ABI. - Tests - Tests updated to assert renamed event fields (user/newSigner). <!-- end of auto-generated comment: release notes by coderabbit.ai -->
6d09a4c to
3227995
Compare
``` <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Replaces the hardcoded `MINIMAL_ACCOUNT_IMPLEMENTATION_ADDRESS` with a dynamic fetch from the bundler using the `tw_getDelegationContract` RPC method. This change: - Introduces an async function `getDelegationContractAddress` to fetch the address. - Implements caching for the fetched address to prevent redundant RPC calls. - Updates `_sendTxWithAuthorization` and `is7702MinimalAccount` to handle the async nature and use the dynamically fetched address. - Ensures type safety for address fields. ## How to test Unit tests cover the functionality. A temporary test was created and verified during development. ``` pnpm test packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts ``` --> ``` --- [Slack Thread](https://thirdwebdev.slack.com/archives/C085FEPFLN9/p1756220164604699?thread_ts=1756220164.604699&cid=C085FEPFLN9) <a href="https://cursor.com/background-agent?bcId=bc-874d9753-17ac-4429-8dfb-c3d6776f6711"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"> <img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"> </picture> </a> <a href="https://cursor.com/agents?id=bc-874d9753-17ac-4429-8dfb-c3d6776f6711"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"> <img alt="Open in Web" src="https://cursor.com/open-in-web.svg"> </picture> </a> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the `erc7702` extension, refining event filters, and modifying function signatures to enhance clarity and correctness. It also introduces delegation contract handling in the `minimal-account` implementation. ### Detailed summary - Updated function signatures and event filters in multiple files to replace `signer` with `user` and `newSigner`. - Improved data structures in the generated files for `MinimalAccount`. - Added delegation contract address fetching in `minimal-account.ts`. - Adjusted transaction handling logic to use the delegation contract address. - Enhanced error handling for RPC responses. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Minimal account updated: token-receiver callbacks, interface support check, payable receive, new executeWithSig entrypoint, and a ValueReceived event; SessionCreated/Executed events now include user/newSigner. - Bug Fixes - Delegation contract resolved dynamically via bundler with caching and improved error handling. - Address normalization for transactions and nonce lookups to reduce mismatch errors. - Removed a redundant error from the ABI. - Tests - Tests updated to assert renamed event fields (user/newSigner). <!-- end of auto-generated comment: release notes by coderabbit.ai -->
3227995 to
bb89561
Compare
pnpm test packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts
Slack Thread
PR-Codex overview
This PR focuses on updating the
erc7702extension in thethirdwebSDK by refining event filters, input/output structures, and enhancing the handling of delegation contracts in the minimal account implementation.Detailed summary
ExecutedEventFilters,SessionCreatedEventFilters, andValueReceivedEventFilters.signertonewSigner).getTransferPoliciesForSigner,getSessionStateForSigner, andcreateSessionWithSig.getDelegationContractAddressfor fetching delegation contract addresses.create7702MinimalAccountto incorporate delegation contract handling.Summary by CodeRabbit
New Features
Bug Fixes
Tests