Skip to content

Commit

Permalink
Improve the wallets search
Browse files Browse the repository at this point in the history
  • Loading branch information
skubarenko committed Aug 11, 2022
1 parent 1c4ac66 commit 6a8b907
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/blockchain/walletsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ export class WalletsManager {
if (toolkit && wallet.id !== toolkit)
continue;

const addressPromise = address ? wallet.getAddress() : undefined;
const blockchainPromise = blockchain ? wallet.getBlockchain() : undefined;
const addressOrPromise = address ? wallet.getAddress() : undefined;
const blockchainOrPromise = blockchain ? wallet.getBlockchain() : undefined;

walletPromises.push(Promise.all([addressPromise, blockchainPromise]).then(([address, blockchain]) => [wallet, address, blockchain]));
if ((!address || address === addressOrPromise) && (!blockchain || blockchain == blockchainOrPromise))
return wallet;

walletPromises.push(Promise.all([addressOrPromise, blockchainOrPromise]).then(([address, blockchain]) => [wallet, address, blockchain]));
}

const walletResults = await Promise.allSettled(walletPromises);
Expand All @@ -45,7 +48,7 @@ export class WalletsManager {
}

const [wallet, walletAddress, walletBlockchain] = walletResult.value;
if (!address || address === walletAddress && !blockchain || blockchain == walletBlockchain)
if ((!address || address === walletAddress) && (!blockchain || blockchain == walletBlockchain))
return wallet;
}

Expand Down

0 comments on commit 6a8b907

Please sign in to comment.