mirror of
https://github.com/luxfi/explore.git
synced 2026-07-27 05:54:15 +00:00
- wallet: brandFamilyChains derives sibling networks (Lux mainnet/testnet/devnet)
from the multi-tenant chain registry so connect/add presents EVERY registered
network for the brand, not just the env chain; dedupe by id.
- login/menu: useProvider queryFn returns null (react-query v5 forbids undefined)
+ callers switched from '= {}' destructure default to '?? {}' so a null result
no longer crashes the wallet hooks (the busted-menu root cause).
- manifest: fix Pars chainId 7070 -> 494949 (regression) and drop the forbidden
'Subnet' term from sovereign L1 network names (-> '<Brand> Network').
- Validators page + /api/pchain proxy present; rebuild makes the live 5-validator
view visible on explore.lux.network.
Co-authored-by: Hanzo Dev <dev@hanzo.ai>
98 lines
3.5 KiB
TypeScript
98 lines
3.5 KiB
TypeScript
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
|
|
import type { AppKitNetwork } from '@reown/appkit/networks';
|
|
import type { Chain, Transport } from 'viem';
|
|
import { fallback, http } from 'viem';
|
|
import { createConfig } from 'wagmi';
|
|
|
|
import appConfig from 'configs/app';
|
|
import essentialDappsChainsConfig from 'configs/essential-dapps-chains';
|
|
import multichainConfig from 'configs/multichain';
|
|
import { brandFamilyChains, chains, parentChain } from 'lib/web3/chains';
|
|
|
|
const feature = appConfig.features.blockchainInteraction;
|
|
|
|
// Transports for the brand's sibling networks (Lux testnet/devnet, …) added by
|
|
// lib/web3/chains. wagmi requires a transport per chain; each sibling uses the
|
|
// Blockscout eth-rpc endpoint carried on its viem chain definition.
|
|
const getBrandFamilyTransports = (): Record<string, Transport> =>
|
|
brandFamilyChains.reduce((acc, chain) => {
|
|
const url = chain.rpcUrls.default.http[0];
|
|
if (url) {
|
|
acc[chain.id] = http(url, { batch: { wait: 100, batchSize: 5 } });
|
|
}
|
|
return acc;
|
|
}, {} as Record<string, Transport>);
|
|
|
|
const getChainTransportFromConfig = (config: Partial<typeof appConfig> | undefined, readOnly?: boolean): Record<string, Transport> => {
|
|
if (!config?.chain?.id) {
|
|
return {};
|
|
}
|
|
|
|
return {
|
|
[config.chain.id]: fallback(
|
|
config.chain.rpcUrls
|
|
.concat(readOnly && config.apis?.general ? `${ config.apis.general.endpoint }${ config.apis.general.basePath ?? '' }/api/eth-rpc` : '')
|
|
.filter(Boolean)
|
|
.map((url) => http(url, { batch: { wait: 100, batchSize: 5 } })),
|
|
),
|
|
};
|
|
};
|
|
|
|
const reduceExternalChainsToTransportConfig = (readOnly: boolean): Record<string, Transport> => {
|
|
const multichain = multichainConfig();
|
|
const essentialDapps = essentialDappsChainsConfig();
|
|
const chains = [ ...(multichain?.chains ?? []), ...(essentialDapps?.chains ?? []) ].filter(Boolean);
|
|
|
|
if (!chains) {
|
|
return {};
|
|
}
|
|
|
|
return chains
|
|
.map(({ app_config: config }) => getChainTransportFromConfig(config, readOnly))
|
|
.reduce((result, item) => {
|
|
Object.entries(item).map(([ id, transport ]) => {
|
|
result[id] = transport;
|
|
});
|
|
return result;
|
|
}, {} as Record<string, Transport>);
|
|
};
|
|
|
|
const wagmi = (() => {
|
|
|
|
if (!feature.isEnabled || feature.connectorType === 'dynamic') {
|
|
const wagmiConfig = createConfig({
|
|
chains: chains as [Chain, ...Array<Chain>],
|
|
transports: {
|
|
...getChainTransportFromConfig(appConfig, true),
|
|
...(parentChain ? { [parentChain.id]: http(parentChain.rpcUrls.default.http[0]) } : {}),
|
|
...getBrandFamilyTransports(),
|
|
...reduceExternalChainsToTransportConfig(true),
|
|
},
|
|
ssr: true,
|
|
batch: { multicall: { wait: 100, batchSize: 5 } },
|
|
multiInjectedProviderDiscovery: feature.isEnabled && feature.connectorType === 'dynamic' ? false : true,
|
|
});
|
|
|
|
return { config: wagmiConfig, adapter: null };
|
|
}
|
|
|
|
const wagmiAdapter = new WagmiAdapter({
|
|
networks: chains as Array<AppKitNetwork>,
|
|
multiInjectedProviderDiscovery: true,
|
|
transports: {
|
|
...getChainTransportFromConfig(appConfig, false),
|
|
...(parentChain ? { [parentChain.id]: http() } : {}),
|
|
...getBrandFamilyTransports(),
|
|
...reduceExternalChainsToTransportConfig(false),
|
|
},
|
|
projectId: feature.reown.projectId,
|
|
ssr: true,
|
|
batch: { multicall: { wait: 100, batchSize: 5 } },
|
|
syncConnectedChain: false,
|
|
});
|
|
|
|
return { config: wagmiAdapter.wagmiConfig, adapter: wagmiAdapter };
|
|
})();
|
|
|
|
export default wagmi;
|