@aptos-labs/wallet-adapter-core 2.2.0 → 2.3.1
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/CHANGELOG.md +19 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/WalletCore.ts +14 -12
- package/src/utils/helpers.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @aptos-labs/wallet-adapter-core
|
|
2
2
|
|
|
3
|
+
## 2.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 06f334f: @aptos-labs/wallet-adapter-core:
|
|
8
|
+
Fixes ssr issue with checking for mobile wallets
|
|
9
|
+
|
|
10
|
+
@aptos-labs/wallet-adapter-mui-design:
|
|
11
|
+
Breaking:
|
|
12
|
+
When on a mobile phone on the native browser, we removed all wallets that are not able to be deep linked to.
|
|
13
|
+
The previous functionally would take them to the extension, which would not help users on mobile phones.
|
|
14
|
+
|
|
15
|
+
## 2.3.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- bb1595e: Fix deeplink redirect
|
|
20
|
+
- 1605d28: Support ReadonlyArray of Wallets in AptosWalletAdapterProvider and WalletCore
|
|
21
|
+
|
|
3
22
|
## 2.2.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
122
122
|
private _network;
|
|
123
123
|
private _connecting;
|
|
124
124
|
private _connected;
|
|
125
|
-
constructor(plugins: Wallet
|
|
125
|
+
constructor(plugins: ReadonlyArray<Wallet>);
|
|
126
126
|
private scopePollingDetectionStrategy;
|
|
127
127
|
private doesWalletExist;
|
|
128
128
|
private clearData;
|
|
@@ -131,7 +131,7 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
131
131
|
setAccount(account: AccountInfo | null): void;
|
|
132
132
|
setNetwork(network: NetworkInfo | null): void;
|
|
133
133
|
isConnected(): boolean;
|
|
134
|
-
get wallets(): Wallet
|
|
134
|
+
get wallets(): ReadonlyArray<Wallet>;
|
|
135
135
|
/**
|
|
136
136
|
* Getter for the current connected wallet
|
|
137
137
|
* @return wallet info
|
package/dist/index.js
CHANGED
|
@@ -210,7 +210,7 @@ function isInAppBrowser() {
|
|
|
210
210
|
return isIphone || isAndroid;
|
|
211
211
|
}
|
|
212
212
|
function isRedirectable() {
|
|
213
|
-
if (!navigator)
|
|
213
|
+
if (typeof navigator === "undefined" || !navigator)
|
|
214
214
|
return false;
|
|
215
215
|
return isMobile() && !isInAppBrowser();
|
|
216
216
|
}
|
|
@@ -340,9 +340,8 @@ var WalletCore = class extends import_eventemitter3.default {
|
|
|
340
340
|
const selectedWallet = (_a = this._wallets) == null ? void 0 : _a.find(
|
|
341
341
|
(wallet) => wallet.name === walletName
|
|
342
342
|
);
|
|
343
|
-
if (!selectedWallet
|
|
343
|
+
if (!selectedWallet)
|
|
344
344
|
return;
|
|
345
|
-
}
|
|
346
345
|
if (this._connected) {
|
|
347
346
|
if (((_b = this.wallet) == null ? void 0 : _b.name) === walletName)
|
|
348
347
|
return;
|
|
@@ -353,10 +352,11 @@ var WalletCore = class extends import_eventemitter3.default {
|
|
|
353
352
|
const url = encodeURIComponent(window.location.href);
|
|
354
353
|
const location = selectedWallet.deeplinkProvider({ url });
|
|
355
354
|
window.location.href = location;
|
|
356
|
-
} else {
|
|
357
|
-
return;
|
|
358
355
|
}
|
|
359
356
|
}
|
|
357
|
+
if (selectedWallet.readyState !== "Installed" /* Installed */ && selectedWallet.readyState !== "Loadable" /* Loadable */) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
360
|
this._connecting = true;
|
|
361
361
|
this.setWallet(selectedWallet);
|
|
362
362
|
const account = await selectedWallet.connect();
|
package/dist/index.mjs
CHANGED
|
@@ -169,7 +169,7 @@ function isInAppBrowser() {
|
|
|
169
169
|
return isIphone || isAndroid;
|
|
170
170
|
}
|
|
171
171
|
function isRedirectable() {
|
|
172
|
-
if (!navigator)
|
|
172
|
+
if (typeof navigator === "undefined" || !navigator)
|
|
173
173
|
return false;
|
|
174
174
|
return isMobile() && !isInAppBrowser();
|
|
175
175
|
}
|
|
@@ -299,9 +299,8 @@ var WalletCore = class extends EventEmitter {
|
|
|
299
299
|
const selectedWallet = (_a = this._wallets) == null ? void 0 : _a.find(
|
|
300
300
|
(wallet) => wallet.name === walletName
|
|
301
301
|
);
|
|
302
|
-
if (!selectedWallet
|
|
302
|
+
if (!selectedWallet)
|
|
303
303
|
return;
|
|
304
|
-
}
|
|
305
304
|
if (this._connected) {
|
|
306
305
|
if (((_b = this.wallet) == null ? void 0 : _b.name) === walletName)
|
|
307
306
|
return;
|
|
@@ -312,10 +311,11 @@ var WalletCore = class extends EventEmitter {
|
|
|
312
311
|
const url = encodeURIComponent(window.location.href);
|
|
313
312
|
const location = selectedWallet.deeplinkProvider({ url });
|
|
314
313
|
window.location.href = location;
|
|
315
|
-
} else {
|
|
316
|
-
return;
|
|
317
314
|
}
|
|
318
315
|
}
|
|
316
|
+
if (selectedWallet.readyState !== "Installed" /* Installed */ && selectedWallet.readyState !== "Loadable" /* Loadable */) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
319
|
this._connecting = true;
|
|
320
320
|
this.setWallet(selectedWallet);
|
|
321
321
|
const account = await selectedWallet.connect();
|
package/package.json
CHANGED
package/src/WalletCore.ts
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
import { getNameByAddress } from "./ans";
|
|
40
40
|
|
|
41
41
|
export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
42
|
-
private _wallets: Wallet
|
|
42
|
+
private _wallets: ReadonlyArray<Wallet> = [];
|
|
43
43
|
private _wallet: Wallet | null = null;
|
|
44
44
|
private _account: AccountInfo | null = null;
|
|
45
45
|
private _network: NetworkInfo | null = null;
|
|
@@ -47,7 +47,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
47
47
|
private _connecting: boolean = false;
|
|
48
48
|
private _connected: boolean = false;
|
|
49
49
|
|
|
50
|
-
constructor(plugins: Wallet
|
|
50
|
+
constructor(plugins: ReadonlyArray<Wallet>) {
|
|
51
51
|
super();
|
|
52
52
|
this._wallets = plugins;
|
|
53
53
|
this.scopePollingDetectionStrategy();
|
|
@@ -123,7 +123,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
123
123
|
return this._connected;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
get wallets(): Wallet
|
|
126
|
+
get wallets(): ReadonlyArray<Wallet> {
|
|
127
127
|
return this._wallets;
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -187,13 +187,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
187
187
|
(wallet: Wallet) => wallet.name === walletName
|
|
188
188
|
);
|
|
189
189
|
|
|
190
|
-
if (
|
|
191
|
-
!selectedWallet ||
|
|
192
|
-
(selectedWallet.readyState !== WalletReadyState.Installed &&
|
|
193
|
-
selectedWallet.readyState !== WalletReadyState.Loadable)
|
|
194
|
-
) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
190
|
+
if (!selectedWallet) return;
|
|
197
191
|
|
|
198
192
|
if (this._connected) {
|
|
199
193
|
// if the selected wallet is already connected, we don't need to connect again
|
|
@@ -201,16 +195,24 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
201
195
|
|
|
202
196
|
await this.disconnect();
|
|
203
197
|
}
|
|
198
|
+
|
|
199
|
+
// check if we are in a redirectable view (i.e on mobile AND not in an in-app browser) and
|
|
200
|
+
// since wallet readyState can be NotDetected, we check it before the next check
|
|
204
201
|
if (isRedirectable()) {
|
|
205
202
|
// use wallet deep link
|
|
206
203
|
if (selectedWallet.deeplinkProvider) {
|
|
207
204
|
const url = encodeURIComponent(window.location.href);
|
|
208
205
|
const location = selectedWallet.deeplinkProvider({ url });
|
|
209
206
|
window.location.href = location;
|
|
210
|
-
} else {
|
|
211
|
-
return;
|
|
212
207
|
}
|
|
213
208
|
}
|
|
209
|
+
if (
|
|
210
|
+
selectedWallet.readyState !== WalletReadyState.Installed &&
|
|
211
|
+
selectedWallet.readyState !== WalletReadyState.Loadable
|
|
212
|
+
) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
214
216
|
this._connecting = true;
|
|
215
217
|
this.setWallet(selectedWallet);
|
|
216
218
|
const account = await selectedWallet.connect();
|
package/src/utils/helpers.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function isInAppBrowser(): boolean {
|
|
|
18
18
|
|
|
19
19
|
export function isRedirectable(): boolean {
|
|
20
20
|
// SSR: return false
|
|
21
|
-
if (!navigator) return false;
|
|
21
|
+
if (typeof navigator === 'undefined' || !navigator) return false;
|
|
22
22
|
|
|
23
23
|
// if we are on mobile and NOT in a in-app browser we will redirect to a wallet app
|
|
24
24
|
|