Skip to content

Conversation

@jamierumbelow
Copy link

@jamierumbelow jamierumbelow commented Feb 10, 2026

This PR adds sign_permit2_allowance support to SafeSmartAccount, enabling World Card to request token allowances (via Permit2's IAllowanceTransfer).

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: Added PermitDetails (token, uint160 amount, uint48 expiration, uint48 nonce) and PermitSingle (details, spender, sigDeadline) structs with #[unparsed] for FFI, plus PermitSingle::as_typed_data() for EIP-712 hashing
  • mod.rs: Added sign_permit2_allowance method on SafeSmartAccount, exported UnparsedPermitDetails and UnparsedPermitSingle
  • bedrock-macros: Extended is_sol_struct_type to handle uint160/uint48, fixed &str vs String in the catch-all TryFrom codegen, added doc comments for nested struct fields to satisfy missing_docs lint
  • Integration test: Full on-chain test (Anvil fork) covering Safe deploy → ERC-20 approve → sign allowance → permit()transferFrom() → balance verification
  • Swift & Kotlin tests: Matching FFI tests for UnparsedPermitDetails, UnparsedPermitSingle, and signPermit2Allowance

Test plan

  • cargo test --lib smart_account — all 35 unit tests pass
  • cargo check --test test_smart_account_permit2_allowance — integration test compiles
  • CI runs full test suite with --features test_utils
  • Swift and Kotlin FFI tests run in CI

Note

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/PermitSingle EIP-712 types and a new SafeSmartAccount::sign_permit2_allowance API, plus exports of the corresponding Unparsed* FFI records.

Updates the bedrock_sol macro codegen to better support nested unparsed structs and additional Solidity primitive widths (uint160, uint48), and fixes error construction to use owned String attributes. Adds unit tests for allowance typed-data hashing and restriction behavior, a full Anvil integration test that executes permit() + 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.

@jamierumbelow jamierumbelow changed the title smart_account: add permit2 allowance signing support feat: add permit2 allowance signing support Feb 10, 2026
@jamierumbelow jamierumbelow force-pushed the jamie/permit2-allowances branch from a753672 to 287be80 Compare February 10, 2026 20:53
@jamierumbelow jamierumbelow force-pushed the jamie/permit2-allowances branch from 287be80 to 0569ab4 Compare February 10, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant