Skip to content

Commit

Permalink
feat: remove @aelf-web-login/utils from other package, resovle XMLHtt…
Browse files Browse the repository at this point in the history
…pRequest is undefined
  • Loading branch information
aelf-lxy committed Aug 7, 2024
1 parent 99259c3 commit 55f9d52
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 131 deletions.
4 changes: 4 additions & 0 deletions packages/base/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { isMobile } from './isMobile';
import { getOriginalAddress } from './getOriginalAddress';
import { isPortkeyApp } from './isPortkeyApp';
import { sleep } from './sleep';
export default {
isMobile,
getOriginalAddress,
isPortkeyApp,
sleep,
};
7 changes: 7 additions & 0 deletions packages/base/src/utils/isPortkeyApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function isPortkeyApp() {
if (typeof window !== 'object') {
return false;
} else {
return window.navigator.userAgent.includes('Portkey');
}
}
5 changes: 5 additions & 0 deletions packages/base/src/utils/sleep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function sleep(milliSeconds: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, milliSeconds));
}

export { sleep };
1 change: 0 additions & 1 deletion packages/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"build": "father build"
},
"dependencies": {
"@aelf-web-login/utils": "workspace:*",
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/services": "2.7.2",
"@reduxjs/toolkit": "^2.2.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/bridge/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TSignatureParams,
enhancedLocalStorage,
IWalletAdapterEvents,
utils,
} from '@aelf-web-login/wallet-adapter-base';
import {
setWalletInfo,
Expand All @@ -23,9 +24,9 @@ import {
clearLoginError,
} from './store';
import { DIDWalletInfo, TelegramPlatform } from '@portkey/did-ui-react';
import { isPortkeyApp } from '@aelf-web-login/utils';
import { IBaseConfig } from '.';

const { isPortkeyApp } = utils;
let isDisconnectClicked = false;
class Bridge {
private _wallets: WalletAdapter[];
Expand Down
5 changes: 3 additions & 2 deletions packages/bridge/src/useTelegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import {
IVerifyInfo,
TelegramPlatform,
} from '@portkey/did-ui-react';
import { DEFAULT_PIN, TChainId, NetworkEnum } from '@aelf-web-login/wallet-adapter-base';
import { DEFAULT_PIN, TChainId, NetworkEnum, utils } from '@aelf-web-login/wallet-adapter-base';
import { useCallback, useMemo, useState } from 'react';
import { sleep } from '@aelf-web-login/utils';
import { Bridge } from './bridge';
import useVerifier from './useVerifier';
import useLockCallback from './useLockCallback';

const { sleep } = utils;

export enum SocialLoginType {
APPLE = 'Apple',
GOOGLE = 'Google',
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import React, { useCallback, useMemo, useState, useSyncExternalStore } from 'react';
import { initBridge, IConfigProps, IBridgeAPI } from '@aelf-web-login/wallet-adapter-bridge';
import VConsole from 'vconsole';
import {
ConnectedWallet,
enhancedLocalStorage,
Expand All @@ -13,10 +12,12 @@ const HOOK_ERROR_MESSAGE =
// let noCommonBaseModal = false;
export const init = (options: IConfigProps): IBridgeAPI => {
// noCommonBaseModal = options.baseConfig.noCommonBaseModal ?? false;
if (options.baseConfig.showVconsole) {
if (options.baseConfig.showVconsole && typeof window !== 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const VConsole = require('vconsole');
new VConsole();
}
console.log('aelf-web-login-init..............');
console.log('aelf-web-login-init..............30');
function initScriptAndMountApp() {
// const HOSTNAME_PREFIX_LIST = ['tg.', 'tg-test.', 'localhost'];
const TELEGRAM_SRC = 'https://telegram.org/js/telegram-web-app.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
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/contracts": "^2.6.2",
"aelf-bridge": "0.0.10",
"aelf-bridge": "^0.0.11-alpha.4",
"bn.js": "^5.2.1"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/wallets/portkey-discover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"build": "father build"
},
"dependencies": {
"@aelf-web-login/utils": "workspace:*",
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/contracts": "^2.6.2",
"@portkey/detect-provider": "^2.2.0",
Expand Down
Loading

0 comments on commit 55f9d52

Please sign in to comment.