@aptos-labs/wallet-adapter-core 5.8.0 → 6.0.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/WalletCore.d.ts +7 -2
- package/dist/WalletCore.d.ts.map +1 -1
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -9
- package/dist/index.mjs.map +1 -1
- package/dist/utils/helpers.d.ts +2 -2
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/types.d.ts +13 -2
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/WalletCore.ts +49 -31
- package/src/utils/helpers.ts +8 -0
- package/src/utils/types.ts +14 -1
- package/src/version.ts +1 -1
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -32,8 +32,8 @@ export declare const fetchDevnetChainId: () => Promise<number>;
|
|
|
32
32
|
* as a string, this function converts the string to Uint8Array.
|
|
33
33
|
*/
|
|
34
34
|
export declare const handlePublishPackageTransaction: (transactionInput: InputTransactionData) => {
|
|
35
|
-
metadataBytes: number | bigint | boolean | Uint8Array | import("@aptos-labs/ts-sdk/dist/common/
|
|
36
|
-
byteCode: (import("@aptos-labs/ts-sdk").
|
|
35
|
+
metadataBytes: number | bigint | boolean | Uint8Array | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").A | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").B | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").U | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").u | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").v | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").q | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").w | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").x | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").p<import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").t> | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").bp<import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").t> | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").o | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").F | ArrayBuffer | (import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").t | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").s)[] | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").p<import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").cb> | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").bo | null | undefined;
|
|
36
|
+
byteCode: (import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").t | import("@aptos-labs/ts-sdk/dist/common/account-Bb5REyaT").s)[];
|
|
37
37
|
};
|
|
38
38
|
export declare function convertNetwork(networkInfo: NetworkInfo | null): Network;
|
|
39
39
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAEX,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAEX,OAAO,EAGR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,WAAW,IAAI,mBAAmB,EACnC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,QAAQ,IAAI,OAAO,CAIlC;AAED,wBAAgB,cAAc,IAAI,OAAO,CAUxC;AAED,wBAAgB,cAAc,IAAI,OAAO,CAOxC;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAI1D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,gBACZ,WAAW,GAAG,IAAI,cACnB,UAAU,GAAG,SAAS,KACjC,WAiDF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gBACZ,WAAW,GAAG,mBAAmB,GAAG,IAAI,KACpD,OAKF,CAAC;AAEF,eAAO,MAAM,kBAAkB,gBAAiB,OAAO,KAAG,OAMzD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAa,QAAQ,MAAM,CAGzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,qBACxB,oBAAoB;;;CAwBvC,CAAC;AAGF,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAavE"}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountAddressInput, InputGenerateTransactionOptions } from "@aptos-labs/ts-sdk";
|
|
1
|
+
import { AccountAddressInput, InputGenerateTransactionOptions, InputTransactionPluginData } from "@aptos-labs/ts-sdk";
|
|
2
2
|
import { InputGenerateTransactionPayloadData } from "@aptos-labs/ts-sdk";
|
|
3
3
|
import { WalletReadyState } from "../constants";
|
|
4
4
|
export interface AptosStandardSupportedWallet {
|
|
@@ -11,18 +11,29 @@ export interface AptosStandardSupportedWallet {
|
|
|
11
11
|
isAptosNativeWallet?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export type AvailableWallets = "Continue with Apple" | "Continue with Google" | "OKX Wallet" | "Petra" | "Nightly" | "Pontem Wallet" | "MSafe" | "Rimosafe";
|
|
14
|
-
|
|
14
|
+
type InputTransactionDataInner = {
|
|
15
15
|
sender?: AccountAddressInput;
|
|
16
16
|
data: InputGenerateTransactionPayloadData;
|
|
17
17
|
options?: InputGenerateTransactionOptions & {
|
|
18
18
|
expirationSecondsFromNow?: number;
|
|
19
19
|
expirationTimestamp?: number;
|
|
20
20
|
};
|
|
21
|
+
/** This will always be set to true if a custom transaction submitter is provided. */
|
|
21
22
|
withFeePayer?: boolean;
|
|
22
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* If `transactionSubmitter` is set it will be used, and override any transaction
|
|
26
|
+
* submitter configured in the DappConfig.
|
|
27
|
+
*
|
|
28
|
+
* The `pluginParams` parameter is used to provide additional parameters to a
|
|
29
|
+
* transaction submitter plugin, whether provided here or configured in the
|
|
30
|
+
* DappConfig.
|
|
31
|
+
*/
|
|
32
|
+
export type InputTransactionData = InputTransactionDataInner & InputTransactionPluginData;
|
|
23
33
|
export type WalletInfo = {
|
|
24
34
|
name: string;
|
|
25
35
|
icon: string;
|
|
26
36
|
url: string;
|
|
27
37
|
};
|
|
38
|
+
export {};
|
|
28
39
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,+BAA+B,
|
|
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,OAAO,GACP,UAAU,CAAC;AAEf,KAAK,yBAAyB,GAAG;IAC/B,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,CAAC,EAAE,+BAA+B,GAAG;QAC1C,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,qFAAqF;IACrF,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAC1D,0BAA0B,CAAC;AAE7B,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const WALLET_ADAPTER_CORE_VERSION = "
|
|
1
|
+
export declare const WALLET_ADAPTER_CORE_VERSION = "6.0.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Aptos Wallet Adapter Core",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"tweetnacl": "^1.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@aptos-labs/ts-sdk": "^1.
|
|
51
|
+
"@aptos-labs/ts-sdk": "^3.1.1"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"dist",
|
package/src/WalletCore.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Network,
|
|
14
14
|
NetworkToChainId,
|
|
15
15
|
PendingTransactionResponse,
|
|
16
|
+
TransactionSubmitter,
|
|
16
17
|
} from "@aptos-labs/ts-sdk";
|
|
17
18
|
import {
|
|
18
19
|
AptosWallet,
|
|
@@ -53,6 +54,7 @@ export type {
|
|
|
53
54
|
Network,
|
|
54
55
|
AnyPublicKey,
|
|
55
56
|
AccountAddress,
|
|
57
|
+
TransactionSubmitter,
|
|
56
58
|
} from "@aptos-labs/ts-sdk";
|
|
57
59
|
|
|
58
60
|
import { GA4 } from "./ga";
|
|
@@ -114,6 +116,11 @@ export type AdapterNotDetectedWallet = Omit<
|
|
|
114
116
|
|
|
115
117
|
export interface DappConfig {
|
|
116
118
|
network: Network;
|
|
119
|
+
/**
|
|
120
|
+
* If provided, the wallet adapter will submit transactions using the provided
|
|
121
|
+
* transaction submitter rather than via the wallet.
|
|
122
|
+
*/
|
|
123
|
+
transactionSubmitter?: TransactionSubmitter;
|
|
117
124
|
aptosApiKeys?: Partial<Record<Network, string>>;
|
|
118
125
|
aptosConnectDappId?: string;
|
|
119
126
|
aptosConnect?: Omit<AptosConnectWalletConfig, "network">;
|
|
@@ -185,7 +192,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
185
192
|
constructor(
|
|
186
193
|
optInWallets?: ReadonlyArray<AvailableWallets>,
|
|
187
194
|
dappConfig?: DappConfig,
|
|
188
|
-
disableTelemetry?: boolean
|
|
195
|
+
disableTelemetry?: boolean,
|
|
189
196
|
) {
|
|
190
197
|
super();
|
|
191
198
|
this._optInWallets = optInWallets || [];
|
|
@@ -232,7 +239,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
232
239
|
* @param extensionwWallets
|
|
233
240
|
*/
|
|
234
241
|
private setExtensionAIP62Wallets(
|
|
235
|
-
extensionwWallets: readonly AptosWallet[]
|
|
242
|
+
extensionwWallets: readonly AptosWallet[],
|
|
236
243
|
): void {
|
|
237
244
|
extensionwWallets.map((wallet: AdapterWallet) => {
|
|
238
245
|
if (this.excludeWallet(wallet)) {
|
|
@@ -244,7 +251,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
244
251
|
if (isValid) {
|
|
245
252
|
// check if we already have this wallet as a not detected wallet
|
|
246
253
|
const index = this._standard_not_detected_wallets.findIndex(
|
|
247
|
-
(notDetctedWallet) => notDetctedWallet.name == wallet.name
|
|
254
|
+
(notDetctedWallet) => notDetctedWallet.name == wallet.name,
|
|
248
255
|
);
|
|
249
256
|
// if we do, remove it from the not detected wallets array as it is now become detected
|
|
250
257
|
if (index !== -1) {
|
|
@@ -253,7 +260,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
253
260
|
|
|
254
261
|
// ✅ Check if wallet already exists in _standard_wallets
|
|
255
262
|
const alreadyExists = this._standard_wallets.some(
|
|
256
|
-
(w) => w.name === wallet.name
|
|
263
|
+
(w) => w.name === wallet.name,
|
|
257
264
|
);
|
|
258
265
|
if (!alreadyExists) {
|
|
259
266
|
wallet.readyState = WalletReadyState.Installed;
|
|
@@ -303,7 +310,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
303
310
|
walletRegistry.map((supportedWallet: AptosStandardSupportedWallet) => {
|
|
304
311
|
// Check if we already have this wallet as a detected AIP-62 wallet standard
|
|
305
312
|
const existingStandardWallet = this._standard_wallets.find(
|
|
306
|
-
(wallet) => wallet.name == supportedWallet.name
|
|
313
|
+
(wallet) => wallet.name == supportedWallet.name,
|
|
307
314
|
);
|
|
308
315
|
// If it is detected, it means the user has the wallet installed, so dont add it to the wallets array
|
|
309
316
|
if (existingStandardWallet) {
|
|
@@ -361,7 +368,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
361
368
|
* @param wallet A wallet
|
|
362
369
|
*/
|
|
363
370
|
private ensureWalletExists(
|
|
364
|
-
wallet: AdapterWallet | null
|
|
371
|
+
wallet: AdapterWallet | null,
|
|
365
372
|
): asserts wallet is AdapterWallet {
|
|
366
373
|
if (!wallet) {
|
|
367
374
|
throw new WalletNotConnectedError().name;
|
|
@@ -376,7 +383,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
376
383
|
* @param account An account
|
|
377
384
|
*/
|
|
378
385
|
private ensureAccountExists(
|
|
379
|
-
account: AccountInfo | null
|
|
386
|
+
account: AccountInfo | null,
|
|
380
387
|
): asserts account is AccountInfo {
|
|
381
388
|
if (!account) {
|
|
382
389
|
throw new WalletAccountError("Account is not set").name;
|
|
@@ -527,7 +534,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
527
534
|
// Check if we are in a redirectable view (i.e on mobile AND not in an in-app browser)
|
|
528
535
|
if (isRedirectable()) {
|
|
529
536
|
const selectedWallet = this._standard_not_detected_wallets.find(
|
|
530
|
-
(wallet: AdapterNotDetectedWallet) => wallet.name === walletName
|
|
537
|
+
(wallet: AdapterNotDetectedWallet) => wallet.name === walletName,
|
|
531
538
|
);
|
|
532
539
|
|
|
533
540
|
if (selectedWallet) {
|
|
@@ -555,7 +562,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
555
562
|
const allDetectedWallets = this._standard_wallets;
|
|
556
563
|
|
|
557
564
|
const selectedWallet = allDetectedWallets.find(
|
|
558
|
-
(wallet: AdapterWallet) => wallet.name === walletName
|
|
565
|
+
(wallet: AdapterWallet) => wallet.name === walletName,
|
|
559
566
|
);
|
|
560
567
|
|
|
561
568
|
if (!selectedWallet) return;
|
|
@@ -565,7 +572,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
565
572
|
// if the selected wallet is already connected, we don't need to connect again
|
|
566
573
|
if (this._wallet?.name === walletName)
|
|
567
574
|
throw new WalletConnectionError(
|
|
568
|
-
`${walletName} wallet is already connected
|
|
575
|
+
`${walletName} wallet is already connected`,
|
|
569
576
|
).message;
|
|
570
577
|
}
|
|
571
578
|
|
|
@@ -598,7 +605,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
598
605
|
|
|
599
606
|
const allDetectedWallets = this._standard_wallets;
|
|
600
607
|
const selectedWallet = allDetectedWallets.find(
|
|
601
|
-
(wallet: AdapterWallet) => wallet.name === walletName
|
|
608
|
+
(wallet: AdapterWallet) => wallet.name === walletName,
|
|
602
609
|
);
|
|
603
610
|
|
|
604
611
|
if (!selectedWallet) {
|
|
@@ -607,14 +614,14 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
607
614
|
|
|
608
615
|
if (!selectedWallet.features["aptos:signIn"]) {
|
|
609
616
|
throw new WalletNotSupportedMethod(
|
|
610
|
-
`aptos:signIn is not supported by ${walletName}
|
|
617
|
+
`aptos:signIn is not supported by ${walletName}`,
|
|
611
618
|
).message;
|
|
612
619
|
}
|
|
613
620
|
|
|
614
621
|
return await this.connectWallet(selectedWallet, async () => {
|
|
615
622
|
if (!selectedWallet.features["aptos:signIn"]) {
|
|
616
623
|
throw new WalletNotSupportedMethod(
|
|
617
|
-
`aptos:signIn is not supported by ${selectedWallet.name}
|
|
624
|
+
`aptos:signIn is not supported by ${selectedWallet.name}`,
|
|
618
625
|
).message;
|
|
619
626
|
}
|
|
620
627
|
|
|
@@ -640,7 +647,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
640
647
|
*/
|
|
641
648
|
private async connectWallet<T>(
|
|
642
649
|
selectedWallet: AdapterWallet,
|
|
643
|
-
onConnect: () => Promise<{ account: AccountInfo; output: T }
|
|
650
|
+
onConnect: () => Promise<{ account: AccountInfo; output: T }>,
|
|
644
651
|
): Promise<T> {
|
|
645
652
|
try {
|
|
646
653
|
this._connecting = true;
|
|
@@ -691,7 +698,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
691
698
|
* @returns AptosSignAndSubmitTransactionOutput
|
|
692
699
|
*/
|
|
693
700
|
async signAndSubmitTransaction(
|
|
694
|
-
transactionInput: InputTransactionData
|
|
701
|
+
transactionInput: InputTransactionData,
|
|
695
702
|
): Promise<AptosSignAndSubmitTransactionOutput> {
|
|
696
703
|
try {
|
|
697
704
|
if ("function" in transactionInput.data) {
|
|
@@ -716,7 +723,15 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
716
723
|
this.ensureAccountExists(this._account);
|
|
717
724
|
this.recordEvent("sign_and_submit_transaction");
|
|
718
725
|
|
|
719
|
-
if
|
|
726
|
+
// We'll submit ourselves if a custom transaction submitter has been provided.
|
|
727
|
+
const shouldUseTxnSubmitter =
|
|
728
|
+
this._dappConfig?.transactionSubmitter !== undefined ||
|
|
729
|
+
transactionInput.transactionSubmitter !== undefined;
|
|
730
|
+
|
|
731
|
+
if (
|
|
732
|
+
this._wallet.features["aptos:signAndSubmitTransaction"] &&
|
|
733
|
+
!shouldUseTxnSubmitter
|
|
734
|
+
) {
|
|
720
735
|
// check for backward compatibility. before version 1.1.0 the standard expected
|
|
721
736
|
// AnyRawTransaction input so the adapter built the transaction before sending it to the wallet
|
|
722
737
|
if (
|
|
@@ -733,7 +748,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
733
748
|
});
|
|
734
749
|
|
|
735
750
|
type AptosSignAndSubmitTransactionV1Method = (
|
|
736
|
-
transaction: AnyRawTransaction
|
|
751
|
+
transaction: AnyRawTransaction,
|
|
737
752
|
) => Promise<UserResponse<AptosSignAndSubmitTransactionOutput>>;
|
|
738
753
|
|
|
739
754
|
const signAndSubmitTransactionMethod = this._wallet.features[
|
|
@@ -742,7 +757,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
742
757
|
.signAndSubmitTransaction as unknown as AptosSignAndSubmitTransactionV1Method;
|
|
743
758
|
|
|
744
759
|
const response = (await signAndSubmitTransactionMethod(
|
|
745
|
-
transaction
|
|
760
|
+
transaction,
|
|
746
761
|
)) as UserResponse<AptosSignAndSubmitTransactionOutput>;
|
|
747
762
|
|
|
748
763
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
@@ -767,14 +782,15 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
767
782
|
return response.args;
|
|
768
783
|
}
|
|
769
784
|
|
|
770
|
-
// If wallet does not support signAndSubmitTransaction
|
|
771
|
-
// the adapter will sign and submit it for the dapp.
|
|
785
|
+
// If wallet does not support signAndSubmitTransaction or a transaction submitter
|
|
786
|
+
// is provided, the adapter will sign and submit it for the dapp.
|
|
772
787
|
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
773
788
|
const aptos = new Aptos(aptosConfig);
|
|
774
789
|
const transaction = await aptos.transaction.build.simple({
|
|
775
|
-
sender: this._account.address,
|
|
790
|
+
sender: this._account.address.toString(),
|
|
776
791
|
data: transactionInput.data,
|
|
777
792
|
options: transactionInput.options,
|
|
793
|
+
withFeePayer: shouldUseTxnSubmitter,
|
|
778
794
|
});
|
|
779
795
|
|
|
780
796
|
const signTransactionResponse = await this.signTransaction({
|
|
@@ -783,6 +799,8 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
783
799
|
const response = await this.submitTransaction({
|
|
784
800
|
transaction,
|
|
785
801
|
senderAuthenticator: signTransactionResponse.authenticator,
|
|
802
|
+
transactionSubmitter: transactionInput.transactionSubmitter,
|
|
803
|
+
pluginParams: transactionInput.pluginParams,
|
|
786
804
|
});
|
|
787
805
|
return { hash: response.hash };
|
|
788
806
|
} catch (error: any) {
|
|
@@ -835,7 +853,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
835
853
|
"aptos:signTransaction"
|
|
836
854
|
].signTransaction(
|
|
837
855
|
transactionOrPayload,
|
|
838
|
-
asFeePayer
|
|
856
|
+
asFeePayer,
|
|
839
857
|
)) as UserResponse<AccountAuthenticator>;
|
|
840
858
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
841
859
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -871,7 +889,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
871
889
|
AptosSignTransactionMethodV1_1;
|
|
872
890
|
|
|
873
891
|
const response = (await walletSignTransactionMethod(
|
|
874
|
-
signTransactionV1_1StandardInput
|
|
892
|
+
signTransactionV1_1StandardInput,
|
|
875
893
|
)) as UserResponse<AptosSignTransactionOutputV1_1>;
|
|
876
894
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
877
895
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -897,7 +915,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
897
915
|
"aptos:signTransaction"
|
|
898
916
|
].signTransaction(
|
|
899
917
|
transaction,
|
|
900
|
-
asFeePayer
|
|
918
|
+
asFeePayer,
|
|
901
919
|
)) as UserResponse<AccountAuthenticator>;
|
|
902
920
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
903
921
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -924,7 +942,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
924
942
|
* @throws WalletSignMessageError
|
|
925
943
|
*/
|
|
926
944
|
async signMessage(
|
|
927
|
-
message: AptosSignMessageInput
|
|
945
|
+
message: AptosSignMessageInput,
|
|
928
946
|
): Promise<AptosSignMessageOutput> {
|
|
929
947
|
try {
|
|
930
948
|
this.ensureWalletExists(this._wallet);
|
|
@@ -950,7 +968,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
950
968
|
* @returns PendingTransactionResponse
|
|
951
969
|
*/
|
|
952
970
|
async submitTransaction(
|
|
953
|
-
transaction: InputSubmitTransactionData
|
|
971
|
+
transaction: InputSubmitTransactionData,
|
|
954
972
|
): Promise<PendingTransactionResponse> {
|
|
955
973
|
// The standard does not support submitTransaction, so we use the adapter to submit the transaction
|
|
956
974
|
try {
|
|
@@ -996,7 +1014,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
996
1014
|
await this.setAnsName();
|
|
997
1015
|
this.recordEvent("account_change");
|
|
998
1016
|
this.emit("accountChange", this._account);
|
|
999
|
-
}
|
|
1017
|
+
},
|
|
1000
1018
|
);
|
|
1001
1019
|
} catch (error: any) {
|
|
1002
1020
|
const errMsg = generalizedErrorMessage(error);
|
|
@@ -1017,7 +1035,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1017
1035
|
this.setNetwork(data);
|
|
1018
1036
|
await this.setAnsName();
|
|
1019
1037
|
this.emit("networkChange", this._network);
|
|
1020
|
-
}
|
|
1038
|
+
},
|
|
1021
1039
|
);
|
|
1022
1040
|
} catch (error: any) {
|
|
1023
1041
|
const errMsg = generalizedErrorMessage(error);
|
|
@@ -1051,7 +1069,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1051
1069
|
if (this._wallet.features["aptos:changeNetwork"]) {
|
|
1052
1070
|
const response =
|
|
1053
1071
|
await this._wallet.features["aptos:changeNetwork"].changeNetwork(
|
|
1054
|
-
networkInfo
|
|
1072
|
+
networkInfo,
|
|
1055
1073
|
);
|
|
1056
1074
|
if (response.status === UserResponseStatus.REJECTED) {
|
|
1057
1075
|
throw new WalletConnectionError("User has rejected the request")
|
|
@@ -1061,7 +1079,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1061
1079
|
}
|
|
1062
1080
|
|
|
1063
1081
|
throw new WalletChangeNetworkError(
|
|
1064
|
-
`${this._wallet.name} does not support changing network request
|
|
1082
|
+
`${this._wallet.name} does not support changing network request`,
|
|
1065
1083
|
).message;
|
|
1066
1084
|
} catch (error: any) {
|
|
1067
1085
|
const errMsg = generalizedErrorMessage(error);
|
|
@@ -1091,7 +1109,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
1091
1109
|
|
|
1092
1110
|
const aptosConfig = getAptosConfig(this._network, this._dappConfig);
|
|
1093
1111
|
const signingMessage = new TextEncoder().encode(
|
|
1094
|
-
response.args.fullMessage
|
|
1112
|
+
response.args.fullMessage,
|
|
1095
1113
|
);
|
|
1096
1114
|
if ("verifySignatureAsync" in (this._account.publicKey as Object)) {
|
|
1097
1115
|
return await this._account.publicKey.verifySignatureAsync({
|
package/src/utils/helpers.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Hex,
|
|
5
5
|
Network,
|
|
6
6
|
NetworkToNodeAPI,
|
|
7
|
+
PluginSettings,
|
|
7
8
|
} from "@aptos-labs/ts-sdk";
|
|
8
9
|
import {
|
|
9
10
|
NetworkInfo,
|
|
@@ -62,6 +63,10 @@ export const getAptosConfig = (
|
|
|
62
63
|
throw new Error("Undefined network");
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
const pluginSettings: PluginSettings = {
|
|
67
|
+
TRANSACTION_SUBMITTER: dappConfig?.transactionSubmitter,
|
|
68
|
+
};
|
|
69
|
+
|
|
65
70
|
if (isAptosNetwork(networkInfo)) {
|
|
66
71
|
const currentNetwork = convertNetwork(networkInfo);
|
|
67
72
|
|
|
@@ -70,11 +75,13 @@ export const getAptosConfig = (
|
|
|
70
75
|
return new AptosConfig({
|
|
71
76
|
network: currentNetwork,
|
|
72
77
|
clientConfig: { API_KEY: apiKey ? apiKey[currentNetwork] : undefined },
|
|
78
|
+
pluginSettings,
|
|
73
79
|
});
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
return new AptosConfig({
|
|
77
83
|
network: currentNetwork,
|
|
84
|
+
pluginSettings,
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
87
|
|
|
@@ -91,6 +98,7 @@ export const getAptosConfig = (
|
|
|
91
98
|
return new AptosConfig({
|
|
92
99
|
network: Network.CUSTOM,
|
|
93
100
|
fullnode: networkInfo.url,
|
|
101
|
+
pluginSettings,
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
104
|
}
|
package/src/utils/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccountAddressInput,
|
|
3
3
|
InputGenerateTransactionOptions,
|
|
4
|
+
InputTransactionPluginData,
|
|
4
5
|
} from "@aptos-labs/ts-sdk";
|
|
5
6
|
import { InputGenerateTransactionPayloadData } from "@aptos-labs/ts-sdk";
|
|
6
7
|
import { WalletReadyState } from "../constants";
|
|
@@ -36,16 +37,28 @@ export type AvailableWallets =
|
|
|
36
37
|
| "MSafe"
|
|
37
38
|
| "Rimosafe";
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
type InputTransactionDataInner = {
|
|
40
41
|
sender?: AccountAddressInput;
|
|
41
42
|
data: InputGenerateTransactionPayloadData;
|
|
42
43
|
options?: InputGenerateTransactionOptions & {
|
|
43
44
|
expirationSecondsFromNow?: number;
|
|
44
45
|
expirationTimestamp?: number;
|
|
45
46
|
};
|
|
47
|
+
/** This will always be set to true if a custom transaction submitter is provided. */
|
|
46
48
|
withFeePayer?: boolean;
|
|
47
49
|
};
|
|
48
50
|
|
|
51
|
+
/**
|
|
52
|
+
* If `transactionSubmitter` is set it will be used, and override any transaction
|
|
53
|
+
* submitter configured in the DappConfig.
|
|
54
|
+
*
|
|
55
|
+
* The `pluginParams` parameter is used to provide additional parameters to a
|
|
56
|
+
* transaction submitter plugin, whether provided here or configured in the
|
|
57
|
+
* DappConfig.
|
|
58
|
+
*/
|
|
59
|
+
export type InputTransactionData = InputTransactionDataInner &
|
|
60
|
+
InputTransactionPluginData;
|
|
61
|
+
|
|
49
62
|
export type WalletInfo = {
|
|
50
63
|
name: string;
|
|
51
64
|
icon: string;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const WALLET_ADAPTER_CORE_VERSION = "
|
|
1
|
+
export const WALLET_ADAPTER_CORE_VERSION = "6.0.0";
|