Skip to content

Commit

Permalink
fix: fix ctrl wallet fail to connect problem
Browse files Browse the repository at this point in the history
  • Loading branch information
RyukTheCoder authored and RanGojo committed Dec 30, 2024
1 parent 8522586 commit f1bfedc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions wallets/shared/src/getCosmosAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface CosmosBlockchainMetaWithChainId
chainId: string;
}

const GET_ACCOUNTS_TIMEOUT = 1000;

const getCosmosMainChainsIds = (blockchains: CosmosBlockchainMeta[]) =>
blockchains
.filter((blockchain) => blockchain.info && !blockchain.info.experimental)
Expand Down Expand Up @@ -91,8 +93,14 @@ async function getMainAccounts({
};
})
.filter(Boolean);
const accountsPromises = offlineSigners.map(({ signer }) =>
signer.getAccounts()
const timeout = new Promise((_, reject) =>
setTimeout(
() => reject(new Error('Timeout while fetching accounts')),
GET_ACCOUNTS_TIMEOUT
)
);
const accountsPromises = offlineSigners.map(async ({ signer }) =>
Promise.race([signer.getAccounts(), timeout])
);
const availableAccountForChains = await Promise.allSettled(accountsPromises);
const resolvedAccounts: ProviderConnectResult[] = [];
Expand Down

0 comments on commit f1bfedc

Please sign in to comment.