Skip to content

Commit bb89561

Browse files
committed
Fetch minimal account address from bundler (#7919)
``` <!-- ## 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 -->
1 parent c92081b commit bb89561

File tree

16 files changed

+313
-170
lines changed

16 files changed

+313
-170
lines changed

packages/thirdweb/scripts/generate/abis/erc7702/MinimalAccount.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
"error AllowanceExceeded(uint256 allowanceUsage, uint256 limit, uint64 period)",
33
"error CallPolicyViolated(address target, bytes4 selector)",
4-
"error CallReverted()",
54
"error ConditionFailed(bytes32 param, bytes32 refValue, uint8 condition)",
65
"error InvalidDataLength(uint256 actualLength, uint256 expectedLength)",
76
"error InvalidSignature(address msgSender, address thisAddress)",
@@ -13,8 +12,9 @@
1312
"error SessionZeroSigner()",
1413
"error TransferPolicyViolated(address target)",
1514
"error UIDAlreadyProcessed()",
16-
"event Executed(address indexed to, uint256 value, bytes data)",
17-
"event SessionCreated(address indexed signer, (address signer, bool isWildcard, uint256 expiresAt, (address target, bytes4 selector, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit, (uint8 condition, uint64 index, bytes32 refValue, (uint8 limitType, uint256 limit, uint256 period) limit)[] constraints)[] callPolicies, (address target, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit)[] transferPolicies, bytes32 uid) sessionSpec)",
15+
"event Executed(address indexed user, address indexed signer, address indexed executor, uint256 batchSize)",
16+
"event SessionCreated(address indexed user, address indexed newSigner, (address signer, bool isWildcard, uint256 expiresAt, (address target, bytes4 selector, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit, (uint8 condition, uint64 index, bytes32 refValue, (uint8 limitType, uint256 limit, uint256 period) limit)[] constraints)[] callPolicies, (address target, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit)[] transferPolicies, bytes32 uid) sessionSpec)",
17+
"event ValueReceived(address indexed user, address indexed from, uint256 value)",
1818
"function createSessionWithSig((address signer, bool isWildcard, uint256 expiresAt, (address target, bytes4 selector, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit, (uint8 condition, uint64 index, bytes32 refValue, (uint8 limitType, uint256 limit, uint256 period) limit)[] constraints)[] callPolicies, (address target, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit)[] transferPolicies, bytes32 uid) sessionSpec, bytes signature)",
1919
"function eip712Domain() view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)",
2020
"function execute((address target, uint256 value, bytes data)[] calls) payable",
@@ -23,5 +23,10 @@
2323
"function getSessionExpirationForSigner(address signer) view returns (uint256)",
2424
"function getSessionStateForSigner(address signer) view returns (((uint256 remaining, address target, bytes4 selector, uint256 index)[] transferValue, (uint256 remaining, address target, bytes4 selector, uint256 index)[] callValue, (uint256 remaining, address target, bytes4 selector, uint256 index)[] callParams))",
2525
"function getTransferPoliciesForSigner(address signer) view returns ((address target, uint256 maxValuePerUse, (uint8 limitType, uint256 limit, uint256 period) valueLimit)[])",
26-
"function isWildcardSigner(address signer) view returns (bool)"
26+
"function isWildcardSigner(address signer) view returns (bool)",
27+
"function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) returns (bytes4)",
28+
"function onERC1155Received(address, address, uint256, uint256, bytes) returns (bytes4)",
29+
"function onERC721Received(address, address, uint256, bytes) returns (bytes4)",
30+
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
31+
"receive() external payable"
2732
]

packages/thirdweb/src/extensions/erc7702/__generated__/MinimalAccount/events/Executed.ts

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7702/__generated__/MinimalAccount/events/SessionCreated.ts

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7702/__generated__/MinimalAccount/events/ValueReceived.ts

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7702/__generated__/MinimalAccount/read/eip712Domain.ts

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7702/__generated__/MinimalAccount/read/getCallPoliciesForSigner.ts

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc7702/__generated__/MinimalAccount/read/getSessionExpirationForSigner.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)