@puzzlehq/sdk-core
Version:
Your portal to privacy
19 lines (17 loc) • 586 B
text/typescript
export const hasInjectedConnection = () => {
if (typeof window === 'undefined') {
return false;
}
const injectedConnection = !!window?.aleo?.puzzleWalletClient;
return injectedConnection;
};
export const waitForInjectedConnection = async () => {
const startTime = Date.now();
while (!hasInjectedConnection()) {
if (Date.now() - startTime > 5000) {
throw new Error('Puzzle wallet not detected within 5 seconds');
}
console.log('Puzzle wallet not detected! Waiting for 0.25 seconds');
await new Promise((resolve) => setTimeout(resolve, 250));
}
}