Skip to content

Commit 32a8bde

Browse files
committed
fix leo and fox wallet detection plus polling errors
bind wallet handles when extensions are detected (same pattern as shield and soter), fix connect error mapping that blamed network mismatch for most failures, and throw after poll retries are exhausted instead of returning undefined
1 parent f730b82 commit 32a8bde

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

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)