-
Notifications
You must be signed in to change notification settings - Fork 46
feat: add sensStrk and execute to Wallet provider
#559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
To view this pull requests documentation preview, visit the following URL: docs.page/focustree/starknet.dart~559 Documentation is deployed and generated using docs.page. |
WalkthroughAdds WalletService.send and WalletService.execute using SecureStore-backed signers; exposes provider wrappers sendEth/sendStrk and execute with error reporting; replaces password flow in Send ETH button with secure-store retrieval; sets icon size to 24 and updates Riverpod provider source hash. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant UI as SendEthButton
participant WN as Wallets Notifier
participant SS as SecureStore
participant WS as WalletService
participant NP as StarkNet Provider
U->>UI: Tap "Send"
UI->>WN: getSecureStoreForWallet(context)
WN->>SS: Retrieve secure store
SS-->>WN: SecureStore
UI->>WN: sendEth(secureStore, account, recipient, amount)
WN->>WS: send(secureStore, account, recipient, amount, strk=false)
WS->>SS: Read private key
WS->>NP: Submit transfer tx
NP-->>WS: Tx hash
WS->>NP: Wait for acceptance
NP-->>WS: Accepted/Rejected
WS-->>WN: bool success
WN-->>UI: Result or emit WalletError
UI-->>U: Show success/failure
sequenceDiagram
autonumber
participant C as Caller
participant WN as Wallets Notifier
participant WS as WalletService
participant SS as SecureStore
participant NP as StarkNet Provider
C->>WN: execute(secureStore, account, calls)
WN->>WS: execute(secureStore, account, calls)
WS->>SS: Read private key
WS->>NP: Estimate max fee for calls
NP-->>WS: Fee estimates
WS->>NP: Execute calls with fees
NP-->>WS: Tx hash
WS->>NP: Wait for acceptance
NP-->>WS: Accepted/Rejected
WS-->>WN: bool success
WN-->>C: Result or WalletError
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (4)
packages/wallet_kit/lib/services/wallet_service.dart (1)
199-207: Minimize in-memory key exposureDon’t keep the hex key string around longer than necessary.
- final privateKey = await secureStore.getSecret( - key: privateKeyKey(account.walletId, account.id)); - if (privateKey == null) { + var privateKeyHex = await secureStore.getSecret( + key: privateKeyKey(account.walletId, account.id)); + if (privateKeyHex == null) { throw Exception("Private key not found"); } - s.StarkAccountSigner? signer = s.StarkAccountSigner( - signer: s.StarkSigner(privateKey: s.Felt.fromHexString(privateKey))); + s.StarkAccountSigner? signer = s.StarkAccountSigner( + signer: s.StarkSigner(privateKey: s.Felt.fromHexString(privateKeyHex))); + privateKeyHex = null; // best-effort wipepackages/wallet_kit/lib/wallet_state/wallet_provider.dart (2)
273-289: Refresh balances after a successful sendTrigger an immediate balance refresh for better UX.
}) async { try { - await WalletService.send( + final success = await WalletService.send( secureStore: secureStore, account: account, recipientAddress: recipientAddress, - amount: amount, + amountWei: amountWei, strk: strk, ); + if (success) { + await (strk + ? refreshStrkBalance(account.walletId, account.id) + : refreshEthBalance(account.walletId, account.id)); + } } catch (e) { ref.read(walletErrorNotifierProvider.notifier).reportError( WalletError.accountError(
321-340: Return execution result (bool) to callers
Changeexecuteto returnFuture<bool>,return await WalletService.execute(...), andreturn falseon error:- execute({ + Future<bool> execute({ required SecureStore secureStore, required Account account, required List<sp.FunctionCall> calls, }) async { try { - await WalletService.execute( + return await WalletService.execute( secureStore: secureStore, account: account, calls: calls, ); } catch (e) { ref.read(walletErrorNotifierProvider.notifier).reportError( WalletError.accountError( message: 'Failed to execute calls', exception: e, ), ); + return false; } }packages/wallet_kit/lib/widgets/send_eth_button.dart (1)
25-39: Prevent double submission while awaiting networkOptional UX guard using a loading flag to disable the button during the async send.
Add inside build() before returning PrimaryButton:
final loading = useState(false);Then update onPressed body:
if (loading.value) return; loading.value = true; try { final secureStore = await ref.read(walletsProvider.notifier) .getSecureStoreForWallet(context: context); await ref.read(walletsProvider.notifier).sendEth( secureStore: secureStore, account: selectedAccount, recipientAddress: recipientAddress, amountWei: BigInt.parse('1000000000000000'), ); } finally { loading.value = false; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
packages/wallet_kit/lib/services/wallet_service.dart(1 hunks)packages/wallet_kit/lib/ui/theme.dart(1 hunks)packages/wallet_kit/lib/wallet_state/wallet_provider.dart(1 hunks)packages/wallet_kit/lib/wallet_state/wallet_provider.g.dart(1 hunks)packages/wallet_kit/lib/widgets/send_eth_button.dart(1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2024-10-25T17:58:31.306Z
Learnt from: rukafe0x
PR: focustree/starknet.dart#411
File: packages/starknet/lib/src/account.dart:396-397
Timestamp: 2024-10-25T17:58:31.306Z
Learning: The `signDeclareTransactionV2` function in `packages/starknet/lib/src/account.dart` is a legacy function and should not be modified.
Applied to files:
packages/wallet_kit/lib/services/wallet_service.dart
📚 Learning: 2024-10-22T20:53:21.313Z
Learnt from: rukafe0x
PR: focustree/starknet.dart#411
File: packages/starknet/lib/src/signer.dart:193-271
Timestamp: 2024-10-22T20:53:21.313Z
Learning: The `signDeclareTransactionV3` method is tested in `packages/starknet/test/account_test.dart`.
Applied to files:
packages/wallet_kit/lib/services/wallet_service.dart
📚 Learning: 2024-11-21T23:14:56.972Z
Learnt from: rukafe0x
PR: focustree/starknet.dart#417
File: packages/starknet/lib/src/signer.dart:41-48
Timestamp: 2024-11-21T23:14:56.972Z
Learning: In the file `packages/starknet/lib/src/signer.dart`, when gas bounds computation logic is repeated across methods `signInvokeTransactionsV3`, `signDeclareTransactionV3`, and `signDeployAccountTransactionV3`, the team prefers to keep the logic within each method rather than refactoring into a shared helper method.
Applied to files:
packages/wallet_kit/lib/services/wallet_service.dart
📚 Learning: 2024-11-21T23:10:45.088Z
Learnt from: rukafe0x
PR: focustree/starknet.dart#417
File: packages/starknet/lib/src/signer.dart:193-206
Timestamp: 2024-11-21T23:10:45.088Z
Learning: In `packages/starknet/lib/src/signer.dart`, when function parameters in methods like `signTransactions` are initialized with default values in the method signature, they cannot be null at runtime, so force unwrapping such parameters is acceptable.
Applied to files:
packages/wallet_kit/lib/services/wallet_service.dart
📚 Learning: 2025-04-23T08:23:55.912Z
Learnt from: ptisserand
PR: focustree/starknet.dart#505
File: packages/starknet/test/argent/argent_test.dart:0-0
Timestamp: 2025-04-23T08:23:55.912Z
Learning: In the starknet.dart package, account variables like `account0` and `account9` are exported from `static_config.dart` and available when importing 'package:starknet/starknet.dart' without needing explicit imports.
Applied to files:
packages/wallet_kit/lib/widgets/send_eth_button.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test-integration
🔇 Additional comments (3)
packages/wallet_kit/lib/ui/theme.dart (1)
42-42: LGTM: explicit icon size improves consistencyNo issues; setting size: 24 aligns with Material defaults and avoids per-widget overrides.
packages/wallet_kit/lib/wallet_state/wallet_provider.g.dart (1)
9-9: Generated file change acknowledgedHash update is expected after provider edits. Nothing to review here.
packages/wallet_kit/lib/services/wallet_service.dart (1)
263-274: No changes needed: Account.execute’s individual gas parameters match the current starknet.dart API.
executeallow an account to make a muticall transactionsendEthbuttonSummary by CodeRabbit
New Features
Refactor
UI/Style
Chores