Skip to content

Conversation

@0xFirekeeper
Copy link
Member

@0xFirekeeper 0xFirekeeper commented Aug 26, 2025

<!--

## 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

Open in Cursor Open in Web

PR-Codex overview

This PR focuses on updating the erc7702 extension in the thirdweb SDK by refining event filters, input/output structures, and enhancing the handling of delegation contracts in the minimal account implementation.

Detailed summary

  • Updated event signatures for ExecutedEventFilters, SessionCreatedEventFilters, and ValueReceivedEventFilters.
  • Changed parameter names in several functions and tests to improve clarity (e.g., signer to newSigner).
  • Refined input/output structures for functions like getTransferPoliciesForSigner, getSessionStateForSigner, and createSessionWithSig.
  • Introduced a new function getDelegationContractAddress for fetching delegation contract addresses.
  • Updated logic in create7702MinimalAccount to incorporate delegation contract handling.
  • Modified tests to align with the new naming conventions and structures.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

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).

@cursor
Copy link

cursor bot commented Aug 26, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link

changeset-bot bot commented Aug 26, 2025

⚠️ No Changeset found

Latest commit: bb89561

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Resolves 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

Cohort / File(s) Summary
Tests: session key assertions updated
packages/thirdweb/src/extensions/erc7702/account/sessionkey.test.ts
Replaces assertions that referenced signer and nested sessionSpec policy arrays with an assertion checking newSigner; removes checks against sessionSpec.callPolicies / sessionSpec.transferPolicies.
Tests: in-app integration log assertion
packages/thirdweb/src/wallets/in-app/web/lib/in-app-integration.test.ts
Replaces assertions on executedLog.args.to and executedLog.args.value with a single assertion on executedLog.args.user.
EIP-7702 minimal account: dynamic delegation address
packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts
Adds getDelegationContractAddress calling bundler RPC tw_getDelegationContract with 24h caching, validation, and error handling; removes hard-coded delegation address and uses resolved address in is7702MinimalAccount, signing, tx target normalization, and nonce retrieval; adds imports for fetch, stringify, withCache, getDefaultBundlerUrl and related types.
Generated types/events: SessionCreated args renamed
packages/thirdweb/src/extensions/erc7702/account/__generated__/MinimalAccount/events/SessionCreated.js
Updates generated event args: renames signernewSigner and removes sessionSpec from the asserted/generated event args shape where applicable.
ABI: MinimalAccount interface changes
packages/thirdweb/scripts/generate/abis/erc7702/MinimalAccount.json
Removes CallReverted() error; updates Executed and SessionCreated event signatures to include user/newSigner and batchSize changes; adds ValueReceived event; adds ERC-721/1155 receiver functions, supportsInterface, receive(), and payable executeWithSig function.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/fetch-minimal-account-address-from-bundler-09f6

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 26, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Aug 26, 2025
@vercel
Copy link

vercel bot commented Aug 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 4, 2025 10:43pm
nebula Ready Ready Preview Comment Sep 4, 2025 10:43pm
thirdweb_playground Ready Ready Preview Comment Sep 4, 2025 10:43pm
thirdweb-www Ready Ready Preview Comment Sep 4, 2025 10:43pm
wallet-ui Ready Ready Preview Comment Sep 4, 2025 10:43pm

@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.01 KB (0%) 1.3 s (0%) 431 ms (+107.52% 🔺) 1.8 s
thirdweb (cjs) 357.32 KB (0%) 7.2 s (0%) 1.6 s (+4.32% 🔺) 8.8 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 102 ms (+716.85% 🔺) 217 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 53 ms (+801.73% 🔺) 63 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 160 ms (+415.03% 🔺) 543 ms

@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 72.13115% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.54%. Comparing base (c92081b) to head (bb89561).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...src/wallets/in-app/core/eip7702/minimal-account.ts 72.13% 17 Missing ⚠️
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     
Flag Coverage Δ
packages 56.54% <72.13%> (+0.01%) ⬆️
Files with missing lines Coverage Δ
...src/wallets/in-app/core/eip7702/minimal-account.ts 90.89% <72.13%> (-1.27%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member Author

0xFirekeeper commented Sep 4, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Sep 4, 2025
```
<!--

## 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 -->
@graphite-app graphite-app bot force-pushed the cursor/fetch-minimal-account-address-from-bundler-09f6 branch from 6d09a4c to 3227995 Compare September 4, 2025 21:59
```
<!--

## 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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants