@algorandfoundation/algokit-utils 10.0.0-alpha.2 → 10.0.0-alpha.21

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 (462) hide show
  1. package/_virtual/rolldown_runtime.js +10 -15
  2. package/algo25/index.d.ts +2 -0
  3. package/algo25/index.js +9 -0
  4. package/algo25/index.mjs +3 -0
  5. package/algod-client/index.d.ts +3 -7
  6. package/algod-client/index.js +2 -5
  7. package/algod-client/index.mjs +2 -2
  8. package/index.d.ts +1 -2
  9. package/index.js +0 -7
  10. package/index.mjs +1 -2
  11. package/indexer-client/index.d.ts +2 -2
  12. package/indexer-client/index.js +6 -6
  13. package/indexer-client/index.mjs +2 -2
  14. package/{indexer-lookup.d.ts → indexer-client/indexer-lookup.d.ts} +8 -11
  15. package/{indexer-lookup.mjs → indexer-client/indexer-lookup.js} +6 -10
  16. package/indexer-client/indexer-lookup.js.map +1 -0
  17. package/{indexer-lookup.js → indexer-client/indexer-lookup.mjs} +3 -18
  18. package/indexer-client/indexer-lookup.mjs.map +1 -0
  19. package/kmd-client/index.d.ts +1 -2
  20. package/kmd-client/index.js +0 -5
  21. package/kmd-client/index.mjs +1 -2
  22. package/package.json +1 -6
  23. package/packages/abi/src/abi-method.d.ts +1 -1
  24. package/packages/abi/src/abi-method.js +1 -1
  25. package/packages/abi/src/abi-method.js.map +1 -1
  26. package/packages/abi/src/abi-method.mjs +1 -1
  27. package/packages/abi/src/abi-method.mjs.map +1 -1
  28. package/packages/abi/src/abi-type.d.ts +1 -1
  29. package/packages/abi/src/abi-type.js +4 -2
  30. package/packages/abi/src/abi-type.js.map +1 -1
  31. package/packages/abi/src/abi-type.mjs +4 -2
  32. package/packages/abi/src/abi-type.mjs.map +1 -1
  33. package/packages/abi/src/arc56-contract.js +1 -0
  34. package/packages/abi/src/arc56-contract.js.map +1 -1
  35. package/packages/abi/src/arc56-contract.mjs +1 -0
  36. package/packages/abi/src/arc56-contract.mjs.map +1 -1
  37. package/packages/algo25/src/index.d.ts +40 -0
  38. package/packages/algo25/src/index.js +45 -1
  39. package/packages/algo25/src/index.js.map +1 -1
  40. package/packages/algo25/src/index.mjs +40 -2
  41. package/packages/algo25/src/index.mjs.map +1 -1
  42. package/packages/algod_client/src/apis/api-service.d.ts +44 -44
  43. package/packages/algod_client/src/apis/api-service.js +155 -155
  44. package/packages/algod_client/src/apis/api-service.js.map +1 -1
  45. package/packages/algod_client/src/apis/api-service.mjs +155 -155
  46. package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
  47. package/packages/algod_client/src/core/api-error.js +3 -1
  48. package/packages/algod_client/src/core/api-error.js.map +1 -1
  49. package/packages/algod_client/src/core/api-error.mjs +3 -1
  50. package/packages/algod_client/src/core/api-error.mjs.map +1 -1
  51. package/packages/algod_client/src/core/model-runtime.js +6 -6
  52. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  53. package/packages/algod_client/src/core/model-runtime.mjs +8 -8
  54. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  55. package/packages/algod_client/src/models/account-participation.js +4 -4
  56. package/packages/algod_client/src/models/account-participation.js.map +1 -1
  57. package/packages/algod_client/src/models/account-participation.mjs +4 -4
  58. package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
  59. package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
  60. package/packages/algod_client/src/models/application-state-schema.js +2 -2
  61. package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
  62. package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
  63. package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
  64. package/packages/algod_client/src/models/asset-params.js +2 -1
  65. package/packages/algod_client/src/models/asset-params.js.map +1 -1
  66. package/packages/algod_client/src/models/asset-params.mjs +2 -1
  67. package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
  68. package/packages/algod_client/src/models/block-response.js +1 -2
  69. package/packages/algod_client/src/models/block-response.js.map +1 -1
  70. package/packages/algod_client/src/models/block-response.mjs +2 -3
  71. package/packages/algod_client/src/models/block-response.mjs.map +1 -1
  72. package/packages/algod_client/src/models/block.d.ts +60 -40
  73. package/packages/algod_client/src/models/block.js +184 -108
  74. package/packages/algod_client/src/models/block.js.map +1 -1
  75. package/packages/algod_client/src/models/block.mjs +184 -108
  76. package/packages/algod_client/src/models/block.mjs.map +1 -1
  77. package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
  78. package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
  79. package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
  80. package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
  81. package/packages/algod_client/src/models/simulate-request.js +1 -1
  82. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  83. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  84. package/packages/algod_client/src/models/simulate-response.js +6 -1
  85. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  86. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  87. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  88. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
  89. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
  90. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
  91. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
  92. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
  93. package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
  94. package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
  95. package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
  96. package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
  97. package/packages/common/src/address.js +0 -14
  98. package/packages/common/src/address.js.map +1 -1
  99. package/packages/common/src/address.mjs +1 -14
  100. package/packages/common/src/address.mjs.map +1 -1
  101. package/packages/common/src/codecs/composite/map.js +7 -4
  102. package/packages/common/src/codecs/composite/map.js.map +1 -1
  103. package/packages/common/src/codecs/composite/map.mjs +7 -4
  104. package/packages/common/src/codecs/composite/map.mjs.map +1 -1
  105. package/packages/common/src/codecs/composite/record.js +0 -1
  106. package/packages/common/src/codecs/composite/record.js.map +1 -1
  107. package/packages/common/src/codecs/primitives/address.js +0 -1
  108. package/packages/common/src/codecs/primitives/address.js.map +1 -1
  109. package/packages/common/src/codecs/primitives/bytes.js +0 -1
  110. package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
  111. package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
  112. package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
  113. package/packages/common/src/codecs/wire.js +0 -1
  114. package/packages/common/src/codecs/wire.js.map +1 -1
  115. package/packages/common/src/json.mjs +2 -2
  116. package/packages/common/src/json.mjs.map +1 -1
  117. package/packages/common/src/msgpack.js +0 -1
  118. package/packages/common/src/msgpack.js.map +1 -1
  119. package/packages/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
  120. package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
  121. package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
  122. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
  123. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.map +1 -1
  124. package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
  125. package/packages/indexer_client/src/apis/api-service.js +12 -12
  126. package/packages/indexer_client/src/apis/api-service.js.map +1 -1
  127. package/packages/indexer_client/src/apis/api-service.mjs +12 -12
  128. package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
  129. package/packages/indexer_client/src/core/api-error.js +3 -1
  130. package/packages/indexer_client/src/core/api-error.js.map +1 -1
  131. package/packages/indexer_client/src/core/api-error.mjs +3 -1
  132. package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
  133. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  134. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  135. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  136. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  137. package/packages/indexer_client/src/models/account-participation.js +4 -4
  138. package/packages/indexer_client/src/models/account-participation.js.map +1 -1
  139. package/packages/indexer_client/src/models/account-participation.mjs +4 -4
  140. package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
  141. package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
  142. package/packages/indexer_client/src/models/application-state-schema.js +2 -2
  143. package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
  144. package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
  145. package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
  146. package/packages/indexer_client/src/models/asset-params.js +2 -1
  147. package/packages/indexer_client/src/models/asset-params.js.map +1 -1
  148. package/packages/indexer_client/src/models/asset-params.mjs +2 -1
  149. package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
  150. package/packages/indexer_client/src/models/block.d.ts +5 -5
  151. package/packages/indexer_client/src/models/block.js +13 -13
  152. package/packages/indexer_client/src/models/block.js.map +1 -1
  153. package/packages/indexer_client/src/models/block.mjs +13 -13
  154. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  155. package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
  156. package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
  157. package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
  158. package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
  159. package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
  160. package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
  161. package/packages/indexer_client/src/models/eval-delta.js +2 -2
  162. package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
  163. package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
  164. package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
  165. package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
  166. package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
  167. package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
  168. package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
  169. package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
  170. package/packages/indexer_client/src/models/participation-updates.js +2 -2
  171. package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
  172. package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
  173. package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
  174. package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
  175. package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
  176. package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
  177. package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
  178. package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
  179. package/packages/indexer_client/src/models/state-schema.js +2 -2
  180. package/packages/indexer_client/src/models/state-schema.js.map +1 -1
  181. package/packages/indexer_client/src/models/state-schema.mjs +2 -2
  182. package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
  183. package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
  184. package/packages/indexer_client/src/models/teal-key-value.js +2 -2
  185. package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
  186. package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
  187. package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
  188. package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
  189. package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
  190. package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
  191. package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
  192. package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
  193. package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
  194. package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
  195. package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
  196. package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
  197. package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
  198. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
  199. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
  200. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
  201. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
  202. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
  203. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
  204. package/packages/indexer_client/src/models/transaction.d.ts +2 -2
  205. package/packages/indexer_client/src/models/transaction.js +6 -5
  206. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  207. package/packages/indexer_client/src/models/transaction.mjs +6 -5
  208. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  209. package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
  210. package/packages/kmd_client/src/apis/api-service.js +32 -32
  211. package/packages/kmd_client/src/apis/api-service.js.map +1 -1
  212. package/packages/kmd_client/src/apis/api-service.mjs +32 -32
  213. package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
  214. package/packages/kmd_client/src/core/api-error.js +3 -1
  215. package/packages/kmd_client/src/core/api-error.js.map +1 -1
  216. package/packages/kmd_client/src/core/api-error.mjs +3 -1
  217. package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
  218. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  219. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  220. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  221. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  222. package/packages/transact/src/logicsig.d.ts +3 -15
  223. package/packages/transact/src/logicsig.js +16 -36
  224. package/packages/transact/src/logicsig.js.map +1 -1
  225. package/packages/transact/src/logicsig.mjs +18 -36
  226. package/packages/transact/src/logicsig.mjs.map +1 -1
  227. package/packages/transact/src/multisig.d.ts +7 -115
  228. package/packages/transact/src/multisig.js +86 -136
  229. package/packages/transact/src/multisig.js.map +1 -1
  230. package/packages/transact/src/multisig.mjs +87 -117
  231. package/packages/transact/src/multisig.mjs.map +1 -1
  232. package/packages/transact/src/transactions/app-call.d.ts +10 -15
  233. package/packages/transact/src/transactions/app-call.js.map +1 -1
  234. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  235. package/packages/transact/src/transactions/asset-config.d.ts +1 -6
  236. package/packages/transact/src/transactions/asset-config.js.map +1 -1
  237. package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
  238. package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
  239. package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
  240. package/packages/transact/src/transactions/key-registration.d.ts +1 -8
  241. package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
  242. package/packages/transact/src/transactions/reference-types-meta.js +71 -0
  243. package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
  244. package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
  245. package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
  246. package/packages/transact/src/transactions/signed-transaction-meta.js +2 -3
  247. package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
  248. package/packages/transact/src/transactions/signed-transaction-meta.mjs +3 -3
  249. package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
  250. package/packages/transact/src/transactions/signed-transaction.d.ts +7 -3
  251. package/packages/transact/src/transactions/signed-transaction.js +1 -1
  252. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  253. package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
  254. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  255. package/packages/transact/src/transactions/transaction-meta.js +29 -23
  256. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  257. package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
  258. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  259. package/packages/transact/src/transactions/transaction.d.ts +5 -1
  260. package/packages/transact/src/transactions/transaction.js +1 -1
  261. package/packages/transact/src/transactions/transaction.js.map +1 -1
  262. package/packages/transact/src/transactions/transaction.mjs +1 -1
  263. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  264. package/testing/account.js +2 -5
  265. package/testing/account.js.map +1 -1
  266. package/testing/account.mjs +2 -5
  267. package/testing/account.mjs.map +1 -1
  268. package/testing/fixtures/algorand-fixture.d.ts +3 -3
  269. package/testing/fixtures/algorand-fixture.js.map +1 -1
  270. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  271. package/testing/transaction-logger.js +1 -1
  272. package/testing/transaction-logger.mjs +1 -1
  273. package/transact/index.d.ts +11 -10
  274. package/transact/index.js +7 -32
  275. package/transact/index.mjs +7 -10
  276. package/transaction/transaction.js +2 -2
  277. package/transaction/transaction.js.map +1 -1
  278. package/transaction/transaction.mjs +2 -2
  279. package/transaction/transaction.mjs.map +1 -1
  280. package/transactions/app-call.d.ts +5 -4
  281. package/transactions/app-call.js +16 -16
  282. package/transactions/app-call.js.map +1 -1
  283. package/transactions/app-call.mjs +16 -16
  284. package/transactions/app-call.mjs.map +1 -1
  285. package/transactions/asset-config.d.ts +1 -1
  286. package/transactions/asset-config.js +1 -1
  287. package/transactions/asset-config.js.map +1 -1
  288. package/transactions/asset-config.mjs +1 -1
  289. package/transactions/asset-config.mjs.map +1 -1
  290. package/transactions/key-registration.d.ts +1 -1
  291. package/transactions/key-registration.js.map +1 -1
  292. package/transactions/key-registration.mjs.map +1 -1
  293. package/transactions/method-call.d.ts +1 -1
  294. package/transactions/method-call.js +70 -78
  295. package/transactions/method-call.js.map +1 -1
  296. package/transactions/method-call.mjs +70 -78
  297. package/transactions/method-call.mjs.map +1 -1
  298. package/types/account-manager.d.ts +1 -1
  299. package/types/account-manager.js +5 -5
  300. package/types/account-manager.js.map +1 -1
  301. package/types/account-manager.mjs +5 -5
  302. package/types/account-manager.mjs.map +1 -1
  303. package/types/algorand-client-transaction-creator.d.ts +74 -60
  304. package/types/algorand-client-transaction-creator.js +8 -0
  305. package/types/algorand-client-transaction-creator.js.map +1 -1
  306. package/types/algorand-client-transaction-creator.mjs +8 -0
  307. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  308. package/types/algorand-client-transaction-sender.d.ts +79 -65
  309. package/types/algorand-client-transaction-sender.js +8 -1
  310. package/types/algorand-client-transaction-sender.js.map +1 -1
  311. package/types/algorand-client-transaction-sender.mjs +8 -0
  312. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  313. package/types/amount.js +23 -4
  314. package/types/amount.js.map +1 -1
  315. package/types/amount.mjs +20 -2
  316. package/types/amount.mjs.map +1 -1
  317. package/types/app-client.d.ts +174 -169
  318. package/types/app-client.js +2 -3
  319. package/types/app-client.js.map +1 -1
  320. package/types/app-client.mjs +2 -2
  321. package/types/app-client.mjs.map +1 -1
  322. package/types/app-deployer.d.ts +1 -1
  323. package/types/app-deployer.js +3 -3
  324. package/types/app-deployer.js.map +1 -1
  325. package/types/app-deployer.mjs +3 -3
  326. package/types/app-deployer.mjs.map +1 -1
  327. package/types/app-factory.d.ts +70 -67
  328. package/types/app-factory.js +2 -2
  329. package/types/app-factory.js.map +1 -1
  330. package/types/app-factory.mjs +2 -2
  331. package/types/app-factory.mjs.map +1 -1
  332. package/types/app-manager.d.ts +3 -1
  333. package/types/app-manager.js +17 -11
  334. package/types/app-manager.js.map +1 -1
  335. package/types/app-manager.mjs +17 -11
  336. package/types/app-manager.mjs.map +1 -1
  337. package/types/app-spec.js +12 -5
  338. package/types/app-spec.js.map +1 -1
  339. package/types/app-spec.mjs +12 -5
  340. package/types/app-spec.mjs.map +1 -1
  341. package/types/app.d.ts +2 -2
  342. package/types/app.js.map +1 -1
  343. package/types/app.mjs.map +1 -1
  344. package/types/asset-manager.js +1 -1
  345. package/types/asset-manager.js.map +1 -1
  346. package/types/asset-manager.mjs +1 -1
  347. package/types/asset-manager.mjs.map +1 -1
  348. package/types/async-event-emitter.d.ts +3 -6
  349. package/types/async-event-emitter.js.map +1 -1
  350. package/types/async-event-emitter.mjs.map +1 -1
  351. package/types/client-manager.d.ts +1 -1
  352. package/types/client-manager.js.map +1 -1
  353. package/types/client-manager.mjs.map +1 -1
  354. package/types/composer.d.ts +9 -1
  355. package/types/composer.js +49 -37
  356. package/types/composer.js.map +1 -1
  357. package/types/composer.mjs +40 -27
  358. package/types/composer.mjs.map +1 -1
  359. package/types/debugging.d.ts +13 -9
  360. package/types/debugging.js.map +1 -1
  361. package/types/debugging.mjs.map +1 -1
  362. package/types/expand.d.ts +2 -9
  363. package/types/kmd-account-manager.d.ts +1 -0
  364. package/types/kmd-account-manager.js +22 -11
  365. package/types/kmd-account-manager.js.map +1 -1
  366. package/types/kmd-account-manager.mjs +23 -12
  367. package/types/kmd-account-manager.mjs.map +1 -1
  368. package/types/lifecycle-events.d.ts +0 -1
  369. package/types/lifecycle-events.js.map +1 -1
  370. package/types/lifecycle-events.mjs.map +1 -1
  371. package/types/testing.d.ts +2 -2
  372. package/types/transaction.d.ts +1 -1
  373. package/_virtual/rolldown_runtime.mjs +0 -13
  374. package/indexer-lookup.js.map +0 -1
  375. package/indexer-lookup.mjs.map +0 -1
  376. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  377. package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
  378. package/packages/algod_client/src/models/application-local-reference.js +0 -23
  379. package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
  380. package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
  381. package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
  382. package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
  383. package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
  384. package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
  385. package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
  386. package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
  387. package/packages/algod_client/src/models/box-reference.d.ts +0 -17
  388. package/packages/algod_client/src/models/box-reference.js +0 -23
  389. package/packages/algod_client/src/models/box-reference.js.map +0 -1
  390. package/packages/algod_client/src/models/box-reference.mjs +0 -23
  391. package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
  392. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  393. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  394. package/packages/sdk/src/convert.d.ts +0 -17
  395. package/packages/sdk/src/convert.js +0 -28
  396. package/packages/sdk/src/convert.js.map +0 -1
  397. package/packages/sdk/src/convert.mjs +0 -25
  398. package/packages/sdk/src/convert.mjs.map +0 -1
  399. package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
  400. package/packages/sdk/src/encoding/binarydata.js +0 -65
  401. package/packages/sdk/src/encoding/binarydata.js.map +0 -1
  402. package/packages/sdk/src/encoding/binarydata.mjs +0 -60
  403. package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
  404. package/packages/sdk/src/encoding/encoding.d.ts +0 -237
  405. package/packages/sdk/src/encoding/encoding.js +0 -302
  406. package/packages/sdk/src/encoding/encoding.js.map +0 -1
  407. package/packages/sdk/src/encoding/encoding.mjs +0 -287
  408. package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
  409. package/packages/sdk/src/encoding/schema/array.js +0 -35
  410. package/packages/sdk/src/encoding/schema/array.js.map +0 -1
  411. package/packages/sdk/src/encoding/schema/array.mjs +0 -35
  412. package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
  413. package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
  414. package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
  415. package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
  416. package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
  417. package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
  418. package/packages/sdk/src/encoding/schema/map.js +0 -110
  419. package/packages/sdk/src/encoding/schema/map.js.map +0 -1
  420. package/packages/sdk/src/encoding/schema/map.mjs +0 -107
  421. package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
  422. package/packages/sdk/src/encoding/schema/optional.js +0 -46
  423. package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
  424. package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
  425. package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
  426. package/packages/sdk/src/encoding/schema/uint64.js +0 -30
  427. package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
  428. package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
  429. package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
  430. package/packages/sdk/src/encoding/uint64.d.ts +0 -34
  431. package/packages/sdk/src/encoding/uint64.js +0 -34
  432. package/packages/sdk/src/encoding/uint64.js.map +0 -1
  433. package/packages/sdk/src/encoding/uint64.mjs +0 -33
  434. package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
  435. package/packages/sdk/src/index.d.ts +0 -44
  436. package/packages/sdk/src/index.js +0 -62
  437. package/packages/sdk/src/index.js.map +0 -1
  438. package/packages/sdk/src/index.mjs +0 -58
  439. package/packages/sdk/src/index.mjs.map +0 -1
  440. package/packages/sdk/src/nacl/naclWrappers.js +0 -14
  441. package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
  442. package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
  443. package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
  444. package/packages/sdk/src/types/intDecoding.d.ts +0 -28
  445. package/packages/sdk/src/types/intDecoding.js +0 -32
  446. package/packages/sdk/src/types/intDecoding.js.map +0 -1
  447. package/packages/sdk/src/types/intDecoding.mjs +0 -31
  448. package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
  449. package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
  450. package/packages/sdk/src/types/transactions/encoded.js +0 -64
  451. package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
  452. package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
  453. package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
  454. package/packages/sdk/src/utils/utils.d.ts +0 -64
  455. package/packages/sdk/src/utils/utils.js +0 -140
  456. package/packages/sdk/src/utils/utils.js.map +0 -1
  457. package/packages/sdk/src/utils/utils.mjs +0 -128
  458. package/packages/sdk/src/utils/utils.mjs.map +0 -1
  459. package/packages/transact/src/transactions/common.d.ts +0 -37
  460. package/sdk/index.d.ts +0 -10
  461. package/sdk/index.js +0 -59
  462. package/sdk/index.mjs +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n validateTransaction(transaction)\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;;CAUA;;;;;;CAOA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;CAEA,YAAY,QAA2B;AACrC,OAAK,cAAc;AACnB,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO;AACrB,OAAK,MAAM,OAAO;AAClB,OAAK,aAAa,OAAO;AACzB,OAAK,YAAY,OAAO;AACxB,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,OAAO,OAAO;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,QAAQ,OAAO;AACpB,OAAK,QAAQ,OAAO;AACpB,OAAK,UAAU,OAAO;AACtB,OAAK,gBAAgB,OAAO;AAC5B,OAAK,cAAc,OAAO;AAC1B,OAAK,UAAU,OAAO;AACtB,OAAK,kBAAkB,OAAO;AAC9B,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,aAAa,OAAO;;CAG3B,AAAQ,UAAsB;AAE5B,SAAO,KADc,kBAAkB,KAAK,CACnB;;;;;CAM3B,OAAe;EACb,MAAM,UAAU,KAAK,SAAS;AAE9B,SAAO,OAAO,OAAO,QAAQ,CAAC,MAAM,GAAG,sBAAsB;;CAG/D,QAAQ,OAAO,a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aAAa,aAAa;AACxC,QAAO,aAAa,KACjB,OACC,IAAI,YAAY;EACd,GAAG;EACH;EACD,CAAC,CACL;;AAGH,SAAgB,UAAU,aAA0B,WAAmC;CACrF,MAAM,MAAM,aAAa,aAAa,UAAU;AAChD,QAAO,IAAI,YAAY;EACrB,GAAG;EACH;EACD,CAAC;;AAGJ,SAAS,aAAa,cAAyC;AAC7D,KAAI,aAAa,WAAW,EAC1B,OAAM,IAAI,MAAM,qCAAqC;AAGvD,KAAI,aAAa,SAAS,2BACxB,OAAM,IAAI,MAAM,mDAAmD,6BAA6B;CAGlG,MAAM,WAAW,aAAa,KAAK,OAAO;AACxC,MAAI,GAAG,MACL,OAAM,IAAI,MAAM,2CAA2C;AAI7D,SAAO,KADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAO,KADe,aALF,IAAI,aAAa,CAAC,OAAO,mCAAmC,EAC3D,cAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
