Plan: Flutter Polymarket Deposit Wallet
Status: Plan written; paused on Flutter WIP. Source: docs/superpowers/plans/2026-05-07-flutter-polymarket-deposit-wallet.md. Design: Design.
Ship a Settings-tab card that walks a Reown-connected EOA user through Polymarket’s May 2026 deposit-wallet onboarding (steps 1–4: derive → deploy → fund-handoff → approve), without any server-arenaton involvement.
Tech stack
Section titled “Tech stack”Flutter, Dart 3.7, http: ^1.1.0, flutter_secure_storage: ^9.2.4, reown_appkit: ^1.8.3, web3dart: ^3.0.2 (provides keccak256), pointycastle: ^4.0.0. No new dependencies.
| # | Title | Files (created or modified) |
|---|---|---|
| 1 | Polymarket Environment Constants | lib/config/polymarket_environment.dart |
| 2 | Wallet Derivation Service With Golden Test | lib/services/polymarket/polymarket_wallet_derivation.dart + test |
| 3 | Approval Calldata Service With Parity Test | lib/services/polymarket/polymarket_calldata.dart + test |
| 4 | WALLET Batch EIP-712 Typed Data Builder | lib/services/polymarket/polymarket_typed_data.dart + test |
| 5 | State Models | lib/models/polymarket/{deposit_wallet_state,relayer_transaction}.dart |
| 6 | Relayer HTTP Service With Mock-HTTP Test | lib/services/polymarket/polymarket_relayer_service.dart + test |
| 7 | Setup Controller With State-Machine Test | lib/controllers/polymarket_setup_controller.dart + test |
| 8 | Settings Card Widget And Tab Integration | lib/widgets/settings/polymarket_setup_card.dart, lib/controllers/polymarket_reown_signer.dart, edits to lib/controllers/wallet_controller.dart, lib/screens/tabs/settings_tab.dart, lib/app/app.dart |
| 9 | Final Verification And Root Commit | Submodule pointer; spec + plan committed at root. |
Each task lands as one focused commit with one or more failing tests written first, then the minimal code to pass them.
Key implementation choices
Section titled “Key implementation choices”- Mirror polygolem layer-for-layer. Each Dart service has a direct Go counterpart; golden tests use polygolem’s known-good fixture (
EOA 0x2c75…65c23 → deposit wallet 0xfd5041…fa3cf9c). - New
signTypedDataV4ForExternalChainonWalletController. The existingsignTypedDataV4enforces Arenaton’s exchange chain viarequireSigningChain. Polymarket needs Polygon 137 specifically and bypasses that check; rather than weakening the existing method, the plan adds a sibling that takeschainIdexplicitly. - Reown rejection mapping.
ReownTypedDataSignercatches “rejected” / “canceled” / “denied” substrings from Reown’s generic exception and rethrowsReownUserRejectedExceptionso the controller maps it toDepositWalletErrorKind.userRejected. - Per-EOA state. Switching the active EOA in the wallet UI rehydrates that EOA’s
DepositWalletRecordfrom secure storage without mutating the previous EOA’s progress. - Funding is purely external. “I’ve funded” and “Skip funding” both call
approve()immediately — Arenaton has no on-chain signal to verify funding.
Pause reason
Section titled “Pause reason”Before dispatching Task 1, the controller noticed arenaton-flutter had substantial uncommitted WIP from a Polymarket-direct refactor (alpha-terminal cleanup, deleted source files with surviving tests, untracked lib/features/). Layering the auth-style restore-and-replay dance on top of that WIP would compound risk. The user opted to finalize the WIP first, then resume Task 1 against a clean baseline.
Non-goals
Section titled “Non-goals”- No CLOB order placement.
- No
server-arenatonchanges. - No
polygolemchanges. - No logout / revoke flow for deployed deposit wallets.
- No automatic re-deploy on transient failures.
- No multi-chain support.
- No in-app pUSD funding.
- No retrofit of existing services.