@aptos-labs/ts-sdk 1.4.0 → 1.5.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.
Files changed (190) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/index.d.ts +306 -226
  3. package/dist/browser/index.global.js +30 -30
  4. package/dist/browser/index.global.js.map +1 -1
  5. package/dist/common/index.d.ts +306 -226
  6. package/dist/common/index.js +24 -24
  7. package/dist/common/index.js.map +1 -1
  8. package/dist/esm/api/account.mjs +1 -1
  9. package/dist/esm/api/ans.mjs +1 -1
  10. package/dist/esm/api/aptos.d.mts +6 -1
  11. package/dist/esm/api/aptos.mjs +1 -1
  12. package/dist/esm/api/coin.mjs +1 -1
  13. package/dist/esm/api/digitalAsset.mjs +1 -1
  14. package/dist/esm/api/event.mjs +1 -1
  15. package/dist/esm/api/faucet.mjs +1 -1
  16. package/dist/esm/api/fungibleAsset.mjs +1 -1
  17. package/dist/esm/api/general.mjs +1 -1
  18. package/dist/esm/api/index.d.mts +5 -0
  19. package/dist/esm/api/index.mjs +1 -1
  20. package/dist/esm/api/staking.mjs +1 -1
  21. package/dist/esm/api/transaction.d.mts +8 -0
  22. package/dist/esm/api/transaction.mjs +1 -1
  23. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  24. package/dist/esm/api/transactionSubmission/management.d.mts +89 -0
  25. package/dist/esm/api/transactionSubmission/management.mjs +2 -0
  26. package/dist/esm/api/transactionSubmission/management.mjs.map +1 -0
  27. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  28. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  29. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  30. package/dist/esm/api/utils.mjs +1 -1
  31. package/dist/esm/bcs/index.mjs +1 -1
  32. package/dist/esm/{chunk-KYI7YRRQ.mjs → chunk-25YXK6L2.mjs} +2 -2
  33. package/dist/esm/{chunk-Q7B4KMTR.mjs → chunk-2BSSYT6I.mjs} +2 -2
  34. package/dist/esm/chunk-2MOYURM2.mjs +2 -0
  35. package/dist/esm/chunk-2MOYURM2.mjs.map +1 -0
  36. package/dist/esm/{chunk-JHKU4VAL.mjs → chunk-2RN7N3EO.mjs} +2 -2
  37. package/dist/esm/{chunk-LGC5FYCC.mjs → chunk-3T4NSGK5.mjs} +2 -2
  38. package/dist/esm/{chunk-NWRKJFHV.mjs → chunk-4QWK47EH.mjs} +2 -2
  39. package/dist/esm/{chunk-RKWCYC3Y.mjs → chunk-4TGKQEEE.mjs} +2 -2
  40. package/dist/esm/{chunk-GGCQNE7J.mjs → chunk-6IMEQXW4.mjs} +2 -2
  41. package/dist/esm/{chunk-3PPUHF6D.mjs → chunk-6KILJ43F.mjs} +2 -2
  42. package/dist/esm/chunk-6XQ33PLM.mjs +2 -0
  43. package/dist/esm/chunk-6XQ33PLM.mjs.map +1 -0
  44. package/dist/esm/{chunk-SBMJNU2O.mjs → chunk-7WQA7OMS.mjs} +2 -2
  45. package/dist/esm/{chunk-3DM36HLF.mjs → chunk-ACMNL2LL.mjs} +2 -2
  46. package/dist/esm/{chunk-2QV6HI3M.mjs → chunk-APOQ4ODM.mjs} +2 -2
  47. package/dist/esm/{chunk-FXXTTZOI.mjs → chunk-ATHZ7INX.mjs} +2 -2
  48. package/dist/esm/{chunk-TN4RHL6A.mjs → chunk-BDHRLMQP.mjs} +2 -2
  49. package/dist/esm/{chunk-LLONKHWW.mjs → chunk-BQYQ45QQ.mjs} +2 -2
  50. package/dist/esm/{chunk-QQMEPYJ3.mjs → chunk-C53MNMPH.mjs} +2 -2
  51. package/dist/esm/{chunk-4RFWMHWT.mjs → chunk-CFQDJZBD.mjs} +2 -2
  52. package/dist/esm/{chunk-4DEYLX4E.mjs → chunk-DHFOORW6.mjs} +2 -2
  53. package/dist/esm/{chunk-BBJ3YXGC.mjs → chunk-DIWRS4YQ.mjs} +2 -2
  54. package/dist/esm/{chunk-CBMEWHLK.mjs → chunk-DSGIOUTJ.mjs} +2 -2
  55. package/dist/esm/{chunk-MJW4JGUR.mjs → chunk-ED2OMOMT.mjs} +2 -2
  56. package/dist/esm/{chunk-CHK4FLX4.mjs → chunk-FE2DRPX7.mjs} +2 -2
  57. package/dist/esm/{chunk-ERWQOVBF.mjs → chunk-FGHNLZRH.mjs} +2 -2
  58. package/dist/esm/{chunk-FW7B46XZ.mjs → chunk-FHUT4EJH.mjs} +2 -2
  59. package/dist/esm/{chunk-PXNW26UO.mjs → chunk-HT6K4NWZ.mjs} +2 -2
  60. package/dist/esm/{chunk-O74RSNEJ.mjs → chunk-HV4ZPHSZ.mjs} +2 -2
  61. package/dist/esm/{chunk-4BGNLZ5Y.mjs → chunk-IK7JAKXG.mjs} +2 -2
  62. package/dist/esm/{chunk-UCHGKGCF.mjs → chunk-J46VAO6L.mjs} +2 -2
  63. package/dist/esm/{chunk-YJQQF4GI.mjs → chunk-J4CN3Q2R.mjs} +2 -2
  64. package/dist/esm/{chunk-XSM3SOZY.mjs → chunk-JBWJE4IP.mjs} +2 -2
  65. package/dist/esm/{chunk-F362Q4BJ.mjs → chunk-JMV2QDNW.mjs} +2 -2
  66. package/dist/esm/{chunk-DHR4YEUH.mjs → chunk-JRQMEVDE.mjs} +2 -2
  67. package/dist/esm/{chunk-TJJSQSO3.mjs → chunk-K6IBDLVC.mjs} +2 -2
  68. package/dist/esm/chunk-LFWMWCS3.mjs +2 -0
  69. package/dist/esm/chunk-LFWMWCS3.mjs.map +1 -0
  70. package/dist/esm/{chunk-I4EKXYTB.mjs → chunk-NXAHJ4KY.mjs} +2 -2
  71. package/dist/esm/{chunk-FBFMQZTM.mjs → chunk-P7B32QR3.mjs} +2 -2
  72. package/dist/esm/{chunk-4OI7MPFH.mjs → chunk-PPNI7SJK.mjs} +2 -2
  73. package/dist/esm/chunk-QYB75IJ6.mjs +2 -0
  74. package/dist/esm/chunk-QYB75IJ6.mjs.map +1 -0
  75. package/dist/esm/{chunk-457LDQ3A.mjs → chunk-R3URESCV.mjs} +2 -2
  76. package/dist/esm/{chunk-XGM33CR7.mjs → chunk-TRTTUBC4.mjs} +2 -2
  77. package/dist/esm/{chunk-7Z4DTVZN.mjs → chunk-VP5JCW6I.mjs} +2 -2
  78. package/dist/esm/chunk-W5PZ5Z4H.mjs +2 -0
  79. package/dist/esm/chunk-W5PZ5Z4H.mjs.map +1 -0
  80. package/dist/esm/{chunk-FP5DPRYL.mjs → chunk-WXWFKCGO.mjs} +2 -2
  81. package/dist/esm/chunk-X3SXV2RB.mjs +2 -0
  82. package/dist/esm/{chunk-NXPN5XLB.mjs.map → chunk-X3SXV2RB.mjs.map} +1 -1
  83. package/dist/esm/{chunk-V6J34VOD.mjs → chunk-ZDT4TIOP.mjs} +2 -2
  84. package/dist/esm/client/core.mjs +1 -1
  85. package/dist/esm/client/get.mjs +1 -1
  86. package/dist/esm/client/index.mjs +1 -1
  87. package/dist/esm/client/post.mjs +1 -1
  88. package/dist/esm/core/account.mjs +1 -1
  89. package/dist/esm/core/authenticationKey.mjs +1 -1
  90. package/dist/esm/core/crypto/anyPublicKey.mjs +1 -1
  91. package/dist/esm/core/crypto/anySignature.mjs +1 -1
  92. package/dist/esm/core/crypto/asymmetricCrypto.mjs +1 -1
  93. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  94. package/dist/esm/core/crypto/index.mjs +1 -1
  95. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  96. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  97. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  98. package/dist/esm/core/index.mjs +1 -1
  99. package/dist/esm/index.d.mts +3 -1
  100. package/dist/esm/index.mjs +1 -1
  101. package/dist/esm/internal/account.mjs +1 -1
  102. package/dist/esm/internal/ans.mjs +1 -1
  103. package/dist/esm/internal/coin.mjs +1 -1
  104. package/dist/esm/internal/digitalAsset.mjs +1 -1
  105. package/dist/esm/internal/event.mjs +1 -1
  106. package/dist/esm/internal/faucet.mjs +1 -1
  107. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  108. package/dist/esm/internal/general.mjs +1 -1
  109. package/dist/esm/internal/staking.mjs +1 -1
  110. package/dist/esm/internal/transaction.mjs +1 -1
  111. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  112. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  113. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  114. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  115. package/dist/esm/transactions/index.mjs +1 -1
  116. package/dist/esm/transactions/instances/index.mjs +1 -1
  117. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  118. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  119. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  120. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  121. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  122. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  123. package/dist/esm/transactions/management/index.d.mts +2 -1
  124. package/dist/esm/transactions/management/index.mjs +1 -1
  125. package/dist/esm/transactions/management/transactionWorker.d.mts +29 -3
  126. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  127. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  128. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  129. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  130. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  131. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  132. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  133. package/dist/esm/version.d.mts +1 -1
  134. package/dist/esm/version.mjs +1 -1
  135. package/package.json +3 -2
  136. package/src/api/aptos.ts +1 -1
  137. package/src/api/transaction.ts +7 -9
  138. package/src/api/transactionSubmission/management.ts +106 -0
  139. package/src/client/core.ts +1 -1
  140. package/src/transactions/management/transactionWorker.ts +74 -14
  141. package/src/version.ts +1 -1
  142. package/dist/esm/chunk-2EQNGCPL.mjs +0 -2
  143. package/dist/esm/chunk-2EQNGCPL.mjs.map +0 -1
  144. package/dist/esm/chunk-ATV7SH7J.mjs +0 -2
  145. package/dist/esm/chunk-ATV7SH7J.mjs.map +0 -1
  146. package/dist/esm/chunk-NXPN5XLB.mjs +0 -2
  147. package/dist/esm/chunk-QLAW63UU.mjs +0 -2
  148. package/dist/esm/chunk-QLAW63UU.mjs.map +0 -1
  149. package/dist/esm/chunk-RVQGLEBY.mjs +0 -2
  150. package/dist/esm/chunk-RVQGLEBY.mjs.map +0 -1
  151. /package/dist/esm/{chunk-KYI7YRRQ.mjs.map → chunk-25YXK6L2.mjs.map} +0 -0
  152. /package/dist/esm/{chunk-Q7B4KMTR.mjs.map → chunk-2BSSYT6I.mjs.map} +0 -0
  153. /package/dist/esm/{chunk-JHKU4VAL.mjs.map → chunk-2RN7N3EO.mjs.map} +0 -0
  154. /package/dist/esm/{chunk-LGC5FYCC.mjs.map → chunk-3T4NSGK5.mjs.map} +0 -0
  155. /package/dist/esm/{chunk-NWRKJFHV.mjs.map → chunk-4QWK47EH.mjs.map} +0 -0
  156. /package/dist/esm/{chunk-RKWCYC3Y.mjs.map → chunk-4TGKQEEE.mjs.map} +0 -0
  157. /package/dist/esm/{chunk-GGCQNE7J.mjs.map → chunk-6IMEQXW4.mjs.map} +0 -0
  158. /package/dist/esm/{chunk-3PPUHF6D.mjs.map → chunk-6KILJ43F.mjs.map} +0 -0
  159. /package/dist/esm/{chunk-SBMJNU2O.mjs.map → chunk-7WQA7OMS.mjs.map} +0 -0
  160. /package/dist/esm/{chunk-3DM36HLF.mjs.map → chunk-ACMNL2LL.mjs.map} +0 -0
  161. /package/dist/esm/{chunk-2QV6HI3M.mjs.map → chunk-APOQ4ODM.mjs.map} +0 -0
  162. /package/dist/esm/{chunk-FXXTTZOI.mjs.map → chunk-ATHZ7INX.mjs.map} +0 -0
  163. /package/dist/esm/{chunk-TN4RHL6A.mjs.map → chunk-BDHRLMQP.mjs.map} +0 -0
  164. /package/dist/esm/{chunk-LLONKHWW.mjs.map → chunk-BQYQ45QQ.mjs.map} +0 -0
  165. /package/dist/esm/{chunk-QQMEPYJ3.mjs.map → chunk-C53MNMPH.mjs.map} +0 -0
  166. /package/dist/esm/{chunk-4RFWMHWT.mjs.map → chunk-CFQDJZBD.mjs.map} +0 -0
  167. /package/dist/esm/{chunk-4DEYLX4E.mjs.map → chunk-DHFOORW6.mjs.map} +0 -0
  168. /package/dist/esm/{chunk-BBJ3YXGC.mjs.map → chunk-DIWRS4YQ.mjs.map} +0 -0
  169. /package/dist/esm/{chunk-CBMEWHLK.mjs.map → chunk-DSGIOUTJ.mjs.map} +0 -0
  170. /package/dist/esm/{chunk-MJW4JGUR.mjs.map → chunk-ED2OMOMT.mjs.map} +0 -0
  171. /package/dist/esm/{chunk-CHK4FLX4.mjs.map → chunk-FE2DRPX7.mjs.map} +0 -0
  172. /package/dist/esm/{chunk-ERWQOVBF.mjs.map → chunk-FGHNLZRH.mjs.map} +0 -0
  173. /package/dist/esm/{chunk-FW7B46XZ.mjs.map → chunk-FHUT4EJH.mjs.map} +0 -0
  174. /package/dist/esm/{chunk-PXNW26UO.mjs.map → chunk-HT6K4NWZ.mjs.map} +0 -0
  175. /package/dist/esm/{chunk-O74RSNEJ.mjs.map → chunk-HV4ZPHSZ.mjs.map} +0 -0
  176. /package/dist/esm/{chunk-4BGNLZ5Y.mjs.map → chunk-IK7JAKXG.mjs.map} +0 -0
  177. /package/dist/esm/{chunk-UCHGKGCF.mjs.map → chunk-J46VAO6L.mjs.map} +0 -0
  178. /package/dist/esm/{chunk-YJQQF4GI.mjs.map → chunk-J4CN3Q2R.mjs.map} +0 -0
  179. /package/dist/esm/{chunk-XSM3SOZY.mjs.map → chunk-JBWJE4IP.mjs.map} +0 -0
  180. /package/dist/esm/{chunk-F362Q4BJ.mjs.map → chunk-JMV2QDNW.mjs.map} +0 -0
  181. /package/dist/esm/{chunk-DHR4YEUH.mjs.map → chunk-JRQMEVDE.mjs.map} +0 -0
  182. /package/dist/esm/{chunk-TJJSQSO3.mjs.map → chunk-K6IBDLVC.mjs.map} +0 -0
  183. /package/dist/esm/{chunk-I4EKXYTB.mjs.map → chunk-NXAHJ4KY.mjs.map} +0 -0
  184. /package/dist/esm/{chunk-FBFMQZTM.mjs.map → chunk-P7B32QR3.mjs.map} +0 -0
  185. /package/dist/esm/{chunk-4OI7MPFH.mjs.map → chunk-PPNI7SJK.mjs.map} +0 -0
  186. /package/dist/esm/{chunk-457LDQ3A.mjs.map → chunk-R3URESCV.mjs.map} +0 -0
  187. /package/dist/esm/{chunk-XGM33CR7.mjs.map → chunk-TRTTUBC4.mjs.map} +0 -0
  188. /package/dist/esm/{chunk-7Z4DTVZN.mjs.map → chunk-VP5JCW6I.mjs.map} +0 -0
  189. /package/dist/esm/{chunk-FP5DPRYL.mjs.map → chunk-WXWFKCGO.mjs.map} +0 -0
  190. /package/dist/esm/{chunk-V6J34VOD.mjs.map → chunk-ZDT4TIOP.mjs.map} +0 -0
@@ -1,5 +1,58 @@
1
1
  /* eslint-disable no-await-in-loop */
2
2
 
3
+ import EventEmitter from "eventemitter3";
4
+ import { AptosConfig } from "../../api/aptosConfig";
5
+ import { Account } from "../../core";
6
+ import { waitForTransaction } from "../../internal/transaction";
7
+ import { generateTransaction, signAndSubmitTransaction } from "../../internal/transactionSubmission";
8
+ import { PendingTransactionResponse, TransactionResponse } from "../../types";
9
+ import { InputGenerateTransactionOptions, InputGenerateTransactionPayloadData, SimpleTransaction } from "../types";
10
+ import { AccountSequenceNumber } from "./accountSequenceNumber";
11
+ import { AsyncQueue, AsyncQueueCancelledError } from "./asyncQueue";
12
+
13
+ export const promiseFulfilledStatus = "fulfilled";
14
+
15
+ // Event types the worker fires during execution and
16
+ // the dapp can listen to
17
+ export enum TransactionWorkerEventsEnum {
18
+ // fired after a transaction gets sent to the chain
19
+ TransactionSent = "transactionSent",
20
+ // fired if there is an error sending the transaction to the chain
21
+ TransactionSendFailed = "transactionSendFailed",
22
+ // fired when a single transaction has executed successfully
23
+ TransactionExecuted = "transactionExecuted",
24
+ // fired if a single transaction fails in execution
25
+ TransactionExecutionFailed = "transactionExecutionFailed",
26
+ // fired when the worker has finished its job / when the queue has been emptied
27
+ ExecutionFinish = "executionFinish",
28
+ }
29
+
30
+ // Typed interface of the worker events
31
+ export interface TransactionWorkerEvents {
32
+ transactionSent: (data: SuccessEventData) => void;
33
+ transactionSendFailed: (data: FailureEventData) => void;
34
+ transactionExecuted: (data: SuccessEventData) => void;
35
+ transactionExecutionFailed: (data: FailureEventData) => void;
36
+ executionFinish: (data: ExecutionFinishEventData) => void;
37
+ }
38
+
39
+ // Type for when the worker has finished its job
40
+ export type ExecutionFinishEventData = {
41
+ message: string;
42
+ };
43
+
44
+ // Type for a success event
45
+ export type SuccessEventData = {
46
+ message: string;
47
+ transactionHash: string;
48
+ };
49
+
50
+ // Type for a failure event
51
+ export type FailureEventData = {
52
+ message: string;
53
+ error: string;
54
+ };
55
+
3
56
  /**
4
57
  * TransactionWorker provides a simple framework for receiving payloads to be processed.
5
58
  *
@@ -12,19 +65,7 @@
12
65
  * and 2) waits for the resolution of the execution process or get an execution error.
13
66
  * The worker fires events for any submission and/or execution success and/or failure.
14
67
  */
15
-
16
- import { AptosConfig } from "../../api/aptosConfig";
17
- import { Account } from "../../core";
18
- import { waitForTransaction } from "../../internal/transaction";
19
- import { generateTransaction, signAndSubmitTransaction } from "../../internal/transactionSubmission";
20
- import { PendingTransactionResponse, TransactionResponse } from "../../types";
21
- import { InputGenerateTransactionOptions, InputGenerateTransactionPayloadData, SimpleTransaction } from "../types";
22
- import { AccountSequenceNumber } from "./accountSequenceNumber";
23
- import { AsyncQueue, AsyncQueueCancelledError } from "./asyncQueue";
24
-
25
- const promiseFulfilledStatus = "fulfilled";
26
-
27
- export class TransactionWorker {
68
+ export class TransactionWorker extends EventEmitter<TransactionWorkerEvents> {
28
69
  readonly aptosConfig: AptosConfig;
29
70
 
30
71
  readonly account: Account;
@@ -79,6 +120,7 @@ export class TransactionWorker {
79
120
  maximumInFlight: number = 100,
80
121
  sleepTime: number = 10,
81
122
  ) {
123
+ super();
82
124
  this.aptosConfig = aptosConfig;
83
125
  this.account = account;
84
126
  this.started = false;
@@ -101,7 +143,6 @@ export class TransactionWorker {
101
143
  try {
102
144
  /* eslint-disable no-constant-condition */
103
145
  while (true) {
104
- if (this.transactionsQueue.isEmpty()) return;
105
146
  const sequenceNumber = await this.accountSequnceNumber.nextSequenceNumber();
106
147
  if (sequenceNumber === null) return;
107
148
  const transaction = await this.generateNextTransaction(this.account, sequenceNumber);
@@ -157,12 +198,23 @@ export class TransactionWorker {
157
198
  // transaction sent to chain
158
199
  this.sentTransactions.push([sentTransaction.value.hash, sequenceNumber, null]);
159
200
  // check sent transaction execution
201
+ this.emit(TransactionWorkerEventsEnum.TransactionSent, {
202
+ message: `transaction hash ${sentTransaction.value.hash} has been committed to chain`,
203
+ transactionHash: sentTransaction.value.hash,
204
+ });
160
205
  await this.checkTransaction(sentTransaction, sequenceNumber);
161
206
  } else {
162
207
  // send transaction failed
163
208
  this.sentTransactions.push([sentTransaction.status, sequenceNumber, sentTransaction.reason]);
209
+ this.emit(TransactionWorkerEventsEnum.TransactionSendFailed, {
210
+ message: `failed to commit transaction ${this.sentTransactions.length} with error ${sentTransaction.reason}`,
211
+ error: sentTransaction.reason,
212
+ });
164
213
  }
165
214
  }
215
+ this.emit(TransactionWorkerEventsEnum.ExecutionFinish, {
216
+ message: `execute ${sentTransactions.length} transactions finished`,
217
+ });
166
218
  }
167
219
  } catch (error: any) {
168
220
  if (error instanceof AsyncQueueCancelledError) {
@@ -188,9 +240,17 @@ export class TransactionWorker {
188
240
  if (executedTransaction.status === promiseFulfilledStatus) {
189
241
  // transaction executed to chain
190
242
  this.executedTransactions.push([executedTransaction.value.hash, sequenceNumber, null]);
243
+ this.emit(TransactionWorkerEventsEnum.TransactionExecuted, {
244
+ message: `transaction hash ${executedTransaction.value.hash} has been executed on chain`,
245
+ transactionHash: sentTransaction.value.hash,
246
+ });
191
247
  } else {
192
248
  // transaction execution failed
193
249
  this.executedTransactions.push([executedTransaction.status, sequenceNumber, executedTransaction.reason]);
250
+ this.emit(TransactionWorkerEventsEnum.TransactionExecutionFailed, {
251
+ message: `failed to execute transaction ${this.executedTransactions.length} with error ${executedTransaction.reason}`,
252
+ error: executedTransaction.reason,
253
+ });
194
254
  }
195
255
  }
196
256
  } catch (error: any) {
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "1.4.0";
9
+ export const VERSION = "1.5.1";
@@ -1,2 +0,0 @@
1
- import{a as d}from"./chunk-6FBKUTGF.mjs";import{a as R}from"./chunk-NXPN5XLB.mjs";var p={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function c(n,a){let{url:o,method:u,body:i,contentType:s,params:e,overrides:t}=n,r={...t?.HEADERS,"x-aptos-client":`aptos-typescript-sdk/${R}`,"content-type":s??"application/json"};return t?.AUTH_TOKEN&&o.includes("faucet")&&(r.Authorization=`Bearer ${t?.AUTH_TOKEN}`),t?.API_KEY&&!o.includes("faucet")&&(r.Authorization=`Bearer ${t?.API_KEY}`),a.provider({url:o,method:u,body:i,params:e,headers:r,overrides:t})}async function T(n,a){let{url:o,path:u}=n,i=`${o}/${u??""}`,s=await c({...n,url:i},a.client),e={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:i};if(a.isIndexerRequest(o)){let r=e.data;if(r.errors)throw new d(n,e,r.errors[0].message??`Unhandled Error ${s.status} : ${s.statusText}`);e.data=r.data}if(e.status>=200&&e.status<300)return e;let t;throw e&&e.data&&"message"in e.data&&"error_code"in e.data?t=JSON.stringify(e.data):e.status in p?t=p[e.status]:t=`Unhandled Error ${e.status} : ${e.statusText}`,new d(n,e,t)}export{c as a,T as b};
2
- //# sourceMappingURL=chunk-2EQNGCPL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/core.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { AptosApiError, AptosResponse } from \"./types\";\nimport { VERSION } from \"../version\";\nimport { AptosRequest, MimeType, ClientRequest, ClientResponse, Client, AnyNumber } from \"../types\";\n\n/**\n * Meaningful errors map\n */\nconst errors: Record<number, string> = {\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 429: \"Too Many Requests\",\n 500: \"Internal Server Error\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n};\n\n/**\n * Given a url and method, sends the request with axios and\n * returns the response.\n */\nexport async function request<Req, Res>(options: ClientRequest<Req>, client: Client): Promise<ClientResponse<Res>> {\n const { url, method, body, contentType, params, overrides } = options;\n const headers: Record<string, string | AnyNumber | boolean | undefined> = {\n ...overrides?.HEADERS,\n \"x-aptos-client\": `aptos-typescript-sdk/${VERSION}`,\n \"content-type\": contentType ?? MimeType.JSON,\n };\n\n // TODO - auth token is being used only for faucet, it breaks full node requests.\n // Find a more sophisticated way than that but without the need to add the\n // auth_token on every `aptos.fundAccount()` call\n if (overrides?.AUTH_TOKEN && url.includes(\"faucet\")) {\n headers.Authorization = `Bearer ${overrides?.AUTH_TOKEN}`;\n }\n if (overrides?.API_KEY && !url.includes(\"faucet\")) {\n headers.Authorization = `Bearer ${overrides?.API_KEY}`;\n }\n\n /*\n * make a call using the @aptos-labs/aptos-client package\n * {@link https://www.npmjs.com/package/@aptos-labs/aptos-client}\n */\n return client.provider<Req, Res>({\n url,\n method,\n body,\n params,\n headers,\n overrides,\n });\n}\n\n/**\n * The main function to use when doing an API request.\n *\n * @param options AptosRequest\n * @param aptosConfig The config information for the SDK client instance\n * @returns the response or AptosApiError\n */\nexport async function aptosRequest<Req extends {}, Res extends {}>(\n options: AptosRequest,\n aptosConfig: AptosConfig,\n): Promise<AptosResponse<Req, Res>> {\n const { url, path } = options;\n const fullUrl = `${url}/${path ?? \"\"}`;\n const response = await request<Req, Res>({ ...options, url: fullUrl }, aptosConfig.client);\n\n const result: AptosResponse<Req, Res> = {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n request: response.request,\n url: fullUrl,\n };\n\n // to support both fullnode and indexer responses,\n // check if it is an indexer query, and adjust response.data\n if (aptosConfig.isIndexerRequest(url)) {\n const indexerResponse = result.data as any;\n // errors from indexer\n if (indexerResponse.errors) {\n throw new AptosApiError(\n options,\n result,\n indexerResponse.errors[0].message ?? `Unhandled Error ${response.status} : ${response.statusText}`,\n );\n }\n result.data = indexerResponse.data as Res;\n }\n\n if (result.status >= 200 && result.status < 300) {\n return result;\n }\n\n let errorMessage: string;\n\n if (result && result.data && \"message\" in result.data && \"error_code\" in result.data) {\n errorMessage = JSON.stringify(result.data);\n } else if (result.status in errors) {\n // If it's not an API type, it must come form infra, these are prehandled\n errorMessage = errors[result.status];\n } else {\n // Everything else is unhandled\n errorMessage = `Unhandled Error ${result.status} : ${result.statusText}`;\n }\n\n throw new AptosApiError(options, result, errorMessage);\n}\n"],"mappings":"kFAWA,IAAMA,EAAiC,CACrC,IAAK,cACL,IAAK,eACL,IAAK,YACL,IAAK,YACL,IAAK,oBACL,IAAK,wBACL,IAAK,cACL,IAAK,qBACP,EAMA,eAAsBC,EAAkBC,EAA6BC,EAA8C,CACjH,GAAM,CAAE,IAAAC,EAAK,OAAAC,EAAQ,KAAAC,EAAM,YAAAC,EAAa,OAAAC,EAAQ,UAAAC,CAAU,EAAIP,EACxDQ,EAAoE,CACxE,GAAGD,GAAW,QACd,iBAAkB,wBAAwBE,CAAO,GACjD,eAAgBJ,qBAClB,EAKA,OAAIE,GAAW,YAAcL,EAAI,SAAS,QAAQ,IAChDM,EAAQ,cAAgB,UAAUD,GAAW,UAAU,IAErDA,GAAW,SAAW,CAACL,EAAI,SAAS,QAAQ,IAC9CM,EAAQ,cAAgB,UAAUD,GAAW,OAAO,IAO/CN,EAAO,SAAmB,CAC/B,IAAAC,EACA,OAAAC,EACA,KAAAC,EACA,OAAAE,EACA,QAAAE,EACA,UAAAD,CACF,CAAC,CACH,CASA,eAAsBG,EACpBV,EACAW,EACkC,CAClC,GAAM,CAAE,IAAAT,EAAK,KAAAU,CAAK,EAAIZ,EAChBa,EAAU,GAAGX,CAAG,IAAIU,GAAQ,EAAE,GAC9BE,EAAW,MAAMf,EAAkB,CAAE,GAAGC,EAAS,IAAKa,CAAQ,EAAGF,EAAY,MAAM,EAEnFI,EAAkC,CACtC,OAAQD,EAAS,OACjB,WAAYA,EAAS,WACrB,KAAMA,EAAS,KACf,QAASA,EAAS,QAClB,OAAQA,EAAS,OACjB,QAASA,EAAS,QAClB,IAAKD,CACP,EAIA,GAAIF,EAAY,iBAAiBT,CAAG,EAAG,CACrC,IAAMc,EAAkBD,EAAO,KAE/B,GAAIC,EAAgB,OAClB,MAAM,IAAIC,EACRjB,EACAe,EACAC,EAAgB,OAAO,CAAC,EAAE,SAAW,mBAAmBF,EAAS,MAAM,MAAMA,EAAS,UAAU,EAClG,EAEFC,EAAO,KAAOC,EAAgB,IAChC,CAEA,GAAID,EAAO,QAAU,KAAOA,EAAO,OAAS,IAC1C,OAAOA,EAGT,IAAIG,EAEJ,MAAIH,GAAUA,EAAO,MAAQ,YAAaA,EAAO,MAAQ,eAAgBA,EAAO,KAC9EG,EAAe,KAAK,UAAUH,EAAO,IAAI,EAChCA,EAAO,UAAUjB,EAE1BoB,EAAepB,EAAOiB,EAAO,MAAM,EAGnCG,EAAe,mBAAmBH,EAAO,MAAM,MAAMA,EAAO,UAAU,GAGlE,IAAIE,EAAcjB,EAASe,EAAQG,CAAY,CACvD","names":["errors","request","options","client","url","method","body","contentType","params","overrides","headers","VERSION","aptosRequest","aptosConfig","path","fullUrl","response","result","indexerResponse","AptosApiError","errorMessage"]}
@@ -1,2 +0,0 @@
1
- import{a as A}from"./chunk-QLAW63UU.mjs";import{a as d}from"./chunk-TN4RHL6A.mjs";import{a as h}from"./chunk-O74RSNEJ.mjs";import{a as T}from"./chunk-BBJ3YXGC.mjs";import{d as p,e as a,h as m,i as f,j as y}from"./chunk-JHKU4VAL.mjs";import{a as s,b as r,c as e,d as c,e as u,f as g}from"./chunk-7Z4DTVZN.mjs";var P=class{constructor(n){this.config=n,this.build=new T(this.config),this.simulate=new d(this.config),this.submit=new h(this.config)}async getTransactions(n){return s({aptosConfig:this.config,...n})}async getTransactionByVersion(n){return e({aptosConfig:this.config,...n})}async getTransactionByHash(n){return c({aptosConfig:this.config,...n})}async isPendingTransaction(n){return u({aptosConfig:this.config,...n})}async waitForTransaction(n){return g({aptosConfig:this.config,...n})}async getGasPriceEstimation(){return r({aptosConfig:this.config})}getSigningMessage(n){return p(n)}async publishPackageTransaction(n){return f({aptosConfig:this.config,...n})}async rotateAuthKey(n){return y({aptosConfig:this.config,...n})}sign(n){return a({...n})}signAsFeePayer(n){let{signer:t,transaction:o}=n;if(!o.feePayerAddress)throw new Error(`Transaction ${o} is not a Fee Payer transaction`);return o.feePayerAddress=t.accountAddress,a({signer:t,transaction:o})}async batchTransactionsForSingleAccount(n){try{let{sender:t,data:o,options:l}=n,i=new A(this.config,t);i.start();for(let w of o)await i.push(w,l)}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(n){let{signer:t,transaction:o}=n;return m({aptosConfig:this.config,signer:t,transaction:o})}};export{P as a};
2
- //# sourceMappingURL=chunk-ATV7SH7J.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/transaction.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"./aptosConfig\";\nimport {\n getGasPriceEstimation,\n getTransactionByHash,\n getTransactionByVersion,\n getTransactions,\n isTransactionPending,\n waitForTransaction,\n} from \"../internal/transaction\";\nimport {\n AnyNumber,\n CommittedTransactionResponse,\n GasEstimation,\n HexInput,\n PaginationArgs,\n PendingTransactionResponse,\n TransactionResponse,\n WaitForTransactionOptions,\n} from \"../types\";\nimport {\n getSigningMessage,\n publicPackageTransaction,\n rotateAuthKey,\n signAndSubmitTransaction,\n signTransaction,\n} from \"../internal/transactionSubmission\";\nimport {\n AccountAuthenticator,\n AnyRawTransaction,\n InputGenerateTransactionOptions,\n InputGenerateTransactionPayloadData,\n SimpleTransaction,\n} from \"../transactions\";\nimport { AccountAddressInput, Account, PrivateKey } from \"../core\";\nimport { TransactionWorker } from \"../transactions/management\";\nimport { Build } from \"./transactionSubmission/build\";\nimport { Simulate } from \"./transactionSubmission/simulate\";\nimport { Submit } from \"./transactionSubmission/submit\";\n\nexport class Transaction {\n readonly config: AptosConfig;\n\n readonly build: Build;\n\n readonly simulate: Simulate;\n\n readonly submit: Submit;\n\n constructor(config: AptosConfig) {\n this.config = config;\n this.build = new Build(this.config);\n this.simulate = new Simulate(this.config);\n this.submit = new Submit(this.config);\n }\n\n /**\n * Queries on-chain transactions. This function will not return pending\n * transactions. For that, use `getTransactionsByHash`.\n *\n * @param args.options.offset The number transaction to start with\n * @param args.options.limit Number of results to return\n *\n * @returns Array of on-chain transactions\n */\n async getTransactions(args?: { options?: PaginationArgs }): Promise<TransactionResponse[]> {\n return getTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries on-chain transaction by version. This function will not return pending transactions.\n *\n * @param args.ledgerVersion - Transaction version is an unsigned 64-bit number.\n * @returns On-chain transaction. Only on-chain transactions have versions, so this\n * function cannot be used to query pending transactions.\n */\n async getTransactionByVersion(args: { ledgerVersion: AnyNumber }): Promise<TransactionResponse> {\n return getTransactionByVersion({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries on-chain transaction by transaction hash. This function will return pending transactions.\n * @param args.transactionHash - Transaction hash should be hex-encoded bytes string with 0x prefix.\n * @returns Transaction from mempool (pending) or on-chain (committed) transaction\n */\n async getTransactionByHash(args: { transactionHash: HexInput }): Promise<TransactionResponse> {\n return getTransactionByHash({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Defines if specified transaction is currently in pending state\n *\n * To create a transaction hash:\n *\n * 1. Create a hash message from the bytes: \"Aptos::Transaction\" bytes + the BCS-serialized Transaction bytes.\n * 2. Apply hash algorithm SHA3-256 to the hash message bytes.\n * 3. Hex-encode the hash bytes with 0x prefix.\n *\n * @param args.transactionHash A hash of transaction\n * @returns `true` if transaction is in pending state and `false` otherwise\n */\n async isPendingTransaction(args: { transactionHash: HexInput }): Promise<boolean> {\n return isTransactionPending({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Waits for a transaction to move past the pending state.\n *\n * There are 4 cases.\n * 1. Transaction is successfully processed and committed to the chain.\n * - The function will resolve with the transaction response from the API.\n * 2. Transaction is rejected for some reason, and is therefore not committed to the blockchain.\n * - The function will throw an AptosApiError with an HTTP status code indicating some problem with the request.\n * 3. Transaction is committed but execution failed, meaning no changes were\n * written to the blockchain state.\n * - If `checkSuccess` is true, the function will throw a FailedTransactionError\n * If `checkSuccess` is false, the function will resolve with the transaction response where the `success` field is false.\n * 4. Transaction does not move past the pending state within `args.options.timeoutSecs` seconds.\n * - The function will throw a WaitForTransactionError\n *\n *\n * @param args.transactionHash The hash of a transaction previously submitted to the blockchain.\n * @param args.options.timeoutSecs Timeout in seconds. Defaults to 20 seconds.\n * @param args.options.checkSuccess A boolean which controls whether the function will error if the transaction failed.\n * Defaults to true. See case 3 above.\n * @returns The transaction on-chain. See above for more details.\n */\n async waitForTransaction(args: {\n transactionHash: HexInput;\n options?: WaitForTransactionOptions;\n }): Promise<CommittedTransactionResponse> {\n return waitForTransaction({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Gives an estimate of the gas unit price required to get a\n * transaction on chain in a reasonable amount of time.\n * For more information {@link https://fullnode.mainnet.aptoslabs.com/v1/spec#/operations/estimate_gas_price}\n *\n * @returns Object holding the outputs of the estimate gas API\n * @example\n * ```\n * {\n * gas_estimate: number;\n * deprioritized_gas_estimate?: number;\n * prioritized_gas_estimate?: number;\n * }\n * ```\n */\n async getGasPriceEstimation(): Promise<GasEstimation> {\n return getGasPriceEstimation({\n aptosConfig: this.config,\n });\n }\n\n /**\n * Returns a signing message for a transaction.\n *\n * This allows a user to sign a transaction using their own preferred signing method, and\n * then submit it to the network.\n * @param args.transaction A raw transaction for signing elsewhere\n */\n // eslint-disable-next-line class-methods-use-this\n getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {\n return getSigningMessage(args);\n }\n\n /**\n * Generates a transaction to publish a move package to chain.\n *\n * To get the `metadataBytes` and `byteCode`, can compile using Aptos CLI with command\n * `aptos move compile --save-metadata ...`,\n * For more info {@link https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module}\n *\n * @param args.account The publisher account\n * @param args.metadataBytes The package metadata bytes\n * @param args.moduleBytecode An array of the bytecode of each module in the package in compiler output order\n *\n * @returns A SimpleTransaction that can be simulated or submitted to chain\n */\n async publishPackageTransaction(args: {\n account: AccountAddressInput;\n metadataBytes: HexInput;\n moduleBytecode: Array<HexInput>;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return publicPackageTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for\n * the account.\n * Note: Only legacy Ed25519 scheme is supported for now.\n * More info: {@link https://aptos.dev/guides/account-management/key-rotation/}\n * @param args.fromAccount The account to rotate the auth key for\n * @param args.toNewPrivateKey The new private key to rotate to\n *\n * @returns PendingTransactionResponse\n */\n async rotateAuthKey(args: { fromAccount: Account; toNewPrivateKey: PrivateKey }): Promise<TransactionResponse> {\n return rotateAuthKey({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sign a transaction that can later be submitted to chain\n *\n * @param args.signer The signer account\n * @param args.transaction A raw transaction to sign on\n *\n * @returns AccountAuthenticator\n */\n // eslint-disable-next-line class-methods-use-this\n sign(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n return signTransaction({\n ...args,\n });\n }\n\n /**\n * Sign a transaction as a fee payer that can later be submitted to chain\n *\n * @param args.signer The fee payer signer account\n * @param args.transaction A raw transaction to sign on\n *\n * @returns AccountAuthenticator\n */\n // eslint-disable-next-line class-methods-use-this\n signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n\n // if transaction doesnt hold a \"feePayerAddress\" prop it means\n // this is not a fee payer transaction\n if (!transaction.feePayerAddress) {\n throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);\n }\n\n // Set the feePayerAddress to the signer account address\n transaction.feePayerAddress = signer.accountAddress;\n\n return signTransaction({\n signer,\n transaction,\n });\n }\n\n // TRANSACTION SUBMISSION //\n\n /**\n * Batch transactions for a single account.\n *\n * This function uses a transaction worker that receives payloads to be processed\n * and submitted to chain.\n * Note that this process is best for submitting multiple transactions that\n * dont rely on each other, i.e batch funds, batch token mints, etc.\n *\n * If any worker failure, the functions throws an error.\n *\n * @param args.sender The sender account to sign and submit the transaction\n * @param args.data An array of transaction payloads\n * @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)\n *\n * @return void. Throws if any error\n */\n async batchTransactionsForSingleAccount(args: {\n sender: Account;\n data: InputGenerateTransactionPayloadData[];\n options?: Omit<InputGenerateTransactionOptions, \"accountSequenceNumber\">;\n }): Promise<void> {\n try {\n const { sender, data, options } = args;\n const transactionWorker = new TransactionWorker(this.config, sender);\n\n transactionWorker.start();\n\n for (const d of data) {\n /* eslint-disable no-await-in-loop */\n await transactionWorker.push(d, options);\n }\n } catch (error: any) {\n throw new Error(`failed to submit transactions with error: ${error}`);\n }\n }\n\n /**\n * Sign and submit a single signer transaction to chain\n *\n * @param args.signer The signer account to sign the transaction\n * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses? : Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n *\n * @return PendingTransactionResponse\n */\n async signAndSubmitTransaction(args: {\n signer: Account;\n transaction: AnyRawTransaction;\n }): Promise<PendingTransactionResponse> {\n const { signer, transaction } = args;\n return signAndSubmitTransaction({\n aptosConfig: this.config,\n signer,\n transaction,\n });\n }\n}\n"],"mappings":"qTA0CO,IAAMA,EAAN,KAAkB,CASvB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,EACd,KAAK,MAAQ,IAAIC,EAAM,KAAK,MAAM,EAClC,KAAK,SAAW,IAAIC,EAAS,KAAK,MAAM,EACxC,KAAK,OAAS,IAAIC,EAAO,KAAK,MAAM,CACtC,CAWA,MAAM,gBAAgBC,EAAqE,CACzF,OAAOC,EAAgB,CACrB,YAAa,KAAK,OAClB,GAAGD,CACL,CAAC,CACH,CASA,MAAM,wBAAwBA,EAAkE,CAC9F,OAAOE,EAAwB,CAC7B,YAAa,KAAK,OAClB,GAAGF,CACL,CAAC,CACH,CAOA,MAAM,qBAAqBA,EAAmE,CAC5F,OAAOG,EAAqB,CAC1B,YAAa,KAAK,OAClB,GAAGH,CACL,CAAC,CACH,CAcA,MAAM,qBAAqBA,EAAuD,CAChF,OAAOI,EAAqB,CAC1B,YAAa,KAAK,OAClB,GAAGJ,CACL,CAAC,CACH,CAwBA,MAAM,mBAAmBA,EAGiB,CACxC,OAAOK,EAAmB,CACxB,YAAa,KAAK,OAClB,GAAGL,CACL,CAAC,CACH,CAiBA,MAAM,uBAAgD,CACpD,OAAOM,EAAsB,CAC3B,YAAa,KAAK,MACpB,CAAC,CACH,CAUA,kBAAkBN,EAAsD,CACtE,OAAOO,EAAkBP,CAAI,CAC/B,CAeA,MAAM,0BAA0BA,EAKD,CAC7B,OAAOQ,EAAyB,CAAE,YAAa,KAAK,OAAQ,GAAGR,CAAK,CAAC,CACvE,CAYA,MAAM,cAAcA,EAA2F,CAC7G,OAAOS,EAAc,CAAE,YAAa,KAAK,OAAQ,GAAGT,CAAK,CAAC,CAC5D,CAWA,KAAKA,EAAiF,CACpF,OAAOU,EAAgB,CACrB,GAAGV,CACL,CAAC,CACH,CAWA,eAAeA,EAAiF,CAC9F,GAAM,CAAE,OAAAW,EAAQ,YAAAC,CAAY,EAAIZ,EAIhC,GAAI,CAACY,EAAY,gBACf,MAAM,IAAI,MAAM,eAAeA,CAAW,iCAAiC,EAI7E,OAAAA,EAAY,gBAAkBD,EAAO,eAE9BD,EAAgB,CACrB,OAAAC,EACA,YAAAC,CACF,CAAC,CACH,CAoBA,MAAM,kCAAkCZ,EAItB,CAChB,GAAI,CACF,GAAM,CAAE,OAAAa,EAAQ,KAAAC,EAAM,QAAAC,CAAQ,EAAIf,EAC5BgB,EAAoB,IAAIC,EAAkB,KAAK,OAAQJ,CAAM,EAEnEG,EAAkB,MAAM,EAExB,QAAWE,KAAKJ,EAEd,MAAME,EAAkB,KAAKE,EAAGH,CAAO,CAE3C,OAASI,EAAY,CACnB,MAAM,IAAI,MAAM,6CAA6CA,CAAK,EAAE,CACtE,CACF,CAiBA,MAAM,yBAAyBnB,EAGS,CACtC,GAAM,CAAE,OAAAW,EAAQ,YAAAC,CAAY,EAAIZ,EAChC,OAAOoB,EAAyB,CAC9B,YAAa,KAAK,OAClB,OAAAT,EACA,YAAAC,CACF,CAAC,CACH,CACF","names":["Transaction","config","Build","Simulate","Submit","args","getTransactions","getTransactionByVersion","getTransactionByHash","isTransactionPending","waitForTransaction","getGasPriceEstimation","getSigningMessage","publicPackageTransaction","rotateAuthKey","signTransaction","signer","transaction","sender","data","options","transactionWorker","TransactionWorker","d","error","signAndSubmitTransaction"]}
@@ -1,2 +0,0 @@
1
- var o="1.4.0";export{o as a};
2
- //# sourceMappingURL=chunk-NXPN5XLB.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as l}from"./chunk-GGCQNE7J.mjs";import{a as o,b as c}from"./chunk-U6Z4FNB7.mjs";import{a as h,h as d}from"./chunk-JHKU4VAL.mjs";import{f as u}from"./chunk-7Z4DTVZN.mjs";var p="fulfilled",f=class{constructor(t,n,e=30,s=100,r=10){this.taskQueue=new o;this.transactionsQueue=new o;this.outstandingTransactions=new o;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=n,this.started=!1,this.accountSequnceNumber=new l(t,n,e,s,r)}async submitNextTransaction(){try{for(;;){if(this.transactionsQueue.isEmpty())return;let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let n=await this.generateNextTransaction(this.account,t);if(!n)return;let e=d({aptosConfig:this.aptosConfig,transaction:n,signer:this.account});await this.outstandingTransactions.enqueue([e,t])}}catch(t){if(t instanceof c)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],n=[],[e,s]=await this.outstandingTransactions.dequeue();for(t.push(e),n.push(s);!this.outstandingTransactions.isEmpty();)[e,s]=await this.outstandingTransactions.dequeue(),t.push(e),n.push(s);let r=await Promise.allSettled(t);for(let a=0;a<r.length&&a<n.length;a+=1){let i=r[a];s=n[a],i.status===p?(this.sentTransactions.push([i.value.hash,s,null]),await this.checkTransaction(i,s)):this.sentTransactions.push([i.status,s,i.reason])}}}catch(t){if(t instanceof c)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,n){try{let e=[];e.push(u({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let s=await Promise.allSettled(e);for(let r=0;r<s.length;r+=1){let a=s[r];a.status===p?this.executedTransactions.push([a.value.hash,n,null]):this.executedTransactions.push([a.status,n,a.reason])}}catch(e){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async push(t,n){await this.transactionsQueue.enqueue([t,n])}async generateNextTransaction(t,n){if(this.transactionsQueue.isEmpty())return;let[e,s]=await this.transactionsQueue.dequeue();return await h({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:e,options:{...s,accountSequenceNumber:n}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};export{f as a};
2
- //# sourceMappingURL=chunk-QLAW63UU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/transactions/management/transactionWorker.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\n\n/**\n * TransactionWorker provides a simple framework for receiving payloads to be processed.\n *\n * Once one `start()` the process and pushes a new transaction, the worker acquires\n * the current account's next sequence number (by using the AccountSequenceNumber class),\n * generates a signed transaction and pushes an async submission process into the `outstandingTransactions` queue.\n * At the same time, the worker processes transactions by reading the `outstandingTransactions` queue\n * and submits the next transaction to chain, it\n * 1) waits for resolution of the submission process or get pre-execution validation error\n * and 2) waits for the resolution of the execution process or get an execution error.\n * The worker fires events for any submission and/or execution success and/or failure.\n */\n\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { Account } from \"../../core\";\nimport { waitForTransaction } from \"../../internal/transaction\";\nimport { generateTransaction, signAndSubmitTransaction } from \"../../internal/transactionSubmission\";\nimport { PendingTransactionResponse, TransactionResponse } from \"../../types\";\nimport { InputGenerateTransactionOptions, InputGenerateTransactionPayloadData, SimpleTransaction } from \"../types\";\nimport { AccountSequenceNumber } from \"./accountSequenceNumber\";\nimport { AsyncQueue, AsyncQueueCancelledError } from \"./asyncQueue\";\n\nconst promiseFulfilledStatus = \"fulfilled\";\n\nexport class TransactionWorker {\n readonly aptosConfig: AptosConfig;\n\n readonly account: Account;\n\n // current account sequence number\n readonly accountSequnceNumber: AccountSequenceNumber;\n\n readonly taskQueue: AsyncQueue<() => Promise<void>> = new AsyncQueue<() => Promise<void>>();\n\n // process has started\n started: boolean;\n\n /**\n * transactions payloads waiting to be generated and signed\n *\n * TODO support entry function payload from ABI builder\n */\n transactionsQueue = new AsyncQueue<\n [InputGenerateTransactionPayloadData, InputGenerateTransactionOptions | undefined]\n >();\n\n /**\n * signed transactions waiting to be submitted\n */\n outstandingTransactions = new AsyncQueue<[Promise<PendingTransactionResponse>, bigint]>();\n\n /**\n * transactions that have been submitted to chain\n */\n sentTransactions: Array<[string, bigint, any]> = [];\n\n /**\n * transactions that have been committed to chain\n */\n executedTransactions: Array<[string, bigint, any]> = [];\n\n /**\n * Provides a simple framework for receiving payloads to be processed.\n *\n * @param aptosConfig - a config object\n * @param sender - a sender as Account\n * @param maxWaitTime - the max wait time to wait before resyncing the sequence number\n * to the current on-chain state, default to 30\n * @param maximumInFlight - submit up to `maximumInFlight` transactions per account.\n * Mempool limits the number of transactions per account to 100, hence why we default to 100.\n * @param sleepTime - If `maximumInFlight` are in flight, wait `sleepTime` seconds before re-evaluating, default to 10\n */\n constructor(\n aptosConfig: AptosConfig,\n account: Account,\n maxWaitTime: number = 30,\n maximumInFlight: number = 100,\n sleepTime: number = 10,\n ) {\n this.aptosConfig = aptosConfig;\n this.account = account;\n this.started = false;\n this.accountSequnceNumber = new AccountSequenceNumber(\n aptosConfig,\n account,\n maxWaitTime,\n maximumInFlight,\n sleepTime,\n );\n }\n\n /**\n * Gets the current account sequence number,\n * generates the transaction with the account sequence number,\n * adds the transaction to the outstanding transaction queue\n * to be processed later.\n */\n async submitNextTransaction() {\n try {\n /* eslint-disable no-constant-condition */\n while (true) {\n if (this.transactionsQueue.isEmpty()) return;\n const sequenceNumber = await this.accountSequnceNumber.nextSequenceNumber();\n if (sequenceNumber === null) return;\n const transaction = await this.generateNextTransaction(this.account, sequenceNumber);\n if (!transaction) return;\n const pendingTransaction = signAndSubmitTransaction({\n aptosConfig: this.aptosConfig,\n transaction,\n signer: this.account,\n });\n await this.outstandingTransactions.enqueue([pendingTransaction, sequenceNumber]);\n }\n } catch (error: any) {\n if (error instanceof AsyncQueueCancelledError) {\n return;\n }\n throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${error}`);\n }\n }\n\n /**\n * Reads the outstanding transaction queue and submits the transaction to chain.\n *\n * If the transaction has fulfilled, it pushes the transaction to the processed\n * transactions queue and fires a transactionsFulfilled event.\n *\n * If the transaction has failed, it pushes the transaction to the processed\n * transactions queue with the failure reason and fires a transactionsFailed event.\n */\n async processTransactions() {\n try {\n /* eslint-disable no-constant-condition */\n while (true) {\n const awaitingTransactions = [];\n const sequenceNumbers = [];\n let [pendingTransaction, sequenceNumber] = await this.outstandingTransactions.dequeue();\n\n awaitingTransactions.push(pendingTransaction);\n sequenceNumbers.push(sequenceNumber);\n\n while (!this.outstandingTransactions.isEmpty()) {\n [pendingTransaction, sequenceNumber] = await this.outstandingTransactions.dequeue();\n\n awaitingTransactions.push(pendingTransaction);\n sequenceNumbers.push(sequenceNumber);\n }\n // send awaiting transactions to chain\n const sentTransactions = await Promise.allSettled(awaitingTransactions);\n for (let i = 0; i < sentTransactions.length && i < sequenceNumbers.length; i += 1) {\n // check sent transaction status\n const sentTransaction = sentTransactions[i];\n sequenceNumber = sequenceNumbers[i];\n if (sentTransaction.status === promiseFulfilledStatus) {\n // transaction sent to chain\n this.sentTransactions.push([sentTransaction.value.hash, sequenceNumber, null]);\n // check sent transaction execution\n await this.checkTransaction(sentTransaction, sequenceNumber);\n } else {\n // send transaction failed\n this.sentTransactions.push([sentTransaction.status, sequenceNumber, sentTransaction.reason]);\n }\n }\n }\n } catch (error: any) {\n if (error instanceof AsyncQueueCancelledError) {\n return;\n }\n throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${error}`);\n }\n }\n\n /**\n * Once transaction has been sent to chain, we check for its execution status.\n * @param sentTransaction transactions that were sent to chain and are now waiting to be executed\n * @param sequenceNumber the account's sequence number that was sent with the transaction\n */\n async checkTransaction(sentTransaction: PromiseFulfilledResult<PendingTransactionResponse>, sequenceNumber: bigint) {\n try {\n const waitFor: Array<Promise<TransactionResponse>> = [];\n waitFor.push(waitForTransaction({ aptosConfig: this.aptosConfig, transactionHash: sentTransaction.value.hash }));\n const sentTransactions = await Promise.allSettled(waitFor);\n\n for (let i = 0; i < sentTransactions.length; i += 1) {\n const executedTransaction = sentTransactions[i];\n if (executedTransaction.status === promiseFulfilledStatus) {\n // transaction executed to chain\n this.executedTransactions.push([executedTransaction.value.hash, sequenceNumber, null]);\n } else {\n // transaction execution failed\n this.executedTransactions.push([executedTransaction.status, sequenceNumber, executedTransaction.reason]);\n }\n }\n } catch (error: any) {\n throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${error}`);\n }\n }\n\n /**\n * Push transaction to the transactions queue\n * @param payload Transaction payload\n */\n async push(\n transactionData: InputGenerateTransactionPayloadData,\n options?: InputGenerateTransactionOptions,\n ): Promise<void> {\n await this.transactionsQueue.enqueue([transactionData, options]);\n }\n\n /**\n * Generates a signed transaction that can be submitted to chain\n * @param account an Aptos account\n * @param sequenceNumber a sequence number the transaction will be generated with\n * @returns\n */\n async generateNextTransaction(account: Account, sequenceNumber: bigint): Promise<SimpleTransaction | undefined> {\n if (this.transactionsQueue.isEmpty()) return undefined;\n const [transactionData, options] = await this.transactionsQueue.dequeue();\n const transaction = await generateTransaction({\n aptosConfig: this.aptosConfig,\n sender: account.accountAddress,\n data: transactionData,\n options: { ...options, accountSequenceNumber: sequenceNumber },\n });\n\n return transaction;\n }\n\n /**\n * Starts transaction submission and transaction processing.\n */\n async run() {\n try {\n while (!this.taskQueue.isCancelled()) {\n const task = await this.taskQueue.dequeue();\n await task();\n }\n } catch (error: any) {\n throw new Error(`Unable to start transaction batching: ${error}`);\n }\n }\n\n /**\n * Starts the transaction management process.\n */\n start() {\n if (this.started) {\n throw new Error(\"worker has already started\");\n }\n this.started = true;\n this.taskQueue.enqueue(() => this.submitNextTransaction());\n this.taskQueue.enqueue(() => this.processTransactions());\n this.run();\n }\n\n /**\n * Stops the the transaction management process.\n */\n stop() {\n if (this.taskQueue.isCancelled()) {\n throw new Error(\"worker has already stopped\");\n }\n this.started = false;\n this.taskQueue.cancel();\n }\n}\n"],"mappings":"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","names":["promiseFulfilledStatus","TransactionWorker","aptosConfig","account","maxWaitTime","maximumInFlight","sleepTime","AsyncQueue","AccountSequenceNumber","sequenceNumber","transaction","pendingTransaction","signAndSubmitTransaction","error","AsyncQueueCancelledError","awaitingTransactions","sequenceNumbers","sentTransactions","i","sentTransaction","waitFor","waitForTransaction","executedTransaction","transactionData","options","generateTransaction"]}
@@ -1,2 +0,0 @@
1
- import{a as c}from"./chunk-DHR4YEUH.mjs";import{a as g}from"./chunk-I4EKXYTB.mjs";import{a as f}from"./chunk-4RFWMHWT.mjs";import{a as l}from"./chunk-XSM3SOZY.mjs";import{a as u}from"./chunk-MJW4JGUR.mjs";import{a as m}from"./chunk-ATV7SH7J.mjs";import{a as s}from"./chunk-3PPUHF6D.mjs";import{a as p}from"./chunk-YJQQF4GI.mjs";import{a as y}from"./chunk-4DI53MOX.mjs";import{a as r}from"./chunk-CBMEWHLK.mjs";import{a}from"./chunk-Q7B4KMTR.mjs";var t=class{constructor(i){this.config=new y(i),this.account=new s(this.config),this.ans=new p(this.config),this.coin=new r(this.config),this.digitalAsset=new a(this.config),this.event=new c(this.config),this.faucet=new g(this.config),this.fungibleAsset=new f(this.config),this.general=new l(this.config),this.staking=new u(this.config),this.transaction=new m(this.config)}};function n(h,i,A){Object.getOwnPropertyNames(i.prototype).forEach(e=>{let o=Object.getOwnPropertyDescriptor(i.prototype,e);o&&(o.value=function(...d){return this[A][e](...d)},Object.defineProperty(h.prototype,e,o))})}n(t,s,"account");n(t,p,"ans");n(t,r,"coin");n(t,a,"digitalAsset");n(t,c,"event");n(t,g,"faucet");n(t,f,"fungibleAsset");n(t,l,"general");n(t,u,"staking");n(t,m,"transaction");export{t as a};
2
- //# sourceMappingURL=chunk-RVQGLEBY.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/aptos.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"./account\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Coin } from \"./coin\";\nimport { DigitalAsset } from \"./digitalAsset\";\nimport { Event } from \"./event\";\nimport { Faucet } from \"./faucet\";\nimport { FungibleAsset } from \"./fungibleAsset\";\nimport { General } from \"./general\";\nimport { ANS } from \"./ans\";\nimport { Staking } from \"./staking\";\nimport { Transaction } from \"./transaction\";\n\n/**\n * This class is the main entry point into Aptos's\n * APIs and separates functionality into different namespaces.\n *\n * To use the SDK, create a new Aptos instance to get access\n * to all the sdk functionality.\n */\nexport class Aptos {\n readonly config: AptosConfig;\n\n readonly account: Account;\n\n readonly ans: ANS;\n\n readonly coin: Coin;\n\n readonly digitalAsset: DigitalAsset;\n\n readonly event: Event;\n\n readonly faucet: Faucet;\n\n readonly fungibleAsset: FungibleAsset;\n\n readonly general: General;\n\n readonly staking: Staking;\n\n readonly transaction: Transaction;\n\n constructor(settings?: AptosConfig) {\n this.config = new AptosConfig(settings);\n this.account = new Account(this.config);\n this.ans = new ANS(this.config);\n this.coin = new Coin(this.config);\n this.digitalAsset = new DigitalAsset(this.config);\n this.event = new Event(this.config);\n this.faucet = new Faucet(this.config);\n this.fungibleAsset = new FungibleAsset(this.config);\n this.general = new General(this.config);\n this.staking = new Staking(this.config);\n this.transaction = new Transaction(this.config);\n }\n}\n\n// extends Aptos interface so all the methods and properties\n// from the other classes will be recognized by typescript.\nexport interface Aptos\n extends Account,\n ANS,\n Coin,\n DigitalAsset,\n Event,\n Faucet,\n FungibleAsset,\n General,\n Staking,\n Omit<Transaction, \"build\" | \"simulate\" | \"submit\"> {}\n\n/**\nIn TypeScript, we can’t inherit or extend from more than one class,\nMixins helps us to get around that by creating a partial classes\nthat we can combine to form a single class that contains all the methods and properties from the partial classes.\n{@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n\nHere, we combine any subclass and the Aptos class.\n*/\nfunction applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {\n // Mixin instance methods\n Object.getOwnPropertyNames(baseClass.prototype).forEach((propertyName) => {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName);\n if (!propertyDescriptor) return;\n // eslint-disable-next-line func-names\n propertyDescriptor.value = function (...args: any) {\n return (this as any)[baseClassProp][propertyName](...args);\n };\n Object.defineProperty(targetClass.prototype, propertyName, propertyDescriptor);\n });\n}\n\napplyMixin(Aptos, Account, \"account\");\napplyMixin(Aptos, ANS, \"ans\");\napplyMixin(Aptos, Coin, \"coin\");\napplyMixin(Aptos, DigitalAsset, \"digitalAsset\");\napplyMixin(Aptos, Event, \"event\");\napplyMixin(Aptos, Faucet, \"faucet\");\napplyMixin(Aptos, FungibleAsset, \"fungibleAsset\");\napplyMixin(Aptos, General, \"general\");\napplyMixin(Aptos, Staking, \"staking\");\napplyMixin(Aptos, Transaction, \"transaction\");\n"],"mappings":"8bAsBO,IAAMA,EAAN,KAAY,CAuBjB,YAAYC,EAAwB,CAClC,KAAK,OAAS,IAAIC,EAAYD,CAAQ,EACtC,KAAK,QAAU,IAAIE,EAAQ,KAAK,MAAM,EACtC,KAAK,IAAM,IAAIC,EAAI,KAAK,MAAM,EAC9B,KAAK,KAAO,IAAIC,EAAK,KAAK,MAAM,EAChC,KAAK,aAAe,IAAIC,EAAa,KAAK,MAAM,EAChD,KAAK,MAAQ,IAAIC,EAAM,KAAK,MAAM,EAClC,KAAK,OAAS,IAAIC,EAAO,KAAK,MAAM,EACpC,KAAK,cAAgB,IAAIC,EAAc,KAAK,MAAM,EAClD,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,EACtC,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,EACtC,KAAK,YAAc,IAAIC,EAAY,KAAK,MAAM,CAChD,CACF,EAwBA,SAASC,EAAWC,EAAkBC,EAAgBC,EAAuB,CAE3E,OAAO,oBAAoBD,EAAU,SAAS,EAAE,QAASE,GAAiB,CACxE,IAAMC,EAAqB,OAAO,yBAAyBH,EAAU,UAAWE,CAAY,EACvFC,IAELA,EAAmB,MAAQ,YAAaC,EAAW,CACjD,OAAQ,KAAaH,CAAa,EAAEC,CAAY,EAAE,GAAGE,CAAI,CAC3D,EACA,OAAO,eAAeL,EAAY,UAAWG,EAAcC,CAAkB,EAC/E,CAAC,CACH,CAEAL,EAAWb,EAAOG,EAAS,SAAS,EACpCU,EAAWb,EAAOI,EAAK,KAAK,EAC5BS,EAAWb,EAAOK,EAAM,MAAM,EAC9BQ,EAAWb,EAAOM,EAAc,cAAc,EAC9CO,EAAWb,EAAOO,EAAO,OAAO,EAChCM,EAAWb,EAAOQ,EAAQ,QAAQ,EAClCK,EAAWb,EAAOS,EAAe,eAAe,EAChDI,EAAWb,EAAOU,EAAS,SAAS,EACpCG,EAAWb,EAAOW,EAAS,SAAS,EACpCE,EAAWb,EAAOY,EAAa,aAAa","names":["Aptos","settings","AptosConfig","Account","ANS","Coin","DigitalAsset","Event","Faucet","FungibleAsset","General","Staking","Transaction","applyMixin","targetClass","baseClass","baseClassProp","propertyName","propertyDescriptor","args"]}