@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/logging.mjs ADDED
@@ -0,0 +1,42 @@
1
+ //#region src/logging.ts
2
+ /** A logger implementation that writes to console */
3
+ const consoleLogger = {
4
+ error: console.error,
5
+ warn: console.warn,
6
+ info: console.info,
7
+ verbose: () => {},
8
+ debug: console.debug
9
+ };
10
+ const infoConsoleLogger = {
11
+ error: console.error,
12
+ warn: console.warn,
13
+ info: console.info,
14
+ verbose: () => {},
15
+ debug: () => {}
16
+ };
17
+ const verboseConsoleLogger = {
18
+ error: console.error,
19
+ warn: console.warn,
20
+ info: console.info,
21
+ verbose: console.trace,
22
+ debug: console.debug
23
+ };
24
+ const warningConsoleLogger = {
25
+ error: console.error,
26
+ warn: console.warn,
27
+ info: () => {},
28
+ verbose: () => {},
29
+ debug: () => {}
30
+ };
31
+ /** A logger implementation that does nothing */
32
+ const nullLogger = {
33
+ error: function(message, ...optionalParams) {},
34
+ warn: function(message, ...optionalParams) {},
35
+ info: function(message, ...optionalParams) {},
36
+ verbose: function(message, ...optionalParams) {},
37
+ debug: function(message, ...optionalParams) {}
38
+ };
39
+
40
+ //#endregion
41
+ export { consoleLogger, infoConsoleLogger, nullLogger, verboseConsoleLogger, warningConsoleLogger };
42
+ //# sourceMappingURL=logging.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.mjs","names":["consoleLogger: Logger","infoConsoleLogger: Logger","verboseConsoleLogger: Logger","warningConsoleLogger: Logger","nullLogger: Logger"],"sources":["../src/logging.ts"],"sourcesContent":["/* eslint-disable unused-imports/no-unused-vars */\n/* eslint-disable no-console */\n\nimport type { Logger } from '@algorandfoundation/algokit-common'\nexport type { Logger } from '@algorandfoundation/algokit-common'\n\n/** A logger implementation that writes to console */\nexport const consoleLogger: Logger = {\n error: console.error,\n warn: console.warn,\n info: console.info,\n verbose: () => {},\n debug: console.debug,\n}\n\nexport const infoConsoleLogger: Logger = {\n error: console.error,\n warn: console.warn,\n info: console.info,\n verbose: () => {},\n debug: () => {},\n}\n\nexport const verboseConsoleLogger: Logger = {\n error: console.error,\n warn: console.warn,\n info: console.info,\n verbose: console.trace,\n debug: console.debug,\n}\n\nexport const warningConsoleLogger: Logger = {\n error: console.error,\n warn: console.warn,\n info: () => {},\n verbose: () => {},\n debug: () => {},\n}\n\n/** A logger implementation that does nothing */\nexport const nullLogger: Logger = {\n error: function (message: string, ...optionalParams: unknown[]): void {},\n warn: function (message: string, ...optionalParams: unknown[]): void {},\n info: function (message: string, ...optionalParams: unknown[]): void {},\n verbose: function (message: string, ...optionalParams: unknown[]): void {},\n debug: function (message: string, ...optionalParams: unknown[]): void {},\n}\n"],"mappings":";;AAOA,MAAaA,gBAAwB;CACnC,OAAO,QAAQ;CACf,MAAM,QAAQ;CACd,MAAM,QAAQ;CACd,eAAe;CACf,OAAO,QAAQ;CAChB;AAED,MAAaC,oBAA4B;CACvC,OAAO,QAAQ;CACf,MAAM,QAAQ;CACd,MAAM,QAAQ;CACd,eAAe;CACf,aAAa;CACd;AAED,MAAaC,uBAA+B;CAC1C,OAAO,QAAQ;CACf,MAAM,QAAQ;CACd,MAAM,QAAQ;CACd,SAAS,QAAQ;CACjB,OAAO,QAAQ;CAChB;AAED,MAAaC,uBAA+B;CAC1C,OAAO,QAAQ;CACf,MAAM,QAAQ;CACd,YAAY;CACZ,eAAe;CACf,aAAa;CACd;;AAGD,MAAaC,aAAqB;CAChC,OAAO,SAAU,SAAiB,GAAG,gBAAiC;CACtE,MAAM,SAAU,SAAiB,GAAG,gBAAiC;CACrE,MAAM,SAAU,SAAiB,GAAG,gBAAiC;CACrE,SAAS,SAAU,SAAiB,GAAG,gBAAiC;CACxE,OAAO,SAAU,SAAiB,GAAG,gBAAiC;CACvE"}
@@ -0,0 +1,39 @@
1
+ //#region src/logic-error.d.ts
2
+ /**
3
+ * Details about a smart contract logic error
4
+ */
5
+ interface LogicErrorDetails {
6
+ /** The ID of the transaction with the logic error */
7
+ txId: string;
8
+ /** The program counter where the error was */
9
+ pc: number;
10
+ /** The error message */
11
+ msg: string;
12
+ /** The full error description */
13
+ desc: string;
14
+ /** Any trace information included in the error */
15
+ traces: Record<string, unknown>[];
16
+ }
17
+ /** Wraps key functionality around processing logic errors */
18
+ declare class LogicError extends Error {
19
+ /** Takes an error message and parses out the details of any logic errors in there.
20
+ * @param error The error message to parse
21
+ * @returns The logic error details if any, or undefined
22
+ */
23
+ static parseLogicError(error: any): LogicErrorDetails | undefined;
24
+ led: LogicErrorDetails;
25
+ program: string[];
26
+ lines: number;
27
+ teal_line: number;
28
+ stack?: string;
29
+ /**
30
+ * Create a new logic error object.
31
+ * @param errorDetails The details of the logic error
32
+ * @param program The TEAL source code, split by line
33
+ * @param getLineForPc The source map of the TEAL source code
34
+ */
35
+ constructor(errorDetails: LogicErrorDetails, program: string[], getLineForPc: (pc: number) => number | undefined);
36
+ }
37
+ //#endregion
38
+ export { LogicError, LogicErrorDetails };
39
+ //# sourceMappingURL=logic-error.d.ts.map
package/logic-error.js ADDED
@@ -0,0 +1,54 @@
1
+
2
+ //#region src/logic-error.ts
3
+ const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/;
4
+ const INNER_LOGIC_ERROR = /inner tx (\d+) failed:.*?pc=([0-9]+)/;
5
+ /** Wraps key functionality around processing logic errors */
6
+ var LogicError = class extends Error {
7
+ /** Takes an error message and parses out the details of any logic errors in there.
8
+ * @param error The error message to parse
9
+ * @returns The logic error details if any, or undefined
10
+ */
11
+ static parseLogicError(error) {
12
+ const errorMessage = error.message;
13
+ const res = LOGIC_ERROR.exec(errorMessage);
14
+ const innerRes = INNER_LOGIC_ERROR.exec(errorMessage);
15
+ if (res === null || res.length <= 3) return void 0;
16
+ return {
17
+ txId: res[1],
18
+ msg: res[2],
19
+ desc: errorMessage,
20
+ pc: parseInt(innerRes?.[2] ?? res[3] ?? "0"),
21
+ traces: error.traces
22
+ };
23
+ }
24
+ led;
25
+ program;
26
+ lines = 5;
27
+ teal_line = 0;
28
+ stack;
29
+ /**
30
+ * Create a new logic error object.
31
+ * @param errorDetails The details of the logic error
32
+ * @param program The TEAL source code, split by line
33
+ * @param getLineForPc The source map of the TEAL source code
34
+ */
35
+ constructor(errorDetails, program, getLineForPc) {
36
+ super();
37
+ this.led = errorDetails;
38
+ this.program = program;
39
+ const line = getLineForPc(errorDetails.pc);
40
+ this.teal_line = line === void 0 ? 0 : line;
41
+ this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`;
42
+ if (this.teal_line > 0) {
43
+ const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0;
44
+ const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length;
45
+ const stack_lines = program.slice(start, stop);
46
+ stack_lines[stack_lines.length / 2] += " <--- Error";
47
+ this.stack = stack_lines.join("\n");
48
+ }
49
+ }
50
+ };
51
+
52
+ //#endregion
53
+ exports.LogicError = LogicError;
54
+ //# sourceMappingURL=logic-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic-error.js","names":[],"sources":["../src/logic-error.ts"],"sourcesContent":["const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/\n// inner tx 0 failed: logic eval error: err opcode executed. Details: app=6248, pc=29, opcodes=tx\nconst INNER_LOGIC_ERROR = /inner tx (\\d+) failed:.*?pc=([0-9]+)/\n\n/**\n * Details about a smart contract logic error\n */\nexport interface LogicErrorDetails {\n /** The ID of the transaction with the logic error */\n txId: string\n /** The program counter where the error was */\n pc: number\n /** The error message */\n msg: string\n /** The full error description */\n desc: string\n /** Any trace information included in the error */\n traces: Record<string, unknown>[]\n}\n\n/** Wraps key functionality around processing logic errors */\nexport class LogicError extends Error {\n /** Takes an error message and parses out the details of any logic errors in there.\n * @param error The error message to parse\n * @returns The logic error details if any, or undefined\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static parseLogicError(error: any): LogicErrorDetails | undefined {\n const errorMessage = error.message\n const res = LOGIC_ERROR.exec(errorMessage)\n const innerRes = INNER_LOGIC_ERROR.exec(errorMessage)\n\n if (res === null || res.length <= 3) return undefined\n\n return {\n txId: res[1],\n msg: res[2],\n desc: errorMessage,\n pc: parseInt(innerRes?.[2] ?? res[3] ?? '0'),\n traces: error.traces,\n } as LogicErrorDetails\n }\n\n public led: LogicErrorDetails\n public program: string[]\n public lines = 5\n public teal_line = 0\n override stack?: string\n\n /**\n * Create a new logic error object.\n * @param errorDetails The details of the logic error\n * @param program The TEAL source code, split by line\n * @param getLineForPc The source map of the TEAL source code\n */\n constructor(errorDetails: LogicErrorDetails, program: string[], getLineForPc: (pc: number) => number | undefined) {\n super()\n this.led = errorDetails\n this.program = program\n\n const line = getLineForPc(errorDetails.pc)\n this.teal_line = line === undefined ? 0 : line\n\n this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`\n\n if (this.teal_line > 0) {\n const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0\n const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length\n\n const stack_lines = program.slice(start, stop)\n\n stack_lines[stack_lines.length / 2] += ' <--- Error'\n\n this.stack = stack_lines.join('\\n')\n }\n }\n}\n"],"mappings":";;AAAA,MAAM,cAAc;AAEpB,MAAM,oBAAoB;;AAmB1B,IAAa,aAAb,cAAgC,MAAM;;;;;CAMpC,OAAO,gBAAgB,OAA2C;EAChE,MAAM,eAAe,MAAM;EAC3B,MAAM,MAAM,YAAY,KAAK,aAAa;EAC1C,MAAM,WAAW,kBAAkB,KAAK,aAAa;AAErD,MAAI,QAAQ,QAAQ,IAAI,UAAU,EAAG,QAAO;AAE5C,SAAO;GACL,MAAM,IAAI;GACV,KAAK,IAAI;GACT,MAAM;GACN,IAAI,SAAS,WAAW,MAAM,IAAI,MAAM,IAAI;GAC5C,QAAQ,MAAM;GACf;;CAGH,AAAO;CACP,AAAO;CACP,AAAO,QAAQ;CACf,AAAO,YAAY;CACnB,AAAS;;;;;;;CAQT,YAAY,cAAiC,SAAmB,cAAkD;AAChH,SAAO;AACP,OAAK,MAAM;AACX,OAAK,UAAU;EAEf,MAAM,OAAO,aAAa,aAAa,GAAG;AAC1C,OAAK,YAAY,SAAS,SAAY,IAAI;AAE1C,OAAK,UAAU,GAAG,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI;AAExD,MAAI,KAAK,YAAY,GAAG;GACtB,MAAM,QAAQ,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ;GAC1E,MAAM,OAAO,QAAQ,SAAS,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ,QAAQ;GAElG,MAAM,cAAc,QAAQ,MAAM,OAAO,KAAK;AAE9C,eAAY,YAAY,SAAS,MAAM;AAEvC,QAAK,QAAQ,YAAY,KAAK,KAAK"}
@@ -0,0 +1,53 @@
1
+ //#region src/logic-error.ts
2
+ const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/;
3
+ const INNER_LOGIC_ERROR = /inner tx (\d+) failed:.*?pc=([0-9]+)/;
4
+ /** Wraps key functionality around processing logic errors */
5
+ var LogicError = class extends Error {
6
+ /** Takes an error message and parses out the details of any logic errors in there.
7
+ * @param error The error message to parse
8
+ * @returns The logic error details if any, or undefined
9
+ */
10
+ static parseLogicError(error) {
11
+ const errorMessage = error.message;
12
+ const res = LOGIC_ERROR.exec(errorMessage);
13
+ const innerRes = INNER_LOGIC_ERROR.exec(errorMessage);
14
+ if (res === null || res.length <= 3) return void 0;
15
+ return {
16
+ txId: res[1],
17
+ msg: res[2],
18
+ desc: errorMessage,
19
+ pc: parseInt(innerRes?.[2] ?? res[3] ?? "0"),
20
+ traces: error.traces
21
+ };
22
+ }
23
+ led;
24
+ program;
25
+ lines = 5;
26
+ teal_line = 0;
27
+ stack;
28
+ /**
29
+ * Create a new logic error object.
30
+ * @param errorDetails The details of the logic error
31
+ * @param program The TEAL source code, split by line
32
+ * @param getLineForPc The source map of the TEAL source code
33
+ */
34
+ constructor(errorDetails, program, getLineForPc) {
35
+ super();
36
+ this.led = errorDetails;
37
+ this.program = program;
38
+ const line = getLineForPc(errorDetails.pc);
39
+ this.teal_line = line === void 0 ? 0 : line;
40
+ this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`;
41
+ if (this.teal_line > 0) {
42
+ const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0;
43
+ const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length;
44
+ const stack_lines = program.slice(start, stop);
45
+ stack_lines[stack_lines.length / 2] += " <--- Error";
46
+ this.stack = stack_lines.join("\n");
47
+ }
48
+ }
49
+ };
50
+
51
+ //#endregion
52
+ export { LogicError };
53
+ //# sourceMappingURL=logic-error.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic-error.mjs","names":[],"sources":["../src/logic-error.ts"],"sourcesContent":["const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/\n// inner tx 0 failed: logic eval error: err opcode executed. Details: app=6248, pc=29, opcodes=tx\nconst INNER_LOGIC_ERROR = /inner tx (\\d+) failed:.*?pc=([0-9]+)/\n\n/**\n * Details about a smart contract logic error\n */\nexport interface LogicErrorDetails {\n /** The ID of the transaction with the logic error */\n txId: string\n /** The program counter where the error was */\n pc: number\n /** The error message */\n msg: string\n /** The full error description */\n desc: string\n /** Any trace information included in the error */\n traces: Record<string, unknown>[]\n}\n\n/** Wraps key functionality around processing logic errors */\nexport class LogicError extends Error {\n /** Takes an error message and parses out the details of any logic errors in there.\n * @param error The error message to parse\n * @returns The logic error details if any, or undefined\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static parseLogicError(error: any): LogicErrorDetails | undefined {\n const errorMessage = error.message\n const res = LOGIC_ERROR.exec(errorMessage)\n const innerRes = INNER_LOGIC_ERROR.exec(errorMessage)\n\n if (res === null || res.length <= 3) return undefined\n\n return {\n txId: res[1],\n msg: res[2],\n desc: errorMessage,\n pc: parseInt(innerRes?.[2] ?? res[3] ?? '0'),\n traces: error.traces,\n } as LogicErrorDetails\n }\n\n public led: LogicErrorDetails\n public program: string[]\n public lines = 5\n public teal_line = 0\n override stack?: string\n\n /**\n * Create a new logic error object.\n * @param errorDetails The details of the logic error\n * @param program The TEAL source code, split by line\n * @param getLineForPc The source map of the TEAL source code\n */\n constructor(errorDetails: LogicErrorDetails, program: string[], getLineForPc: (pc: number) => number | undefined) {\n super()\n this.led = errorDetails\n this.program = program\n\n const line = getLineForPc(errorDetails.pc)\n this.teal_line = line === undefined ? 0 : line\n\n this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`\n\n if (this.teal_line > 0) {\n const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0\n const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length\n\n const stack_lines = program.slice(start, stop)\n\n stack_lines[stack_lines.length / 2] += ' <--- Error'\n\n this.stack = stack_lines.join('\\n')\n }\n }\n}\n"],"mappings":";AAAA,MAAM,cAAc;AAEpB,MAAM,oBAAoB;;AAmB1B,IAAa,aAAb,cAAgC,MAAM;;;;;CAMpC,OAAO,gBAAgB,OAA2C;EAChE,MAAM,eAAe,MAAM;EAC3B,MAAM,MAAM,YAAY,KAAK,aAAa;EAC1C,MAAM,WAAW,kBAAkB,KAAK,aAAa;AAErD,MAAI,QAAQ,QAAQ,IAAI,UAAU,EAAG,QAAO;AAE5C,SAAO;GACL,MAAM,IAAI;GACV,KAAK,IAAI;GACT,MAAM;GACN,IAAI,SAAS,WAAW,MAAM,IAAI,MAAM,IAAI;GAC5C,QAAQ,MAAM;GACf;;CAGH,AAAO;CACP,AAAO;CACP,AAAO,QAAQ;CACf,AAAO,YAAY;CACnB,AAAS;;;;;;;CAQT,YAAY,cAAiC,SAAmB,cAAkD;AAChH,SAAO;AACP,OAAK,MAAM;AACX,OAAK,UAAU;EAEf,MAAM,OAAO,aAAa,aAAa,GAAG;AAC1C,OAAK,YAAY,SAAS,SAAY,IAAI;AAE1C,OAAK,UAAU,GAAG,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI;AAExD,MAAI,KAAK,YAAY,GAAG;GACtB,MAAM,QAAQ,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ;GAC1E,MAAM,OAAO,QAAQ,SAAS,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ,QAAQ;GAElG,MAAM,cAAc,QAAQ,MAAM,OAAO,KAAK;AAE9C,eAAY,YAAY,SAAS,MAAM;AAEvC,QAAK,QAAQ,YAAY,KAAK,KAAK"}
@@ -0,0 +1,43 @@
1
+ //#region src/network-client.d.ts
2
+ /** Config for an Algorand SDK client. */
3
+ interface AlgoClientConfig {
4
+ /** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
5
+ server: string;
6
+ /** The port to use e.g. 4001, 443, etc. */
7
+ port?: string | number;
8
+ /** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
9
+ token?: string | {
10
+ [name: string]: string;
11
+ };
12
+ }
13
+ /** Configuration for algod, indexer and kmd clients. */
14
+ interface AlgoConfig {
15
+ /** Algod client configuration */
16
+ algodConfig: AlgoClientConfig;
17
+ /** Indexer client configuration */
18
+ indexerConfig?: AlgoClientConfig;
19
+ /** Kmd configuration */
20
+ kmdConfig?: AlgoClientConfig;
21
+ }
22
+ /** Details of the current network. */
23
+ interface NetworkDetails {
24
+ /** Whether or not the network is TestNet. */
25
+ isTestNet: boolean;
26
+ /** Whether or not the network is MainNet. */
27
+ isMainNet: boolean;
28
+ /** Whether or not the network is LocalNet. */
29
+ isLocalNet: boolean;
30
+ /** The genesis ID of the current network. */
31
+ genesisId: string;
32
+ /** The base64 genesis hash of the current network. */
33
+ genesisHash: string;
34
+ }
35
+ /**
36
+ * Returns true if the given network genesisId is associated with a LocalNet network.
37
+ * @param genesisId The network genesis ID
38
+ * @returns Whether the given genesis ID is associated with a LocalNet network
39
+ */
40
+ declare function genesisIdIsLocalNet(genesisId: string): boolean;
41
+ //#endregion
42
+ export { AlgoClientConfig, AlgoConfig, NetworkDetails, genesisIdIsLocalNet };
43
+ //# sourceMappingURL=network-client.d.ts.map
@@ -0,0 +1,14 @@
1
+
2
+ //#region src/network-client.ts
3
+ /**
4
+ * Returns true if the given network genesisId is associated with a LocalNet network.
5
+ * @param genesisId The network genesis ID
6
+ * @returns Whether the given genesis ID is associated with a LocalNet network
7
+ */
8
+ function genesisIdIsLocalNet(genesisId) {
9
+ return genesisId === "devnet-v1" || genesisId === "sandnet-v1" || genesisId === "dockernet-v1";
10
+ }
11
+
12
+ //#endregion
13
+ exports.genesisIdIsLocalNet = genesisIdIsLocalNet;
14
+ //# sourceMappingURL=network-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-client.js","names":[],"sources":["../src/network-client.ts"],"sourcesContent":["/** Config for an Algorand SDK client. */\nexport interface AlgoClientConfig {\n /** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */\n server: string\n /** The port to use e.g. 4001, 443, etc. */\n port?: string | number\n /** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */\n token?: string | { [name: string]: string }\n}\n\n/** Configuration for algod, indexer and kmd clients. */\nexport interface AlgoConfig {\n /** Algod client configuration */\n algodConfig: AlgoClientConfig\n /** Indexer client configuration */\n indexerConfig?: AlgoClientConfig\n /** Kmd configuration */\n kmdConfig?: AlgoClientConfig\n}\n\n/** Details of the current network. */\nexport interface NetworkDetails {\n /** Whether or not the network is TestNet. */\n isTestNet: boolean\n /** Whether or not the network is MainNet. */\n isMainNet: boolean\n /** Whether or not the network is LocalNet. */\n isLocalNet: boolean\n /** The genesis ID of the current network. */\n genesisId: string\n /** The base64 genesis hash of the current network. */\n genesisHash: string\n}\n\n/**\n * Returns true if the given network genesisId is associated with a LocalNet network.\n * @param genesisId The network genesis ID\n * @returns Whether the given genesis ID is associated with a LocalNet network\n */\nexport function genesisIdIsLocalNet(genesisId: string) {\n return genesisId === 'devnet-v1' || genesisId === 'sandnet-v1' || genesisId === 'dockernet-v1'\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,oBAAoB,WAAmB;AACrD,QAAO,cAAc,eAAe,cAAc,gBAAgB,cAAc"}
@@ -0,0 +1,13 @@
1
+ //#region src/network-client.ts
2
+ /**
3
+ * Returns true if the given network genesisId is associated with a LocalNet network.
4
+ * @param genesisId The network genesis ID
5
+ * @returns Whether the given genesis ID is associated with a LocalNet network
6
+ */
7
+ function genesisIdIsLocalNet(genesisId) {
8
+ return genesisId === "devnet-v1" || genesisId === "sandnet-v1" || genesisId === "dockernet-v1";
9
+ }
10
+
11
+ //#endregion
12
+ export { genesisIdIsLocalNet };
13
+ //# sourceMappingURL=network-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-client.mjs","names":[],"sources":["../src/network-client.ts"],"sourcesContent":["/** Config for an Algorand SDK client. */\nexport interface AlgoClientConfig {\n /** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */\n server: string\n /** The port to use e.g. 4001, 443, etc. */\n port?: string | number\n /** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */\n token?: string | { [name: string]: string }\n}\n\n/** Configuration for algod, indexer and kmd clients. */\nexport interface AlgoConfig {\n /** Algod client configuration */\n algodConfig: AlgoClientConfig\n /** Indexer client configuration */\n indexerConfig?: AlgoClientConfig\n /** Kmd configuration */\n kmdConfig?: AlgoClientConfig\n}\n\n/** Details of the current network. */\nexport interface NetworkDetails {\n /** Whether or not the network is TestNet. */\n isTestNet: boolean\n /** Whether or not the network is MainNet. */\n isMainNet: boolean\n /** Whether or not the network is LocalNet. */\n isLocalNet: boolean\n /** The genesis ID of the current network. */\n genesisId: string\n /** The base64 genesis hash of the current network. */\n genesisHash: string\n}\n\n/**\n * Returns true if the given network genesisId is associated with a LocalNet network.\n * @param genesisId The network genesis ID\n * @returns Whether the given genesis ID is associated with a LocalNet network\n */\nexport function genesisIdIsLocalNet(genesisId: string) {\n return genesisId === 'devnet-v1' || genesisId === 'sandnet-v1' || genesisId === 'dockernet-v1'\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,oBAAoB,WAAmB;AACrD,QAAO,cAAc,eAAe,cAAc,gBAAgB,cAAc"}
package/package.json CHANGED
@@ -6,11 +6,15 @@
6
6
  "**"
7
7
  ],
