Skip to content

Commit

Permalink
Merge pull request #1823 from Web3Auth/feat/hooks-refactor
Browse files Browse the repository at this point in the history
refactor hooks
  • Loading branch information
chaitanyapotti authored May 9, 2024
2 parents b7e4670 + aa2a206 commit 45c18fe
Show file tree
Hide file tree
Showing 47 changed files with 6,463 additions and 5,983 deletions.
9,658 changes: 5,860 additions & 3,798 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions packages/base/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { LoginParams, OpenloginUserInfo } from "@toruslabs/openlogin-utils";

import { ADAPTER_STATUS_TYPE, IProvider, UserAuthInfo } from "../adapter";
import { CustomChainConfig } from "../chain/IChainInterface";
import { IPlugin } from "../plugin";

export interface IBaseWeb3AuthHookContext {
isConnected: boolean;
provider: IProvider | null;
userInfo: Partial<OpenloginUserInfo> | null;
isMFAEnabled: boolean;
isInitialized: boolean;
status: ADAPTER_STATUS_TYPE | null;
enableMFA(params?: LoginParams): Promise<void>;
logout(params?: { cleanup: boolean }): Promise<void>;
addAndSwitchChain(chainConfig: CustomChainConfig): Promise<void>;
addPlugin(plugin: IPlugin): void;
getPlugin(pluginName: string): IPlugin | null;
authenticateUser(): Promise<UserAuthInfo>;
addChain(chainConfig: CustomChainConfig): Promise<void>;
switchChain(params: { chainId: string }): Promise<void>;
}

export interface IBaseWalletServicesHookContext {
isConnected: boolean;
showWalletConnectScanner(): Promise<void>;
showCheckout(): Promise<void>;
showWalletUI(): Promise<void>;
}
1 change: 1 addition & 0 deletions packages/base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./chain/config";
export * from "./chain/IChainInterface";
export * from "./core/IWeb3Auth";
export * from "./errors";
export * from "./hooks";
export { default as log } from "./loglevel";
export * from "./plugin";
export * from "./provider/IProvider";
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/plugin/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class WalletServicesPluginError extends Web3AuthError {
return WalletServicesPluginError.fromCode(5218, extraMessage);
}

public static differentWeb3authNetwork(extraMessage = ""): IWeb3AuthError {
public static differentWeb3AuthNetwork(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5219, extraMessage);
}

Expand Down
Loading

0 comments on commit 45c18fe

Please sign in to comment.