Skip to content

Commit

Permalink
Merge pull request #369 from hyperlane-xyz/trevor/inj-rpcs
Browse files Browse the repository at this point in the history
fix: allow Injective RPC to be overridden
  • Loading branch information
tkporter authored Jan 7, 2025
2 parents d3d78c7 + 5ef3acc commit 16681db
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/consts/chains.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {
eclipsemainnet,
eclipsemainnetAddresses,
injective,
solanamainnet,
solanamainnetAddresses,
} from '@hyperlane-xyz/registry';
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 @@ -17,14 +23,21 @@ 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: process.env.NEXT_PUBLIC_SOLANA_RPC_URL
? [{ http: process.env.NEXT_PUBLIC_SOLANA_RPC_URL }, ...solanamainnet.rpcUrls]
: solanamainnet.rpcUrls,
rpcUrls: [
// For backward compatibility
...getOverrideRpcUrls('solana'),
...getOverrideRpcUrls('solanamainnet'),
...solanamainnet.rpcUrls,
],
},
eclipsemainnet: {
...eclipsemainnet,
mailbox: eclipsemainnetAddresses.mailbox,
},
injective: {
...injective,
rpcUrls: [...getOverrideRpcUrls('injective'), ...injective.rpcUrls],
},
// mycustomchain: {
// protocol: ProtocolType.Ethereum,
// chainId: 123123,
Expand Down

0 comments on commit 16681db

Please sign in to comment.