mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
29 lines
850 B
TypeScript
29 lines
850 B
TypeScript
import type CspDev from 'csp-dev';
|
|
|
|
import multichainConfig from 'configs/multichain';
|
|
|
|
export function multichain(): CspDev.DirectiveDescriptor {
|
|
const value = multichainConfig();
|
|
if (!value) {
|
|
return {};
|
|
}
|
|
|
|
const apiEndpoints = value.chains.map((chain) => {
|
|
return chain.app_config?.apis ? [
|
|
...Object.values(chain.app_config.apis).filter(Boolean).map((api) => api.endpoint),
|
|
...Object.values(chain.app_config.apis).filter(Boolean).map((api) => api.socketEndpoint),
|
|
].filter(Boolean) : [];
|
|
}).flat();
|
|
|
|
const rpcEndpoints = value.chains.map(({ app_config: config }) => config?.chain?.rpcUrls).flat().filter(Boolean);
|
|
|
|
return {
|
|
'connect-src': [
|
|
...apiEndpoints,
|
|
...rpcEndpoints,
|
|
// please see comment in the useFetchParentChainApi.tsx file
|
|
'https://eth.blockscout.com',
|
|
],
|
|
};
|
|
}
|