@aptos-labs/ts-sdk 1.0.0 → 1.1.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/README.md +3 -3
- package/dist/browser/index.d.ts +513 -214
- package/dist/browser/index.global.js +25 -25
- package/dist/browser/index.global.js.map +1 -1
- package/dist/common/index.d.ts +513 -214
- package/dist/common/index.js +26 -26
- package/dist/common/index.js.map +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +9 -9
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +4 -11
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.d.mts +3 -3
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +300 -76
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +3 -3
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +0 -2
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +118 -13
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +25 -4
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.d.mts +4 -0
- package/dist/esm/api/transactionSubmission/helpers.mjs +2 -0
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +23 -2
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +21 -2
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-ZKFDLJ2F.mjs → chunk-2HBIGMDV.mjs} +2 -2
- package/dist/esm/{chunk-MNFGMNYS.mjs → chunk-3O4GKLXA.mjs} +2 -2
- package/dist/esm/chunk-3O4GKLXA.mjs.map +1 -0
- package/dist/esm/{chunk-GMOHGD73.mjs → chunk-4TIQQKXV.mjs} +2 -2
- package/dist/esm/{chunk-DBJTMCAG.mjs → chunk-4VG7DV6F.mjs} +2 -2
- package/dist/esm/{chunk-XKINEFAA.mjs → chunk-4ZYW3BPF.mjs} +2 -2
- package/dist/esm/chunk-4ZYW3BPF.mjs.map +1 -0
- package/dist/esm/chunk-6EMN3BOV.mjs +2 -0
- package/dist/esm/chunk-6EMN3BOV.mjs.map +1 -0
- package/dist/esm/chunk-6MKBROIC.mjs +2 -0
- package/dist/esm/chunk-6MKBROIC.mjs.map +1 -0
- package/dist/esm/{chunk-DYJVDOBH.mjs → chunk-AS7RX4RK.mjs} +2 -2
- package/dist/esm/chunk-AS7RX4RK.mjs.map +1 -0
- package/dist/esm/{chunk-X7QBDRQR.mjs → chunk-BUM2FIHF.mjs} +2 -2
- package/dist/esm/chunk-BV6SCEXY.mjs +2 -0
- package/dist/esm/chunk-BV6SCEXY.mjs.map +1 -0
- package/dist/esm/{chunk-CBAVJ5EN.mjs → chunk-D2XLC3KK.mjs} +2 -2
- package/dist/esm/chunk-EMQWD6KP.mjs +2 -0
- package/dist/esm/chunk-EMQWD6KP.mjs.map +1 -0
- package/dist/esm/chunk-HDNJ4JK4.mjs +2 -0
- package/dist/esm/chunk-HDNJ4JK4.mjs.map +1 -0
- package/dist/esm/{chunk-BA4TDBYB.mjs → chunk-IEL6J6Z3.mjs} +2 -2
- package/dist/esm/{chunk-Q3R3KKKP.mjs → chunk-IPW2YTRD.mjs} +2 -2
- package/dist/esm/{chunk-BDTDWLGO.mjs → chunk-KH3M3YPI.mjs} +2 -2
- package/dist/esm/chunk-KSWQZKMQ.mjs +2 -0
- package/dist/esm/chunk-KSWQZKMQ.mjs.map +1 -0
- package/dist/esm/{chunk-ELWWME6B.mjs → chunk-LUCDRB52.mjs} +2 -2
- package/dist/esm/chunk-LUCDRB52.mjs.map +1 -0
- package/dist/esm/chunk-NZ6RYGJQ.mjs +2 -0
- package/dist/esm/chunk-NZ6RYGJQ.mjs.map +1 -0
- package/dist/esm/chunk-OU4MEM5F.mjs +2 -0
- package/dist/esm/chunk-OU4MEM5F.mjs.map +1 -0
- package/dist/esm/{chunk-PLY7MQKE.mjs → chunk-PJMRQLJ5.mjs} +2 -2
- package/dist/esm/chunk-PJMRQLJ5.mjs.map +1 -0
- package/dist/esm/{chunk-Y5RQOXZH.mjs → chunk-R3SAAJ2N.mjs} +2 -2
- package/dist/esm/{chunk-32A35CPU.mjs → chunk-R4APGSSC.mjs} +2 -2
- package/dist/esm/chunk-SI6QMT4N.mjs +2 -0
- package/dist/esm/chunk-SI6QMT4N.mjs.map +1 -0
- package/dist/esm/{chunk-PZ5JKQSP.mjs → chunk-SMN2QQ4Q.mjs} +1 -1
- package/dist/esm/chunk-SMN2QQ4Q.mjs.map +1 -0
- package/dist/esm/chunk-SODP7NAK.mjs +2 -0
- package/dist/esm/{chunk-W4JEP5GW.mjs.map → chunk-SODP7NAK.mjs.map} +1 -1
- package/dist/esm/{chunk-5IVRKK5V.mjs → chunk-SR7XLV76.mjs} +2 -2
- package/dist/esm/{chunk-LBNMY7EM.mjs → chunk-T3ID6KFN.mjs} +2 -2
- package/dist/esm/{chunk-2AMFCGJ3.mjs → chunk-TCSN7PYL.mjs} +2 -2
- package/dist/esm/chunk-TCSN7PYL.mjs.map +1 -0
- package/dist/esm/chunk-TTDCRLRD.mjs +2 -0
- package/dist/esm/chunk-TTDCRLRD.mjs.map +1 -0
- package/dist/esm/{chunk-NFGAZSSK.mjs → chunk-UZB7CTLX.mjs} +2 -2
- package/dist/esm/chunk-VA4K6DEK.mjs +2 -0
- package/dist/esm/chunk-VA4K6DEK.mjs.map +1 -0
- package/dist/esm/{chunk-7IY2Y73Q.mjs → chunk-VBUKPN4Q.mjs} +2 -2
- package/dist/esm/chunk-VBUKPN4Q.mjs.map +1 -0
- package/dist/esm/{chunk-5SRMD5C6.mjs → chunk-YLI6J47P.mjs} +2 -2
- package/dist/esm/{chunk-4FDIPWVB.mjs → chunk-YLPG6XMH.mjs} +2 -2
- package/dist/esm/{chunk-KR5JAN32.mjs → chunk-ZLYSA7JR.mjs} +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account.d.mts +2 -2
- package/dist/esm/core/account.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/anyPublicKey.mjs +1 -1
- package/dist/esm/core/crypto/anySignature.mjs +1 -1
- package/dist/esm/core/crypto/asymmetricCrypto.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +1 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +5 -5
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +2 -2
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +144 -27
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +2 -2
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +6 -6
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +3 -3
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +4 -2
- package/src/api/ans.ts +9 -9
- package/src/api/aptos.ts +3 -28
- package/src/api/coin.ts +3 -3
- package/src/api/digitalAsset.ts +368 -94
- package/src/api/fungibleAsset.ts +3 -3
- package/src/api/transaction.ts +172 -2
- package/src/api/transactionSubmission/build.ts +25 -4
- package/src/api/transactionSubmission/helpers.ts +31 -0
- package/src/api/transactionSubmission/simulate.ts +26 -20
- package/src/api/transactionSubmission/submit.ts +24 -20
- package/src/client/core.ts +1 -1
- package/src/core/account.ts +2 -2
- package/src/internal/ans.ts +5 -5
- package/src/internal/coin.ts +2 -2
- package/src/internal/digitalAsset.ts +461 -61
- package/src/internal/fungibleAsset.ts +2 -2
- package/src/internal/transactionSubmission.ts +6 -6
- package/src/transactions/management/transactionWorker.ts +2 -9
- package/src/transactions/transactionBuilder/transactionBuilder.ts +2 -4
- package/src/transactions/types.ts +2 -2
- package/src/version.ts +1 -1
- package/dist/esm/api/transactionSubmission.d.mts +0 -113
- package/dist/esm/api/transactionSubmission.mjs +0 -2
- package/dist/esm/chunk-26GRNGPL.mjs +0 -2
- package/dist/esm/chunk-26GRNGPL.mjs.map +0 -1
- package/dist/esm/chunk-2AMFCGJ3.mjs.map +0 -1
- package/dist/esm/chunk-2X3FRUKX.mjs +0 -2
- package/dist/esm/chunk-2X3FRUKX.mjs.map +0 -1
- package/dist/esm/chunk-4XQ5IV6C.mjs +0 -2
- package/dist/esm/chunk-4XQ5IV6C.mjs.map +0 -1
- package/dist/esm/chunk-5X46HDCI.mjs +0 -2
- package/dist/esm/chunk-5X46HDCI.mjs.map +0 -1
- package/dist/esm/chunk-7IY2Y73Q.mjs.map +0 -1
- package/dist/esm/chunk-DYJVDOBH.mjs.map +0 -1
- package/dist/esm/chunk-ELWWME6B.mjs.map +0 -1
- package/dist/esm/chunk-MNFGMNYS.mjs.map +0 -1
- package/dist/esm/chunk-NBSXZKMQ.mjs +0 -2
- package/dist/esm/chunk-NBSXZKMQ.mjs.map +0 -1
- package/dist/esm/chunk-NZ36UN4C.mjs +0 -2
- package/dist/esm/chunk-NZ36UN4C.mjs.map +0 -1
- package/dist/esm/chunk-PEBXSNMJ.mjs +0 -2
- package/dist/esm/chunk-PEBXSNMJ.mjs.map +0 -1
- package/dist/esm/chunk-PLY7MQKE.mjs.map +0 -1
- package/dist/esm/chunk-PZ5JKQSP.mjs.map +0 -1
- package/dist/esm/chunk-TNUGIBLO.mjs +0 -2
- package/dist/esm/chunk-TNUGIBLO.mjs.map +0 -1
- package/dist/esm/chunk-TTICPGX6.mjs +0 -2
- package/dist/esm/chunk-TTICPGX6.mjs.map +0 -1
- package/dist/esm/chunk-UES76WF2.mjs +0 -2
- package/dist/esm/chunk-UES76WF2.mjs.map +0 -1
- package/dist/esm/chunk-W44E6YAW.mjs +0 -2
- package/dist/esm/chunk-W44E6YAW.mjs.map +0 -1
- package/dist/esm/chunk-W4JEP5GW.mjs +0 -2
- package/dist/esm/chunk-WXISFVRU.mjs +0 -2
- package/dist/esm/chunk-WXISFVRU.mjs.map +0 -1
- package/dist/esm/chunk-XKINEFAA.mjs.map +0 -1
- package/src/api/transactionSubmission.ts +0 -121
- /package/dist/esm/api/{transactionSubmission.mjs.map → transactionSubmission/helpers.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZKFDLJ2F.mjs.map → chunk-2HBIGMDV.mjs.map} +0 -0
- /package/dist/esm/{chunk-GMOHGD73.mjs.map → chunk-4TIQQKXV.mjs.map} +0 -0
- /package/dist/esm/{chunk-DBJTMCAG.mjs.map → chunk-4VG7DV6F.mjs.map} +0 -0
- /package/dist/esm/{chunk-X7QBDRQR.mjs.map → chunk-BUM2FIHF.mjs.map} +0 -0
- /package/dist/esm/{chunk-CBAVJ5EN.mjs.map → chunk-D2XLC3KK.mjs.map} +0 -0
- /package/dist/esm/{chunk-BA4TDBYB.mjs.map → chunk-IEL6J6Z3.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q3R3KKKP.mjs.map → chunk-IPW2YTRD.mjs.map} +0 -0
- /package/dist/esm/{chunk-BDTDWLGO.mjs.map → chunk-KH3M3YPI.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y5RQOXZH.mjs.map → chunk-R3SAAJ2N.mjs.map} +0 -0
- /package/dist/esm/{chunk-32A35CPU.mjs.map → chunk-R4APGSSC.mjs.map} +0 -0
- /package/dist/esm/{chunk-5IVRKK5V.mjs.map → chunk-SR7XLV76.mjs.map} +0 -0
- /package/dist/esm/{chunk-LBNMY7EM.mjs.map → chunk-T3ID6KFN.mjs.map} +0 -0
- /package/dist/esm/{chunk-NFGAZSSK.mjs.map → chunk-UZB7CTLX.mjs.map} +0 -0
- /package/dist/esm/{chunk-5SRMD5C6.mjs.map → chunk-YLI6J47P.mjs.map} +0 -0
- /package/dist/esm/{chunk-4FDIPWVB.mjs.map → chunk-YLPG6XMH.mjs.map} +0 -0
- /package/dist/esm/{chunk-KR5JAN32.mjs.map → chunk-ZLYSA7JR.mjs.map} +0 -0
package/src/api/transaction.ts
CHANGED
|
@@ -16,17 +16,44 @@ import {
|
|
|
16
16
|
GasEstimation,
|
|
17
17
|
HexInput,
|
|
18
18
|
PaginationArgs,
|
|
19
|
+
PendingTransactionResponse,
|
|
19
20
|
TransactionResponse,
|
|
20
21
|
WaitForTransactionOptions,
|
|
21
22
|
} from "../types";
|
|
22
|
-
import {
|
|
23
|
-
|
|
23
|
+
import {
|
|
24
|
+
getSigningMessage,
|
|
25
|
+
publicPackageTransaction,
|
|
26
|
+
rotateAuthKey,
|
|
27
|
+
signAndSubmitTransaction,
|
|
28
|
+
signTransaction,
|
|
29
|
+
} from "../internal/transactionSubmission";
|
|
30
|
+
import {
|
|
31
|
+
AccountAuthenticator,
|
|
32
|
+
AnyRawTransaction,
|
|
33
|
+
InputGenerateTransactionOptions,
|
|
34
|
+
InputGenerateTransactionPayloadData,
|
|
35
|
+
SimpleTransaction,
|
|
36
|
+
} from "../transactions";
|
|
37
|
+
import { AccountAddressInput, Account, PrivateKey } from "../core";
|
|
38
|
+
import { TransactionWorker } from "../transactions/management";
|
|
39
|
+
import { Build } from "./transactionSubmission/build";
|
|
40
|
+
import { Simulate } from "./transactionSubmission/simulate";
|
|
41
|
+
import { Submit } from "./transactionSubmission/submit";
|
|
24
42
|
|
|
25
43
|
export class Transaction {
|
|
26
44
|
readonly config: AptosConfig;
|
|
27
45
|
|
|
46
|
+
readonly build: Build;
|
|
47
|
+
|
|
48
|
+
readonly simulate: Simulate;
|
|
49
|
+
|
|
50
|
+
readonly submit: Submit;
|
|
51
|
+
|
|
28
52
|
constructor(config: AptosConfig) {
|
|
29
53
|
this.config = config;
|
|
54
|
+
this.build = new Build(this.config);
|
|
55
|
+
this.simulate = new Simulate(this.config);
|
|
56
|
+
this.submit = new Submit(this.config);
|
|
30
57
|
}
|
|
31
58
|
|
|
32
59
|
/**
|
|
@@ -154,4 +181,147 @@ export class Transaction {
|
|
|
154
181
|
getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {
|
|
155
182
|
return getSigningMessage(args);
|
|
156
183
|
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Generates a transaction to publish a move package to chain.
|
|
187
|
+
*
|
|
188
|
+
* To get the `metadataBytes` and `byteCode`, can compile using Aptos CLI with command
|
|
189
|
+
* `aptos move compile --save-metadata ...`,
|
|
190
|
+
* For more info {@link https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module}
|
|
191
|
+
*
|
|
192
|
+
* @param args.account The publisher account
|
|
193
|
+
* @param args.metadataBytes The package metadata bytes
|
|
194
|
+
* @param args.moduleBytecode An array of the bytecode of each module in the package in compiler output order
|
|
195
|
+
*
|
|
196
|
+
* @returns A SimpleTransaction that can be simulated or submitted to chain
|
|
197
|
+
*/
|
|
198
|
+
async publishPackageTransaction(args: {
|
|
199
|
+
account: AccountAddressInput;
|
|
200
|
+
metadataBytes: HexInput;
|
|
201
|
+
moduleBytecode: Array<HexInput>;
|
|
202
|
+
options?: InputGenerateTransactionOptions;
|
|
203
|
+
}): Promise<SimpleTransaction> {
|
|
204
|
+
return publicPackageTransaction({ aptosConfig: this.config, ...args });
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for
|
|
209
|
+
* the account.
|
|
210
|
+
* Note: Only legacy Ed25519 scheme is supported for now.
|
|
211
|
+
* More info: {@link https://aptos.dev/guides/account-management/key-rotation/}
|
|
212
|
+
* @param args.fromAccount The account to rotate the auth key for
|
|
213
|
+
* @param args.toNewPrivateKey The new private key to rotate to
|
|
214
|
+
*
|
|
215
|
+
* @returns PendingTransactionResponse
|
|
216
|
+
*/
|
|
217
|
+
async rotateAuthKey(args: { fromAccount: Account; toNewPrivateKey: PrivateKey }): Promise<TransactionResponse> {
|
|
218
|
+
return rotateAuthKey({ aptosConfig: this.config, ...args });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Sign a transaction that can later be submitted to chain
|
|
223
|
+
*
|
|
224
|
+
* @param args.signer The signer account
|
|
225
|
+
* @param args.transaction A raw transaction to sign on
|
|
226
|
+
*
|
|
227
|
+
* @returns AccountAuthenticator
|
|
228
|
+
*/
|
|
229
|
+
// eslint-disable-next-line class-methods-use-this
|
|
230
|
+
sign(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
|
|
231
|
+
return signTransaction({
|
|
232
|
+
...args,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Sign a transaction as a fee payer that can later be submitted to chain
|
|
238
|
+
*
|
|
239
|
+
* @param args.signer The fee payer signer account
|
|
240
|
+
* @param args.transaction A raw transaction to sign on
|
|
241
|
+
*
|
|
242
|
+
* @returns AccountAuthenticator
|
|
243
|
+
*/
|
|
244
|
+
// eslint-disable-next-line class-methods-use-this
|
|
245
|
+
signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
|
|
246
|
+
const { signer, transaction } = args;
|
|
247
|
+
|
|
248
|
+
// if transaction doesnt hold a "feePayerAddress" prop it means
|
|
249
|
+
// this is not a fee payer transaction
|
|
250
|
+
if (!transaction.feePayerAddress) {
|
|
251
|
+
throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Set the feePayerAddress to the signer account address
|
|
255
|
+
transaction.feePayerAddress = signer.accountAddress;
|
|
256
|
+
|
|
257
|
+
return signTransaction({
|
|
258
|
+
signer,
|
|
259
|
+
transaction,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// TRANSACTION SUBMISSION //
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Batch transactions for a single account.
|
|
267
|
+
*
|
|
268
|
+
* This function uses a transaction worker that receives payloads to be processed
|
|
269
|
+
* and submitted to chain.
|
|
270
|
+
* Note that this process is best for submitting multiple transactions that
|
|
271
|
+
* dont rely on each other, i.e batch funds, batch token mints, etc.
|
|
272
|
+
*
|
|
273
|
+
* If any worker failure, the functions throws an error.
|
|
274
|
+
*
|
|
275
|
+
* @param args.sender The sender account to sign and submit the transaction
|
|
276
|
+
* @param args.data An array of transaction payloads
|
|
277
|
+
* @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)
|
|
278
|
+
*
|
|
279
|
+
* @return void. Throws if any error
|
|
280
|
+
*/
|
|
281
|
+
async batchTransactionsForSingleAccount(args: {
|
|
282
|
+
sender: Account;
|
|
283
|
+
data: InputGenerateTransactionPayloadData[];
|
|
284
|
+
options?: Omit<InputGenerateTransactionOptions, "accountSequenceNumber">;
|
|
285
|
+
}): Promise<void> {
|
|
286
|
+
try {
|
|
287
|
+
const { sender, data, options } = args;
|
|
288
|
+
const transactionWorker = new TransactionWorker(this.config, sender);
|
|
289
|
+
|
|
290
|
+
transactionWorker.start();
|
|
291
|
+
|
|
292
|
+
for (const d of data) {
|
|
293
|
+
/* eslint-disable no-await-in-loop */
|
|
294
|
+
await transactionWorker.push(d, options);
|
|
295
|
+
}
|
|
296
|
+
} catch (error: any) {
|
|
297
|
+
throw new Error(`failed to submit transactions with error: ${error}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Sign and submit a single signer transaction to chain
|
|
303
|
+
*
|
|
304
|
+
* @param args.signer The signer account to sign the transaction
|
|
305
|
+
* @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
|
|
306
|
+
* ```
|
|
307
|
+
* {
|
|
308
|
+
* rawTransaction: RawTransaction,
|
|
309
|
+
* secondarySignerAddresses? : Array<AccountAddress>,
|
|
310
|
+
* feePayerAddress?: AccountAddress
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @return PendingTransactionResponse
|
|
315
|
+
*/
|
|
316
|
+
async signAndSubmitTransaction(args: {
|
|
317
|
+
signer: Account;
|
|
318
|
+
transaction: AnyRawTransaction;
|
|
319
|
+
}): Promise<PendingTransactionResponse> {
|
|
320
|
+
const { signer, transaction } = args;
|
|
321
|
+
return signAndSubmitTransaction({
|
|
322
|
+
aptosConfig: this.config,
|
|
323
|
+
signer,
|
|
324
|
+
transaction,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
157
327
|
}
|
|
@@ -6,7 +6,7 @@ import { generateTransaction } from "../../internal/transactionSubmission";
|
|
|
6
6
|
import {
|
|
7
7
|
InputGenerateTransactionPayloadData,
|
|
8
8
|
InputGenerateTransactionOptions,
|
|
9
|
-
|
|
9
|
+
SimpleTransaction,
|
|
10
10
|
MultiAgentTransaction,
|
|
11
11
|
} from "../../transactions";
|
|
12
12
|
import { AptosConfig } from "../aptosConfig";
|
|
@@ -21,16 +21,37 @@ export class Build {
|
|
|
21
21
|
this.config = config;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Build a simple transaction
|
|
26
|
+
*
|
|
27
|
+
* @param args.sender The sender account address
|
|
28
|
+
* @param args.data The transaction data
|
|
29
|
+
* @param args.options optional. Optional transaction configurations
|
|
30
|
+
* @param args.withFeePayer optional. Whether there is a fee payer for the transaction
|
|
31
|
+
*
|
|
32
|
+
* @returns SimpleTransaction
|
|
33
|
+
*/
|
|
34
|
+
async simple(args: {
|
|
25
35
|
sender: AccountAddressInput;
|
|
26
36
|
data: InputGenerateTransactionPayloadData;
|
|
27
37
|
options?: InputGenerateTransactionOptions;
|
|
28
38
|
withFeePayer?: boolean;
|
|
29
|
-
}): Promise<
|
|
39
|
+
}): Promise<SimpleTransaction> {
|
|
30
40
|
return generateTransaction({ aptosConfig: this.config, ...args });
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Build a multi agent transaction
|
|
45
|
+
*
|
|
46
|
+
* @param args.sender The sender account address
|
|
47
|
+
* @param args.data The transaction data
|
|
48
|
+
* @param args.secondarySignerAddresses An array of the secondary signers account addresses
|
|
49
|
+
* @param args.options optional. Optional transaction configurations
|
|
50
|
+
* @param args.withFeePayer optional. Whether there is a fee payer for the transaction
|
|
51
|
+
*
|
|
52
|
+
* @returns MultiAgentTransaction
|
|
53
|
+
*/
|
|
54
|
+
async multiAgent(args: {
|
|
34
55
|
sender: AccountAddressInput;
|
|
35
56
|
data: InputGenerateTransactionPayloadData;
|
|
36
57
|
secondarySignerAddresses: AccountAddressInput[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function ValidateFeePayerDataOnSubmission(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
2
|
+
const originalMethod = descriptor.value;
|
|
3
|
+
/* eslint-disable-next-line func-names, no-param-reassign */
|
|
4
|
+
descriptor.value = async function (...args: any[]) {
|
|
5
|
+
const [methodArgs] = args;
|
|
6
|
+
|
|
7
|
+
if (methodArgs.transaction.feePayerAddress && !methodArgs.feePayerAuthenticator) {
|
|
8
|
+
throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return originalMethod.apply(this, args);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return descriptor;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ValidateFeePayerDataOnSimulation(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
18
|
+
const originalMethod = descriptor.value;
|
|
19
|
+
/* eslint-disable-next-line func-names, no-param-reassign */
|
|
20
|
+
descriptor.value = async function (...args: any[]) {
|
|
21
|
+
const [methodArgs] = args;
|
|
22
|
+
|
|
23
|
+
if (methodArgs.transaction.feePayerAddress && !methodArgs.feePayerPublicKey) {
|
|
24
|
+
throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return originalMethod.apply(this, args);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return descriptor;
|
|
31
|
+
}
|
|
@@ -6,6 +6,7 @@ import { simulateTransaction } from "../../internal/transactionSubmission";
|
|
|
6
6
|
import { AnyRawTransaction, InputSimulateTransactionOptions } from "../../transactions";
|
|
7
7
|
import { UserTransactionResponse } from "../../types";
|
|
8
8
|
import { AptosConfig } from "../aptosConfig";
|
|
9
|
+
import { ValidateFeePayerDataOnSimulation } from "./helpers";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* A class to handle all `Simulate` transaction operations
|
|
@@ -17,8 +18,18 @@ export class Simulate {
|
|
|
17
18
|
this.config = config;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Simulate a simple transaction
|
|
23
|
+
*
|
|
24
|
+
* @param args.signerPublicKey The signer public key
|
|
25
|
+
* @param args.transaction An instance of a raw transaction
|
|
26
|
+
* @param args.options optional. Optional transaction configurations
|
|
27
|
+
* @param args.feePayerPublicKey optional. The fee payer public key if it is a fee payer transaction
|
|
28
|
+
*
|
|
29
|
+
* @returns Array<UserTransactionResponse>
|
|
30
|
+
*/
|
|
31
|
+
@ValidateFeePayerDataOnSimulation
|
|
32
|
+
async simple(args: {
|
|
22
33
|
signerPublicKey: PublicKey;
|
|
23
34
|
transaction: AnyRawTransaction;
|
|
24
35
|
feePayerPublicKey?: PublicKey;
|
|
@@ -27,8 +38,19 @@ export class Simulate {
|
|
|
27
38
|
return simulateTransaction({ aptosConfig: this.config, ...args });
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Simulate a multi agent transaction
|
|
43
|
+
*
|
|
44
|
+
* @param args.signerPublicKey The signer public key
|
|
45
|
+
* @param args.transaction An instance of a raw transaction
|
|
46
|
+
* @param args.secondarySignersPublicKeys An array of the secondary signers public keys
|
|
47
|
+
* @param args.options optional. Optional transaction configurations
|
|
48
|
+
* @param args.feePayerPublicKey optional. The fee payer public key if it is a fee payer transaction
|
|
49
|
+
*
|
|
50
|
+
* @returns Array<UserTransactionResponse>
|
|
51
|
+
*/
|
|
52
|
+
@ValidateFeePayerDataOnSimulation
|
|
53
|
+
async multiAgent(args: {
|
|
32
54
|
signerPublicKey: PublicKey;
|
|
33
55
|
transaction: AnyRawTransaction;
|
|
34
56
|
secondarySignersPublicKeys: Array<PublicKey>;
|
|
@@ -38,19 +60,3 @@ export class Simulate {
|
|
|
38
60
|
return simulateTransaction({ aptosConfig: this.config, ...args });
|
|
39
61
|
}
|
|
40
62
|
}
|
|
41
|
-
|
|
42
|
-
function ValidateFeePayerData(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
43
|
-
const originalMethod = descriptor.value;
|
|
44
|
-
/* eslint-disable-next-line func-names, no-param-reassign */
|
|
45
|
-
descriptor.value = async function (...args: any[]) {
|
|
46
|
-
const [methodArgs] = args;
|
|
47
|
-
|
|
48
|
-
if (methodArgs.transaction.feePayerAddress && !methodArgs.feePayerPublicKey) {
|
|
49
|
-
throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return originalMethod.apply(this, args);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return descriptor;
|
|
56
|
-
}
|
|
@@ -5,6 +5,7 @@ import { submitTransaction } from "../../internal/transactionSubmission";
|
|
|
5
5
|
import { AccountAuthenticator, AnyRawTransaction } from "../../transactions";
|
|
6
6
|
import { PendingTransactionResponse } from "../../types";
|
|
7
7
|
import { AptosConfig } from "../aptosConfig";
|
|
8
|
+
import { ValidateFeePayerDataOnSubmission } from "./helpers";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A class to handle all `Submit` transaction operations
|
|
@@ -16,8 +17,17 @@ export class Submit {
|
|
|
16
17
|
this.config = config;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Submit a simple transaction
|
|
22
|
+
*
|
|
23
|
+
* @param args.transaction An instance of a raw transaction
|
|
24
|
+
* @param args.senderAuthenticator optional. The sender account authenticator
|
|
25
|
+
* @param args.feePayerAuthenticator optional. The fee payer account authenticator if it is a fee payer transaction
|
|
26
|
+
*
|
|
27
|
+
* @returns PendingTransactionResponse
|
|
28
|
+
*/
|
|
29
|
+
@ValidateFeePayerDataOnSubmission
|
|
30
|
+
async simple(args: {
|
|
21
31
|
transaction: AnyRawTransaction;
|
|
22
32
|
senderAuthenticator: AccountAuthenticator;
|
|
23
33
|
feePayerAuthenticator?: AccountAuthenticator;
|
|
@@ -25,8 +35,18 @@ export class Submit {
|
|
|
25
35
|
return submitTransaction({ aptosConfig: this.config, ...args });
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Submit a multi agent transaction
|
|
40
|
+
*
|
|
41
|
+
* @param args.transaction An instance of a raw transaction
|
|
42
|
+
* @param args.senderAuthenticator optional. The sender account authenticator
|
|
43
|
+
* @param args.additionalSignersAuthenticators An array of the secondary signers account authenticators
|
|
44
|
+
* @param args.feePayerAuthenticator optional. The fee payer account authenticator if it is a fee payer transaction
|
|
45
|
+
*
|
|
46
|
+
* @returns PendingTransactionResponse
|
|
47
|
+
*/
|
|
48
|
+
@ValidateFeePayerDataOnSubmission
|
|
49
|
+
async multiAgent(args: {
|
|
30
50
|
transaction: AnyRawTransaction;
|
|
31
51
|
senderAuthenticator: AccountAuthenticator;
|
|
32
52
|
additionalSignersAuthenticators: Array<AccountAuthenticator>;
|
|
@@ -35,19 +55,3 @@ export class Submit {
|
|
|
35
55
|
return submitTransaction({ aptosConfig: this.config, ...args });
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
|
-
|
|
39
|
-
function ValidateFeePayerData(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
40
|
-
const originalMethod = descriptor.value;
|
|
41
|
-
/* eslint-disable-next-line func-names, no-param-reassign */
|
|
42
|
-
descriptor.value = async function (...args: any[]) {
|
|
43
|
-
const [methodArgs] = args;
|
|
44
|
-
|
|
45
|
-
if (methodArgs.transaction.feePayerAddress && !methodArgs.feePayerAuthenticator) {
|
|
46
|
-
throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return originalMethod.apply(this, args);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return descriptor;
|
|
53
|
-
}
|
package/src/client/core.ts
CHANGED
|
@@ -28,7 +28,7 @@ export async function request<Req, Res>(options: ClientRequest<Req>, client: Cli
|
|
|
28
28
|
const { url, method, body, contentType, params, overrides } = options;
|
|
29
29
|
const headers: Record<string, string | AnyNumber | boolean | undefined> = {
|
|
30
30
|
...overrides?.HEADERS,
|
|
31
|
-
"x-aptos-client": `aptos-
|
|
31
|
+
"x-aptos-client": `aptos-typescript-sdk/${VERSION}`,
|
|
32
32
|
"content-type": contentType ?? MimeType.JSON,
|
|
33
33
|
};
|
|
34
34
|
|
package/src/core/account.ts
CHANGED
|
@@ -64,8 +64,8 @@ export class Account {
|
|
|
64
64
|
*
|
|
65
65
|
* @param args.privateKey PrivateKey - private key of the account
|
|
66
66
|
* @param args.address AccountAddress - address of the account
|
|
67
|
-
* @param args.legacy optional. If set to
|
|
68
|
-
* Defaults to deriving an authentication key with
|
|
67
|
+
* @param args.legacy optional. If set to false, the keypair authentication keys will be derived with a unified scheme.
|
|
68
|
+
* Defaults to deriving an authentication key with the legacy scheme.
|
|
69
69
|
*
|
|
70
70
|
* This method is private because it should only be called by the factory static methods.
|
|
71
71
|
* @returns Account
|
package/src/internal/ans.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
12
|
import { Account, AccountAddress, AccountAddressInput } from "../core";
|
|
13
|
-
import { InputGenerateTransactionOptions,
|
|
13
|
+
import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions/types";
|
|
14
14
|
import { GetANSNameResponse, MoveAddressType, MoveValue, OrderByArg, PaginationArgs, WhereArg } from "../types";
|
|
15
15
|
import { GetNamesQuery } from "../types/generated/operations";
|
|
16
16
|
import { GetNames } from "../types/generated/queries";
|
|
@@ -130,7 +130,7 @@ export interface RegisterNameParameters {
|
|
|
130
130
|
options?: InputGenerateTransactionOptions;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export async function registerName(args: RegisterNameParameters): Promise<
|
|
133
|
+
export async function registerName(args: RegisterNameParameters): Promise<SimpleTransaction> {
|
|
134
134
|
const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options, transferable } = args;
|
|
135
135
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
136
136
|
const { domainName, subdomainName } = isValidANSName(name);
|
|
@@ -257,7 +257,7 @@ export async function setPrimaryName(args: {
|
|
|
257
257
|
sender: Account;
|
|
258
258
|
name?: string;
|
|
259
259
|
options?: InputGenerateTransactionOptions;
|
|
260
|
-
}): Promise<
|
|
260
|
+
}): Promise<SimpleTransaction> {
|
|
261
261
|
const { aptosConfig, sender, name, options } = args;
|
|
262
262
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
263
263
|
|
|
@@ -316,7 +316,7 @@ export async function setTargetAddress(args: {
|
|
|
316
316
|
name: string;
|
|
317
317
|
address: AccountAddressInput;
|
|
318
318
|
options?: InputGenerateTransactionOptions;
|
|
319
|
-
}): Promise<
|
|
319
|
+
}): Promise<SimpleTransaction> {
|
|
320
320
|
const { aptosConfig, sender, name, address, options } = args;
|
|
321
321
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
322
322
|
const { domainName, subdomainName } = isValidANSName(name);
|
|
@@ -533,7 +533,7 @@ export async function renewDomain(args: {
|
|
|
533
533
|
name: string;
|
|
534
534
|
years?: 1;
|
|
535
535
|
options?: InputGenerateTransactionOptions;
|
|
536
|
-
}): Promise<
|
|
536
|
+
}): Promise<SimpleTransaction> {
|
|
537
537
|
const { aptosConfig, sender, name, years = 1, options } = args;
|
|
538
538
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
539
539
|
const renewalDuration = years * 31536000;
|
package/src/internal/coin.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AptosConfig } from "../api/aptosConfig";
|
|
2
2
|
import { Account, AccountAddressInput } from "../core";
|
|
3
|
-
import { InputGenerateTransactionOptions,
|
|
3
|
+
import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions/types";
|
|
4
4
|
import { AnyNumber, MoveStructId } from "../types";
|
|
5
5
|
import { APTOS_COIN } from "../utils/const";
|
|
6
6
|
import { generateTransaction } from "./transactionSubmission";
|
|
@@ -12,7 +12,7 @@ export async function transferCoinTransaction(args: {
|
|
|
12
12
|
amount: AnyNumber;
|
|
13
13
|
coinType?: MoveStructId;
|
|
14
14
|
options?: InputGenerateTransactionOptions;
|
|
15
|
-
}): Promise<
|
|
15
|
+
}): Promise<SimpleTransaction> {
|
|
16
16
|
const { aptosConfig, sender, recipient, amount, coinType, options } = args;
|
|
17
17
|
const coinStructType = coinType ?? APTOS_COIN;
|
|
18
18
|
const transaction = await generateTransaction({
|