Skip to content

Comments

feat(wallet): add Cartridge support and display all Starknet wallets#50

Open
davedumto wants to merge 5 commits intoFundable-Protocol:mainfrom
davedumto:feat/add-cartridge-and-all-wallets
Open

feat(wallet): add Cartridge support and display all Starknet wallets#50
davedumto wants to merge 5 commits intoFundable-Protocol:mainfrom
davedumto:feat/add-cartridge-and-all-wallets

Conversation

@davedumto
Copy link

@davedumto davedumto commented Jul 25, 2025

🚀 Enhance Wallet Support: Add Cartridge & All Starknet Wallets

Overview

This PR adds support for the Cartridge wallet and ensures that all major wallets supported by Starknet React are available in the wallet connection UI. This enhancement provides users with more choices and better accessibility when interacting with the platform.


What’s Changed

  • Added Cartridge Wallet Support:
    Integrated the ControllerConnector from @cartridge/connector/controller into the wallet provider, enabling users to connect with the Cartridge wallet.
  • Display All Supported Wallets:
    The wallet connection interface now includes Argent, Braavos, Injected (browser wallets), and Cartridge, removing previous limitations on wallet options.
  • Maintained Existing Functionality:
    Existing wallet connections (Argent, Braavos, Injected) remain fully functional.
  • Consistent Integration:
    The implementation follows the same style and best practices as the existing wallet connectors.
  • Error Handling:
    Existing error handling for connection and transaction failures applies to all connectors, including Cartridge.

How This Satisfies the Issue Requirements

  • ✔️ Cartridge wallet is now available for connection.
  • ✔️ All major Starknet wallets are displayed in the connect UI.
  • ✔️ No breaking changes to existing wallet logic.
  • ✔️ Consistent code style and error handling.
  • ✔️ No new linting issues introduced.
  • Cartridge wallet connection/transaction flow could not be tested due to access issues (see below).

Testing

  • Argent and Braavos wallets:
    Successfully tested connection
  • Cartridge wallet:
    Unable to test due to “access denied” on the Cartridge website and issues running the local keychain. The integration follows official documentation and should work as soon as Cartridge is accessible.

Notes / Blockers

  • If a reviewer has access to Cartridge, please verify the connection flow.
  • I will be happy to provide a Loom demo as soon as access to Cartridge is restored.

Loom Video of the argent wallet connection

https://www.loom.com/share/9ad38e4b2c1e4707ac79a8a541ccf0f9?sid=61da6982-e480-4848-82b1-8ead0933725f


Thank you for reviewing!
Let me know if you have any questions or need further changes.

Summary by CodeRabbit

  • New Features

    • Added support for the Cartridge wallet, allowing users to connect using this new wallet option.
  • Refactor

    • Improved the wallet connection process by listing supported wallets explicitly for a more predictable and stable experience.
  • Chores

    • Upgraded the core framework to the latest version for enhanced performance and security.
    • Added new dependencies to support wallet connectivity features.

@vercel
Copy link

vercel bot commented Jul 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fundable-fe ❌ Failed (Inspect) Aug 2, 2025 11:50am

@vercel
Copy link

vercel bot commented Jul 25, 2025

@davedumto is attempting to deploy a commit to the Fundable Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Two new dependencies, @cartridge/connector and @cartridge/controller, were added to package.json. The WalletProvider component was refactored to use a static array of wallet connectors, including the new Cartridge ControllerConnector, instead of dynamically obtaining connectors. Imports and connector configuration were updated accordingly.

Changes

File(s) Summary
package.json Added @cartridge/connector and @cartridge/controller to dependencies; upgraded next version.
src/providers/wallet-provider.tsx Refactored to use a static array of connectors, including Cartridge ControllerConnector; updated imports and connector instantiation.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant WalletProvider
    participant StarknetConfig
    participant Connectors

    App ->> WalletProvider: Render with children
    WalletProvider ->> Connectors: Define static array (argent, braavos, injected, ControllerConnector)
    WalletProvider ->> StarknetConfig: Pass connectors, chains, provider, explorer, children
    StarknetConfig ->> App: Provide wallet context to children
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related issues

