Skip to content

Commit 014e58a

Browse files
authored
fix: switch precedence of cartridgeChains and provided chains (#1769)
1 parent 4775fd1 commit 014e58a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/controller/src/controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class ControllerProvider extends BaseProvider {
4949

5050
// Merge user chains with default chains
5151
// User chains take precedence if they specify the same network
52-
const chains = [...(options.chains || []), ...cartridgeChains];
52+
const chains = [...cartridgeChains, ...(options.chains || [])];
5353
const defaultChainId =
5454
options.defaultChainId || constants.StarknetChainId.SN_MAIN;
5555

@@ -438,8 +438,10 @@ export default class ControllerProvider extends BaseProvider {
438438
const isMainnet = chainId === constants.StarknetChainId.SN_MAIN;
439439
const isSepolia = chainId === constants.StarknetChainId.SN_SEPOLIA;
440440
const isCartridgeRpc = url.hostname === "api.cartridge.gg";
441+
const isLocalhost =
442+
url.hostname === "localhost" || url.hostname === "127.0.0.1";
441443

442-
if ((isMainnet || isSepolia) && !isCartridgeRpc) {
444+
if ((isMainnet || isSepolia) && !(isCartridgeRpc || isLocalhost)) {
443445
throw new Error(
444446
`Only Cartridge RPC providers are allowed for ${isMainnet ? "mainnet" : "sepolia"}. ` +
445447
`Please use: https://api.cartridge.gg/x/starknet/${isMainnet ? "mainnet" : "sepolia"}`,

0 commit comments

Comments
 (0)