Skip to content

Conversation

@ptisserand
Copy link
Collaborator

@ptisserand ptisserand commented Aug 28, 2025

execute allow an account to make a muticall transaction

  • add missing icon size in default theme
  • fix sendEth button

Summary by CodeRabbit

  • New Features

    • Send ETH and STRK directly from the wallet.
    • Execute multiple contract calls in a single action.
  • Refactor

    • Replaced password prompts with a secure storage flow when sending funds.
    • Centralized transfer and execution logic with improved error handling.
  • UI/Style

    • Standardized icon size for consistent appearance.
  • Chores

    • Updated generated provider metadata (no user-facing impact).

@docs-page
Copy link

docs-page bot commented Aug 28, 2025

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 28, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Service API additions
packages/wallet_kit/lib/services/wallet_service.dart
Adds static send and execute methods that load a private key from SecureStore, construct a signer/account via WalletKit, submit on-chain transfers or invoke calls (with fee estimation for execute), await acceptance, and return success boolean.
Provider wrappers & error handling
packages/wallet_kit/lib/wallet_state/wallet_provider.dart, .../wallet_provider.g.dart
Adds private _send helper; public sendEth, sendStrk, and execute methods that call WalletService, surface errors via walletErrorNotifierProvider; updates generated provider source hash constant in wallet_provider.g.dart.
UI: Send button flow
packages/wallet_kit/lib/widgets/send_eth_button.dart
Replaces password modal flow with getSecureStoreForWallet(...) retrieval and calls sendEth(secureStore, ...); removes password UI/handling and related imports.
Theme tweak
packages/wallet_kit/lib/ui/theme.dart
Sets IconThemeData size explicitly to 24.

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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

In my burrow I guard the key,
I skip the prompt and hop with glee.
ETH and STRK, or calls galore,
Signed and sent—then thump once more.
Rabbit grins: the tx is sure to store. 🐇✨

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 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5181d3f and a353311.

📒 Files selected for processing (2)
  • packages/wallet_kit/lib/wallet_state/wallet_provider.dart (1 hunks)
  • packages/wallet_kit/lib/wallet_state/wallet_provider.g.dart (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/wallet_kit/lib/wallet_state/wallet_provider.g.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/wallet_kit/lib/wallet_state/wallet_provider.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
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 exposure

Don’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 wipe
packages/wallet_kit/lib/wallet_state/wallet_provider.dart (2)

273-289: Refresh balances after a successful send

Trigger 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
Change execute to return Future<bool>, return await WalletService.execute(...), and return false on 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 network

Optional 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0fca0 and 5181d3f.

📒 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 consistency

No 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 acknowledged

Hash 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.

@ptisserand ptisserand merged commit 9dd90bc into focustree:main Aug 28, 2025
9 of 10 checks passed
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