@aptos-labs/wallet-adapter-core 7.7.0 → 7.8.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/constants.d.ts +14 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -7
- package/dist/index.mjs.map +1 -1
- package/dist/registry.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 +31 -5
- package/dist/utils/walletSelector.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/WalletCore.ts +27 -27
- package/src/constants.ts +17 -2
- package/src/registry.ts +7 -0
- package/src/utils/types.ts +1 -0
- package/src/utils/walletSelector.ts +54 -8
- package/src/version.ts +1 -1
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,4BAA4B,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,4BAA4B,CA6D9E,CAAC;AAEJ,eAAO,MAAM,qCAAqC,EAAE,KAAK,CAAC,4BAA4B,CAkCnF,CAAC"}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface AptosStandardSupportedWallet {
|
|
|
10
10
|
deeplinkProvider?: string;
|
|
11
11
|
isAptosNativeWallet?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export type AvailableWallets = "Continue with Apple" | "Continue with Google" | "OKX Wallet" | "Petra" | "Nightly" | "Pontem Wallet" | "Backpack" | "MSafe" | "Bitget Wallet" | "Gate Wallet";
|
|
13
|
+
export type AvailableWallets = "Continue with Apple" | "Continue with Google" | "OKX Wallet" | "Petra" | "Nightly" | "Pontem Wallet" | "Backpack" | "MSafe" | "Bitget Wallet" | "Gate Wallet" | "Cosmostation Wallet";
|
|
14
14
|
type InputTransactionDataInner = {
|
|
15
15
|
sender?: AccountAddressInput;
|
|
16
16
|
data: InputGenerateTransactionPayloadData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAC/B,0BAA0B,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,4BAA4B;IAE3C,IAAI,EAAE,MAAM,CAAC;IAEb,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,EAAE,cAAc,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,WAAW,MAAM,EAAE,CAAC;IAG1E,UAAU,EAAE,gBAAgB,CAAC,WAAW,CAAC;IAGzC,eAAe,EAAE,IAAI,CAAC;IAGtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAGD,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,sBAAsB,GACtB,YAAY,GACZ,OAAO,GACP,SAAS,GACT,eAAe,GACf,UAAU,GACV,OAAO,GACP,eAAe,GACf,aAAa,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"A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alledOrLoadable(wallet: AdapterWallet | AdapterNot
|
|
|
18
18
|
export declare function isInstallRequired(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean;
|
|
19
19
|
/** Truncates the provided wallet address at the middle with an ellipsis. */
|
|
20
20
|
export declare function truncateAddress(address: string | undefined): string | undefined;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Returns `true` if the provided wallet is an Aptos Connect wallet.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use {@link isPetraWebWallet} instead.
|
|
25
|
+
*/
|
|
22
26
|
export declare function isAptosConnectWallet(wallet: WalletInfo | AdapterWallet): boolean;
|
|
27
|
+
/** Returns `true` if the provided wallet is a Petra Web wallet. */
|
|
28
|
+
export declare function isPetraWebWallet(wallet: WalletInfo | AdapterWallet): boolean;
|
|
23
29
|
/**
|
|
24
|
-
* Partitions the `wallets` array so that
|
|
30
|
+
* Partitions the `wallets` array so that Aptos Connect wallets are grouped separately from the rest.
|
|
25
31
|
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use {@link getPetraWebWallets} instead.
|
|
26
34
|
*/
|
|
27
35
|
export declare function getAptosConnectWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>): {
|
|
28
36
|
aptosConnectWallets: AdapterWallet[];
|
|
29
37
|
otherWallets: AdapterNotDetectedWallet[];
|
|
30
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Partitions the `wallets` array so that Petra Web wallets are grouped separately from the rest.
|
|
41
|
+
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getPetraWebWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>): {
|
|
44
|
+
petraWebWallets: AdapterWallet[];
|
|
45
|
+
otherWallets: AdapterNotDetectedWallet[];
|
|
46
|
+
};
|
|
31
47
|
export interface WalletSortingOptions {
|
|
32
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* An optional function for sorting Aptos Connect wallets.
|
|
50
|
+
*
|
|
51
|
+
* @deprecated Use {@link sortPetraWebWallets} instead.
|
|
52
|
+
*/
|
|
33
53
|
sortAptosConnectWallets?: (a: AdapterWallet, b: AdapterWallet) => number;
|
|
54
|
+
/** An optional function for sorting Petra Web wallets. */
|
|
55
|
+
sortPetraWebWallets?: (a: AdapterWallet, b: AdapterWallet) => number;
|
|
34
56
|
/** An optional function for sorting wallets that are currently installed or loadable. */
|
|
35
57
|
sortAvailableWallets?: (a: AdapterWallet | AdapterNotDetectedWallet, b: AdapterWallet | AdapterNotDetectedWallet) => number;
|
|
36
58
|
/** An optional function for sorting wallets that are NOT currently installed or loadable. */
|
|
@@ -39,7 +61,9 @@ export interface WalletSortingOptions {
|
|
|
39
61
|
/**
|
|
40
62
|
* Partitions the `wallets` array into three distinct groups:
|
|
41
63
|
*
|
|
42
|
-
* `aptosConnectWallets` -
|
|
64
|
+
* `aptosConnectWallets` - Use {@link petraWebWallets} instead.
|
|
65
|
+
*
|
|
66
|
+
* `petraWebWallets` - Wallets that use social login to create accounts on
|
|
43
67
|
* the blockchain via Petra Web.
|
|
44
68
|
*
|
|
45
69
|
* `availableWallets` - Wallets that are currently installed or loadable by the client.
|
|
@@ -50,8 +74,10 @@ export interface WalletSortingOptions {
|
|
|
50
74
|
* Additionally, these wallet groups can be sorted by passing sort functions via the `options` argument.
|
|
51
75
|
*/
|
|
52
76
|
export declare function groupAndSortWallets(wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>, options?: WalletSortingOptions): {
|
|
53
|
-
/**
|
|
77
|
+
/** @deprecated Use {@link petraWebWallets} instead. */
|
|
54
78
|
aptosConnectWallets: AdapterWallet[];
|
|
79
|
+
/** Wallets that use social login to create an account on the blockchain */
|
|
80
|
+
petraWebWallets: AdapterWallet[];
|
|
55
81
|
/** Wallets that are currently installed or loadable. */
|
|
56
82
|
availableWallets: AdapterWallet[];
|
|
57
83
|
/** Wallets that are NOT currently installed or loadable. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletSelector.d.ts","sourceRoot":"","sources":["../../src/utils/walletSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"walletSelector.d.ts","sourceRoot":"","sources":["../../src/utils/walletSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAQxE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,aAAa,GAAG,wBAAwB,CAAC,EAChE,iBAAiB,GAAE,CACjB,MAAM,EAAE,aAAa,GAAG,wBAAwB,KAC7C,OAA+B;;;EAWrC;AAED,2DAA2D;AAC3D,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,GAAG,wBAAwB,WAGjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,GAAG,wBAAwB,WAMjD;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,sBAG1D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,WAEtE;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,WAMlE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,aAAa,CAAC,aAAa,GAAG,wBAAwB,CAAC;;;EAOjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,CAAC,aAAa,GAAG,wBAAwB,CAAC;;;EAOjE;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IACzE,0DAA0D;IAC1D,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IACrE,yFAAyF;IACzF,oBAAoB,CAAC,EAAE,CACrB,CAAC,EAAE,aAAa,GAAG,wBAAwB,EAC3C,CAAC,EAAE,aAAa,GAAG,wBAAwB,KACxC,MAAM,CAAC;IACZ,6FAA6F;IAC7F,sBAAsB,CAAC,EAAE,CACvB,CAAC,EAAE,aAAa,GAAG,wBAAwB,EAC3C,CAAC,EAAE,aAAa,GAAG,wBAAwB,KACxC,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,CAAC,aAAa,GAAG,wBAAwB,CAAC,EAChE,OAAO,CAAC,EAAE,oBAAoB;IAoB5B,uDAAuD;;IAEvD,2EAA2E;;IAE3E,wDAAwD;;IAExD,4DAA4D;;EAG/D"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const WALLET_ADAPTER_CORE_VERSION = "7.
|
|
1
|
+
export declare const WALLET_ADAPTER_CORE_VERSION = "7.8.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
package/src/WalletCore.ts
CHANGED
|
@@ -190,7 +190,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
190
190
|
constructor(
|
|
191
191
|
optInWallets?: ReadonlyArray<AvailableWallets>,
|
|
192
192
|
dappConfig?: DappConfig,
|
|
193
|
-
disableTelemetry?: boolean
|
|
193
|
+
disableTelemetry?: boolean,
|
|
194
194
|
) {
|
|
195
195
|
super();
|
|
196
196
|
this._optInWallets = optInWallets || [];
|
|
@@ -237,7 +237,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
237
237
|
* @param extensionwWallets
|
|
238
238
|
*/
|
|
239
239
|
private setExtensionAIP62Wallets(
|
|
240
|
-
extensionwWallets: readonly AptosWallet[]
|
|
240
|
+
extensionwWallets: readonly AptosWallet[],
|
|
241
241
|
): void {
|
|
242
242
|
extensionwWallets.map((wallet: AdapterWallet) => {
|
|
243
243
|
if (this.excludeWallet(wallet)) {
|
|
@@ -254,7 +254,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
254
254
|
if (isValid) {
|
|
255
255
|
// check if we already have this wallet as a not detected wallet
|
|
256
256
|
const index = this._standard_not_detected_wallets.findIndex(
|
|
257
|
-
(notDetctedWallet) => notDetctedWallet.name == wallet.name
|
|
257
|
+
(notDetctedWallet) => notDetctedWallet.name == wallet.name,
|
|
258
258
|
);
|
|
259
259
|
// if we do, remove it from the not detected wallets array as it is now become detected
|
|
260
260
|
if (index !== -1) {
|
|
@@ -263,7 +263,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
263
263
|
|
|
264
264
|
// ✅ Check if wallet already exists in _standard_wallets
|
|
265
265
|
const alreadyExists = this._standard_wallets.some(
|
|
266
|
-
(w) => w.name === wallet.name
|
|
266
|
+
(w) => w.name === wallet.name,
|
|
267
267
|
);
|
|
268
268
|
if (!alreadyExists) {
|
|
269
269
|
wallet.readyState = WalletReadyState.Installed;
|
|
@@ -313,7 +313,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
313
313
|
walletRegistry.map((supportedWallet: AptosStandardSupportedWallet) => {
|
|
314
314
|
// Check if we already have this wallet as a detected AIP-62 wallet standard
|
|
315
315
|
const existingStandardWallet = this._standard_wallets.find(
|
|
316
|
-
(wallet) => wallet.name == supportedWallet.name
|
|
316
|
+
(wallet) => wallet.name == supportedWallet.name,
|
|
317
317
|
);
|
|
318
318
|
// If it is detected, it means the user has the wallet installed, so dont add it to the wallets array
|
|
319
319
|
if (existingStandardWallet) {
|
|
@@ -371,7 +371,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
371
371
|
* @param wallet A wallet
|
|
372
372
|
*/
|
|
373
373
|
private ensureWalletExists(
|
|
374
|
-
wallet: AdapterWallet | null
|
|
374
|
+
wallet: AdapterWallet | null,
|
|
375
375
|
): asserts wallet is AdapterWallet {
|
|
376
376
|
if (!wallet) {
|
|
377
377
|
throw new WalletNotConnectedError().name;
|
|
@@ -386,7 +386,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
386
386
|
* @param account An account
|
|
387
387
|
*/
|
|
388
388
|
private ensureAccountExists(
|
|
389
|
-
account: AccountInfo | null
|
|
389
|
+
account: AccountInfo | null,
|
|
390
390
|
): asserts account is AccountInfo {
|
|
391
391
|
if (!account) {
|
|
392
392
|
throw new WalletAccountError("Account is not set").name;
|
|
@@ -537,7 +537,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
537
537
|
// Check if we are in a redirectable view (i.e on mobile AND not in an in-app browser)
|
|
538
538
|
if (isRedirectable()) {
|
|
539
539
|
const selectedWallet = this._standard_not_detected_wallets.find(
|
|
540
|
-
(wallet: AdapterNotDetectedWallet) => wallet.name === walletName
|
|
540
|
+
(wallet: AdapterNotDetectedWallet) => wallet.name === walletName,
|
|
541
541
|
);
|
|
542
542
|
|
|
543
543
|
if (selectedWallet) {
|
|
@@ -565,7 +565,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
565
565
|
const allDetectedWallets = this._standard_wallets;
|
|
566
566
|
|
|
567
567
|
const selectedWallet = allDetectedWallets.find(
|
|
568
|
-
(wallet: AdapterWallet) => wallet.name === walletName
|
|
568
|
+
(wallet: AdapterWallet) => wallet.name === walletName,
|
|
569
569
|
);
|
|
570
570
|
|
|
571
571
|
if (!selectedWallet) return;
|
|
@@ -575,7 +575,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
575
575
|
// if the selected wallet is already connected, we don't need to connect again
|
|
576
576
|
if (this._wallet?.name === walletName)
|
|
577
577
|
throw new WalletConnectionError(
|
|
578
|
-
`${walletName} wallet is already connected
|
|
578
|
+
`${walletName} wallet is already connected`,
|
|
579
579
|
).message;
|
|
580
580
|
}
|
|
581
581
|
|
|
@@ -608,7 +608,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
608
608
|
|
|
609
609
|
const allDetectedWallets = this._standard_wallets;
|
|
610
610
|
const selectedWallet = allDetectedWallets.find(
|
|
611
|
-
(wallet: AdapterWallet) => wallet.name === walletName
|
|
611
|
+
(wallet: AdapterWallet) => wallet.name === walletName,
|
|
612
612
|
);
|
|
613
613
|
|
|
614
614
|
if (!selectedWallet) {
|
|
@@ -617,14 +617,14 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
617
617
|
|
|
618
618
|
if (!selectedWallet.features["aptos:signIn"]) {
|
|
619
619
|
throw new WalletNotSupportedMethod(
|
|
620
|
-
`aptos:signIn is not supported by ${walletName}
|
|
620
|
+
`aptos:signIn is not supported by ${walletName}`,
|
|
621
621
|
).message;
|
|
622
622
|
}
|
|
623
623
|
|
|
624
624
|
return await this.connectWallet(selectedWallet, async () => {
|
|
625
625
|
if (!selectedWallet.features["aptos:signIn"]) {
|
|
626
626
|
throw new WalletNotSupportedMethod(
|
|
627
|
-
`aptos:signIn is not supported by ${selectedWallet.name}
|
|
627
|
+
`aptos:signIn is not supported by ${selectedWallet.name}`,
|
|
628
628
|
).message;
|
|
629
629
|
}
|
|
630
630
|
|
|
@@ -650,7 +650,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
650
650
|
*/
|
|
651
651
|
private async connectWallet<T>(
|
|
652
652
|
selectedWallet: AdapterWallet,
|
|
653
|
-
onConnect: () => Promise<{ account: AccountInfo; output: T }
|
|
653
|
+
onConnect: () => Promise<{ account: AccountInfo; output: T }>,
|
|
654
654
|
): Promise<T> {
|
|
655
655
|
try {
|
|
656
656
|
this._connecting = true;
|
|
@@ -701,7 +701,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
701
701
|
* @returns AptosSignAndSubmitTransactionOutput
|
|
702
702
|
*/
|
|
703
703
|
async signAndSubmitTransaction(
|
|
704
|
-
transactionInput: InputTransactionData
|
|
704
|
+
transactionInput: InputTransactionData,
|
|
705
705
|
): Promise<AptosSignAndSubmitTransactionOutput> {
|
|
706
706
|
try {
|
|
707
707
|
if ("function" in transactionInput.data) {
|
|
@@ -752,7 +752,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
752
752
|
});
|
|
753
753
|
|
|
754
754
|
type AptosSignAndSubmitTransactionV1Method = (
|
|
755
|
-
transaction: AnyRawTransaction
|
|
755
|
+
transaction: AnyRawTransaction,
|
|
756
756
|
) => Promise<UserResponse<AptosSignAndSubmitTransactionOutput>>;
|
|
757
757
|
|
|
758
758
|
const signAndSubmitTransactionMethod = this._wallet.features[
|
|
@@ -761,7 +761,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
761
761
|
.signAndSubmitTransaction as unknown as AptosSignAndSubmitTransactionV1Method;
|
|
762
762
|
|
|
763
763
|
const response = (await signAndSubmitTransactionMethod(
|
|
764
|
-
transaction
|
|
764
|
+
transaction,
|
|
765
765
|
)) as UserResponse<AptosSignAndSubmitTransactionOutput>;
|
|
766
766
|
|
|
767
767
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
@@ -857,7 +857,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
857
857
|
"aptos:signTransaction"
|
|
858
858
|
].signTransaction(
|
|
859
859
|
transactionOrPayload,
|
|
860
|
-
asFeePayer
|
|
860
|
+
asFeePayer,
|
|
861
861
|
)) as UserResponse<AccountAuthenticator>;
|
|
862
862
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
863
863
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -893,7 +893,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
893
893
|
AptosSignTransactionMethodV1_1;
|
|
894
894
|
|
|
895
895
|
const response = (await walletSignTransactionMethod(
|
|
896
|
-
signTransactionV1_1StandardInput
|
|
896
|
+
signTransactionV1_1StandardInput,
|
|
897
897
|
)) as UserResponse<AptosSignTransactionOutputV1_1>;
|
|
898
898
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
899
899
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -919,7 +919,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
919
919
|
"aptos:signTransaction"
|
|
920
920
|
].signTransaction(
|
|
921
921
|
transaction,
|
|
922
|
-
asFeePayer
|
|
922
|
+
asFeePayer,
|
|
923
923
|
)) as UserResponse<AccountAuthenticator>;
|
|
924
924
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
925
925
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -946,7 +946,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
946
946
|
* @throws WalletSignMessageError
|
|
947
947
|
*/
|
|
948
948
|
async signMessage(
|
|
949
|
-
message: AptosSignMessageInput
|
|
949
|
+
message: AptosSignMessageInput,
|
|
950
950
|
): Promise<AptosSignMessageOutput> {
|
|
951
951
|
try {
|
|
952
952
|
this.ensureWalletExists(this._wallet);
|
|
@@ -972,7 +972,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
972
972
|
* @returns PendingTransactionResponse
|
|
973
973
|
*/
|
|
974
974
|
async submitTransaction(
|
|
975
|
-
transaction: InputSubmitTransactionData
|
|
975
|
+
transaction: InputSubmitTransactionData,
|
|
976
976
|
): Promise<PendingTransactionResponse> {
|
|
977
977
|
// The standard does not support submitTransaction, so we use the adapter to submit the transaction
|
|
978
978
|
try {
|
|
@@ -1018,7 +1018,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1018
1018
|
await this.setAnsName();
|
|
1019
1019
|
this.recordEvent("account_change");
|
|
1020
1020
|
this.emit("accountChange", this._account);
|
|
1021
|
-
}
|
|
1021
|
+
},
|
|
1022
1022
|
);
|
|
1023
1023
|
} catch (error: any) {
|
|
1024
1024
|
const errMsg = generalizedErrorMessage(error);
|
|
@@ -1039,7 +1039,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1039
1039
|
this.setNetwork(data);
|
|
1040
1040
|
await this.setAnsName();
|
|
1041
1041
|
this.emit("networkChange", this._network);
|
|
1042
|
-
}
|
|
1042
|
+
},
|
|
1043
1043
|
);
|
|
1044
1044
|
} catch (error: any) {
|
|
1045
1045
|
const errMsg = generalizedErrorMessage(error);
|
|
@@ -1073,7 +1073,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1073
1073
|
if (this._wallet.features["aptos:changeNetwork"]) {
|
|
1074
1074
|
const response =
|
|
1075
1075
|
await this._wallet.features["aptos:changeNetwork"].changeNetwork(
|
|
1076
|
-
networkInfo
|
|
1076
|
+
networkInfo,
|
|
1077
1077
|
);
|
|
1078
1078
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
1079
1079
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -1083,7 +1083,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
1085
|
throw new WalletChangeNetworkError(
|
|
1086
|
-
`${this._wallet.name} does not support changing network request
|
|
1086
|
+
`${this._wallet.name} does not support changing network request`,
|
|
1087
1087
|
).message;
|
|
1088
1088
|
} catch (error: any) {
|
|
1089
1089
|
const errMsg = generalizedErrorMessage(error);
|
|
@@ -1113,7 +1113,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1113
1113
|
|
|
1114
1114
|
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
1115
1115
|
const signingMessage = new TextEncoder().encode(
|
|
1116
|
-
response.args.fullMessage
|
|
1116
|
+
response.args.fullMessage,
|
|
1117
1117
|
);
|
|
1118
1118
|
if ("verifySignatureAsync" in (this._account.publicKey as Object)) {
|
|
1119
1119
|
return await this._account.publicKey.verifySignatureAsync({
|
package/src/constants.ts
CHANGED
|
@@ -19,9 +19,24 @@ export const ChainIdToAnsSupportedNetworkMap: Record<string, string> = {
|
|
|
19
19
|
"2": "testnet", // testnet
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The base URL for all Aptos Connect wallets.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Use {@link PETRA_WEB_BASE_URL} instead.
|
|
26
|
+
*/
|
|
27
|
+
export const APTOS_CONNECT_BASE_URL = "https://aptosconnect.app";
|
|
28
|
+
|
|
22
29
|
/** The base URL for all Petra Web wallets. */
|
|
23
|
-
export const
|
|
30
|
+
export const PETRA_WEB_BASE_URL = "https://web.petra.app";
|
|
24
31
|
|
|
25
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The URL to the Aptos Connect account page if the user is signed in to Aptos Connect.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated Use {@link PETRA_WEB_ACCOUNT_URL} instead.
|
|
36
|
+
*/
|
|
26
37
|
export const APTOS_CONNECT_ACCOUNT_URL =
|
|
38
|
+
"https://aptosconnect.app/dashboard/main-account";
|
|
39
|
+
|
|
40
|
+
/** The URL to the Petra Web account page if the user is signed in to Petra Web. */
|
|
41
|
+
export const PETRA_WEB_ACCOUNT_URL =
|
|
27
42
|
"https://web.petra.app/dashboard/main-account";
|
package/src/registry.ts
CHANGED
|
@@ -69,6 +69,13 @@ export const aptosStandardSupportedWalletList: Array<AptosStandardSupportedWalle
|
|
|
69
69
|
readyState: WalletReadyState.NotDetected,
|
|
70
70
|
isAIP62Standard: true,
|
|
71
71
|
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Cosmostation Wallet',
|
|
74
|
+
url: 'https://www.cosmostation.io/',
|
|
75
|
+
icon: 'data:image/svg+xml;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zQyLjExOTcgMTAwLjQ0OCA0MS4zNzcyIDEwMC4yNDkgNDAuNzIyNiA5OS44NzExQzQwLjA2ODEgOTkuNDkzMiAzOS41MjQ1IDk4Ljk0OTYgMzkuMTQ2NiA5OC4yOTUxTDI0IDcyLjA2NDFMMzEuNDQ1MSA2Ny43NTg1TDQ1LjM2MTUgOTEuODYyM0g3MC42ODI3TDgzLjM0MzMgNjkuOTExM0w2OS40Mzk3IDQ1LjgyMDNMNzYuODg0OSA0MS41MTQ2TDkyLjA0NDIgNjcuNzU4NUM5Mi40MjIxIDY4LjQxMyA5Mi42MjExIDY5LjE1NTUgOTIuNjIxMSA2OS45MTEzQzkyLjYyMTEgNzAuNjY3MSA5Mi40MjIxIDcxLjQwOTYgOTIuMDQ0MiA3Mi4wNjQxTDc2Ljg4NDkgOTguMzIwN0M3Ni41MTM0IDk4Ljk1OTIgNzUuOTgzIDk5LjQ5MDYgNzUuMzQ1MyA5OS44NjM0Qzc0LjcwNzUgMTAwLjIzNiA3My45ODQyIDEwMC40MzggNzMuMjQ1NiAxMDAuNDQ4WiIgZmlsbD0iIzA1RDJERCIvPgo8ZGVmcz4KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDBfbGluZWFyXzkwODhfMTQ5ODEiIHgxPSI2NCIgeTE9IjAiIHgyPSI2NCIgeTI9IjEyOCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMjEyMTIxIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzE3MTcxNyIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=',
|
|
76
|
+
readyState: WalletReadyState.NotDetected,
|
|
77
|
+
isAIP62Standard: true,
|
|
78
|
+
},
|
|
72
79
|
];
|
|
73
80
|
|
|
74
81
|
export const crossChainStandardSupportedWalletList: Array<AptosStandardSupportedWallet> =
|
package/src/utils/types.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { WalletInfo } from "./types";
|
|
2
2
|
import { AdapterNotDetectedWallet, AdapterWallet } from "../WalletCore";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
APTOS_CONNECT_BASE_URL,
|
|
5
|
+
PETRA_WEB_BASE_URL,
|
|
6
|
+
WalletReadyState,
|
|
7
|
+
} from "../constants";
|
|
4
8
|
import { isRedirectable } from "./helpers";
|
|
5
9
|
|
|
6
10
|
/**
|
|
@@ -51,15 +55,29 @@ export function truncateAddress(address: string | undefined) {
|
|
|
51
55
|
return `${address.slice(0, 6)}...${address.slice(-5)}`;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Returns `true` if the provided wallet is an Aptos Connect wallet.
|
|
60
|
+
*
|
|
61
|
+
* @deprecated Use {@link isPetraWebWallet} instead.
|
|
62
|
+
*/
|
|
55
63
|
export function isAptosConnectWallet(wallet: WalletInfo | AdapterWallet) {
|
|
64
|
+
return isPetraWebWallet(wallet);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Returns `true` if the provided wallet is a Petra Web wallet. */
|
|
68
|
+
export function isPetraWebWallet(wallet: WalletInfo | AdapterWallet) {
|
|
56
69
|
if (!wallet.url) return false;
|
|
57
|
-
return
|
|
70
|
+
return (
|
|
71
|
+
wallet.url.startsWith(APTOS_CONNECT_BASE_URL) ||
|
|
72
|
+
wallet.url.startsWith(PETRA_WEB_BASE_URL)
|
|
73
|
+
);
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
/**
|
|
61
|
-
* Partitions the `wallets` array so that
|
|
77
|
+
* Partitions the `wallets` array so that Aptos Connect wallets are grouped separately from the rest.
|
|
62
78
|
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
|
|
79
|
+
*
|
|
80
|
+
* @deprecated Use {@link getPetraWebWallets} instead.
|
|
63
81
|
*/
|
|
64
82
|
export function getAptosConnectWallets(
|
|
65
83
|
wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>,
|
|
@@ -71,9 +89,29 @@ export function getAptosConnectWallets(
|
|
|
71
89
|
return { aptosConnectWallets: defaultWallets, otherWallets: moreWallets };
|
|
72
90
|
}
|
|
73
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Partitions the `wallets` array so that Petra Web wallets are grouped separately from the rest.
|
|
94
|
+
* Petra Web is a web wallet that uses social login to create accounts on the blockchain.
|
|
95
|
+
*/
|
|
96
|
+
export function getPetraWebWallets(
|
|
97
|
+
wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>,
|
|
98
|
+
) {
|
|
99
|
+
const { defaultWallets, moreWallets } = partitionWallets(
|
|
100
|
+
wallets,
|
|
101
|
+
isPetraWebWallet,
|
|
102
|
+
);
|
|
103
|
+
return { petraWebWallets: defaultWallets, otherWallets: moreWallets };
|
|
104
|
+
}
|
|
105
|
+
|
|
74
106
|
export interface WalletSortingOptions {
|
|
75
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* An optional function for sorting Aptos Connect wallets.
|
|
109
|
+
*
|
|
110
|
+
* @deprecated Use {@link sortPetraWebWallets} instead.
|
|
111
|
+
*/
|
|
76
112
|
sortAptosConnectWallets?: (a: AdapterWallet, b: AdapterWallet) => number;
|
|
113
|
+
/** An optional function for sorting Petra Web wallets. */
|
|
114
|
+
sortPetraWebWallets?: (a: AdapterWallet, b: AdapterWallet) => number;
|
|
77
115
|
/** An optional function for sorting wallets that are currently installed or loadable. */
|
|
78
116
|
sortAvailableWallets?: (
|
|
79
117
|
a: AdapterWallet | AdapterNotDetectedWallet,
|
|
@@ -89,7 +127,9 @@ export interface WalletSortingOptions {
|
|
|
89
127
|
/**
|
|
90
128
|
* Partitions the `wallets` array into three distinct groups:
|
|
91
129
|
*
|
|
92
|
-
* `aptosConnectWallets` -
|
|
130
|
+
* `aptosConnectWallets` - Use {@link petraWebWallets} instead.
|
|
131
|
+
*
|
|
132
|
+
* `petraWebWallets` - Wallets that use social login to create accounts on
|
|
93
133
|
* the blockchain via Petra Web.
|
|
94
134
|
*
|
|
95
135
|
* `availableWallets` - Wallets that are currently installed or loadable by the client.
|
|
@@ -103,12 +143,16 @@ export function groupAndSortWallets(
|
|
|
103
143
|
wallets: ReadonlyArray<AdapterWallet | AdapterNotDetectedWallet>,
|
|
104
144
|
options?: WalletSortingOptions,
|
|
105
145
|
) {
|
|
106
|
-
const { aptosConnectWallets
|
|
146
|
+
const { aptosConnectWallets } = getAptosConnectWallets(wallets);
|
|
147
|
+
const { otherWallets, petraWebWallets } = getPetraWebWallets(wallets);
|
|
107
148
|
const { defaultWallets, moreWallets } = partitionWallets(otherWallets);
|
|
108
149
|
|
|
109
150
|
if (options?.sortAptosConnectWallets) {
|
|
110
151
|
aptosConnectWallets.sort(options.sortAptosConnectWallets);
|
|
111
152
|
}
|
|
153
|
+
if (options?.sortPetraWebWallets) {
|
|
154
|
+
petraWebWallets.sort(options.sortPetraWebWallets);
|
|
155
|
+
}
|
|
112
156
|
if (options?.sortAvailableWallets) {
|
|
113
157
|
defaultWallets.sort(options.sortAvailableWallets);
|
|
114
158
|
}
|
|
@@ -117,8 +161,10 @@ export function groupAndSortWallets(
|
|
|
117
161
|
}
|
|
118
162
|
|
|
119
163
|
return {
|
|
120
|
-
/**
|
|
164
|
+
/** @deprecated Use {@link petraWebWallets} instead. */
|
|
121
165
|
aptosConnectWallets,
|
|
166
|
+
/** Wallets that use social login to create an account on the blockchain */
|
|
167
|
+
petraWebWallets,
|
|
122
168
|
/** Wallets that are currently installed or loadable. */
|
|
123
169
|
availableWallets: defaultWallets,
|
|
124
170
|
/** Wallets that are NOT currently installed or loadable. */
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const WALLET_ADAPTER_CORE_VERSION = "7.
|
|
1
|
+
export const WALLET_ADAPTER_CORE_VERSION = "7.8.0";
|