Skip to content

Commit

Permalink
wallet context
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenmarcus committed Feb 23, 2023
1 parent af5cdd8 commit 9c5cbb4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/react/src/WalletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,22 @@ export type WalletContext = {
signMessage: (params: VerifyOwnerParams) => Promise<VerifiedOwner>;
}


export interface WalletContextProviderProps {
network?: Network;
children?: React.ReactNode;
}

export type WalletSetupComponents = {
selector: WalletSelector;
modal: WalletSelectorModal;
}

export const WalletContext = createContext<WalletContext | null>(null);

export const WalletContextProvider: React.FC<React.PropsWithChildren> = (
{ children }, network: Network,
) => {
export const WalletContextProvider = (
{ children, network }: WalletContextProviderProps,
): JSX.Element => {
const [errorMessage, setErrorMessage] = useState<string>(null);
const [components, setComponents] = useState<WalletSelectorComponents | null>(null);
const [accounts, setAccounts] = useState<AccountState[]>([]);
Expand All @@ -54,7 +60,7 @@ export const WalletContextProvider: React.FC<React.PropsWithChildren> = (
console.log('networksssssssss', WalletNetwork, network, mbjs.keys.network);


const components = await setupWalletSelectorComponents(WalletNetwork || network || mbjs.keys.network);
const components = await setupWalletSelectorComponents(network || WalletNetwork || mbjs.keys.network);
setIsWalletSelectorSetup(true);
setComponents(components);
}, []);
Expand Down

0 comments on commit 9c5cbb4

Please sign in to comment.