Skip to content

Commit

Permalink
Merge pull request #155 from AElfProject/feature/ecoEarn-support
Browse files Browse the repository at this point in the history
fix: pass keybord paramters to SignIn
  • Loading branch information
aelf-lxy authored Sep 19, 2024
2 parents 4e0a46c + 9b97499 commit 1be4d9c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-base",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-bridge",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
35 changes: 23 additions & 12 deletions packages/bridge/src/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
WalletAdapter,
utils,
Expand Down Expand Up @@ -241,27 +241,38 @@ const SignInModal: React.FC<ISignInModalProps> = (props: ISignInModalProps) => {
ConfirmLogoutDialog: CustomizedConfirmLogoutDialog,
cancelAutoLoginInTelegram = false,
defaultPin = '111111',
keyboard,
} = baseConfig;
const FinalSignInComponent = SignInComponent || SignIn;
const FinalConfirmLogoutDialog = CustomizedConfirmLogoutDialog || ConfirmLogoutDialog;
// const isLocking = store.getState().isLocking;
// console.log('isLocking', isLocking);

const initializeTelegram = () => {
const handleLogout = async () => {
await bridgeInstance.onPortkeyAAUnLock(defaultPin);
await bridgeInstance.doubleCheckDisconnect();
};
TelegramPlatform.initializeTelegramWebApp({ handleLogout });
};
const isToggleAccountRef = useRef(false);

useEffect(() => {
console.log('----------------------2', TelegramPlatform.isTelegramPlatform());
if (!TelegramPlatform.isTelegramPlatform()) {
return;
}

const initializeTelegram = () => {
const handleLogout = async () => {
console.log('begin to execute handleLogout......');
isToggleAccountRef.current = true;
await bridgeInstance.onPortkeyAAUnLock(defaultPin);
await bridgeInstance.doubleCheckDisconnect();
};
TelegramPlatform.initializeTelegramWebApp({ handleLogout });
};

console.log('begin to init and execute handleTelegram', TelegramPlatform.isTelegramPlatform());
initializeTelegram();
async function autoAuthInTelegram() {
console.log('isToggleAccountRef.current:', isToggleAccountRef.current);
if (isToggleAccountRef.current) {
return;
}
console.log('begin to excute autoAuthInTelegram');
if (enhancedLocalStorage.getItem('connectedWallet') === PORTKEYAA) {
await bridgeInstance.onPortkeyAAUnLock(defaultPin);
Expand All @@ -276,7 +287,6 @@ const SignInModal: React.FC<ISignInModalProps> = (props: ISignInModalProps) => {
}, [bridgeInstance, cancelAutoLoginInTelegram, defaultPin, handleTelegram]);

bridgeInstance.autoLogin = () => {
// initializeTelegram();
handleTelegram();
};

Expand Down Expand Up @@ -341,15 +351,15 @@ const SignInModal: React.FC<ISignInModalProps> = (props: ISignInModalProps) => {
const success = await bridgeInstance.onPortkeyAAUnLock(pin);
if (!success) {
setIsWrongPassword(true);
if (isMobileDevice && baseConfig.keyboard) {
if (isMobileDevice && keyboard) {
setPassword('');
}
} else {
setIsWrongPassword(false);
setPassword('');
}
},
[baseConfig.keyboard, bridgeInstance, isMobileDevice],
[keyboard, bridgeInstance, isMobileDevice],
);

const extraWallets = useMemo(() => {
Expand Down Expand Up @@ -435,7 +445,7 @@ const SignInModal: React.FC<ISignInModalProps> = (props: ISignInModalProps) => {
open={true}
value={password}
isWrongPassword={isWrongPassword}
keyboard={baseConfig.keyboard}
keyboard={keyboard}
onChange={setPassword}
onCancel={onCloseWrapperInternal}
onUnlock={onUnlockInternal}
Expand All @@ -453,6 +463,7 @@ const SignInModal: React.FC<ISignInModalProps> = (props: ISignInModalProps) => {
design={baseConfig.design}
isShowScan
extraElementList={[extraWallets]}
keyboard={keyboard}
onCancel={() => {
//TODO: seem to not execute
console.log('onSignInCancel');
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-react",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/utils",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/night-elf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-night-elf",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/portkey-aa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-portkey-aa",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/portkey-discover/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-portkey-discover",
"version": "0.1.8",
"version": "0.1.11",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit 1be4d9c

Please sign in to comment.