diff --git a/README.md b/README.md index 0056ec0c..a78188c5 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,45 @@ const config: IConfigProps = { }; ``` +_IConfigProps Clarifications_ + +```ts +import { GlobalConfigProps } from '@portkey/did-ui-react/dist/_types/src/components/config-provider/types'; +import { SignInProps, ISignIn, PortkeyProvider } from '@portkey/did-ui-react'; +import { WalletAdapter } from '@aelf-web-login/wallet-adapter-base'; + +interface IConfirmLogoutDialogProps { + title: string; + subTitle: string[]; + okTxt: string; + cancelTxt: string; + visible: boolean; + onOk: () => void; + onCancel: () => void; + width: number; + mobileWidth: number; +} + +interface IConfigProps { + didConfig: GlobalConfigProps; + baseConfig: IBaseConfig; + wallets: WalletAdapter[]; +} +interface IBaseConfig { + networkType: NetworkEnum; + chainId: TChainId; + keyboard?: boolean; + design?: SignInDesignEnum; + iconSrcForSocialDesign?: string; + titleForSocialDesign?: string; + noCommonBaseModal?: boolean; + showVconsole?: boolean; + SignInComponent?: React.FC>; + PortkeyProviderProps?: Partial, 'children'>>; + ConfirmLogoutDialog?: React.FC>; +} +``` + # Usage 1. Import `WebLoginProvider`, `init` and `useConnectWallet` diff --git a/packages/base/package.json b/packages/base/package.json index 2242d7e3..68dd467b 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-base", - "version": "0.1.3-alpha.2", + "version": "0.1.3-alpha.5", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/bridge/package.json b/packages/bridge/package.json index ee8bfa9c..5a275cdf 100755 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-bridge", - "version": "0.1.3-alpha.2", + "version": "0.1.3-alpha.5", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/bridge/src/bridge.ts b/packages/bridge/src/bridge.ts index c7352020..a4120e86 100644 --- a/packages/bridge/src/bridge.ts +++ b/packages/bridge/src/bridge.ts @@ -26,6 +26,7 @@ import { DIDWalletInfo, TelegramPlatform } from '@portkey/did-ui-react'; import { isPortkeyApp } from '@aelf-web-login/utils'; import { IBaseConfig } from '.'; +let isDisconnectClicked = false; class Bridge { private _wallets: WalletAdapter[]; private _activeWallet: WalletAdapter | undefined; @@ -80,19 +81,24 @@ class Bridge { return new Promise((resolve, reject) => { this._loginResolve = resolve; this._loginReject = reject; - console.log('connect'); this.openLoginPanel(); }); }; disConnect = async (isDoubleCheck = false) => { - console.log('disconnect', isDoubleCheck, this.isAAWallet); + console.log('disconnect, isDoubleCheck: isAAWallet:', isDoubleCheck, this.isAAWallet); try { if (isDoubleCheck || (this.isAAWallet && this.activeWallet!.noNeedForConfirm)) { + if (isDisconnectClicked) { + return; + } + isDisconnectClicked = true; + // only click confirmLogout button/or noNeedForConfirm can enter here await this.activeWallet?.logout(); this.closeConfirmLogoutPanel(); this.closeLockPanel(); + isDisconnectClicked = false; } else { if (this.isAAWallet) { this.openConfirmLogoutPanel(); @@ -170,7 +176,6 @@ class Bridge { }; onConnectedHandler = (walletInfo: TWalletInfo) => { - console.log('xxxxxxxxxxxxx-------'); dispatch(setWalletInfo(walletInfo)); dispatch(setWalletType(this.activeWallet?.name)); dispatch(clearLoginError()); @@ -256,9 +261,9 @@ class Bridge { console.log('onUniqueWalletClick--', e); } finally { if (!this._noCommonBaseModal) { - this.closeLoadingModal(); this.closeLoginPanel(); } + this.closeLoadingModal(); } }; diff --git a/packages/bridge/src/index.ts b/packages/bridge/src/index.ts index 9d4a6cf4..0b65a4d3 100644 --- a/packages/bridge/src/index.ts +++ b/packages/bridge/src/index.ts @@ -11,6 +11,7 @@ import { store, AppStore } from './store'; import { GlobalConfigProps } from '@portkey/did-ui-react/dist/_types/src/components/config-provider/types'; import { ConfigProvider, SignInProps, ISignIn, PortkeyProvider } from '@portkey/did-ui-react'; import { RefAttributes } from 'react'; +import { IConfirmLogoutDialogProps } from './ui'; type BaseConfigProviderProps = Omit, 'children'>; @@ -25,6 +26,7 @@ export interface IBaseConfig { showVconsole?: boolean; SignInComponent?: React.FC>; PortkeyProviderProps?: Partial; + ConfirmLogoutDialog?: React.FC>; } export interface IConfigProps { didConfig: GlobalConfigProps; diff --git a/packages/bridge/src/store.ts b/packages/bridge/src/store.ts index 567e90f3..eb4405b3 100644 --- a/packages/bridge/src/store.ts +++ b/packages/bridge/src/store.ts @@ -55,12 +55,16 @@ export const store: EnhancedStore = configureStore({ 'walletInfo.extraInfo.provider', 'walletInfo.extraInfo.portkeyInfo.walletInfo', 'walletInfo.extraInfo.nightElfInfo', + 'loginError.nativeError', + 'payload.nativeError', ], // Ignore these paths in the state ignoredPaths: [ 'walletInfo.extraInfo.provider', 'walletInfo.extraInfo.portkeyInfo.walletInfo', 'walletInfo.extraInfo.nightElfInfo', + 'loginError.nativeError', + 'payload.nativeError', ], }, }), diff --git a/packages/bridge/src/ui.tsx b/packages/bridge/src/ui.tsx index 696865b0..467a0def 100644 --- a/packages/bridge/src/ui.tsx +++ b/packages/bridge/src/ui.tsx @@ -21,7 +21,7 @@ import { Modal, Button, Typography, Drawer } from 'antd'; import useTelegram from './useTelegram'; import './ui.css'; -interface ConfirmLogoutDialogProps { +export interface IConfirmLogoutDialogProps { title: string; subTitle: string[]; okTxt: string; @@ -49,7 +49,7 @@ const constant = { connectWallet: 'Connect Wallet', }; -const defaultProps: Partial = { +const defaultProps: Partial = { title: 'Are you sure you want to exit your wallet?', subTitle: [ 'Your current wallet and assets will be removed from this app permanently. This action cannot be undone.', @@ -71,7 +71,7 @@ interface ISignInModalProps { } const { isMobile } = utils; -const ConfirmLogoutDialog = (props: Partial) => { +const ConfirmLogoutDialog = (props: Partial) => { const { title, subTitle, okTxt, cancelTxt, visible, onOk, onCancel, width, mobileWidth } = { ...defaultProps, ...props, @@ -235,8 +235,13 @@ const SignInModal: React.FC = (props: ISignInModalProps) => { ); const filteredWallets = wallets.filter((ele) => ele.name !== PORTKEYAA); const isMobileDevice = isMobile(); - const { noCommonBaseModal = false, SignInComponent } = baseConfig; + const { + noCommonBaseModal = false, + SignInComponent, + ConfirmLogoutDialog: CustomizedConfirmLogoutDialog, + } = baseConfig; const FinalSignInComponent = SignInComponent || SignIn; + const FinalConfirmLogoutDialog = CustomizedConfirmLogoutDialog || ConfirmLogoutDialog; // const isLocking = store.getState().isLocking; // console.log('isLocking', isLocking); @@ -446,7 +451,7 @@ const SignInModal: React.FC = (props: ISignInModalProps) => { )} - { try { - const appName = this._config.appName; + const appName = this.appName; const chainId = this._config.chainId; const isValidPinCode = await this.checkPassword(appName, password); if (!isValidPinCode) { return; } + const localWallet = await did.load(password, appName); + let caInfo = localWallet.didWallet.caInfo[chainId]; let caHash = caInfo?.caHash; if (!caInfo) { diff --git a/packages/wallets/portkey-discover/package.json b/packages/wallets/portkey-discover/package.json index 47524300..63d77bd1 100755 --- a/packages/wallets/portkey-discover/package.json +++ b/packages/wallets/portkey-discover/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-portkey-discover", - "version": "0.1.3-alpha.2", + "version": "0.1.3-alpha.5", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js",