Skip to content

Commit

Permalink
chore: handle comments
Browse files Browse the repository at this point in the history
  • Loading branch information
khanti42 committed Dec 9, 2024
1 parent e224437 commit 0674b12
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
12 changes: 12 additions & 0 deletions packages/starknet-snap/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type SnapConfig = {
defaultNetwork: Network;
availableNetworks: Network[];
preloadTokens: Erc20Token[];
rpcEndpoint: {
[key: string]: string;
};
explorer: {
[key: string]: string;
};
Expand Down Expand Up @@ -49,6 +52,15 @@ export const Config: SnapConfig = {
STARKNET_SEPOLIA_TESTNET_NETWORK,
],

rpcEndpoint: {
[constants.StarknetChainId.SN_MAIN]:
// eslint-disable-next-line no-restricted-globals
`https://starknet-mainnet.infura.io/v3/${process.env.DIN_API_KEY ?? ''}`,
[constants.StarknetChainId.SN_SEPOLIA]:
// eslint-disable-next-line no-restricted-globals
`https://starknet-sepolia.infura.io/v3/${process.env.DIN_API_KEY ?? ''}`,
},

explorer: {
[constants.StarknetChainId.SN_MAIN]:
// eslint-disable-next-line no-template-curly-in-string
Expand Down
23 changes: 0 additions & 23 deletions packages/starknet-snap/src/utils/din.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { constants } from 'starknet';

import { getRPCUrl } from './din';
import { getRPCUrl } from './rpc-provider';

describe('getRPCUrl', () => {
it('returns Mainnet RPC URL if chain id is Mainnet', () => {
Expand Down
17 changes: 17 additions & 0 deletions packages/starknet-snap/src/utils/rpc-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { constants } from 'starknet';

import { Config } from '../config';

/**
*
* @param chainId
*/
export function getRPCUrl(chainId: string) {
switch (chainId) {
case constants.StarknetChainId.SN_MAIN:
return Config.rpcEndpoint[constants.StarknetChainId.SN_MAIN];
default:
case constants.StarknetChainId.SN_SEPOLIA:
return Config.rpcEndpoint[constants.StarknetChainId.SN_SEPOLIA];
}
}
2 changes: 1 addition & 1 deletion packages/starknet-snap/src/utils/starknetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ import {
ETHER_SEPOLIA_TESTNET,
BlockIdentifierEnum,
} from './constants';
import { getRPCUrl } from './din';
import { DeployRequiredError, UpgradeRequiredError } from './exceptions';
import { hexToString } from './formatter-utils';
import { getAddressKey } from './keyPair';
import { logger } from './logger';
import { getRPCUrl } from './rpc-provider';
import { toJson } from './serializer';
import {
getAccount,
Expand Down

0 comments on commit 0674b12

Please sign in to comment.