Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass keybord paramters to SignIn #155

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading