@algorandfoundation/algokit-utils 10.0.0-alpha.3 → 10.0.0-alpha.32

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 (704) hide show
  1. package/_virtual/rolldown_runtime.js +10 -15
  2. package/abi/index.d.ts +2 -1
  3. package/abi/index.js +3 -0
  4. package/abi/index.mjs +2 -1
  5. package/account-manager.d.ts +448 -0
  6. package/account-manager.js +623 -0
  7. package/account-manager.js.map +1 -0
  8. package/account-manager.mjs +620 -0
  9. package/account-manager.mjs.map +1 -0
  10. package/account.d.ts +156 -0
  11. package/account.js +10 -0
  12. package/account.js.map +1 -0
  13. package/account.mjs +9 -0
  14. package/account.mjs.map +1 -0
  15. package/algod-client/index.d.ts +3 -7
  16. package/algod-client/index.js +2 -5
  17. package/algod-client/index.mjs +2 -2
  18. package/algorand-client-transaction-creator.d.ts +1103 -0
  19. package/algorand-client-transaction-creator.js +735 -0
  20. package/algorand-client-transaction-creator.js.map +1 -0
  21. package/algorand-client-transaction-creator.mjs +734 -0
  22. package/algorand-client-transaction-creator.mjs.map +1 -0
  23. package/algorand-client-transaction-sender.d.ts +1317 -0
  24. package/algorand-client-transaction-sender.js +933 -0
  25. package/algorand-client-transaction-sender.js.map +1 -0
  26. package/algorand-client-transaction-sender.mjs +932 -0
  27. package/algorand-client-transaction-sender.mjs.map +1 -0
  28. package/algorand-client.d.ts +246 -0
  29. package/algorand-client.js +325 -0
  30. package/algorand-client.js.map +1 -0
  31. package/algorand-client.mjs +325 -0
  32. package/algorand-client.mjs.map +1 -0
  33. package/amount.d.ts +46 -3
  34. package/amount.js +92 -13
  35. package/amount.js.map +1 -1
  36. package/amount.mjs +80 -3
  37. package/amount.mjs.map +1 -1
  38. package/app-client.d.ts +2130 -0
  39. package/app-client.js +909 -0
  40. package/app-client.js.map +1 -0
  41. package/app-client.mjs +908 -0
  42. package/app-client.mjs.map +1 -0
  43. package/app-deployer.d.ts +166 -0
  44. package/app-deployer.js +353 -0
  45. package/app-deployer.js.map +1 -0
  46. package/app-deployer.mjs +353 -0
  47. package/app-deployer.mjs.map +1 -0
  48. package/app-factory.d.ts +965 -0
  49. package/app-factory.js +448 -0
  50. package/app-factory.js.map +1 -0
  51. package/app-factory.mjs +448 -0
  52. package/app-factory.mjs.map +1 -0
  53. package/app-manager.d.ts +323 -0
  54. package/app-manager.js +468 -0
  55. package/app-manager.js.map +1 -0
  56. package/app-manager.mjs +468 -0
  57. package/app-manager.mjs.map +1 -0
  58. package/app-spec.d.ts +203 -0
  59. package/app-spec.js +137 -0
  60. package/app-spec.js.map +1 -0
  61. package/app-spec.mjs +137 -0
  62. package/app-spec.mjs.map +1 -0
  63. package/app.d.ts +257 -0
  64. package/app.js +49 -0
  65. package/app.js.map +1 -0
  66. package/app.mjs +42 -0
  67. package/app.mjs.map +1 -0
  68. package/asset-manager.d.ts +212 -0
  69. package/asset-manager.js +166 -0
  70. package/asset-manager.js.map +1 -0
  71. package/asset-manager.mjs +166 -0
  72. package/asset-manager.mjs.map +1 -0
  73. package/async-event-emitter.d.ts +16 -0
  74. package/async-event-emitter.js +38 -0
  75. package/async-event-emitter.js.map +1 -0
  76. package/async-event-emitter.mjs +37 -0
  77. package/async-event-emitter.mjs.map +1 -0
  78. package/client-manager.d.ts +475 -0
  79. package/client-manager.js +616 -0
  80. package/client-manager.js.map +1 -0
  81. package/client-manager.mjs +616 -0
  82. package/client-manager.mjs.map +1 -0
  83. package/composer.d.ts +947 -0
  84. package/composer.js +1584 -0
  85. package/composer.js.map +1 -0
  86. package/composer.mjs +1583 -0
  87. package/composer.mjs.map +1 -0
  88. package/config.d.ts +1 -1
  89. package/config.js +2 -2
  90. package/config.js.map +1 -1
  91. package/config.mjs +1 -1
  92. package/config.mjs.map +1 -1
  93. package/debugging.d.ts +47 -0
  94. package/debugging.js +20 -0
  95. package/debugging.js.map +1 -0
  96. package/debugging.mjs +15 -0
  97. package/debugging.mjs.map +1 -0
  98. package/dispenser-client.d.ts +90 -0
  99. package/dispenser-client.js +127 -0
  100. package/dispenser-client.js.map +1 -0
  101. package/dispenser-client.mjs +127 -0
  102. package/dispenser-client.mjs.map +1 -0
  103. package/expand.d.ts +2 -0
  104. package/expand.js +0 -0
  105. package/expand.mjs +0 -0
  106. package/index.d.ts +6 -6
  107. package/index.js +4 -10
  108. package/index.mjs +5 -6
  109. package/indexer-client/index.d.ts +2 -2
  110. package/indexer-client/index.js +6 -6
  111. package/indexer-client/index.mjs +2 -2
  112. package/{indexer-lookup.d.ts → indexer-client/indexer-lookup.d.ts} +8 -11
  113. package/{indexer-lookup.mjs → indexer-client/indexer-lookup.js} +6 -10
  114. package/indexer-client/indexer-lookup.js.map +1 -0
  115. package/{indexer-lookup.js → indexer-client/indexer-lookup.mjs} +3 -18
  116. package/indexer-client/indexer-lookup.mjs.map +1 -0
  117. package/indexer.d.ts +40 -0
  118. package/indexer.js +38 -0
  119. package/indexer.js.map +1 -0
  120. package/indexer.mjs +35 -0
  121. package/indexer.mjs.map +1 -0
  122. package/instance-of.d.ts +8 -0
  123. package/kmd-account-manager.d.ts +74 -0
  124. package/kmd-account-manager.js +167 -0
  125. package/kmd-account-manager.js.map +1 -0
  126. package/kmd-account-manager.mjs +165 -0
  127. package/kmd-account-manager.mjs.map +1 -0
  128. package/kmd-client/index.d.ts +1 -2
  129. package/kmd-client/index.js +0 -5
  130. package/kmd-client/index.mjs +1 -2
  131. package/lifecycle-events.d.ts +14 -0
  132. package/lifecycle-events.js +11 -0
  133. package/lifecycle-events.js.map +1 -0
  134. package/lifecycle-events.mjs +10 -0
  135. package/lifecycle-events.mjs.map +1 -0
  136. package/logging.d.ts +13 -0
  137. package/logging.js +47 -0
  138. package/logging.js.map +1 -0
  139. package/logging.mjs +42 -0
  140. package/logging.mjs.map +1 -0
  141. package/logic-error.d.ts +39 -0
  142. package/logic-error.js +54 -0
  143. package/logic-error.js.map +1 -0
  144. package/logic-error.mjs +53 -0
  145. package/logic-error.mjs.map +1 -0
  146. package/network-client.d.ts +43 -0
  147. package/network-client.js +14 -0
  148. package/network-client.js.map +1 -0
  149. package/network-client.mjs +13 -0
  150. package/network-client.mjs.map +1 -0
  151. package/package.json +14 -5
  152. package/packages/abi/src/abi-method.d.ts +1 -1
  153. package/packages/abi/src/abi-method.js +1 -1
  154. package/packages/abi/src/abi-method.js.map +1 -1
  155. package/packages/abi/src/abi-method.mjs +1 -1
  156. package/packages/abi/src/abi-method.mjs.map +1 -1
  157. package/packages/abi/src/abi-type.d.ts +1 -3
  158. package/packages/abi/src/abi-type.js +7 -36
  159. package/packages/abi/src/abi-type.js.map +1 -1
  160. package/packages/abi/src/abi-type.mjs +7 -36
  161. package/packages/abi/src/abi-type.mjs.map +1 -1
  162. package/packages/abi/src/arc56-contract.js +1 -0
  163. package/packages/abi/src/arc56-contract.js.map +1 -1
  164. package/packages/abi/src/arc56-contract.mjs +1 -0
  165. package/packages/abi/src/arc56-contract.mjs.map +1 -1
  166. package/packages/abi/src/utils.d.ts +22 -0
  167. package/packages/abi/src/utils.js +57 -0
  168. package/packages/abi/src/utils.js.map +1 -0
  169. package/packages/abi/src/utils.mjs +55 -0
  170. package/packages/abi/src/utils.mjs.map +1 -0
  171. package/packages/algo25/src/index.js +1 -1
  172. package/packages/algo25/src/index.mjs +1 -1
  173. package/packages/algod_client/src/apis/api-service.d.ts +44 -44
  174. package/packages/algod_client/src/apis/api-service.js +155 -155
  175. package/packages/algod_client/src/apis/api-service.js.map +1 -1
  176. package/packages/algod_client/src/apis/api-service.mjs +155 -155
  177. package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
  178. package/packages/algod_client/src/core/api-error.js +3 -1
  179. package/packages/algod_client/src/core/api-error.js.map +1 -1
  180. package/packages/algod_client/src/core/api-error.mjs +3 -1
  181. package/packages/algod_client/src/core/api-error.mjs.map +1 -1
  182. package/packages/algod_client/src/core/model-runtime.js +6 -6
  183. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  184. package/packages/algod_client/src/core/model-runtime.mjs +8 -8
  185. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  186. package/packages/algod_client/src/models/account-participation.js +4 -4
  187. package/packages/algod_client/src/models/account-participation.js.map +1 -1
  188. package/packages/algod_client/src/models/account-participation.mjs +4 -4
  189. package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
  190. package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
  191. package/packages/algod_client/src/models/application-state-schema.js +2 -2
  192. package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
  193. package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
  194. package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
  195. package/packages/algod_client/src/models/asset-params.js +2 -1
  196. package/packages/algod_client/src/models/asset-params.js.map +1 -1
  197. package/packages/algod_client/src/models/asset-params.mjs +2 -1
  198. package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
  199. package/packages/algod_client/src/models/block-response.js +1 -2
  200. package/packages/algod_client/src/models/block-response.js.map +1 -1
  201. package/packages/algod_client/src/models/block-response.mjs +2 -3
  202. package/packages/algod_client/src/models/block-response.mjs.map +1 -1
  203. package/packages/algod_client/src/models/block.d.ts +60 -40
  204. package/packages/algod_client/src/models/block.js +184 -108
  205. package/packages/algod_client/src/models/block.js.map +1 -1
  206. package/packages/algod_client/src/models/block.mjs +184 -108
  207. package/packages/algod_client/src/models/block.mjs.map +1 -1
  208. package/packages/algod_client/src/models/eval-delta-key-value.js +2 -2
  209. package/packages/algod_client/src/models/eval-delta-key-value.js.map +1 -1
  210. package/packages/algod_client/src/models/eval-delta-key-value.mjs +2 -2
  211. package/packages/algod_client/src/models/eval-delta-key-value.mjs.map +1 -1
  212. package/packages/algod_client/src/models/eval-delta.js +2 -2
  213. package/packages/algod_client/src/models/eval-delta.js.map +1 -1
  214. package/packages/algod_client/src/models/eval-delta.mjs +2 -2
  215. package/packages/algod_client/src/models/eval-delta.mjs.map +1 -1
  216. package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
  217. package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
  218. package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
  219. package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
  220. package/packages/algod_client/src/models/simulate-request.js +1 -1
  221. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  222. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  223. package/packages/algod_client/src/models/simulate-response.js +6 -1
  224. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  225. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  226. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  227. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
  228. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
  229. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
  230. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
  231. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
  232. package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
  233. package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
  234. package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
  235. package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
  236. package/packages/common/src/address.d.ts +0 -1
  237. package/packages/common/src/address.js +4 -17
  238. package/packages/common/src/address.js.map +1 -1
  239. package/packages/common/src/address.mjs +5 -17
  240. package/packages/common/src/address.mjs.map +1 -1
  241. package/packages/common/src/codecs/composite/map.js +7 -4
  242. package/packages/common/src/codecs/composite/map.js.map +1 -1
  243. package/packages/common/src/codecs/composite/map.mjs +7 -4
  244. package/packages/common/src/codecs/composite/map.mjs.map +1 -1
  245. package/packages/common/src/codecs/composite/record.js +0 -1
  246. package/packages/common/src/codecs/composite/record.js.map +1 -1
  247. package/packages/common/src/codecs/primitives/address.js +0 -1
  248. package/packages/common/src/codecs/primitives/address.js.map +1 -1
  249. package/packages/common/src/codecs/primitives/bytes-base64.js +26 -0
  250. package/packages/common/src/codecs/primitives/bytes-base64.js.map +1 -0
  251. package/packages/common/src/codecs/primitives/bytes-base64.mjs +25 -0
  252. package/packages/common/src/codecs/primitives/bytes-base64.mjs.map +1 -0
  253. package/packages/common/src/codecs/primitives/bytes.js +0 -1
  254. package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
  255. package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
  256. package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
  257. package/packages/common/src/codecs/wire.js +0 -1
  258. package/packages/common/src/codecs/wire.js.map +1 -1
  259. package/packages/common/src/json.mjs +2 -2
  260. package/packages/common/src/json.mjs.map +1 -1
  261. package/packages/common/src/msgpack.js +0 -1
  262. package/packages/common/src/msgpack.js.map +1 -1
  263. package/packages/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
  264. package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
  265. package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
  266. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
  267. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.map +1 -1
  268. package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
  269. package/packages/indexer_client/src/apis/api-service.js +12 -12
  270. package/packages/indexer_client/src/apis/api-service.js.map +1 -1
  271. package/packages/indexer_client/src/apis/api-service.mjs +12 -12
  272. package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
  273. package/packages/indexer_client/src/core/api-error.js +3 -1
  274. package/packages/indexer_client/src/core/api-error.js.map +1 -1
  275. package/packages/indexer_client/src/core/api-error.mjs +3 -1
  276. package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
  277. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  278. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  279. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  280. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  281. package/packages/indexer_client/src/models/account-participation.js +4 -4
  282. package/packages/indexer_client/src/models/account-participation.js.map +1 -1
  283. package/packages/indexer_client/src/models/account-participation.mjs +4 -4
  284. package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
  285. package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
  286. package/packages/indexer_client/src/models/application-state-schema.js +2 -2
  287. package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
  288. package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
  289. package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
  290. package/packages/indexer_client/src/models/asset-params.js +2 -1
  291. package/packages/indexer_client/src/models/asset-params.js.map +1 -1
  292. package/packages/indexer_client/src/models/asset-params.mjs +2 -1
  293. package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
  294. package/packages/indexer_client/src/models/block.d.ts +5 -5
  295. package/packages/indexer_client/src/models/block.js +13 -13
  296. package/packages/indexer_client/src/models/block.js.map +1 -1
  297. package/packages/indexer_client/src/models/block.mjs +13 -13
  298. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  299. package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
  300. package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
  301. package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
  302. package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
  303. package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
  304. package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
  305. package/packages/indexer_client/src/models/eval-delta.js +2 -2
  306. package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
  307. package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
  308. package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
  309. package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
  310. package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
  311. package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
  312. package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
  313. package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
  314. package/packages/indexer_client/src/models/participation-updates.js +2 -2
  315. package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
  316. package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
  317. package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
  318. package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
  319. package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
  320. package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
  321. package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
  322. package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
  323. package/packages/indexer_client/src/models/state-schema.js +2 -2
  324. package/packages/indexer_client/src/models/state-schema.js.map +1 -1
  325. package/packages/indexer_client/src/models/state-schema.mjs +2 -2
  326. package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
  327. package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
  328. package/packages/indexer_client/src/models/teal-key-value.js +2 -2
  329. package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
  330. package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
  331. package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
  332. package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
  333. package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
  334. package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
  335. package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
  336. package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
  337. package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
  338. package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
  339. package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
  340. package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
  341. package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
  342. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
  343. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
  344. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
  345. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
  346. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
  347. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
  348. package/packages/indexer_client/src/models/transaction-state-proof.d.ts +1 -1
  349. package/packages/indexer_client/src/models/transaction-state-proof.js +2 -2
  350. package/packages/indexer_client/src/models/transaction-state-proof.js.map +1 -1
  351. package/packages/indexer_client/src/models/transaction-state-proof.mjs +2 -2
  352. package/packages/indexer_client/src/models/transaction-state-proof.mjs.map +1 -1
  353. package/packages/indexer_client/src/models/transaction.d.ts +2 -2
  354. package/packages/indexer_client/src/models/transaction.js +6 -5
  355. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  356. package/packages/indexer_client/src/models/transaction.mjs +6 -5
  357. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  358. package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
  359. package/packages/kmd_client/src/apis/api-service.js +32 -32
  360. package/packages/kmd_client/src/apis/api-service.js.map +1 -1
  361. package/packages/kmd_client/src/apis/api-service.mjs +32 -32
  362. package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
  363. package/packages/kmd_client/src/core/api-error.js +3 -1
  364. package/packages/kmd_client/src/core/api-error.js.map +1 -1
  365. package/packages/kmd_client/src/core/api-error.mjs +3 -1
  366. package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
  367. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  368. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  369. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  370. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  371. package/packages/transact/src/logicsig.d.ts +35 -33
  372. package/packages/transact/src/logicsig.js +74 -76
  373. package/packages/transact/src/logicsig.js.map +1 -1
  374. package/packages/transact/src/logicsig.mjs +77 -78
  375. package/packages/transact/src/logicsig.mjs.map +1 -1
  376. package/packages/transact/src/multisig.d.ts +11 -116
  377. package/packages/transact/src/multisig.js +106 -136
  378. package/packages/transact/src/multisig.js.map +1 -1
  379. package/packages/transact/src/multisig.mjs +108 -118
  380. package/packages/transact/src/multisig.mjs.map +1 -1
  381. package/packages/transact/src/signer.js +9 -2
  382. package/packages/transact/src/signer.js.map +1 -1
  383. package/packages/transact/src/signer.mjs +10 -3
  384. package/packages/transact/src/signer.mjs.map +1 -1
  385. package/packages/transact/src/transactions/app-call.d.ts +10 -15
  386. package/packages/transact/src/transactions/app-call.js.map +1 -1
  387. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  388. package/packages/transact/src/transactions/asset-config.d.ts +1 -6
  389. package/packages/transact/src/transactions/asset-config.js.map +1 -1
  390. package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
  391. package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
  392. package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
  393. package/packages/transact/src/transactions/key-registration.d.ts +1 -8
  394. package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
  395. package/packages/transact/src/transactions/reference-types-meta.js +71 -0
  396. package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
  397. package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
  398. package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
  399. package/packages/transact/src/transactions/signed-transaction-meta.js +8 -9
  400. package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
  401. package/packages/transact/src/transactions/signed-transaction-meta.mjs +8 -8
  402. package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
  403. package/packages/transact/src/transactions/signed-transaction.d.ts +10 -6
  404. package/packages/transact/src/transactions/signed-transaction.js +1 -1
  405. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  406. package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
  407. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  408. package/packages/transact/src/transactions/state-proof.d.ts +1 -1
  409. package/packages/transact/src/transactions/transaction-meta.js +29 -23
  410. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  411. package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
  412. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  413. package/packages/transact/src/transactions/transaction.d.ts +5 -2
  414. package/packages/transact/src/transactions/transaction.js +5 -4
  415. package/packages/transact/src/transactions/transaction.js.map +1 -1
  416. package/packages/transact/src/transactions/transaction.mjs +5 -4
  417. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  418. package/testing/account.d.ts +2 -2
  419. package/testing/account.js +2 -3
  420. package/testing/account.js.map +1 -1
  421. package/testing/account.mjs +2 -3
  422. package/testing/account.mjs.map +1 -1
  423. package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
  424. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  425. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  426. package/testing/fixtures/algorand-fixture.d.ts +5 -5
  427. package/testing/fixtures/algorand-fixture.js +2 -2
  428. package/testing/fixtures/algorand-fixture.js.map +1 -1
  429. package/testing/fixtures/algorand-fixture.mjs +2 -2
  430. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  431. package/testing/index.d.ts +2 -1
  432. package/testing/test-logger.d.ts +1 -1
  433. package/testing/test-logger.js.map +1 -1
  434. package/testing/test-logger.mjs.map +1 -1
  435. package/testing/transaction-logger.js +1 -1
  436. package/testing/transaction-logger.mjs +1 -1
  437. package/testing/types.d.ts +156 -0
  438. package/transact/index.d.ts +11 -10
  439. package/transact/index.js +7 -31
  440. package/transact/index.mjs +7 -10
  441. package/transaction/index.d.ts +4 -0
  442. package/transaction/index.js +9 -0
  443. package/transaction/index.mjs +4 -0
  444. package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
  445. package/transaction/perform-transaction-composer-simulate.js.map +1 -1
  446. package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
  447. package/transaction/transaction.d.ts +2 -2
  448. package/transaction/transaction.js +2 -2
  449. package/transaction/transaction.js.map +1 -1
  450. package/transaction/transaction.mjs +2 -2
  451. package/transaction/transaction.mjs.map +1 -1
  452. package/transaction/types.d.ts +133 -0
  453. package/transactions/app-call.d.ts +6 -5
  454. package/transactions/app-call.js +17 -17
  455. package/transactions/app-call.js.map +1 -1
  456. package/transactions/app-call.mjs +17 -17
  457. package/transactions/app-call.mjs.map +1 -1
  458. package/transactions/asset-config.d.ts +1 -1
  459. package/transactions/asset-config.js +1 -1
  460. package/transactions/asset-config.js.map +1 -1
  461. package/transactions/asset-config.mjs +1 -1
  462. package/transactions/asset-config.mjs.map +1 -1
  463. package/transactions/common.d.ts +1 -1
  464. package/transactions/common.js.map +1 -1
  465. package/transactions/common.mjs.map +1 -1
  466. package/transactions/key-registration.d.ts +1 -1
  467. package/transactions/key-registration.js.map +1 -1
  468. package/transactions/key-registration.mjs.map +1 -1
  469. package/transactions/method-call.d.ts +2 -2
  470. package/transactions/method-call.js +78 -85
  471. package/transactions/method-call.js.map +1 -1
  472. package/transactions/method-call.mjs +78 -85
  473. package/transactions/method-call.mjs.map +1 -1
  474. package/transactions/payment.d.ts +1 -1
  475. package/transactions/payment.js.map +1 -1
  476. package/transactions/payment.mjs.map +1 -1
  477. package/types/account-manager.d.ts +11 -444
  478. package/types/account-manager.js +5 -606
  479. package/types/account-manager.js.map +1 -1
  480. package/types/account-manager.mjs +5 -604
  481. package/types/account-manager.mjs.map +1 -1
  482. package/types/account.d.ts +8 -150
  483. package/types/account.js +3 -4
  484. package/types/account.js.map +1 -1
  485. package/types/account.mjs +4 -4
  486. package/types/account.mjs.map +1 -1
  487. package/types/algorand-client-transaction-creator.d.ts +5 -1084
  488. package/types/algorand-client-transaction-creator.js +3 -721
  489. package/types/algorand-client-transaction-creator.js.map +1 -1
  490. package/types/algorand-client-transaction-creator.mjs +4 -721
  491. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  492. package/types/algorand-client-transaction-sender.d.ts +5 -1298
  493. package/types/algorand-client-transaction-sender.js +3 -920
  494. package/types/algorand-client-transaction-sender.js.map +1 -1
  495. package/types/algorand-client-transaction-sender.mjs +3 -918
  496. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  497. package/types/algorand-client.d.ts +5 -241
  498. package/types/algorand-client.js +3 -319
  499. package/types/algorand-client.js.map +1 -1
  500. package/types/algorand-client.mjs +3 -319
  501. package/types/algorand-client.mjs.map +1 -1
  502. package/types/amount.d.ts +6 -45
  503. package/types/amount.js +3 -60
  504. package/types/amount.js.map +1 -1
  505. package/types/amount.mjs +3 -60
  506. package/types/amount.mjs.map +1 -1
  507. package/types/app-client.d.ts +75 -2120
  508. package/types/app-client.js +3 -904
  509. package/types/app-client.js.map +1 -1
  510. package/types/app-client.mjs +3 -902
  511. package/types/app-client.mjs.map +1 -1
  512. package/types/app-deployer.d.ts +21 -161
  513. package/types/app-deployer.js +3 -347
  514. package/types/app-deployer.js.map +1 -1
  515. package/types/app-deployer.mjs +3 -347
  516. package/types/app-deployer.mjs.map +1 -1
  517. package/types/app-factory.d.ts +21 -957
  518. package/types/app-factory.js +3 -442
  519. package/types/app-factory.js.map +1 -1
  520. package/types/app-factory.mjs +3 -442
  521. package/types/app-factory.mjs.map +1 -1
  522. package/types/app-manager.d.ts +15 -316
  523. package/types/app-manager.js +3 -456
  524. package/types/app-manager.js.map +1 -1
  525. package/types/app-manager.mjs +3 -456
  526. package/types/app-manager.mjs.map +1 -1
  527. package/types/app-spec.d.ts +39 -198
  528. package/types/app-spec.js +3 -124
  529. package/types/app-spec.js.map +1 -1
  530. package/types/app-spec.mjs +3 -124
  531. package/types/app-spec.mjs.map +1 -1
  532. package/types/app.d.ts +62 -247
  533. package/types/app.js +15 -37
  534. package/types/app.js.map +1 -1
  535. package/types/app.mjs +16 -37
  536. package/types/app.mjs.map +1 -1
  537. package/types/asset-manager.d.ts +9 -207
  538. package/types/asset-manager.js +3 -160
  539. package/types/asset-manager.js.map +1 -1
  540. package/types/asset-manager.mjs +3 -160
  541. package/types/asset-manager.mjs.map +1 -1
  542. package/types/async-event-emitter.d.ts +7 -14
  543. package/types/async-event-emitter.js +3 -32
  544. package/types/async-event-emitter.js.map +1 -1
  545. package/types/async-event-emitter.mjs +4 -32
  546. package/types/async-event-emitter.mjs.map +1 -1
  547. package/types/client-manager.d.ts +27 -470
  548. package/types/client-manager.js +3 -610
  549. package/types/client-manager.js.map +1 -1
  550. package/types/client-manager.mjs +3 -610
  551. package/types/client-manager.mjs.map +1 -1
  552. package/types/composer.d.ts +79 -935
  553. package/types/composer.js +3 -1569
  554. package/types/composer.js.map +1 -1
  555. package/types/composer.mjs +3 -1567
  556. package/types/composer.mjs.map +1 -1
  557. package/types/config.d.ts +7 -52
  558. package/types/config.js +3 -74
  559. package/types/config.js.map +1 -1
  560. package/types/config.mjs +3 -74
  561. package/types/config.mjs.map +1 -1
  562. package/types/debugging.d.ts +12 -33
  563. package/types/debugging.js +11 -10
  564. package/types/debugging.js.map +1 -1
  565. package/types/debugging.mjs +12 -10
  566. package/types/debugging.mjs.map +1 -1
  567. package/types/dispenser-client.d.ts +11 -85
  568. package/types/dispenser-client.js +3 -121
  569. package/types/dispenser-client.js.map +1 -1
  570. package/types/dispenser-client.mjs +3 -121
  571. package/types/dispenser-client.mjs.map +1 -1
  572. package/types/expand.d.ts +4 -5
  573. package/types/indexer.d.ts +16 -36
  574. package/types/indexer.js +7 -30
  575. package/types/indexer.js.map +1 -1
  576. package/types/indexer.mjs +8 -30
  577. package/types/indexer.mjs.map +1 -1
  578. package/types/instance-of.d.ts +4 -4
  579. package/types/kmd-account-manager.d.ts +5 -68
  580. package/types/kmd-account-manager.js +3 -150
  581. package/types/kmd-account-manager.js.map +1 -1
  582. package/types/kmd-account-manager.mjs +3 -148
  583. package/types/kmd-account-manager.mjs.map +1 -1
  584. package/types/lifecycle-events.d.ts +7 -10
  585. package/types/lifecycle-events.js +3 -5
  586. package/types/lifecycle-events.js.map +1 -1
  587. package/types/lifecycle-events.mjs +4 -5
  588. package/types/lifecycle-events.mjs.map +1 -1
  589. package/types/logging.d.ts +14 -9
  590. package/types/logging.js +11 -37
  591. package/types/logging.js.map +1 -1
  592. package/types/logging.mjs +12 -37
  593. package/types/logging.mjs.map +1 -1
  594. package/types/logic-error.d.ts +8 -35
  595. package/types/logic-error.js +3 -48
  596. package/types/logic-error.js.map +1 -1
  597. package/types/logic-error.mjs +4 -48
  598. package/types/logic-error.mjs.map +1 -1
  599. package/types/network-client.d.ts +10 -39
  600. package/types/network-client.js +3 -8
  601. package/types/network-client.js.map +1 -1
  602. package/types/network-client.mjs +4 -8
  603. package/types/network-client.mjs.map +1 -1
  604. package/types/testing.d.ts +13 -151
  605. package/types/transaction.d.ts +33 -128
  606. package/updatable-config.d.ts +57 -0
  607. package/updatable-config.js +80 -0
  608. package/updatable-config.js.map +1 -0
  609. package/updatable-config.mjs +80 -0
  610. package/updatable-config.mjs.map +1 -0
  611. package/util.js +1 -1
  612. package/util.js.map +1 -1
  613. package/util.mjs +1 -1
  614. package/util.mjs.map +1 -1
  615. package/_virtual/rolldown_runtime.mjs +0 -13
  616. package/indexer-lookup.js.map +0 -1
  617. package/indexer-lookup.mjs.map +0 -1
  618. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  619. package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
  620. package/packages/algod_client/src/models/application-local-reference.js +0 -23
  621. package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
  622. package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
  623. package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
  624. package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
  625. package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
  626. package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
  627. package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
  628. package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
  629. package/packages/algod_client/src/models/box-reference.d.ts +0 -17
  630. package/packages/algod_client/src/models/box-reference.js +0 -23
  631. package/packages/algod_client/src/models/box-reference.js.map +0 -1
  632. package/packages/algod_client/src/models/box-reference.mjs +0 -23
  633. package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
  634. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  635. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  636. package/packages/sdk/src/convert.d.ts +0 -17
  637. package/packages/sdk/src/convert.js +0 -28
  638. package/packages/sdk/src/convert.js.map +0 -1
  639. package/packages/sdk/src/convert.mjs +0 -25
  640. package/packages/sdk/src/convert.mjs.map +0 -1
  641. package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
  642. package/packages/sdk/src/encoding/binarydata.js +0 -65
  643. package/packages/sdk/src/encoding/binarydata.js.map +0 -1
  644. package/packages/sdk/src/encoding/binarydata.mjs +0 -60
  645. package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
  646. package/packages/sdk/src/encoding/encoding.d.ts +0 -237
  647. package/packages/sdk/src/encoding/encoding.js +0 -302
  648. package/packages/sdk/src/encoding/encoding.js.map +0 -1
  649. package/packages/sdk/src/encoding/encoding.mjs +0 -287
  650. package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
  651. package/packages/sdk/src/encoding/schema/array.js +0 -35
  652. package/packages/sdk/src/encoding/schema/array.js.map +0 -1
  653. package/packages/sdk/src/encoding/schema/array.mjs +0 -35
  654. package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
  655. package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
  656. package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
  657. package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
  658. package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
  659. package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
  660. package/packages/sdk/src/encoding/schema/map.js +0 -110
  661. package/packages/sdk/src/encoding/schema/map.js.map +0 -1
  662. package/packages/sdk/src/encoding/schema/map.mjs +0 -107
  663. package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
  664. package/packages/sdk/src/encoding/schema/optional.js +0 -46
  665. package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
  666. package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
  667. package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
  668. package/packages/sdk/src/encoding/schema/uint64.js +0 -30
  669. package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
  670. package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
  671. package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
  672. package/packages/sdk/src/encoding/uint64.d.ts +0 -34
  673. package/packages/sdk/src/encoding/uint64.js +0 -34
  674. package/packages/sdk/src/encoding/uint64.js.map +0 -1
  675. package/packages/sdk/src/encoding/uint64.mjs +0 -33
  676. package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
  677. package/packages/sdk/src/index.d.ts +0 -44
  678. package/packages/sdk/src/index.js +0 -62
  679. package/packages/sdk/src/index.js.map +0 -1
  680. package/packages/sdk/src/index.mjs +0 -58
  681. package/packages/sdk/src/index.mjs.map +0 -1
  682. package/packages/sdk/src/nacl/naclWrappers.js +0 -14
  683. package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
  684. package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
  685. package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
  686. package/packages/sdk/src/types/intDecoding.d.ts +0 -28
  687. package/packages/sdk/src/types/intDecoding.js +0 -32
  688. package/packages/sdk/src/types/intDecoding.js.map +0 -1
  689. package/packages/sdk/src/types/intDecoding.mjs +0 -31
  690. package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
  691. package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
  692. package/packages/sdk/src/types/transactions/encoded.js +0 -64
  693. package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
  694. package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
  695. package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
  696. package/packages/sdk/src/utils/utils.d.ts +0 -64
  697. package/packages/sdk/src/utils/utils.js +0 -140
  698. package/packages/sdk/src/utils/utils.js.map +0 -1
  699. package/packages/sdk/src/utils/utils.mjs +0 -128
  700. package/packages/sdk/src/utils/utils.mjs.map +0 -1
  701. package/packages/transact/src/transactions/common.d.ts +0 -37
  702. package/sdk/index.d.ts +0 -10
  703. package/sdk/index.js +0 -59
  704. package/sdk/index.mjs +0 -11
