diff --git a/dist/action.js b/dist/action.js index 29a5e4b..f272805 100644 --- a/dist/action.js +++ b/dist/action.js @@ -23205,6 +23205,21 @@ var ChainId = { zksync: zksync.id }; +// src/public.ts +var publicRPCs = { + [ChainId.mainnet]: "https://eth.llamarpc.com", + [ChainId.polygon]: "https://polygon.llamarpc.com", + [ChainId.arbitrum]: "https://polygon.llamarpc.com", + [ChainId.base]: "https://base.llamarpc.com", + [ChainId.bnb]: "https://binance.llamarpc.com", + [ChainId.metis]: "https://andromeda.metis.io/?owner=1088", + [ChainId.gnosis]: "https://rpc.ankr.com/gnosis", + [ChainId.scroll]: "https://rpc.scroll.io", + [ChainId.zksync]: "https://mainnet.era.zksync.io", + [ChainId.fantom]: "https://rpc.ftm.tools", + [ChainId.avalanche]: "https://api.avax.network/ext/bc/C/rpc" +}; + // src/lib.ts Object.values(ChainId).filter( (id) => networkMap[id] @@ -23240,6 +23255,12 @@ function getAlchemyRPC(chainId, alchemyKey2) { } return `https://${alchemyId}.g.alchemy.com/v2/${alchemyKey2}`; } +function getPublicRpc(chainId) { + const publicRpc = publicRPCs[chainId]; + if (!publicRpc) + throw new Error(`No default public rpc for '${chainId}' configured.`); + return publicRpc; +} var getRPCUrl = (chainId, options) => { if (!Object.values(ChainId).includes(chainId)) { throw new Error( @@ -23256,6 +23277,10 @@ var getRPCUrl = (chainId, options) => { } catch (e) { } } + try { + return getPublicRpc(chainId); + } catch (e) { + } }; // src/action.ts diff --git a/dist/action.mjs b/dist/action.mjs index 778c9b4..e8348c0 100644 --- a/dist/action.mjs +++ b/dist/action.mjs @@ -23203,6 +23203,21 @@ var ChainId = { zksync: zksync.id }; +// src/public.ts +var publicRPCs = { + [ChainId.mainnet]: "https://eth.llamarpc.com", + [ChainId.polygon]: "https://polygon.llamarpc.com", + [ChainId.arbitrum]: "https://polygon.llamarpc.com", + [ChainId.base]: "https://base.llamarpc.com", + [ChainId.bnb]: "https://binance.llamarpc.com", + [ChainId.metis]: "https://andromeda.metis.io/?owner=1088", + [ChainId.gnosis]: "https://rpc.ankr.com/gnosis", + [ChainId.scroll]: "https://rpc.scroll.io", + [ChainId.zksync]: "https://mainnet.era.zksync.io", + [ChainId.fantom]: "https://rpc.ftm.tools", + [ChainId.avalanche]: "https://api.avax.network/ext/bc/C/rpc" +}; + // src/lib.ts Object.values(ChainId).filter( (id) => networkMap[id] @@ -23238,6 +23253,12 @@ function getAlchemyRPC(chainId, alchemyKey2) { } return `https://${alchemyId}.g.alchemy.com/v2/${alchemyKey2}`; } +function getPublicRpc(chainId) { + const publicRpc = publicRPCs[chainId]; + if (!publicRpc) + throw new Error(`No default public rpc for '${chainId}' configured.`); + return publicRpc; +} var getRPCUrl = (chainId, options) => { if (!Object.values(ChainId).includes(chainId)) { throw new Error( @@ -23254,6 +23275,10 @@ var getRPCUrl = (chainId, options) => { } catch (e) { } } + try { + return getPublicRpc(chainId); + } catch (e) { + } }; // src/action.ts diff --git a/src/lib.ts b/src/lib.ts index 3b81825..295889a 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -1,5 +1,6 @@ import { networkMap } from "./alchemyIds"; import { ChainId, ChainList } from "./chainIds"; +import { publicRPCs } from "./public"; type SupportedChainIds = (typeof ChainId)[keyof typeof ChainId]; @@ -53,6 +54,13 @@ export function getAlchemyRPC(chainId: SupportedChainIds, alchemyKey: string) { return `https://${alchemyId}.g.alchemy.com/v2/${alchemyKey}`; } +export function getPublicRpc(chainId: SupportedChainIds) { + const publicRpc = publicRPCs[chainId as keyof typeof publicRPCs]; + if (!publicRpc) + throw new Error(`No default public rpc for '${chainId}' configured.`); + return publicRpc; +} + type GetRPCUrlOptions = { alchemyKey?: string; }; @@ -89,6 +97,9 @@ export const getRPCUrl = ( return getAlchemyRPC(chainId, options?.alchemyKey); } catch (e) {} } + try { + return getPublicRpc(chainId); + } catch (e) {} }; export { ChainId, ChainList }; diff --git a/src/public.ts b/src/public.ts new file mode 100644 index 0000000..7a1f158 --- /dev/null +++ b/src/public.ts @@ -0,0 +1,15 @@ +import { ChainId } from "./chainIds"; + +export const publicRPCs = { + [ChainId.mainnet]: "https://eth.llamarpc.com", + [ChainId.polygon]: "https://polygon.llamarpc.com", + [ChainId.arbitrum]: "https://polygon.llamarpc.com", + [ChainId.base]: "https://base.llamarpc.com", + [ChainId.bnb]: "https://binance.llamarpc.com", + [ChainId.metis]: "https://andromeda.metis.io/?owner=1088", + [ChainId.gnosis]: "https://rpc.ankr.com/gnosis", + [ChainId.scroll]: "https://rpc.scroll.io", + [ChainId.zksync]: "https://mainnet.era.zksync.io", + [ChainId.fantom]: "https://rpc.ftm.tools", + [ChainId.avalanche]: "https://api.avax.network/ext/bc/C/rpc", +} as const;