fix(wallet): export Starknet embedded key when network is Starknet#498
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR extracts wallet export functionality from the Privy hook into a dedicated hook that adds network-aware logic, particularly requiring an address parameter for Starknet chains. Two dropdown components are updated to use the new hook, and TypeScript configuration is improved with a dedicated test config. ChangesEmbedded Wallet Export Refactor
Sequence Diagram(s)sequenceDiagram
participant User
participant Component as MobileDropdown<br/>SettingsDropdown
participant Handler as useHandleExportEmbeddedWallet
participant Toast
participant Privy as Privy exportWallet
User->>Component: Click export wallet
Component->>Handler: Call handleExportEmbeddedWallet()
Handler->>Handler: Check selected chain
alt Starknet chain
Handler->>Handler: Get wallet address
alt No address available
Handler->>Toast: Show error (missing address)
else Address present
Handler->>Privy: exportWallet({ address })
end
else Other chain
Handler->>Privy: exportWallet()
end
alt Export succeeds
Privy-->>Handler: Success
else Export fails
Privy-->>Handler: Error
Handler->>Toast: Show error (export failed)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Description
Embedded wallet export was always calling Privy’s
exportWallet()with no arguments, so Privy defaulted to HD index 0 (the EVM embedded wallet). Users on Starknet saw the wrong address in the export modal and could not export their Starknet key.This change adds
useHandleExportEmbeddedWallet, which passesexportWallet({ address })when the selected network is Starknet, using the same address asuseWalletAddress()(the Privy Starknet embedded account). Desktop settings and mobile settings both use this handler. EVM behavior is unchanged (exportWallet()with no args).TypeScript:
baseUrlis set onmaintsconfig;__tests__are excluded from the app project and covered bytsconfig.tests.jsonsotscis not blocked by Jest matchers. No API or contract changes.References
None.
Testing
Manual: log in with embedded wallet, select Starknet, open Export wallet from settings (desktop dropdown and mobile settings). Confirm the modal shows the Starknet address and export completes. Switch to an EVM network and confirm export still targets the default EVM embedded flow.
Automated:
pnpm exec tsc --noEmit -p tsconfig.json && pnpm exec tsc --noEmit -p tsconfig.tests.jsonChecklist
mainBy submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.
Summary by CodeRabbit
Release Notes
New Features
Chores