diff --git a/wallets/react-wallet-v2/src/components/PageHeader.tsx b/wallets/react-wallet-v2/src/components/PageHeader.tsx index b6f92fe..b187271 100644 --- a/wallets/react-wallet-v2/src/components/PageHeader.tsx +++ b/wallets/react-wallet-v2/src/components/PageHeader.tsx @@ -1,9 +1,15 @@ import { Text } from '@nextui-org/react' +/** + * Types + */ interface Props { children: string } +/** + * Component + */ export default function PageHeader({ children }: Props) { return ( { - actions.createWallet() - await actions.createWalletConnectClient() - actions.setInitialized() - }, [actions]) + walletActions.createWallet() + await walletActions.createWalletConnectClient() + walletActions.setInitialized() + }, [walletActions]) useEffect(() => { - if (!initialized) { + if (!waletReady) { onInitialize() } - }, [initialized, onInitialize]) + }, [waletReady, onInitialize]) return ( - {initialized ? ( + {waletReady ? ( Header diff --git a/wallets/react-wallet-v2/src/contexts/AccountContext.tsx b/wallets/react-wallet-v2/src/contexts/AccountContext.tsx new file mode 100644 index 0000000..e69de29 diff --git a/wallets/react-wallet-v2/src/contexts/WalletContext.tsx b/wallets/react-wallet-v2/src/contexts/WalletContext.tsx index 1553383..d13a8ef 100644 --- a/wallets/react-wallet-v2/src/contexts/WalletContext.tsx +++ b/wallets/react-wallet-v2/src/contexts/WalletContext.tsx @@ -7,7 +7,7 @@ import { createContext, ReactNode, useMemo, useState } from 'react' * Types */ interface State { - initialized: boolean + ready: boolean wallet: Wallet walletConnectClient: WalletConnectClient } @@ -19,8 +19,8 @@ interface Actions { } interface Context { - state: State - actions: Actions + walletState: State + walletActions: Actions } interface Props { @@ -33,13 +33,13 @@ interface Props { export const WalletContext = createContext({} as Context) export function WalletContextProvider({ children }: Props) { - const [state, setState] = useState({ - initialized: false, + const [walletState, setState] = useState({ + ready: false, wallet: undefined, walletConnectClient: undefined }) - const actions = useMemo( + const walletActions = useMemo( () => ({ setInitialized() { setState(s => ({ ...s, initialized: true })) @@ -70,5 +70,9 @@ export function WalletContextProvider({ children }: Props) { [] ) - return {children} + return ( + + {children} + + ) }