Skip to content

Commit b192e7e

Browse files
authored
Merge pull request #89 from mooncitydev/fix/wallet-detect-and-polling-errors
fix leo and fox wallet connect plus mapping poll retries
2 parents f730b82 + 8d613dc commit b192e7e

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

.changeset/cold-bears-fix.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@provablehq/aleo-hooks': patch
3+
'@provablehq/aleo-wallet-adaptor-fox': patch
4+
'@provablehq/aleo-wallet-adaptor-leo': patch
5+
---
6+
7+
Fix wallet detection rebinding and error handling in Leo/Fox adapters, and make mapping polling throw once retries are exhausted.

packages/aleo-hooks/src/createConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ export class State {
3030
);
3131
return callback(value);
3232
} catch (error) {
33+
retries--;
3334
if (retries === 0) {
3435
throw error;
3536
}
36-
console.error(error);
37-
retries--;
38-
console.log('Retrying...');
39-
console.log(retries, 'retries left');
4037
await new Promise(resolve => setTimeout(resolve, interval));
4138
}
4239
}

packages/aleo-wallet-adaptor/wallets/fox/src/FoxWalletAdapter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export class FoxWalletAdapter extends BaseAleoWalletAdapter {
9090
if (this._readyState !== WalletReadyState.UNSUPPORTED) {
9191
scopePollingDetectionStrategy(() => this._checkAvailability());
9292
}
93-
this._foxWallet = this._window?.foxwallet?.aleo;
9493
}
9594

9695
/**
@@ -106,6 +105,7 @@ export class FoxWalletAdapter extends BaseAleoWalletAdapter {
106105
this._window = window as FoxWindow;
107106

108107
if (this._window.foxwallet?.aleo) {
108+
this._foxWallet = this._window.foxwallet.aleo;
109109
this.readyState = WalletReadyState.INSTALLED;
110110
this.emit('readyStateChange', this.readyState);
111111
return true;
@@ -139,10 +139,8 @@ export class FoxWalletAdapter extends BaseAleoWalletAdapter {
139139
if (
140140
error instanceof Object &&
141141
'name' in error &&
142-
(error.name === 'InvalidParamsAleoWalletError' ||
143-
error.name !== 'NotGrantedAleoWalletError')
142+
error.name === 'InvalidParamsAleoWalletError'
144143
) {
145-
// TODO: Handle wrongNetwork at WalletProvider level?
146144
throw new WalletConnectionError(
147145
'Connection failed: Likely due to a difference in configured network and the selected wallet network. Configured network: ' +
148146
network,

packages/aleo-wallet-adaptor/wallets/leo/src/LeoWalletAdapter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export class LeoWalletAdapter extends BaseAleoWalletAdapter {
9494
if (this._readyState !== WalletReadyState.UNSUPPORTED) {
9595
scopePollingDetectionStrategy(() => this._checkAvailability());
9696
}
97-
this._leoWallet = this._window?.leoWallet || this._window?.leo;
9897
if (config?.isMobile) {
9998
this.url = `https://app.leo.app/browser?url=${config.mobileWebviewUrl}`;
10099
}
@@ -107,6 +106,7 @@ export class LeoWalletAdapter extends BaseAleoWalletAdapter {
107106
this._window = window as LeoWindow;
108107

109108
if (this._window.leoWallet || this._window.leo) {
109+
this._leoWallet = this._window.leoWallet ?? this._window.leo;
110110
this.readyState = WalletReadyState.INSTALLED;
111111
this.emit('readyStateChange', this.readyState);
112112
// Wake up service worker
@@ -140,10 +140,8 @@ export class LeoWalletAdapter extends BaseAleoWalletAdapter {
140140
if (
141141
error instanceof Object &&
142142
'name' in error &&
143-
(error.name === 'InvalidParamsAleoWalletError' ||
144-
error.name !== 'NotGrantedAleoWalletError')
143+
error.name === 'InvalidParamsAleoWalletError'
145144
) {
146-
// TODO: Handle wrongNetwork at WalletProvider level?
147145
throw new WalletConnectionError(
148146
'Connection failed: Likely due to a difference in configured network and the selected wallet network. Configured network: ' +
149147
network,

0 commit comments

Comments
 (0)