@aptos-labs/wallet-adapter-core 3.4.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +23 -8
- package/dist/index.mjs +25 -9
- package/package.json +2 -2
- package/src/WalletCore.ts +20 -8
- package/src/WalletCoreV1.ts +6 -0
- package/src/types.ts +18 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ interface AdapterPluginProps<Name extends string = string> {
|
|
|
97
97
|
connect(): Promise<any>;
|
|
98
98
|
disconnect: () => Promise<any>;
|
|
99
99
|
network: () => Promise<any>;
|
|
100
|
-
signAndSubmitTransaction
|
|
100
|
+
signAndSubmitTransaction(transaction: Types.TransactionPayload | InputGenerateTransactionData, options?: InputGenerateTransactionOptions): Promise<{
|
|
101
101
|
hash: Types.HexEncodedBytes;
|
|
102
102
|
output?: any;
|
|
103
103
|
} | PendingTransactionResponse>;
|
|
@@ -117,6 +117,18 @@ type InputTransactionData = {
|
|
|
117
117
|
data: InputGenerateTransactionPayloadData;
|
|
118
118
|
options?: InputGenerateTransactionOptions;
|
|
119
119
|
};
|
|
120
|
+
interface PluginProvider {
|
|
121
|
+
connect: () => Promise<AccountInfo>;
|
|
122
|
+
account: () => Promise<AccountInfo>;
|
|
123
|
+
disconnect: () => Promise<void>;
|
|
124
|
+
signAndSubmitTransaction: (transaction: any, options?: any) => Promise<{
|
|
125
|
+
hash: Types.HexEncodedBytes;
|
|
126
|
+
} | AptosWalletErrorResult>;
|
|
127
|
+
signMessage: (message: SignMessagePayload) => Promise<SignMessageResponse>;
|
|
128
|
+
network: () => Promise<NetworkInfo>;
|
|
129
|
+
onAccountChange: (listener: (newAddress: AccountInfo) => Promise<void>) => Promise<void>;
|
|
130
|
+
onNetworkChange: OnNetworkChange;
|
|
131
|
+
}
|
|
120
132
|
|
|
121
133
|
declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
122
134
|
private _wallets;
|
|
@@ -239,4 +251,4 @@ declare function isRedirectable(): boolean;
|
|
|
239
251
|
declare function generalizedErrorMessage(error: any): string;
|
|
240
252
|
declare const areBCSArguments: (args: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>) => boolean;
|
|
241
253
|
|
|
242
|
-
export { AccountInfo, AdapterPlugin, AdapterPluginEvents, AdapterPluginProps, AptosWalletErrorResult, InputTransactionData, NetworkInfo, NetworkName, OnAccountChange, OnNetworkChange, SignMessagePayload, SignMessageResponse, TransactionOptions, Wallet, WalletCore, WalletCoreEvents, WalletInfo, WalletName, WalletReadyState, areBCSArguments, generalizedErrorMessage, getLocalStorage, isInAppBrowser, isMobile, isRedirectable, removeLocalStorage, scopePollingDetectionStrategy, setLocalStorage };
|
|
254
|
+
export { AccountInfo, AdapterPlugin, AdapterPluginEvents, AdapterPluginProps, AptosWalletErrorResult, InputTransactionData, NetworkInfo, NetworkName, OnAccountChange, OnNetworkChange, PluginProvider, SignMessagePayload, SignMessageResponse, TransactionOptions, Wallet, WalletCore, WalletCoreEvents, WalletInfo, WalletName, WalletReadyState, areBCSArguments, generalizedErrorMessage, getLocalStorage, isInAppBrowser, isMobile, isRedirectable, removeLocalStorage, scopePollingDetectionStrategy, setLocalStorage };
|
package/dist/index.js
CHANGED
|
@@ -309,6 +309,11 @@ var WalletCoreV1 = class extends import_eventemitter3.default {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
async signAndSubmitBCSTransaction(transaction, wallet, options) {
|
|
312
|
+
if (!("signAndSubmitBCSTransaction" in wallet)) {
|
|
313
|
+
throw new WalletNotSupportedMethod(
|
|
314
|
+
`Submit a BCS Transaction is not supported by ${wallet.name}`
|
|
315
|
+
).message;
|
|
316
|
+
}
|
|
312
317
|
try {
|
|
313
318
|
const response = await wallet.signAndSubmitBCSTransaction(
|
|
314
319
|
transaction,
|
|
@@ -549,7 +554,7 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
549
554
|
`Sign Transaction V2 is not supported by ${(_b = this.wallet) == null ? void 0 : _b.name}`
|
|
550
555
|
).message;
|
|
551
556
|
}
|
|
552
|
-
const accountAuthenticator2 = this._wallet.signTransaction(
|
|
557
|
+
const accountAuthenticator2 = await this._wallet.signTransaction(
|
|
553
558
|
transactionOrPayload,
|
|
554
559
|
asFeePayer
|
|
555
560
|
);
|
|
@@ -597,15 +602,25 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
597
602
|
}
|
|
598
603
|
}
|
|
599
604
|
async submitTransaction(transaction) {
|
|
600
|
-
var _a;
|
|
601
|
-
if (this._wallet && !("submitTransaction" in this._wallet)) {
|
|
602
|
-
throw new WalletNotSupportedMethod(
|
|
603
|
-
`Submit Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
|
|
604
|
-
).message;
|
|
605
|
-
}
|
|
606
605
|
try {
|
|
607
606
|
this.doesWalletExist();
|
|
608
|
-
|
|
607
|
+
if (this._wallet && !("submitTransaction" in this._wallet)) {
|
|
608
|
+
const { additionalSignersAuthenticators } = transaction;
|
|
609
|
+
const aptosConfig = new import_ts_sdk3.AptosConfig({
|
|
610
|
+
network: convertNetwork(this.network)
|
|
611
|
+
});
|
|
612
|
+
const aptos = new import_ts_sdk3.Aptos(aptosConfig);
|
|
613
|
+
if (additionalSignersAuthenticators !== void 0) {
|
|
614
|
+
const multiAgentTxn = {
|
|
615
|
+
...transaction,
|
|
616
|
+
additionalSignersAuthenticators
|
|
617
|
+
};
|
|
618
|
+
return aptos.transaction.submit.multiAgent(multiAgentTxn);
|
|
619
|
+
} else {
|
|
620
|
+
return aptos.transaction.submit.simple(transaction);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
const pendingTransaction = await this._wallet.submitTransaction(
|
|
609
624
|
transaction
|
|
610
625
|
);
|
|
611
626
|
return pendingTransaction;
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
Ed25519PublicKey,
|
|
6
6
|
Ed25519Signature,
|
|
7
7
|
AptosConfig,
|
|
8
|
-
generateTransactionPayload
|
|
8
|
+
generateTransactionPayload,
|
|
9
|
+
Aptos
|
|
9
10
|
} from "@aptos-labs/ts-sdk";
|
|
10
11
|
import EventEmitter2 from "eventemitter3";
|
|
11
12
|
import nacl from "tweetnacl";
|
|
@@ -275,6 +276,11 @@ var WalletCoreV1 = class extends EventEmitter {
|
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
async signAndSubmitBCSTransaction(transaction, wallet, options) {
|
|
279
|
+
if (!("signAndSubmitBCSTransaction" in wallet)) {
|
|
280
|
+
throw new WalletNotSupportedMethod(
|
|
281
|
+
`Submit a BCS Transaction is not supported by ${wallet.name}`
|
|
282
|
+
).message;
|
|
283
|
+
}
|
|
278
284
|
try {
|
|
279
285
|
const response = await wallet.signAndSubmitBCSTransaction(
|
|
280
286
|
transaction,
|
|
@@ -515,7 +521,7 @@ var WalletCore = class extends EventEmitter2 {
|
|
|
515
521
|
`Sign Transaction V2 is not supported by ${(_b = this.wallet) == null ? void 0 : _b.name}`
|
|
516
522
|
).message;
|
|
517
523
|
}
|
|
518
|
-
const accountAuthenticator2 = this._wallet.signTransaction(
|
|
524
|
+
const accountAuthenticator2 = await this._wallet.signTransaction(
|
|
519
525
|
transactionOrPayload,
|
|
520
526
|
asFeePayer
|
|
521
527
|
);
|
|
@@ -563,15 +569,25 @@ var WalletCore = class extends EventEmitter2 {
|
|
|
563
569
|
}
|
|
564
570
|
}
|
|
565
571
|
async submitTransaction(transaction) {
|
|
566
|
-
var _a;
|
|
567
|
-
if (this._wallet && !("submitTransaction" in this._wallet)) {
|
|
568
|
-
throw new WalletNotSupportedMethod(
|
|
569
|
-
`Submit Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
|
|
570
|
-
).message;
|
|
571
|
-
}
|
|
572
572
|
try {
|
|
573
573
|
this.doesWalletExist();
|
|
574
|
-
|
|
574
|
+
if (this._wallet && !("submitTransaction" in this._wallet)) {
|
|
575
|
+
const { additionalSignersAuthenticators } = transaction;
|
|
576
|
+
const aptosConfig = new AptosConfig({
|
|
577
|
+
network: convertNetwork(this.network)
|
|
578
|
+
});
|
|
579
|
+
const aptos = new Aptos(aptosConfig);
|
|
580
|
+
if (additionalSignersAuthenticators !== void 0) {
|
|
581
|
+
const multiAgentTxn = {
|
|
582
|
+
...transaction,
|
|
583
|
+
additionalSignersAuthenticators
|
|
584
|
+
};
|
|
585
|
+
return aptos.transaction.submit.multiAgent(multiAgentTxn);
|
|
586
|
+
} else {
|
|
587
|
+
return aptos.transaction.submit.simple(transaction);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const pendingTransaction = await this._wallet.submitTransaction(
|
|
575
591
|
transaction
|
|
576
592
|
);
|
|
577
593
|
return pendingTransaction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Aptos Wallet Adapter Core",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"aptos": "^1.21.0",
|
|
47
|
-
"@aptos-labs/ts-sdk": "^1.
|
|
47
|
+
"@aptos-labs/ts-sdk": "^1.6.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/WalletCore.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
generateTransactionPayload,
|
|
11
11
|
InputSubmitTransactionData,
|
|
12
12
|
PendingTransactionResponse,
|
|
13
|
-
InputEntryFunctionDataWithRemoteABI,
|
|
13
|
+
InputEntryFunctionDataWithRemoteABI, Aptos,
|
|
14
14
|
} from "@aptos-labs/ts-sdk";
|
|
15
15
|
import EventEmitter from "eventemitter3";
|
|
16
16
|
import nacl from "tweetnacl";
|
|
@@ -385,7 +385,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
385
385
|
`Sign Transaction V2 is not supported by ${this.wallet?.name}`
|
|
386
386
|
).message;
|
|
387
387
|
}
|
|
388
|
-
const accountAuthenticator = (this._wallet as any).signTransaction(
|
|
388
|
+
const accountAuthenticator = await (this._wallet as any).signTransaction(
|
|
389
389
|
transactionOrPayload,
|
|
390
390
|
asFeePayer
|
|
391
391
|
);
|
|
@@ -457,14 +457,26 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
457
457
|
async submitTransaction(
|
|
458
458
|
transaction: InputSubmitTransactionData
|
|
459
459
|
): Promise<PendingTransactionResponse> {
|
|
460
|
-
if (this._wallet && !("submitTransaction" in this._wallet)) {
|
|
461
|
-
throw new WalletNotSupportedMethod(
|
|
462
|
-
`Submit Transaction is not supported by ${this.wallet?.name}`
|
|
463
|
-
).message;
|
|
464
|
-
}
|
|
465
460
|
try {
|
|
466
461
|
this.doesWalletExist();
|
|
467
|
-
|
|
462
|
+
if (this._wallet && !("submitTransaction" in this._wallet)) {
|
|
463
|
+
const { additionalSignersAuthenticators } = transaction;
|
|
464
|
+
const aptosConfig = new AptosConfig({
|
|
465
|
+
network: convertNetwork(this.network),
|
|
466
|
+
});
|
|
467
|
+
const aptos = new Aptos(aptosConfig);
|
|
468
|
+
if (additionalSignersAuthenticators !== undefined) {
|
|
469
|
+
const multiAgentTxn = {
|
|
470
|
+
...transaction,
|
|
471
|
+
additionalSignersAuthenticators,
|
|
472
|
+
};
|
|
473
|
+
return aptos.transaction.submit.multiAgent(multiAgentTxn);
|
|
474
|
+
} else {
|
|
475
|
+
return aptos.transaction.submit.simple(transaction);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const pendingTransaction = await (this._wallet as any).submitTransaction(
|
|
468
480
|
transaction
|
|
469
481
|
);
|
|
470
482
|
|
package/src/WalletCoreV1.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { TxnBuilderTypes, Types } from "aptos";
|
|
|
2
2
|
import EventEmitter from "eventemitter3";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
WalletNotSupportedMethod,
|
|
5
6
|
WalletSignAndSubmitMessageError,
|
|
6
7
|
WalletSignTransactionError,
|
|
7
8
|
} from "./error";
|
|
@@ -45,6 +46,11 @@ export class WalletCoreV1 extends EventEmitter<WalletCoreEvents> {
|
|
|
45
46
|
wallet: Wallet,
|
|
46
47
|
options?: TransactionOptions
|
|
47
48
|
): Promise<any> {
|
|
49
|
+
if (!("signAndSubmitBCSTransaction" in wallet)) {
|
|
50
|
+
throw new WalletNotSupportedMethod(
|
|
51
|
+
`Submit a BCS Transaction is not supported by ${wallet.name}`
|
|
52
|
+
).message;
|
|
53
|
+
}
|
|
48
54
|
try {
|
|
49
55
|
const response = await (wallet as any).signAndSubmitBCSTransaction(
|
|
50
56
|
transaction,
|
package/src/types.ts
CHANGED
|
@@ -103,7 +103,7 @@ export interface AdapterPluginProps<Name extends string = string> {
|
|
|
103
103
|
connect(): Promise<any>;
|
|
104
104
|
disconnect: () => Promise<any>;
|
|
105
105
|
network: () => Promise<any>;
|
|
106
|
-
signAndSubmitTransaction
|
|
106
|
+
signAndSubmitTransaction(
|
|
107
107
|
transaction: Types.TransactionPayload | InputGenerateTransactionData,
|
|
108
108
|
options?: InputGenerateTransactionOptions
|
|
109
109
|
): Promise<
|
|
@@ -134,3 +134,20 @@ export type InputTransactionData = {
|
|
|
134
134
|
data: InputGenerateTransactionPayloadData;
|
|
135
135
|
options?: InputGenerateTransactionOptions;
|
|
136
136
|
};
|
|
137
|
+
|
|
138
|
+
// To be used by a wallet plugin
|
|
139
|
+
export interface PluginProvider {
|
|
140
|
+
connect: () => Promise<AccountInfo>;
|
|
141
|
+
account: () => Promise<AccountInfo>;
|
|
142
|
+
disconnect: () => Promise<void>;
|
|
143
|
+
signAndSubmitTransaction: (
|
|
144
|
+
transaction: any,
|
|
145
|
+
options?: any
|
|
146
|
+
) => Promise<{ hash: Types.HexEncodedBytes } | AptosWalletErrorResult>;
|
|
147
|
+
signMessage: (message: SignMessagePayload) => Promise<SignMessageResponse>;
|
|
148
|
+
network: () => Promise<NetworkInfo>;
|
|
149
|
+
onAccountChange: (
|
|
150
|
+
listener: (newAddress: AccountInfo) => Promise<void>
|
|
151
|
+
) => Promise<void>;
|
|
152
|
+
onNetworkChange: OnNetworkChange;
|
|
153
|
+
}
|