Poem

In fields of code, the wallets grow,
With Cartridge seeds now set to sow.
Static lines, connectors four—
Argent, Braavos, and more in store!
The rabbits cheer and gently nudge,
“Hop in, connect, and never begrudge!”
🐇✨

✨ 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.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai 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:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @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

Documentation and Community

  • 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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46aa43b and 0a719c3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/providers/wallet-provider.tsx (1 hunks)
🔇 Additional comments (5)
package.json (1)

12-13: Dependencies Verified: @cartridge/connector & @cartridge/controller at ^0.9.2

Both packages exist on npm, are maintained by the expected authors, and 0.9.2 is their latest stable release (dist-tag latest). The caret range ^0.9.2 correctly tracks patch updates without risking breaking changes.

• package.json — lines 12–13

src/providers/wallet-provider.tsx (4)

6-12: Import changes look correct for static connector implementation.

The updated imports properly support the transition from dynamic to static connector configuration. All necessary connectors are imported from @starknet-react/core.


24-34: StarknetConfig integration looks correct.

The StarknetConfig component properly receives the static connectors array, and all other configuration remains unchanged. This maintains backward compatibility for the provider interface.


36-36: Export statement formatting is consistent.

The export statement follows consistent formatting with the rest of the codebase.


13-13: ControllerConnector import path is correct

The @cartridge/connector package’s exports field includes a ./controller subpath (mapping to dist/controller.js), so the import

import ControllerConnector from "@cartridge/connector/controller";

in src/providers/wallet-provider.tsx is valid and requires no changes.

