Skip to content

Commit

Permalink
feat(snaps-rpc-methods): Use BigInt to parse chain ids (#2781)
Browse files Browse the repository at this point in the history
There are no size limits on Ethereum chain ids, so we should use BigInt
to parse them.
  • Loading branch information
rekmarks authored Oct 1, 2024
1 parent 824fd4f commit 8ff9427
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type,
} from '@metamask/superstruct';
import {
numberToHex,
bigIntToHex,
parseCaipChainId,
type PendingJsonRpcResponse,
type Json,
Expand Down Expand Up @@ -175,10 +175,10 @@ async function providerRequestImplementation(
);
}

const numericalChainId = parseInt(parsedChainId.reference, 10);
const numericalChainId = BigInt(parsedChainId.reference);

const networkConfiguration = getNetworkConfigurationByChainId(
numberToHex(numericalChainId),
bigIntToHex(numericalChainId),
);

if (!networkConfiguration) {
Expand Down

0 comments on commit 8ff9427

Please sign in to comment.