@aptos-labs/wallet-adapter-core 2.2.0 → 2.3.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/CHANGELOG.md +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
- package/src/WalletCore.ts +14 -12
package/CHANGELOG.md
CHANGED
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
|
@@ -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
|
@@ -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();
|