Comment on lines 16 to 22
// All supported connectors (excluding 'ready', which is not exported)
const connectors = [
argent(),
braavos(),
injected({ id: "injected" }),
new ControllerConnector(), // Cartridge wallet
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify ControllerConnector constructor parameters and breaking change impact.

The transition from useInjectedConnectors() to a static array is a significant architectural change. Please verify:

  1. ControllerConnector configuration: Does the constructor require any parameters (like app name, RPC URL, etc.)?
  2. Breaking change assessment: The injected({ id: "injected" }) configuration might affect existing wallet connections that relied on the previous dynamic detection.

The static connector array approach provides better control over which wallets are available, which aligns with the PR objective of displaying all major Starknet wallets.


🌐 Web query:

ControllerConnector from @cartridge/connector constructor parameters and configuration options

💡 Result:

The ControllerConnector from @cartridge/connector accepts a configuration object with several parameters that allow you to customize its behavior for integration with Starknet-based applications. The key parameters and configuration options are as follows:

  • policies:
    An object defining session policies (permissions) for interacting with smart contracts. Policies specify which contracts and methods can be used, and can include descriptive metadata for each permitted method. This allows for fine-grained session key management, particularly useful for gaming or applications requiring specific delegated permissions[1][7].

    Example:

    const policies = {
      contracts: {
        "0x...": {
          methods: [
            { name: "approve", entrypoint: "approve", description: "Approve tokens" },
            { name: "transfer", entrypoint: "transfer" }
          ]
        }
      }
    };
  • rpc:
    The Starknet JSON-RPC endpoint to use for the connector. This is the node URL where the connector will send requests. You can explicitly pass different endpoints for networks like mainnet or sepolia, e.g., 'https://api.cartridge.gg/x/starknet/sepolia'[1][4][7].

  • theme (optional):
    Some documentation and code suggest there may be support for UI themes (light/dark/custom), but the primary examples do not show this in detail. If supported, it would allow you to adjust the appearance of built-in modal UIs[1].

  • Other parameters:
    Documentation focuses primarily on policies and rpc. The code examples do not expose additional documented parameters such as session duration, preferred explorer, or inventory configuration directly within ControllerConnector, but those may be available via props in related UI components[1][4][7].

Example Minimal Configuration

import ControllerConnector from "@cartridge/connector/controller";

const policies = {
  contracts: {
    "0x049d...": {
      methods: [
        { name: "approve", entrypoint: "approve", description: "Approve spending" },
        { name: "transfer", entrypoint: "transfer" }
      ]
    }
  }
};

const connector = new ControllerConnector({
  policies,
  rpc: "https://api.cartridge.gg/x/starknet/sepolia"
});
// Add to StarknetConfig as connector

[1][4][7]

Essential Usage Guidelines

  • Instantiate outside React components:
    Always create the ControllerConnector outside of the React component tree to avoid recreation on every render, which can disrupt connection handling[1][7].

  • Session Policies:
    Session key features (delegation, gasless txs, method whitelisting) are enabled via the policies parameter[1][7].

  • Provider configuration:
    Use with a Starknet JSON-RPC provider (such as jsonRpcProvider() from @starknet-react/core) and specify different node URLs per environment as needed[1][7].

Summary Table

Parameter Type Description Required
policies object Defines contracts/methods permitted by the controller (session delegation/permissions) No*
rpc string URL for the Starknet JSON-RPC endpoint used by the controller Yes
theme string (If supported) UI theme for built-in modals No

* Policies are optional for basic use but required for advanced session key/delegation scenarios.

References

  • Direct integration and usage instructions are available in the [Cartridge documentation][1][4][7].

If you need details on a specialized parameter or a specific advanced configuration not included here, please specify, as current official documentation focuses mainly on contract permissioning and RPC setup.

Citations:


Ensure ControllerConnector Is Instantiated with Required Configuration

The ControllerConnector constructor from @cartridge/connector requires at least an rpc URL (and, for advanced use, an optional policies object). Instantiating it with no arguments will cause runtime failures. In addition, switching from useInjectedConnectors() to a hard-coded injected({ id: "injected" }) may alter how existing wallet sessions are detected and re-connected.

Please update and verify the following in src/providers/wallet-provider.tsx (lines 16–22):

• Instantiate ControllerConnector with a configuration object:

-  new ControllerConnector(),
+  new ControllerConnector({
+    rpc: "https://api.cartridge.gg/x/starknet/sepolia",
+    // optional: policies for session delegation
+    // policies: { contracts: { "<contract-address>": { methods: […] } } }
+  }),

• Ensure this instantiation occurs outside React render logic to avoid re-creation on every render.
• Test that the static injected({ id: "injected" }) connector replicates the behavior of the former dynamic detection—especially re-attaching to already-connected wallets.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// All supported connectors (excluding 'ready', which is not exported)
const connectors = [
argent(),
braavos(),
injected({ id: "injected" }),
new ControllerConnector(), // Cartridge wallet
];
// All supported connectors (excluding 'ready', which is not exported)
const connectors = [
argent(),
braavos(),
injected({ id: "injected" }),
new ControllerConnector({
rpc: "https://api.cartridge.gg/x/starknet/sepolia",
// optional: policies for session delegation
// policies: { contracts: { "<contract-address>": { methods: […] } } }
}),
];
🤖 Prompt for AI Agents
In src/providers/wallet-provider.tsx around lines 16 to 22, the
ControllerConnector must be instantiated with a configuration object including
at least an rpc URL to prevent runtime errors. Move this instantiation outside
the React render function to avoid recreating it on every render. Also, verify
that replacing useInjectedConnectors() with a static injected({ id: "injected"
}) connector maintains the previous behavior of detecting and reconnecting
existing wallet sessions, adjusting the implementation if necessary to preserve
this functionality.

@pragmaticAweds
Copy link
Contributor

Hi @davedumto

How is it going on your end?

Any challenges or assistance needed?

@davedumto
Copy link
Author

Hi there, there are no issues in waiting for it to be merged

@Utilitycoder
Copy link
Contributor

Please resolve the conflict so your PR can be merged.

@davedumto
Copy link
Author

hi @Utilitycoder I have fixed the merge conflicts

@davedumto
Copy link
Author

hey @Utilitycoder please what is the hold up?

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.

3 participants