package/composer.js ADDED
@@ -0,0 +1,1584 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
2
+ const require_constants = require('./packages/common/src/constants.js');
3
+ const require_amount = require('./amount.js');
4
+ const require_config = require('./config.js');
5
+ const require_util = require('./util.js');
6
+ const require_transaction = require('./transaction/transaction.js');
7
+ const require_app_call = require('./packages/transact/src/transactions/app-call.js');
8
+ const require_transaction_type = require('./packages/transact/src/transactions/transaction-type.js');
9
+ const require_transaction$1 = require('./packages/transact/src/transactions/transaction.js');
10
+ const require_signed_transaction = require('./packages/transact/src/transactions/signed-transaction.js');
11
+ const require_signer = require('./packages/transact/src/signer.js');
12
+ const require_app_manager = require('./app-manager.js');
13
+ const require_app_call$1 = require('./transactions/app-call.js');
14
+ const require_asset_transfer = require('./transactions/asset-transfer.js');
15
+ const require_lifecycle_events = require('./lifecycle-events.js');
16
+ const require_network_client = require('./network-client.js');
17
+ const require_asset_config = require('./transactions/asset-config.js');
18
+ const require_fee_coverage = require('./transactions/fee-coverage.js');
19
+ const require_key_registration = require('./transactions/key-registration.js');
20
+ const require_method_call = require('./transactions/method-call.js');
21
+ const require_payment = require('./transactions/payment.js');
22
+ let buffer = require("buffer");
23
+
24
+ //#region src/composer.ts
25
+ var InvalidErrorTransformerValue = class extends Error {
26
+ constructor(originalError, value) {
27
+ super(`An error transformer returned a non-error value: ${value}. The original error before any transformation: ${originalError}`);
28
+ }
29
+ };
30
+ var ErrorTransformerError = class extends Error {
31
+ constructor(originalError, cause) {
32
+ super(`An error transformer threw an error: ${cause}. The original error before any transformation: ${originalError} `, { cause });
33
+ }
34
+ };
35
+ /** TransactionComposer helps you compose and execute transactions as a transaction group. */
36
+ var TransactionComposer = class TransactionComposer {
37
+ /** Transactions that have not yet been composed */
38
+ txns = [];
39
+ /** The algod client used by the composer. */
40
+ algod;
41
+ /** An async function that will return suggested params for the transaction. */
42
+ getSuggestedParams;
43
+ /** A function that takes in an address and return a signer function for that address. */
44
+ getSigner;
45
+ /** The default transaction validity window */
46
+ defaultValidityWindow = 10n;
47
+ /** Whether the validity window was explicitly set on construction */
48
+ defaultValidityWindowIsExplicit = false;
49
+ appManager;
50
+ errorTransformers;
51
+ composerConfig;
52
+ transactionsWithSigners;
53
+ signedTransactions;
54
+ rawBuildTransactions;
55
+ async transformError(originalError) {
56
+ if (!(originalError instanceof Error)) return originalError;
57
+ let transformedError = originalError;
58
+ for (const transformer of this.errorTransformers) try {
59
+ transformedError = await transformer(transformedError);
60
+ if (!(transformedError instanceof Error)) return new InvalidErrorTransformerValue(originalError, transformedError);
61
+ } catch (errorFromTransformer) {
62
+ return new ErrorTransformerError(originalError, errorFromTransformer);
63
+ }
64
+ return transformedError;
65
+ }
66
+ validateReferenceParams(params) {
67
+ if (params.accessReferences && params.accessReferences.length > 0 && (params.appReferences && params.appReferences.length > 0 || params.assetReferences && params.assetReferences.length > 0 || params.boxReferences && params.boxReferences.length > 0)) throw new Error("Cannot specify both `accessReferences` and reference arrays (`appReferences`, `assetReferences`, `boxReferences`).");
68
+ }
69
+ /**
70
+ * Create a `TransactionComposer`.
71
+ * @param params The configuration for this composer
72
+ * @returns The `TransactionComposer` instance
73
+ */
74
+ constructor(params) {
75
+ this.algod = params.algod;
76
+ const defaultGetSuggestedParams = () => params.algod.suggestedParams();
77
+ this.getSuggestedParams = params.getSuggestedParams ?? defaultGetSuggestedParams;
78
+ this.getSigner = params.getSigner;
79
+ this.defaultValidityWindow = params.defaultValidityWindow ?? this.defaultValidityWindow;
80
+ this.defaultValidityWindowIsExplicit = params.defaultValidityWindow !== void 0;
81
+ this.appManager = params.appManager ?? new require_app_manager.AppManager(params.algod);
82
+ this.errorTransformers = params.errorTransformers ?? [];
83
+ this.composerConfig = params.composerConfig ?? {
84
+ coverAppCallInnerTransactionFees: false,
85
+ populateAppCallResources: true
86
+ };
87
+ }
88
+ cloneTransaction(txn) {
89
+ switch (txn.type) {
90
+ case "pay": return {
91
+ type: "pay",
92
+ data: { ...txn.data }
93
+ };
94
+ case "assetCreate": return {
95
+ type: "assetCreate",
96
+ data: { ...txn.data }
97
+ };
98
+ case "assetConfig": return {
99
+ type: "assetConfig",
100
+ data: { ...txn.data }
101
+ };
102
+ case "assetFreeze": return {
103
+ type: "assetFreeze",
104
+ data: { ...txn.data }
105
+ };
106
+ case "assetDestroy": return {
107
+ type: "assetDestroy",
108
+ data: { ...txn.data }
109
+ };
110
+ case "assetTransfer": return {
111
+ type: "assetTransfer",
112
+ data: { ...txn.data }
113
+ };
114
+ case "assetOptIn": return {
115
+ type: "assetOptIn",
116
+ data: { ...txn.data }
117
+ };
118
+ case "assetOptOut": return {
119
+ type: "assetOptOut",
120
+ data: { ...txn.data }
121
+ };
122
+ case "appCall": return {
123
+ type: "appCall",
124
+ data: { ...txn.data }
125
+ };
126
+ case "keyReg": return {
127
+ type: "keyReg",
128
+ data: { ...txn.data }
129
+ };
130
+ case "txn": {
131
+ const { txn: transaction, signer, maxFee } = txn.data;
132
+ const clonedTxn = require_transaction$1.decodeTransaction(require_transaction$1.encodeTransactionRaw(transaction));
133
+ delete clonedTxn.group;
134
+ return {
135
+ type: "txn",
136
+ data: {
137
+ txn: clonedTxn,
138
+ signer,
139
+ maxFee
140
+ }
141
+ };
142
+ }
143
+ case "asyncTxn": {
144
+ const { txn: txnPromise, signer, maxFee } = txn.data;
145
+ return {
146
+ type: "asyncTxn",
147
+ data: {
148
+ txn: txnPromise.then((resolvedTxn) => {
149
+ const clonedTxn = require_transaction$1.decodeTransaction(require_transaction$1.encodeTransactionRaw(resolvedTxn));
150
+ delete clonedTxn.group;
151
+ return clonedTxn;
152
+ }),
153
+ signer,
154
+ maxFee
155
+ }
156
+ };
157
+ }
158
+ case "methodCall": return {
159
+ type: "methodCall",
160
+ data: { ...txn.data }
161
+ };
162
+ }
163
+ }
164
+ push(...txns) {
165
+ if (this.transactionsWithSigners) throw new Error("Cannot add new transactions after building");
166
+ if (this.txns.length + txns.length > require_constants.MAX_TRANSACTION_GROUP_SIZE) throw new Error(`Adding ${txns.length} transaction(s) would exceed the maximum group size. Current: ${this.txns.length}, Maximum: ${require_constants.MAX_TRANSACTION_GROUP_SIZE}`);
167
+ this.txns.push(...txns);
168
+ }
169
+ clone(composerConfig) {
170
+ const newComposer = new TransactionComposer({
171
+ algod: this.algod,
172
+ getSuggestedParams: this.getSuggestedParams,
173
+ getSigner: this.getSigner,
174
+ defaultValidityWindow: this.defaultValidityWindow,
175
+ appManager: this.appManager,
176
+ errorTransformers: this.errorTransformers,
177
+ composerConfig: {
178
+ ...this.composerConfig,
179
+ ...composerConfig
180
+ }
181
+ });
182
+ this.txns.forEach((txn) => {
183
+ newComposer.txns.push(this.cloneTransaction(txn));
184
+ });
185
+ newComposer.defaultValidityWindowIsExplicit = this.defaultValidityWindowIsExplicit;
186
+ return newComposer;
187
+ }
188
+ /**
189
+ * Register a function that will be used to transform an error caught when simulating or executing
190
+ *
191
+ * @returns The composer so you can chain method calls
192
+ */
193
+ registerErrorTransformer(transformer) {
194
+ this.errorTransformers.push(transformer);
195
+ return this;
196
+ }
197
+ /**
198
+ * Add a pre-built transaction to the transaction group.
199
+ * @param transaction The pre-built transaction
200
+ * @param signer Optional signer override for the transaction
201
+ * @returns The composer so you can chain method calls
202
+ * @example
203
+ * ```typescript
204
+ * composer.addTransaction(txn)
205
+ * ```
206
+ */
207
+ addTransaction(transaction, signer) {
208
+ if (transaction.group) throw new Error("Cannot add a transaction to the composer because it is already in a group");
209
+ require_transaction$1.validateTransaction(transaction);
210
+ this.push({
211
+ data: {
212
+ txn: transaction,
213
+ signer: signer ?? this.getSigner(transaction.sender)
214
+ },
215
+ type: "txn"
216
+ });
217
+ return this;
218
+ }
219
+ /**
220
+ * Add another transaction composer to the current transaction composer.
221
+ * The transaction params of the input transaction composer will be added.
222
+ * If the input transaction composer is updated, it won't affect the current transaction composer.
223
+ * @param composer The transaction composer to add
224
+ * @returns The composer so you can chain method calls
225
+ * @example
226
+ * ```typescript
227
+ * const innerComposer = algorand.newGroup()
228
+ * .addPayment({ sender: 'SENDER', receiver: 'RECEIVER', amount: (1).algo() })
229
+ * .addPayment({ sender: 'SENDER', receiver: 'RECEIVER', amount: (2).algo() })
230
+ *
231
+ * composer.addTransactionComposer(innerComposer)
232
+ * ```
233
+ */
234
+ addTransactionComposer(composer) {
235
+ const clonedTxns = composer.txns.map((txn) => this.cloneTransaction(txn));
236
+ this.push(...clonedTxns);
237
+ return this;
238
+ }
239
+ /**
240
+ * Add a payment transaction to the transaction group.
241
+ * @param params The payment transaction parameters
242
+ * @returns The composer so you can chain method calls
243
+ * @example Basic example
244
+ * ```typescript
245
+ * composer.addPayment({
246
+ * sender: 'SENDERADDRESS',
247
+ * receiver: 'RECEIVERADDRESS',
248
+ * amount: (4).algo(),
249
+ * })
250
+ * ```
251
+ * @example Advanced example
252
+ * ```typescript
253
+ * composer.addPayment({
254
+ * amount: (4).algo(),
255
+ * receiver: 'RECEIVERADDRESS',
256
+ * sender: 'SENDERADDRESS',
257
+ * closeRemainderTo: 'CLOSEREMAINDERTOADDRESS',
258
+ * lease: 'lease',
259
+ * note: 'note',
260
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
261
+ * rekeyTo: 'REKEYTOADDRESS',
262
+ * // You wouldn't normally set this field
263
+ * firstValidRound: 1000n,
264
+ * validityWindow: 10,
265
+ * extraFee: (1000).microAlgo(),
266
+ * staticFee: (1000).microAlgo(),
267
+ * // Max fee doesn't make sense with extraFee AND staticFee
268
+ * // already specified, but here for completeness
269
+ * maxFee: (3000).microAlgo(),
270
+ * })
271
+ */
272
+ addPayment(params) {
273
+ this.push({
274
+ data: params,
275
+ type: "pay"
276
+ });
277
+ return this;
278
+ }
279
+ /**
280
+ * Add an asset create transaction to the transaction group.
281
+ * @param params The asset create transaction parameters
282
+ * @returns The composer so you can chain method calls
283
+ * @example Basic example
284
+ * ```typescript
285
+ * composer.addAssetCreate({ sender: "CREATORADDRESS", total: 100n})
286
+ * ```
287
+ * @example Advanced example
288
+ * ```typescript
289
+ * composer.addAssetCreate({
290
+ * sender: 'CREATORADDRESS',
291
+ * total: 100n,
292
+ * decimals: 2,
293
+ * assetName: 'asset',
294
+ * unitName: 'unit',
295
+ * url: 'url',
296
+ * metadataHash: 'metadataHash',
297
+ * defaultFrozen: false,
298
+ * manager: 'MANAGERADDRESS',
299
+ * reserve: 'RESERVEADDRESS',
300
+ * freeze: 'FREEZEADDRESS',
301
+ * clawback: 'CLAWBACKADDRESS',
302
+ * lease: 'lease',
303
+ * note: 'note',
304
+ * // You wouldn't normally set this field
305
+ * firstValidRound: 1000n,
306
+ * validityWindow: 10,
307
+ * extraFee: (1000).microAlgo(),
308
+ * staticFee: (1000).microAlgo(),
309
+ * // Max fee doesn't make sense with extraFee AND staticFee
310
+ * // already specified, but here for completeness
311
+ * maxFee: (3000).microAlgo(),
312
+ * })
313
+ */
314
+ addAssetCreate(params) {
315
+ this.push({
316
+ data: params,
317
+ type: "assetCreate"
318
+ });
319
+ return this;
320
+ }
321
+ /**
322
+ * Add an asset config transaction to the transaction group.
323
+ * @param params The asset config transaction parameters
324
+ * @returns The composer so you can chain method calls
325
+ * @example Basic example
326
+ * ```typescript
327
+ * composer.addAssetConfig({ sender: "MANAGERADDRESS", assetId: 123456n, manager: "MANAGERADDRESS" })
328
+ * ```
329
+ * @example Advanced example
330
+ * ```typescript
331
+ * composer.addAssetConfig({
332
+ * sender: 'MANAGERADDRESS',
333
+ * assetId: 123456n,
334
+ * manager: 'MANAGERADDRESS',
335
+ * reserve: 'RESERVEADDRESS',
336
+ * freeze: 'FREEZEADDRESS',
337
+ * clawback: 'CLAWBACKADDRESS',
338
+ * lease: 'lease',
339
+ * note: 'note',
340
+ * // You wouldn't normally set this field
341
+ * firstValidRound: 1000n,
342
+ * validityWindow: 10,
343
+ * extraFee: (1000).microAlgo(),
344
+ * staticFee: (1000).microAlgo(),
345
+ * // Max fee doesn't make sense with extraFee AND staticFee
346
+ * // already specified, but here for completeness
347
+ * maxFee: (3000).microAlgo(),
348
+ * })
349
+ */
350
+ addAssetConfig(params) {
351
+ this.push({
352
+ data: params,
353
+ type: "assetConfig"
354
+ });
355
+ return this;
356
+ }
357
+ /**
358
+ * Add an asset freeze transaction to the transaction group.
359
+ * @param params The asset freeze transaction parameters
360
+ * @returns The composer so you can chain method calls
361
+ * @example Basic example
362
+ * ```typescript
363
+ * composer.addAssetFreeze({ sender: "MANAGERADDRESS", assetId: 123456n, account: "ACCOUNTADDRESS", frozen: true })
364
+ * ```
365
+ * @example Advanced example
366
+ * ```typescript
367
+ * composer.addAssetFreeze({
368
+ * sender: 'MANAGERADDRESS',
369
+ * assetId: 123456n,
370
+ * account: 'ACCOUNTADDRESS',
371
+ * frozen: true,
372
+ * lease: 'lease',
373
+ * note: 'note',
374
+ * // You wouldn't normally set this field
375
+ * firstValidRound: 1000n,
376
+ * validityWindow: 10,
377
+ * extraFee: (1000).microAlgo(),
378
+ * staticFee: (1000).microAlgo(),
379
+ * // Max fee doesn't make sense with extraFee AND staticFee
380
+ * // already specified, but here for completeness
381
+ * maxFee: (3000).microAlgo(),
382
+ * })
383
+ * ```
384
+ */
385
+ addAssetFreeze(params) {
386
+ this.push({
387
+ data: params,
388
+ type: "assetFreeze"
389
+ });
390
+ return this;
391
+ }
392
+ /**
393
+ * Add an asset destroy transaction to the transaction group.
394
+ * @param params The asset destroy transaction parameters
395
+ * @returns The composer so you can chain method calls
396
+ * @example Basic example
397
+ * ```typescript
398
+ * composer.addAssetDestroy({ sender: "MANAGERADDRESS", assetId: 123456n })
399
+ * ```
400
+ * @example Advanced example
401
+ * ```typescript
402
+ * composer.addAssetDestroy({
403
+ * sender: 'MANAGERADDRESS',
404
+ * assetId: 123456n,
405
+ * lease: 'lease',
406
+ * note: 'note',
407
+ * // You wouldn't normally set this field
408
+ * firstValidRound: 1000n,
409
+ * validityWindow: 10,
410
+ * extraFee: (1000).microAlgo(),
411
+ * staticFee: (1000).microAlgo(),
412
+ * // Max fee doesn't make sense with extraFee AND staticFee
413
+ * // already specified, but here for completeness
414
+ * maxFee: (3000).microAlgo(),
415
+ * })
416
+ * ```
417
+ */
418
+ addAssetDestroy(params) {
419
+ this.push({
420
+ data: params,
421
+ type: "assetDestroy"
422
+ });
423
+ return this;
424
+ }
425
+ /**
426
+ * Add an asset transfer transaction to the transaction group.
427
+ * @param params The asset transfer transaction parameters
428
+ * @returns The composer so you can chain method calls
429
+ * @example Basic example
430
+ * ```typescript
431
+ * composer.addAssetTransfer({ sender: "HOLDERADDRESS", assetId: 123456n, amount: 1n, receiver: "RECEIVERADDRESS" })
432
+ * ```
433
+ * @example Advanced example (with clawback)
434
+ * ```typescript
435
+ * composer.addAssetTransfer({
436
+ * sender: 'CLAWBACKADDRESS',
437
+ * assetId: 123456n,
438
+ * amount: 1n,
439
+ * receiver: 'RECEIVERADDRESS',
440
+ * clawbackTarget: 'HOLDERADDRESS',
441
+ * // This field needs to be used with caution
442
+ * closeAssetTo: 'ADDRESSTOCLOSETO'
443
+ * lease: 'lease',
444
+ * note: 'note',
445
+ * // You wouldn't normally set this field
446
+ * firstValidRound: 1000n,
447
+ * validityWindow: 10,
448
+ * extraFee: (1000).microAlgo(),
449
+ * staticFee: (1000).microAlgo(),
450
+ * // Max fee doesn't make sense with extraFee AND staticFee
451
+ * // already specified, but here for completeness
452
+ * maxFee: (3000).microAlgo(),
453
+ * })
454
+ * ```
455
+ */
456
+ addAssetTransfer(params) {
457
+ this.push({
458
+ data: params,
459
+ type: "assetTransfer"
460
+ });
461
+ return this;
462
+ }
463
+ /**
464
+ * Add an asset opt-in transaction to the transaction group.
465
+ * @param params The asset opt-in transaction parameters
466
+ * @returns The composer so you can chain method calls
467
+ * @example Basic example
468
+ * ```typescript
469
+ * composer.addAssetOptIn({ sender: "SENDERADDRESS", assetId: 123456n })
470
+ * ```
471
+ * @example Advanced example
472
+ * ```typescript
473
+ * composer.addAssetOptIn({
474
+ * sender: 'SENDERADDRESS',
475
+ * assetId: 123456n,
476
+ * lease: 'lease',
477
+ * note: 'note',
478
+ * // You wouldn't normally set this field
479
+ * firstValidRound: 1000n,
480
+ * validityWindow: 10,
481
+ * extraFee: (1000).microAlgo(),
482
+ * staticFee: (1000).microAlgo(),
483
+ * // Max fee doesn't make sense with extraFee AND staticFee
484
+ * // already specified, but here for completeness
485
+ * maxFee: (3000).microAlgo(),
486
+ * })
487
+ * ```
488
+ */
489
+ addAssetOptIn(params) {
490
+ this.push({
491
+ data: params,
492
+ type: "assetOptIn"
493
+ });
494
+ return this;
495
+ }
496
+ /**
497
+ * Add an asset opt-out transaction to the transaction group.
498
+ * @param params The asset opt-out transaction parameters
499
+ * @returns The composer so you can chain method calls
500
+ * @example Basic example (without creator, will be retrieved from algod)
501
+ * ```typescript
502
+ * composer.addAssetOptOut({ sender: "SENDERADDRESS", assetId: 123456n, ensureZeroBalance: true })
503
+ * ```
504
+ * @example Basic example (with creator)
505
+ * ```typescript
506
+ * composer.addAssetOptOut({ sender: "SENDERADDRESS", creator: "CREATORADDRESS", assetId: 123456n, ensureZeroBalance: true })
507
+ * ```
508
+ * @example Advanced example
509
+ * ```typescript
510
+ * composer.addAssetOptOut({
511
+ * sender: 'SENDERADDRESS',
512
+ * assetId: 123456n,
513
+ * creator: 'CREATORADDRESS',
514
+ * ensureZeroBalance: true,
515
+ * lease: 'lease',
516
+ * note: 'note',
517
+ * // You wouldn't normally set this field
518
+ * firstValidRound: 1000n,
519
+ * validityWindow: 10,
520
+ * extraFee: (1000).microAlgo(),
521
+ * staticFee: (1000).microAlgo(),
522
+ * // Max fee doesn't make sense with extraFee AND staticFee
523
+ * // already specified, but here for completeness
524
+ * maxFee: (3000).microAlgo(),
525
+ * })
526
+ * ```
527
+ */
528
+ addAssetOptOut(params) {
529
+ this.push({
530
+ data: params,
531
+ type: "assetOptOut"
532
+ });
533
+ return this;
534
+ }
535
+ /**
536
+ * Add an application create transaction to the transaction group.
537
+ *
538
+ * Note: we recommend using app clients to make it easier to make app calls.
539
+ * @param params The application create transaction parameters
540
+ * @returns The composer so you can chain method calls
541
+ * @example Basic example
542
+ * ```typescript
543
+ * composer.addAppCreate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
544
+ * ```
545
+ * @example Advanced example
546
+ * ```typescript
547
+ * composer.addAppCreate({
548
+ * sender: 'CREATORADDRESS',
549
+ * approvalProgram: "TEALCODE",
550
+ * clearStateProgram: "TEALCODE",
551
+ * schema: {
552
+ * globalInts: 1,
553
+ * globalByteSlices: 2,
554
+ * localInts: 3,
555
+ * localByteSlices: 4
556
+ * },
557
+ * extraProgramPages: 1,
558
+ * onComplete: OnApplicationComplete.OptIn,
559
+ * args: [new Uint8Array(1, 2, 3, 4)]
560
+ * accountReferences: ["ACCOUNT_1"]
561
+ * appReferences: [123n, 1234n]
562
+ * assetReferences: [12345n]
563
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
564
+ * accessReferences: [{ appId: 1234n }]
565
+ * lease: 'lease',
566
+ * note: 'note',
567
+ * // You wouldn't normally set this field
568
+ * firstValidRound: 1000n,
569
+ * validityWindow: 10,
570
+ * extraFee: (1000).microAlgo(),
571
+ * staticFee: (1000).microAlgo(),
572
+ * // Max fee doesn't make sense with extraFee AND staticFee
573
+ * // already specified, but here for completeness
574
+ * maxFee: (3000).microAlgo(),
575
+ * rejectVersion: 1,
576
+ * // Signer only needed if you want to provide one,
577
+ * // generally you'd register it with AlgorandClient
578
+ * // against the sender and not need to pass it in
579
+ * signer: transactionSigner,
580
+ * maxRoundsToWaitForConfirmation: 5,
581
+ * suppressLog: true,
582
+ *})
583
+ * ```
584
+ */
585
+ addAppCreate(params) {
586
+ this.validateReferenceParams(params);
587
+ this.push({
588
+ data: params,
589
+ type: "appCall"
590
+ });
591
+ return this;
592
+ }
593
+ /**
594
+ * Add an application update transaction to the transaction group.
595
+ *
596
+ * Note: we recommend using app clients to make it easier to make app calls.
597
+ * @param params The application update transaction parameters
598
+ * @returns The composer so you can chain method calls
599
+ * @example Basic example
600
+ * ```typescript
601
+ * composer.addAppUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
602
+ * ```
603
+ * @example Advanced example
604
+ * ```typescript
605
+ * composer.addAppUpdate({
606
+ * sender: 'CREATORADDRESS',
607
+ * approvalProgram: "TEALCODE",
608
+ * clearStateProgram: "TEALCODE",
609
+ * onComplete: OnApplicationComplete.UpdateApplication,
610
+ * args: [new Uint8Array(1, 2, 3, 4)]
611
+ * accountReferences: ["ACCOUNT_1"]
612
+ * appReferences: [123n, 1234n]
613
+ * assetReferences: [12345n]
614
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
615
+ * accessReferences: [{ appId: 1234n }]
616
+ * lease: 'lease',
617
+ * note: 'note',
618
+ * // You wouldn't normally set this field
619
+ * firstValidRound: 1000n,
620
+ * validityWindow: 10,
621
+ * extraFee: (1000).microAlgo(),
622
+ * staticFee: (1000).microAlgo(),
623
+ * // Max fee doesn't make sense with extraFee AND staticFee
624
+ * // already specified, but here for completeness
625
+ * maxFee: (3000).microAlgo(),
626
+ * rejectVersion: 1,
627
+ *})
628
+ * ```
629
+ */
630
+ addAppUpdate(params) {
631
+ this.validateReferenceParams(params);
632
+ this.push({
633
+ data: {
634
+ ...params,
635
+ onComplete: require_app_call.OnApplicationComplete.UpdateApplication
636
+ },
637
+ type: "appCall"
638
+ });
639
+ return this;
640
+ }
641
+ /**
642
+ * Add an application delete transaction to the transaction group.
643
+ *
644
+ * Note: we recommend using app clients to make it easier to make app calls.
645
+ * @param params The application delete transaction parameters
646
+ * @returns The composer so you can chain method calls
647
+ * @example Basic example
648
+ * ```typescript
649
+ * composer.addAppDelete({ sender: 'CREATORADDRESS' })
650
+ * ```
651
+ * @example Advanced example
652
+ * ```typescript
653
+ * composer.addAppDelete({
654
+ * sender: 'CREATORADDRESS',
655
+ * onComplete: OnApplicationComplete.DeleteApplication,
656
+ * args: [new Uint8Array(1, 2, 3, 4)]
657
+ * accountReferences: ["ACCOUNT_1"]
658
+ * appReferences: [123n, 1234n]
659
+ * assetReferences: [12345n]
660
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
661
+ * accessReferences: [{ appId: 1234n }]
662
+ * lease: 'lease',
663
+ * note: 'note',
664
+ * // You wouldn't normally set this field
665
+ * firstValidRound: 1000n,
666
+ * validityWindow: 10,
667
+ * extraFee: (1000).microAlgo(),
668
+ * staticFee: (1000).microAlgo(),
669
+ * // Max fee doesn't make sense with extraFee AND staticFee
670
+ * // already specified, but here for completeness
671
+ * maxFee: (3000).microAlgo(),
672
+ * rejectVersion: 1,
673
+ *})
674
+ * ```
675
+ */
676
+ addAppDelete(params) {
677
+ this.validateReferenceParams(params);
678
+ this.push({
679
+ data: {
680
+ ...params,
681
+ onComplete: require_app_call.OnApplicationComplete.DeleteApplication
682
+ },
683
+ type: "appCall"
684
+ });
685
+ return this;
686
+ }
687
+ /**
688
+ * Add an application call transaction to the transaction group.
689
+ *
690
+ * If you want to create or update an app use `addAppCreate` or `addAppUpdate`.
691
+ *
692
+ * Note: we recommend using app clients to make it easier to make app calls.
693
+ * @param params The application call transaction parameters
694
+ * @returns The composer so you can chain method calls
695
+ * @example Basic example
696
+ * ```typescript
697
+ * composer.addAppCall({ sender: 'CREATORADDRESS' })
698
+ * ```
699
+ * @example Advanced example
700
+ * ```typescript
701
+ * composer.addAppCall({
702
+ * sender: 'CREATORADDRESS',
703
+ * onComplete: OnApplicationComplete.OptIn,
704
+ * args: [new Uint8Array(1, 2, 3, 4)]
705
+ * accountReferences: ["ACCOUNT_1"]
706
+ * appReferences: [123n, 1234n]
707
+ * assetReferences: [12345n]
708
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
709
+ * accessReferences: [{ appId: 1234n }]
710
+ * lease: 'lease',
711
+ * note: 'note',
712
+ * // You wouldn't normally set this field
713
+ * firstValidRound: 1000n,
714
+ * validityWindow: 10,
715
+ * extraFee: (1000).microAlgo(),
716
+ * staticFee: (1000).microAlgo(),
717
+ * // Max fee doesn't make sense with extraFee AND staticFee
718
+ * // already specified, but here for completeness
719
+ * maxFee: (3000).microAlgo(),
720
+ * rejectVersion: 1,
721
+ *})
722
+ * ```
723
+ */
724
+ addAppCall(params) {
725
+ this.validateReferenceParams(params);
726
+ this.push({
727
+ data: params,
728
+ type: "appCall"
729
+ });
730
+ return this;
731
+ }
732
+ /**
733
+ * Add an ABI method create application call transaction to the transaction group.
734
+ *
735
+ * Note: we recommend using app clients to make it easier to make app calls.
736
+ * @param params The ABI create method application call transaction parameters
737
+ * @returns The composer so you can chain method calls
738
+ * @example Basic example
739
+ * ```typescript
740
+ * const method = new ABIMethod({
741
+ * name: 'method',
742
+ * args: [{ name: 'arg1', type: 'string' }],
743
+ * returns: { type: 'string' },
744
+ * })
745
+ * composer.addAppCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
746
+ * ```
747
+ * @example Advanced example
748
+ * ```typescript
749
+ * const method = new ABIMethod({
750
+ * name: 'method',
751
+ * args: [{ name: 'arg1', type: 'string' }],
752
+ * returns: { type: 'string' },
753
+ * })
754
+ * composer.addAppCreateMethodCall({
755
+ * sender: 'CREATORADDRESS',
756
+ * method: method,
757
+ * args: ["arg1_value"],
758
+ * approvalProgram: "TEALCODE",
759
+ * clearStateProgram: "TEALCODE",
760
+ * schema: {
761
+ * globalInts: 1,
762
+ * globalByteSlices: 2,
763
+ * localInts: 3,
764
+ * localByteSlices: 4
765
+ * },
766
+ * extraProgramPages: 1,
767
+ * onComplete: OnApplicationComplete.OptIn,
768
+ * args: [new Uint8Array(1, 2, 3, 4)]
769
+ * accountReferences: ["ACCOUNT_1"]
770
+ * appReferences: [123n, 1234n]
771
+ * assetReferences: [12345n]
772
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
773
+ * accessReferences: [{ appId: 1234n }]
774
+ * lease: 'lease',
775
+ * note: 'note',
776
+ * // You wouldn't normally set this field
777
+ * firstValidRound: 1000n,
778
+ * validityWindow: 10,
779
+ * extraFee: (1000).microAlgo(),
780
+ * staticFee: (1000).microAlgo(),
781
+ * // Max fee doesn't make sense with extraFee AND staticFee
782
+ * // already specified, but here for completeness
783
+ * maxFee: (3000).microAlgo(),
784
+ * rejectVersion: 1,
785
+ *})
786
+ * ```
787
+ */
788
+ addAppCreateMethodCall(params) {
789
+ this.validateReferenceParams(params);
790
+ const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
791
+ this.push(...txnArgs, {
792
+ data: {
793
+ ...params,
794
+ args: require_method_call.processAppMethodCallArgs(params.args)
795
+ },
796
+ type: "methodCall"
797
+ });
798
+ return this;
799
+ }
800
+ /**
801
+ * Add an ABI method update application call transaction to the transaction group.
802
+ *
803
+ * Note: we recommend using app clients to make it easier to make app calls.
804
+ * @param params The ABI update method application call transaction parameters
805
+ * @returns The composer so you can chain method calls
806
+ * @example Basic example
807
+ * ```typescript
808
+ * const method = new ABIMethod({
809
+ * name: 'method',
810
+ * args: [{ name: 'arg1', type: 'string' }],
811
+ * returns: { type: 'string' },
812
+ * })
813
+ * composer.addAppUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
814
+ * ```
815
+ * @example Advanced example
816
+ * ```typescript
817
+ * const method = new ABIMethod({
818
+ * name: 'method',
819
+ * args: [{ name: 'arg1', type: 'string' }],
820
+ * returns: { type: 'string' },
821
+ * })
822
+ * composer.addAppUpdateMethodCall({
823
+ * sender: 'CREATORADDRESS',
824
+ * method: method,
825
+ * args: ["arg1_value"],
826
+ * approvalProgram: "TEALCODE",
827
+ * clearStateProgram: "TEALCODE",
828
+ * onComplete: OnApplicationComplete.UpdateApplication,
829
+ * args: [new Uint8Array(1, 2, 3, 4)]
830
+ * accountReferences: ["ACCOUNT_1"]
831
+ * appReferences: [123n, 1234n]
832
+ * assetReferences: [12345n]
833
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
834
+ * accessReferences: [{ appId: 1234n }]
835
+ * lease: 'lease',
836
+ * note: 'note',
837
+ * // You wouldn't normally set this field
838
+ * firstValidRound: 1000n,
839
+ * validityWindow: 10,
840
+ * extraFee: (1000).microAlgo(),
841
+ * staticFee: (1000).microAlgo(),
842
+ * // Max fee doesn't make sense with extraFee AND staticFee
843
+ * // already specified, but here for completeness
844
+ * maxFee: (3000).microAlgo(),
845
+ * rejectVersion: 1,
846
+ *})
847
+ * ```
848
+ */
849
+ addAppUpdateMethodCall(params) {
850
+ this.validateReferenceParams(params);
851
+ const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
852
+ this.push(...txnArgs, {
853
+ data: {
854
+ ...params,
855
+ args: require_method_call.processAppMethodCallArgs(params.args),
856
+ onComplete: require_app_call.OnApplicationComplete.UpdateApplication
857
+ },
858
+ type: "methodCall"
859
+ });
860
+ return this;
861
+ }
862
+ /**
863
+ * Add an ABI method delete application call transaction to the transaction group.
864
+ *
865
+ * Note: we recommend using app clients to make it easier to make app calls.
866
+ * @param params The ABI delete method application call transaction parameters
867
+ * @returns The composer so you can chain method calls
868
+ * @example Basic example
869
+ * ```typescript
870
+ * const method = new ABIMethod({
871
+ * name: 'method',
872
+ * args: [{ name: 'arg1', type: 'string' }],
873
+ * returns: { type: 'string' },
874
+ * })
875
+ * composer.addAppDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
876
+ * ```
877
+ * @example Advanced example
878
+ * ```typescript
879
+ * const method = new ABIMethod({
880
+ * name: 'method',
881
+ * args: [{ name: 'arg1', type: 'string' }],
882
+ * returns: { type: 'string' },
883
+ * })
884
+ * composer.addAppDeleteMethodCall({
885
+ * sender: 'CREATORADDRESS',
886
+ * method: method,
887
+ * args: ["arg1_value"],
888
+ * onComplete: OnApplicationComplete.DeleteApplication,
889
+ * args: [new Uint8Array(1, 2, 3, 4)]
890
+ * accountReferences: ["ACCOUNT_1"]
891
+ * appReferences: [123n, 1234n]
892
+ * assetReferences: [12345n]
893
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
894
+ * accessReferences: [{ appId: 1234n }]
895
+ * lease: 'lease',
896
+ * note: 'note',
897
+ * // You wouldn't normally set this field
898
+ * firstValidRound: 1000n,
899
+ * validityWindow: 10,
900
+ * extraFee: (1000).microAlgo(),
901
+ * staticFee: (1000).microAlgo(),
902
+ * // Max fee doesn't make sense with extraFee AND staticFee
903
+ * // already specified, but here for completeness
904
+ * maxFee: (3000).microAlgo(),
905
+ * rejectVersion: 1,
906
+ *})
907
+ * ```
908
+ */
909
+ addAppDeleteMethodCall(params) {
910
+ this.validateReferenceParams(params);
911
+ const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
912
+ this.push(...txnArgs, {
913
+ data: {
914
+ ...params,
915
+ args: require_method_call.processAppMethodCallArgs(params.args),
916
+ onComplete: require_app_call.OnApplicationComplete.DeleteApplication
917
+ },
918
+ type: "methodCall"
919
+ });
920
+ return this;
921
+ }
922
+ /**
923
+ * Add a non-create/non-update ABI method application call transaction to the transaction group.
924
+ *
925
+ * Note: we recommend using app clients to make it easier to make app calls.
926
+ * @param params The ABI method application call transaction parameters
927
+ * @returns The composer so you can chain method calls
928
+ * @example Basic example
929
+ * ```typescript
930
+ * const method = new ABIMethod({
931
+ * name: 'method',
932
+ * args: [{ name: 'arg1', type: 'string' }],
933
+ * returns: { type: 'string' },
934
+ * })
935
+ * composer.addAppCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
936
+ * ```
937
+ * @example Advanced example
938
+ * ```typescript
939
+ * const method = new ABIMethod({
940
+ * name: 'method',
941
+ * args: [{ name: 'arg1', type: 'string' }],
942
+ * returns: { type: 'string' },
943
+ * })
944
+ * composer.addAppCallMethodCall({
945
+ * sender: 'CREATORADDRESS',
946
+ * method: method,
947
+ * args: ["arg1_value"],
948
+ * onComplete: OnApplicationComplete.OptIn,
949
+ * args: [new Uint8Array(1, 2, 3, 4)]
950
+ * accountReferences: ["ACCOUNT_1"]
951
+ * appReferences: [123n, 1234n]
952
+ * assetReferences: [12345n]
953
+ * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
954
+ * accessReferences: [{ appId: 1234n }]
955
+ * lease: 'lease',
956
+ * note: 'note',
957
+ * // You wouldn't normally set this field
958
+ * firstValidRound: 1000n,
959
+ * validityWindow: 10,
960
+ * extraFee: (1000).microAlgo(),
961
+ * staticFee: (1000).microAlgo(),
962
+ * // Max fee doesn't make sense with extraFee AND staticFee
963
+ * // already specified, but here for completeness
964
+ * maxFee: (3000).microAlgo(),
965
+ * rejectVersion: 1,
966
+ *})
967
+ * ```
968
+ */
969
+ addAppCallMethodCall(params) {
970
+ this.validateReferenceParams(params);
971
+ const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
972
+ this.push(...txnArgs, {
973
+ data: {
974
+ ...params,
975
+ args: require_method_call.processAppMethodCallArgs(params.args)
976
+ },
977
+ type: "methodCall"
978
+ });
979
+ return this;
980
+ }
981
+ /**
982
+ * Add an online key registration transaction to the transaction group.
983
+ * @param params The online key registration transaction parameters
984
+ * @returns The composer so you can chain method calls
985
+ * @example Basic example
986
+ * ```typescript
987
+ * composer.addOnlineKeyRegistration({
988
+ * sender: 'SENDERADDRESS',
989
+ * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
990
+ * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
991
+ * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
992
+ * voteFirst: 1n,
993
+ * voteLast: 1000n,
994
+ * voteKeyDilution: 1n,
995
+ * })
996
+ * ```
997
+ * @example Advanced example
998
+ * ```typescript
999
+ * composer.addOnlineKeyRegistration({
1000
+ * sender: 'SENDERADDRESS',
1001
+ * voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
1002
+ * selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
1003
+ * stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
1004
+ * voteFirst: 1n,
1005
+ * voteLast: 1000n,
1006
+ * voteKeyDilution: 1n,
1007
+ * lease: 'lease',
1008
+ * note: 'note',
1009
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
1010
+ * rekeyTo: 'REKEYTOADDRESS',
1011
+ * // You wouldn't normally set this field
1012
+ * firstValidRound: 1000n,
1013
+ * validityWindow: 10,
1014
+ * extraFee: (1000).microAlgo(),
1015
+ * staticFee: (1000).microAlgo(),
1016
+ * // Max fee doesn't make sense with extraFee AND staticFee
1017
+ * // already specified, but here for completeness
1018
+ * maxFee: (3000).microAlgo(),
1019
+ * })
1020
+ * ```
1021
+ */
1022
+ addOnlineKeyRegistration(params) {
1023
+ this.push({
1024
+ data: params,
1025
+ type: "keyReg"
1026
+ });
1027
+ return this;
1028
+ }
1029
+ /**
1030
+ * Add an offline key registration transaction to the transaction group.
1031
+ * @param params The offline key registration transaction parameters
1032
+ * @returns The composer so you can chain method calls
1033
+ * @example Basic example
1034
+ * ```typescript
1035
+ * composer.addOfflineKeyRegistration({
1036
+ * sender: 'SENDERADDRESS',
1037
+ * })
1038
+ * ```
1039
+ * @example Advanced example
1040
+ * ```typescript
1041
+ * composer.addOfflineKeyRegistration({
1042
+ * sender: 'SENDERADDRESS',
1043
+ * lease: 'lease',
1044
+ * note: 'note',
1045
+ * // Use this with caution, it's generally better to use algorand.account.rekeyAccount
1046
+ * rekeyTo: 'REKEYTOADDRESS',
1047
+ * // You wouldn't normally set this field
1048
+ * firstValidRound: 1000n,
1049
+ * validityWindow: 10,
1050
+ * extraFee: (1000).microAlgo(),
1051
+ * staticFee: (1000).microAlgo(),
1052
+ * // Max fee doesn't make sense with extraFee AND staticFee
1053
+ * // already specified, but here for completeness
1054
+ * maxFee: (3000).microAlgo(),
1055
+ * })
1056
+ * ```
1057
+ */
1058
+ addOfflineKeyRegistration(params) {
1059
+ this.push({
1060
+ data: params,
1061
+ type: "keyReg"
1062
+ });
1063
+ return this;
1064
+ }
1065
+ /**
1066
+ * Get the number of transactions currently added to this composer.
1067
+ * @returns The number of transactions currently added to this composer
1068
+ */
1069
+ count() {
1070
+ return this.txns.length;
1071
+ }
1072
+ /**
1073
+ * Build the transaction composer.
1074
+ *
1075
+ * This method performs resource population and inner transaction fee coverage if these options are set in the composer.
1076
+ *
1077
+ * Once this method is called, no further transactions will be able to be added.
1078
+ * You can safely call this method multiple times to get the same result.
1079
+ * @returns The built transaction composer, the transactions and any corresponding method calls
1080
+ * @example
1081
+ * ```typescript
1082
+ * const { transactions, methodCalls } = await composer.build()
1083
+ * ```
1084
+ */
1085
+ async build() {
1086
+ if (!this.transactionsWithSigners) {
1087
+ const suggestedParams = await this.getSuggestedParams();
1088
+ const builtTransactions = await this._buildTransactions(suggestedParams);
1089
+ this.rawBuildTransactions = builtTransactions.transactions.map((txn) => new require_transaction$1.Transaction({ ...txn }));
1090
+ const groupAnalysis = (this.composerConfig.coverAppCallInnerTransactionFees || this.composerConfig.populateAppCallResources) && builtTransactions.transactions.some((txn) => txn.type === require_transaction_type.TransactionType.AppCall) ? await this.analyzeGroupRequirements(builtTransactions.transactions, suggestedParams, this.composerConfig) : void 0;
1091
+ this.populateTransactionAndGroupResources(builtTransactions.transactions, groupAnalysis);
1092
+ this.transactionsWithSigners = builtTransactions.transactions.map((txn, index) => {
1093
+ return {
1094
+ txn,
1095
+ signer: builtTransactions.signers.get(index) ?? this.getSigner(txn.sender)
1096
+ };
1097
+ });
1098
+ }
1099
+ const methodCalls = /* @__PURE__ */ new Map();
1100
+ this.txns.forEach((txn, index) => {
1101
+ if (txn.type === "methodCall") methodCalls.set(index, txn.data.method);
1102
+ });
1103
+ return {
1104
+ transactions: this.transactionsWithSigners,
1105
+ methodCalls
1106
+ };
1107
+ }
1108
+ async _buildTransactions(suggestedParams) {
1109
+ const defaultValidityWindow = !this.defaultValidityWindowIsExplicit && require_network_client.genesisIdIsLocalNet(suggestedParams.genesisId ?? "unknown") ? 1000n : this.defaultValidityWindow;
1110
+ const signers = /* @__PURE__ */ new Map();
1111
+ const transactions = new Array();
1112
+ let transactionIndex = 0;
1113
+ for (const ctxn of this.txns) if (ctxn.type === "txn") {
1114
+ require_transaction$1.validateTransaction(ctxn.data.txn);
1115
+ transactions.push(ctxn.data.txn);
1116
+ if (ctxn.data.signer) signers.set(transactionIndex, ctxn.data.signer);
1117
+ transactionIndex++;
1118
+ } else if (ctxn.type === "asyncTxn") {
1119
+ const transaction = await ctxn.data.txn;
1120
+ require_transaction$1.validateTransaction(transaction);
1121
+ transactions.push(transaction);
1122
+ if (ctxn.data.signer) signers.set(transactionIndex, ctxn.data.signer);
1123
+ transactionIndex++;
1124
+ } else {
1125
+ let transaction;
1126
+ switch (ctxn.type) {
1127
+ case "pay":
1128
+ transaction = require_payment.buildPayment(ctxn.data, suggestedParams, defaultValidityWindow);
1129
+ break;
1130
+ case "assetCreate":
1131
+ transaction = require_asset_config.buildAssetCreate(ctxn.data, suggestedParams, defaultValidityWindow);
1132
+ break;
1133
+ case "assetConfig":
1134
+ transaction = require_asset_config.buildAssetConfig(ctxn.data, suggestedParams, defaultValidityWindow);
1135
+ break;
1136
+ case "assetFreeze":
1137
+ transaction = require_asset_config.buildAssetFreeze(ctxn.data, suggestedParams, defaultValidityWindow);
1138
+ break;
1139
+ case "assetDestroy":
1140
+ transaction = require_asset_config.buildAssetDestroy(ctxn.data, suggestedParams, defaultValidityWindow);
1141
+ break;
1142
+ case "assetTransfer":
1143
+ transaction = require_asset_transfer.buildAssetTransfer(ctxn.data, suggestedParams, defaultValidityWindow);
1144
+ break;
1145
+ case "assetOptIn":
1146
+ transaction = require_asset_transfer.buildAssetOptIn(ctxn.data, suggestedParams, defaultValidityWindow);
1147
+ break;
1148
+ case "assetOptOut":
1149
+ transaction = require_asset_transfer.buildAssetOptOut(ctxn.data, suggestedParams, defaultValidityWindow);
1150
+ break;
1151
+ case "appCall":
1152
+ if (ctxn.data.appId === void 0 || ctxn.data.appId === 0) transaction = await require_app_call$1.buildAppCreate(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
1153
+ else if ("approvalProgram" in ctxn.data && "clearStateProgram" in ctxn.data) transaction = await require_app_call$1.buildAppUpdate(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
1154
+ else transaction = require_app_call$1.buildAppCall(ctxn.data, suggestedParams, defaultValidityWindow);
1155
+ break;
1156
+ case "keyReg":
1157
+ transaction = require_key_registration.buildKeyReg(ctxn.data, suggestedParams, defaultValidityWindow);
1158
+ break;
1159
+ case "methodCall":
1160
+ if (ctxn.data.appId === void 0 || ctxn.data.appId === 0) transaction = await require_method_call.buildAppCreateMethodCall(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
1161
+ else if ("approvalProgram" in ctxn.data && "clearStateProgram" in ctxn.data) transaction = await require_method_call.buildAppUpdateMethodCall(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
1162
+ else transaction = await require_method_call.buildAppCallMethodCall(ctxn.data, suggestedParams, defaultValidityWindow);
1163
+ break;
1164
+ default: throw new Error(`Unsupported transaction type: ${ctxn.type}`);
1165
+ }
1166
+ if (transaction.fee === void 0) transaction = require_transaction$1.assignFee(transaction, {
1167
+ feePerByte: suggestedParams.fee,
1168
+ minFee: suggestedParams.minFee,
1169
+ extraFee: ctxn.data.extraFee?.microAlgos,
1170
+ maxFee: ctxn.data.maxFee?.microAlgos
1171
+ });
1172
+ require_transaction$1.validateTransaction(transaction);
1173
+ transactions.push(transaction);
1174
+ if (ctxn.data.signer) {
1175
+ const signer = "signer" in ctxn.data.signer ? ctxn.data.signer.signer : ctxn.data.signer;
1176
+ signers.set(transactionIndex, signer);
1177
+ }
1178
+ transactionIndex++;
1179
+ }
1180
+ if (transactions.length > require_constants.MAX_TRANSACTION_GROUP_SIZE) throw new Error(`Transaction group size ${transactions.length} exceeds the maximum limit of ${require_constants.MAX_TRANSACTION_GROUP_SIZE}`);
1181
+ const methodCalls = /* @__PURE__ */ new Map();
1182
+ this.txns.forEach((txn, index) => {
1183
+ if (txn.type === "methodCall") methodCalls.set(index, txn.data.method);
1184
+ });
1185
+ return {
1186
+ transactions,
1187
+ methodCalls,
1188
+ signers
1189
+ };
1190
+ }
1191
+ /**
1192
+ * Builds all transactions in the composer and returns them along with method calls and signers.
1193
+ *
1194
+ * Note: This method only builds the transactions as-is without resource population or automatic grouping.
1195
+ * Use this when you need the raw transactions.
1196
+ * @returns An object containing the array of built transactions, method calls, and signers
1197
+ * @example
1198
+ * ```typescript
1199
+ * const { transactions, methodCalls, signers } = await composer.buildTransactions()
1200
+ * ```
1201
+ */
1202
+ async buildTransactions() {
1203
+ const suggestedParams = await this.getSuggestedParams();
1204
+ const buildResult = await this._buildTransactions(suggestedParams);
1205
+ return {
1206
+ ...buildResult,
1207
+ transactions: buildResult.transactions
1208
+ };
1209
+ }
1210
+ populateTransactionAndGroupResources(transactions, groupAnalysis) {
1211
+ if (groupAnalysis) {
1212
+ let surplusGroupFees = 0n;
1213
+ const transactionAnalysis = [];
1214
+ groupAnalysis.transactions.forEach((txnAnalysis, groupIndex) => {
1215
+ if (txnAnalysis.requiredFeeDelta && require_fee_coverage.FeeDelta.isSurplus(txnAnalysis.requiredFeeDelta)) surplusGroupFees += require_fee_coverage.FeeDelta.amount(txnAnalysis.requiredFeeDelta);
1216
+ const ctxn = this.txns[groupIndex];
1217
+ const txn = transactions[groupIndex];
1218
+ const logicalMaxFee = getLogicalMaxFee(ctxn);
1219
+ const isImmutableFee = logicalMaxFee !== void 0 && logicalMaxFee === (txn.fee || 0n);
1220
+ let priority = require_fee_coverage.FeePriority.Covered;
1221
+ if (txnAnalysis.requiredFeeDelta && require_fee_coverage.FeeDelta.isDeficit(txnAnalysis.requiredFeeDelta)) {
1222
+ const deficitAmount = require_fee_coverage.FeeDelta.amount(txnAnalysis.requiredFeeDelta);
1223
+ if (isImmutableFee || txn.type !== require_transaction_type.TransactionType.AppCall) priority = require_fee_coverage.FeePriority.ImmutableDeficit(deficitAmount);
1224
+ else priority = require_fee_coverage.FeePriority.ModifiableDeficit(deficitAmount);
1225
+ }
1226
+ transactionAnalysis.push({
1227
+ groupIndex,
1228
+ requiredFeeDelta: txnAnalysis.requiredFeeDelta,
1229
+ priority,
1230
+ unnamedResourcesAccessed: txnAnalysis.unnamedResourcesAccessed
1231
+ });
1232
+ });
1233
+ transactionAnalysis.sort((a, b) => b.priority.compare(a.priority));
1234
+ const indexesWithAccessReferences = [];
1235
+ for (const { groupIndex, requiredFeeDelta, unnamedResourcesAccessed } of transactionAnalysis) {
1236
+ if (requiredFeeDelta && require_fee_coverage.FeeDelta.isDeficit(requiredFeeDelta)) {
1237
+ const deficitAmount = require_fee_coverage.FeeDelta.amount(requiredFeeDelta);
1238
+ let additionalFeeDelta;
1239
+ if (surplusGroupFees === 0n) additionalFeeDelta = requiredFeeDelta;
1240
+ else if (surplusGroupFees >= deficitAmount) surplusGroupFees -= deficitAmount;
1241
+ else {
1242
+ additionalFeeDelta = require_fee_coverage.FeeDelta.fromBigInt(deficitAmount - surplusGroupFees);
1243
+ surplusGroupFees = 0n;
1244
+ }
1245
+ if (additionalFeeDelta && require_fee_coverage.FeeDelta.isDeficit(additionalFeeDelta)) {
1246
+ const additionalDeficitAmount = require_fee_coverage.FeeDelta.amount(additionalFeeDelta);
1247
+ if (transactions[groupIndex].type === require_transaction_type.TransactionType.AppCall) {
1248
+ const transactionFee = (transactions[groupIndex].fee || 0n) + additionalDeficitAmount;
1249
+ const logicalMaxFee = getLogicalMaxFee(this.txns[groupIndex]);
1250
+ if (!logicalMaxFee || transactionFee > logicalMaxFee) throw new Error(`Calculated transaction fee ${transactionFee} µALGO is greater than max of ${logicalMaxFee ?? 0n} for transaction ${groupIndex}`);
1251
+ transactions[groupIndex].fee = transactionFee;
1252
+ } else throw new Error(`An additional fee of ${additionalDeficitAmount} µALGO is required for non app call transaction ${groupIndex}`);
1253
+ }
1254
+ }
1255
+ if (unnamedResourcesAccessed && transactions[groupIndex].type === require_transaction_type.TransactionType.AppCall) if (!(transactions[groupIndex].appCall?.accessReferences && transactions[groupIndex].appCall?.accessReferences?.length)) require_app_call$1.populateTransactionResources(transactions[groupIndex], unnamedResourcesAccessed, groupIndex);
1256
+ else indexesWithAccessReferences.push(groupIndex);
1257
+ }
1258
+ if (indexesWithAccessReferences.length > 0) require_config.Config.logger.warn(`Resource population will be skipped for transaction indexes ${indexesWithAccessReferences.join(", ")} as they use access references.`);
1259
+ if (groupAnalysis.unnamedResourcesAccessed) require_app_call$1.populateGroupResources(transactions, groupAnalysis.unnamedResourcesAccessed);
1260
+ }
1261
+ if (transactions.length > 1) {
1262
+ const groupedTransactions = require_transaction$1.groupTransactions(transactions);
1263
+ transactions.forEach((t) => t.group = groupedTransactions[0].group);
1264
+ return transactions;
1265
+ } else return transactions;
1266
+ }
1267
+ async analyzeGroupRequirements(transactions, suggestedParams, analysisParams) {
1268
+ const appCallIndexesWithoutMaxFees = [];
1269
+ let transactionsToSimulate = transactions.map((txn, groupIndex) => {
1270
+ const ctxn = this.txns[groupIndex];
1271
+ const params = { ...txn };
1272
+ delete params.group;
1273
+ if (analysisParams.coverAppCallInnerTransactionFees && txn.type === require_transaction_type.TransactionType.AppCall) {
1274
+ const logicalMaxFee = getLogicalMaxFee(ctxn);
1275
+ if (logicalMaxFee !== void 0) params.fee = logicalMaxFee;
1276
+ else appCallIndexesWithoutMaxFees.push(groupIndex);
1277
+ }
1278
+ return new require_transaction$1.Transaction(params);
1279
+ });
1280
+ if (transactionsToSimulate.length > 1) transactionsToSimulate = require_transaction$1.groupTransactions(transactionsToSimulate);
1281
+ if (analysisParams.coverAppCallInnerTransactionFees && appCallIndexesWithoutMaxFees.length > 0) throw new Error(`Please provide a maxFee for each app call transaction when coverAppCallInnerTransactionFees is enabled. Required for transaction ${appCallIndexesWithoutMaxFees.join(", ")}`);
1282
+ const simulateRequest = {
1283
+ txnGroups: [{ txns: transactionsToSimulate.map((txn) => ({
1284
+ txn,
1285
+ sig: require_constants.EMPTY_SIGNATURE
1286
+ })) }],
1287
+ allowUnnamedResources: true,
1288
+ allowEmptySignatures: true,
1289
+ fixSigners: true,
1290
+ allowMoreLogging: true,
1291
+ execTraceConfig: {
1292
+ enable: true,
1293
+ scratchChange: true,
1294
+ stackChange: true,
1295
+ stateChange: true
1296
+ }
1297
+ };
1298
+ const groupResponse = (await this.algod.simulateTransactions(simulateRequest)).txnGroups[0];
1299
+ if (groupResponse.failureMessage) {
1300
+ if (analysisParams.coverAppCallInnerTransactionFees && groupResponse.failureMessage.includes("fee too small")) throw new Error("Fees were too small to resolve execution info via simulate. You may need to increase an app call transaction maxFee.");
1301
+ throw new Error(`Error resolving execution info via simulate in transaction ${groupResponse.failedAt?.join(", ")}: ${groupResponse.failureMessage}`);
1302
+ }
1303
+ const txnAnalysisResults = groupResponse.txnResults.map((simulateTxnResult, groupIndex) => {
1304
+ const btxn = transactions[groupIndex];
1305
+ let requiredFeeDelta;
1306
+ if (analysisParams.coverAppCallInnerTransactionFees) {
1307
+ const minTxnFee = require_transaction$1.calculateFee(btxn, {
1308
+ feePerByte: suggestedParams.fee,
1309
+ minFee: suggestedParams.minFee
1310
+ });
1311
+ const txnFeeDelta = require_fee_coverage.FeeDelta.fromBigInt(minTxnFee - (btxn.fee ?? 0n));
1312
+ if (btxn.type === require_transaction_type.TransactionType.AppCall) {
1313
+ const innerTxnsFeeDelta = require_fee_coverage.calculateInnerFeeDelta(simulateTxnResult.txnResult.innerTxns, suggestedParams.minFee);
1314
+ requiredFeeDelta = require_fee_coverage.FeeDelta.fromBigInt((innerTxnsFeeDelta ? require_fee_coverage.FeeDelta.toBigInt(innerTxnsFeeDelta) : 0n) + (txnFeeDelta ? require_fee_coverage.FeeDelta.toBigInt(txnFeeDelta) : 0n));
1315
+ } else requiredFeeDelta = txnFeeDelta;
1316
+ }
1317
+ return {
1318
+ requiredFeeDelta,
1319
+ unnamedResourcesAccessed: analysisParams.populateAppCallResources ? simulateTxnResult.unnamedResourcesAccessed : void 0
1320
+ };
1321
+ });
1322
+ const sortedResources = groupResponse.unnamedResourcesAccessed;
1323
+ const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1324
+ if (sortedResources) {
1325
+ sortedResources.accounts?.sort((a, b) => compare(a.toString(), b.toString()));
1326
+ sortedResources.assets?.sort(compare);
1327
+ sortedResources.apps?.sort(compare);
1328
+ sortedResources.boxes?.sort((a, b) => {
1329
+ return compare(`${a.appId}-${a.name}`, `${b.appId}-${b.name}`);
1330
+ });
1331
+ sortedResources.appLocals?.sort((a, b) => {
1332
+ return compare(`${a.appId}-${a.address}`, `${b.appId}-${b.address}`);
1333
+ });
1334
+ sortedResources.assetHoldings?.sort((a, b) => {
1335
+ return compare(`${a.assetId}-${a.address}`, `${b.assetId}-${b.address}`);
1336
+ });
1337
+ }
1338
+ return {
1339
+ transactions: txnAnalysisResults,
1340
+ unnamedResourcesAccessed: analysisParams.populateAppCallResources ? sortedResources : void 0
1341
+ };
1342
+ }
1343
+ /**
1344
+ * Rebuild the group, discarding any previously built transactions.
1345
+ * This will potentially cause new signers and suggested params to be used if the callbacks return a new value compared to the first build.
1346
+ * @returns The newly built transaction composer and the transactions
1347
+ * @example
1348
+ * ```typescript
1349
+ * const { atc, transactions, methodCalls } = await composer.rebuild()
1350
+ * ```
1351
+ */
1352
+ async rebuild() {
1353
+ this.reset();
1354
+ return await this.build();
1355
+ }
1356
+ reset() {
1357
+ this.signedTransactions = void 0;
1358
+ this.transactionsWithSigners = void 0;
1359
+ }
1360
+ /**
1361
+ * Compose the transaction group and send it to the network.
1362
+ * @param params The parameters to control execution with
1363
+ * @returns The execution result
1364
+ * @example
1365
+ * ```typescript
1366
+ * const result = await composer.send()
1367
+ * ```
1368
+ */
1369
+ async send(params) {
1370
+ const effectiveConfig = {
1371
+ coverAppCallInnerTransactionFees: params?.coverAppCallInnerTransactionFees ?? this.composerConfig.coverAppCallInnerTransactionFees,
1372
+ populateAppCallResources: params?.populateAppCallResources ?? this.composerConfig.populateAppCallResources
1373
+ };
1374
+ if (this.composerConfig.coverAppCallInnerTransactionFees !== effectiveConfig.coverAppCallInnerTransactionFees || this.composerConfig.populateAppCallResources !== effectiveConfig.populateAppCallResources) {
1375
+ this.composerConfig = effectiveConfig;
1376
+ this.reset();
1377
+ }
1378
+ try {
1379
+ await this.gatherSignatures();
1380
+ if (!this.transactionsWithSigners || this.transactionsWithSigners.length === 0 || !this.signedTransactions || this.signedTransactions.length === 0) throw new Error("No transactions available");
1381
+ const transactionsToSend = this.transactionsWithSigners.map((stxn) => stxn.txn);
1382
+ const transactionIds = transactionsToSend.map((txn) => txn.txId());
1383
+ if (transactionsToSend.length > 1) {
1384
+ const groupId = transactionsToSend[0].group ? buffer.Buffer.from(transactionsToSend[0].group).toString("base64") : "";
1385
+ require_config.Config.getLogger(params?.suppressLog).verbose(`Sending group of ${transactionsToSend.length} transactions (${groupId})`, { transactionsToSend });
1386
+ require_config.Config.getLogger(params?.suppressLog).debug(`Transaction IDs (${groupId})`, transactionIds);
1387
+ }
1388
+ if (require_config.Config.debug && require_config.Config.traceAll) await this.simulate({
1389
+ allowEmptySignatures: true,
1390
+ fixSigners: true,
1391
+ allowMoreLogging: true,
1392
+ execTraceConfig: {
1393
+ enable: true,
1394
+ scratchChange: true,
1395
+ stackChange: true,
1396
+ stateChange: true
1397
+ },
1398
+ resultOnFailure: true
1399
+ });
1400
+ const group = this.transactionsWithSigners[0].txn.group;
1401
+ let waitRounds = params?.maxRoundsToWaitForConfirmation;
1402
+ if (waitRounds === void 0) {
1403
+ const firstRound = (await this.getSuggestedParams()).firstValid;
1404
+ const lastRound = this.transactionsWithSigners.reduce((max, txn) => txn.txn.lastValid > max ? txn.txn.lastValid : max, 0n);
1405
+ waitRounds = Number(lastRound - firstRound) + 1;
1406
+ }
1407
+ await this.algod.sendRawTransaction(this.signedTransactions);
1408
+ if (transactionsToSend.length > 1 && group) require_config.Config.getLogger(params?.suppressLog).verbose(`Group transaction (${buffer.Buffer.from(group).toString("base64")}) sent with ${transactionsToSend.length} transactions`);
1409
+ else require_config.Config.getLogger(params?.suppressLog).verbose(`Sent transaction ID ${transactionsToSend[0].txId()} ${transactionsToSend[0].type} from ${transactionsToSend[0].sender}`);
1410
+ let confirmations = new Array();
1411
+ if (params?.maxRoundsToWaitForConfirmation !== 0) confirmations = await Promise.all(transactionIds.map(async (id) => await require_transaction.waitForConfirmation(id, waitRounds, this.algod)));
1412
+ const abiReturns = this.parseAbiReturnValues(confirmations);
1413
+ return {
1414
+ groupId: group ? buffer.Buffer.from(group).toString("base64") : void 0,
1415
+ transactions: transactionsToSend,
1416
+ txIds: transactionIds,
1417
+ returns: abiReturns,
1418
+ confirmations
1419
+ };
1420
+ } catch (originalError) {
1421
+ const errorMessage = originalError.body?.message ?? originalError.message ?? "Received error executing Transaction Composer";
1422
+ const err = new Error(errorMessage);
1423
+ err.cause = originalError;
1424
+ if (typeof originalError === "object") err.name = originalError.name;
1425
+ let sentTransactions;
1426
+ if (this.transactionsWithSigners) sentTransactions = this.transactionsWithSigners.map((t) => t.txn);
1427
+ else if (this.rawBuildTransactions) sentTransactions = this.rawBuildTransactions.length > 1 ? require_transaction$1.groupTransactions(this.rawBuildTransactions) : this.rawBuildTransactions;
1428
+ if (require_config.Config.debug && typeof originalError === "object" && sentTransactions) {
1429
+ err.traces = [];
1430
+ require_config.Config.getLogger(params?.suppressLog).error("Received error executing Transaction Composer and debug flag enabled; attempting simulation to get more information", err);
1431
+ const transactionsWithEmptySigners = sentTransactions.map((txn) => ({
1432
+ txn,
1433
+ signer: require_signer.makeEmptyTransactionSigner()
1434
+ }));
1435
+ const signedTransactions = require_signed_transaction.decodeSignedTransactions(await this.signTransactions(transactionsWithEmptySigners));
1436
+ const simulateResponse = await this.algod.simulateTransactions({
1437
+ txnGroups: [{ txns: signedTransactions }],
1438
+ allowEmptySignatures: true,
1439
+ fixSigners: true,
1440
+ allowMoreLogging: true,
1441
+ execTraceConfig: {
1442
+ enable: true,
1443
+ scratchChange: true,
1444
+ stackChange: true,
1445
+ stateChange: true
1446
+ }
1447
+ });
1448
+ if (require_config.Config.debug && !require_config.Config.traceAll) await require_config.Config.events.emitAsync(require_lifecycle_events.EventType.TxnGroupSimulated, { simulateResponse });
1449
+ if (simulateResponse && simulateResponse.txnGroups[0].failedAt) for (const txn of simulateResponse.txnGroups[0].txnResults) err.traces.push({
1450
+ trace: txn.execTrace,
1451
+ appBudget: txn.appBudgetConsumed,
1452
+ logicSigBudget: txn.logicSigBudgetConsumed,
1453
+ logs: txn.txnResult.logs,
1454
+ message: simulateResponse.txnGroups[0].failureMessage
1455
+ });
1456
+ } else require_config.Config.getLogger(params?.suppressLog).error("Received error executing Transaction Composer, for more information enable the debug flag", err);
1457
+ err.sentTransactions = sentTransactions ?? [];
1458
+ throw await this.transformError(err);
1459
+ }
1460
+ }
1461
+ async simulate(options) {
1462
+ const { skipSignatures = false, resultOnFailure = false, ...rawOptions } = options ?? {};
1463
+ if (skipSignatures) {
1464
+ rawOptions.allowEmptySignatures = true;
1465
+ rawOptions.fixSigners = true;
1466
+ }
1467
+ let transactionsWithSigner;
1468
+ if (!this.transactionsWithSigners) {
1469
+ const builtTransactions = await this.buildTransactions();
1470
+ transactionsWithSigner = (builtTransactions.transactions.length > 1 ? require_transaction$1.groupTransactions(builtTransactions.transactions) : builtTransactions.transactions).map((txn, index) => ({
1471
+ txn,
1472
+ signer: skipSignatures ? require_signer.makeEmptyTransactionSigner() : builtTransactions.signers.get(index) ?? require_signer.makeEmptyTransactionSigner()
1473
+ }));
1474
+ } else transactionsWithSigner = this.transactionsWithSigners.map((e) => ({
1475
+ txn: e.txn,
1476
+ signer: skipSignatures ? require_signer.makeEmptyTransactionSigner() : e.signer
1477
+ }));
1478
+ const transactions = transactionsWithSigner.map((e) => e.txn);
1479
+ const simulateRequest = {
1480
+ txnGroups: [{ txns: require_signed_transaction.decodeSignedTransactions(await this.signTransactions(transactionsWithSigner)) }],
1481
+ ...rawOptions,
1482
+ ...require_config.Config.debug ? {
1483
+ allowEmptySignatures: true,
1484
+ fixSigners: true,
1485
+ allowMoreLogging: true,
1486
+ execTraceConfig: {
1487
+ enable: true,
1488
+ scratchChange: true,
1489
+ stackChange: true,
1490
+ stateChange: true
1491
+ }
1492
+ } : void 0
1493
+ };
1494
+ const simulateResponse = await this.algod.simulateTransactions(simulateRequest);
1495
+ const simulateResult = simulateResponse.txnGroups[0];
1496
+ if (simulateResult?.failureMessage && !resultOnFailure) {
1497
+ const errorMessage = `Transaction failed at transaction(s) ${simulateResult.failedAt?.join(", ") || "unknown"} in the group. ${simulateResult.failureMessage}`;
1498
+ const error = new Error(errorMessage);
1499
+ if (require_config.Config.debug) await require_config.Config.events.emitAsync(require_lifecycle_events.EventType.TxnGroupSimulated, { simulateResponse });
1500
+ throw await this.transformError(error);
1501
+ }
1502
+ if (require_config.Config.debug && require_config.Config.traceAll) await require_config.Config.events.emitAsync(require_lifecycle_events.EventType.TxnGroupSimulated, { simulateResponse });
1503
+ const abiReturns = this.parseAbiReturnValues(simulateResult.txnResults.map((t) => t.txnResult));
1504
+ return {
1505
+ confirmations: simulateResult.txnResults.map((t) => t.txnResult),
1506
+ transactions,
1507
+ txIds: transactions.map((t) => t.txId()),
1508
+ groupId: buffer.Buffer.from(transactions[0].group ?? new Uint8Array()).toString("base64"),
1509
+ simulateResponse,
1510
+ returns: abiReturns
1511
+ };
1512
+ }
1513
+ /**
1514
+ * Create an encoded transaction note that follows the ARC-2 spec.
1515
+ *
1516
+ * https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md
1517
+ * @param note The ARC-2 transaction note data
1518
+ * @returns The binary encoded transaction note
1519
+ */
1520
+ static arc2Note(note) {
1521
+ const arc2Payload = `${note.dAppName}:${note.format}${typeof note.data === "string" ? note.data : require_util.asJson(note.data)}`;
1522
+ return new TextEncoder().encode(arc2Payload);
1523
+ }
1524
+ async gatherSignatures() {
1525
+ if (this.signedTransactions) return this.signedTransactions;
1526
+ await this.build();
1527
+ if (!this.transactionsWithSigners || this.transactionsWithSigners.length === 0) throw new Error("No transactions available to sign");
1528
+ this.signedTransactions = await this.signTransactions(this.transactionsWithSigners);
1529
+ return this.signedTransactions;
1530
+ }
1531
+ async signTransactions(transactionsWithSigners) {
1532
+ if (transactionsWithSigners.length === 0) throw new Error("No transactions available to sign");
1533
+ const transactions = transactionsWithSigners.map((txnWithSigner) => txnWithSigner.txn);
1534
+ const signerGroups = /* @__PURE__ */ new Map();
1535
+ transactionsWithSigners.forEach(({ signer }, index) => {
1536
+ const indexes = signerGroups.get(signer) ?? [];
1537
+ indexes.push(index);
1538
+ signerGroups.set(signer, indexes);
1539
+ });
1540
+ const signerEntries = Array.from(signerGroups);
1541
+ const signedGroups = await Promise.all(signerEntries.map(([signer, indexes]) => signer(transactions, indexes)));
1542
+ const encodedSignedTransactions = new Array(transactionsWithSigners.length).fill(null);
1543
+ signerEntries.forEach(([, indexes], signerIndex) => {
1544
+ const stxs = signedGroups[signerIndex];
1545
+ indexes.forEach((txIndex, stxIndex) => {
1546
+ encodedSignedTransactions[txIndex] = stxs[stxIndex] ?? null;
1547
+ });
1548
+ });
1549
+ const unsignedIndexes = encodedSignedTransactions.map((stxn, index) => stxn == null ? index : null).filter((index) => index !== null);
1550
+ if (unsignedIndexes.length > 0) throw new Error(`Transactions at indexes [${unsignedIndexes.join(", ")}] were not signed`);
1551
+ return encodedSignedTransactions;
1552
+ }
1553
+ parseAbiReturnValues(confirmations) {
1554
+ const abiReturns = new Array();
1555
+ for (let i = 0; i < confirmations.length; i++) {
1556
+ const confirmation = confirmations[i];
1557
+ const txn = this.txns[i];
1558
+ if (txn?.type !== "methodCall") continue;
1559
+ const abiReturn = require_app_manager.AppManager.getABIReturn(confirmation, txn.data.method);
1560
+ if (abiReturn !== void 0) abiReturns.push(abiReturn);
1561
+ }
1562
+ return abiReturns;
1563
+ }
1564
+ setMaxFees(maxFees) {
1565
+ maxFees.forEach((_, index) => {
1566
+ if (index > this.txns.length - 1) throw new Error(`Index ${index} is out of range. The composer only contains ${this.txns.length} transactions`);
1567
+ });
1568
+ maxFees.forEach((maxFee, index) => {
1569
+ this.txns[index].data.maxFee = new require_amount.AlgoAmount({ microAlgos: maxFee.microAlgos });
1570
+ });
1571
+ }
1572
+ };
1573
+ /** Get the logical maximum fee based on staticFee and maxFee */
1574
+ function getLogicalMaxFee(ctxn) {
1575
+ if (ctxn.type === "txn" || ctxn.type === "asyncTxn") return;
1576
+ const maxFee = ctxn.data.maxFee;
1577
+ const staticFee = ctxn.data.staticFee;
1578
+ if (maxFee !== void 0 && (staticFee === void 0 || maxFee.microAlgos > staticFee.microAlgos)) return maxFee.microAlgos;
1579
+ return staticFee?.microAlgos;
1580
+ }
1581
+
1582
+ //#endregion
1583
+ exports.TransactionComposer = TransactionComposer;
1584
+ //# sourceMappingURL=composer.js.map