Skip to content

Commit

Permalink
feat: sepolia constants, rpc open change
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Nov 24, 2023
1 parent 1843e3c commit 6de46b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
23 changes: 14 additions & 9 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ export const API_VERSION = ZERO;
export enum BaseUrl {
SN_MAIN = 'https://alpha-mainnet.starknet.io',
SN_GOERLI = 'https://alpha4.starknet.io',
SN_SEPOLIA = 'https://alpha-sepolia.starknet.io',
}

export enum NetworkName {
SN_MAIN = 'SN_MAIN',
SN_GOERLI = 'SN_GOERLI',
SN_SEPOLIA = 'SN_SEPOLIA',
}

export enum StarknetChainId {
SN_MAIN = '0x534e5f4d41494e', // encodeShortString('SN_MAIN'),
SN_GOERLI = '0x534e5f474f45524c49', // encodeShortString('SN_GOERLI')
SN_SEPOLIA = '0x534e5f5345504f4c4941', // encodeShortString('SN_SEPOLIA')
}

export enum TransactionHashPrefix {
Expand All @@ -45,12 +48,14 @@ export const UDC = {
ENTRYPOINT: 'deployContract',
};

export const RPC_GOERLI_NODES = [
'https://starknet-testnet.public.blastapi.io/rpc/v0.5',
'https://limited-rpc.nethermind.io/goerli-juno/v0_5',
];

export const RPC_MAINNET_NODES = [
'https://starknet-mainnet.public.blastapi.io/rpc/v0.5',
'https://limited-rpc.nethermind.io/mainnet-juno/v0_5',
];
export const RPC_NODES = {
SN_GOERLI: [
'https://starknet-testnet.public.blastapi.io/rpc/v0.5',
'https://limited-rpc.nethermind.io/goerli-juno/v0_5',
],
SN_MAIN: [
'https://starknet-mainnet.public.blastapi.io/rpc/v0.5',
'https://limited-rpc.nethermind.io/mainnet-juno/v0_5',
],
SN_SEPOLIA: [],
};
5 changes: 2 additions & 3 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {
HEX_STR_TRANSACTION_VERSION_1,
HEX_STR_TRANSACTION_VERSION_2,
NetworkName,
RPC_GOERLI_NODES,
RPC_MAINNET_NODES,
RPC_NODES,
StarknetChainId,
} from '../constants';
import {
Expand Down Expand Up @@ -46,7 +45,7 @@ export const getDefaultNodeUrl = (networkName?: NetworkName, mute: boolean = fal
if (!mute)
// eslint-disable-next-line no-console
console.warn('Using default public node url, please provide nodeUrl in provider options!');
const nodes = networkName === NetworkName.SN_MAIN ? RPC_MAINNET_NODES : RPC_GOERLI_NODES;
const nodes = networkName ? RPC_NODES[networkName] : RPC_NODES[NetworkName.SN_GOERLI];
const randIdx = Math.floor(Math.random() * nodes.length);
return nodes[randIdx];
};
Expand Down

0 comments on commit 6de46b5

Please sign in to comment.