1
+ {"version":3,"file":"transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;;CAUA;;;;;;CAOA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;CAEA,YAAY,QAA2B;AACrC,OAAK,cAAc;AACnB,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO;AACrB,OAAK,MAAM,OAAO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B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
@@ -8,7 +8,7 @@ async function getTestAccount({ suppressLog, initialFunds, accountGetter }, algo
8
8
  algod: algodOrAlgorandClient,
9
9
  kmd
10
10
  });
11
- const account = accountGetter ? await accountGetter(algorand) : algorand.account.random();
11
+ const account = accountGetter ? await accountGetter(algorand) : algorand.account.random().account;
12
12
  require_config.Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`);
13
13
  const dispenser = await algorand.account.dispenserFromEnvironment();
14
14
  await algorand.send.payment({
@@ -21,10 +21,7 @@ async function getTestAccount({ suppressLog, initialFunds, accountGetter }, algo
21
21
  const accountInfo = await algorand.account.getInformation(account.addr);
22
22
  require_config.Config.getLogger(suppressLog).info("Test account funded; account balance: %d µALGO", accountInfo.balance.microAlgo);
23
23
  algorand.setSignerFromAccount(account);
24
- const address = require_address.Address.fromString(account.addr.toString());
25
- address.addr = account.addr;
26
- address.signer = algorand.account.getSigner(address);
27
- return address;
24
+ return Object.assign(require_address.Address.fromString(account.addr.toString()), account);
28
25
  }
29
26
 
30
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","names":["AlgorandClient","Address"],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from '../types/testing'\n\n/**\n * @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.\n *\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algod An algod client\n * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables and if not found fallback to the default LocalNet KMD client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(\n params: GetTestAccountParams,\n algod: AlgodClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner>\n/**\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algorand An AlgorandClient client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(params: GetTestAccountParams, algorand: AlgorandClient): Promise<Address & AddressWithSigners>\nexport async function getTestAccount(\n { suppressLog, initialFunds, accountGetter }: GetTestAccountParams,\n algodOrAlgorandClient: AlgodClient | AlgorandClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner> {\n const algorand =\n algodOrAlgorandClient instanceof AlgorandClient\n ? algodOrAlgorandClient\n : AlgorandClient.fromClients({\n algod: algodOrAlgorandClient,\n kmd,\n })\n\n const account = accountGetter ? await accountGetter(algorand) : algorand.account.random()\n\n Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`)\n\n const dispenser = await algorand.account.dispenserFromEnvironment()\n\n await algorand.send.payment({\n sender: dispenser,\n receiver: account.addr,\n amount: initialFunds,\n note: 'Funding test account',\n suppressLog,\n })\n\n const accountInfo = await algorand.account.getInformation(account.addr)\n\n Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo)\n\n algorand.setSignerFromAccount(account)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const address = Address.fromString(account.addr.toString()) as any\n address.addr = account.addr\n address.signer = algorand.account.getSigner(address)\n\n return address\n}\n"],"mappings":";;;;;AAkCA,eAAsB,eACpB,EAAE,aAAa,cAAc,iBAC7B,uBACA,KACiD;CACjD,MAAM,WACJ,iCAAiCA,yCAC7B,wBACAA,uCAAe,YAAY;EACzB,OAAO;EACP;EACD,CAAC;CAER,MAAM,UAAU,gBAAgB,MAAM,cAAc,SAAS,GAAG,SAAS,QAAQ,QAAQ;AAEzF,uBAAO,UAAU,YAAY,CAAC,KAAK,0CAA0C,QAAQ,KAAK,IAAI;CAE9F,MAAM,YAAY,MAAM,SAAS,QAAQ,0BAA0B;AAEnE,OAAM,SAAS,KAAK,QAAQ;EAC1B,QAAQ;EACR,UAAU,QAAQ;EAClB,QAAQ;EACR,MAAM;EACN;EACD,CAAC;CAEF,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe,QAAQ,KAAK;AAEvE,uBAAO,UAAU,YAAY,CAAC,KAAK,kDAAkD,YAAY,QAAQ,UAAU;AAEnH,UAAS,qBAAqB,QAAQ;CAGtC,MAAM,UAAUC,wBAAQ,WAAW,QAAQ,KAAK,UAAU,CAAC;AAC3D,SAAQ,OAAO,QAAQ;AACvB,SAAQ,SAAS,SAAS,QAAQ,UAAU,QAAQ;AAEpD,QAAO"}
1
+ {"version":3,"file":"account.js","names":["AlgorandClient","Address"],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from '../types/testing'\n\n/**\n * @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.\n *\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algod An algod client\n * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables and if not found fallback to the default LocalNet KMD client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(\n params: GetTestAccountParams,\n algod: AlgodClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner>\n/**\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algorand An AlgorandClient client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(params: GetTestAccountParams, algorand: AlgorandClient): Promise<Address & AddressWithSigners>\nexport async function getTestAccount(\n { suppressLog, initialFunds, accountGetter }: GetTestAccountParams,\n algodOrAlgorandClient: AlgodClient | AlgorandClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner> {\n const algorand =\n algodOrAlgorandClient instanceof AlgorandClient\n ? algodOrAlgorandClient\n : AlgorandClient.fromClients({\n algod: algodOrAlgorandClient,\n kmd,\n })\n\n const account = accountGetter ? await accountGetter(algorand) : algorand.account.random().account\n\n Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`)\n\n const dispenser = await algorand.account.dispenserFromEnvironment()\n\n await algorand.send.payment({\n sender: dispenser,\n receiver: account.addr,\n amount: initialFunds,\n note: 'Funding test account',\n suppressLog,\n })\n\n const accountInfo = await algorand.account.getInformation(account.addr)\n\n Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo)\n\n algorand.setSignerFromAccount(account)\n\n return Object.assign(Address.fromString(account.addr.toString()), account)\n}\n"],"mappings":";;;;;AAkCA,eAAsB,eACpB,EAAE,aAAa,cAAc,iBAC7B,uBACA,KACiD;CACjD,MAAM,WACJ,iCAAiCA,yCAC7B,wBACAA,uCAAe,YAAY;EACzB,OAAO;EACP;EACD,CAAC;CAER,MAAM,UAAU,gBAAgB,MAAM,cAAc,SAAS,GAAG,SAAS,QAAQ,QAAQ,CAAC;AAE1F,uBAAO,UAAU,YAAY,CAAC,KAAK,0CAA0C,QAAQ,KAAK,IAAI;CAE9F,MAAM,YAAY,MAAM,SAAS,QAAQ,0BAA0B;AAEnE,OAAM,SAAS,KAAK,QAAQ;EAC1B,QAAQ;EACR,UAAU,QAAQ;EAClB,QAAQ;EACR,MAAM;EACN;EACD,CAAC;CAEF,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe,QAAQ,KAAK;AAEvE,uBAAO,UAAU,YAAY,CAAC,KAAK,kDAAkD,YAAY,QAAQ,UAAU;AAEnH,UAAS,qBAAqB,QAAQ;AAEtC,QAAO,OAAO,OAAOC,wBAAQ,WAAW,QAAQ,KAAK,UAAU,CAAC,EAAE,QAAQ"}
@@ -8,7 +8,7 @@ async function getTestAccount({ suppressLog, initialFunds, accountGetter }, algo
8
8
  algod: algodOrAlgorandClient,
9
9
  kmd
10
10
  });
11
- const account = accountGetter ? await accountGetter(algorand) : algorand.account.random();
11
+ const account = accountGetter ? await accountGetter(algorand) : algorand.account.random().account;
12
12
  Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`);
13
13
  const dispenser = await algorand.account.dispenserFromEnvironment();
14
14
  await algorand.send.payment({
@@ -21,10 +21,7 @@ async function getTestAccount({ suppressLog, initialFunds, accountGetter }, algo
21
21
  const accountInfo = await algorand.account.getInformation(account.addr);
22
22
  Config.getLogger(suppressLog).info("Test account funded; account balance: %d µALGO", accountInfo.balance.microAlgo);
23
23
  algorand.setSignerFromAccount(account);
24
- const address = Address.fromString(account.addr.toString());
25
- address.addr = account.addr;
26
- address.signer = algorand.account.getSigner(address);
27
- return address;
24
+ return Object.assign(Address.fromString(account.addr.toString()), account);
28
25
  }
29
26
 
30
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"account.mjs","names":[],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from '../types/testing'\n\n/**\n * @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.\n *\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algod An algod client\n * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables and if not found fallback to the default LocalNet KMD client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(\n params: GetTestAccountParams,\n algod: AlgodClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner>\n/**\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algorand An AlgorandClient client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(params: GetTestAccountParams, algorand: AlgorandClient): Promise<Address & AddressWithSigners>\nexport async function getTestAccount(\n { suppressLog, initialFunds, accountGetter }: GetTestAccountParams,\n algodOrAlgorandClient: AlgodClient | AlgorandClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner> {\n const algorand =\n algodOrAlgorandClient instanceof AlgorandClient\n ? algodOrAlgorandClient\n : AlgorandClient.fromClients({\n algod: algodOrAlgorandClient,\n kmd,\n })\n\n const account = accountGetter ? await accountGetter(algorand) : algorand.account.random()\n\n Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`)\n\n const dispenser = await algorand.account.dispenserFromEnvironment()\n\n await algorand.send.payment({\n sender: dispenser,\n receiver: account.addr,\n amount: initialFunds,\n note: 'Funding test account',\n suppressLog,\n })\n\n const accountInfo = await algorand.account.getInformation(account.addr)\n\n Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo)\n\n algorand.setSignerFromAccount(account)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const address = Address.fromString(account.addr.toString()) as any\n address.addr = account.addr\n address.signer = algorand.account.getSigner(address)\n\n return address\n}\n"],"mappings":";;;;;AAkCA,eAAsB,eACpB,EAAE,aAAa,cAAc,iBAC7B,uBACA,KACiD;CACjD,MAAM,WACJ,iCAAiC,iBAC7B,wBACA,eAAe,YAAY;EACzB,OAAO;EACP;EACD,CAAC;CAER,MAAM,UAAU,gBAAgB,MAAM,cAAc,SAAS,GAAG,SAAS,QAAQ,QAAQ;AAEzF,QAAO,UAAU,YAAY,CAAC,KAAK,0CAA0C,QAAQ,KAAK,IAAI;CAE9F,MAAM,YAAY,MAAM,SAAS,QAAQ,0BAA0B;AAEnE,OAAM,SAAS,KAAK,QAAQ;EAC1B,QAAQ;EACR,UAAU,QAAQ;EAClB,QAAQ;EACR,MAAM;EACN;EACD,CAAC;CAEF,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe,QAAQ,KAAK;AAEvE,QAAO,UAAU,YAAY,CAAC,KAAK,kDAAkD,YAAY,QAAQ,UAAU;AAEnH,UAAS,qBAAqB,QAAQ;CAGtC,MAAM,UAAU,QAAQ,WAAW,QAAQ,KAAK,UAAU,CAAC;AAC3D,SAAQ,OAAO,QAAQ;AACvB,SAAQ,SAAS,SAAS,QAAQ,UAAU,QAAQ;AAEpD,QAAO"}
1
+ {"version":3,"file":"account.mjs","names":[],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from '../types/testing'\n\n/**\n * @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.\n *\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algod An algod client\n * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables and if not found fallback to the default LocalNet KMD client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(\n params: GetTestAccountParams,\n algod: AlgodClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner>\n/**\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algorand An AlgorandClient client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(params: GetTestAccountParams, algorand: AlgorandClient): Promise<Address & AddressWithSigners>\nexport async function getTestAccount(\n { suppressLog, initialFunds, accountGetter }: GetTestAccountParams,\n algodOrAlgorandClient: AlgodClient | AlgorandClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner> {\n const algorand =\n algodOrAlgorandClient instanceof AlgorandClient\n ? algodOrAlgorandClient\n : AlgorandClient.fromClients({\n algod: algodOrAlgorandClient,\n kmd,\n })\n\n const account = accountGetter ? await accountGetter(algorand) : algorand.account.random().account\n\n Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`)\n\n const dispenser = await algorand.account.dispenserFromEnvironment()\n\n await algorand.send.payment({\n sender: dispenser,\n receiver: account.addr,\n amount: initialFunds,\n note: 'Funding test account',\n suppressLog,\n })\n\n const accountInfo = await algorand.account.getInformation(account.addr)\n\n Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo)\n\n algorand.setSignerFromAccount(account)\n\n return Object.assign(Address.fromString(account.addr.toString()), account)\n}\n"],"mappings":";;;;;AAkCA,eAAsB,eACpB,EAAE,aAAa,cAAc,iBAC7B,uBACA,KACiD;CACjD,MAAM,WACJ,iCAAiC,iBAC7B,wBACA,eAAe,YAAY;EACzB,OAAO;EACP;EACD,CAAC;CAER,MAAM,UAAU,gBAAgB,MAAM,cAAc,SAAS,GAAG,SAAS,QAAQ,QAAQ,CAAC;AAE1F,QAAO,UAAU,YAAY,CAAC,KAAK,0CAA0C,QAAQ,KAAK,IAAI;CAE9F,MAAM,YAAY,MAAM,SAAS,QAAQ,0BAA0B;AAEnE,OAAM,SAAS,KAAK,QAAQ;EAC1B,QAAQ;EACR,UAAU,QAAQ;EAClB,QAAQ;EACR,MAAM;EACN;EACD,CAAC;CAEF,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe,QAAQ,KAAK;AAEvE,QAAO,UAAU,YAAY,CAAC,KAAK,kDAAkD,YAAY,QAAQ,UAAU;AAEnH,UAAS,qBAAqB,QAAQ;AAEtC,QAAO,OAAO,OAAO,QAAQ,WAAW,QAAQ,KAAK,UAAU,CAAC,EAAE,QAAQ"}
@@ -15,7 +15,7 @@ import { AlgorandFixture, AlgorandFixtureConfig } from "../../types/testing.js";
15
15
  * ```typescript
16
16
  * const fixture = algorandFixture()
17
17
  *
18
- * beforeEach(fixture.newScope, 10_000)
18
+ * beforeEach(fixture.newScope)
19
19
  *
20
20
  * test('My test', async () => {
21
21
  * const {algod, indexer, testAccount, ...} = fixture.context
@@ -27,7 +27,7 @@ import { AlgorandFixture, AlgorandFixtureConfig } from "../../types/testing.js";
27
27
  * ```typescript
28
28
  * const fixture = algorandFixture()
29
29
  *
30
- * beforeAll(fixture.newScope, 10_000)
30
+ * beforeAll(fixture.newScope)
31
31
  *
32
32
  * test('My test', async () => {
33
33
  * const {algod, indexer, testAccount, ...} = fixture.context
@@ -42,7 +42,7 @@ import { AlgorandFixture, AlgorandFixtureConfig } from "../../types/testing.js";
42
42
  * // ...
43
43
  * })
44
44
  *
45
- * beforeEach(fixture.newScope, 10_000)
45
+ * beforeEach(fixture.newScope)
46
46
  *
47
47
  * test('My test', async () => {
48
48
  * const {algod, indexer, testAccount, ...} = fixture.context
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-fixture.js","names":["ClientManager","context: AlgorandTestAutomationContext","algorand: AlgorandClient","TransactionLogger","AlgorandClient","getTestAccount","algos","runWhenIndexerCaughtUp"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new AlgodClient({ baseUrl: 'http://localhost:12345', headers: { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } }),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionById(transactionId)),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;AAC3G,iBAAgB;EAAE,GAAG;EAAe,GAAG;EAAQ;AAC/C,KAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,IACnE,iBAAgB;EAAE,GAAGA,qCAAc,oCAAoC;EAAE,GAAG;EAAe;CAG7F,MAAM,QAAQ,cAAc,SAASA,qCAAc,eAAe,cAAc,YAAa;CAC7F,MAAM,UAAU,cAAc,WAAWA,qCAAc,iBAAiB,cAAc,cAAe;CACrG,MAAM,MAAM,cAAc,OAAOA,qCAAc,aAAa,cAAc,UAAW;CACrF,IAAIC;CACJ,IAAIC;CAEJ,MAAM,WAAW,YAAY;AAC3B,wBAAO,UAAU,EAAE,OAAO,MAAM,CAAC;EACjC,MAAM,oBAAoB,IAAIC,8CAAmB;EACjD,MAAM,yBAAyB,kBAAkB,QAAQ,MAAM;AAE/D,aAAWC,uCAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;GAAK,CAAC,CAAC,+BAA+B,EAAE;EAExH,MAAM,cAAc,MAAMC,+BAAe;GAAE,cAAc,eAAe,sBAAsBC,qBAAM,GAAG;GAAE,aAAa;GAAM,EAAE,SAAS;AACvI,WAAS,qBAAqB,YAAY;AAI1C,MAAI,MAAM,SAAS,OAAO,YAAY,CACpC,UAAS,yBAAyB,IAAK;AAEzC,YAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAMD,+BAAe,QAAQ,SAAS;AACtD,aAAS,qBAAqB,QAAQ;AACtC,WAAO;;GAEU;GACnB,sBAAsB,kBAAkB,eAAe,QAAQ;GAC/D,4BAA4B,kBAA0BE,6CAA6B,QAAQ,sBAAsB,cAAc,CAAC;GACjI;;AAGH,QAAO;EACL,IAAI,UAAU;AACZ,OAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0FAA0F;AACxH,UAAO;;EAET,IAAI,WAAW;AACb,UAAO;;EAET,YAAY;EACZ;EACD"}
1
+ {"version":3,"file":"algorand-fixture.js","names":["ClientManager","context: AlgorandTestAutomationContext","algorand: AlgorandClient","TransactionLogger","AlgorandClient","getTestAccount","algos","runWhenIndexerCaughtUp"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new AlgodClient({ baseUrl: 'http://localhost:12345', headers: { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } }),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionById(transactionId)),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;AAC3G,iBAAgB;EAAE,GAAG;EAAe,GAAG;EAAQ;AAC/C,KAAI,CAAC,c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["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new AlgodClient({ baseUrl: 'http://localhost:12345', headers: { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } }),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope, 10_000)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionById(transactionId)),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;AAC3G,iBAAgB;EAAE,GAAG;EAAe,GAAG;EAAQ;AAC/C,KAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,IACnE,iBAAgB;EAAE,GAAG,cAAc,oCAAoC;EAAE,GAAG;EAAe;CAG7F,MAAM,QAAQ,cAAc,SAAS,cAAc,eAAe,cAAc,YAAa;CAC7F,MAAM,UAAU,cAAc,WAAW,cAAc,iBAAiB,cAAc,cAAe;CACrG,MAAM,MAAM,cAAc,OAAO,cAAc,aAAa,cAAc,UAAW;CACrF,IAAIA;CACJ,IAAIC;CAEJ,MAAM,WAAW,YAAY;AAC3B,SAAO,UAAU,EAAE,OAAO,MAAM,CAAC;EACjC,MAAM,oBAAoB,IAAI,mBAAmB;EACjD,MAAM,yBAAyB,kBAAkB,QAAQ,MAAM;AAE/D,aAAW,eAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;GAAK,CAAC,CAAC,+BAA+B,EAAE;EAExH,MAAM,cAAc,MAAM,eAAe;GAAE,cAAc,eAAe,sBAAsB,MAAM,GAAG;GAAE,aAAa;GAAM,EAAE,SAAS;AACvI,WAAS,qBAAqB,YAAY;AAI1C,MAAI,MAAM,SAAS,OAAO,YAAY,CACpC,UAAS,yBAAyB,IAAK;AAEzC,YAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAM,eAAe,QAAQ,SAAS;AACtD,aAAS,qBAAqB,QAAQ;AACtC,WAAO;;GAEU;GACnB,sBAAsB,kBAAkB,eAAe,QAAQ;GAC/D,4BAA4B,kBAA0B,6BAA6B,QAAQ,sBAAsB,cAAc,CAAC;GACjI;;AAGH,QAAO;EACL,IAAI,UAAU;AACZ,OAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0FAA0F;AACxH,UAAO;;EAET,IAAI,WAAW;AACb,UAAO;;EAET,YAAY;EACZ;EACD"}
1
+ {"version":3,"file":"algorand-fixture.mjs","names":["context: AlgorandTestAutomationContext","algorand: AlgorandClient"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../types/algorand-client'\nimport { ClientManager } from '../../types/client-manager'\nimport { AlgoConfig } from '../../types/network-client'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../../types/testing'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new AlgodClient({ baseUrl: 'http://localhost:12345', headers: { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } }),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionById(transactionId)),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;AAC3G,iBAAgB;EAAE,GAAG;EAAe,GAAG;EAAQ;AAC/C,KAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,IACnE,iBAAgB;EAAE,GAAG,cAAc,oCAAoC;EAAE,GAAG;EAAe;CAG7F,MAAM,QAAQ,cAAc,SAAS,cAAc,eAAe,cAAc,YAAa;CAC7F,MAAM,UAAU,cAAc,WAAW,cAAc,iBAAiB,cAAc,cAAe;CACrG,MAAM,MAAM,cAAc,OAAO,cAAc,aAAa,cAAc,UAAW;CACrF,IAAIA;CACJ,IAAIC;CAEJ,MAAM,WAAW,YAAY;AAC3B,SAAO,UAAU,EAAE,OAAO,MAAM,CAAC;EACjC,MAAM,oBAAoB,IAAI,mBAAmB;EACjD,MAAM,yBAAyB,kBAAkB,QAAQ,MAAM;AAE/D,aAAW,eAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;GAAK,CAAC,CAAC,+BAA+B,EAAE;EAExH,MAAM,cAAc,MAAM,eAAe;GAAE,cAAc,eAAe,sBAAsB,MAAM,GAAG;GAAE,aAAa;GAAM,EAAE,SAAS;AACvI,WAAS,qBAAqB,YAAY;AAI1C,MAAI,MAAM,SAAS,OAAO,YAAY,CACpC,UAAS,yBAAyB,IAAK;AAEzC,YAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAM,eAAe,QAAQ,SAAS;AACtD,aAAS,qBAAqB,QAAQ;AACtC,WAAO;;GAEU;GACnB,sBAAsB,kBAAkB,eAAe,QAAQ;GAC/D,4BAA4B,kBAA0B,6BAA6B,QAAQ,sBAAsB,cAAc,CAAC;GACjI;;AAGH,QAAO;EACL,IAAI,UAAU;AACZ,OAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0FAA0F;AACxH,UAAO;;EAET,IAAI,WAAW;AACb,UAAO;;EAET,YAAY;EACZ;EACD"}
@@ -1,5 +1,5 @@
1
- const require_signed_transaction = require('../packages/transact/src/transactions/signed-transaction.js');
2
1
  const require_config = require('../config.js');
2
+ const require_signed_transaction = require('../packages/transact/src/transactions/signed-transaction.js');
3
3
  const require_indexer = require('./indexer.js');
4
4
 
5
5
  //#region src/testing/transaction-logger.ts
@@ -1,5 +1,5 @@
1
- import { decodeSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.mjs";
2
1
  import { Config } from "../config.mjs";
2
+ import { decodeSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.mjs";
3
3
  import { runWhenIndexerCaughtUp } from "./indexer.mjs";
4
4
 
5
5
  //#region src/testing/transaction-logger.ts
@@ -1,17 +1,18 @@
1
- import { AccessReference, AppCallTransactionFields, BoxReference, HoldingReference, LocalsReference, OnApplicationComplete, StateSchema, validateAppCallTransaction } from "../packages/transact/src/transactions/app-call.js";
2
- import { AssetConfigTransactionFields, validateAssetConfigTransaction } from "../packages/transact/src/transactions/asset-config.js";
3
- import { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from "../packages/transact/src/transactions/asset-freeze.js";
4
- import { AssetTransferTransactionFields, validateAssetTransferTransaction } from "../packages/transact/src/transactions/asset-transfer.js";
1
+ import { AppCallTransactionFields, BoxReference, HoldingReference, LocalsReference, OnApplicationComplete, ResourceReference, StateSchema } from "../packages/transact/src/transactions/app-call.js";
2
+ import { AssetConfigTransactionFields } from "../packages/transact/src/transactions/asset-config.js";
3
+ import { AssetFreezeTransactionFields } from "../packages/transact/src/transactions/asset-freeze.js";
4
+ import { AssetTransferTransactionFields } from "../packages/transact/src/transactions/asset-transfer.js";
5
5
  import { HeartbeatProof, HeartbeatTransactionFields } from "../packages/transact/src/transactions/heartbeat.js";
6
- import { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from "../packages/transact/src/transactions/key-registration.js";
6
+ import { KeyRegistrationTransactionFields } from "../packages/transact/src/transactions/key-registration.js";
7
7
  import { PaymentTransactionFields } from "../packages/transact/src/transactions/payment.js";
8
8
  import { FalconSignatureStruct, FalconVerifier, HashFactory, MerkleArrayProof, MerkleSignatureVerifier, Participant, Reveal, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields } from "../packages/transact/src/transactions/state-proof.js";
9
9
  import { TransactionType } from "../packages/transact/src/transactions/transaction-type.js";
10
- import { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec } from "../packages/transact/src/transactions/transaction.js";
11
- import { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions } from "../packages/transact/src/transactions/signed-transaction.js";
10
+ import { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec, validateTransaction } from "../packages/transact/src/transactions/transaction.js";
11
+ import { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.js";
12
+ import { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from "../packages/transact/src/transactions/reference-types-meta.js";
12
13
  import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.js";
13
14
  import { TransactionParamsMeta, transactionParamsCodec } from "../packages/transact/src/transactions/transaction-meta.js";
14
- import { MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG, MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG, MULTISIG_MERGE_MISMATCH_ERROR_MSG, MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG, MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG, MULTISIG_NO_MUTATE_ERROR_MSG, MULTISIG_SIGNATURE_LENGTH_ERROR_MSG, MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG, MultisigAccount, MultisigMetadata, addressFromMultisigPreImg, addressFromMultisigPreImgAddrs, addressFromMultisigSignature, appendSignRawMultisigSignature, applyMultisigSubsignature, createMultisigTransaction, decodeMultiSignature, mergeMultisigTransactions, mergeMultisignatures, multisigAddress, newMultisigSignature, participantsFromMultisigSignature } from "../packages/transact/src/multisig.js";
15
- import { DelegatedLsigSigner, LogicSigAccount, ProgramDataSigner, decodeLogicSignature, sanityCheckProgram } from "../packages/transact/src/logicsig.js";
15
+ import { MultisigAccount, MultisigMetadata } from "../packages/transact/src/multisig.js";
16
+ import { DelegatedLsigSigner, LogicSigAccount, ProgramDataSigner } from "../packages/transact/src/logicsig.js";
16
17
  import { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, MxBytesSigner, SendingAddress, TransactionSigner, generateAddressWithSigners, makeEmptyTransactionSigner } from "../packages/transact/src/signer.js";
17
- export { AccessReference, AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, AppCallTransactionFields, AssetConfigTransactionFields, AssetFreezeTransactionFields, AssetTransferTransactionFields, BoxReference, DelegatedLsigSigner, FalconSignatureStruct, FalconVerifier, HashFactory, HeartbeatProof, HeartbeatTransactionFields, HoldingReference, KeyRegistrationTransactionFields, LocalsReference, LogicSigAccount, LogicSignature, MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG, MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG, MULTISIG_MERGE_MISMATCH_ERROR_MSG, MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG, MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG, MULTISIG_NO_MUTATE_ERROR_MSG, MULTISIG_SIGNATURE_LENGTH_ERROR_MSG, MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG, MerkleArrayProof, MerkleSignatureVerifier, MultisigAccount, MultisigMetadata, MultisigSignature, MultisigSubsignature, MxBytesSigner, OnApplicationComplete, Participant, PaymentTransactionFields, ProgramDataSigner, Reveal, SendingAddress, SignedTransaction, SignedTransactionMeta, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields, StateSchema, Transaction, TransactionParams, TransactionParamsMeta, TransactionSigner, TransactionType, addressFromMultisigPreImg, addressFromMultisigPreImgAddrs, addressFromMultisigSignature, appendSignRawMultisigSignature, applyMultisigSubsignature, assignFee, calculateFee, createMultisigTransaction, decodeLogicSignature, decodeMultiSignature, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, mergeMultisigTransactions, mergeMultisignatures, multisigAddress, newMultisigSignature, participantsFromMultisigSignature, sanityCheckProgram, transactionCodec, transactionParamsCodec, validateAppCallTransaction, validateAssetConfigTransaction, validateAssetFreezeTransaction, validateAssetTransferTransaction, validateKeyRegistrationTransaction };
18
+ export { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, AppCallTransactionFields, AssetConfigTransactionFields, AssetFreezeTransactionFields, AssetTransferTransactionFields, BoxReference, BoxReferenceMeta, DelegatedLsigSigner, FalconSignatureStruct, FalconVerifier, HashFactory, HeartbeatProof, HeartbeatTransactionFields, HoldingReference, HoldingReferenceMeta, KeyRegistrationTransactionFields, LocalsReference, LocalsReferenceMeta, LogicSigAccount, LogicSignature, MerkleArrayProof, MerkleSignatureVerifier, MultisigAccount, MultisigMetadata, MultisigSignature, MultisigSubsignature, MxBytesSigner, OnApplicationComplete, Participant, PaymentTransactionFields, ProgramDataSigner, ResourceReference, Reveal, SendingAddress, SignedTransaction, SignedTransactionMeta, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields, StateSchema, Transaction, TransactionParams, TransactionParamsMeta, TransactionSigner, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec, validateSignedTransaction, validateTransaction };
package/transact/index.js CHANGED
@@ -1,42 +1,26 @@
1
1
  const require_app_call = require('../packages/transact/src/transactions/app-call.js');
2
- const require_asset_config = require('../packages/transact/src/transactions/asset-config.js');
3
- const require_asset_freeze = require('../packages/transact/src/transactions/asset-freeze.js');
4
- const require_asset_transfer = require('../packages/transact/src/transactions/asset-transfer.js');
5
- const require_key_registration = require('../packages/transact/src/transactions/key-registration.js');
6
2
  const require_transaction_type = require('../packages/transact/src/transactions/transaction-type.js');
7
3
  const require_transaction_meta = require('../packages/transact/src/transactions/transaction-meta.js');
8
4
  const require_transaction = require('../packages/transact/src/transactions/transaction.js');
9
5
  const require_signed_transaction_meta = require('../packages/transact/src/transactions/signed-transaction-meta.js');
10
6
  const require_signed_transaction = require('../packages/transact/src/transactions/signed-transaction.js');
7
+ const require_reference_types_meta = require('../packages/transact/src/transactions/reference-types-meta.js');
11
8
  const require_signer = require('../packages/transact/src/signer.js');
12
- const require_multisig = require('../packages/transact/src/multisig.js');
13
9
  const require_logicsig = require('../packages/transact/src/logicsig.js');
10
+ const require_multisig = require('../packages/transact/src/multisig.js');
14
11
 
12
+ exports.BoxReferenceMeta = require_reference_types_meta.BoxReferenceMeta;
13
+ exports.HoldingReferenceMeta = require_reference_types_meta.HoldingReferenceMeta;
14
+ exports.LocalsReferenceMeta = require_reference_types_meta.LocalsReferenceMeta;
15
15
  exports.LogicSigAccount = require_logicsig.LogicSigAccount;
16
- exports.MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG = require_multisig.MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG;
17
- exports.MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG = require_multisig.MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG;
18
- exports.MULTISIG_MERGE_MISMATCH_ERROR_MSG = require_multisig.MULTISIG_MERGE_MISMATCH_ERROR_MSG;
19
- exports.MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG = require_multisig.MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG;
20
- exports.MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG = require_multisig.MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG;
21
- exports.MULTISIG_NO_MUTATE_ERROR_MSG = require_multisig.MULTISIG_NO_MUTATE_ERROR_MSG;
22
- exports.MULTISIG_SIGNATURE_LENGTH_ERROR_MSG = require_multisig.MULTISIG_SIGNATURE_LENGTH_ERROR_MSG;
23
- exports.MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG = require_multisig.MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG;
24
16
  exports.MultisigAccount = require_multisig.MultisigAccount;
25
17
  exports.OnApplicationComplete = require_app_call.OnApplicationComplete;
26
18
  exports.SignedTransactionMeta = require_signed_transaction_meta.SignedTransactionMeta;
27
19
  exports.Transaction = require_transaction.Transaction;
28
20
  exports.TransactionParamsMeta = require_transaction_meta.TransactionParamsMeta;
29
21
  exports.TransactionType = require_transaction_type.TransactionType;
30
- exports.addressFromMultisigPreImg = require_multisig.addressFromMultisigPreImg;
31
- exports.addressFromMultisigPreImgAddrs = require_multisig.addressFromMultisigPreImgAddrs;
32
- exports.addressFromMultisigSignature = require_multisig.addressFromMultisigSignature;
33
- exports.appendSignRawMultisigSignature = require_multisig.appendSignRawMultisigSignature;
34
- exports.applyMultisigSubsignature = require_multisig.applyMultisigSubsignature;
35
22
  exports.assignFee = require_transaction.assignFee;
36
23
  exports.calculateFee = require_transaction.calculateFee;
37
- exports.createMultisigTransaction = require_multisig.createMultisigTransaction;
38
- exports.decodeLogicSignature = require_logicsig.decodeLogicSignature;
39
- exports.decodeMultiSignature = require_multisig.decodeMultiSignature;
40
24
  exports.decodeSignedTransaction = require_signed_transaction.decodeSignedTransaction;
41
25
  exports.decodeSignedTransactions = require_signed_transaction.decodeSignedTransactions;
42
26
  exports.decodeTransaction = require_transaction.decodeTransaction;
@@ -51,16 +35,7 @@ exports.generateAddressWithSigners = require_signer.generateAddressWithSigners;
51
35
  exports.getEncodedTransactionType = require_transaction.getEncodedTransactionType;
52
36
  exports.groupTransactions = require_transaction.groupTransactions;
53
37
  exports.makeEmptyTransactionSigner = require_signer.makeEmptyTransactionSigner;
54
- exports.mergeMultisigTransactions = require_multisig.mergeMultisigTransactions;
55
- exports.mergeMultisignatures = require_multisig.mergeMultisignatures;
56
- exports.multisigAddress = require_multisig.multisigAddress;
57
- exports.newMultisigSignature = require_multisig.newMultisigSignature;
58
- exports.participantsFromMultisigSignature = require_multisig.participantsFromMultisigSignature;
59
- exports.sanityCheckProgram = require_logicsig.sanityCheckProgram;
60
38
  exports.transactionCodec = require_transaction.transactionCodec;
61
39
  exports.transactionParamsCodec = require_transaction_meta.transactionParamsCodec;
62
- exports.validateAppCallTransaction = require_app_call.validateAppCallTransaction;
63
- exports.validateAssetConfigTransaction = require_asset_config.validateAssetConfigTransaction;
64
- exports.validateAssetFreezeTransaction = require_asset_freeze.validateAssetFreezeTransaction;
65
- exports.validateAssetTransferTransaction = require_asset_transfer.validateAssetTransferTransaction;
66
- exports.validateKeyRegistrationTransaction = require_key_registration.validateKeyRegistrationTransaction;
40
+ exports.validateSignedTransaction = require_signed_transaction.validateSignedTransaction;
41
+ exports.validateTransaction = require_transaction.validateTransaction;
@@ -1,15 +1,12 @@
1
- import { OnApplicationComplete, validateAppCallTransaction } from "../packages/transact/src/transactions/app-call.mjs";
2
- import { validateAssetConfigTransaction } from "../packages/transact/src/transactions/asset-config.mjs";
3
- import { validateAssetFreezeTransaction } from "../packages/transact/src/transactions/asset-freeze.mjs";
4
- import { validateAssetTransferTransaction } from "../packages/transact/src/transactions/asset-transfer.mjs";
5
- import { validateKeyRegistrationTransaction } from "../packages/transact/src/transactions/key-registration.mjs";
1
+ import { OnApplicationComplete } from "../packages/transact/src/transactions/app-call.mjs";
6
2
  import { TransactionType } from "../packages/transact/src/transactions/transaction-type.mjs";
7
3
  import { TransactionParamsMeta, transactionParamsCodec } from "../packages/transact/src/transactions/transaction-meta.mjs";
8
- import { Transaction, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec } from "../packages/transact/src/transactions/transaction.mjs";
4
+ import { Transaction, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec, validateTransaction } from "../packages/transact/src/transactions/transaction.mjs";
9
5
  import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.mjs";
10
- import { decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions } from "../packages/transact/src/transactions/signed-transaction.mjs";
6
+ import { decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.mjs";
7
+ import { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from "../packages/transact/src/transactions/reference-types-meta.mjs";
11
8
  import { generateAddressWithSigners, makeEmptyTransactionSigner } from "../packages/transact/src/signer.mjs";
12
- import { MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG, MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG, MULTISIG_MERGE_MISMATCH_ERROR_MSG, MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG, MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG, MULTISIG_NO_MUTATE_ERROR_MSG, MULTISIG_SIGNATURE_LENGTH_ERROR_MSG, MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG, MultisigAccount, addressFromMultisigPreImg, addressFromMultisigPreImgAddrs, addressFromMultisigSignature, appendSignRawMultisigSignature, applyMultisigSubsignature, createMultisigTransaction, decodeMultiSignature, mergeMultisigTransactions, mergeMultisignatures, multisigAddress, newMultisigSignature, participantsFromMultisigSignature } from "../packages/transact/src/multisig.mjs";
13
- import { LogicSigAccount, decodeLogicSignature, sanityCheckProgram } from "../packages/transact/src/logicsig.mjs";
9
+ import { LogicSigAccount } from "../packages/transact/src/logicsig.mjs";
10
+ import { MultisigAccount } from "../packages/transact/src/multisig.mjs";
14
11
 
15
- export { LogicSigAccount, MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG, MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG, MULTISIG_MERGE_MISMATCH_ERROR_MSG, MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG, MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG, MULTISIG_NO_MUTATE_ERROR_MSG, MULTISIG_SIGNATURE_LENGTH_ERROR_MSG, MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG, MultisigAccount, OnApplicationComplete, SignedTransactionMeta, Transaction, TransactionParamsMeta, TransactionType, addressFromMultisigPreImg, addressFromMultisigPreImgAddrs, addressFromMultisigSignature, appendSignRawMultisigSignature, applyMultisigSubsignature, assignFee, calculateFee, createMultisigTransaction, decodeLogicSignature, decodeMultiSignature, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, mergeMultisigTransactions, mergeMultisignatures, multisigAddress, newMultisigSignature, participantsFromMultisigSignature, sanityCheckProgram, transactionCodec, transactionParamsCodec, validateAppCallTransaction, validateAssetConfigTransaction, validateAssetFreezeTransaction, validateAssetTransferTransaction, validateKeyRegistrationTransaction };
12
+ export { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta, LogicSigAccount, MultisigAccount, OnApplicationComplete, SignedTransactionMeta, Transaction, TransactionParamsMeta, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec, validateSignedTransaction, validateTransaction };
@@ -80,7 +80,7 @@ async function prepareGroupForSending(composer, sendParams, additionalContext) {
80
80
  * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
81
81
  */
82
82
  const sendTransactionComposer = async function(atcSend) {
83
- const { transactionComposer: givenComposer,...executeParams } = atcSend;
83
+ const { transactionComposer: givenComposer, ...executeParams } = atcSend;
84
84
  return atcSend.transactionComposer.send({ ...executeParams });
85
85
  };
86
86
  /**
@@ -96,7 +96,7 @@ const sendTransactionComposer = async function(atcSend) {
96
96
  */
97
97
  const waitForConfirmation = async function(transactionId, maxRoundsToWait, algod) {
98
98
  if (maxRoundsToWait < 0) throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`);
99
- const status = await algod.getStatus();
99
+ const status = await algod.status();
100
100
  if (status === void 0) throw new Error("Unable to get node status");
101
101
  const startRound = BigInt(status.lastRound) + 1n;
102
102
  let currentRound = startRound;
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","names":["e: any","toNumber"],"sources":["../../src/transaction/transaction.ts"],"sourcesContent":["import { AlgodClient, PendingTransactionResponse } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { TransactionComposer } from '../types/composer'\nimport {\n AdditionalTransactionComposerContext,\n SendParams,\n SendTransactionComposerResults,\n TransactionComposerToSend,\n} from '../types/transaction'\nimport { toNumber } from '../util'\n\n/** Represents an unsigned transactions and a signer that can authorize that transaction. */\nexport interface TransactionWithSigner {\n /** An unsigned transaction */\n txn: Transaction\n /** A transaction signer that can authorize txn */\n signer: TransactionSigner\n}\n\n/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction.\n *\n * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease\n * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease\n * @throws if the length of the data is > 32 bytes or empty\n * @example algokit.encodeLease('UNIQUE_ID')\n * @example algokit.encodeLease(new Uint8Array([1, 2, 3]))\n */\nexport function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined {\n if (lease === null || typeof lease === 'undefined') {\n return undefined\n } else if (typeof lease === 'object' && lease.constructor === Uint8Array) {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`,\n )\n }\n if (lease.length === 32) return lease\n const lease32 = new Uint8Array(32)\n lease32.set(lease, 0)\n return lease32\n } else if (typeof lease === 'string') {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`,\n )\n }\n const encoder = new TextEncoder()\n const lease32 = new Uint8Array(32)\n lease32.set(encoder.encode(lease), 0)\n return lease32\n } else {\n throw new Error(`Unknown lease type received of ${typeof lease}`)\n }\n}\n\n/**\n * @deprecated Use `composer.build()` directly\n * Take an existing Transaction Composer and return a new one with the required\n * app call resources populated into it\n *\n * @param algod The algod client to use for the simulation\n * @param composer The composer containing the txn group\n * @returns A new composer with the resources populated into the transactions\n *\n * @privateRemarks\n *\n * This entire function will eventually be implemented in simulate upstream in algod. The simulate endpoint will return\n * an array of refference arrays for each transaction, so this eventually will eventually just call simulate and set the\n * reference arrays in the transactions to the reference arrays returned by simulate.\n *\n * See https://github.com/algorand/go-algorand/pull/5684\n *\n */\nexport async function populateAppCallResources(composer: TransactionComposer) {\n await composer.build()\n return composer\n}\n\n/**\n * @deprecated Use `composer.setMaxFees()` instead if you need to set max fees for transactions.\n * Use `composer.build()` instead if you need to build transactions with resource population.\n *\n * Take an existing Transaction Composer and return a new one with changes applied to the transactions\n * based on the supplied sendParams to prepare it for sending.\n *\n * @param composer The Transaction Composer containing the txn group\n * @param sendParams The send params for the transaction group\n * @param additionalContext Additional context used to determine how best to change the transactions in the group\n * @returns A new Transaction Composer with the changes applied\n *\n * @privateRemarks\n * Parts of this function will eventually be implemented in algod. Namely:\n * - Simulate will return information on how to populate reference arrays, see https://github.com/algorand/go-algorand/pull/6015\n */\nexport async function prepareGroupForSending(\n composer: TransactionComposer,\n sendParams: SendParams,\n additionalContext?: AdditionalTransactionComposerContext,\n) {\n const newComposer = composer.clone({\n coverAppCallInnerTransactionFees: sendParams.coverAppCallInnerTransactionFees ?? false,\n populateAppCallResources: sendParams.populateAppCallResources ?? true,\n })\n\n if (additionalContext?.maxFees) {\n newComposer.setMaxFees(additionalContext?.maxFees)\n }\n\n await newComposer.build()\n\n return newComposer\n}\n\n/**\n * @deprecated Use `composer.send()` directly\n * Signs and sends transactions that have been collected by an `TransactionComposer`.\n * @param atcSend The parameters controlling the send, including `atc` The `TransactionComposer` and params to control send behaviour\n * @param algod An algod client\n * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)\n */\nexport const sendTransactionComposer = async function (atcSend: TransactionComposerToSend): Promise<SendTransactionComposerResults> {\n const { transactionComposer: givenComposer, ...executeParams } = atcSend\n\n return atcSend.transactionComposer.send({\n ...executeParams,\n })\n}\n\n/**\n * Wait until the transaction is confirmed or rejected, or until `timeout`\n * number of rounds have passed.\n *\n * @param algod An algod client\n * @param transactionId The transaction ID to wait for\n * @param maxRoundsToWait Maximum number of rounds to wait\n *\n * @return Pending transaction information\n * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds\n */\nexport const waitForConfirmation = async function (\n transactionId: string,\n maxRoundsToWait: number | bigint,\n algod: AlgodClient,\n): Promise<PendingTransactionResponse> {\n if (maxRoundsToWait < 0) {\n throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`)\n }\n\n // Get current round\n const status = await algod.getStatus()\n if (status === undefined) {\n throw new Error('Unable to get node status')\n }\n\n // Loop for up to `timeout` rounds looking for a confirmed transaction\n const startRound = BigInt(status.lastRound) + 1n\n let currentRound = startRound\n while (currentRound < startRound + BigInt(maxRoundsToWait)) {\n try {\n const pendingInfo = await algod.pendingTransactionInformation(transactionId)\n\n if (pendingInfo !== undefined) {\n const confirmedRound = pendingInfo.confirmedRound\n if (confirmedRound && confirmedRound > 0) {\n return pendingInfo\n } else {\n const poolError = pendingInfo.poolError\n if (poolError != null && poolError.length > 0) {\n // If there was a pool error, then the transaction has been rejected!\n throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`)\n }\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if ('status' in e && e.status === 404) {\n currentRound++\n continue\n }\n }\n\n await algod.statusAfterBlock(toNumber(currentRound))\n currentRound++\n }\n\n throw new Error(`Transaction ${transactionId} not confirmed after ${max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,OAAM,IAAI,MAAM,6BAA6B,gBAAgB,gBAAgB;CAI/E,MAAM,SAAS,MAAM,MAAM,WAAW;AACtC,KAAI,WAAW,OACb,OAAM,IAAI,MAAM,4BAA4B;CAI9C,MAAM,aAAa,OAAO,OAAO,UAAU,GAAG;CAC9C,IAAI,eAAe;AACnB,QAAO,eAAe,aAAa,OAAO,gBAAgB,EAAE;AAC1D,MAAI;GACF,MAAM,cAAc,MAAM,MAAM,8BAA8B,cAAc;AAE5E,OAAI,gBAAgB,QAAW;IAC7B,MAAM,iBAAiB,YAAY;AACnC,QAAI,kBAAkB,iBAAiB,EACrC,QAAO;SACF;KACL,MAAM,YAAY,YAAY;AAC9B,SAAI,aAAa,QAAQ,UAAU,SAAS,EAE1C,OAAM,IAAI,MAAM,eAAe,cAAc,6BAA6B,YAAY;;;WAKrFA,GAAQ;AACf,OAAI,YAAY,KAAK,EAAE,WAAW,KAAK;AACrC;AACA;;;AAIJ,QAAM,MAAM,iBAAiBC,sBAAS,aAAa,CAAC;AACpD;;AAGF,OAAM,IAAI,MAAM,eAAe,cAAc,uBAAuB,gBAAgB,SAAS"}
1
+ {"version":3,"file":"transaction.js","names":["e: any","toNumber"],"sources":["../../src/transaction/transaction.ts"],"sourcesContent":["import { AlgodClient, PendingTransactionResponse } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { TransactionComposer } from '../types/composer'\nimport {\n AdditionalTransactionComposerContext,\n SendParams,\n SendTransactionComposerResults,\n TransactionComposerToSend,\n} from '../types/transaction'\nimport { toNumber } from '../util'\n\n/** Represents an unsigned transactions and a signer that can authorize that transaction. */\nexport interface TransactionWithSigner {\n /** An unsigned transaction */\n txn: Transaction\n /** A transaction signer that can authorize txn */\n signer: TransactionSigner\n}\n\n/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction.\n *\n * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease\n * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease\n * @throws if the length of the data is > 32 bytes or empty\n * @example algokit.encodeLease('UNIQUE_ID')\n * @example algokit.encodeLease(new Uint8Array([1, 2, 3]))\n */\nexport function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined {\n if (lease === null || typeof lease === 'undefined') {\n return undefined\n } else if (typeof lease === 'object' && lease.constructor === Uint8Array) {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`,\n )\n }\n if (lease.length === 32) return lease\n const lease32 = new Uint8Array(32)\n lease32.set(lease, 0)\n return lease32\n } else if (typeof lease === 'string') {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`,\n )\n }\n const encoder = new TextEncoder()\n const lease32 = new Uint8Array(32)\n lease32.set(encoder.encode(lease), 0)\n return lease32\n } else {\n throw new Error(`Unknown lease type received of ${typeof lease}`)\n }\n}\n\n/**\n * @deprecated Use `composer.build()` directly\n * Take an existing Transaction Composer and return a new one with the required\n * app call resources populated into it\n *\n * @param algod The algod client to use for the simulation\n * @param composer The composer containing the txn group\n * @returns A new composer with the resources populated into the transactions\n *\n * @privateRemarks\n *\n * This entire function will eventually be implemented in simulate upstream in algod. The simulate endpoint will return\n * an array of refference arrays for each transaction, so this eventually will eventually just call simulate and set the\n * reference arrays in the transactions to the reference arrays returned by simulate.\n *\n * See https://github.com/algorand/go-algorand/pull/5684\n *\n */\nexport async function populateAppCallResources(composer: TransactionComposer) {\n await composer.build()\n return composer\n}\n\n/**\n * @deprecated Use `composer.setMaxFees()` instead if you need to set max fees for transactions.\n * Use `composer.build()` instead if you need to build transactions with resource population.\n *\n * Take an existing Transaction Composer and return a new one with changes applied to the transactions\n * based on the supplied sendParams to prepare it for sending.\n *\n * @param composer The Transaction Composer containing the txn group\n * @param sendParams The send params for the transaction group\n * @param additionalContext Additional context used to determine how best to change the transactions in the group\n * @returns A new Transaction Composer with the changes applied\n *\n * @privateRemarks\n * Parts of this function will eventually be implemented in algod. Namely:\n * - Simulate will return information on how to populate reference arrays, see https://github.com/algorand/go-algorand/pull/6015\n */\nexport async function prepareGroupForSending(\n composer: TransactionComposer,\n sendParams: SendParams,\n additionalContext?: AdditionalTransactionComposerContext,\n) {\n const newComposer = composer.clone({\n coverAppCallInnerTransactionFees: sendParams.coverAppCallInnerTransactionFees ?? false,\n populateAppCallResources: sendParams.populateAppCallResources ?? true,\n })\n\n if (additionalContext?.maxFees) {\n newComposer.setMaxFees(additionalContext?.maxFees)\n }\n\n await newComposer.build()\n\n return newComposer\n}\n\n/**\n * @deprecated Use `composer.send()` directly\n * Signs and sends transactions that have been collected by an `TransactionComposer`.\n * @param atcSend The parameters controlling the send, including `atc` The `TransactionComposer` and params to control send behaviour\n * @param algod An algod client\n * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)\n */\nexport const sendTransactionComposer = async function (atcSend: TransactionComposerToSend): Promise<SendTransactionComposerResults> {\n const { transactionComposer: givenComposer, ...executeParams } = atcSend\n\n return atcSend.transactionComposer.send({\n ...executeParams,\n })\n}\n\n/**\n * Wait until the transaction is confirmed or rejected, or until `timeout`\n * number of rounds have passed.\n *\n * @param algod An algod client\n * @param transactionId The transaction ID to wait for\n * @param maxRoundsToWait Maximum number of rounds to wait\n *\n * @return Pending transaction information\n * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds\n */\nexport const waitForConfirmation = async function (\n transactionId: string,\n maxRoundsToWait: number | bigint,\n algod: AlgodClient,\n): Promise<PendingTransactionResponse> {\n if (maxRoundsToWait < 0) {\n throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`)\n }\n\n // Get current round\n const status = await algod.status()\n if (status === undefined) {\n throw new Error('Unable to get node status')\n }\n\n // Loop for up to `timeout` rounds looking for a confirmed transaction\n const startRound = BigInt(status.lastRound) + 1n\n let currentRound = startRound\n while (currentRound < startRound + BigInt(maxRoundsToWait)) {\n try {\n const pendingInfo = await algod.pendingTransactionInformation(transactionId)\n\n if (pendingInfo !== undefined) {\n const confirmedRound = pendingInfo.confirmedRound\n if (confirmedRound && confirmedRound > 0) {\n return pendingInfo\n } else {\n const poolError = pendingInfo.poolError\n if (poolError != null && poolError.length > 0) {\n // If there was a pool error, then the transaction has been rejected!\n throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`)\n }\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if ('status' in e && e.status === 404) {\n currentRound++\n continue\n }\n }\n\n await algod.statusAfterBlock(toNumber(currentRound))\n currentRound++\n }\n\n throw new Error(`Transaction ${transactionId} not confirmed after ${maxRoundsToWait} rounds`)\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAgB,YAAY,OAAqD;AAC/E,KAAI,UAAU,QAAQ,OAAO,UAAU,YACrC;UACS,OAAO,UAAU,YAAY,MAAM,gBAAgB,YAAY;AACxE,MAAI,MAAM,WAAW,KAAK,MAAM,SAAS,GACvC,OAAM,IAAI,MACR,2GAA2G,MAAM,SAClH;AAEH,MAAI,MAAM,WAAW,GAAI,QAAO;EAChC,MAAM,UAAU,IAAI,WAAW,GAAG;AAClC,UAAQ,IAAI,OAAO,EAAE;AACrB,SAAO;YACE,OAAO,UAAU,UAAU;AACpC,MAAI,MAAM,WAAW,KAAK,MAAM,SAAS,GACvC,OAAM,IAAI,MACR,0FAA0F,MAAM,gBAAgB,MAAM,SACvH;EAEH,MAAM,UAAU,IAAI,aAAa;EACjC,MAAM,UAAU,IAAI,WAAW,GAAG;AAClC,UAAQ,IAAI,QAAQ,OAAO,MAAM,EAAE,EAAE;AACrC,SAAO;OAEP,OAAM,IAAI,MAAM,kCAAkC,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;;AAsBrE,eAAsB,yBAAyB,UAA+B;AAC5E,OAAM,SAAS,OAAO;AACt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ams, additionalContext) {
80
80
  * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
81
81
  */
82
82
  const sendTransactionComposer = async function(atcSend) {
83
- const { transactionComposer: givenComposer,...executeParams } = atcSend;
83
+ const { transactionComposer: givenComposer, ...executeParams } = atcSend;
84
84
  return atcSend.transactionComposer.send({ ...executeParams });
85
85
  };
86
86
  /**
@@ -96,7 +96,7 @@ const sendTransactionComposer = async function(atcSend) {
96
96
  */
97
97
  const waitForConfirmation = async function(transactionId, maxRoundsToWait, algod) {
98
98
  if (maxRoundsToWait < 0) throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`);
99
- const status = await algod.getStatus();
99
+ const status = await algod.status();
100
100
  if (status === void 0) throw new Error("Unable to get node status");
101
101
  const startRound = BigInt(status.lastRound) + 1n;
102
102
  let currentRound = startRound;
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","names":["e: any"],"sources":["../../src/transaction/transaction.ts"],"sourcesContent":["import { AlgodClient, PendingTransactionResponse } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { TransactionComposer } from '../types/composer'\nimport {\n AdditionalTransactionComposerContext,\n SendParams,\n SendTransactionComposerResults,\n TransactionComposerToSend,\n} from '../types/transaction'\nimport { toNumber } from '../util'\n\n/** Represents an unsigned transactions and a signer that can authorize that transaction. */\nexport interface TransactionWithSigner {\n /** An unsigned transaction */\n txn: Transaction\n /** A transaction signer that can authorize txn */\n signer: TransactionSigner\n}\n\n/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction.\n *\n * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease\n * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease\n * @throws if the length of the data is > 32 bytes or empty\n * @example algokit.encodeLease('UNIQUE_ID')\n * @example algokit.encodeLease(new Uint8Array([1, 2, 3]))\n */\nexport function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined {\n if (lease === null || typeof lease === 'undefined') {\n return undefined\n } else if (typeof lease === 'object' && lease.constructor === Uint8Array) {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`,\n )\n }\n if (lease.length === 32) return lease\n const lease32 = new Uint8Array(32)\n lease32.set(lease, 0)\n return lease32\n } else if (typeof lease === 'string') {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`,\n )\n }\n const encoder = new TextEncoder()\n const lease32 = new Uint8Array(32)\n lease32.set(encoder.encode(lease), 0)\n return lease32\n } else {\n throw new Error(`Unknown lease type received of ${typeof lease}`)\n }\n}\n\n/**\n * @deprecated Use `composer.build()` directly\n * Take an existing Transaction Composer and return a new one with the required\n * app call resources populated into it\n *\n * @param algod The algod client to use for the simulation\n * @param composer The composer containing the txn group\n * @returns A new composer with the resources populated into the transactions\n *\n * @privateRemarks\n *\n * This entire function will eventually be implemented in simulate upstream in algod. The simulate endpoint will return\n * an array of refference arrays for each transaction, so this eventually will eventually just call simulate and set the\n * reference arrays in the transactions to the reference arrays returned by simulate.\n *\n * See https://github.com/algorand/go-algorand/pull/5684\n *\n */\nexport async function populateAppCallResources(composer: TransactionComposer) {\n await composer.build()\n return composer\n}\n\n/**\n * @deprecated Use `composer.setMaxFees()` instead if you need to set max fees for transactions.\n * Use `composer.build()` instead if you need to build transactions with resource population.\n *\n * Take an existing Transaction Composer and return a new one with changes applied to the transactions\n * based on the supplied sendParams to prepare it for sending.\n *\n * @param composer The Transaction Composer containing the txn group\n * @param sendParams The send params for the transaction group\n * @param additionalContext Additional context used to determine how best to change the transactions in the group\n * @returns A new Transaction Composer with the changes applied\n *\n * @privateRemarks\n * Parts of this function will eventually be implemented in algod. Namely:\n * - Simulate will return information on how to populate reference arrays, see https://github.com/algorand/go-algorand/pull/6015\n */\nexport async function prepareGroupForSending(\n composer: TransactionComposer,\n sendParams: SendParams,\n additionalContext?: AdditionalTransactionComposerContext,\n) {\n const newComposer = composer.clone({\n coverAppCallInnerTransactionFees: sendParams.coverAppCallInnerTransactionFees ?? false,\n populateAppCallResources: sendParams.populateAppCallResources ?? true,\n })\n\n if (additionalContext?.maxFees) {\n newComposer.setMaxFees(additionalContext?.maxFees)\n }\n\n await newComposer.build()\n\n return newComposer\n}\n\n/**\n * @deprecated Use `composer.send()` directly\n * Signs and sends transactions that have been collected by an `TransactionComposer`.\n * @param atcSend The parameters controlling the send, including `atc` The `TransactionComposer` and params to control send behaviour\n * @param algod An algod client\n * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)\n */\nexport const sendTransactionComposer = async function (atcSend: TransactionComposerToSend): Promise<SendTransactionComposerResults> {\n const { transactionComposer: givenComposer, ...executeParams } = atcSend\n\n return atcSend.transactionComposer.send({\n ...executeParams,\n })\n}\n\n/**\n * Wait until the transaction is confirmed or rejected, or until `timeout`\n * number of rounds have passed.\n *\n * @param algod An algod client\n * @param transactionId The transaction ID to wait for\n * @param maxRoundsToWait Maximum number of rounds to wait\n *\n * @return Pending transaction information\n * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds\n */\nexport const waitForConfirmation = async function (\n transactionId: string,\n maxRoundsToWait: number | bigint,\n algod: AlgodClient,\n): Promise<PendingTransactionResponse> {\n if (maxRoundsToWait < 0) {\n throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`)\n }\n\n // Get current round\n const status = await algod.getStatus()\n if (status === undefined) {\n throw new Error('Unable to get node status')\n }\n\n // Loop for up to `timeout` rounds looking for a confirmed transaction\n const startRound = BigInt(status.lastRound) + 1n\n let currentRound = startRound\n while (currentRound < startRound + BigInt(maxRoundsToWait)) {\n try {\n const pendingInfo = await algod.pendingTransactionInformation(transactionId)\n\n if (pendingInfo !== undefined) {\n const confirmedRound = pendingInfo.confirmedRound\n if (confirmedRound && confirmedRound > 0) {\n return pendingInfo\n } else {\n const poolError = pendingInfo.poolError\n if (poolError != null && poolError.length > 0) {\n // If there was a pool error, then the transaction has been rejected!\n throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`)\n }\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if ('status' in e && e.status === 404) {\n currentRound++\n continue\n }\n }\n\n await algod.statusAfterBlock(toNumber(currentRound))\n currentRound++\n }\n\n throw new Error(`Transaction ${transactionId} not confirmed after ${maxRoundsToWait} rounds`)\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAgB,YAAY,OAAqD;AAC/E,KAAI,UAAU,QAAQ,OAAO,UAAU,YACrC;UACS,OAAO,UAAU,YAAY,MAAM,gBAAgB,YAAY;AACxE,MAAI,MAAM,WAAW,KAAK,MAAM,SAAS,GACvC,OAAM,IAAI,MACR,2GAA2G,MAAM,SAClH;AAEH,MAAI,MAAM,WAAW,GAAI,QAAO;EAChC,MAAM,UAAU,IAAI,WAAW,GAAG;AAClC,UAAQ,IAAI,OAAO,EAAE;AACrB,SAAO;YACE,OAAO,UAAU,UAAU;AACpC,MAAI,MAAM,WAAW,KAAK,MAAM,SAAS,GACvC,OAAM,IAAI,MACR,0FAA0F,MAAM,gBAAgB,MAAM,SACvH;EAEH,MAAM,UAAU,IAAI,aAAa;EACjC,MAAM,UAAU,IAAI,WAAW,GAAG;AAClC,UAAQ,IAAI,QAAQ,OAAO,MAAM,EAAE,EAAE;AACrC,SAAO;OAEP,OAAM,IAAI,MAAM,kCAAkC,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;;AAsBrE,eAAsB,yBAAyB,UAA+B;AAC5E,OAAM,SAAS,OAAO;AACtB,QAAO;;;;;;;;;;;;;;;;;;AAmBT,eAAsB,uBACpB,UACA,YACA,mBACA;CACA,MAAM,cAAc,SAAS,MAAM;EACjC,kCAAkC,WAAW,oCAAoC;EACjF,0BAA0B,WAAW,4BAA4B;EAClE,CAAC;AAEF,KAAI,mBAAmB,QACrB,aAAY,WAAW,mBAAmB,QAAQ;AAGpD,OAAM,YAAY,OAAO;AAEzB,QAAO;;;;;;;;;AAUT,MAAa,0BAA0B,eAAgB,SAA6E;CAClI,MAAM,EAAE,qBAAqB,cAAe,GAAG,kBAAkB;AAEjE,QAAO,QAAQ,oBAAoB,KAAK,EACtC,GAAG,eACJ,CAAC;;;;;;;;;;;;;AAcJ,MAAa,sBAAsB,eACjC,eACA,iBACA,OACqC;AACrC,KAAI,kBAAkB,EACpB,OAAM,IAAI,MAAM,6BAA6B,gBAAgB,gBAAgB;CAI/E,MAAM,SAAS,MAAM,MAAM,WAAW;AACtC,KAAI,WAAW,OACb,OAAM,IAAI,MAAM,4BAA4B;CAI9C,MAAM,aAAa,OAAO,OAAO,UAAU,GAAG;CAC9C,IAAI,eAAe;AACnB,QAAO,eAAe,aAAa,OAAO,gBAAgB,EAAE;AAC1D,MAAI;GACF,MAAM,cAAc,MAAM,MAAM,8BAA8B,cAAc;AAE5E,OAAI,gBAAgB,QAAW;IAC7B,MAAM,iBAAiB,YAAY;AACnC,QAAI,kBAAkB,iBAAiB,EACrC,QAAO;SACF;KACL,MAAM,YAAY,YAAY;AAC9B,SAAI,aAAa,QAAQ,UAAU,SAAS,EAE1C,OAAM,IAAI,MAAM,eAAe,cAAc,6BAA6B,YAAY;;;WAKrFA,GAAQ;AACf,OAAI,YAAY,KAAK,EAAE,WAAW,KAAK;AACrC;AACA;;;AAIJ,QAAM,MAAM,iBAAiB,SAAS,aAAa,CAAC;AACpD;;AAGF,OAAM,IAAI,MAAM,eAAe,cAAc,uBAAuB,gBAAgB,SAAS"}
1
+ {"version":3,"file":"transaction.mjs","names":["e: any"],"sources":["../../src/transaction/transaction.ts"],"sourcesContent":["import { AlgodClient, PendingTransactionResponse } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { TransactionComposer } from '../types/composer'\nimport {\n AdditionalTransactionComposerContext,\n SendParams,\n SendTransactionComposerResults,\n TransactionComposerToSend,\n} from '../types/transaction'\nimport { toNumber } from '../util'\n\n/** Represents an unsigned transactions and a signer that can authorize that transaction. */\nexport interface TransactionWithSigner {\n /** An unsigned transaction */\n txn: Transaction\n /** A transaction signer that can authorize txn */\n signer: TransactionSigner\n}\n\n/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction.\n *\n * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease\n * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease\n * @throws if the length of the data is > 32 bytes or empty\n * @example algokit.encodeLease('UNIQUE_ID')\n * @example algokit.encodeLease(new Uint8Array([1, 2, 3]))\n */\nexport function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined {\n if (lease === null || typeof lease === 'undefined') {\n return undefined\n } else if (typeof lease === 'object' && lease.constructor === Uint8Array) {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`,\n )\n }\n if (lease.length === 32) return lease\n const lease32 = new Uint8Array(32)\n lease32.set(lease, 0)\n return lease32\n } else if (typeof lease === 'string') {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`,\n )\n }\n const encoder = new TextEncoder()\n const lease32 = new Uint8Array(32)\n lease32.set(encoder.encode(lease), 0)\n return lease32\n } else {\n throw new Error(`Unknown lease type received of ${typeof lease}`)\n }\n}\n\n/**\n * @deprecated Use `composer.build()` directly\n * Take an existing Transaction Composer and return a new one with the required\n * app call resources populated into it\n *\n * @param algod The algod client to use for the simulation\n * @param composer The composer containing the txn group\n * @returns A new composer with the resources populated into the transactions\n *\n * @privateRemarks\n *\n * This entire function will eventually be implemented in simulate upstream in algod. The simulate endpoint will return\n * an array of refference arrays for each transaction, so this eventually will eventually just call simulate and set the\n * reference arrays in the transactions to the reference arrays returned by simulate.\n *\n * See https://github.com/algorand/go-algorand/pull/5684\n *\n */\nexport async function populateAppCallResources(composer: TransactionComposer) {\n await composer.build()\n return composer\n}\n\n/**\n * @deprecated Use `composer.setMaxFees()` instead if you need to set max fees for transactions.\n * Use `composer.build()` instead if you need to build transactions with resource population.\n *\n * Take an existing Transaction Composer and return a new one with changes applied to the transactions\n * based on the supplied sendParams to prepare it for sending.\n *\n * @param composer The Transaction Composer containing the txn group\n * @param sendParams The send params for the transaction group\n * @param additionalContext Additional context used to determine how best to change the transactions in the group\n * @returns A new Transaction Composer with the changes applied\n *\n * @privateRemarks\n * Parts of this function will eventually be implemented in algod. Namely:\n * - Simulate will return information on how to populate reference arrays, see https://github.com/algorand/go-algorand/pull/6015\n */\nexport async function prepareGroupForSending(\n composer: TransactionComposer,\n sendParams: SendParams,\n additionalContext?: AdditionalTransactionComposerContext,\n) {\n const newComposer = composer.clone({\n coverAppCallInnerTransactionFees: sendParams.coverAppCallInnerTransactionFees ?? false,\n populateAppCallResources: sendParams.populateAppCallResources ?? true,\n })\n\n if (additionalContext?.maxFees) {\n newComposer.setMaxFees(additionalContext?.maxFees)\n }\n\n await newComposer.build()\n\n return newComposer\n}\n\n/**\n * @deprecated Use `composer.send()` directly\n * Signs and sends transactions that have been collected by an `TransactionComposer`.\n * @param atcSend The parameters controlling the send, including `atc` The `TransactionComposer` and params to control send behaviour\n * @param algod An algod client\n * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)\n */\nexport const sendTransactionComposer = async function (atcSend: TransactionComposerToSend): Promise<SendTransactionComposerResults> {\n const { transactionComposer: givenComposer, ...executeParams } = atcSend\n\n return atcSend.transactionComposer.send({\n ...executeParams,\n })\n}\n\n/**\n * Wait until the transaction is confirmed or rejected, or until `timeout`\n * number of rounds have passed.\n *\n * @param algod An algod client\n * @param transactionId The transaction ID to wait for\n * @param maxRoundsToWait Maximum number of rounds to wait\n *\n * @return Pending transaction information\n * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds\n */\nexport const waitForConfirmation = async function (\n transactionId: string,\n maxRoundsToWait: number | bigint,\n algod: AlgodClient,\n): Promise<PendingTransactionResponse> {\n if (maxRoundsToWait < 0) {\n throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`)\n }\n\n // Get current round\n const status = await algod.status()\n if (status === undefined) {\n throw new Error('Unable to get node status')\n }\n\n // Loop for up to `timeout` rounds looking for a confirmed transaction\n const startRound = BigInt(status.lastRound) + 1n\n let currentRound = startRound\n while (currentRound < startRound + BigInt(maxRoundsToWait)) {\n try {\n const pendingInfo = await algod.pendingTransactionInformation(transactionId)\n\n if (pendingInfo !== undefined) {\n const confirmedRound = pendingInfo.confirmedRound\n if (confirmedRound && confirmedRound > 0) {\n return pendingInfo\n } else {\n const poolError = pendingInfo.poolError\n if (poolError != null && poolError.length > 0) {\n // If there was a pool error, then the transaction has been rejected!\n throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`)\n }\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if ('status' in e && e.status === 404) {\n currentRound++\n continue\n }\n }\n\n await algod.statusAfterBlock(toNumber(currentRound))\n currentRound++\n }\n\n throw new Error(`Transaction ${transactionId} not confirmed after ${maxRoundsToWait} rounds`)\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAgB,YAAY,OAAqD;AAC/E,KAAI,UAAU,QAAQ,OAAO,UAAU,YACrC;UACS,OAAO,UAAU,YAAY,MAAM,gBAAgB,YAAY;AACxE,MAAI,MAAM,WAAW,KAAK,MAAM,SAAS,GACvC,OAAM,IAAI,MACR,2GAA2G,MAAM,SAClH;AAEH,MAAI,MAAM,WAAW,GAAI,QAAO;EAChC,MAAM,UAAU,IAAI,WAAW,GAAG;AAClC,UAAQ,IAAI,OAAO,EAAE;AACrB,SAAO;YACE,O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