mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* context for storing subchain config and tx view for subchain * address page and block page for subchain * address aggregated page: local txs tab * connect MultichainSelect to context * home page placeholder * refactor subchain select state * envs for demo * fix ts * clear value for l2 review * subchain widgets on home page * csp policies * sockets, duck and goose * fix socket on subchain address page * link builder for subchain views * update home widget * fix time increment * enable tx interpretator and metadata service * generate multichain config based on every chain app config * Fix the multichain config to work in Docker * multichain socket test * rename subchain-id to subchain-slug path param * refactoring * update chain icons on entities * home page: latest local txs * latest cross-chain txs * minor improvements * renaming, pt. 1 * rename chain routes * enable blockchain interaction * add loading state to icon shield * fix build * fix tests * update types package
85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import type { AppKitNetwork } from '@reown/appkit/networks';
|
|
import { createAppKit, useAppKitTheme } from '@reown/appkit/react';
|
|
import React from 'react';
|
|
import { WagmiProvider } from 'wagmi';
|
|
|
|
import config from 'configs/app';
|
|
import { currentChain, parentChain, clusterChains } from 'lib/web3/chains';
|
|
import wagmiConfig from 'lib/web3/wagmiConfig';
|
|
import { useColorMode } from 'toolkit/chakra/color-mode';
|
|
import colors from 'toolkit/theme/foundations/colors';
|
|
import { BODY_TYPEFACE } from 'toolkit/theme/foundations/typography';
|
|
import zIndex from 'toolkit/theme/foundations/zIndex';
|
|
|
|
const feature = config.features.blockchainInteraction;
|
|
|
|
const init = () => {
|
|
try {
|
|
if (!feature.isEnabled || !wagmiConfig.adapter) {
|
|
return;
|
|
}
|
|
|
|
const networks = [ currentChain, parentChain, ...(clusterChains ?? []) ].filter(Boolean) as [AppKitNetwork, ...Array<AppKitNetwork>];
|
|
|
|
createAppKit({
|
|
adapters: [ wagmiConfig.adapter ],
|
|
networks,
|
|
metadata: {
|
|
name: `${ config.chain.name } explorer`,
|
|
description: `${ config.chain.name } explorer`,
|
|
url: config.app.baseUrl,
|
|
icons: [ config.UI.navigation.icon.default ].filter(Boolean),
|
|
},
|
|
projectId: feature.walletConnect.projectId,
|
|
features: {
|
|
analytics: false,
|
|
email: false,
|
|
socials: [],
|
|
onramp: false,
|
|
swaps: false,
|
|
},
|
|
themeVariables: {
|
|
'--w3m-font-family': `${ BODY_TYPEFACE }, sans-serif`,
|
|
'--w3m-accent': colors.blue[600].value,
|
|
'--w3m-border-radius-master': '2px',
|
|
'--w3m-z-index': zIndex?.modal2?.value,
|
|
},
|
|
featuredWalletIds: [],
|
|
allowUnsupportedChain: true,
|
|
});
|
|
} catch (error) {}
|
|
};
|
|
|
|
init();
|
|
|
|
interface Props {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
const DefaultProvider = ({ children }: Props) => {
|
|
return (
|
|
<WagmiProvider config={ wagmiConfig.config }>
|
|
{ children }
|
|
</WagmiProvider>
|
|
);
|
|
};
|
|
|
|
const Web3ModalProvider = ({ children }: Props) => {
|
|
const { colorMode } = useColorMode();
|
|
const { setThemeMode } = useAppKitTheme();
|
|
|
|
React.useEffect(() => {
|
|
setThemeMode(colorMode ?? 'light');
|
|
}, [ colorMode, setThemeMode ]);
|
|
|
|
return (
|
|
<DefaultProvider>
|
|
{ children }
|
|
</DefaultProvider>
|
|
);
|
|
};
|
|
|
|
const Provider = feature.isEnabled ? Web3ModalProvider : DefaultProvider;
|
|
|
|
export default Provider;
|