diff --git a/package.json b/package.json index 652d62cb..a4edab52 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "devDependencies": { "@babel/parser": "^7.24.0", "@biomejs/biome": "^1.4.1", - "@changesets/changelog-git": "^0.2.0", + "@changesets/changelog-git": "^0.2.1-alpha.3", "@changesets/cli": "^2.27.1", "@ianvs/prettier-plugin-sort-imports": "^4.1.1", "@testing-library/react": "^14.1.2", diff --git a/packages/base/package.json b/packages/base/package.json index 2f056d3b..4e539a5f 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-base", - "version": "0.2.0", + "version": "0.2.1-alpha.3", "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 9098a1d6..c61a0b50 100755 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-bridge", - "version": "0.2.0", + "version": "0.2.1-alpha.3", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/bridge/src/index.ts b/packages/bridge/src/index.ts index 17b4a59e..0d8533f3 100644 --- a/packages/bridge/src/index.ts +++ b/packages/bridge/src/index.ts @@ -60,3 +60,5 @@ export function initBridge({ baseConfig, wallets, didConfig }: IConfigProps): IB } export * as PortkeyDid from '@portkey/did-ui-react'; + +// export { demoFn } from './ui'; diff --git a/packages/bridge/src/ui.tsx b/packages/bridge/src/ui.tsx index 52b60bd0..de6c252b 100644 --- a/packages/bridge/src/ui.tsx +++ b/packages/bridge/src/ui.tsx @@ -5,6 +5,7 @@ import { enhancedLocalStorage, PORTKEYAA, OperationTypeEnum, + // EventEmitter, } from '@aelf-web-login/wallet-adapter-base'; import { Bridge } from './bridge'; import { @@ -76,6 +77,8 @@ interface ISignInModalProps { } const { isMobile } = utils; +// const EE = new EventEmitter(); + const ConfirmLogoutDialog = (props: Partial) => { const { title, subTitle, okTxt, cancelTxt, visible, onOk, onCancel, width, mobileWidth } = { ...defaultProps, @@ -295,30 +298,34 @@ const SignInModal: React.FC = (props: ISignInModalProps) => { } console.log('begin to excute autoAuthInTelegram'); if (enhancedLocalStorage.getItem('connectedWallet') === PORTKEYAA) { - ConfigProvider.setGlobalConfig({ - globalLoadingHandler: { - onSetLoading: (loadingInfo) => { - console.log(loadingInfo, 'loadingInfo==='); + if (enableAcceleration) { + ConfigProvider.setGlobalConfig({ + globalLoadingHandler: { + onSetLoading: (loadingInfo) => { + console.log(loadingInfo, 'loadingInfo==='); + }, }, - }, - }); + }); + } await bridgeInstance.onPortkeyAAUnLock(defaultPin); return; } if (!cancelAutoLoginInTelegram) { - ConfigProvider.setGlobalConfig({ - globalLoadingHandler: { - onSetLoading: (loadingInfo) => { - console.log(loadingInfo, 'loadingInfo==='); + if (enableAcceleration) { + ConfigProvider.setGlobalConfig({ + globalLoadingHandler: { + onSetLoading: (loadingInfo) => { + console.log(loadingInfo, 'loadingInfo==='); + }, }, - }, - }); + }); + } console.log('begin to excute handleTelegram'); handleTelegram(); } } autoAuthInTelegram(); - }, [bridgeInstance, cancelAutoLoginInTelegram, defaultPin, handleTelegram]); + }, [bridgeInstance, cancelAutoLoginInTelegram, defaultPin, enableAcceleration, handleTelegram]); bridgeInstance.autoLogin = () => { handleTelegram(); @@ -512,6 +519,18 @@ const SignInModal: React.FC = (props: ISignInModalProps) => { ); }, [onForgetPinHandler]); + // const [showGuardianApprovalModal, setShowGuardianApprovalModal] = useState(false); + + // useEffect(() => { + // const hander = (args: boolean) => { + // setShowGuardianApprovalModal(args); + // }; + // EE.on('SET_GLOBAL_LOADING_1', hander); + // return () => { + // EE.off('SET_GLOBAL_LOADING_1', hander); + // }; + // }, []); + return ( //
@@ -583,3 +602,10 @@ const SignInModal: React.FC = (props: ISignInModalProps) => { }; export default SignInModal; + +// const demoFn = (bool: boolean) => { +// console.log('demoFn', EE); +// EE.emit('SET_GLOBAL_LOADING_1', bool); +// }; + +// export { demoFn }; diff --git a/packages/bridge/src/useTelegram.ts b/packages/bridge/src/useTelegram.ts index bef1fbec..63e734dd 100644 --- a/packages/bridge/src/useTelegram.ts +++ b/packages/bridge/src/useTelegram.ts @@ -205,7 +205,7 @@ const useTelegram = ( async (value: IGuardianIdentifierInfo, extraData?: TOnSuccessExtraData) => { // setDrawerVisible(false); // setModalVisible(false); - if (extraData) { + if (enableAcceleration && extraData) { setOriginChainId(extraData.originChainId); setCaHash(extraData.caHash); caInfoRef.current = { @@ -244,7 +244,7 @@ const useTelegram = ( } } else { setLoading(false); - if (isTelegramPlatform) { + if (isTelegramPlatform && enableAcceleration) { console.log('intg-----------more guardian', signResult.value.guardianList); setGuardianList(signResult.value.guardianList || []); setTimeout(() => { @@ -277,17 +277,21 @@ const useTelegram = ( }); const handleTelegram = useCallback(async () => { - const res = await socialLoginAuth({ - type: SocialLoginType.TELEGRAM, - network: network, - }); + try { + const res = await socialLoginAuth({ + type: SocialLoginType.TELEGRAM, + network: network, + }); - console.log('socialLoginAuth', res); + console.log('socialLoginAuth', res); - signHandle.onSocialFinish({ - type: res!.provider, - data: { accessToken: res!.token }, - }); + signHandle.onSocialFinish({ + type: res!.provider, + data: { accessToken: res!.token }, + }); + } catch (e) { + console.log('execute await socialLoginAuth error', e); + } }, [network, signHandle]); const onTGSignInApprovalSuccess = useCallback( diff --git a/packages/react/package.json b/packages/react/package.json index 1fe36278..5fa0e009 100755 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-react", - "version": "0.2.0", + "version": "0.2.1-alpha.3", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/starter/src/Demo/LoginDemo.tsx b/packages/starter/src/Demo/LoginDemo.tsx index 50202eeb..f388243a 100644 --- a/packages/starter/src/Demo/LoginDemo.tsx +++ b/packages/starter/src/Demo/LoginDemo.tsx @@ -1,6 +1,7 @@ import { useEffect } from 'react'; import { Button, message, Divider, Flex } from 'antd'; import { useConnectWallet } from '@aelf-web-login/wallet-adapter-react'; +// import { demoFn } from '@aelf-web-login/wallet-adapter-bridge'; const LoginDemo: React.FC = () => { const { @@ -47,6 +48,20 @@ const LoginDemo: React.FC = () => { return (
+ {/* + */} diff --git a/packages/starter/src/Demo/demo.tsx b/packages/starter/src/Demo/demo.tsx index ba9402b9..edb67d4d 100644 --- a/packages/starter/src/Demo/demo.tsx +++ b/packages/starter/src/Demo/demo.tsx @@ -83,6 +83,7 @@ const wallets = [ chainId: CHAIN_ID, autoShowUnlock: true, noNeedForConfirm: true, + enableAcceleration: true, }), // new PortkeyDiscoverWallet({ // networkType: NETWORK_TYPE, diff --git a/packages/utils/package.json b/packages/utils/package.json index 2c4c8361..dceaa8e0 100755 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/utils", - "version": "0.2.0", + "version": "0.2.1-alpha.3", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/wallets/night-elf/package.json b/packages/wallets/night-elf/package.json index 3db0b310..2b1f795c 100755 --- a/packages/wallets/night-elf/package.json +++ b/packages/wallets/night-elf/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-night-elf", - "version": "0.2.0", + "version": "0.2.1-alpha.3", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/wallets/portkey-aa/package.json b/packages/wallets/portkey-aa/package.json index e10fe0b2..ecf0372a 100755 --- a/packages/wallets/portkey-aa/package.json +++ b/packages/wallets/portkey-aa/package.json @@ -1,6 +1,6 @@ { "name": "@aelf-web-login/wallet-adapter-portkey-aa", - "version": "0.2.0", + "version": "0.2.1-alpha.3", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js", diff --git a/packages/wallets/portkey-aa/src/index.ts b/packages/wallets/portkey-aa/src/index.ts index 861f075c..f74b772c 100644 --- a/packages/wallets/portkey-aa/src/index.ts +++ b/packages/wallets/portkey-aa/src/index.ts @@ -32,6 +32,7 @@ export interface IPortkeyAAWalletAdapterConfig { chainId: TChainId; autoShowUnlock: boolean; noNeedForConfirm?: boolean; + enableAcceleration?: boolean; } type TStatus = 'initial' | 'inBeforeLastGuardianApprove' | 'inCreatePending' | 'inFinish'; @@ -126,6 +127,7 @@ export class PortkeyAAWallet extends BaseWalletAdapter { enhancedLocalStorage.setItem(PORTKEY_ORIGIN_CHAIN_ID_KEY, didWalletInfo.chainId); this._loginState = LoginStateEnum.CONNECTING; const chainId = this._config.chainId; + const enableAcceleration = this._config.enableAcceleration; if (didWalletInfo.chainId !== chainId) { const caInfo = await did.didWallet.getHolderInfoByContract({ caHash: didWalletInfo.caInfo?.caHash, @@ -135,7 +137,7 @@ export class PortkeyAAWallet extends BaseWalletAdapter { } let nickName = 'Wallet 01'; - if (this._status !== 'inBeforeLastGuardianApprove') { + if (enableAcceleration && this._status !== 'inBeforeLastGuardianApprove') { try { const holderInfo = await did.getCAHolderInfo(didWalletInfo.chainId); nickName = holderInfo.nickName; @@ -177,6 +179,7 @@ export class PortkeyAAWallet extends BaseWalletAdapter { this._status = 'inFinish'; } this.emit('connected', this._wallet); + this.emit('loginOnChainStatusChanged', did.didWallet.isLoginStatus!); console.log('did.didWallet.isLoginStatus-1', did.didWallet.isLoginStatus); return this._wallet; } catch (error) { @@ -507,16 +510,20 @@ export class PortkeyAAWallet extends BaseWalletAdapter { args, sendOptions, }: ICallContractParams) { + const enableAcceleration = this._config.enableAcceleration; if (!this._wallet) { throw makeError(ERR_CODE.PORTKEY_AA_NOT_CONNECTED); } if (!contractAddress) { throw makeError(ERR_CODE.INVALID_CONTRACT_ADDRESS); } - if (this._status === 'initial' || this._status === 'inBeforeLastGuardianApprove') { + if ( + enableAcceleration && + (this._status === 'initial' || this._status === 'inBeforeLastGuardianApprove') + ) { throw makeError(ERR_CODE.CANT_CALL_SEND_METHOD); } - if (this._status === 'inCreatePending') { + if (enableAcceleration && this._status === 'inCreatePending') { console.log( '----------in callSendMethod and _status is inCreatePending, begin to execute getLoginStatus, sessionId=', did.didWallet.sessionId, diff --git a/packages/wallets/portkey-discover/package.json b/packages/wallets/portkey-discover/package.json index fb79457a..14f49c81 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.2.0", + "version": "0.2.1-alpha.3", "type": "module", "main": "dist/esm/index.js", "module": "dist/esm/index.js",