@aptos-labs/wallet-adapter-core 2.6.0 → 3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @aptos-labs/wallet-adapter-core
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 31e0084: Support TypeScript SDK V2. Fully compatible with existing SDK V1 and Wallet Adapter V1
8
+ but with a full SDK V2 support for the dapp.
9
+
10
+ - Add support for SDK V2 input types
11
+ - `signAndSubmitTransaction()` accept only SDK V2 transaction input type
12
+ - Implement a `submitTransaction()` function for multi signers transactions
13
+ - `signTransaction()` to support both SDK V1 and V2 versions
14
+ - Convert wallet `SignedTransaction` response from `signTransaction()` to TS SDK V2 `AccountAuthenticator`
15
+ - Demo app to demonstrate different trnsaction flows - single signer, sponsor and multi agent transactions
16
+ - Reject promise on core and/or provider errors instead of just returning `false`
17
+ - Use `@aptos-labs/ts-sdk@experimental` version `0.0.7`
18
+
3
19
  ## 2.6.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Types, TxnBuilderTypes } from 'aptos';
1
+ import { Types } from 'aptos';
2
2
  export { TxnBuilderTypes, Types } from 'aptos';
3
- import { InputGenerateTransactionData } from '@aptos-labs/ts-sdk';
4
- export { InputGenerateTransactionData } from '@aptos-labs/ts-sdk';
3
+ import { Network, InputGenerateTransactionData, InputGenerateTransactionOptions, PendingTransactionResponse, InputSubmitTransactionData, AnyRawTransaction, AccountAuthenticator } from '@aptos-labs/ts-sdk';
4
+ export { AccountAuthenticator, AnyRawTransaction, InputGenerateTransactionData, InputGenerateTransactionOptions, InputSubmitTransactionData, PendingTransactionResponse } from '@aptos-labs/ts-sdk';
5
5
  import EventEmitter from 'eventemitter3';
6
6
 
7
7
  declare enum WalletReadyState {
@@ -33,10 +33,15 @@ type WalletName<T extends string = string> = T & {
33
33
  __brand__: "WalletName";
34
34
  };
35
35
  type NetworkInfo = {
36
- name: NetworkName;
36
+ name: Network;
37
37
  chainId?: string;
38
38
  url?: string;
39
39
  };
40
+ type WalletInfo = {
41
+ name: WalletName;
42
+ icon: string;
43
+ url: string;
44
+ };
40
45
  type AccountInfo = {
41
46
  address: string;
42
47
  publicKey: string | string[];
@@ -48,50 +53,6 @@ interface AptosWalletErrorResult {
48
53
  name: string;
49
54
  message: string;
50
55
  }
51
- type OnNetworkChange = (callBack: (networkInfo: NetworkInfo) => Promise<void>) => Promise<void>;
52
- interface PluginProvider {
53
- connect: () => Promise<AccountInfo>;
54
- account: () => Promise<AccountInfo>;
55
- disconnect: () => Promise<void>;
56
- signAndSubmitTransaction: (transaction: any, options?: any) => Promise<{
57
- hash: Types.HexEncodedBytes;
58
- } | AptosWalletErrorResult>;
59
- signMessage: (message: SignMessagePayload) => Promise<SignMessageResponse>;
60
- network: () => Promise<NetworkName>;
61
- onAccountChange: (listener: (newAddress: AccountInfo) => Promise<void>) => Promise<void>;
62
- onNetworkChange: OnNetworkChange;
63
- signMultiAgentTransaction: (rawTxn: TxnBuilderTypes.MultiAgentRawTransaction | TxnBuilderTypes.FeePayerRawTransaction) => Promise<string>;
64
- }
65
- interface AdapterPluginEvents {
66
- onNetworkChange: OnNetworkChange;
67
- onAccountChange(callback: any): Promise<any>;
68
- }
69
- interface AdapterPluginProps<Name extends string = string> {
70
- name: WalletName<Name>;
71
- url: string;
72
- icon: `data:image/${"svg+xml" | "webp" | "png" | "gif"};base64,${string}`;
73
- providerName?: string;
74
- provider: any;
75
- deeplinkProvider?: (data: {
76
- url: string;
77
- }) => string;
78
- connect(): Promise<any>;
79
- disconnect: () => Promise<any>;
80
- network: () => Promise<any>;
81
- signAndSubmitTransaction<T extends Types.TransactionPayload, V>(transaction: T, options?: V): Promise<{
82
- hash: Types.HexEncodedBytes;
83
- }>;
84
- signMessage<T extends SignMessagePayload>(message: T): Promise<SignMessageResponse>;
85
- }
86
- type AdapterPlugin<Name extends string = string> = AdapterPluginProps<Name> & AdapterPluginEvents;
87
- type Wallet<Name extends string = string> = AdapterPlugin<Name> & {
88
- readyState?: WalletReadyState;
89
- };
90
- type WalletInfo = {
91
- name: WalletName;
92
- icon: string;
93
- url: string;
94
- };
95
56
  declare interface WalletCoreEvents {
96
57
  connect(account: AccountInfo | null): void;
97
58
  disconnect(): void;
@@ -117,6 +78,36 @@ interface SignMessageResponse {
117
78
  signature: string | string[];
118
79
  bitmap?: Uint8Array;
119
80
  }
81
+ type OnNetworkChange = (callBack: (networkInfo: NetworkInfo) => Promise<void>) => Promise<void>;
82
+ type OnAccountChange = (callBack: (accountInfo: AccountInfo) => Promise<any>) => Promise<void>;
83
+ interface AdapterPluginEvents {
84
+ onNetworkChange: OnNetworkChange;
85
+ onAccountChange: OnAccountChange;
86
+ }
87
+ interface AdapterPluginProps<Name extends string = string> {
88
+ name: WalletName<Name>;
89
+ url: string;
90
+ icon: `data:image/${"svg+xml" | "webp" | "png" | "gif"};base64,${string}`;
91
+ version?: "v1" | "v2";
92
+ providerName?: string;
93
+ provider: any;
94
+ deeplinkProvider?: (data: {
95
+ url: string;
96
+ }) => string;
97
+ connect(): Promise<any>;
98
+ disconnect: () => Promise<any>;
99
+ network: () => Promise<any>;
100
+ signAndSubmitTransaction<V>(transaction: Types.TransactionPayload | InputGenerateTransactionData, options?: InputGenerateTransactionOptions): Promise<{
101
+ hash: Types.HexEncodedBytes;
102
+ output?: any;
103
+ } | PendingTransactionResponse>;
104
+ submitTransaction?(transaction: InputSubmitTransactionData): Promise<PendingTransactionResponse>;
105
+ signMessage<T extends SignMessagePayload>(message: T): Promise<SignMessageResponse>;
106
+ }
107
+ type AdapterPlugin<Name extends string = string> = AdapterPluginProps<Name> & AdapterPluginEvents;
108
+ type Wallet<Name extends string = string> = AdapterPlugin<Name> & {
109
+ readyState?: WalletReadyState;
110
+ };
120
111
  interface TransactionOptions {
121
112
  max_gas_amount?: bigint;
122
113
  gas_unit_price?: bigint;
@@ -127,6 +118,7 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
127
118
  private _wallet;
128
119
  private _account;
129
120
  private _network;
121
+ private readonly waletCoreV1;
130
122
  private _connecting;
131
123
  private _connected;
132
124
  constructor(plugins: ReadonlyArray<Wallet>);
@@ -162,7 +154,7 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
162
154
  * If all good, we connect the wallet by calling `this.connectWallet`
163
155
  * @param walletName. The wallet name we want to connect.
164
156
  */
165
- connect(walletName: WalletName): Promise<void | string>;
157
+ connect(walletName: string): Promise<void | string>;
166
158
  /**
167
159
  * Connects a wallet to the dapp.
168
160
  * On connect success, we set the current account and the network, and keeping the selected wallet
@@ -181,50 +173,35 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
181
173
  */
182
174
  disconnect(): Promise<void>;
183
175
  /**
184
- Sign and submit an entry (not bcs serialized) transaction type to chain.
185
- @param transaction a non-bcs serialized transaction
186
- @param options max_gas_amount and gas_unit_limit
187
- @return response from the wallet's signAndSubmitTransaction function
188
- @throws WalletSignAndSubmitMessageError
189
- */
190
- signAndSubmitTransaction(transaction: Types.TransactionPayload, options?: TransactionOptions): Promise<any>;
191
- /**
192
- Sign and submit a bsc serialized transaction type to chain.
193
- @param transaction a bcs serialized transaction
194
- @param options max_gas_amount and gas_unit_limit
195
- @return response from the wallet's signAndSubmitBCSTransaction function
196
- @throws WalletSignAndSubmitMessageError
176
+ * Signs and submits a transaction to chain
177
+ *
178
+ * @param transactionInput InputGenerateTransactionData
179
+ * @param options optional. A configuration object to generate a transaction by
180
+ * @returns The pending transaction hash (V1 output) | PendingTransactionResponse (V2 output)
197
181
  */
198
- signAndSubmitBCSTransaction(transaction: TxnBuilderTypes.TransactionPayload, options?: TransactionOptions): Promise<any>;
182
+ signAndSubmitTransaction(transactionInput: InputGenerateTransactionData, options?: InputGenerateTransactionOptions): Promise<{
183
+ hash: Types.HexEncodedBytes;
184
+ output?: any;
185
+ } | PendingTransactionResponse>;
199
186
  /**
200
- Sign transaction (doesnt submit to chain).
201
- @param transaction
202
- @param options max_gas_amount and gas_unit_limit
203
- @return response from the wallet's signTransaction function
204
- @throws WalletSignTransactionError
187
+ * Signs a transaction
188
+ *
189
+ * To support both existing wallet adapter V1 and V2, we support 2 input types
190
+ *
191
+ * @param transactionOrPayload AnyRawTransaction - V2 input | Types.TransactionPayload - V1 input
192
+ * @param options optional. V1 input
193
+ *
194
+ * @returns AccountAuthenticator
205
195
  */
206
- signTransaction(transaction: Types.TransactionPayload, options?: TransactionOptions): Promise<Uint8Array | null>;
196
+ signTransaction(transactionOrPayload: AnyRawTransaction | Types.TransactionPayload, asFeePayer?: boolean, options?: InputGenerateTransactionOptions): Promise<AccountAuthenticator>;
207
197
  /**
208
198
  Sign message (doesnt submit to chain).
209
199
  @param message
210
200
  @return response from the wallet's signMessage function
211
201
  @throws WalletSignMessageError
212
202
  */
213
- signMessage(message: SignMessagePayload): Promise<SignMessageResponse | null>;
214
- /**
215
- * This function is for signing and submitting a transaction using the `@aptos-labs/ts-sdk` (aka the v2 SDK)
216
- * input types. It's internally converting the input types to the old SDK input types and then calling
217
- * the v1 SDK's `signAndSubmitBCSTransaction` with it.
218
- *
219
- * @param transactionInput the transaction input
220
- * @param options max_gas_amount and gas_unit_limit
221
- * @returns the response from the wallet's signAndSubmitBCSTransaction function
222
- */
223
- submitTransaction(transactionInput: InputGenerateTransactionData, options?: TransactionOptions): Promise<{
224
- hash: string;
225
- output?: any;
226
- }>;
227
- signMultiAgentTransaction(transaction: TxnBuilderTypes.MultiAgentRawTransaction | TxnBuilderTypes.FeePayerRawTransaction): Promise<string | null>;
203
+ signMessage(message: SignMessagePayload): Promise<SignMessageResponse>;
204
+ submitTransaction(transaction: InputSubmitTransactionData): Promise<PendingTransactionResponse>;
228
205
  /**
229
206
  Event for when account has changed on the wallet
230
207
  @return the new account info
@@ -237,6 +214,11 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
237
214
  @throws WalletNetworkChangeError
238
215
  */
239
216
  onNetworkChange(): Promise<void>;
217
+ /**
218
+ * Signs a message and verifies the signer
219
+ * @param message SignMessagePayload
220
+ * @returns boolean
221
+ */
240
222
  signMessageAndVerify(message: SignMessagePayload): Promise<boolean>;
241
223
  }
242
224
 
@@ -249,5 +231,6 @@ declare function getLocalStorage(): void;
249
231
  declare function isMobile(): boolean;
250
232
  declare function isInAppBrowser(): boolean;
251
233
  declare function isRedirectable(): boolean;
234
+ declare function generalizedErrorMessage(error: any): string;
252
235
 
253
- export { AccountInfo, AdapterPlugin, AdapterPluginEvents, AdapterPluginProps, AptosWalletErrorResult, NetworkInfo, NetworkName, OnNetworkChange, PluginProvider, SignMessagePayload, SignMessageResponse, TransactionOptions, Wallet, WalletCore, WalletCoreEvents, WalletInfo, WalletName, WalletReadyState, getLocalStorage, isInAppBrowser, isMobile, isRedirectable, removeLocalStorage, scopePollingDetectionStrategy, setLocalStorage };
236
+ export { AccountInfo, AdapterPlugin, AdapterPluginEvents, AdapterPluginProps, AptosWalletErrorResult, NetworkInfo, NetworkName, OnAccountChange, OnNetworkChange, SignMessagePayload, SignMessageResponse, TransactionOptions, Wallet, WalletCore, WalletCoreEvents, WalletInfo, WalletName, WalletReadyState, generalizedErrorMessage, getLocalStorage, isInAppBrowser, isMobile, isRedirectable, removeLocalStorage, scopePollingDetectionStrategy, setLocalStorage };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __export(src_exports, {
31
31
  Types: () => import_aptos3.Types,
32
32
  WalletCore: () => WalletCore,
33
33
  WalletReadyState: () => WalletReadyState,
34
+ generalizedErrorMessage: () => generalizedErrorMessage,
34
35
  getLocalStorage: () => getLocalStorage,
35
36
  isInAppBrowser: () => isInAppBrowser,
36
37
  isMobile: () => isMobile,
@@ -44,7 +45,7 @@ module.exports = __toCommonJS(src_exports);
44
45
  // src/WalletCore.ts
45
46
  var import_aptos2 = require("aptos");
46
47
  var import_ts_sdk2 = require("@aptos-labs/ts-sdk");
47
- var import_eventemitter3 = __toESM(require("eventemitter3"));
48
+ var import_eventemitter32 = __toESM(require("eventemitter3"));
48
49
  var import_tweetnacl = __toESM(require("tweetnacl"));
49
50
  var import_buffer = require("buffer");
50
51
 
@@ -217,6 +218,9 @@ function isRedirectable() {
217
218
  return false;
218
219
  return isMobile() && !isInAppBrowser();
219
220
  }
221
+ function generalizedErrorMessage(error) {
222
+ return typeof error === "object" && "message" in error ? error.message : error;
223
+ }
220
224
 
221
225
  // src/ans.ts
222
226
  var ChainIdToAnsContractAddressMap = {
@@ -253,19 +257,83 @@ function convertNetwork(networkInfo) {
253
257
  throw new Error("Invalid network name");
254
258
  }
255
259
  }
256
- function convertToBCSPayload(payload) {
260
+ function convertV2TransactionPayloadToV1BCSPayload(payload) {
257
261
  const deserializer = new import_aptos.BCS.Deserializer(payload.bcsToBytes());
258
262
  return import_aptos.TxnBuilderTypes.TransactionPayload.deserialize(deserializer);
259
263
  }
264
+ function convertV2PayloadToV1JSONPayload(payload) {
265
+ var _a;
266
+ if ("bytecode" in payload) {
267
+ throw new Error("script payload not supported");
268
+ } else {
269
+ const stringTypeTags = (_a = payload.typeArguments) == null ? void 0 : _a.map(
270
+ (typeTag) => {
271
+ if (typeTag instanceof import_ts_sdk.TypeTag) {
272
+ return typeTag.toString();
273
+ }
274
+ return typeTag;
275
+ }
276
+ );
277
+ const newPayload = {
278
+ type: "entry_function_payload",
279
+ function: payload.function,
280
+ type_arguments: stringTypeTags || [],
281
+ arguments: payload.functionArguments
282
+ };
283
+ return newPayload;
284
+ }
285
+ }
286
+
287
+ // src/WalletCoreV1.ts
288
+ var import_eventemitter3 = __toESM(require("eventemitter3"));
289
+ var WalletCoreV1 = class extends import_eventemitter3.default {
290
+ async signAndSubmitTransaction(transaction, wallet, options) {
291
+ try {
292
+ const response = await wallet.signAndSubmitTransaction(
293
+ transaction,
294
+ options
295
+ );
296
+ return response;
297
+ } catch (error) {
298
+ const errMsg = typeof error == "object" && "message" in error ? error.message : error;
299
+ throw new WalletSignAndSubmitMessageError(errMsg).message;
300
+ }
301
+ }
302
+ async signAndSubmitBCSTransaction(transaction, wallet, options) {
303
+ try {
304
+ const response = await wallet.signAndSubmitBCSTransaction(
305
+ transaction,
306
+ options
307
+ );
308
+ return response;
309
+ } catch (error) {
310
+ const errMsg = typeof error == "object" && "message" in error ? error.message : error;
311
+ throw new WalletSignAndSubmitMessageError(errMsg).message;
312
+ }
313
+ }
314
+ async signTransaction(transaction, wallet, options) {
315
+ try {
316
+ const response = await wallet.signTransaction(
317
+ transaction,
318
+ options
319
+ );
320
+ return response;
321
+ } catch (error) {
322
+ const errMsg = typeof error == "object" && "message" in error ? error.message : error;
323
+ throw new WalletSignTransactionError(errMsg).message;
324
+ }
325
+ }
326
+ };
260
327
 
261
328
  // src/WalletCore.ts
262
- var WalletCore = class extends import_eventemitter3.default {
329
+ var WalletCore = class extends import_eventemitter32.default {
263
330
  constructor(plugins) {
264
331
  super();
265
332
  this._wallets = [];
266
333
  this._wallet = null;
267
334
  this._account = null;
268
335
  this._network = null;
336
+ this.waletCoreV1 = new WalletCoreV1();
269
337
  this._connecting = false;
270
338
  this._connected = false;
271
339
  this._wallets = plugins;
@@ -396,7 +464,7 @@ var WalletCore = class extends import_eventemitter3.default {
396
464
  this.emit("connect", account);
397
465
  } catch (error) {
398
466
  this.clearData();
399
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
467
+ const errMsg = generalizedErrorMessage(error);
400
468
  throw new WalletConnectionError(errMsg).message;
401
469
  } finally {
402
470
  this._connecting = false;
@@ -410,99 +478,130 @@ var WalletCore = class extends import_eventemitter3.default {
410
478
  this.clearData();
411
479
  this.emit("disconnect");
412
480
  } catch (error) {
413
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
481
+ const errMsg = generalizedErrorMessage(error);
414
482
  throw new WalletDisconnectionError(errMsg).message;
415
483
  }
416
484
  }
417
- async signAndSubmitTransaction(transaction, options) {
485
+ async signAndSubmitTransaction(transactionInput, options) {
418
486
  var _a;
419
487
  try {
420
488
  this.doesWalletExist();
421
- const response = await ((_a = this._wallet) == null ? void 0 : _a.signAndSubmitTransaction(
422
- transaction,
423
- options
424
- ));
425
- return response;
426
- } catch (error) {
427
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
428
- throw new WalletSignAndSubmitMessageError(errMsg).message;
429
- }
430
- }
431
- async signAndSubmitBCSTransaction(transaction, options) {
432
- var _a;
433
- if (this._wallet && !("signAndSubmitBCSTransaction" in this._wallet)) {
434
- throw new WalletNotSupportedMethod(
435
- `Submit a BCS Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
436
- ).message;
437
- }
438
- try {
439
- this.doesWalletExist();
440
- const response = await this._wallet.signAndSubmitBCSTransaction(
441
- transaction,
442
- options
489
+ if (((_a = this._wallet) == null ? void 0 : _a.version) === "v2") {
490
+ const response2 = await this._wallet.signAndSubmitTransaction(
491
+ transactionInput,
492
+ options
493
+ );
494
+ return response2;
495
+ }
496
+ const payloadData = transactionInput.data;
497
+ if (typeof payloadData.functionArguments[0] === "object") {
498
+ const aptosConfig = new import_ts_sdk2.AptosConfig({
499
+ network: convertNetwork(this._network)
500
+ });
501
+ const newPayload = await (0, import_ts_sdk2.generateTransactionPayload)({
502
+ ...payloadData,
503
+ aptosConfig
504
+ });
505
+ const oldTransactionPayload2 = convertV2TransactionPayloadToV1BCSPayload(newPayload);
506
+ const response2 = await this.waletCoreV1.signAndSubmitBCSTransaction(
507
+ oldTransactionPayload2,
508
+ this._wallet,
509
+ {
510
+ max_gas_amount: (options == null ? void 0 : options.maxGasAmount) ? BigInt(options == null ? void 0 : options.maxGasAmount) : void 0,
511
+ gas_unit_price: (options == null ? void 0 : options.gasUnitPrice) ? BigInt(options == null ? void 0 : options.gasUnitPrice) : void 0
512
+ }
513
+ );
514
+ const { hash: hash2, ...output2 } = response2;
515
+ return { hash: hash2, output: output2 };
516
+ }
517
+ const oldTransactionPayload = convertV2PayloadToV1JSONPayload(payloadData);
518
+ const response = await this.waletCoreV1.signAndSubmitTransaction(
519
+ oldTransactionPayload,
520
+ this._wallet,
521
+ {
522
+ max_gas_amount: (options == null ? void 0 : options.maxGasAmount) ? BigInt(options == null ? void 0 : options.maxGasAmount) : void 0,
523
+ gas_unit_price: (options == null ? void 0 : options.gasUnitPrice) ? BigInt(options == null ? void 0 : options.gasUnitPrice) : void 0
524
+ }
443
525
  );
444
- return response;
526
+ const { hash, ...output } = response;
527
+ return { hash, output };
445
528
  } catch (error) {
446
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
529
+ const errMsg = generalizedErrorMessage(error);
447
530
  throw new WalletSignAndSubmitMessageError(errMsg).message;
448
531
  }
449
532
  }
450
- async signTransaction(transaction, options) {
451
- var _a;
452
- if (this._wallet && !("signTransaction" in this._wallet)) {
453
- throw new WalletNotSupportedMethod(
454
- `Sign Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
455
- ).message;
456
- }
533
+ async signTransaction(transactionOrPayload, asFeePayer, options) {
534
+ var _a, _b, _c;
457
535
  try {
458
536
  this.doesWalletExist();
459
- const response = await this._wallet.signTransaction(
460
- transaction,
461
- options
537
+ if ("rawTransaction" in transactionOrPayload) {
538
+ if (((_a = this._wallet) == null ? void 0 : _a.version) !== "v2") {
539
+ throw new WalletNotSupportedMethod(
540
+ `Sign Transaction V2 is not supported by ${(_b = this.wallet) == null ? void 0 : _b.name}`
541
+ ).message;
542
+ }
543
+ const accountAuthenticator2 = this._wallet.signTransaction(
544
+ transactionOrPayload,
545
+ asFeePayer
546
+ );
547
+ return accountAuthenticator2;
548
+ }
549
+ if (this._wallet && !("signTransaction" in this._wallet)) {
550
+ throw new WalletNotSupportedMethod(
551
+ `Sign Transaction is not supported by ${(_c = this.wallet) == null ? void 0 : _c.name}`
552
+ ).message;
553
+ }
554
+ const response = await this.waletCoreV1.signTransaction(
555
+ transactionOrPayload,
556
+ this._wallet,
557
+ {
558
+ max_gas_amount: (options == null ? void 0 : options.maxGasAmount) ? BigInt(options == null ? void 0 : options.maxGasAmount) : void 0,
559
+ gas_unit_price: (options == null ? void 0 : options.gasUnitPrice) ? BigInt(options == null ? void 0 : options.gasUnitPrice) : void 0
560
+ }
462
561
  );
463
- return response;
562
+ if (!response) {
563
+ throw new Error("error");
564
+ }
565
+ const deserializer1 = new import_aptos2.BCS.Deserializer(response);
566
+ const deserializedSignature = import_aptos2.TxnBuilderTypes.SignedTransaction.deserialize(deserializer1);
567
+ const transactionAuthenticator = deserializedSignature.authenticator;
568
+ const publicKey = transactionAuthenticator.public_key.value;
569
+ const signature = transactionAuthenticator.signature.value;
570
+ const accountAuthenticator = new import_ts_sdk2.AccountAuthenticatorEd25519(
571
+ new import_ts_sdk2.Ed25519PublicKey(publicKey),
572
+ new import_ts_sdk2.Ed25519Signature(signature)
573
+ );
574
+ return accountAuthenticator;
464
575
  } catch (error) {
465
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
576
+ const errMsg = generalizedErrorMessage(error);
466
577
  throw new WalletSignTransactionError(errMsg).message;
467
578
  }
468
579
  }
469
580
  async signMessage(message) {
470
- var _a;
471
581
  try {
472
582
  this.doesWalletExist();
473
- if (!this._wallet)
474
- return null;
475
- const response = await ((_a = this._wallet) == null ? void 0 : _a.signMessage(message));
583
+ const response = await this._wallet.signMessage(message);
476
584
  return response;
477
585
  } catch (error) {
478
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
586
+ const errMsg = generalizedErrorMessage(error);
479
587
  throw new WalletSignMessageError(errMsg).message;
480
588
  }
481
589
  }
482
- async submitTransaction(transactionInput, options) {
483
- const payloadData = transactionInput.data;
484
- const aptosConfig = new import_ts_sdk2.AptosConfig({ network: convertNetwork(this._network) });
485
- const newPayload = await (0, import_ts_sdk2.generateTransactionPayload)({ ...payloadData, aptosConfig });
486
- const oldTransactionPayload = convertToBCSPayload(newPayload);
487
- const response = await this.signAndSubmitBCSTransaction(oldTransactionPayload, options);
488
- const { hash, ...output } = response;
489
- return { hash, output };
490
- }
491
- async signMultiAgentTransaction(transaction) {
590
+ async submitTransaction(transaction) {
492
591
  var _a;
493
- if (this._wallet && !("signMultiAgentTransaction" in this._wallet)) {
592
+ if (this._wallet && !("submitTransaction" in this._wallet)) {
494
593
  throw new WalletNotSupportedMethod(
495
- `Multi-agent & sponsored transactions are not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
594
+ `Submit Transaction is not supported by ${(_a = this.wallet) == null ? void 0 : _a.name}`
496
595
  ).message;
497
596
  }
498
597
  try {
499
598
  this.doesWalletExist();
500
- const response = await this._wallet.signMultiAgentTransaction(
599
+ const pendingTransaction = this._wallet.submitTransaction(
501
600
  transaction
502
601
  );
503
- return response;
602
+ return pendingTransaction;
504
603
  } catch (error) {
505
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
604
+ const errMsg = generalizedErrorMessage(error);
506
605
  throw new WalletSignTransactionError(errMsg).message;
507
606
  }
508
607
  }
@@ -516,7 +615,7 @@ var WalletCore = class extends import_eventemitter3.default {
516
615
  this.emit("accountChange", this._account);
517
616
  }));
518
617
  } catch (error) {
519
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
618
+ const errMsg = generalizedErrorMessage(error);
520
619
  throw new WalletAccountChangeError(errMsg).message;
521
620
  }
522
621
  }
@@ -530,7 +629,7 @@ var WalletCore = class extends import_eventemitter3.default {
530
629
  this.emit("networkChange", this._network);
531
630
  }));
532
631
  } catch (error) {
533
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
632
+ const errMsg = generalizedErrorMessage(error);
534
633
  throw new WalletNetworkChangeError(errMsg).message;
535
634
  }
536
635
  }
@@ -588,7 +687,7 @@ var WalletCore = class extends import_eventemitter3.default {
588
687
  }
589
688
  return verified;
590
689
  } catch (error) {
591
- const errMsg = typeof error == "object" && "message" in error ? error.message : error;
690
+ const errMsg = generalizedErrorMessage(error);
592
691
  throw new WalletSignMessageAndVerifyError(errMsg).message;
593
692
  }
594
693
  }
@@ -603,6 +702,7 @@ var import_aptos3 = require("aptos");
603
702
  Types,
604
703
  WalletCore,
605
704
  WalletReadyState,
705
+ generalizedErrorMessage,
606
706
  getLocalStorage,
607
707
  isInAppBrowser,
608
708
  isMobile,