Skip to content

Commit

Permalink
Use controller presets (#2430)
Browse files Browse the repository at this point in the history
  • Loading branch information
edisontim authored Dec 11, 2024
1 parent bbfe2b6 commit 6f7e906
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"dependencies": {
"@bibliothecadao/eternum": "workspace:^",
"@cartridge/connector": "0.5.4",
"@cartridge/controller": "0.5.4",
"@cartridge/connector": "0.5.5",
"@cartridge/controller": "0.5.5",
"@dojoengine/core": "1.0.1",
"@dojoengine/create-burner": "1.0.1",
"@dojoengine/react": "1.0.1",
Expand Down Expand Up @@ -104,4 +104,4 @@
"vitest": "^2.0.5",
"workbox-window": "^7.3.0"
}
}
}
39 changes: 25 additions & 14 deletions client/src/hooks/context/starknet-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { ColorMode } from "@cartridge/controller";
import { mainnet, sepolia } from "@starknet-react/chains";
import { Connector, StarknetConfig, jsonRpcProvider, voyager } from "@starknet-react/core";
import { env } from "../../../env";
import { mainnetPolicies } from "./mainnet-policies";
import { policies } from "./policies";
import { signingPolicy } from "./signing-policy";

const preset: string = "eternum";
const theme: string = "eternum";
const slot: string = env.VITE_PUBLIC_SLOT;
const namespace: string = "s0_eternum";
Expand All @@ -20,19 +20,30 @@ const vrfPolicy = {
description: "Allows requesting random numbers from the VRF provider",
};

const signingPolicies = env.VITE_PUBLIC_CHAIN === "mainnet" ? mainnetPolicies : policies;

const controller = new ControllerConnector({
rpc: env.VITE_PUBLIC_NODE_URL,
namespace,
slot,
policies: [...signingPolicies, ...signingPolicy, vrfPolicy],
theme,
tokens: {
erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
},
colorMode,
});
const controller =
env.VITE_PUBLIC_CHAIN === "mainnet"
? new ControllerConnector({
rpc: env.VITE_PUBLIC_NODE_URL,
namespace,
slot,
preset,
tokens: {
erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
},
colorMode,
})
: new ControllerConnector({
rpc: env.VITE_PUBLIC_NODE_URL,
namespace,
slot,
preset,
policies: [...signingPolicy, ...policies, vrfPolicy],
theme,
tokens: {
erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"],
},
colorMode,
});

export function StarknetProvider({ children }: { children: React.ReactNode }) {
const rpc = useCallback(() => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwindcss": "^3.4.1"
}
},
"packageManager": "[email protected]+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
}
45 changes: 35 additions & 10 deletions pnpm-lock.yaml

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

0 comments on commit 6f7e906

Please sign in to comment.