Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use browser env vars for Solana and Injective RPC URLs #371

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/consts/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import {
import { ChainMap, ChainMetadata, ExplorerFamily } from '@hyperlane-xyz/sdk';
import { ProtocolType } from '@hyperlane-xyz/utils';

function getOverrideRpcUrls(chainName: string): { http: string }[] {
const envVar = process.env[`NEXT_PUBLIC_${chainName.toUpperCase()}_RPC_URL`];
return envVar ? [{ http: envVar }] : [];
}

// A map of chain names to ChainMetadata
// Chains can be defined here, in chains.json, or in chains.yaml
// Chains already in the SDK need not be included here unless you want to override some fields
Expand All @@ -23,20 +18,19 @@ export const chains: ChainMap<ChainMetadata & { mailbox?: Address }> = {
// SVM chains require mailbox addresses for the token adapters
mailbox: solanamainnetAddresses.mailbox,
// Including a convenient rpc override because the Solana public RPC does not allow browser requests from localhost
rpcUrls: [
// For backward compatibility
...getOverrideRpcUrls('solana'),
...getOverrideRpcUrls('solanamainnet'),
...solanamainnet.rpcUrls,
],
rpcUrls: process.env.NEXT_PUBLIC_SOLANA_RPC_URL
? [{ http: process.env.NEXT_PUBLIC_SOLANA_RPC_URL }, ...solanamainnet.rpcUrls]
: solanamainnet.rpcUrls,
},
eclipsemainnet: {
...eclipsemainnet,
mailbox: eclipsemainnetAddresses.mailbox,
},
injective: {
...injective,
rpcUrls: [...getOverrideRpcUrls('injective'), ...injective.rpcUrls],
rpcUrls: process.env.NEXT_PUBLIC_INJECTIVE_RPC_URL
? [{ http: process.env.NEXT_PUBLIC_INJECTIVE_RPC_URL }, ...injective.rpcUrls]
: injective.rpcUrls,
},
// mycustomchain: {
// protocol: ProtocolType.Ethereum,
Expand Down
Loading