Skip to content

Commit

Permalink
[WIP] Add cartridge connector
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed May 16, 2024
1 parent 96a8337 commit 1af5689
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lint": "next lint",
"knip": "knip",
"format": "prettier --write ./src",
"clean": "git clean -xdf && pnpm store prune",
"gen": "graphql-codegen --config codegen.yaml",
"gen:dojo": "pnpm gen && pnpm gen:events",
"gen:events": "npx create-events ./src/manifests/dev/manifest.json ./src/dojo/generated/contractEvents.ts"
Expand All @@ -18,6 +19,7 @@
"create-events": "./bin/generateEvents.cjs"
},
"dependencies": {
"@cartridge/connector": "../../cartridge/packages/connector",
"@chakra-ui/anatomy": "^2.1.1",
"@chakra-ui/react": "^2.8.1",
"@dojoengine/core": "0.6.122",
Expand Down Expand Up @@ -68,4 +70,4 @@
"prettier": "^2.8.8",
"typescript": "5.2.2"
}
}
}
3 changes: 3 additions & 0 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion web/src/components/wallet/StarknetProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getStarknetProviderChains } from "@/dojo/setup/config";
import { Chain } from "@starknet-react/chains";
import {
ExplorerFactory,
InjectedConnector,
StarknetConfig,
argent,
braavos,
Expand All @@ -11,6 +12,8 @@ import {
useInjectedConnectors,
} from "@starknet-react/core";
import { ReactNode, useState } from "react";
import CartridgeConnector from "@cartridge/connector"
import colors from "@/theme/colors";

export const walletInstallLinks = {
argentX: "https://www.argent.xyz/argent-x/",
Expand All @@ -28,7 +31,12 @@ function rpc(chain: Chain) {
export function StarknetProvider({ children }: { children: ReactNode }) {
const { connectors } = useInjectedConnectors({
// Show these connectors if the user has no connector installed.
recommended: [argent(), braavos(), injected({ id: "dojoburner" })],
recommended: [
argent(),
braavos(),
injected({ id: "dojoburner" }),
cartridgeConnector
],
// Hide recommended connectors if the user has any connector installed.
includeRecommended: "always",
// Randomize the order of the connectors.
Expand All @@ -49,3 +57,21 @@ export function StarknetProvider({ children }: { children: ReactNode }) {
</StarknetConfig>
);
}

const cartridgeConnector = new CartridgeConnector(
[
// {
// target: "0x...",
// method: "todo",
// },
],
{
url: "https://x.cartridge.gg",
theme: {
colors: {
// e.g. button bg
primary: colors.neon["200"] as string,
}
},
}
) as unknown as InjectedConnector

0 comments on commit 1af5689

Please sign in to comment.