import type { AElfContextType } from '@aelf-react/core/dist/types'; import { DIDWalletInfo, ISignIn } from '@portkey/did-ui-react'; import { DIDWalletInfo as DIDWalletInfoV1, ISignIn as ISignInV1 } from '@portkey-v1/did-ui-react'; import type { IHolderInfo } from '@portkey/services'; import type { Accounts, ChainIds, IPortkeyProvider } from '@portkey/provider-types'; import type { RefAttributes } from 'react'; import { ConfirmLogoutDialogProps } from './components/CofirmLogoutDialog'; import { ChainId, SendOptions } from '@portkey/types'; import { ChainId as ChainIdV1, SendOptions as SendOptionsV1 } from '@portkey-v1/types'; import { SignInProps, TDesign } from '@portkey/did-ui-react'; import { IPortkeyContract } from '@portkey/contracts'; import { IPortkeyContract as IPortkeyContractV1 } from '@portkey-v1/contracts'; /** * WebLoginProvider types */ export type ExtraWalletNames = 'discover' | 'elf'; export type NightElfOptions = { connectEagerly: boolean; useMultiChain?: boolean; onClick?: OnClickCryptoWallet; onPluginNotFound?: PluginNotFoundCallback; }; export type PortkeyOptions = { autoShowUnlock: boolean; checkAccountInfoSync: boolean; SignInComponent?: React.FC | RefAttributes)>; ConfirmLogoutDialog?: React.FC>; design?: TDesign; noCommonBaseModal?: boolean; keyboard?: { v1?: boolean; v2?: boolean; }; }; export type PluginNotFoundCallback = (openPluginStorePage: (version?: 'v1') => void) => void; export type OnClickCryptoWallet = (continueDefaultBehaviour: () => void) => void; export type DiscoverOptions = { autoRequestAccount: boolean; autoLogoutOnDisconnected: boolean; autoLogoutOnNetworkMismatch: boolean; autoLogoutOnAccountMismatch: boolean; autoLogoutOnChainMismatch: boolean; onClick?: OnClickCryptoWallet; onPluginNotFound?: PluginNotFoundCallback; }; export interface ICommonConfig { showClose?: boolean; iconSrc?: string; title?: string; } export type WebLoginProviderProps = { nightElf: NightElfOptions; portkey: PortkeyOptions; discover: DiscoverOptions; extraWallets?: Array; children: React.ReactNode; commonConfig?: ICommonConfig; }; /** * callContract */ export interface CallContractParams { contractAddress: string; methodName: string; args: T; options?: { chainId?: ChainId | ChainIdV1; }; } export type CallContractFunc = (params: CallContractParams) => Promise; /** * getSignature */ export type SignatureParams = { appName: string; address: string; signInfo: string; hexToBeSign?: string; }; export type SignatureData = { signature: string; error: number; errorMessage: string; from: string; }; export type GetSignatureFunc = (params: SignatureParams) => Promise; /** * wallet */ export type PortkeyInfo = DIDWalletInfo & { nickName: string; accounts: { [key: string]: string; }; }; export type PortkeyInfoV1 = DIDWalletInfoV1 & { nickName: string; accounts: { [key: string]: string; }; }; export type DiscoverInfo = { address: string; accounts: Accounts; nickName?: string; provider?: IPortkeyProvider; }; export type WalletInfo = { name?: string; address: string; publicKey?: string; nightElfInfo?: AElfContextType; portkeyInfo?: PortkeyInfo | PortkeyInfoV1; discoverInfo?: DiscoverInfo; accountInfoSync: { syncCompleted: boolean; holderInfo?: IHolderInfo; chainIds?: ChainIds; }; }; /** * switch wallet */ export type DoSwitchFunc = (commit: () => Promise, rollback: () => Promise) => Promise; export type SwitchWalletFunc = (doSwitch: DoSwitchFunc) => Promise; export interface LogoutOptions { noModal?: boolean; } /** * useWebLogin */ export type WalletHookInterface = { wallet: WalletInfo; loginEagerly: () => void; login: () => void; loginBySwitch: () => void; logout: (options?: LogoutOptions) => void; logoutSilently: () => Promise; switchWallet: SwitchWalletFunc; callContract(params: CallContractParams, sendOptions?: SendOptions | SendOptionsV1): Promise; getSignature(params: SignatureParams): Promise; changeVersion?: () => void; }; /** * useCallContract */ export type CallContractHookOptions = { chainId?: string; rpcUrl?: string; cache?: boolean; }; export type CallContractHookInterface = { contractHookId: string; callViewMethod(params: CallContractParams): Promise; callSendMethod(params: CallContractParams, sendOptions: SendOptions | SendOptionsV1 | undefined): Promise; }; /** * useContract */ export type ContractHookOptions = { chainId?: string; rpcUrl?: string; cache?: boolean; }; export interface IPortkeySendAdapterProps { caContract: IPortkeyContract | IPortkeyContractV1; didWalletInfo: DIDWalletInfo | DIDWalletInfoV1; params: CallContractParams; chainId: ChainId | ChainIdV1; sendOptions?: SendOptions | SendOptionsV1; }