@aptos-labs/wallet-adapter-core 4.8.2 → 4.9.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/AIP62StandardWallets/sdkWallets.d.ts.map +1 -1
- package/dist/WalletCore.d.ts +20 -10
- package/dist/WalletCore.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.js +94 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -65
- package/dist/index.mjs.map +1 -1
- package/dist/utils/helpers.d.ts +0 -19
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/walletSelector.d.ts +61 -0
- package/dist/utils/walletSelector.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/AIP62StandardWallets/sdkWallets.ts +6 -5
- package/src/WalletCore.ts +61 -37
- package/src/constants.ts +7 -0
- package/src/utils/helpers.ts +0 -47
- package/src/utils/index.ts +1 -1
- package/src/utils/walletSelector.ts +118 -0
- package/src/version.ts +1 -1
- package/dist/utils/aptosConnect.d.ts +0 -18
- package/dist/utils/aptosConnect.d.ts.map +0 -1
- package/src/utils/aptosConnect.ts +0 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkWallets.d.ts","sourceRoot":"","sources":["../../src/AIP62StandardWallets/sdkWallets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"sdkWallets.d.ts","sourceRoot":"","sources":["../../src/AIP62StandardWallets/sdkWallets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,yBAkBpD"}
|
package/dist/WalletCore.d.ts
CHANGED
|
@@ -39,27 +39,37 @@ export declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
39
39
|
network: Network;
|
|
40
40
|
});
|
|
41
41
|
private scopePollingDetectionStrategy;
|
|
42
|
-
private
|
|
42
|
+
private fetchExtensionAIP62AptosWallets;
|
|
43
43
|
private appendNotDetectedStandardSupportedWallets;
|
|
44
44
|
/**
|
|
45
|
-
* Set
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
* 3) push the wallet into a local wallets array
|
|
51
|
-
* 4) standardize each wallet to the Wallet Plugin type interface for legacy compatibility
|
|
45
|
+
* Set AIP-62 SDK wallets
|
|
46
|
+
*/
|
|
47
|
+
private fetchSDKAIP62AptosWallets;
|
|
48
|
+
/**
|
|
49
|
+
* Set AIP-62 extension wallets
|
|
52
50
|
*
|
|
53
51
|
* @param extensionwWallets
|
|
54
52
|
*/
|
|
55
|
-
private
|
|
53
|
+
private setExtensionAIP62Wallets;
|
|
56
54
|
/**
|
|
57
|
-
* A function that excludes
|
|
55
|
+
* A function that excludes an AIP-62 compatible wallet the dapp doesnt want to include
|
|
58
56
|
*
|
|
59
57
|
* @param walletName
|
|
60
58
|
* @returns
|
|
61
59
|
*/
|
|
62
60
|
excludeWallet(wallet: AptosStandardWallet): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Standardize AIP62 wallet
|
|
63
|
+
*
|
|
64
|
+
* 1) check it is Standard compatible
|
|
65
|
+
* 2) Update its readyState to Installed (for a future UI detection)
|
|
66
|
+
* 3) convert it to the Wallet Plugin type interface for legacy compatibility
|
|
67
|
+
* 4) push the wallet into a local standard wallets array
|
|
68
|
+
*
|
|
69
|
+
* @param wallet
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
private standardizeAIP62WalletType;
|
|
63
73
|
/**
|
|
64
74
|
* To maintain support for both plugins and AIP-62 standard wallets,
|
|
65
75
|
* without introducing dapps breaking changes, we convert
|
package/dist/WalletCore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WalletCore.d.ts","sourceRoot":"","sources":["../src/WalletCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAO,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EAGpB,+BAA+B,EAG/B,0BAA0B,EAC1B,0BAA0B,EAK3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,wBAAwB,EAGxB,WAAW,IAAI,mBAAmB,EAClC,YAAY,EAGb,MAAM,6BAA6B,CAAC;AAqBrC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,EACN,gBAAgB,EAChB,UAAU,EAMX,MAAM,uBAAuB,CAAC;AAY/B,OAAO,EACL,mBAAmB,EAEnB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAKhC,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,4BAA4B,CAAC;AAEnE,qBAAa,UAAW,SAAQ,YAAY,CAAC,gBAAgB,CAAC;IAE5D,OAAO,CAAC,QAAQ,CAA6B;IAG7C,OAAO,CAAC,aAAa,CAAuC;IAG5D,OAAO,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"WalletCore.d.ts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;;MAIE;IACI,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBtC;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAgCxE;;;;OAIG;IACG,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAuB1E"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -23,4 +23,8 @@ export declare enum NetworkName {
|
|
|
23
23
|
Devnet = "devnet"
|
|
24
24
|
}
|
|
25
25
|
export declare const ChainIdToAnsSupportedNetworkMap: Record<string, string>;
|
|
26
|
+
/** The base URL for all Aptos Connect wallets. */
|
|
27
|
+
export declare const APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
28
|
+
/** The URL to the Aptos Connect account page if the user is signed in to Aptos Connect. */
|
|
29
|
+
export declare const APTOS_CONNECT_ACCOUNT_URL = "https://aptosconnect.app/dashboard/main-account";
|
|
26
30
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B;;;;OAIG;IACH,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,QAAQ,aAAa;IACrB;;;OAGG;IACH,WAAW,gBAAgB;CAC5B;AAED,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGlE,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B;;;;OAIG;IACH,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,QAAQ,aAAa;IACrB;;;OAGG;IACH,WAAW,gBAAgB;CAC5B;AAED,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGlE,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,2FAA2F;AAC3F,eAAO,MAAM,yBAAyB,oDACa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __export(src_exports, {
|
|
|
46
46
|
getAptosConfig: () => getAptosConfig,
|
|
47
47
|
getAptosConnectWallets: () => getAptosConnectWallets,
|
|
48
48
|
getLocalStorage: () => getLocalStorage,
|
|
49
|
+
groupAndSortWallets: () => groupAndSortWallets,
|
|
49
50
|
isAptosConnectWallet: () => isAptosConnectWallet,
|
|
50
51
|
isAptosNetwork: () => isAptosNetwork,
|
|
51
52
|
isInAppBrowser: () => isInAppBrowser,
|
|
@@ -62,7 +63,7 @@ __export(src_exports, {
|
|
|
62
63
|
module.exports = __toCommonJS(src_exports);
|
|
63
64
|
|
|
64
65
|
// src/version.ts
|
|
65
|
-
var WALLET_ADAPTER_CORE_VERSION = "4.
|
|
66
|
+
var WALLET_ADAPTER_CORE_VERSION = "4.9.0";
|
|
66
67
|
|
|
67
68
|
// src/WalletCore.ts
|
|
68
69
|
var import_aptos4 = require("aptos");
|
|
@@ -76,14 +77,14 @@ var import_wallet_adapter_plugin = require("@aptos-connect/wallet-adapter-plugin
|
|
|
76
77
|
var import_ts_sdk = require("@aptos-labs/ts-sdk");
|
|
77
78
|
function getSDKWallets(dappConfig) {
|
|
78
79
|
const sdkWallets = [];
|
|
80
|
+
if (typeof window !== "undefined") {
|
|
81
|
+
sdkWallets.push(new import_wallet_adapter_plugin.AptosConnectWallet({ network: dappConfig == null ? void 0 : dappConfig.network }));
|
|
82
|
+
}
|
|
79
83
|
if ((dappConfig == null ? void 0 : dappConfig.network) === import_ts_sdk.Network.MAINNET) {
|
|
80
84
|
sdkWallets.push(new import_aptos_wallet_adapter.TWallet());
|
|
81
85
|
} else {
|
|
82
86
|
sdkWallets.push(new import_aptos_wallet_adapter.DevTWallet());
|
|
83
87
|
}
|
|
84
|
-
if (typeof window !== "undefined") {
|
|
85
|
-
sdkWallets.push(new import_wallet_adapter_plugin.AptosConnectWallet({ network: dappConfig == null ? void 0 : dappConfig.network, dappId: dappConfig == null ? void 0 : dappConfig.aptosConnectDappId }));
|
|
86
|
-
}
|
|
87
88
|
return sdkWallets;
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -105,6 +106,8 @@ var ChainIdToAnsSupportedNetworkMap = {
|
|
|
105
106
|
"1": "mainnet",
|
|
106
107
|
"2": "testnet"
|
|
107
108
|
};
|
|
109
|
+
var APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
110
|
+
var APTOS_CONNECT_ACCOUNT_URL = "https://aptosconnect.app/dashboard/main-account";
|
|
108
111
|
|
|
109
112
|
// src/error/index.ts
|
|
110
113
|
var WalletError = class extends Error {
|
|
@@ -338,44 +341,6 @@ var fetchDevnetChainId = async () => {
|
|
|
338
341
|
const aptos = new import_ts_sdk3.Aptos();
|
|
339
342
|
return await aptos.getChainId();
|
|
340
343
|
};
|
|
341
|
-
function partitionWallets(wallets, partitionFunction = isInstalledOrLoadable) {
|
|
342
|
-
const defaultWallets = [];
|
|
343
|
-
const moreWallets = [];
|
|
344
|
-
for (const wallet of wallets) {
|
|
345
|
-
if (partitionFunction(wallet))
|
|
346
|
-
defaultWallets.push(wallet);
|
|
347
|
-
else
|
|
348
|
-
moreWallets.push(wallet);
|
|
349
|
-
}
|
|
350
|
-
return { defaultWallets, moreWallets };
|
|
351
|
-
}
|
|
352
|
-
function isInstalledOrLoadable(wallet) {
|
|
353
|
-
return wallet.readyState === "Installed" /* Installed */ || wallet.readyState === "Loadable" /* Loadable */;
|
|
354
|
-
}
|
|
355
|
-
function isInstallRequired(wallet) {
|
|
356
|
-
const isWalletReady = isInstalledOrLoadable(wallet);
|
|
357
|
-
const isMobile2 = !isWalletReady && isRedirectable();
|
|
358
|
-
return !isMobile2 && !isWalletReady;
|
|
359
|
-
}
|
|
360
|
-
function truncateAddress(address) {
|
|
361
|
-
if (!address)
|
|
362
|
-
return;
|
|
363
|
-
return `${address.slice(0, 6)}...${address.slice(-5)}`;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// src/utils/aptosConnect.ts
|
|
367
|
-
var APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
368
|
-
var APTOS_CONNECT_ACCOUNT_URL = "https://aptosconnect.app/dashboard/main-account";
|
|
369
|
-
function isAptosConnectWallet(wallet) {
|
|
370
|
-
return wallet.url.startsWith(APTOS_CONNECT_BASE_URL);
|
|
371
|
-
}
|
|
372
|
-
function getAptosConnectWallets(wallets) {
|
|
373
|
-
const { defaultWallets, moreWallets } = partitionWallets(
|
|
374
|
-
wallets,
|
|
375
|
-
isAptosConnectWallet
|
|
376
|
-
);
|
|
377
|
-
return { aptosConnectWallets: defaultWallets, otherWallets: moreWallets };
|
|
378
|
-
}
|
|
379
344
|
|
|
380
345
|
// src/utils/localStorage.ts
|
|
381
346
|
var LOCAL_STORAGE_ITEM_KEY = "AptosWalletName";
|
|
@@ -419,6 +384,60 @@ function scopePollingDetectionStrategy(detect) {
|
|
|
419
384
|
detectAndDispose();
|
|
420
385
|
}
|
|
421
386
|
|
|
387
|
+
// src/utils/walletSelector.ts
|
|
388
|
+
function partitionWallets(wallets, partitionFunction = isInstalledOrLoadable) {
|
|
389
|
+
const defaultWallets = [];
|
|
390
|
+
const moreWallets = [];
|
|
391
|
+
for (const wallet of wallets) {
|
|
392
|
+
if (partitionFunction(wallet))
|
|
393
|
+
defaultWallets.push(wallet);
|
|
394
|
+
else
|
|
395
|
+
moreWallets.push(wallet);
|
|
396
|
+
}
|
|
397
|
+
return { defaultWallets, moreWallets };
|
|
398
|
+
}
|
|
399
|
+
function isInstalledOrLoadable(wallet) {
|
|
400
|
+
return wallet.readyState === "Installed" /* Installed */ || wallet.readyState === "Loadable" /* Loadable */;
|
|
401
|
+
}
|
|
402
|
+
function isInstallRequired(wallet) {
|
|
403
|
+
const isWalletReady = isInstalledOrLoadable(wallet);
|
|
404
|
+
const isMobile2 = !isWalletReady && isRedirectable();
|
|
405
|
+
return !isMobile2 && !isWalletReady;
|
|
406
|
+
}
|
|
407
|
+
function truncateAddress(address) {
|
|
408
|
+
if (!address)
|
|
409
|
+
return;
|
|
410
|
+
return `${address.slice(0, 6)}...${address.slice(-5)}`;
|
|
411
|
+
}
|
|
412
|
+
function isAptosConnectWallet(wallet) {
|
|
413
|
+
return wallet.url.startsWith(APTOS_CONNECT_BASE_URL);
|
|
414
|
+
}
|
|
415
|
+
function getAptosConnectWallets(wallets) {
|
|
416
|
+
const { defaultWallets, moreWallets } = partitionWallets(
|
|
417
|
+
wallets,
|
|
418
|
+
isAptosConnectWallet
|
|
419
|
+
);
|
|
420
|
+
return { aptosConnectWallets: defaultWallets, otherWallets: moreWallets };
|
|
421
|
+
}
|
|
422
|
+
function groupAndSortWallets(wallets, options) {
|
|
423
|
+
const { aptosConnectWallets, otherWallets } = getAptosConnectWallets(wallets);
|
|
424
|
+
const { defaultWallets, moreWallets } = partitionWallets(otherWallets);
|
|
425
|
+
if (options == null ? void 0 : options.sortAptosConnectWallets) {
|
|
426
|
+
aptosConnectWallets.sort(options.sortAptosConnectWallets);
|
|
427
|
+
}
|
|
428
|
+
if (options == null ? void 0 : options.sortAvailableWallets) {
|
|
429
|
+
defaultWallets.sort(options.sortAvailableWallets);
|
|
430
|
+
}
|
|
431
|
+
if (options == null ? void 0 : options.sortInstallableWallets) {
|
|
432
|
+
moreWallets.sort(options.sortInstallableWallets);
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
aptosConnectWallets,
|
|
436
|
+
availableWallets: defaultWallets,
|
|
437
|
+
installableWallets: moreWallets
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
422
441
|
// src/LegacyWalletPlugins/WalletCoreV1.ts
|
|
423
442
|
var WalletCoreV1 = class extends import_eventemitter3.default {
|
|
424
443
|
async connect(wallet) {
|
|
@@ -764,9 +783,10 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
764
783
|
this._optInWallets = optInWallets;
|
|
765
784
|
this._dappConfig = dappConfig;
|
|
766
785
|
this._sdkWallets = getSDKWallets(this._dappConfig);
|
|
786
|
+
this.fetchExtensionAIP62AptosWallets();
|
|
787
|
+
this.fetchSDKAIP62AptosWallets();
|
|
767
788
|
this.scopePollingDetectionStrategy();
|
|
768
|
-
this.
|
|
769
|
-
this.appendNotDetectedStandardSupportedWallets(this._standard_wallets);
|
|
789
|
+
this.appendNotDetectedStandardSupportedWallets();
|
|
770
790
|
}
|
|
771
791
|
scopePollingDetectionStrategy() {
|
|
772
792
|
var _a;
|
|
@@ -789,29 +809,29 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
789
809
|
}
|
|
790
810
|
});
|
|
791
811
|
}
|
|
792
|
-
|
|
812
|
+
fetchExtensionAIP62AptosWallets() {
|
|
793
813
|
let { aptosWallets, on } = (0, import_wallet_standard2.getAptosWallets)();
|
|
794
|
-
this.
|
|
814
|
+
this.setExtensionAIP62Wallets(aptosWallets);
|
|
795
815
|
if (typeof window === "undefined")
|
|
796
816
|
return;
|
|
797
817
|
const that = this;
|
|
798
818
|
const removeRegisterListener = on("register", function() {
|
|
799
819
|
let { aptosWallets: aptosWallets2 } = (0, import_wallet_standard2.getAptosWallets)();
|
|
800
|
-
that.
|
|
820
|
+
that.setExtensionAIP62Wallets(aptosWallets2);
|
|
801
821
|
});
|
|
802
822
|
const removeUnregisterListener = on("unregister", function() {
|
|
803
823
|
let { aptosWallets: aptosWallets2 } = (0, import_wallet_standard2.getAptosWallets)();
|
|
804
|
-
that.
|
|
824
|
+
that.setExtensionAIP62Wallets(aptosWallets2);
|
|
805
825
|
});
|
|
806
826
|
}
|
|
807
|
-
appendNotDetectedStandardSupportedWallets(
|
|
827
|
+
appendNotDetectedStandardSupportedWallets() {
|
|
808
828
|
aptosStandardSupportedWalletList.map((supportedWallet) => {
|
|
809
829
|
const existingPluginWalletIndex = this.wallets.findIndex(
|
|
810
830
|
(wallet) => wallet.name === supportedWallet.name
|
|
811
831
|
);
|
|
812
832
|
if (existingPluginWalletIndex !== -1)
|
|
813
833
|
return;
|
|
814
|
-
const existingStandardWallet =
|
|
834
|
+
const existingStandardWallet = this._standard_wallets.find(
|
|
815
835
|
(wallet) => wallet.name == supportedWallet.name
|
|
816
836
|
);
|
|
817
837
|
if (existingStandardWallet && this.excludeWallet(existingStandardWallet)) {
|
|
@@ -823,22 +843,19 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
823
843
|
}
|
|
824
844
|
});
|
|
825
845
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
if (isValid) {
|
|
835
|
-
wallet.readyState = "Installed" /* Installed */;
|
|
836
|
-
aptosStandardWallets.push(wallet);
|
|
837
|
-
this.standardizeStandardWalletToPluginWalletType(wallet);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
846
|
+
fetchSDKAIP62AptosWallets() {
|
|
847
|
+
this._sdkWallets.map((wallet) => {
|
|
848
|
+
this.standardizeAIP62WalletType(wallet);
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
setExtensionAIP62Wallets(extensionwWallets) {
|
|
852
|
+
const wallets = extensionwWallets.filter(
|
|
853
|
+
(wallet) => wallet.name !== "Dev T wallet" && wallet.name !== "T wallet"
|
|
840
854
|
);
|
|
841
|
-
|
|
855
|
+
wallets.map((wallet) => {
|
|
856
|
+
this.standardizeAIP62WalletType(wallet);
|
|
857
|
+
this._standard_wallets.push(wallet);
|
|
858
|
+
});
|
|
842
859
|
}
|
|
843
860
|
excludeWallet(wallet) {
|
|
844
861
|
if (isAptosConnectWallet(wallet))
|
|
@@ -848,6 +865,17 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
848
865
|
}
|
|
849
866
|
return false;
|
|
850
867
|
}
|
|
868
|
+
standardizeAIP62WalletType(wallet) {
|
|
869
|
+
if (this.excludeWallet(wallet)) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
const isValid = (0, import_wallet_standard2.isWalletWithRequiredFeatureSet)(wallet);
|
|
873
|
+
if (isValid) {
|
|
874
|
+
wallet.readyState = "Installed" /* Installed */;
|
|
875
|
+
this.standardizeStandardWalletToPluginWalletType(wallet);
|
|
876
|
+
this._standard_wallets.push(wallet);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
851
879
|
recordEvent(eventName, additionalInfo) {
|
|
852
880
|
var _a, _b, _c;
|
|
853
881
|
this.ga4.gtag("event", `wallet_adapter_${eventName}`, {
|
|
@@ -1353,6 +1381,7 @@ if (typeof window !== "undefined") {
|
|
|
1353
1381
|
getAptosConfig,
|
|
1354
1382
|
getAptosConnectWallets,
|
|
1355
1383
|
getLocalStorage,
|
|
1384
|
+
groupAndSortWallets,
|
|
1356
1385
|
isAptosConnectWallet,
|
|
1357
1386
|
isAptosNetwork,
|
|
1358
1387
|
isInAppBrowser,
|