@provablehq/aleo-wallet-adaptor-leo 0.1.1-alpha.0 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -5
- package/dist/index.mjs +11 -6
- package/package.json +4 -4
- package/src/LeoWalletAdapter.ts +11 -7
package/dist/index.js
CHANGED
|
@@ -87,7 +87,9 @@ var LeoWalletAdapter = class extends import_aleo_wallet_adaptor_core.BaseAleoWal
|
|
|
87
87
|
this._readyState = typeof window === "undefined" || typeof document === "undefined" ? import_aleo_wallet_standard.WalletReadyState.UNSUPPORTED : import_aleo_wallet_standard.WalletReadyState.NOT_DETECTED;
|
|
88
88
|
console.debug("LeoWalletAdapter constructor", config);
|
|
89
89
|
this.network = import_aleo_types2.Network.TESTNET3;
|
|
90
|
-
this.
|
|
90
|
+
if (this._readyState !== import_aleo_wallet_standard.WalletReadyState.UNSUPPORTED) {
|
|
91
|
+
(0, import_aleo_wallet_adaptor_core.scopePollingDetectionStrategy)(() => this._checkAvailability());
|
|
92
|
+
}
|
|
91
93
|
this._leoWallet = this._window?.leoWallet || this._window?.leo;
|
|
92
94
|
if (config?.isMobile) {
|
|
93
95
|
this.url = `https://app.leo.app/browser?url=${config.mobileWebviewUrl}`;
|
|
@@ -97,18 +99,20 @@ var LeoWalletAdapter = class extends import_aleo_wallet_adaptor_core.BaseAleoWal
|
|
|
97
99
|
* Check if Leo wallet is available
|
|
98
100
|
*/
|
|
99
101
|
_checkAvailability() {
|
|
100
|
-
|
|
101
|
-
this.readyState = import_aleo_wallet_standard.WalletReadyState.UNSUPPORTED;
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
102
|
+
console.debug("Checking Leo Wallet availability");
|
|
104
103
|
this._window = window;
|
|
105
104
|
if (this._window.leoWallet || this._window.leo) {
|
|
106
105
|
this.readyState = import_aleo_wallet_standard.WalletReadyState.INSTALLED;
|
|
106
|
+
console.debug("Leo Wallet is installed");
|
|
107
|
+
return true;
|
|
107
108
|
} else {
|
|
108
109
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
109
110
|
if (isMobile) {
|
|
110
111
|
this.readyState = import_aleo_wallet_standard.WalletReadyState.LOADABLE;
|
|
112
|
+
return true;
|
|
111
113
|
}
|
|
114
|
+
console.debug("Leo Wallet is not available");
|
|
115
|
+
return false;
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
WalletError,
|
|
18
18
|
WalletNotConnectedError,
|
|
19
19
|
WalletSignMessageError,
|
|
20
|
-
WalletTransactionError
|
|
20
|
+
WalletTransactionError,
|
|
21
|
+
scopePollingDetectionStrategy
|
|
21
22
|
} from "@provablehq/aleo-wallet-adaptor-core";
|
|
22
23
|
|
|
23
24
|
// src/types.ts
|
|
@@ -75,7 +76,9 @@ var LeoWalletAdapter = class extends BaseAleoWalletAdapter {
|
|
|
75
76
|
this._readyState = typeof window === "undefined" || typeof document === "undefined" ? WalletReadyState.UNSUPPORTED : WalletReadyState.NOT_DETECTED;
|
|
76
77
|
console.debug("LeoWalletAdapter constructor", config);
|
|
77
78
|
this.network = Network2.TESTNET3;
|
|
78
|
-
this.
|
|
79
|
+
if (this._readyState !== WalletReadyState.UNSUPPORTED) {
|
|
80
|
+
scopePollingDetectionStrategy(() => this._checkAvailability());
|
|
81
|
+
}
|
|
79
82
|
this._leoWallet = this._window?.leoWallet || this._window?.leo;
|
|
80
83
|
if (config?.isMobile) {
|
|
81
84
|
this.url = `https://app.leo.app/browser?url=${config.mobileWebviewUrl}`;
|
|
@@ -85,18 +88,20 @@ var LeoWalletAdapter = class extends BaseAleoWalletAdapter {
|
|
|
85
88
|
* Check if Leo wallet is available
|
|
86
89
|
*/
|
|
87
90
|
_checkAvailability() {
|
|
88
|
-
|
|
89
|
-
this.readyState = WalletReadyState.UNSUPPORTED;
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
91
|
+
console.debug("Checking Leo Wallet availability");
|
|
92
92
|
this._window = window;
|
|
93
93
|
if (this._window.leoWallet || this._window.leo) {
|
|
94
94
|
this.readyState = WalletReadyState.INSTALLED;
|
|
95
|
+
console.debug("Leo Wallet is installed");
|
|
96
|
+
return true;
|
|
95
97
|
} else {
|
|
96
98
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
97
99
|
if (isMobile) {
|
|
98
100
|
this.readyState = WalletReadyState.LOADABLE;
|
|
101
|
+
return true;
|
|
99
102
|
}
|
|
103
|
+
console.debug("Leo Wallet is not available");
|
|
104
|
+
return false;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provablehq/aleo-wallet-adaptor-leo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.0",
|
|
4
4
|
"description": "Leo wallet adapter for Aleo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"src"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@provablehq/aleo-
|
|
15
|
-
"@provablehq/aleo-wallet-standard": "0.
|
|
16
|
-
"@provablehq/aleo-
|
|
14
|
+
"@provablehq/aleo-wallet-adaptor-core": "0.3.0-alpha.0",
|
|
15
|
+
"@provablehq/aleo-wallet-standard": "0.3.0-alpha.0",
|
|
16
|
+
"@provablehq/aleo-types": "0.3.0-alpha.0"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
package/src/LeoWalletAdapter.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
WalletNotConnectedError,
|
|
23
23
|
WalletSignMessageError,
|
|
24
24
|
WalletTransactionError,
|
|
25
|
+
scopePollingDetectionStrategy,
|
|
25
26
|
} from '@provablehq/aleo-wallet-adaptor-core';
|
|
26
27
|
import {
|
|
27
28
|
AleoTransaction,
|
|
@@ -89,7 +90,9 @@ export class LeoWalletAdapter extends BaseAleoWalletAdapter {
|
|
|
89
90
|
super();
|
|
90
91
|
console.debug('LeoWalletAdapter constructor', config);
|
|
91
92
|
this.network = Network.TESTNET3;
|
|
92
|
-
this.
|
|
93
|
+
if (this._readyState !== WalletReadyState.UNSUPPORTED) {
|
|
94
|
+
scopePollingDetectionStrategy(() => this._checkAvailability());
|
|
95
|
+
}
|
|
93
96
|
this._leoWallet = this._window?.leoWallet || this._window?.leo;
|
|
94
97
|
if (config?.isMobile) {
|
|
95
98
|
this.url = `https://app.leo.app/browser?url=${config.mobileWebviewUrl}`;
|
|
@@ -99,22 +102,23 @@ export class LeoWalletAdapter extends BaseAleoWalletAdapter {
|
|
|
99
102
|
/**
|
|
100
103
|
* Check if Leo wallet is available
|
|
101
104
|
*/
|
|
102
|
-
private _checkAvailability():
|
|
103
|
-
|
|
104
|
-
this.readyState = WalletReadyState.UNSUPPORTED;
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
105
|
+
private _checkAvailability(): boolean {
|
|
106
|
+
console.debug('Checking Leo Wallet availability');
|
|
108
107
|
this._window = window as LeoWindow;
|
|
109
108
|
|
|
110
109
|
if (this._window.leoWallet || this._window.leo) {
|
|
111
110
|
this.readyState = WalletReadyState.INSTALLED;
|
|
111
|
+
console.debug('Leo Wallet is installed');
|
|
112
|
+
return true;
|
|
112
113
|
} else {
|
|
113
114
|
// Check if user is on a mobile device
|
|
114
115
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
115
116
|
if (isMobile) {
|
|
116
117
|
this.readyState = WalletReadyState.LOADABLE;
|
|
118
|
+
return true;
|
|
117
119
|
}
|
|
120
|
+
console.debug('Leo Wallet is not available');
|
|
121
|
+
return false;
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
|