8
8
  "name": "@algorandfoundation/algokit-utils",
9
- "version": "10.0.0-alpha.3",
9
+ "version": "10.0.0-alpha.32",
10
10
  "private": false,
11
11
  "description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
12
12
  "author": "Algorand Foundation",
13
13
  "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/algorandfoundation/algokit-utils-ts.git"
17
+ },
14
18
  "engines": {
15
19
  "node": ">=20.0"
16
20
  },
@@ -42,6 +46,11 @@
42
46
  "import": "./transact/index.mjs",
43
47
  "require": "./transact/index.js"
44
48
  },
49
+ "./transaction": {
50
+ "types": "./transaction/index.d.ts",
51
+ "import": "./transaction/index.mjs",
52
+ "require": "./transaction/index.js"
53
+ },
45
54
  "./algod-client": {
46
55
  "types": "./algod-client/index.d.ts",
47
56
  "import": "./algod-client/index.mjs",
@@ -62,10 +71,10 @@
62
71
  "import": "./algo25/index.mjs",
63
72
  "require": "./algo25/index.js"
64
73
  },
65
- "./sdk": {
66
- "types": "./sdk/index.d.ts",
67
- "import": "./sdk/index.mjs",
68
- "require": "./sdk/index.js"
74
+ "./*": {
75
+ "types": "./*.d.ts",
76
+ "import": "./*.mjs",
77
+ "require": "./*.js"
69
78
  },
70
79
  "./index.d.ts": "./index.d.ts",
71
80
  "./package.json": "./package.json"
@@ -61,7 +61,7 @@ type ABIReturn = {
61
61
  rawReturnValue?: undefined;
62
62
  returnValue?: undefined;
63
63
  method: ABIMethod;
64
- decodeError: Error;
64
+ decodeError?: Error;
65
65
  };
66
66
  declare class ABIMethod {
67
67
  readonly name: string;
@@ -139,7 +139,7 @@ function arc56MethodToABIMethod(method, appSpec) {
139
139
  });
140
140
  const returns = {
141
141
  type: method.returns.type === "void" ? "void" : method.returns.struct ? require_abi_type.ABIStructType.fromStruct(method.returns.struct, appSpec.structs) : require_abi_type.ABIType.from(method.returns.type),
142
- desc: method.returns.desc
142
+ description: method.returns.desc
143
143
  };
144
144
  return new ABIMethod({
145
145
  name: method.name,
@@ -1 +1 @@
1
- {"version":3,"file":"abi-method.js","names":["sha512","parseTupleContent","ABIType","convertedDefaultValue: ABIDefaultValue | undefined","ABIStructType","ABIUintType","ABIAddressType"],"sources":["../../../../packages/abi/src/abi-method.ts"],"sourcesContent":["import sha512 from 'js-sha512'\nimport { ABIAddressType, ABIStructType, ABIType, ABIUintType, parseTupleContent } from './abi-type'\nimport { ABIValue } from './abi-value'\nimport { ARC28Event } from './arc28-event'\nimport { AVMType, Arc56Contract, Arc56Method } from './arc56-contract'\n\nexport enum ABITransactionType {\n Txn = 'txn',\n Payment = 'pay',\n KeyRegistration = 'keyreg',\n AssetConfig = 'acfg',\n AssetTransfer = 'axfer',\n AssetFreeze = 'afrz',\n AppCall = 'appl',\n}\nexport enum ABIReferenceType {\n Account = 'account',\n Application = 'application',\n Asset = 'asset',\n}\nexport type ABIMethodArgType = ABIType | ABITransactionType | ABIReferenceType\nexport type ABIMethodReturnType = ABIType | 'void'\n\nexport type ABIMethodArg = {\n type: ABIMethodArgType\n name?: string\n description?: string\n defaultValue?: ABIDefaultValue\n}\n\nexport type ABIMethodReturn = {\n type: ABIMethodReturnType\n description?: string\n}\n\nexport type ABIDefaultValue = {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** Where the default value is coming from */\n source: DefaultValueSource\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABIType | AVMType\n}\n\nexport enum DefaultValueSource {\n Box = 'box',\n Global = 'global',\n Local = 'local',\n Literal = 'literal',\n Method = 'method',\n}\n\n/** Represents an ABI method return value with parsed data. */\nexport type ABIReturn =\n | {\n /** The method that was called. */\n method: ABIMethod\n /** The raw return value as bytes.\n *\n * This is the value from the last app call log with the first 4 bytes (the ABI return prefix) omitted.\n */\n rawReturnValue: Uint8Array\n /** The parsed ABI return value. */\n returnValue: ABIValue\n decodeError: undefined\n }\n | { rawReturnValue?: undefined; returnValue?: undefined; method: ABIMethod; decodeError: Error }\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | ABIValue\n}\n\nexport class ABIMethod {\n readonly name: string\n readonly description?: string\n readonly args: ABIMethodArg[]\n readonly returns: ABIMethodReturn\n readonly events?: ARC28Event[]\n readonly readonly?: boolean\n\n constructor(params: {\n name: string\n description?: string\n args: ABIMethodArg[]\n returns: ABIMethodReturn\n events?: ARC28Event[]\n readonly?: boolean\n }) {\n this.name = params.name\n this.description = params.description\n this.args = params.args\n this.returns = params.returns\n this.events = params.events\n this.readonly = params.readonly\n }\n\n /**\n * Returns the signature of this ABI method.\n * @returns The signature, e.g. `my_method(unit64,string)bytes`\n */\n getSignature(): string {\n const args = this.args\n .map((arg) => {\n if (argTypeIsTransaction(arg.type) || argTypeIsReference(arg.type)) return arg.type\n return arg.type.name\n })\n .join(',')\n const returns = this.returns.type === 'void' ? 'void' : this.returns.type.name\n return `${this.name}(${args})${returns}`\n }\n\n /**\n * Returns the method selector of this ABI method.\n * @returns The 4-byte method selector\n */\n getSelector(): Uint8Array {\n const hash = sha512.sha512_256.array(this.getSignature())\n return new Uint8Array(hash.slice(0, 4))\n }\n\n /**\n * Returns the ABI method object for a given method signature.\n * @param signature The method signature\n * e.g. `my_method(unit64,string)bytes`\n * @returns The `ABIMethod`\n */\n static fromSignature(signature: string): ABIMethod {\n const argsStart = signature.indexOf('(')\n if (argsStart === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n let argsEnd = -1\n let depth = 0\n for (let i = argsStart; i < signature.length; i++) {\n const char = signature[i]\n\n if (char === '(') {\n depth += 1\n } else if (char === ')') {\n if (depth === 0) {\n // unpaired parenthesis\n break\n }\n\n depth -= 1\n if (depth === 0) {\n argsEnd = i\n break\n }\n }\n }\n\n if (argsEnd === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n const name = signature.slice(0, argsStart)\n const args = parseTupleContent(signature.slice(argsStart + 1, argsEnd)).map((n: string) => {\n if (argTypeIsTransaction(n as ABIMethodArgType) || argTypeIsReference(n as ABIMethodArgType)) {\n return { type: n as ABIMethodArgType } satisfies ABIMethodArg\n }\n return { type: ABIType.from(n) } satisfies ABIMethodArg\n })\n const returnType = signature.slice(argsEnd + 1)\n const returns = { type: returnType === 'void' ? ('void' as const) : ABIType.from(returnType) } satisfies ABIMethodReturn\n\n return new ABIMethod({\n name,\n args,\n returns,\n })\n }\n}\n\n/**\n * Returns the ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `ABIMethod`\n */\nexport function getABIMethod(methodNameOrSignature: string, appSpec: Arc56Contract): ABIMethod {\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => getArc56MethodSignature(m))\n .join(', ')}`,\n )\n }\n return arc56MethodToABIMethod(methods[0], appSpec)\n } else {\n const method = appSpec.methods.find((m) => getArc56MethodSignature(m) === methodNameOrSignature)\n if (!method) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n return arc56MethodToABIMethod(method, appSpec)\n }\n}\n\nexport function arc56MethodToABIMethod(method: Arc56Method, appSpec: Arc56Contract): ABIMethod {\n if (typeof method.name !== 'string' || typeof method.returns !== 'object' || !Array.isArray(method.args)) {\n throw new Error('Invalid ABIMethod parameters')\n }\n\n const args = method.args.map(({ type, name, desc, struct, defaultValue }) => {\n const convertedDefaultValue: ABIDefaultValue | undefined = defaultValue\n ? {\n data: defaultValue.data,\n source: defaultValue.source as DefaultValueSource,\n type: defaultValue.type ? (isAVMType(defaultValue.type) ? defaultValue.type : ABIType.from(defaultValue.type)) : undefined,\n }\n : undefined\n\n if (argTypeIsTransaction(type as ABIMethodArgType) || argTypeIsReference(type as ABIMethodArgType)) {\n return {\n type: type as ABIMethodArgType,\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n if (struct) {\n return {\n type: ABIStructType.fromStruct(struct, appSpec.structs),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n return {\n type: ABIType.from(type),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n })\n\n const returns = {\n type:\n method.returns.type === ('void' as const)\n ? ('void' as const)\n : method.returns.struct\n ? ABIStructType.fromStruct(method.returns.struct, appSpec.structs)\n : ABIType.from(method.returns.type),\n desc: method.returns.desc,\n }\n\n return new ABIMethod({\n name: method.name,\n description: method.desc,\n args,\n returns,\n events: method.events,\n readonly: method.readonly,\n })\n}\n\nexport function argTypeIsTransaction(type: ABIMethodArgType): type is ABITransactionType {\n return (\n typeof type === 'string' &&\n (type === ABITransactionType.Txn ||\n type === ABITransactionType.Payment ||\n type === ABITransactionType.KeyRegistration ||\n type === ABITransactionType.AssetConfig ||\n type === ABITransactionType.AssetTransfer ||\n type === ABITransactionType.AssetFreeze ||\n type === ABITransactionType.AppCall)\n )\n}\n\nexport function argTypeIsReference(type: ABIMethodArgType): type is ABIReferenceType {\n return (\n typeof type === 'string' &&\n (type === ABIReferenceType.Account || type === ABIReferenceType.Application || type === ABIReferenceType.Asset)\n )\n}\n\nexport function argTypeIsAbiType(type: ABIMethodArgType): type is ABIType {\n return !argTypeIsTransaction(type) && !argTypeIsReference(type)\n}\n\nfunction getArc56MethodSignature(method: Arc56Method): string {\n const args = method.args.map((arg) => arg.type).join(',')\n const returns = method.returns.type\n return `${method.name}(${args})${returns}`\n}\n\nexport function decodeAVMValue(avmType: AVMType, bytes: Uint8Array): ABIValue {\n switch (avmType) {\n case 'AVMString':\n return Buffer.from(bytes).toString('utf-8')\n case 'AVMBytes':\n return bytes\n case 'AVMUint64':\n return ABIType.from('uint64').decode(bytes)\n }\n}\n\nexport function encodeAVMValue(avmType: AVMType, value: ABIValue): Uint8Array {\n switch (avmType) {\n case 'AVMString':\n return ABIType.from('string').encode(value)\n case 'AVMBytes':\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array))\n throw new Error(`Expected bytes value for AVMBytes, but got ${value}`)\n return value\n case 'AVMUint64':\n return ABIType.from('uint64').encode(value)\n }\n}\n\nexport function isAVMType(type: unknown): type is AVMType {\n return typeof type === 'string' && (type === 'AVMString' || type === 'AVMBytes' || type === 'AVMUint64')\n}\n\nexport function getABIDecodedValue(type: AVMType | ABIType | ABIReferenceType, bytes: Uint8Array): ABIValue {\n if (type === ABIReferenceType.Asset || type === ABIReferenceType.Application) {\n return new ABIUintType(64).decode(bytes)\n } else if (type === ABIReferenceType.Account) {\n return new ABIAddressType().decode(bytes)\n } else if (isAVMType(type)) {\n return decodeAVMValue(type, bytes)\n }\n return type.decode(bytes)\n}\n\nexport function getABIEncodedValue(type: AVMType | ABIType, value: ABIValue): Uint8Array {\n return isAVMType(type) ? encodeAVMValue(type, value) : type.encode(value)\n}\n"],"mappings":";;;;;;AAMA,IAAY,oEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEF,IAAY,gEAAL;AACL;AACA;AACA;;;AAuDF,IAAa,YAAb,MAAa,UAAU;CACrB,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,QAOT;AACD,OAAK,OAAO,OAAO;AACnB,OAAK,cAAc,OAAO;AAC1B,OAAK,OAAO,OAAO;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS,OAAO;AACrB,OAAK,WAAW,OAAO;;;;;;CAOzB,eAAuB;EACrB,MAAM,OAAO,KAAK,KACf,KAAK,QAAQ;AACZ,OAAI,qBAAqB,IAAI,KAAK,IAAI,mBAAmB,IAAI,KAAK,CAAE,QAAO,IAAI;AAC/E,UAAO,IAAI,KAAK;IAChB,CACD,KAAK,IAAI;AAEZ,SAAO,GAAG,KAAK,KAAK,GAAG,KAAK,GADZ,KAAK,QAAQ,SAAS,SAAS,SAAS,KAAK,QAAQ,KAAK;;;;;;CAQ5E,cAA0B;EACxB,MAAM,OAAOA,kBAAO,WAAW,MAAM,KAAK,cAAc,CAAC;AACzD,SAAO,IAAI,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC;;;;;;;;CASzC,OAAO,cAAc,WAA8B;EACjD,MAAM,YAAY,UAAU,QAAQ,IAAI;AACxC,MAAI,cAAc,GAChB,OAAM,IA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,SAAS,iBAAiB,YAC/D,QAAO,IAAIG,6BAAY,GAAG,CAAC,OAAO,MAAM;UAC/B,SAAS,iBAAiB,QACnC,QAAO,IAAIC,iCAAgB,CAAC,OAAO,MAAM;UAChC,UAAU,KAAK,CACxB,QAAO,eAAe,MAAM,MAAM;AAEpC,QAAO,KAAK,OAAO,MAAM;;AAG3B,SAAgB,mBAAmB,MAAyB,OAA6B;AACvF,QAAO,UAAU,KAAK,GAAG,eAAe,MAAM,MAAM,GAAG,KAAK,OAAO,MAAM"}
1
+ {"version":3,"file":"abi-method.js","names":["sha512","parseTupleContent","ABIType","convertedDefaultValue: ABIDefaultValue | undefined","ABIStructType","ABIUintType","ABIAddressType"],"sources":["../../../../packages/abi/src/abi-method.ts"],"sourcesContent":["import sha512 from 'js-sha512'\nimport { ABIAddressType, ABIStructType, ABIType, ABIUintType, parseTupleContent } from './abi-type'\nimport { ABIValue } from './abi-value'\nimport { ARC28Event } from './arc28-event'\nimport { AVMType, Arc56Contract, Arc56Method } from './arc56-contract'\n\nexport enum ABITransactionType {\n Txn = 'txn',\n Payment = 'pay',\n KeyRegistration = 'keyreg',\n AssetConfig = 'acfg',\n AssetTransfer = 'axfer',\n AssetFreeze = 'afrz',\n AppCall = 'appl',\n}\nexport enum ABIReferenceType {\n Account = 'account',\n Application = 'application',\n Asset = 'asset',\n}\nexport type ABIMethodArgType = ABIType | ABITransactionType | ABIReferenceType\nexport type ABIMethodReturnType = ABIType | 'void'\n\nexport type ABIMethodArg = {\n type: ABIMethodArgType\n name?: string\n description?: string\n defaultValue?: ABIDefaultValue\n}\n\nexport type ABIMethodReturn = {\n type: ABIMethodReturnType\n description?: string\n}\n\nexport type ABIDefaultValue = {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** Where the default value is coming from */\n source: DefaultValueSource\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABIType | AVMType\n}\n\nexport enum DefaultValueSource {\n Box = 'box',\n Global = 'global',\n Local = 'local',\n Literal = 'literal',\n Method = 'method',\n}\n\n/** Represents an ABI method return value with parsed data. */\nexport type ABIReturn =\n | {\n /** The method that was called. */\n method: ABIMethod\n /** The raw return value as bytes.\n *\n * This is the value from the last app call log with the first 4 bytes (the ABI return prefix) omitted.\n */\n rawReturnValue: Uint8Array\n /** The parsed ABI return value. */\n returnValue: ABIValue\n decodeError: undefined\n }\n | { rawReturnValue?: undefined; returnValue?: undefined; method: ABIMethod; decodeError?: Error }\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | ABIValue\n}\n\nexport class ABIMethod {\n readonly name: string\n readonly description?: string\n readonly args: ABIMethodArg[]\n readonly returns: ABIMethodReturn\n readonly events?: ARC28Event[]\n readonly readonly?: boolean\n\n constructor(params: {\n name: string\n description?: string\n args: ABIMethodArg[]\n returns: ABIMethodReturn\n events?: ARC28Event[]\n readonly?: boolean\n }) {\n this.name = params.name\n this.description = params.description\n this.args = params.args\n this.returns = params.returns\n this.events = params.events\n this.readonly = params.readonly\n }\n\n /**\n * Returns the signature of this ABI method.\n * @returns The signature, e.g. `my_method(unit64,string)bytes`\n */\n getSignature(): string {\n const args = this.args\n .map((arg) => {\n if (argTypeIsTransaction(arg.type) || argTypeIsReference(arg.type)) return arg.type\n return arg.type.name\n })\n .join(',')\n const returns = this.returns.type === 'void' ? 'void' : this.returns.type.name\n return `${this.name}(${args})${returns}`\n }\n\n /**\n * Returns the method selector of this ABI method.\n * @returns The 4-byte method selector\n */\n getSelector(): Uint8Array {\n const hash = sha512.sha512_256.array(this.getSignature())\n return new Uint8Array(hash.slice(0, 4))\n }\n\n /**\n * Returns the ABI method object for a given method signature.\n * @param signature The method signature\n * e.g. `my_method(unit64,string)bytes`\n * @returns The `ABIMethod`\n */\n static fromSignature(signature: string): ABIMethod {\n const argsStart = signature.indexOf('(')\n if (argsStart === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n let argsEnd = -1\n let depth = 0\n for (let i = argsStart; i < signature.length; i++) {\n const char = signature[i]\n\n if (char === '(') {\n depth += 1\n } else if (char === ')') {\n if (depth === 0) {\n // unpaired parenthesis\n break\n }\n\n depth -= 1\n if (depth === 0) {\n argsEnd = i\n break\n }\n }\n }\n\n if (argsEnd === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n const name = signature.slice(0, argsStart)\n const args = parseTupleContent(signature.slice(argsStart + 1, argsEnd)).map((n: string) => {\n if (argTypeIsTransaction(n as ABIMethodArgType) || argTypeIsReference(n as ABIMethodArgType)) {\n return { type: n as ABIMethodArgType } satisfies ABIMethodArg\n }\n return { type: ABIType.from(n) } satisfies ABIMethodArg\n })\n const returnType = signature.slice(argsEnd + 1)\n const returns = { type: returnType === 'void' ? ('void' as const) : ABIType.from(returnType) } satisfies ABIMethodReturn\n\n return new ABIMethod({\n name,\n args,\n returns,\n })\n }\n}\n\n/**\n * Returns the ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `ABIMethod`\n */\nexport function getABIMethod(methodNameOrSignature: string, appSpec: Arc56Contract): ABIMethod {\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => getArc56MethodSignature(m))\n .join(', ')}`,\n )\n }\n return arc56MethodToABIMethod(methods[0], appSpec)\n } else {\n const method = appSpec.methods.find((m) => getArc56MethodSignature(m) === methodNameOrSignature)\n if (!method) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n return arc56MethodToABIMethod(method, appSpec)\n }\n}\n\nexport function arc56MethodToABIMethod(method: Arc56Method, appSpec: Arc56Contract): ABIMethod {\n if (typeof method.name !== 'string' || typeof method.returns !== 'object' || !Array.isArray(method.args)) {\n throw new Error('Invalid ABIMethod parameters')\n }\n\n const args = method.args.map(({ type, name, desc, struct, defaultValue }) => {\n const convertedDefaultValue: ABIDefaultValue | undefined = defaultValue\n ? {\n data: defaultValue.data,\n source: defaultValue.source as DefaultValueSource,\n type: defaultValue.type ? (isAVMType(defaultValue.type) ? defaultValue.type : ABIType.from(defaultValue.type)) : undefined,\n }\n : undefined\n\n if (argTypeIsTransaction(type as ABIMethodArgType) || argTypeIsReference(type as ABIMethodArgType)) {\n return {\n type: type as ABIMethodArgType,\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n if (struct) {\n return {\n type: ABIStructType.fromStruct(struct, appSpec.structs),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n return {\n type: ABIType.from(type),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n })\n\n const returns = {\n type:\n method.returns.type === ('void' as const)\n ? ('void' as const)\n : method.returns.struct\n ? ABIStructType.fromStruct(method.returns.struct, appSpec.structs)\n : ABIType.from(method.returns.type),\n description: method.returns.desc,\n } satisfies ABIMethodReturn\n\n return new ABIMethod({\n name: method.name,\n description: method.desc,\n args,\n returns,\n events: method.events,\n readonly: method.readonly,\n })\n}\n\nexport function argTypeIsTransaction(type: ABIMethodArgType): type is ABITransactionType {\n return (\n typeof type === 'string' &&\n (type === ABITransactionType.Txn ||\n type === ABITransactionType.Payment ||\n type === ABITransactionType.KeyRegistration ||\n type === ABITransactionType.AssetConfig ||\n type === ABITransactionType.AssetTransfer ||\n type === ABITransactionType.AssetFreeze ||\n type === ABITransactionType.AppCall)\n )\n}\n\nexport function argTypeIsReference(type: ABIMethodArgType): type is ABIReferenceType {\n return (\n typeof type === 'string' &&\n (type === ABIReferenceType.Account || type === ABIReferenceType.Application || type === ABIReferenceType.Asset)\n )\n}\n\nexport function argTypeIsAbiType(type: ABIMethodArgType): type is ABIType {\n return !argTypeIsTransaction(type) && !argTypeIsReference(type)\n}\n\nfunction getArc56MethodSignature(method: Arc56Method): string {\n const args = method.args.map((arg) => arg.type).join(',')\n const returns = method.returns.type\n return `${method.name}(${args})${returns}`\n}\n\nexport function decodeAVMValue(avmType: AVMType, bytes: Uint8Array): ABIValue {\n switch (avmType) {\n case 'AVMString':\n return Buffer.from(bytes).toString('utf-8')\n case 'AVMBytes':\n return bytes\n case 'AVMUint64':\n return ABIType.from('uint64').decode(bytes)\n }\n}\n\nexport function encodeAVMValue(avmType: AVMType, value: ABIValue): Uint8Array {\n switch (avmType) {\n case 'AVMString':\n return ABIType.from('string').encode(value)\n case 'AVMBytes':\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array))\n throw new Error(`Expected bytes value for AVMBytes, but got ${value}`)\n return value\n case 'AVMUint64':\n return ABIType.from('uint64').encode(value)\n }\n}\n\nexport function isAVMType(type: unknown): type is AVMType {\n return typeof type === 'string' && (type === 'AVMString' || type === 'AVMBytes' || type === 'AVMUint64')\n}\n\nexport function getABIDecodedValue(type: AVMType | ABIType | ABIReferenceType, bytes: Uint8Array): ABIValue {\n if (type === ABIReferenceType.Asset || type === ABIReferenceType.Application) {\n return new ABIUintType(64).decode(bytes)\n } else if (type === ABIReferenceType.Account) {\n return new ABIAddressType().decode(bytes)\n } else if (isAVMType(type)) {\n return decodeAVMValue(type, bytes)\n }\n return type.decode(bytes)\n}\n\nexport function getABIEncodedValue(type: AVMType | ABIType, value: ABIValue): Uint8Array {\n return isAVMType(type) ? encodeAVMValue(type, value) : type.encode(value)\n}\n"],"mappings":";;;;;;AAMA,IAAY,oEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEF,IAAY,gEAAL;AACL;AACA;AACA;;;AA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,IAAI;AAEzD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GADd,OAAO,QAAQ;;AAIjC,SAAgB,eAAe,SAAkB,OAA6B;AAC5E,SAAQ,SAAR;EACE,KAAK,YACH,QAAO,OAAO,KAAK,MAAM,CAAC,SAAS,QAAQ;EAC7C,KAAK,WACH,QAAO;EACT,KAAK,YACH,QAAOA,yBAAQ,KAAK,SAAS,CAAC,OAAO,MAAM;;;AAIjD,SAAgB,eAAe,SAAkB,OAA6B;AAC5E,SAAQ,SAAR;EACE,KAAK,YACH,QAAOA,yBAAQ,KAAK,SAAS,CAAC,OAAO,MAAM;EAC7C,KAAK;AACH,OAAI,OAAO,UAAU,SAAU,QAAO,OAAO,KAAK,OAAO,QAAQ;AACjE,OAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,YAClD,OAAM,IAAI,MAAM,8CAA8C,QAAQ;AACxE,UAAO;EACT,KAAK,YACH,QAAOA,yBAAQ,KAAK,SAAS,CAAC,OAAO,MAAM;;;AAIjD,SAAgB,UAAU,MAAgC;AACxD,QAAO,OAAO,SAAS,aAAa,SAAS,eAAe,SAAS,cAAc,SAAS;;AAG9F,SAAgB,mBAAmB,MAA4C,OAA6B;AAC1G,KAAI,SAAS,iBAAiB,SAAS,SAAS,iBAAiB,YAC/D,QAAO,IAAIG,6BAAY,GAAG,CAAC,OAAO,MAAM;UAC/B,SAAS,iBAAiB,QACnC,QAAO,IAAIC,iCAAgB,CAAC,OAAO,MAAM;UAChC,UAAU,KAAK,CACxB,QAAO,eAAe,MAAM,MAAM;AAEpC,QAAO,KAAK,OAAO,MAAM;;AAG3B,SAAgB,mBAAmB,MAAyB,OAA6B;AACvF,QAAO,UAAU,KAAK,GAAG,eAAe,MAAM,MAAM,GAAG,KAAK,OAAO,MAAM"}
@@ -137,7 +137,7 @@ function arc56MethodToABIMethod(method, appSpec) {
137
137
  });
138
138
  const returns = {
139
139
  type: method.returns.type === "void" ? "void" : method.returns.struct ? ABIStructType.fromStruct(method.returns.struct, appSpec.structs) : ABIType.from(method.returns.type),
140
- desc: method.returns.desc
140
+ description: method.returns.desc
141
141
  };
142
142
  return new ABIMethod({
143
143
  name: method.name,
@@ -1 +1 @@
1
- {"version":3,"file":"abi-method.mjs","names":["convertedDefaultValue: ABIDefaultValue | undefined"],"sources":["../../../../packages/abi/src/abi-method.ts"],"sourcesContent":["import sha512 from 'js-sha512'\nimport { ABIAddressType, ABIStructType, ABIType, ABIUintType, parseTupleContent } from './abi-type'\nimport { ABIValue } from './abi-value'\nimport { ARC28Event } from './arc28-event'\nimport { AVMType, Arc56Contract, Arc56Method } from './arc56-contract'\n\nexport enum ABITransactionType {\n Txn = 'txn',\n Payment = 'pay',\n KeyRegistration = 'keyreg',\n AssetConfig = 'acfg',\n AssetTransfer = 'axfer',\n AssetFreeze = 'afrz',\n AppCall = 'appl',\n}\nexport enum ABIReferenceType {\n Account = 'account',\n Application = 'application',\n Asset = 'asset',\n}\nexport type ABIMethodArgType = ABIType | ABITransactionType | ABIReferenceType\nexport type ABIMethodReturnType = ABIType | 'void'\n\nexport type ABIMethodArg = {\n type: ABIMethodArgType\n name?: string\n description?: string\n defaultValue?: ABIDefaultValue\n}\n\nexport type ABIMethodReturn = {\n type: ABIMethodReturnType\n description?: string\n}\n\nexport type ABIDefaultValue = {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** Where the default value is coming from */\n source: DefaultValueSource\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABIType | AVMType\n}\n\nexport enum DefaultValueSource {\n Box = 'box',\n Global = 'global',\n Local = 'local',\n Literal = 'literal',\n Method = 'method',\n}\n\n/** Represents an ABI method return value with parsed data. */\nexport type ABIReturn =\n | {\n /** The method that was called. */\n method: ABIMethod\n /** The raw return value as bytes.\n *\n * This is the value from the last app call log with the first 4 bytes (the ABI return prefix) omitted.\n */\n rawReturnValue: Uint8Array\n /** The parsed ABI return value. */\n returnValue: ABIValue\n decodeError: undefined\n }\n | { rawReturnValue?: undefined; returnValue?: undefined; method: ABIMethod; decodeError: Error }\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | ABIValue\n}\n\nexport class ABIMethod {\n readonly name: string\n readonly description?: string\n readonly args: ABIMethodArg[]\n readonly returns: ABIMethodReturn\n readonly events?: ARC28Event[]\n readonly readonly?: boolean\n\n constructor(params: {\n name: string\n description?: string\n args: ABIMethodArg[]\n returns: ABIMethodReturn\n events?: ARC28Event[]\n readonly?: boolean\n }) {\n this.name = params.name\n this.description = params.description\n this.args = params.args\n this.returns = params.returns\n this.events = params.events\n this.readonly = params.readonly\n }\n\n /**\n * Returns the signature of this ABI method.\n * @returns The signature, e.g. `my_method(unit64,string)bytes`\n */\n getSignature(): string {\n const args = this.args\n .map((arg) => {\n if (argTypeIsTransaction(arg.type) || argTypeIsReference(arg.type)) return arg.type\n return arg.type.name\n })\n .join(',')\n const returns = this.returns.type === 'void' ? 'void' : this.returns.type.name\n return `${this.name}(${args})${returns}`\n }\n\n /**\n * Returns the method selector of this ABI method.\n * @returns The 4-byte method selector\n */\n getSelector(): Uint8Array {\n const hash = sha512.sha512_256.array(this.getSignature())\n return new Uint8Array(hash.slice(0, 4))\n }\n\n /**\n * Returns the ABI method object for a given method signature.\n * @param signature The method signature\n * e.g. `my_method(unit64,string)bytes`\n * @returns The `ABIMethod`\n */\n static fromSignature(signature: string): ABIMethod {\n const argsStart = signature.indexOf('(')\n if (argsStart === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n let argsEnd = -1\n let depth = 0\n for (let i = argsStart; i < signature.length; i++) {\n const char = signature[i]\n\n if (char === '(') {\n depth += 1\n } else if (char === ')') {\n if (depth === 0) {\n // unpaired parenthesis\n break\n }\n\n depth -= 1\n if (depth === 0) {\n argsEnd = i\n break\n }\n }\n }\n\n if (argsEnd === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n const name = signature.slice(0, argsStart)\n const args = parseTupleContent(signature.slice(argsStart + 1, argsEnd)).map((n: string) => {\n if (argTypeIsTransaction(n as ABIMethodArgType) || argTypeIsReference(n as ABIMethodArgType)) {\n return { type: n as ABIMethodArgType } satisfies ABIMethodArg\n }\n return { type: ABIType.from(n) } satisfies ABIMethodArg\n })\n const returnType = signature.slice(argsEnd + 1)\n const returns = { type: returnType === 'void' ? ('void' as const) : ABIType.from(returnType) } satisfies ABIMethodReturn\n\n return new ABIMethod({\n name,\n args,\n returns,\n })\n }\n}\n\n/**\n * Returns the ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `ABIMethod`\n */\nexport function getABIMethod(methodNameOrSignature: string, appSpec: Arc56Contract): ABIMethod {\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => getArc56MethodSignature(m))\n .join(', ')}`,\n )\n }\n return arc56MethodToABIMethod(methods[0], appSpec)\n } else {\n const method = appSpec.methods.find((m) => getArc56MethodSignature(m) === methodNameOrSignature)\n if (!method) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n return arc56MethodToABIMethod(method, appSpec)\n }\n}\n\nexport function arc56MethodToABIMethod(method: Arc56Method, appSpec: Arc56Contract): ABIMethod {\n if (typeof method.name !== 'string' || typeof method.returns !== 'object' || !Array.isArray(method.args)) {\n throw new Error('Invalid ABIMethod parameters')\n }\n\n const args = method.args.map(({ type, name, desc, struct, defaultValue }) => {\n const convertedDefaultValue: ABIDefaultValue | undefined = defaultValue\n ? {\n data: defaultValue.data,\n source: defaultValue.source as DefaultValueSource,\n type: defaultValue.type ? (isAVMType(defaultValue.type) ? defaultValue.type : ABIType.from(defaultValue.type)) : undefined,\n }\n : undefined\n\n if (argTypeIsTransaction(type as ABIMethodArgType) || argTypeIsReference(type as ABIMethodArgType)) {\n return {\n type: type as ABIMethodArgType,\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n if (struct) {\n return {\n type: ABIStructType.fromStruct(struct, appSpec.structs),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n return {\n type: ABIType.from(type),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n })\n\n const returns = {\n type:\n method.returns.type === ('void' as const)\n ? ('void' as const)\n : method.returns.struct\n ? ABIStructType.fromStruct(method.returns.struct, appSpec.structs)\n : ABIType.from(method.returns.type),\n desc: method.returns.desc,\n }\n\n return new ABIMethod({\n name: method.name,\n description: method.desc,\n args,\n returns,\n events: method.events,\n readonly: method.readonly,\n })\n}\n\nexport function argTypeIsTransaction(type: ABIMethodArgType): type is ABITransactionType {\n return (\n typeof type === 'string' &&\n (type === ABITransactionType.Txn ||\n type === ABITransactionType.Payment ||\n type === ABITransactionType.KeyRegistration ||\n type === ABITransactionType.AssetConfig ||\n type === ABITransactionType.AssetTransfer ||\n type === ABITransactionType.AssetFreeze ||\n type === ABITransactionType.AppCall)\n )\n}\n\nexport function argTypeIsReference(type: ABIMethodArgType): type is ABIReferenceType {\n return (\n typeof type === 'string' &&\n (type === ABIReferenceType.Account || type === ABIReferenceType.Application || type === ABIReferenceType.Asset)\n )\n}\n\nexport function argTypeIsAbiType(type: ABIMethodArgType): type is ABIType {\n return !argTypeIsTransaction(type) && !argTypeIsReference(type)\n}\n\nfunction getArc56MethodSignature(method: Arc56Method): string {\n const args = method.args.map((arg) => arg.type).join(',')\n const returns = method.returns.type\n return `${method.name}(${args})${returns}`\n}\n\nexport function decodeAVMValue(avmType: AVMType, bytes: Uint8Array): ABIValue {\n switch (avmType) {\n case 'AVMString':\n return Buffer.from(bytes).toString('utf-8')\n case 'AVMBytes':\n return bytes\n case 'AVMUint64':\n return ABIType.from('uint64').decode(bytes)\n }\n}\n\nexport function encodeAVMValue(avmType: AVMType, value: ABIValue): Uint8Array {\n switch (avmType) {\n case 'AVMString':\n return ABIType.from('string').encode(value)\n case 'AVMBytes':\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array))\n throw new Error(`Expected bytes value for AVMBytes, but got ${value}`)\n return value\n case 'AVMUint64':\n return ABIType.from('uint64').encode(value)\n }\n}\n\nexport function isAVMType(type: unknown): type is AVMType {\n return typeof type === 'string' && (type === 'AVMString' || type === 'AVMBytes' || type === 'AVMUint64')\n}\n\nexport function getABIDecodedValue(type: AVMType | ABIType | ABIReferenceType, bytes: Uint8Array): ABIValue {\n if (type === ABIReferenceType.Asset || type === ABIReferenceType.Application) {\n return new ABIUintType(64).decode(bytes)\n } else if (type === ABIReferenceType.Account) {\n return new ABIAddressType().decode(bytes)\n } else if (isAVMType(type)) {\n return decodeAVMValue(type, bytes)\n }\n return type.decode(bytes)\n}\n\nexport function getABIEncodedValue(type: AVMType | ABIType, value: ABIValue): Uint8Array {\n return isAVMType(type) ? encodeAVMValue(type, value) : type.encode(value)\n}\n"],"mappings":";;;;AAMA,IAAY,oEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEF,IAAY,gEAAL;AACL;AACA;AACA;;;AAuDF,IAAa,YAAb,MAAa,UAAU;CACrB,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,QAOT;AACD,OAAK,OAAO,OAAO;AACnB,OAAK,cAAc,OAAO;AAC1B,OAAK,OAAO,OAAO;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS,OAAO;AACrB,OAAK,WAAW,OAAO;;;;;;CA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AAe,SAAkB,OAA6B;AAC5E,SAAQ,SAAR;EACE,KAAK,YACH,QAAO,QAAQ,KAAK,SAAS,CAAC,OAAO,MAAM;EAC7C,KAAK;AACH,OAAI,OAAO,UAAU,SAAU,QAAO,OAAO,KAAK,OAAO,QAAQ;AACjE,OAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,YAClD,OAAM,IAAI,MAAM,8CAA8C,QAAQ;AACxE,UAAO;EACT,KAAK,YACH,QAAO,QAAQ,KAAK,SAAS,CAAC,OAAO,MAAM;;;AAIjD,SAAgB,UAAU,MAAgC;AACxD,QAAO,OAAO,SAAS,aAAa,SAAS,eAAe,SAAS,cAAc,SAAS;;AAG9F,SAAgB,mBAAmB,MAA4C,OAA6B;AAC1G,KAAI,SAAS,iBAAiB,SAAS,SAAS,iBAAiB,YAC/D,QAAO,IAAI,YAAY,GAAG,CAAC,OAAO,MAAM;UAC/B,SAAS,iBAAiB,QACnC,QAAO,IAAI,gBAAgB,CAAC,OAAO,MAAM;UAChC,UAAU,KAAK,CACxB,QAAO,eAAe,MAAM,MAAM;AAEpC,QAAO,KAAK,OAAO,MAAM;;AAG3B,SAAgB,mBAAmB,MAAyB,OAA6B;AACvF,QAAO,UAAU,KAAK,GAAG,eAAe,MAAM,MAAM,GAAG,KAAK,OAAO,MAAM"}
1
+ {"version":3,"file":"abi-method.mjs","names":["convertedDefaultValue: ABIDefaultValue | undefined"],"sources":["../../../../packages/abi/src/abi-method.ts"],"sourcesContent":["import sha512 from 'js-sha512'\nimport { ABIAddressType, ABIStructType, ABIType, ABIUintType, parseTupleContent } from './abi-type'\nimport { ABIValue } from './abi-value'\nimport { ARC28Event } from './arc28-event'\nimport { AVMType, Arc56Contract, Arc56Method } from './arc56-contract'\n\nexport enum ABITransactionType {\n Txn = 'txn',\n Payment = 'pay',\n KeyRegistration = 'keyreg',\n AssetConfig = 'acfg',\n AssetTransfer = 'axfer',\n AssetFreeze = 'afrz',\n AppCall = 'appl',\n}\nexport enum ABIReferenceType {\n Account = 'account',\n Application = 'application',\n Asset = 'asset',\n}\nexport type ABIMethodArgType = ABIType | ABITransactionType | ABIReferenceType\nexport type ABIMethodReturnType = ABIType | 'void'\n\nexport type ABIMethodArg = {\n type: ABIMethodArgType\n name?: string\n description?: string\n defaultValue?: ABIDefaultValue\n}\n\nexport type ABIMethodReturn = {\n type: ABIMethodReturnType\n description?: string\n}\n\nexport type ABIDefaultValue = {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** Where the default value is coming from */\n source: DefaultValueSource\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABIType | AVMType\n}\n\nexport enum DefaultValueSource {\n Box = 'box',\n Global = 'global',\n Local = 'local',\n Literal = 'literal',\n Method = 'method',\n}\n\n/** Represents an ABI method return value with parsed data. */\nexport type ABIReturn =\n | {\n /** The method that was called. */\n method: ABIMethod\n /** The raw return value as bytes.\n *\n * This is the value from the last app call log with the first 4 bytes (the ABI return prefix) omitted.\n */\n rawReturnValue: Uint8Array\n /** The parsed ABI return value. */\n returnValue: ABIValue\n decodeError: undefined\n }\n | { rawReturnValue?: undefined; returnValue?: undefined; method: ABIMethod; decodeError?: Error }\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | ABIValue\n}\n\nexport class ABIMethod {\n readonly name: string\n readonly description?: string\n readonly args: ABIMethodArg[]\n readonly returns: ABIMethodReturn\n readonly events?: ARC28Event[]\n readonly readonly?: boolean\n\n constructor(params: {\n name: string\n description?: string\n args: ABIMethodArg[]\n returns: ABIMethodReturn\n events?: ARC28Event[]\n readonly?: boolean\n }) {\n this.name = params.name\n this.description = params.description\n this.args = params.args\n this.returns = params.returns\n this.events = params.events\n this.readonly = params.readonly\n }\n\n /**\n * Returns the signature of this ABI method.\n * @returns The signature, e.g. `my_method(unit64,string)bytes`\n */\n getSignature(): string {\n const args = this.args\n .map((arg) => {\n if (argTypeIsTransaction(arg.type) || argTypeIsReference(arg.type)) return arg.type\n return arg.type.name\n })\n .join(',')\n const returns = this.returns.type === 'void' ? 'void' : this.returns.type.name\n return `${this.name}(${args})${returns}`\n }\n\n /**\n * Returns the method selector of this ABI method.\n * @returns The 4-byte method selector\n */\n getSelector(): Uint8Array {\n const hash = sha512.sha512_256.array(this.getSignature())\n return new Uint8Array(hash.slice(0, 4))\n }\n\n /**\n * Returns the ABI method object for a given method signature.\n * @param signature The method signature\n * e.g. `my_method(unit64,string)bytes`\n * @returns The `ABIMethod`\n */\n static fromSignature(signature: string): ABIMethod {\n const argsStart = signature.indexOf('(')\n if (argsStart === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n let argsEnd = -1\n let depth = 0\n for (let i = argsStart; i < signature.length; i++) {\n const char = signature[i]\n\n if (char === '(') {\n depth += 1\n } else if (char === ')') {\n if (depth === 0) {\n // unpaired parenthesis\n break\n }\n\n depth -= 1\n if (depth === 0) {\n argsEnd = i\n break\n }\n }\n }\n\n if (argsEnd === -1) {\n throw new Error(`Invalid method signature: ${signature}`)\n }\n\n const name = signature.slice(0, argsStart)\n const args = parseTupleContent(signature.slice(argsStart + 1, argsEnd)).map((n: string) => {\n if (argTypeIsTransaction(n as ABIMethodArgType) || argTypeIsReference(n as ABIMethodArgType)) {\n return { type: n as ABIMethodArgType } satisfies ABIMethodArg\n }\n return { type: ABIType.from(n) } satisfies ABIMethodArg\n })\n const returnType = signature.slice(argsEnd + 1)\n const returns = { type: returnType === 'void' ? ('void' as const) : ABIType.from(returnType) } satisfies ABIMethodReturn\n\n return new ABIMethod({\n name,\n args,\n returns,\n })\n }\n}\n\n/**\n * Returns the ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `ABIMethod`\n */\nexport function getABIMethod(methodNameOrSignature: string, appSpec: Arc56Contract): ABIMethod {\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => getArc56MethodSignature(m))\n .join(', ')}`,\n )\n }\n return arc56MethodToABIMethod(methods[0], appSpec)\n } else {\n const method = appSpec.methods.find((m) => getArc56MethodSignature(m) === methodNameOrSignature)\n if (!method) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n return arc56MethodToABIMethod(method, appSpec)\n }\n}\n\nexport function arc56MethodToABIMethod(method: Arc56Method, appSpec: Arc56Contract): ABIMethod {\n if (typeof method.name !== 'string' || typeof method.returns !== 'object' || !Array.isArray(method.args)) {\n throw new Error('Invalid ABIMethod parameters')\n }\n\n const args = method.args.map(({ type, name, desc, struct, defaultValue }) => {\n const convertedDefaultValue: ABIDefaultValue | undefined = defaultValue\n ? {\n data: defaultValue.data,\n source: defaultValue.source as DefaultValueSource,\n type: defaultValue.type ? (isAVMType(defaultValue.type) ? defaultValue.type : ABIType.from(defaultValue.type)) : undefined,\n }\n : undefined\n\n if (argTypeIsTransaction(type as ABIMethodArgType) || argTypeIsReference(type as ABIMethodArgType)) {\n return {\n type: type as ABIMethodArgType,\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n if (struct) {\n return {\n type: ABIStructType.fromStruct(struct, appSpec.structs),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n }\n\n return {\n type: ABIType.from(type),\n name,\n description: desc,\n defaultValue: convertedDefaultValue,\n } satisfies ABIMethodArg\n })\n\n const returns = {\n type:\n method.returns.type === ('void' as const)\n ? ('void' as const)\n : method.returns.struct\n ? ABIStructType.fromStruct(method.returns.struct, appSpec.structs)\n : ABIType.from(method.returns.type),\n description: method.returns.desc,\n } satisfies ABIMethodReturn\n\n return new ABIMethod({\n name: method.name,\n description: method.desc,\n args,\n returns,\n events: method.events,\n readonly: method.readonly,\n })\n}\n\nexport function argTypeIsTransaction(type: ABIMethodArgType): type is ABITransactionType {\n return (\n typeof type === 'string' &&\n (type === ABITransactionType.Txn ||\n type === ABITransactionType.Payment ||\n type === ABITransactionType.KeyRegistration ||\n type === ABITransactionType.AssetConfig ||\n type === ABITransactionType.AssetTransfer ||\n type === ABITransactionType.AssetFreeze ||\n type === ABITransactionType.AppCall)\n )\n}\n\nexport function argTypeIsReference(type: ABIMethodArgType): type is ABIReferenceType {\n return (\n typeof type === 'string' &&\n (type === ABIReferenceType.Account || type === ABIReferenceType.Application || type === ABIReferenceType.Asset)\n )\n}\n\nexport function argTypeIsAbiType(type: ABIMethodArgType): type is ABIType {\n return !argTypeIsTransaction(type) && !argTypeIsReference(type)\n}\n\nfunction getArc56MethodSignature(method: Arc56Method): string {\n const args = method.args.map((arg) => arg.type).join(',')\n const returns = method.returns.type\n return `${method.name}(${args})${returns}`\n}\n\nexport function decodeAVMValue(avmType: AVMType, bytes: Uint8Array): ABIValue {\n switch (avmType) {\n case 'AVMString':\n return Buffer.from(bytes).toString('utf-8')\n case 'AVMBytes':\n return bytes\n case 'AVMUint64':\n return ABIType.from('uint64').decode(bytes)\n }\n}\n\nexport function encodeAVMValue(avmType: AVMType, value: ABIValue): Uint8Array {\n switch (avmType) {\n case 'AVMString':\n return ABIType.from('string').encode(value)\n case 'AVMBytes':\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array))\n throw new Error(`Expected bytes value for AVMBytes, but got ${value}`)\n return value\n case 'AVMUint64':\n return ABIType.from('uint64').encode(value)\n }\n}\n\nexport function isAVMType(type: unknown): type is AVMType {\n return typeof type === 'string' && (type === 'AVMString' || type === 'AVMBytes' || type === 'AVMUint64')\n}\n\nexport function getABIDecodedValue(type: AVMType | ABIType | ABIReferenceType, bytes: Uint8Array): ABIValue {\n if (type === ABIReferenceType.Asset || type === ABIReferenceType.Application) {\n return new ABIUintType(64).decode(bytes)\n } else if (type === ABIReferenceType.Account) {\n return new ABIAddressType().decode(bytes)\n } else if (isAVMType(type)) {\n return decodeAVMValue(type, bytes)\n }\n return type.decode(bytes)\n}\n\nexport function getABIEncodedValue(type: AVMType | ABIType, value: ABIValue): Uint8Array {\n return isAVMType(type) ? encodeAVMValue(type, value) : type.encode(value)\n}\n"],"mappings":";;;;AAMA,IAAY,oEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEF,IAAY,gEAAL;AACL;AACA;AACA;;;AAuDF,IAAa,YAAb,MAAa,UAAU;CACrB,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,QAOT;AACD,OAAK,OAAO,OAAO;AACnB,OAAK,cAAc,OAAO;AAC1B,OAAK,OAAO,OAAO;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,SAAS,OAAO;AACrB,OAAK,WAAW,OAAO;;;;;;CAOzB,eAAuB;EACrB,MAAM,OAAO,KAAK,KACf,KAAK,QAAQ;AACZ,OAAI,qBAAqB,IAAI,KAAK,IAAI,mBAAmB,IAAI,KAAK,CAAE,QAAO,IAAI;AAC/E,UAAO,IAAI,KAAK;IAChB,CACD,KAAK,IAAI;AAEZ,SAAO,GAAG,KAAK,KAAK,GAAG,KAAK,GADZ,KAAK,QAAQ,SAAS,SAAS,SAAS,KAAK,QAAQ,KAAK;;;;;;CAQ5E,cAA0B;EACxB,MAAM,OAAO,OAAO,WAAW,MAAM,KAAK,cAAc,CAAC;AACzD,SAAO,IAAI,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC;;;;;;;;CASzC,OAAO,cAAc,WAA8B;EACjD,MAAM,YAAY,UAAU,QAAQ,IAAI;AACxC,MAAI,cAAc,GAChB,OAAM,IAAI,MAAM,6BAA6B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,GAAG,CAAC,OAAO,MAAM;UAC/B,SAAS,iBAAiB,QACnC,QAAO,IAAI,gBAAgB,CAAC,OAAO,MAAM;UAChC,UAAU,KAAK,CACxB,QAAO,eAAe,MAAM,MAAM;AAEpC,QAAO,KAAK,OAAO,MAAM;;AAG3B,SAAgB,mBAAmB,MAAyB,OAA6B;AACvF,QAAO,UAAU,KAAK,GAAG,eAAe,MAAM,MAAM,GAAG,KAAK,OAAO,MAAM"}
@@ -114,7 +114,7 @@ declare class ABIAddressType extends ABIType {
114
114
  isDynamic(): boolean;
115
115
  byteLen(): number;
116
116
  encode(value: ABIValue): Uint8Array;
117
- decode(bytes: Uint8Array): ABIValue;
117
+ decode(bytes: Uint8Array): string;
118
118
  }
119
119
  /**
120
120
  * A boolean ABI type.
@@ -244,8 +244,6 @@ declare class ABIStructType extends ABIType {
244
244
  static fromStruct(structName: string, structs: Record<string, StructField[]>): ABIStructType;
245
245
  encode(value: ABIValue): Uint8Array;
246
246
  decode(bytes: Uint8Array): ABIStructValue;
247
- private getTupleValueFromStructValue;
248
- private getStructValueFromTupleValue;
249
247
  }
250
248
  declare function parseTupleContent(content: string): string[];
251
249
  //#endregion
@@ -2,6 +2,7 @@ const require_array = require('../../common/src/array.js');
2
2
  const require_constants = require('../../common/src/constants.js');
3
3
  const require_address = require('../../common/src/address.js');
4
4
  const require_bigint = require('./bigint.js');
5
+ const require_utils = require('./utils.js');
5
6
 
6
7
  //#region packages/abi/src/abi-type.ts
7
8
  const STATIC_ARRAY_REGEX = /^([a-z\d[\](),]+)\[(0|[1-9][\d]*)]$/;
@@ -167,10 +168,11 @@ var ABIAddressType = class ABIAddressType extends ABIType {
167
168
  encode(value) {
168
169
  if (typeof value === "string") return require_address.Address.fromString(value).publicKey;
169
170
  if (value instanceof require_address.Address) return value.publicKey;
171
+ if (value instanceof Uint8Array && value.length === 32) return value;
170
172
  throw new Error(`Cannot encode value as address: ${value}`);
171
173
  }
172
174
  decode(bytes) {
173
- return new require_address.Address(bytes);
175
+ return new require_address.Address(bytes).toString();
174
176
  }
175
177
  };
176
178
  /**
@@ -526,46 +528,15 @@ var ABIStructType = class ABIStructType extends ABIType {
526
528
  })));
527
529
  }
528
530
  encode(value) {
529
- if (typeof value !== "object" || Array.isArray(value) || value instanceof Uint8Array || value instanceof require_address.Address) throw new Error(`Cannot encode value as ${this.name}: ${value}`);
531
+ if (value instanceof Uint8Array || value instanceof require_address.Address || typeof value !== "object") throw new Error(`Cannot encode value as ${this.name}: ${value}`);
530
532
  const tupleType = this.toABITupleType();
531
- const tupleValue = this.getTupleValueFromStructValue(value);
533
+ if (Array.isArray(value)) return tupleType.encode(value);
534
+ const tupleValue = require_utils.getTupleValueFromStructValue(this, value);
532
535
  return tupleType.encode(tupleValue);
533
536
  }
534
537
  decode(bytes) {
535
538
  const tupleValue = this.toABITupleType().decode(bytes);
536
- return this.getStructValueFromTupleValue(tupleValue);
537
- }
538
- getTupleValueFromStructValue(structValue) {
539
- const getTupleValueFromStructFields = (structFields, values) => {
540
- return structFields.map(({ type }, index) => {
541
- if (Array.isArray(type)) {
542
- const value = values[index];
543
- return getTupleValueFromStructFields(type, Object.values(value));
544
- }
545
- if (type instanceof ABIStructType) {
546
- const value = values[index];
547
- return getTupleValueFromStructFields(type.structFields, Object.values(value));
548
- }
549
- return values[index];
550
- });
551
- };
552
- return getTupleValueFromStructFields(this.structFields, Object.values(structValue));
553
- }
554
- getStructValueFromTupleValue(tupleValue) {
555
- const getStructFieldValues = (structFields, values) => {
556
- return Object.fromEntries(structFields.map(({ name, type }, index) => {
557
- if (Array.isArray(type)) {
558
- const value = values[index];
559
- return [name, getStructFieldValues(type, value)];
560
- }
561
- if (type instanceof ABIStructType) {
562
- const value = values[index];
563
- return [name, getStructFieldValues(type.structFields, value)];
564
- }
565
- return [name, values[index]];
566
- }));
567
- };
568
- return getStructFieldValues(this.structFields, tupleValue);
539
+ return require_utils.getStructValueFromTupleValue(this, tupleValue);
569
540
  }
570
541
  };
571
542
  function compressBools(values) {