Files
tom goriunovandGitHub 401dc58402 Smart wallet auth (#3220)
* basic login button implementation

* refactoring and add dynamic auth button to the other pages

* connect wallet without authenticating an user

* login and logout user in blockscout account

* refactoring and RPC overrides

* authenticate user with connected wallet

* add ENS to profile button

* override evm chains and fix contract write with waas wallet

* disconnect wallet and fix docker build

* add dynamic imports to components that use web3 wallet packages

* refactor user profile directory

* clean up

* tweaks

* update pw ci script

* fix "connect wallet" button behavior

* handle linking email to profile with dynamic provider

* fix test

* async loading web3 hooks and remove dynamic loading from components that use them

* fix pw tests

* add account navigation in horizontal layout when auth provider is dynamic

* fix address verification modal

* review fixes

* spelling fixes
2026-02-18 19:42:44 +01:00

74 lines
2.1 KiB
TypeScript

import type { AppKitNetwork } from '@reown/appkit/networks';
import { createAppKit, useAppKitTheme } from '@reown/appkit/react';
import React from 'react';
import config from 'configs/app';
import { chains } 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';
import WagmiProvider from './WagmiProvider';
const feature = config.features.blockchainInteraction;
const initReown = () => {
try {
if (!feature.isEnabled || !wagmiConfig.adapter || feature.connectorType === 'dynamic') {
return;
}
createAppKit({
adapters: [ wagmiConfig.adapter ],
networks: chains as [AppKitNetwork, ...Array<AppKitNetwork>],
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.reown.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: feature.reown.featuredWalletIds,
allowUnsupportedChain: true,
});
} catch (error) {}
};
initReown();
interface Props {
children: React.ReactNode;
}
const ReownProvider = ({ children }: Props) => {
const { colorMode } = useColorMode();
const { setThemeMode } = useAppKitTheme();
React.useEffect(() => {
setThemeMode(colorMode ?? 'light');
}, [ colorMode, setThemeMode ]);
return (
<WagmiProvider>
{ children }
</WagmiProvider>
);
};
export default React.memo(ReownProvider);