From 6de46b59d22bfda959c083b3ac5570cb8d4c6d0a Mon Sep 17 00:00:00 2001 From: Toni Tabak Date: Fri, 24 Nov 2023 12:01:48 +0100 Subject: [PATCH] feat: sepolia constants, rpc open change --- src/constants.ts | 23 ++++++++++++++--------- src/provider/rpc.ts | 5 ++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 60a9303b1..b85f3c88e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 { @@ -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: [], +}; diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts index 721585920..e7a51eba9 100644 --- a/src/provider/rpc.ts +++ b/src/provider/rpc.ts @@ -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 { @@ -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]; };