feat: add permit2 allowance signing support #260
+625
−5
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.
This PR adds
sign_permit2_allowancesupport toSafeSmartAccount, enabling World Card to request token allowances (via Permit2'sIAllowanceTransfer).Problem
Permit2 has two distinct mechanisms: SignatureTransfer (one-time transfers, already supported via
sign_permit2_transfer) and AllowanceTransfer (recurring allowances with expiration). We only supported the former, but allowance-based approvals are needed for Mini App use cases where a spender draws from an allowance over time.Changes
permit2.rs: AddedPermitDetails(token, uint160 amount, uint48 expiration, uint48 nonce) andPermitSingle(details, spender, sigDeadline) structs with#[unparsed]for FFI, plusPermitSingle::as_typed_data()for EIP-712 hashingmod.rs: Addedsign_permit2_allowancemethod onSafeSmartAccount, exportedUnparsedPermitDetailsandUnparsedPermitSinglebedrock-macros: Extendedis_sol_struct_typeto handleuint160/uint48, fixed&strvsStringin the catch-allTryFromcodegen, added doc comments for nested struct fields to satisfymissing_docslintpermit()→transferFrom()→ balance verificationUnparsedPermitDetails,UnparsedPermitSingle, andsignPermit2AllowanceTest plan
cargo test --lib smart_account— all 35 unit tests passcargo check --test test_smart_account_permit2_allowance— integration test compiles--features test_utilsNote
Medium Risk
Touches crypto-signing and EIP-712 typed-data hashing paths and expands codegen for FFI structs/types; while scoped and well-tested, mistakes could produce invalid signatures or parsing errors across languages.
Overview
Adds Permit2 allowance ("AllowanceTransfer") signing support by introducing
PermitDetails/PermitSingleEIP-712 types and a newSafeSmartAccount::sign_permit2_allowanceAPI, plus exports of the correspondingUnparsed*FFI records.Updates the
bedrock_solmacro codegen to better support nested unparsed structs and additional Solidity primitive widths (uint160,uint48), and fixes error construction to use ownedStringattributes. Adds unit tests for allowance typed-data hashing and restriction behavior, a full Anvil integration test that executespermit()+transferFrom()on-chain, and Swift/Kotlin FFI tests covering the new unparsed types and signing method.Written by Cursor Bugbot for commit 0569ab4. This will update automatically on new commits. Configure here.