Files
explore/lib/api/luxnet/instance.ts
T
zeekayandHanzo Dev e53f9cd22f fix(explore): reconcile chainIds to live/canonical + migrate chain RPC to /v1 (v1.1.7)
chainId reconciliation (registry = live chains = genesis LP-018 map, one way):
- Pars mainnet 7070 -> 494949 (live api.pars.network eth_chainId=0x78d65,
  net_version=494949); Pars testnet 7071 -> 494950, devnet 7072 -> 494951
  (matches genesis configs/lp182_chain_id_map.go 4949xx scheme).
- Lux devnet 96370 -> 96367 (live api.lux-dev.network reports 96367).
- chainRegistry.spec.ts now asserts Pars 494949 (was stale-7070 assert).
- Also fixed: configmap-mainnet Pars NETWORK_ID, configmap-testnet Pars
  NETWORK_ID, branded_build.sh, tools/send_test_txs.py, well-known/explore.json
  (regenerated from the fixed registry).

RPC /ext/bc/<alias>/rpc -> /v1/bc/C/rpc (gateway canonical; each sovereign L1
serves its own C-Chain at /v1/bc/C/rpc). Verified returning blocks before switch:
Lux/Zoo/Hanzo/Pars mainnet + Lux testnet. Kept on /ext (their /v1 not up yet):
Lux devnet, brand testnets, local-node compose/test-tool URLs. P-chain proxy
now dials /v1/bc/P. useChainHeights + luxnet/instance no longer strip
/ext/bc/C/rpc; they use the env RPC URL / origin directly so C-chain height +
luxnet SDK work under /v1.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-14 10:06:17 -07:00

36 lines
990 B
TypeScript

import Lux from 'luxnet';
import { getEnvValue } from 'configs/app/utils';
const HTTPS_PORT = 443;
const HTTP_PORT = 80;
function parseRpcUrl(): { host: string; port: number; protocol: string } {
const rpcUrl = getEnvValue('NEXT_PUBLIC_NETWORK_RPC_URL');
if (!rpcUrl) {
throw new Error('NEXT_PUBLIC_NETWORK_RPC_URL is not configured');
}
// The luxnet SDK builds its own chain paths from scheme+host+port, so we
// only need the origin of the RPC URL — independent of its path scheme
// (canonical `/v1/bc/C/rpc`).
const url = new URL(rpcUrl);
const defaultPort = url.protocol === 'https:' ? HTTPS_PORT : HTTP_PORT;
return {
host: url.hostname,
port: url.port ? Number(url.port) : defaultPort,
protocol: url.protocol.replace(':', ''),
};
}
let instance: Lux | undefined;
export function getLux(): Lux {
if (!instance) {
const { host, port, protocol } = parseRpcUrl();
instance = new Lux(host, port, protocol);
}
return instance;
}