Skip to content

Commit

Permalink
Remove chainid timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Dec 18, 2024
1 parent b041110 commit b948f83
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/keychain/src/hooks/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
OpenSettingsCtx,
} from "utils/connection";
import { getChainName, isIframe } from "@cartridge/utils";
import { RpcProvider, constants } from "starknet";
import { RpcProvider } from "starknet";
import {
Prefund,
ResponseCodes,
Expand All @@ -29,8 +29,6 @@ import {
} from "@cartridge/presets";
import { ParsedSessionPolicies, parseSessionPolicies } from "./session";

const CHAIN_ID_TIMEOUT = 3000;

type ParentMethods = AsyncMethodReturns<{ close: () => Promise<void> }>;

export function useConnectionValue() {
Expand Down Expand Up @@ -201,17 +199,7 @@ export function useConnectionValue() {
const update = async () => {
try {
let provider = new RpcProvider({ nodeUrl: rpcUrl });
const timeoutPromise = new Promise((_, reject) =>
setTimeout(
() => reject(new Error("Chain ID fetch timed out")),
CHAIN_ID_TIMEOUT,
),
);
const chainIdPromise = provider.getChainId();
let chainId = (await Promise.race([
chainIdPromise,
timeoutPromise,
])) as constants.StarknetChainId;
const chainId = await provider.getChainId();
setChainId(chainId);
} catch (e) {
console.error(e);
Expand Down

0 comments on commit b948f83

Please sign in to comment.