-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: useConnectWallet hook, explicit onLogin handling
- Loading branch information
1 parent
499a656
commit 13036f2
Showing
7 changed files
with
40 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,17 @@ | ||
import { useMPCWallet, MPCWalletState } from '@/hooks/wallets/mpc/useMPCWallet' | ||
import { type UserInfo } from '@web3auth/mpc-core-kit' | ||
import { useMPCWallet, MPCWalletState, type MPCWalletHook } from '@/hooks/wallets/mpc/useMPCWallet' | ||
import { createContext, type ReactElement } from 'react' | ||
|
||
type MPCWalletContext = { | ||
loginPending: boolean | ||
triggerLogin: () => Promise<void> | ||
resetAccount: () => Promise<void> | ||
upsertPasswordBackup: (password: string) => Promise<void> | ||
recoverFactorWithPassword: (password: string, storeDeviceFactor: boolean) => Promise<void> | ||
walletState: MPCWalletState | ||
userInfo: UserInfo | undefined | ||
} | ||
|
||
export const MpcWalletContext = createContext<MPCWalletContext>({ | ||
loginPending: false, | ||
export const MpcWalletContext = createContext<MPCWalletHook>({ | ||
walletState: MPCWalletState.NOT_INITIALIZED, | ||
triggerLogin: () => Promise.resolve(), | ||
triggerLogin: () => Promise.resolve(false), | ||
resetAccount: () => Promise.resolve(), | ||
upsertPasswordBackup: () => Promise.resolve(), | ||
recoverFactorWithPassword: () => Promise.resolve(), | ||
recoverFactorWithPassword: () => Promise.resolve(false), | ||
userInfo: undefined, | ||
}) | ||
|
||
export const MpcWalletProvider = ({ children }: { children: ReactElement }) => { | ||
const mpcValue = useMPCWallet() | ||
|
||
return ( | ||
<MpcWalletContext.Provider | ||
value={{ ...mpcValue, loginPending: mpcValue.walletState === MPCWalletState.AUTHENTICATING }} | ||
> | ||
{children} | ||
</MpcWalletContext.Provider> | ||
) | ||
return <MpcWalletContext.Provider value={mpcValue}>{children}</MpcWalletContext.Provider> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
.bulletList { | ||
list-style: none; | ||
margin-bottom: auto; | ||
padding: 0; | ||
} | ||
|
||
.bulletList li { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters