@aptos-labs/wallet-adapter-core 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +10 -10
- package/dist/index.mjs +10 -10
- package/package.json +3 -3
- package/src/WalletCore.ts +15 -16
- package/src/types.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @aptos-labs/wallet-adapter-core
|
|
2
2
|
|
|
3
|
+
## 3.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6266a29: Consolidate options argument on signAndSubmitTransaction
|
|
8
|
+
|
|
9
|
+
## 3.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 6257015: [deps] Updated aptos and @aptos-labs/ts-sdk dependencies to latest versions
|
|
14
|
+
- aa3d15a: Make sender optional when sign and submit single signer transaction
|
|
15
|
+
|
|
3
16
|
## 3.0.0
|
|
4
17
|
|
|
5
18
|
### Major Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types } from 'aptos';
|
|
2
2
|
export { TxnBuilderTypes, Types } from 'aptos';
|
|
3
|
-
import { Network, InputGenerateTransactionData, InputGenerateTransactionOptions, PendingTransactionResponse, InputSubmitTransactionData, AnyRawTransaction, AccountAuthenticator } from '@aptos-labs/ts-sdk';
|
|
3
|
+
import { Network, InputGenerateTransactionData, InputGenerateTransactionOptions, PendingTransactionResponse, InputSubmitTransactionData, AccountAddressInput, InputGenerateTransactionPayloadData, AnyRawTransaction, AccountAuthenticator } from '@aptos-labs/ts-sdk';
|
|
4
4
|
export { AccountAuthenticator, AnyRawTransaction, InputGenerateTransactionData, InputGenerateTransactionOptions, InputSubmitTransactionData, PendingTransactionResponse } from '@aptos-labs/ts-sdk';
|
|
5
5
|
import EventEmitter from 'eventemitter3';
|
|
6
6
|
|
|
@@ -112,6 +112,11 @@ interface TransactionOptions {
|
|
|
112
112
|
max_gas_amount?: bigint;
|
|
113
113
|
gas_unit_price?: bigint;
|
|
114
114
|
}
|
|
115
|
+
type InputTransactionData = {
|
|
116
|
+
sender?: AccountAddressInput;
|
|
117
|
+
data: InputGenerateTransactionPayloadData;
|
|
118
|
+
options?: InputGenerateTransactionOptions;
|
|
119
|
+
};
|
|
115
120
|
|
|
116
121
|
declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
117
122
|
private _wallets;
|
|
@@ -175,11 +180,11 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
175
180
|
/**
|
|
176
181
|
* Signs and submits a transaction to chain
|
|
177
182
|
*
|
|
178
|
-
* @param transactionInput
|
|
183
|
+
* @param transactionInput InputTransactionData
|
|
179
184
|
* @param options optional. A configuration object to generate a transaction by
|
|
180
185
|
* @returns The pending transaction hash (V1 output) | PendingTransactionResponse (V2 output)
|
|
181
186
|
*/
|
|
182
|
-
signAndSubmitTransaction(transactionInput:
|
|
187
|
+
signAndSubmitTransaction(transactionInput: InputTransactionData): Promise<{
|
|
183
188
|
hash: Types.HexEncodedBytes;
|
|
184
189
|
output?: any;
|
|
185
190
|
} | PendingTransactionResponse>;
|
|
@@ -233,4 +238,4 @@ declare function isInAppBrowser(): boolean;
|
|
|
233
238
|
declare function isRedirectable(): boolean;
|
|
234
239
|
declare function generalizedErrorMessage(error: any): string;
|
|
235
240
|
|
|
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 };
|
|
241
|
+
export { AccountInfo, AdapterPlugin, AdapterPluginEvents, AdapterPluginProps, AptosWalletErrorResult, InputTransactionData, 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
|
@@ -482,15 +482,15 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
482
482
|
throw new WalletDisconnectionError(errMsg).message;
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
async signAndSubmitTransaction(transactionInput
|
|
486
|
-
var _a;
|
|
485
|
+
async signAndSubmitTransaction(transactionInput) {
|
|
486
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
487
487
|
try {
|
|
488
488
|
this.doesWalletExist();
|
|
489
489
|
if (((_a = this._wallet) == null ? void 0 : _a.version) === "v2") {
|
|
490
|
-
const response2 = await this._wallet.signAndSubmitTransaction(
|
|
491
|
-
transactionInput,
|
|
492
|
-
|
|
493
|
-
);
|
|
490
|
+
const response2 = await this._wallet.signAndSubmitTransaction({
|
|
491
|
+
...transactionInput,
|
|
492
|
+
sender: (_b = transactionInput.sender) != null ? _b : this._account.address
|
|
493
|
+
});
|
|
494
494
|
return response2;
|
|
495
495
|
}
|
|
496
496
|
const payloadData = transactionInput.data;
|
|
@@ -507,8 +507,8 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
507
507
|
oldTransactionPayload2,
|
|
508
508
|
this._wallet,
|
|
509
509
|
{
|
|
510
|
-
max_gas_amount: (options == null ? void 0 :
|
|
511
|
-
gas_unit_price: (options == null ? void 0 :
|
|
510
|
+
max_gas_amount: ((_c = transactionInput.options) == null ? void 0 : _c.maxGasAmount) ? BigInt((_d = transactionInput.options) == null ? void 0 : _d.maxGasAmount) : void 0,
|
|
511
|
+
gas_unit_price: ((_e = transactionInput.options) == null ? void 0 : _e.gasUnitPrice) ? BigInt((_f = transactionInput.options) == null ? void 0 : _f.gasUnitPrice) : void 0
|
|
512
512
|
}
|
|
513
513
|
);
|
|
514
514
|
const { hash: hash2, ...output2 } = response2;
|
|
@@ -519,8 +519,8 @@ var WalletCore = class extends import_eventemitter32.default {
|
|
|
519
519
|
oldTransactionPayload,
|
|
520
520
|
this._wallet,
|
|
521
521
|
{
|
|
522
|
-
max_gas_amount: (options == null ? void 0 :
|
|
523
|
-
gas_unit_price: (options == null ? void 0 :
|
|
522
|
+
max_gas_amount: ((_g = transactionInput.options) == null ? void 0 : _g.maxGasAmount) ? BigInt((_h = transactionInput.options) == null ? void 0 : _h.maxGasAmount) : void 0,
|
|
523
|
+
gas_unit_price: ((_i = transactionInput.options) == null ? void 0 : _i.gasUnitPrice) ? BigInt((_j = transactionInput.options) == null ? void 0 : _j.gasUnitPrice) : void 0
|
|
524
524
|
}
|
|
525
525
|
);
|
|
526
526
|
const { hash, ...output } = response;
|
package/dist/index.mjs
CHANGED
|
@@ -447,15 +447,15 @@ var WalletCore = class extends EventEmitter2 {
|
|
|
447
447
|
throw new WalletDisconnectionError(errMsg).message;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
async signAndSubmitTransaction(transactionInput
|
|
451
|
-
var _a;
|
|
450
|
+
async signAndSubmitTransaction(transactionInput) {
|
|
451
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
452
452
|
try {
|
|
453
453
|
this.doesWalletExist();
|
|
454
454
|
if (((_a = this._wallet) == null ? void 0 : _a.version) === "v2") {
|
|
455
|
-
const response2 = await this._wallet.signAndSubmitTransaction(
|
|
456
|
-
transactionInput,
|
|
457
|
-
|
|
458
|
-
);
|
|
455
|
+
const response2 = await this._wallet.signAndSubmitTransaction({
|
|
456
|
+
...transactionInput,
|
|
457
|
+
sender: (_b = transactionInput.sender) != null ? _b : this._account.address
|
|
458
|
+
});
|
|
459
459
|
return response2;
|
|
460
460
|
}
|
|
461
461
|
const payloadData = transactionInput.data;
|
|
@@ -472,8 +472,8 @@ var WalletCore = class extends EventEmitter2 {
|
|
|
472
472
|
oldTransactionPayload2,
|
|
473
473
|
this._wallet,
|
|
474
474
|
{
|
|
475
|
-
max_gas_amount: (options == null ? void 0 :
|
|
476
|
-
gas_unit_price: (options == null ? void 0 :
|
|
475
|
+
max_gas_amount: ((_c = transactionInput.options) == null ? void 0 : _c.maxGasAmount) ? BigInt((_d = transactionInput.options) == null ? void 0 : _d.maxGasAmount) : void 0,
|
|
476
|
+
gas_unit_price: ((_e = transactionInput.options) == null ? void 0 : _e.gasUnitPrice) ? BigInt((_f = transactionInput.options) == null ? void 0 : _f.gasUnitPrice) : void 0
|
|
477
477
|
}
|
|
478
478
|
);
|
|
479
479
|
const { hash: hash2, ...output2 } = response2;
|
|
@@ -484,8 +484,8 @@ var WalletCore = class extends EventEmitter2 {
|
|
|
484
484
|
oldTransactionPayload,
|
|
485
485
|
this._wallet,
|
|
486
486
|
{
|
|
487
|
-
max_gas_amount: (options == null ? void 0 :
|
|
488
|
-
gas_unit_price: (options == null ? void 0 :
|
|
487
|
+
max_gas_amount: ((_g = transactionInput.options) == null ? void 0 : _g.maxGasAmount) ? BigInt((_h = transactionInput.options) == null ? void 0 : _h.maxGasAmount) : void 0,
|
|
488
|
+
gas_unit_price: ((_i = transactionInput.options) == null ? void 0 : _i.gasUnitPrice) ? BigInt((_j = transactionInput.options) == null ? void 0 : _j.gasUnitPrice) : void 0
|
|
489
489
|
}
|
|
490
490
|
);
|
|
491
491
|
const { hash, ...output } = response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Aptos Wallet Adapter Core",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"tweetnacl": "^1.0.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"aptos": "^1.
|
|
47
|
-
"@aptos-labs/ts-sdk": "^0.0
|
|
46
|
+
"aptos": "^1.20.0",
|
|
47
|
+
"@aptos-labs/ts-sdk": "^1.0.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/WalletCore.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HexString, TxnBuilderTypes, Types, BCS } from "aptos";
|
|
2
2
|
import {
|
|
3
|
-
InputGenerateTransactionData,
|
|
4
3
|
AnyRawTransaction,
|
|
5
4
|
AccountAuthenticator,
|
|
6
5
|
AccountAuthenticatorEd25519,
|
|
@@ -42,6 +41,7 @@ import {
|
|
|
42
41
|
WalletInfo,
|
|
43
42
|
WalletCoreEvents,
|
|
44
43
|
SignMessageResponse,
|
|
44
|
+
InputTransactionData,
|
|
45
45
|
} from "./types";
|
|
46
46
|
import {
|
|
47
47
|
removeLocalStorage,
|
|
@@ -285,13 +285,12 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
285
285
|
/**
|
|
286
286
|
* Signs and submits a transaction to chain
|
|
287
287
|
*
|
|
288
|
-
* @param transactionInput
|
|
288
|
+
* @param transactionInput InputTransactionData
|
|
289
289
|
* @param options optional. A configuration object to generate a transaction by
|
|
290
290
|
* @returns The pending transaction hash (V1 output) | PendingTransactionResponse (V2 output)
|
|
291
291
|
*/
|
|
292
292
|
async signAndSubmitTransaction(
|
|
293
|
-
transactionInput:
|
|
294
|
-
options?: InputGenerateTransactionOptions
|
|
293
|
+
transactionInput: InputTransactionData
|
|
295
294
|
): Promise<
|
|
296
295
|
{ hash: Types.HexEncodedBytes; output?: any } | PendingTransactionResponse
|
|
297
296
|
> {
|
|
@@ -300,10 +299,10 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
300
299
|
|
|
301
300
|
// wallet supports sdk v2
|
|
302
301
|
if (this._wallet?.version === "v2") {
|
|
303
|
-
const response = await this._wallet.signAndSubmitTransaction(
|
|
304
|
-
transactionInput,
|
|
305
|
-
|
|
306
|
-
);
|
|
302
|
+
const response = await this._wallet.signAndSubmitTransaction({
|
|
303
|
+
...transactionInput,
|
|
304
|
+
sender: transactionInput.sender ?? this._account!.address,
|
|
305
|
+
});
|
|
307
306
|
// response should be PendingTransactionResponse
|
|
308
307
|
return response;
|
|
309
308
|
}
|
|
@@ -327,11 +326,11 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
327
326
|
oldTransactionPayload,
|
|
328
327
|
this._wallet!,
|
|
329
328
|
{
|
|
330
|
-
max_gas_amount: options?.maxGasAmount
|
|
331
|
-
? BigInt(options?.maxGasAmount)
|
|
329
|
+
max_gas_amount: transactionInput.options?.maxGasAmount
|
|
330
|
+
? BigInt(transactionInput.options?.maxGasAmount)
|
|
332
331
|
: undefined,
|
|
333
|
-
gas_unit_price: options?.gasUnitPrice
|
|
334
|
-
? BigInt(options?.gasUnitPrice)
|
|
332
|
+
gas_unit_price: transactionInput.options?.gasUnitPrice
|
|
333
|
+
? BigInt(transactionInput.options?.gasUnitPrice)
|
|
335
334
|
: undefined,
|
|
336
335
|
}
|
|
337
336
|
);
|
|
@@ -347,11 +346,11 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
|
|
|
347
346
|
oldTransactionPayload,
|
|
348
347
|
this._wallet!,
|
|
349
348
|
{
|
|
350
|
-
max_gas_amount: options?.maxGasAmount
|
|
351
|
-
? BigInt(options?.maxGasAmount)
|
|
349
|
+
max_gas_amount: transactionInput.options?.maxGasAmount
|
|
350
|
+
? BigInt(transactionInput.options?.maxGasAmount)
|
|
352
351
|
: undefined,
|
|
353
|
-
gas_unit_price: options?.gasUnitPrice
|
|
354
|
-
? BigInt(options?.gasUnitPrice)
|
|
352
|
+
gas_unit_price: transactionInput.options?.gasUnitPrice
|
|
353
|
+
? BigInt(transactionInput.options?.gasUnitPrice)
|
|
355
354
|
: undefined,
|
|
356
355
|
}
|
|
357
356
|
);
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
InputGenerateTransactionOptions,
|
|
6
6
|
InputSubmitTransactionData,
|
|
7
7
|
PendingTransactionResponse,
|
|
8
|
+
AccountAddressInput,
|
|
9
|
+
InputGenerateTransactionPayloadData,
|
|
8
10
|
} from "@aptos-labs/ts-sdk";
|
|
9
11
|
import { WalletReadyState } from "./constants";
|
|
10
12
|
|
|
@@ -126,3 +128,9 @@ export interface TransactionOptions {
|
|
|
126
128
|
max_gas_amount?: bigint;
|
|
127
129
|
gas_unit_price?: bigint;
|
|
128
130
|
}
|
|
131
|
+
|
|
132
|
+
export type InputTransactionData = {
|
|
133
|
+
sender?: AccountAddressInput;
|
|
134
|
+
data: InputGenerateTransactionPayloadData;
|
|
135
|
+
options?: InputGenerateTransactionOptions;
|
|
136
|
+
};
|