@aptos-labs/wallet-adapter-core 8.0.0-xchaininit2.0 → 8.0.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/dist/WalletCore.d.ts +17 -1
- package/dist/WalletCore.d.ts.map +1 -1
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.mts +55 -6
- package/dist/index.js +109 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -10
- package/dist/index.mjs.map +1 -1
- package/dist/sdkWallets.d.ts.map +1 -1
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/walletSelector.d.ts +29 -4
- package/dist/utils/walletSelector.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/WalletCore.ts +83 -36
- package/src/constants.ts +11 -0
- package/src/sdkWallets.ts +6 -0
- package/src/utils/types.ts +1 -0
- package/src/utils/walletSelector.ts +105 -8
- package/src/version.ts +1 -1
package/dist/WalletCore.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { AvailableWallets, InputTransactionData } from "./utils/types";
|
|
|
9
9
|
export type AdapterWallet = AptosWallet & {
|
|
10
10
|
readyState?: WalletReadyState;
|
|
11
11
|
isAptosNativeWallet?: boolean;
|
|
12
|
+
/** A fallback wallet to use when this wallet is not installed */
|
|
13
|
+
fallbackWallet?: AdapterWallet;
|
|
12
14
|
};
|
|
13
15
|
export type AdapterNotDetectedWallet = Omit<AdapterWallet, "features" | "version" | "chains" | "accounts"> & {
|
|
14
16
|
readyState: WalletReadyState.NotDetected;
|
|
@@ -51,6 +53,7 @@ export declare interface WalletCoreEvents {
|
|
|
51
53
|
connect(account: AccountInfo | null): void;
|
|
52
54
|
disconnect(): void;
|
|
53
55
|
standardWalletsAdded(wallets: AdapterWallet): void;
|
|
56
|
+
standardWalletsHiddenAdded(wallets: AdapterWallet): void;
|
|
54
57
|
standardNotDetectedWalletAdded(wallets: AdapterNotDetectedWallet): void;
|
|
55
58
|
networkChange(network: NetworkInfo | null): void;
|
|
56
59
|
accountChange(account: AccountInfo | null): void;
|
|
@@ -63,15 +66,17 @@ export declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
63
66
|
private readonly _sdkWallets;
|
|
64
67
|
private _standard_wallets;
|
|
65
68
|
private _standard_not_detected_wallets;
|
|
69
|
+
private _standard_wallets_hidden;
|
|
66
70
|
private _network;
|
|
67
71
|
private _connected;
|
|
68
72
|
private _connecting;
|
|
69
73
|
private _account;
|
|
70
74
|
private _dappConfig;
|
|
71
75
|
private _optInWallets;
|
|
76
|
+
private _hideWallets;
|
|
72
77
|
private _disableTelemetry;
|
|
73
78
|
private readonly ga4;
|
|
74
|
-
constructor(optInWallets?: ReadonlyArray<AvailableWallets>, dappConfig?: DappConfig, disableTelemetry?: boolean);
|
|
79
|
+
constructor(optInWallets?: ReadonlyArray<AvailableWallets>, dappConfig?: DappConfig, disableTelemetry?: boolean, hideWallets?: ReadonlyArray<AvailableWallets>);
|
|
75
80
|
private fetchExtensionAIP62AptosWallets;
|
|
76
81
|
/**
|
|
77
82
|
* Set AIP-62 extension wallets
|
|
@@ -92,6 +97,13 @@ export declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
92
97
|
* @returns boolean
|
|
93
98
|
*/
|
|
94
99
|
excludeWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* A function that hides an AIP-62 compatible wallet from normal display.
|
|
102
|
+
*
|
|
103
|
+
* @param wallet AdapterWallet | AdapterNotDetectedWallet
|
|
104
|
+
* @returns boolean
|
|
105
|
+
*/
|
|
106
|
+
hideWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
95
107
|
private recordEvent;
|
|
96
108
|
/**
|
|
97
109
|
* Helper function to ensure wallet exists
|
|
@@ -146,6 +158,10 @@ export declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
146
158
|
* Getter to fetch all detected wallets
|
|
147
159
|
*/
|
|
148
160
|
get wallets(): ReadonlyArray<AptosWallet>;
|
|
161
|
+
/**
|
|
162
|
+
* Getter to fetch all hidden wallets
|
|
163
|
+
*/
|
|
164
|
+
get hiddenWallets(): ReadonlyArray<AdapterWallet>;
|
|
149
165
|
get notDetectedWallets(): ReadonlyArray<AdapterNotDetectedWallet>;
|
|
150
166
|
/**
|
|
151
167
|
* Getter for the current connected wallet
|
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,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAEL,oBAAoB,EACpB,iBAAiB,EAEjB,0BAA0B,EAC1B,OAAO,EAEP,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EAIX,mCAAmC,EAMnC,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,YAAY,EACV,WAAW,EACX,WAAW,EACX,mCAAmC,EACnC,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,OAAO,EACP,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAsB5B,OAAO,EAAmC,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkBhF,OAAO,EACL,gBAAgB,EAEhB,oBAAoB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;;OAYG;IACG,eAAe,CAAC,IAAI,EAAE;QAC1B,oBAAoB,EAAE,iBAAiB,GAAG,oBAAoB,CAAC;QAC/D,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,GAAG,OAAO,CAAC;QACV,aAAa,EAAE,oBAAoB,CAAC;QACpC,cAAc,EAAE,UAAU,CAAC;KAC5B,CAAC;IAyGF;;;;;;;OAOG;IACG,WAAW,CACf,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACG,iBAAiB,CACrB,WAAW,EAAE,0BAA0B,GACtC,OAAO,CAAC,0BAA0B,CAAC;IA+BtC;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBtC;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBtC;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAsCxE;;;;OAIG;IACG,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;CAoC7E"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ export declare const ChainIdToAnsSupportedNetworkMap: Record<string, string>;
|
|
|
21
21
|
export declare const APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
22
22
|
/** The base URL for all Petra Web wallets. */
|
|
23
23
|
export declare const PETRA_WEB_BASE_URL = "https://web.petra.app";
|
|
24
|
+
/** The name of the generic wallet for Petra Web. */
|
|
25
|
+
export declare const PETRA_WEB_GENERIC_WALLET_NAME = "Petra Web";
|
|
26
|
+
/** The name of the Petra wallet. */
|
|
27
|
+
export declare const PETRA_WALLET_NAME = "Petra";
|
|
28
|
+
/** The default connection fallbacks for wallets that are not installed. */
|
|
29
|
+
export declare const DEFAULT_WALLET_CONNECTION_FALLBACKS: {
|
|
30
|
+
Petra: string;
|
|
31
|
+
};
|
|
24
32
|
/**
|
|
25
33
|
* The URL to the Aptos Connect account page if the user is signed in to Aptos Connect.
|
|
26
34
|
*
|
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;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;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,oDACa,CAAC;AAEpD,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,iDACc,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;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;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,oDAAoD;AACpD,eAAO,MAAM,6BAA6B,cAAc,CAAC;AAEzD,oCAAoC;AACpC,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,2EAA2E;AAC3E,eAAO,MAAM,mCAAmC;;CAE/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,oDACa,CAAC;AAEpD,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,iDACc,CAAC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,14 @@ declare const ChainIdToAnsSupportedNetworkMap: Record<string, string>;
|
|
|
29
29
|
declare const APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
30
30
|
/** The base URL for all Petra Web wallets. */
|
|
31
31
|
declare const PETRA_WEB_BASE_URL = "https://web.petra.app";
|
|
32
|
+
/** The name of the generic wallet for Petra Web. */
|
|
33
|
+
declare const PETRA_WEB_GENERIC_WALLET_NAME = "Petra Web";
|
|
34
|
+
/** The name of the Petra wallet. */
|
|
35
|
+
declare const PETRA_WALLET_NAME = "Petra";
|
|
36
|
+
/** The default connection fallbacks for wallets that are not installed. */
|
|
37
|
+
declare const DEFAULT_WALLET_CONNECTION_FALLBACKS: {
|
|
38
|
+
Petra: string;
|
|
39
|
+
};
|
|
32
40
|
/**
|
|
33
41
|
* The URL to the Aptos Connect account page if the user is signed in to Aptos Connect.
|
|
34
42
|
*
|
|
@@ -47,7 +55,7 @@ interface AptosStandardSupportedWallet {
|
|
|
47
55
|
deeplinkProvider?: string;
|
|
48
56
|
isAptosNativeWallet?: boolean;
|
|
49
57
|
}
|
|
50
|
-
type AvailableWallets = "Continue with Apple" | "Continue with Google" | "OKX Wallet" | "Petra" | "Nightly" | "Pontem Wallet" | "Backpack" | "MSafe" | "Bitget Wallet" | "Gate Wallet" | "Cosmostation Wallet";
|
|
58
|
+
type AvailableWallets = "Continue with Apple" | "Continue with Google" | "Petra Web" | "OKX Wallet" | "Petra" | "Nightly" | "Pontem Wallet" | "Backpack" | "MSafe" | "Bitget Wallet" | "Gate Wallet" | "Cosmostation Wallet";
|
|
51
59
|
type InputTransactionDataInner = {
|
|
52
60
|
sender?: AccountAddressInput;
|
|
53
61
|
data: InputGenerateTransactionPayloadData;
|
|
@@ -76,6 +84,8 @@ type WalletInfo = {
|
|
|
76
84
|
type AdapterWallet = AptosWallet & {
|
|
77
85
|
readyState?: WalletReadyState;
|
|
78
86
|
isAptosNativeWallet?: boolean;
|
|
87
|
+
/** A fallback wallet to use when this wallet is not installed */
|
|
88
|
+
fallbackWallet?: AdapterWallet;
|
|
79
89
|
};
|
|
80
90
|
type AdapterNotDetectedWallet = Omit<AdapterWallet, "features" | "version" | "chains" | "accounts"> & {
|
|
81
91
|
readyState: WalletReadyState.NotDetected;
|
|
@@ -118,6 +128,7 @@ declare interface WalletCoreEvents {
|
|
|
118
128
|
connect(account: AccountInfo | null): void;
|
|
119
129
|
disconnect(): void;
|
|
120
130
|
standardWalletsAdded(wallets: AdapterWallet): void;
|
|
131
|
+
standardWalletsHiddenAdded(wallets: AdapterWallet): void;
|
|
121
132
|
standardNotDetectedWalletAdded(wallets: AdapterNotDetectedWallet): void;
|
|
122
133
|
networkChange(network: NetworkInfo | null): void;
|
|
123
134
|
accountChange(account: AccountInfo | null): void;
|
|
@@ -130,15 +141,17 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
130
141
|
private readonly _sdkWallets;
|
|
131
142
|
private _standard_wallets;
|
|
132
143
|
private _standard_not_detected_wallets;
|
|
144
|
+
private _standard_wallets_hidden;
|
|
133
145
|
private _network;
|
|
134
146
|
private _connected;
|
|
135
147
|
private _connecting;
|
|
136
148
|
private _account;
|
|
137
149
|
private _dappConfig;
|
|
138
150
|
private _optInWallets;
|
|
151
|
+
private _hideWallets;
|
|
139
152
|
private _disableTelemetry;
|
|
140
153
|
private readonly ga4;
|
|
141
|
-
constructor(optInWallets?: ReadonlyArray<AvailableWallets>, dappConfig?: DappConfig, disableTelemetry?: boolean);
|
|
154
|
+
constructor(optInWallets?: ReadonlyArray<AvailableWallets>, dappConfig?: DappConfig, disableTelemetry?: boolean, hideWallets?: ReadonlyArray<AvailableWallets>);
|
|
142
155
|
private fetchExtensionAIP62AptosWallets;
|
|
143
156
|
/**
|
|
144
157
|
* Set AIP-62 extension wallets
|
|
@@ -159,6 +172,13 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
159
172
|
* @returns boolean
|
|
160
173
|
*/
|
|
161
174
|
excludeWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* A function that hides an AIP-62 compatible wallet from normal display.
|
|
177
|
+
*
|
|
178
|
+
* @param wallet AdapterWallet | AdapterNotDetectedWallet
|
|
179
|
+
* @returns boolean
|
|
180
|
+
*/
|
|
181
|
+
hideWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
162
182
|
private recordEvent;
|
|
163
183
|
/**
|
|
164
184
|
* Helper function to ensure wallet exists
|
|
@@ -213,6 +233,10 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
213
233
|
* Getter to fetch all detected wallets
|
|
214
234
|
*/
|
|
215
235
|
get wallets(): ReadonlyArray<AptosWallet>;
|
|
236
|
+
/**
|
|
237
|
+
* Getter to fetch all hidden wallets
|
|
238
|
+
*/
|
|
239
|
+
get hiddenWallets(): ReadonlyArray<AdapterWallet>;
|
|
216
240
|
get notDetectedWallets(): ReadonlyArray<AdapterNotDetectedWallet>;
|
|
217
241
|
/**
|
|
218
242
|
* Getter for the current connected wallet
|
|
@@ -392,12 +416,13 @@ declare function partitionWallets(wallets: ReadonlyArray<AdapterWallet | Adapter
|
|
|
392
416
|
moreWallets: AdapterNotDetectedWallet[];
|
|
393
417
|
};
|
|
394
418
|
/** Returns true if the wallet is installed or loadable. */
|
|
395
|
-
declare function isInstalledOrLoadable(wallet: AdapterWallet | AdapterNotDetectedWallet):
|
|
419
|
+
declare function isInstalledOrLoadable(wallet: AdapterWallet | AdapterNotDetectedWallet): wallet is AdapterWallet;
|
|
396
420
|
/**
|
|
397
421
|
* Returns true if the user is on desktop and the provided wallet requires installation of a browser extension.
|
|
398
422
|
* This can be used to decide whether to show a "Connect" button or "Install" link in the UI.
|
|
399
423
|
*/
|
|
400
424
|
declare function isInstallRequired(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
425
|
+
declare function shouldUseFallbackWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
401
426
|
/** Truncates the provided wallet address at the middle with an ellipsis. */
|
|
402
427
|
declare function truncateAddress(address: string | undefined): string | undefined;
|
|
403
428
|
/**
|
|
@@ -406,8 +431,10 @@ declare function truncateAddress(address: string | undefined): string | undefine
|
|
|
406
431
|
* @deprecated Use {@link isPetraWebWallet} instead.
|
|
407
432
|
*/
|
|
408
433
|
declare function isAptosConnectWallet(wallet: WalletInfo | AdapterWallet): boolean;
|
|
409
|
-
/** Returns `true` if the provided wallet is a Petra Web wallet. */
|
|
410
|
-
declare function isPetraWebWallet(wallet: WalletInfo | AdapterWallet): boolean;
|
|
434
|
+
/** Returns `true` if the provided wallet is a Petra Web wallet. This will automatically exclude the generic wallet. */
|
|
435
|
+
declare function isPetraWebWallet(wallet: WalletInfo | AdapterWallet, ignoreGenericWallet?: boolean): boolean;
|
|
436
|
+
/** Returns true if the wallet is a generic wallet. */
|
|
437
|
+
declare function isPetraWebGenericWallet(wallet: AdapterWallet | AdapterNotDetectedWallet | WalletInfo): boolean;
|
|
411
438
|
/**
|
|
412
439
|
* Partitions the `wallets` array so that Aptos Connect wallets are grouped separately from the rest.
|
|
413
440
|
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
|
|
@@ -439,6 +466,24 @@ interface WalletSortingOptions {
|
|
|
439
466
|
sortAvailableWallets?: (a: AdapterWallet | AdapterNotDetectedWallet, b: AdapterWallet | AdapterNotDetectedWallet) => number;
|
|
440
467
|
/** An optional function for sorting wallets that are NOT currently installed or loadable. */
|
|
441
468
|
sortInstallableWallets?: (a: AdapterWallet | AdapterNotDetectedWallet, b: AdapterWallet | AdapterNotDetectedWallet) => number;
|
|
469
|
+
/**
|
|
470
|
+
* A map of wallet names to fallback wallet names.
|
|
471
|
+
* If a wallet is not installed and has a fallback wallet that IS installed,
|
|
472
|
+
* the fallback wallet will be attached to the not-installed wallet and it will
|
|
473
|
+
* be moved to the available wallets list.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* // Override the default fallbacks
|
|
478
|
+
* fallbacks: { connections: { "Petra": "Petra Web", "OtherWallet": "OtherFallback" } }
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
fallbacks?: {
|
|
482
|
+
/** A map of wallet names to fallback wallet names. */
|
|
483
|
+
connections: Record<string | AvailableWallets, string | AvailableWallets>;
|
|
484
|
+
/** An optional array of wallets that are available but not intended for display. These wallets will only be shown if there is logic to explicitly show them (e.g. `fallbacks`) */
|
|
485
|
+
additionalFallbackWallets?: ReadonlyArray<AdapterWallet>;
|
|
486
|
+
};
|
|
442
487
|
}
|
|
443
488
|
/**
|
|
444
489
|
* Partitions the `wallets` array into three distinct groups:
|
|
@@ -450,6 +495,8 @@ interface WalletSortingOptions {
|
|
|
450
495
|
*
|
|
451
496
|
* `availableWallets` - Wallets that are currently installed or loadable by the client.
|
|
452
497
|
*
|
|
498
|
+
* `availableWalletsWithFallbacks` - Wallets that are currently uninstalled that have a fallback wallet.
|
|
499
|
+
*
|
|
453
500
|
* `installableWallets` - Wallets that are NOT current installed or loadable and
|
|
454
501
|
* require the client to install a browser extension first.
|
|
455
502
|
*
|
|
@@ -462,6 +509,8 @@ declare function groupAndSortWallets(wallets: ReadonlyArray<AdapterWallet | Adap
|
|
|
462
509
|
petraWebWallets: AdapterWallet[];
|
|
463
510
|
/** Wallets that are currently installed or loadable. */
|
|
464
511
|
availableWallets: AdapterWallet[];
|
|
512
|
+
/** Wallets that are currently uninstalled that have a fallback wallet. */
|
|
513
|
+
availableWalletsWithFallbacks: (AdapterWallet | AdapterNotDetectedWallet)[];
|
|
465
514
|
/** Wallets that are NOT currently installed or loadable. */
|
|
466
515
|
installableWallets: AdapterNotDetectedWallet[];
|
|
467
516
|
};
|
|
@@ -491,4 +540,4 @@ declare const evmStandardSupportedWalletList: Array<AptosStandardSupportedWallet
|
|
|
491
540
|
*/
|
|
492
541
|
type AptosSignInRequiredFields = AptosSignInBoundFields;
|
|
493
542
|
|
|
494
|
-
export { APTOS_CONNECT_ACCOUNT_URL, APTOS_CONNECT_BASE_URL, type AdapterAccountInfo, type AdapterNotDetectedWallet, type AdapterWallet, type AptosSignInRequiredFields, type AptosStandardSupportedWallet, type AvailableWallets, ChainIdToAnsSupportedNetworkMap, type DappConfig, type InputTransactionData, NetworkName, PETRA_WEB_ACCOUNT_URL, PETRA_WEB_BASE_URL, WalletCore, type WalletCoreEvents, type WalletInfo, WalletReadyState, type WalletSortingOptions, aptosStandardSupportedWalletList, convertNetwork, evmStandardSupportedWalletList, fetchDevnetChainId, generalizedErrorMessage, getAptosConfig, getAptosConnectWallets, getLocalStorage, getPetraWebWallets, getSDKWallets, groupAndSortWallets, handlePublishPackageTransaction, isAptosConnectWallet, isAptosLiveNetwork, isAptosNetwork, isInAppBrowser, isInstallRequired, isInstalledOrLoadable, isMobile, isPetraWebWallet, isRedirectable, partitionWallets, removeLocalStorage, setLocalStorage, solanaStandardSupportedWalletList, truncateAddress };
|
|
543
|
+
export { APTOS_CONNECT_ACCOUNT_URL, APTOS_CONNECT_BASE_URL, type AdapterAccountInfo, type AdapterNotDetectedWallet, type AdapterWallet, type AptosSignInRequiredFields, type AptosStandardSupportedWallet, type AvailableWallets, ChainIdToAnsSupportedNetworkMap, DEFAULT_WALLET_CONNECTION_FALLBACKS, type DappConfig, type InputTransactionData, NetworkName, PETRA_WALLET_NAME, PETRA_WEB_ACCOUNT_URL, PETRA_WEB_BASE_URL, PETRA_WEB_GENERIC_WALLET_NAME, WalletCore, type WalletCoreEvents, type WalletInfo, WalletReadyState, type WalletSortingOptions, aptosStandardSupportedWalletList, convertNetwork, evmStandardSupportedWalletList, fetchDevnetChainId, generalizedErrorMessage, getAptosConfig, getAptosConnectWallets, getLocalStorage, getPetraWebWallets, getSDKWallets, groupAndSortWallets, handlePublishPackageTransaction, isAptosConnectWallet, isAptosLiveNetwork, isAptosNetwork, isInAppBrowser, isInstallRequired, isInstalledOrLoadable, isMobile, isPetraWebGenericWallet, isPetraWebWallet, isRedirectable, partitionWallets, removeLocalStorage, setLocalStorage, shouldUseFallbackWallet, solanaStandardSupportedWalletList, truncateAddress };
|
package/dist/index.js
CHANGED
|
@@ -389,15 +389,24 @@ __export(index_exports, {
|
|
|
389
389
|
ChainIdToAnsSupportedNetworkMap: function() {
|
|
390
390
|
return ChainIdToAnsSupportedNetworkMap;
|
|
391
391
|
},
|
|
392
|
+
DEFAULT_WALLET_CONNECTION_FALLBACKS: function() {
|
|
393
|
+
return DEFAULT_WALLET_CONNECTION_FALLBACKS;
|
|
394
|
+
},
|
|
392
395
|
NetworkName: function() {
|
|
393
396
|
return NetworkName;
|
|
394
397
|
},
|
|
398
|
+
PETRA_WALLET_NAME: function() {
|
|
399
|
+
return PETRA_WALLET_NAME;
|
|
400
|
+
},
|
|
395
401
|
PETRA_WEB_ACCOUNT_URL: function() {
|
|
396
402
|
return PETRA_WEB_ACCOUNT_URL;
|
|
397
403
|
},
|
|
398
404
|
PETRA_WEB_BASE_URL: function() {
|
|
399
405
|
return PETRA_WEB_BASE_URL;
|
|
400
406
|
},
|
|
407
|
+
PETRA_WEB_GENERIC_WALLET_NAME: function() {
|
|
408
|
+
return PETRA_WEB_GENERIC_WALLET_NAME;
|
|
409
|
+
},
|
|
401
410
|
WalletCore: function() {
|
|
402
411
|
return WalletCore;
|
|
403
412
|
},
|
|
@@ -461,6 +470,9 @@ __export(index_exports, {
|
|
|
461
470
|
isMobile: function() {
|
|
462
471
|
return isMobile;
|
|
463
472
|
},
|
|
473
|
+
isPetraWebGenericWallet: function() {
|
|
474
|
+
return isPetraWebGenericWallet;
|
|
475
|
+
},
|
|
464
476
|
isPetraWebWallet: function() {
|
|
465
477
|
return isPetraWebWallet;
|
|
466
478
|
},
|
|
@@ -476,6 +488,9 @@ __export(index_exports, {
|
|
|
476
488
|
setLocalStorage: function() {
|
|
477
489
|
return setLocalStorage;
|
|
478
490
|
},
|
|
491
|
+
shouldUseFallbackWallet: function() {
|
|
492
|
+
return shouldUseFallbackWallet;
|
|
493
|
+
},
|
|
479
494
|
solanaStandardSupportedWalletList: function() {
|
|
480
495
|
return solanaStandardSupportedWalletList;
|
|
481
496
|
},
|
|
@@ -485,7 +500,7 @@ __export(index_exports, {
|
|
|
485
500
|
});
|
|
486
501
|
module.exports = __toCommonJS(index_exports);
|
|
487
502
|
// src/version.ts
|
|
488
|
-
var WALLET_ADAPTER_CORE_VERSION = "8.0.
|
|
503
|
+
var WALLET_ADAPTER_CORE_VERSION = "8.0.1";
|
|
489
504
|
// src/WalletCore.ts
|
|
490
505
|
var import_eventemitter3 = __toESM(require("eventemitter3"));
|
|
491
506
|
var import_ts_sdk2 = require("@aptos-labs/ts-sdk");
|
|
@@ -746,6 +761,9 @@ var ChainIdToAnsSupportedNetworkMap = {
|
|
|
746
761
|
};
|
|
747
762
|
var APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
748
763
|
var PETRA_WEB_BASE_URL = "https://web.petra.app";
|
|
764
|
+
var PETRA_WEB_GENERIC_WALLET_NAME = "Petra Web";
|
|
765
|
+
var PETRA_WALLET_NAME = "Petra";
|
|
766
|
+
var DEFAULT_WALLET_CONNECTION_FALLBACKS = _define_property({}, PETRA_WALLET_NAME, PETRA_WEB_GENERIC_WALLET_NAME);
|
|
749
767
|
var APTOS_CONNECT_ACCOUNT_URL = "https://aptosconnect.app/dashboard/main-account";
|
|
750
768
|
var PETRA_WEB_ACCOUNT_URL = "https://web.petra.app/dashboard/main-account";
|
|
751
769
|
// src/utils/helpers.ts
|
|
@@ -893,8 +911,11 @@ function partitionWallets(wallets) {
|
|
|
893
911
|
try {
|
|
894
912
|
for(var _iterator = wallets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
895
913
|
var wallet = _step.value;
|
|
896
|
-
if (partitionFunction(wallet))
|
|
897
|
-
|
|
914
|
+
if (partitionFunction(wallet)) {
|
|
915
|
+
defaultWallets.push(wallet);
|
|
916
|
+
} else {
|
|
917
|
+
moreWallets.push(wallet);
|
|
918
|
+
}
|
|
898
919
|
}
|
|
899
920
|
} catch (err) {
|
|
900
921
|
_didIteratorError = true;
|
|
@@ -923,6 +944,9 @@ function isInstallRequired(wallet) {
|
|
|
923
944
|
var isMobile2 = !isWalletReady && isRedirectable();
|
|
924
945
|
return !isMobile2 && !isWalletReady;
|
|
925
946
|
}
|
|
947
|
+
function shouldUseFallbackWallet(wallet) {
|
|
948
|
+
return !!wallet.fallbackWallet && isInstallRequired(wallet) && isInstalledOrLoadable(wallet.fallbackWallet);
|
|
949
|
+
}
|
|
926
950
|
function truncateAddress(address) {
|
|
927
951
|
if (!address) return;
|
|
928
952
|
return "".concat(address.slice(0, 6), "...").concat(address.slice(-5));
|
|
@@ -931,9 +955,16 @@ function isAptosConnectWallet(wallet) {
|
|
|
931
955
|
return isPetraWebWallet(wallet);
|
|
932
956
|
}
|
|
933
957
|
function isPetraWebWallet(wallet) {
|
|
958
|
+
var ignoreGenericWallet = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
934
959
|
if (!wallet.url) return false;
|
|
960
|
+
if (ignoreGenericWallet && isPetraWebGenericWallet(wallet)) {
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
935
963
|
return wallet.url.startsWith(APTOS_CONNECT_BASE_URL) || wallet.url.startsWith(PETRA_WEB_BASE_URL);
|
|
936
964
|
}
|
|
965
|
+
function isPetraWebGenericWallet(wallet) {
|
|
966
|
+
return wallet.name === PETRA_WEB_GENERIC_WALLET_NAME;
|
|
967
|
+
}
|
|
937
968
|
function getAptosConnectWallets(wallets) {
|
|
938
969
|
var _partitionWallets = partitionWallets(wallets, isAptosConnectWallet), defaultWallets = _partitionWallets.defaultWallets, moreWallets = _partitionWallets.moreWallets;
|
|
939
970
|
return {
|
|
@@ -949,9 +980,30 @@ function getPetraWebWallets(wallets) {
|
|
|
949
980
|
};
|
|
950
981
|
}
|
|
951
982
|
function groupAndSortWallets(wallets, options) {
|
|
983
|
+
var _ref = options !== null && options !== void 0 ? options : {}, tmp = _ref.fallbacks, _ref1 = tmp === void 0 ? {} : tmp, fallbackConnections = _ref1.connections, additionalFallbackWallets = _ref1.additionalFallbackWallets;
|
|
952
984
|
var aptosConnectWallets = getAptosConnectWallets(wallets).aptosConnectWallets;
|
|
953
985
|
var _getPetraWebWallets = getPetraWebWallets(wallets), otherWallets = _getPetraWebWallets.otherWallets, petraWebWallets = _getPetraWebWallets.petraWebWallets;
|
|
954
986
|
var _partitionWallets = partitionWallets(otherWallets), defaultWallets = _partitionWallets.defaultWallets, moreWallets = _partitionWallets.moreWallets;
|
|
987
|
+
var availableWalletsWithFallbacks = [];
|
|
988
|
+
if (fallbackConnections && Object.keys(fallbackConnections).length > 0) {
|
|
989
|
+
var _loop = function(i) {
|
|
990
|
+
var wallet = moreWallets[i];
|
|
991
|
+
var fallbackName = fallbackConnections[wallet.name];
|
|
992
|
+
if (fallbackName) {
|
|
993
|
+
var fallbackWallet = _to_consumable_array(wallets).concat(_to_consumable_array(additionalFallbackWallets !== null && additionalFallbackWallets !== void 0 ? additionalFallbackWallets : [])).find(function(w) {
|
|
994
|
+
return w.name === fallbackName && isInstalledOrLoadable(w);
|
|
995
|
+
});
|
|
996
|
+
if (fallbackWallet) {
|
|
997
|
+
var walletWithFallback = _object_spread_props(_object_spread({}, wallet), {
|
|
998
|
+
fallbackWallet: fallbackWallet
|
|
999
|
+
});
|
|
1000
|
+
moreWallets.splice(i, 1);
|
|
1001
|
+
availableWalletsWithFallbacks.push(walletWithFallback);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
for(var i = moreWallets.length - 1; i >= 0; i--)_loop(i);
|
|
1006
|
+
}
|
|
955
1007
|
if (options === null || options === void 0 ? void 0 : options.sortAptosConnectWallets) {
|
|
956
1008
|
aptosConnectWallets.sort(options.sortAptosConnectWallets);
|
|
957
1009
|
}
|
|
@@ -968,6 +1020,7 @@ function groupAndSortWallets(wallets, options) {
|
|
|
968
1020
|
/** @deprecated Use {@link petraWebWallets} instead. */ aptosConnectWallets: aptosConnectWallets,
|
|
969
1021
|
/** Wallets that use social login to create an account on the blockchain */ petraWebWallets: petraWebWallets,
|
|
970
1022
|
/** Wallets that are currently installed or loadable. */ availableWallets: defaultWallets,
|
|
1023
|
+
/** Wallets that are currently uninstalled that have a fallback wallet. */ availableWalletsWithFallbacks: availableWalletsWithFallbacks,
|
|
971
1024
|
/** Wallets that are NOT currently installed or loadable. */ installableWallets: moreWallets
|
|
972
1025
|
};
|
|
973
1026
|
}
|
|
@@ -1096,6 +1149,9 @@ function getSDKWallets(dappConfig) {
|
|
|
1096
1149
|
}, dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnect)), new import_wallet_adapter_plugin.AptosConnectAppleWallet(_object_spread({
|
|
1097
1150
|
network: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network,
|
|
1098
1151
|
dappId: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnectDappId
|
|
1152
|
+
}, dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnect)), new import_wallet_adapter_plugin.AptosConnectGenericWallet(_object_spread({
|
|
1153
|
+
network: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.network,
|
|
1154
|
+
dappId: dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnectDappId
|
|
1099
1155
|
}, dappConfig === null || dappConfig === void 0 ? void 0 : dappConfig.aptosConnect)));
|
|
1100
1156
|
}
|
|
1101
1157
|
return sdkWallets;
|
|
@@ -1104,6 +1160,9 @@ function getSDKWallets(dappConfig) {
|
|
|
1104
1160
|
var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
1105
1161
|
_inherits(WalletCore, _import_eventemitter3_default);
|
|
1106
1162
|
function WalletCore(optInWallets, dappConfig, disableTelemetry) {
|
|
1163
|
+
var hideWallets = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [
|
|
1164
|
+
"Petra Web"
|
|
1165
|
+
];
|
|
1107
1166
|
_class_call_check(this, WalletCore);
|
|
1108
1167
|
var _this;
|
|
1109
1168
|
_this = _call_super(this, WalletCore);
|
|
@@ -1115,6 +1174,8 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1115
1174
|
_this._standard_wallets = [];
|
|
1116
1175
|
// Local array that holds all the wallets that are AIP-62 standard compatible but are not installed on the user machine
|
|
1117
1176
|
_this._standard_not_detected_wallets = [];
|
|
1177
|
+
// Local array that holds all the wallets that are AIP-62 standard compatible but are hidden from normal display and that are installed on the user machine
|
|
1178
|
+
_this._standard_wallets_hidden = [];
|
|
1118
1179
|
// Local private variable to hold the network that is currently connected
|
|
1119
1180
|
_this._network = null;
|
|
1120
1181
|
// Local private variable to hold the wallet connected state
|
|
@@ -1125,11 +1186,14 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1125
1186
|
_this._account = null;
|
|
1126
1187
|
// Private array that holds all the Wallets a dapp decided to opt-in to
|
|
1127
1188
|
_this._optInWallets = [];
|
|
1189
|
+
// Private array that holds all the Wallets a dapp decided to hide from normal display
|
|
1190
|
+
_this._hideWallets = [];
|
|
1128
1191
|
// Local flag to disable the adapter telemetry tool
|
|
1129
1192
|
_this._disableTelemetry = false;
|
|
1130
1193
|
// Google Analytics 4 module
|
|
1131
1194
|
_this.ga4 = null;
|
|
1132
1195
|
_this._optInWallets = optInWallets || [];
|
|
1196
|
+
_this._hideWallets = hideWallets;
|
|
1133
1197
|
_this._dappConfig = dappConfig;
|
|
1134
1198
|
_this._disableTelemetry = disableTelemetry !== null && disableTelemetry !== void 0 ? disableTelemetry : false;
|
|
1135
1199
|
_this._sdkWallets = getSDKWallets(_this._dappConfig);
|
|
@@ -1184,12 +1248,19 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1184
1248
|
}
|
|
1185
1249
|
var alreadyExists = _this._standard_wallets.some(function(w) {
|
|
1186
1250
|
return w.name === wallet.name;
|
|
1251
|
+
}) || _this._standard_wallets_hidden.some(function(w) {
|
|
1252
|
+
return w.name === wallet.name;
|
|
1187
1253
|
});
|
|
1188
1254
|
if (!alreadyExists) {
|
|
1189
1255
|
wallet.readyState = "Installed" /* Installed */ ;
|
|
1190
1256
|
wallet.isAptosNativeWallet = _this.isAptosNativeWallet(wallet);
|
|
1191
|
-
_this.
|
|
1192
|
-
|
|
1257
|
+
if (!_this.hideWallet(wallet)) {
|
|
1258
|
+
_this._standard_wallets.push(wallet);
|
|
1259
|
+
_this.emit("standardWalletsAdded", wallet);
|
|
1260
|
+
} else {
|
|
1261
|
+
_this._standard_wallets_hidden.push(wallet);
|
|
1262
|
+
_this.emit("standardWalletsHiddenAdded", wallet);
|
|
1263
|
+
}
|
|
1193
1264
|
}
|
|
1194
1265
|
}
|
|
1195
1266
|
});
|
|
@@ -1209,7 +1280,11 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1209
1280
|
if (isValid) {
|
|
1210
1281
|
wallet.readyState = "Installed" /* Installed */ ;
|
|
1211
1282
|
wallet.isAptosNativeWallet = _this.isAptosNativeWallet(wallet);
|
|
1212
|
-
_this.
|
|
1283
|
+
if (!_this.hideWallet(wallet)) {
|
|
1284
|
+
_this._standard_wallets.push(wallet);
|
|
1285
|
+
} else {
|
|
1286
|
+
_this._standard_wallets_hidden.push(wallet);
|
|
1287
|
+
}
|
|
1213
1288
|
}
|
|
1214
1289
|
});
|
|
1215
1290
|
}
|
|
@@ -1241,7 +1316,9 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1241
1316
|
}
|
|
1242
1317
|
walletRegistry.map(function(supportedWallet) {
|
|
1243
1318
|
var existingStandardWallet = _this._standard_wallets.find(function(wallet) {
|
|
1244
|
-
return wallet.name
|
|
1319
|
+
return wallet.name === supportedWallet.name;
|
|
1320
|
+
}) || _this._standard_wallets_hidden.find(function(wallet) {
|
|
1321
|
+
return wallet.name === supportedWallet.name;
|
|
1245
1322
|
});
|
|
1246
1323
|
if (existingStandardWallet) {
|
|
1247
1324
|
return;
|
|
@@ -1271,6 +1348,17 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1271
1348
|
return false;
|
|
1272
1349
|
}
|
|
1273
1350
|
},
|
|
1351
|
+
{
|
|
1352
|
+
/**
|
|
1353
|
+
* A function that hides an AIP-62 compatible wallet from normal display.
|
|
1354
|
+
*
|
|
1355
|
+
* @param wallet AdapterWallet | AdapterNotDetectedWallet
|
|
1356
|
+
* @returns boolean
|
|
1357
|
+
*/ key: "hideWallet",
|
|
1358
|
+
value: function hideWallet(wallet) {
|
|
1359
|
+
return this._hideWallets.length > 0 && this._hideWallets.includes(wallet.name);
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1274
1362
|
{
|
|
1275
1363
|
key: "recordEvent",
|
|
1276
1364
|
value: function recordEvent(eventName, additionalInfo) {
|
|
@@ -1437,6 +1525,14 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1437
1525
|
return this._standard_wallets;
|
|
1438
1526
|
}
|
|
1439
1527
|
},
|
|
1528
|
+
{
|
|
1529
|
+
key: "hiddenWallets",
|
|
1530
|
+
get: /**
|
|
1531
|
+
* Getter to fetch all hidden wallets
|
|
1532
|
+
*/ function get() {
|
|
1533
|
+
return this._standard_wallets_hidden;
|
|
1534
|
+
}
|
|
1535
|
+
},
|
|
1440
1536
|
{
|
|
1441
1537
|
key: "notDetectedWallets",
|
|
1442
1538
|
get: function get() {
|
|
@@ -1527,7 +1623,7 @@ var WalletCore = /*#__PURE__*/ function(_import_eventemitter3_default) {
|
|
|
1527
1623
|
}
|
|
1528
1624
|
}
|
|
1529
1625
|
}
|
|
1530
|
-
allDetectedWallets = _this._standard_wallets;
|
|
1626
|
+
allDetectedWallets = _to_consumable_array(_this._standard_wallets).concat(_to_consumable_array(_this._standard_wallets_hidden));
|
|
1531
1627
|
selectedWallet = allDetectedWallets.find(function(wallet) {
|
|
1532
1628
|
return wallet.name === walletName;
|
|
1533
1629
|
});
|
|
@@ -2428,9 +2524,12 @@ if (typeof window !== "undefined") {
|
|
|
2428
2524
|
APTOS_CONNECT_ACCOUNT_URL: APTOS_CONNECT_ACCOUNT_URL,
|
|
2429
2525
|
APTOS_CONNECT_BASE_URL: APTOS_CONNECT_BASE_URL,
|
|
2430
2526
|
ChainIdToAnsSupportedNetworkMap: ChainIdToAnsSupportedNetworkMap,
|
|
2527
|
+
DEFAULT_WALLET_CONNECTION_FALLBACKS: DEFAULT_WALLET_CONNECTION_FALLBACKS,
|
|
2431
2528
|
NetworkName: NetworkName,
|
|
2529
|
+
PETRA_WALLET_NAME: PETRA_WALLET_NAME,
|
|
2432
2530
|
PETRA_WEB_ACCOUNT_URL: PETRA_WEB_ACCOUNT_URL,
|
|
2433
2531
|
PETRA_WEB_BASE_URL: PETRA_WEB_BASE_URL,
|
|
2532
|
+
PETRA_WEB_GENERIC_WALLET_NAME: PETRA_WEB_GENERIC_WALLET_NAME,
|
|
2434
2533
|
WalletCore: WalletCore,
|
|
2435
2534
|
WalletReadyState: WalletReadyState,
|
|
2436
2535
|
aptosStandardSupportedWalletList: aptosStandardSupportedWalletList,
|
|
@@ -2452,11 +2551,13 @@ if (typeof window !== "undefined") {
|
|
|
2452
2551
|
isInstallRequired: isInstallRequired,
|
|
2453
2552
|
isInstalledOrLoadable: isInstalledOrLoadable,
|
|
2454
2553
|
isMobile: isMobile,
|
|
2554
|
+
isPetraWebGenericWallet: isPetraWebGenericWallet,
|
|
2455
2555
|
isPetraWebWallet: isPetraWebWallet,
|
|
2456
2556
|
isRedirectable: isRedirectable,
|
|
2457
2557
|
partitionWallets: partitionWallets,
|
|
2458
2558
|
removeLocalStorage: removeLocalStorage,
|
|
2459
2559
|
setLocalStorage: setLocalStorage,
|
|
2560
|
+
shouldUseFallbackWallet: shouldUseFallbackWallet,
|
|
2460
2561
|
solanaStandardSupportedWalletList: solanaStandardSupportedWalletList,
|
|
2461
2562
|
truncateAddress: truncateAddress
|
|
2462
2563
|
});
|