Skip to content

Commit

Permalink
fix: some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jake4take committed Dec 6, 2024
1 parent 10bf964 commit 11f90f4
Showing 1 changed file with 30 additions and 31 deletions.
61 changes: 30 additions & 31 deletions packages/wallets/src/okx/services/service.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
import { BrowserContext } from '@playwright/test';

export async function checkNetworkName(networkName: string) {
switch (networkName) {
case 'zkSync Era Mainnet':
return 'zkSync Era';
case 'OP Mainnet':
return 'Optimism';
case 'Polygon Mainnet':
return 'Polygon';
case 'Base Mainnet':
return 'Base';
case 'Binance Smart Chain':
return 'BNB Chain';
case 'Mantle Mainnet':
return 'Mantle';
case 'Scroll Mainnet':
return 'Scroll';
case 'Mode':
return 'Mode Network';
default:
return networkName;
const incorrectNetworkNames = new Map<string, string>([
['zkSync Era Mainnet', 'zkSync Era'],
['OP Mainnet', 'Optimism'],
['Polygon Mainnet', 'Polygon'],
['Base Mainnet', 'Base'],
['Binance Smart Chain', 'BNB Chain'],
['Mantle Mainnet', 'Mantle'],
['Scroll Mainnet', 'Scroll'],
['Mode', 'Mode Network'],
]);

const OkxIncludedNetwork = [
'Linea',
'zkSync Era',
'Polygon',
'Base',
'BNB Chain',
'Mantle',
'Scroll',
'Mode Network',
'Zircuit',
];

/** Check network name and return correct name suited for OKX Wallet*/
export function checkNetworkName(networkName: string) {
for (const [incorrectName, correctName] of incorrectNetworkNames.entries()) {
if (networkName === incorrectName) {
return correctName;
}
}
return networkName;
}

export async function closeUnnecessaryPages(browserContext: BrowserContext) {
Expand All @@ -33,16 +43,5 @@ export async function closeUnnecessaryPages(browserContext: BrowserContext) {
/** Before AddNetwork() we check the network is included in wallet or not*/
export async function isNeedAddNetwork(network: string) {
const networkName = await checkNetworkName(network);
const OkxIncludedNetwork = [
'Linea',
'zkSync Era',
'Polygon',
'Base',
'BNB Chain',
'Mantle',
'Scroll',
'Mode Network',
'Zircuit',
];
return !OkxIncludedNetwork.includes(networkName);
}

0 comments on commit 11f90f4

Please sign in to comment.