@algorandfoundation/algokit-utils 7.0.0-beta.5 → 7.0.0-beta.7

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 (324) hide show
  1. package/README.md +2 -24
  2. package/account/account.d.ts +1 -2
  3. package/account/account.js.map +1 -1
  4. package/account/account.mjs.map +1 -1
  5. package/account/get-account-config-from-environment.d.ts +0 -1
  6. package/account/get-account-config-from-environment.js.map +1 -1
  7. package/account/get-account-config-from-environment.mjs.map +1 -1
  8. package/account/get-account.d.ts +0 -1
  9. package/account/get-account.js.map +1 -1
  10. package/account/get-account.mjs.map +1 -1
  11. package/account/get-dispenser-account.d.ts +0 -1
  12. package/account/get-dispenser-account.js.map +1 -1
  13. package/account/get-dispenser-account.mjs.map +1 -1
  14. package/account/index.d.ts +0 -1
  15. package/account/mnemonic-account.d.ts +0 -1
  16. package/account/mnemonic-account.js.map +1 -1
  17. package/account/mnemonic-account.mjs.map +1 -1
  18. package/amount.d.ts +0 -1
  19. package/amount.js.map +1 -1
  20. package/amount.mjs.map +1 -1
  21. package/app-client.d.ts +0 -1
  22. package/app-client.js.map +1 -1
  23. package/app-client.mjs.map +1 -1
  24. package/app-deploy.d.ts +0 -1
  25. package/app-deploy.js.map +1 -1
  26. package/app-deploy.mjs.map +1 -1
  27. package/app.d.ts +6 -7
  28. package/app.js +6 -6
  29. package/app.js.map +1 -1
  30. package/app.mjs +6 -6
  31. package/app.mjs.map +1 -1
  32. package/asset.d.ts +3 -4
  33. package/asset.js +3 -3
  34. package/asset.js.map +1 -1
  35. package/asset.mjs +3 -3
  36. package/asset.mjs.map +1 -1
  37. package/config.d.ts +0 -1
  38. package/config.js.map +1 -1
  39. package/config.mjs.map +1 -1
  40. package/debugging/debugging.d.ts +3 -5
  41. package/debugging/debugging.js +4 -127
  42. package/debugging/debugging.js.map +1 -1
  43. package/debugging/debugging.mjs +4 -108
  44. package/debugging/debugging.mjs.map +1 -1
  45. package/debugging/index.d.ts +0 -2
  46. package/dispenser-client.d.ts +0 -1
  47. package/dispenser-client.js.map +1 -1
  48. package/dispenser-client.mjs.map +1 -1
  49. package/index.d.ts +1 -1
  50. package/index.js +6 -2
  51. package/index.js.map +1 -1
  52. package/index.mjs +1 -1
  53. package/indexer-lookup.d.ts +0 -1
  54. package/indexer-lookup.js.map +1 -1
  55. package/indexer-lookup.mjs.map +1 -1
  56. package/localnet/get-kmd-wallet-account.d.ts +0 -1
  57. package/localnet/get-kmd-wallet-account.js.map +1 -1
  58. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  59. package/localnet/get-localnet-dispenser-account.d.ts +0 -1
  60. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  61. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  62. package/localnet/get-or-create-kmd-wallet-account.d.ts +0 -1
  63. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  64. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  65. package/localnet/index.d.ts +0 -1
  66. package/localnet/is-localnet.d.ts +0 -1
  67. package/localnet/is-localnet.js.map +1 -1
  68. package/localnet/is-localnet.mjs.map +1 -1
  69. package/network-client.d.ts +0 -1
  70. package/network-client.js.map +1 -1
  71. package/network-client.mjs.map +1 -1
  72. package/package.json +1 -1
  73. package/testing/_asset.d.ts +0 -1
  74. package/testing/account.d.ts +0 -1
  75. package/testing/account.js.map +1 -1
  76. package/testing/account.mjs.map +1 -1
  77. package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
  78. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  79. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  80. package/testing/fixtures/algorand-fixture.d.ts +0 -1
  81. package/testing/fixtures/algorand-fixture.js +1 -1
  82. package/testing/fixtures/algorand-fixture.js.map +1 -1
  83. package/testing/fixtures/algorand-fixture.mjs +1 -1
  84. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  85. package/testing/fixtures/index.d.ts +0 -1
  86. package/testing/index.d.ts +0 -1
  87. package/testing/indexer.d.ts +0 -1
  88. package/testing/indexer.js.map +1 -1
  89. package/testing/indexer.mjs.map +1 -1
  90. package/testing/test-logger.d.ts +0 -1
  91. package/testing/test-logger.js.map +1 -1
  92. package/testing/test-logger.mjs.map +1 -1
  93. package/testing/transaction-logger.d.ts +0 -1
  94. package/testing/transaction-logger.js.map +1 -1
  95. package/testing/transaction-logger.mjs.map +1 -1
  96. package/transaction/index.d.ts +0 -1
  97. package/transaction/legacy-bridge.d.ts +3 -4
  98. package/transaction/legacy-bridge.js.map +1 -1
  99. package/transaction/legacy-bridge.mjs.map +1 -1
  100. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +0 -1
  101. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  102. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  103. package/transaction/transaction.d.ts +1 -4
  104. package/transaction/transaction.js +26 -31
  105. package/transaction/transaction.js.map +1 -1
  106. package/transaction/transaction.mjs +26 -31
  107. package/transaction/transaction.mjs.map +1 -1
  108. package/transfer/index.d.ts +0 -1
  109. package/transfer/transfer-algos.d.ts +1 -2
  110. package/transfer/transfer-algos.js +1 -1
  111. package/transfer/transfer-algos.js.map +1 -1
  112. package/transfer/transfer-algos.mjs +1 -1
  113. package/transfer/transfer-algos.mjs.map +1 -1
  114. package/transfer/transfer.d.ts +1 -2
  115. package/transfer/transfer.js +1 -1
  116. package/transfer/transfer.js.map +1 -1
  117. package/transfer/transfer.mjs +1 -1
  118. package/transfer/transfer.mjs.map +1 -1
  119. package/types/account-manager.d.ts +13 -5
  120. package/types/account-manager.js +17 -3
  121. package/types/account-manager.js.map +1 -1
  122. package/types/account-manager.mjs +17 -3
  123. package/types/account-manager.mjs.map +1 -1
  124. package/types/account.d.ts +0 -1
  125. package/types/account.js.map +1 -1
  126. package/types/account.mjs.map +1 -1
  127. package/types/algo-http-client-with-retry.d.ts +0 -1
  128. package/types/algo-http-client-with-retry.js.map +1 -1
  129. package/types/algo-http-client-with-retry.mjs.map +1 -1
  130. package/types/algorand-client-interface.d.ts +1 -2
  131. package/types/algorand-client-transaction-creator.d.ts +30 -31
  132. package/types/algorand-client-transaction-creator.js +30 -30
  133. package/types/algorand-client-transaction-creator.js.map +1 -1
  134. package/types/algorand-client-transaction-creator.mjs +30 -30
  135. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  136. package/types/algorand-client-transaction-sender.d.ts +19 -20
  137. package/types/algorand-client-transaction-sender.js +2 -2
  138. package/types/algorand-client-transaction-sender.js.map +1 -1
  139. package/types/algorand-client-transaction-sender.mjs +2 -2
  140. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  141. package/types/algorand-client.d.ts +8 -9
  142. package/types/algorand-client.js +8 -8
  143. package/types/algorand-client.js.map +1 -1
  144. package/types/algorand-client.mjs +8 -8
  145. package/types/algorand-client.mjs.map +1 -1
  146. package/types/amount.d.ts +0 -1
  147. package/types/amount.js.map +1 -1
  148. package/types/amount.mjs.map +1 -1
  149. package/types/app-arc56.d.ts +60 -38
  150. package/types/app-arc56.js +37 -16
  151. package/types/app-arc56.js.map +1 -1
  152. package/types/app-arc56.mjs +37 -16
  153. package/types/app-arc56.mjs.map +1 -1
  154. package/types/app-client.d.ts +100 -75
  155. package/types/app-client.js +154 -101
  156. package/types/app-client.js.map +1 -1
  157. package/types/app-client.mjs +154 -101
  158. package/types/app-client.mjs.map +1 -1
  159. package/types/app-deployer.d.ts +2 -3
  160. package/types/app-deployer.js +24 -24
  161. package/types/app-deployer.js.map +1 -1
  162. package/types/app-deployer.mjs +24 -24
  163. package/types/app-deployer.mjs.map +1 -1
  164. package/types/app-factory.d.ts +141 -87
  165. package/types/app-factory.js +106 -34
  166. package/types/app-factory.js.map +1 -1
  167. package/types/app-factory.mjs +107 -35
  168. package/types/app-factory.mjs.map +1 -1
  169. package/types/app-manager.d.ts +0 -1
  170. package/types/app-manager.js.map +1 -1
  171. package/types/app-manager.mjs.map +1 -1
  172. package/types/app-spec.d.ts +0 -1
  173. package/types/app-spec.js +15 -9
  174. package/types/app-spec.js.map +1 -1
  175. package/types/app-spec.mjs +15 -9
  176. package/types/app-spec.mjs.map +1 -1
  177. package/types/app.d.ts +0 -1
  178. package/types/app.js.map +1 -1
  179. package/types/app.mjs.map +1 -1
  180. package/types/asset-manager.d.ts +3 -4
  181. package/types/asset-manager.js +3 -3
  182. package/types/asset-manager.js.map +1 -1
  183. package/types/asset-manager.mjs +3 -3
  184. package/types/asset-manager.mjs.map +1 -1
  185. package/types/asset.d.ts +0 -1
  186. package/types/async-event-emitter.d.ts +23 -0
  187. package/types/async-event-emitter.js +55 -0
  188. package/types/async-event-emitter.js.map +1 -0
  189. package/types/async-event-emitter.mjs +53 -0
  190. package/types/async-event-emitter.mjs.map +1 -0
  191. package/types/client-manager.d.ts +30 -9
  192. package/types/client-manager.js +6 -0
  193. package/types/client-manager.js.map +1 -1
  194. package/types/client-manager.mjs +6 -0
  195. package/types/client-manager.mjs.map +1 -1
  196. package/types/composer.d.ts +57 -5
  197. package/types/composer.js +30 -14
  198. package/types/composer.js.map +1 -1
  199. package/types/composer.mjs +30 -14
  200. package/types/composer.mjs.map +1 -1
  201. package/types/config.d.ts +3 -6
  202. package/types/config.js +5 -44
  203. package/types/config.js.map +1 -1
  204. package/types/config.mjs +5 -27
  205. package/types/config.mjs.map +1 -1
  206. package/types/debugging.d.ts +29 -102
  207. package/types/debugging.js +16 -109
  208. package/types/debugging.js.map +1 -1
  209. package/types/debugging.mjs +12 -107
  210. package/types/debugging.mjs.map +1 -1
  211. package/types/dispenser-client.d.ts +0 -1
  212. package/types/dispenser-client.js +5 -4
  213. package/types/dispenser-client.js.map +1 -1
  214. package/types/dispenser-client.mjs +5 -4
  215. package/types/dispenser-client.mjs.map +1 -1
  216. package/types/expand.d.ts +0 -1
  217. package/types/indexer.d.ts +0 -1
  218. package/types/indexer.js.map +1 -1
  219. package/types/indexer.mjs.map +1 -1
  220. package/types/kmd-account-manager.d.ts +0 -1
  221. package/types/kmd-account-manager.js +2 -2
  222. package/types/kmd-account-manager.js.map +1 -1
  223. package/types/kmd-account-manager.mjs +2 -2
  224. package/types/kmd-account-manager.mjs.map +1 -1
  225. package/types/logging.d.ts +0 -1
  226. package/types/logging.js.map +1 -1
  227. package/types/logging.mjs.map +1 -1
  228. package/types/logic-error.d.ts +0 -1
  229. package/types/logic-error.js.map +1 -1
  230. package/types/logic-error.mjs.map +1 -1
  231. package/types/network-client.d.ts +0 -1
  232. package/types/network-client.js.map +1 -1
  233. package/types/network-client.mjs.map +1 -1
  234. package/types/testing.d.ts +0 -1
  235. package/types/transaction.d.ts +4 -7
  236. package/types/transfer.d.ts +0 -1
  237. package/types/urlTokenBaseHTTPClient.d.ts +0 -1
  238. package/types/urlTokenBaseHTTPClient.js +1 -1
  239. package/types/urlTokenBaseHTTPClient.js.map +1 -1
  240. package/types/urlTokenBaseHTTPClient.mjs +1 -1
  241. package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
  242. package/util.d.ts +0 -1
  243. package/util.js +0 -9
  244. package/util.js.map +1 -1
  245. package/util.mjs +1 -9
  246. package/util.mjs.map +1 -1
  247. package/account/account.d.ts.map +0 -1
  248. package/account/get-account-config-from-environment.d.ts.map +0 -1
  249. package/account/get-account.d.ts.map +0 -1
  250. package/account/get-dispenser-account.d.ts.map +0 -1
  251. package/account/index.d.ts.map +0 -1
  252. package/account/mnemonic-account.d.ts.map +0 -1
  253. package/amount.d.ts.map +0 -1
  254. package/app-client.d.ts.map +0 -1
  255. package/app-deploy.d.ts.map +0 -1
  256. package/app.d.ts.map +0 -1
  257. package/asset.d.ts.map +0 -1
  258. package/config.d.ts.map +0 -1
  259. package/debugging/debugging.d.ts.map +0 -1
  260. package/debugging/index.d.ts.map +0 -1
  261. package/debugging/simulate-and-persist-response.d.ts +0 -20
  262. package/debugging/simulate-and-persist-response.d.ts.map +0 -1
  263. package/debugging/simulate-and-persist-response.js +0 -108
  264. package/debugging/simulate-and-persist-response.js.map +0 -1
  265. package/debugging/simulate-and-persist-response.mjs +0 -89
  266. package/debugging/simulate-and-persist-response.mjs.map +0 -1
  267. package/dispenser-client.d.ts.map +0 -1
  268. package/index.d.ts.map +0 -1
  269. package/indexer-lookup.d.ts.map +0 -1
  270. package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
  271. package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
  272. package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
  273. package/localnet/index.d.ts.map +0 -1
  274. package/localnet/is-localnet.d.ts.map +0 -1
  275. package/network-client.d.ts.map +0 -1
  276. package/testing/_asset.d.ts.map +0 -1
  277. package/testing/account.d.ts.map +0 -1
  278. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
  279. package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
  280. package/testing/fixtures/index.d.ts.map +0 -1
  281. package/testing/index.d.ts.map +0 -1
  282. package/testing/indexer.d.ts.map +0 -1
  283. package/testing/test-logger.d.ts.map +0 -1
  284. package/testing/transaction-logger.d.ts.map +0 -1
  285. package/transaction/index.d.ts.map +0 -1
  286. package/transaction/legacy-bridge.d.ts.map +0 -1
  287. package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
  288. package/transaction/transaction.d.ts.map +0 -1
  289. package/transfer/index.d.ts.map +0 -1
  290. package/transfer/transfer-algos.d.ts.map +0 -1
  291. package/transfer/transfer.d.ts.map +0 -1
  292. package/types/account-manager.d.ts.map +0 -1
  293. package/types/account.d.ts.map +0 -1
  294. package/types/algo-http-client-with-retry.d.ts.map +0 -1
  295. package/types/algorand-client-interface.d.ts.map +0 -1
  296. package/types/algorand-client-transaction-creator.d.ts.map +0 -1
  297. package/types/algorand-client-transaction-sender.d.ts.map +0 -1
  298. package/types/algorand-client.d.ts.map +0 -1
  299. package/types/amount.d.ts.map +0 -1
  300. package/types/app-arc56.d.ts.map +0 -1
  301. package/types/app-client.d.ts.map +0 -1
  302. package/types/app-deployer.d.ts.map +0 -1
  303. package/types/app-factory.d.ts.map +0 -1
  304. package/types/app-manager.d.ts.map +0 -1
  305. package/types/app-spec.d.ts.map +0 -1
  306. package/types/app.d.ts.map +0 -1
  307. package/types/asset-manager.d.ts.map +0 -1
  308. package/types/asset.d.ts.map +0 -1
  309. package/types/client-manager.d.ts.map +0 -1
  310. package/types/composer.d.ts.map +0 -1
  311. package/types/config.d.ts.map +0 -1
  312. package/types/debugging.d.ts.map +0 -1
  313. package/types/dispenser-client.d.ts.map +0 -1
  314. package/types/expand.d.ts.map +0 -1
  315. package/types/indexer.d.ts.map +0 -1
  316. package/types/kmd-account-manager.d.ts.map +0 -1
  317. package/types/logging.d.ts.map +0 -1
  318. package/types/logic-error.d.ts.map +0 -1
  319. package/types/network-client.d.ts.map +0 -1
  320. package/types/testing.d.ts.map +0 -1
  321. package/types/transaction.d.ts.map +0 -1
  322. package/types/transfer.d.ts.map +0 -1
  323. package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
  324. package/util.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"amount.mjs","sources":["../../src/types/amount.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;MACa,UAAU,CAAA;;AAIrB,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAA;KAC9B;;AAGD,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,IAAI,CAAC,iBAAiB,CAAA;KAC9B;;AAGD,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;KACjE;;AAGD,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;KACjE;AAED,IAAA,WAAA,CACE,MAAiI,EAAA;AAEjI,QAAA,IAAI,CAAC,iBAAiB;AACpB,YAAA,YAAY,IAAI,MAAM;AACpB,kBAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;kBACzB,WAAW,IAAI,MAAM;AACrB,sBAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;sBACxB,OAAO,IAAI,MAAM;AACjB,0BAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,0BAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KACjE;IAED,QAAQ,GAAA;QACN,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA,MAAA,CAAQ,CAAA;KACzD;AAED;;;AAGG;IACH,OAAO,GAAA;AACL,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;KAC9B;;IAGD,OAAO,KAAK,CAAC,MAAuB,EAAA;QAClC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;KACzC;;IAGD,OAAO,IAAI,CAAC,MAAuB,EAAA;QACjC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;KACzC;;IAGD,OAAO,UAAU,CAAC,MAAuB,EAAA;QACvC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;;IAGD,OAAO,SAAS,CAAC,MAAuB,EAAA;QACtC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;AACF;;;;"}
1
+ {"version":3,"file":"amount.mjs","sources":["../../src/types/amount.ts"],"sourcesContent":["import algosdk from 'algosdk'\n\n/** Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers */\nexport class AlgoAmount {\n private amountInMicroAlgo: bigint\n\n /** Return the amount as a number in µAlgo */\n get microAlgos() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in µAlgo */\n get microAlgo() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in Algo */\n get algos() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n /** Return the amount as a number in Algo */\n get algo() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n constructor(\n amount: { algos: number | bigint } | { algo: number | bigint } | { microAlgos: number | bigint } | { microAlgo: number | bigint },\n ) {\n this.amountInMicroAlgo =\n 'microAlgos' in amount\n ? BigInt(amount.microAlgos)\n : 'microAlgo' in amount\n ? BigInt(amount.microAlgo)\n : 'algos' in amount\n ? BigInt(algosdk.algosToMicroalgos(Number(amount.algos)))\n : BigInt(algosdk.algosToMicroalgos(Number(amount.algo)))\n }\n\n toString(): string {\n return `${this.microAlgo.toLocaleString('en-US')} µALGO`\n }\n\n /** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,\n * but it's not recommended to use this to convert to a number, it's much safer to explicitly call\n * the algos or microAlgos properties\n */\n valueOf(): number {\n return Number(this.microAlgo)\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algos(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algo(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgos(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgo(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n}\n"],"names":[],"mappings":";;AAEA;MACa,UAAU,CAAA;;AAIrB,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAA;KAC9B;;AAGD,I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D,OAAO,UAAU,CAAC,MAAuB,EAAA;QACvC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;;IAGD,OAAO,SAAS,CAAC,MAAuB,EAAA;QACtC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;AACF;;;;"}
@@ -1,17 +1,21 @@
1
1
  import algosdk from 'algosdk';
2
2
  import { ABIReturn } from './app';
3
3
  import { Expand } from './expand';
4
+ /** Type to describe an argument within an `Arc56Method`. */
5
+ export type Arc56MethodArg = Expand<Omit<Method['args'][number], 'type'> & {
6
+ type: algosdk.ABIArgumentType;
7
+ }>;
8
+ /** Type to describe a return type within an `Arc56Method`. */
9
+ export type Arc56MethodReturnType = Expand<Omit<Method['returns'], 'type'> & {
10
+ type: algosdk.ABIReturnType;
11
+ }>;
4
12
  /**
5
13
  * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.
6
14
  */
7
15
  export declare class Arc56Method extends algosdk.ABIMethod {
8
16
  method: Method;
9
- readonly args: Array<Expand<Omit<Method['args'][number], 'type'> & {
10
- type: algosdk.ABIArgumentType;
11
- }>>;
12
- readonly returns: Expand<Omit<Method['returns'], 'type'> & {
13
- type: algosdk.ABIReturnType;
14
- }>;
17
+ readonly args: Array<Arc56MethodArg>;
18
+ readonly returns: Arc56MethodReturnType;
15
19
  constructor(method: Method);
16
20
  toJSON(): Method;
17
21
  }
@@ -20,21 +24,21 @@ export declare class Arc56Method extends algosdk.ABIMethod {
20
24
  * @param struct The ARC-56 struct definition
21
25
  * @returns The `ABITupleType`
22
26
  */
23
- export declare function getABITupleTypeFromABIStructDefinition(struct: StructFields): algosdk.ABITupleType;
27
+ export declare function getABITupleTypeFromABIStructDefinition(struct: StructField[], structs: Record<string, StructField[]>): algosdk.ABITupleType;
24
28
  /**
25
29
  * Converts a decoded ABI tuple as a struct.
26
30
  * @param decodedABITuple The decoded ABI tuple value
27
31
  * @param structFields The struct fields from an ARC-56 app spec
28
32
  * @returns The struct as a Record<string, any>
29
33
  */
30
- export declare function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(decodedABITuple: algosdk.ABIValue[], structFields: StructFields): TReturn;
34
+ export declare function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(decodedABITuple: algosdk.ABIValue[], structFields: StructField[], structs: Record<string, StructField[]>): TReturn;
31
35
  /**
32
36
  * Converts an ARC-56 struct as an ABI tuple.
33
37
  * @param struct The struct to convert
34
38
  * @param structFields The struct fields from an ARC-56 app spec
35
39
  * @returns The struct as a decoded ABI tuple
36
40
  */
37
- export declare function getABITupleFromABIStruct(struct: ABIStruct, structFields: StructFields): algosdk.ABIValue[];
41
+ export declare function getABITupleFromABIStruct(struct: ABIStruct, structFields: StructField[], structs: Record<string, StructField[]>): algosdk.ABIValue[];
38
42
  /** Decoded ARC-56 struct as a struct rather than a tuple. */
39
43
  export type ABIStruct = {
40
44
  [key: string]: ABIStruct | algosdk.ABIValue;
@@ -47,7 +51,7 @@ export type ABIStruct = {
47
51
  * @param structs The defined ARC-56 structs
48
52
  * @returns The decoded ABI value or struct
49
53
  */
50
- export declare function getABIDecodedValue(value: Uint8Array | number | bigint, type: string, structs: Record<string, StructFields>): algosdk.ABIValue | ABIStruct;
54
+ export declare function getABIDecodedValue(value: Uint8Array | number | bigint, type: string, structs: Record<string, StructField[]>): algosdk.ABIValue | ABIStruct;
51
55
  /**
52
56
  * Returns the ABI-encoded value for the given value.
53
57
  * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct
@@ -55,7 +59,7 @@ export declare function getABIDecodedValue(value: Uint8Array | number | bigint,
55
59
  * @param structs The defined ARC-56 structs
56
60
  * @returns The binary ABI-encoded value
57
61
  */
58
- export declare function getABIEncodedValue(value: Uint8Array | algosdk.ABIValue | ABIStruct, type: string, structs: Record<string, StructFields>): Uint8Array;
62
+ export declare function getABIEncodedValue(value: Uint8Array | algosdk.ABIValue | ABIStruct, type: string, structs: Record<string, StructField[]>): Uint8Array;
59
63
  /**
60
64
  * Returns the ARC-56 ABI method object for a given method name or signature and ARC-56 app spec.
61
65
  * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
@@ -72,7 +76,7 @@ export declare function getArc56Method(methodNameOrSignature: string, appSpec: A
72
76
  * @param structs The struct fields from the app spec
73
77
  * @returns The smart contract response with an updated return value
74
78
  */
75
- export declare function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(returnValue: ABIReturn | undefined, method: Method | Arc56Method, structs: StructFields): TReturn;
79
+ export declare function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(returnValue: ABIReturn | undefined, method: Method | Arc56Method, structs: Record<string, StructField[]>): TReturn;
76
80
  /****************/
77
81
  /** ARC-56 spec */
78
82
  /****************/
@@ -85,23 +89,21 @@ export interface Arc56Contract {
85
89
  /** Optional, user-friendly description for the interface */
86
90
  desc?: string;
87
91
  /**
88
- * Optional object listing the contract instances across different networks
92
+ * Optional object listing the contract instances across different networks.
93
+ * The key is the base64 genesis hash of the network, and the value contains
94
+ * information about the deployed contract in the network indicated by the
95
+ * key. A key containing the human-readable name of the network MAY be
96
+ * included, but the corresponding genesis hash key MUST also be define
89
97
  */
90
98
  networks?: {
91
- /**
92
- * The key is the base64 genesis hash of the network, and the value contains
93
- * information about the deployed contract in the network indicated by the
94
- * key. A key containing the human-readable name of the network MAY be
95
- * included, but the corresponding genesis hash key MUST also be defined
96
- */
97
99
  [network: string]: {
98
100
  /** The app ID of the deployed contract in this network */
99
101
  appID: number;
100
102
  };
101
103
  };
102
- /** Named structs use by the application */
104
+ /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */
103
105
  structs: {
104
- [structName: StructName]: StructFields;
106
+ [structName: StructName]: StructField[];
105
107
  };
106
108
  /** All of the methods that the contract implements */
107
109
  methods: Method[];
@@ -179,7 +181,7 @@ export interface Arc56Contract {
179
181
  major: number;
180
182
  minor: number;
181
183
  patch: number;
182
- commit?: string;
184
+ commitHash?: string;
183
185
  };
184
186
  };
185
187
  /** ARC-28 events that MAY be emitted by this contract */
@@ -188,7 +190,7 @@ export interface Arc56Contract {
188
190
  templateVariables?: {
189
191
  [name: string]: {
190
192
  /** The type of the template variable */
191
- type: ABIType | AVMBytes | StructName;
193
+ type: ABIType | AVMType | StructName;
192
194
  /** If given, the the base64 encoded value used for the given app/program */
193
195
  value?: string;
194
196
  };
@@ -197,7 +199,7 @@ export interface Arc56Contract {
197
199
  scratchVariables?: {
198
200
  [name: string]: {
199
201
  slot: number;
200
- type: ABIType | AVMBytes | StructName;
202
+ type: ABIType | AVMType | StructName;
201
203
  };
202
204
  };
203
205
  }
@@ -209,7 +211,7 @@ export interface Method {
209
211
  desc?: string;
210
212
  /** The arguments of the method, in order */
211
213
  args: Array<{
212
- /** The type of the argument */
214
+ /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */
213
215
  type: ABIType;
214
216
  /** If the type is a struct, the name of the struct */
215
217
  struct?: StructName;
@@ -217,12 +219,24 @@ export interface Method {
217
219
  name?: string;
218
220
  /** Optional, user-friendly description for the argument */
219
221
  desc?: string;
220
- /** The default value that clients should use. MUST be base64 encoded bytes */
221
- defaultValue?: string;
222
+ /** The default value that clients should use. */
223
+ defaultValue?: {
224
+ /** Base64 encoded bytes or uint64 */
225
+ data: string | number;
226
+ /** How the data is encoded. This is the encoding for the data provided here, not the arg type */
227
+ type: ABIType | AVMType;
228
+ /** Where the default value is coming from
229
+ * - box: The data key signifies the box key to read the value from
230
+ * - global: The data key signifies the global state key to read the value from
231
+ * - local: The data key signifies the local state key to read the value from (for the sender)
232
+ * - literal: the value is a literal and should be passed directly as the argument
233
+ */
234
+ source: 'box' | 'global' | 'local' | 'literal';
235
+ };
222
236
  }>;
223
237
  /** Information about the method's return value */
224
238
  returns: {
225
- /** The type of the return value, or "void" to indicate no return value. */
239
+ /** The type of the return value, or "void" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */
226
240
  type: ABIType;
227
241
  /** If the type is a struct, the name of the struct */
228
242
  struct?: StructName;
@@ -271,7 +285,7 @@ export interface Event {
271
285
  desc?: string;
272
286
  /** The arguments of the event, in order */
273
287
  args: Array<{
274
- /** The type of the argument */
288
+ /** The type of the argument. The `struct` field should also be checked to determine if this return value is a struct. */
275
289
  type: ABIType;
276
290
  /** Optional, user-friendly name for the argument */
277
291
  name?: string;
@@ -286,19 +300,28 @@ export type ABIType = string;
286
300
  /** The name of a defined struct */
287
301
  export type StructName = string;
288
302
  /** Raw byteslice without the length prefixed that is specified in ARC-4 */
289
- export type AVMBytes = 'bytes';
290
- /** Mapping of named structs to the ABI type of their fields */
291
- export interface StructFields {
292
- [fieldName: string]: ABIType | StructFields;
303
+ export type AVMBytes = 'AVMBytes';
304
+ /** A utf-8 string without the length prefix that is specified in ARC-4 */
305
+ export type AVMString = 'AVMString';
306
+ /** A 64-bit unsigned integer */
307
+ export type AVMUint64 = 'AVMUint64';
308
+ /** A native AVM type */
309
+ export type AVMType = AVMBytes | AVMString | AVMUint64;
310
+ /** Information about a single field in a struct */
311
+ export interface StructField {
312
+ /** The name of the struct field */
313
+ name: string;
314
+ /** The type of the struct field's value */
315
+ type: ABIType | StructName | StructField[];
293
316
  }
294
317
  /** Describes a single key in app storage */
295
318
  export interface StorageKey {
296
319
  /** Description of what this storage key holds */
297
320
  desc?: string;
298
321
  /** The type of the key */
299
- keyType: ABIType | AVMBytes | StructName;
322
+ keyType: ABIType | AVMType | StructName;
300
323
  /** The type of the value */
301
- valueType: ABIType | AVMBytes | StructName;
324
+ valueType: ABIType | AVMType | StructName;
302
325
  /** The bytes of the key encoded as base64 */
303
326
  key: string;
304
327
  }
@@ -307,9 +330,9 @@ export interface StorageMap {
307
330
  /** Description of what the key-value pairs in this mapping hold */
308
331
  desc?: string;
309
332
  /** The type of the keys in the map */
310
- keyType: ABIType | AVMBytes | StructName;
333
+ keyType: ABIType | AVMType | StructName;
311
334
  /** The type of the values in the map */
312
- valueType: ABIType | AVMBytes | StructName;
335
+ valueType: ABIType | AVMType | StructName;
313
336
  /** The base64-encoded prefix of the map keys*/
314
337
  prefix?: string;
315
338
  }
@@ -323,4 +346,3 @@ export interface SourceInfo {
323
346
  /** The line of the dissasembled TEAL this line of pre-compiled TEAL corresponds to */
324
347
  disassembledTeal?: number;
325
348
  }
326
- //# sourceMappingURL=app-arc56.d.ts.map
@@ -27,8 +27,12 @@ class Arc56Method extends algosdk.ABIMethod {
27
27
  * @param struct The ARC-56 struct definition
28
28
  * @returns The `ABITupleType`
29
29
  */
30
- function getABITupleTypeFromABIStructDefinition(struct) {
31
- return new algosdk.ABITupleType(Object.values(struct).map((v) => (typeof v === 'string' ? algosdk.ABIType.from(v) : getABITupleTypeFromABIStructDefinition(v))));
30
+ function getABITupleTypeFromABIStructDefinition(struct, structs) {
31
+ return new algosdk.ABITupleType(struct.map((v) => typeof v.type === 'string'
32
+ ? structs[v.type]
33
+ ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)
34
+ : algosdk.ABIType.from(v.type)
35
+ : getABITupleTypeFromABIStructDefinition(v.type, structs)));
32
36
  }
33
37
  /**
34
38
  * Converts a decoded ABI tuple as a struct.
@@ -37,10 +41,15 @@ function getABITupleTypeFromABIStructDefinition(struct) {
37
41
  * @returns The struct as a Record<string, any>
38
42
  */
39
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- function getABIStructFromABITuple(decodedABITuple, structFields) {
41
- return Object.fromEntries(Object.entries(structFields).map(([key, type], i) => {
44
+ function getABIStructFromABITuple(decodedABITuple, structFields, structs) {
45
+ return Object.fromEntries(structFields.map(({ name: key, type }, i) => {
42
46
  const abiValue = decodedABITuple[i];
43
- return [key, typeof type === 'string' || !Array.isArray(abiValue) ? decodedABITuple[i] : getABIStructFromABITuple(abiValue, type)];
47
+ return [
48
+ key,
49
+ (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)
50
+ ? decodedABITuple[i]
51
+ : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),
52
+ ];
44
53
  }));
45
54
  }
46
55
  /**
@@ -49,10 +58,12 @@ function getABIStructFromABITuple(decodedABITuple, structFields) {
49
58
  * @param structFields The struct fields from an ARC-56 app spec
50
59
  * @returns The struct as a decoded ABI tuple
51
60
  */
52
- function getABITupleFromABIStruct(struct, structFields) {
53
- return Object.entries(structFields).map(([key, type]) => {
61
+ function getABITupleFromABIStruct(struct, structFields, structs) {
62
+ return structFields.map(({ name: key, type }) => {
54
63
  const value = struct[key];
55
- return typeof type === 'string' ? value : getABITupleFromABIStruct(value, type);
64
+ return typeof type === 'string' && !structs[type]
65
+ ? value
66
+ : getABITupleFromABIStruct(value, typeof type === 'string' ? structs[type] : type, structs);
56
67
  });
57
68
  }
58
69
  /**
@@ -64,11 +75,15 @@ function getABITupleFromABIStruct(struct, structFields) {
64
75
  * @returns The decoded ABI value or struct
65
76
  */
66
77
  function getABIDecodedValue(value, type, structs) {
67
- if (type === 'bytes' || typeof value !== 'object')
78
+ if (type === 'AVMBytes' || typeof value !== 'object')
68
79
  return value;
80
+ if (type === 'AVMString')
81
+ return Buffer.from(value).toString('utf-8');
82
+ if (type === 'AVMUint64')
83
+ return algosdk.ABIType.from('uint64').decode(value);
69
84
  if (structs[type]) {
70
- const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type]).decode(value);
71
- return getABIStructFromABITuple(tupleValue, structs[type]);
85
+ const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value);
86
+ return getABIStructFromABITuple(tupleValue, structs[type], structs);
72
87
  }
73
88
  return algosdk.ABIType.from(type).decode(value);
74
89
  }
@@ -82,7 +97,9 @@ function getABIDecodedValue(value, type, structs) {
82
97
  function getABIEncodedValue(value, type, structs) {
83
98
  if (typeof value === 'object' && value instanceof Uint8Array)
84
99
  return value;
85
- if (type === 'bytes') {
100
+ if (type === 'AVMUint64')
101
+ return algosdk.ABIType.from('uint64').encode(value);
102
+ if (type === 'AVMBytes' || type === 'AVMString') {
86
103
  if (typeof value === 'string')
87
104
  return Buffer.from(value, 'utf-8');
88
105
  if (typeof value !== 'object' || !(value instanceof Uint8Array))
@@ -90,12 +107,12 @@ function getABIEncodedValue(value, type, structs) {
90
107
  return value;
91
108
  }
92
109
  if (structs[type]) {
93
- const tupleType = getABITupleTypeFromABIStructDefinition(structs[type]);
110
+ const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs);
94
111
  if (Array.isArray(value)) {
95
112
  tupleType.encode(value);
96
113
  }
97
114
  else {
98
- return tupleType.encode(getABITupleFromABIStruct(value, structs[type]));
115
+ return tupleType.encode(getABITupleFromABIStruct(value, structs[type], structs));
99
116
  }
100
117
  }
101
118
  return algosdk.ABIType.from(type).encode(value);
@@ -144,10 +161,14 @@ function getArc56ReturnValue(returnValue, method, structs) {
144
161
  }
145
162
  if (type === undefined || type === 'void' || returnValue?.returnValue === undefined)
146
163
  return undefined;
147
- if (type === 'bytes')
164
+ if (type === 'AVMBytes')
148
165
  return returnValue.rawReturnValue;
166
+ if (type === 'AVMString')
167
+ return Buffer.from(returnValue.rawReturnValue).toString('utf-8');
168
+ if (type === 'AVMUint64')
169
+ return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue);
149
170
  if (structs[type]) {
150
- return getABIStructFromABITuple(returnValue.returnValue, structs[type]);
171
+ return getABIStructFromABITuple(returnValue.returnValue, structs[type], structs);
151
172
  }
152
173
  return returnValue.returnValue;
153
174
  }
@@ -1 +1 @@
1
- {"version":3,"file":"app-arc56.js","sources":["../../src/types/app-arc56.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;AAEG;AACU,MAAA,WAAY,SAAQ,OAAO,CAAC,SAAS,CAAA;AAchD,IAAA,WAAA,CAAmB,MAAc,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAA;QADI,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;AA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C,MAAM,GAAG,MAAM,CAAA;AACrD,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA;AAC/C,IAAA,IAAI,WAAW,EAAE,WAAW,EAAE;QAC5B,MAAM,WAAW,CAAC,WAAW,CAAA;KAC9B;AACD,IAAA,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,SAAoB,CAAA;IAEhH,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,WAAW,CAAC,cAAyB,CAAA;AAElE,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,OAAO,wBAAwB,CAAC,WAAW,CAAC,WAAiC,EAAE,OAAO,CAAC,IAAI,CAAiB,CAAY,CAAA;KACzH;IAED,OAAO,WAAW,CAAC,WAAsB,CAAA;AAC3C;;;;;;;;;;;"}
1
+ {"version":3,"file":"app-arc56.js","sources":["../../src/types/app-arc56.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { ABIReturn } from './app'\nimport { Expand } from './expand'\n\n/** Type to describe an argument within an `Arc56Method`. */\nexport type Arc56MethodArg = Expand<\n Omit<Method['args'][number], 'type'> & {\n type: algosdk.ABIArgumentType\n }\n>\n\n/** Type to describe a return type within an `Arc56Method`. */\nexport type Arc56MethodReturnType = Expand<\n Omit<Method['returns'], 'type'> & {\n type: algosdk.ABIReturnType\n }\n>\n\n/**\n * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.\n */\nexport class Arc56Method extends algosdk.ABIMethod {\n override readonly args: Array<Arc56MethodArg>\n override readonly returns: Arc56MethodReturnType\n\n constructor(public method: Method) {\n super(method)\n this.args = method.args.map((arg) => ({\n ...arg,\n type: algosdk.abiTypeIsTransaction(arg.type) || algosdk.abiTypeIsReference(arg.type) ? arg.type : algosdk.ABIType.from(arg.type),\n }))\n this.returns = {\n ...this.method.returns,\n type: this.method.returns.type === 'void' ? 'void' : algosdk.ABIType.from(this.method.returns.type),\n }\n }\n\n override toJSON(): Method {\n return this.method\n }\n}\n\n/**\n * Returns the `ABITupleType` for the given ARC-56 struct definition\n * @param struct The ARC-56 struct definition\n * @returns The `ABITupleType`\n */\nexport function getABITupleTypeFromABIStructDefinition(\n struct: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABITupleType {\n return new algosdk.ABITupleType(\n struct.map((v) =>\n typeof v.type === 'string'\n ? structs[v.type]\n ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)\n : algosdk.ABIType.from(v.type)\n : getABITupleTypeFromABIStructDefinition(v.type, structs),\n ),\n )\n}\n\n/**\n * Converts a decoded ABI tuple as a struct.\n * @param decodedABITuple The decoded ABI tuple value\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a Record<string, any>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(\n decodedABITuple: algosdk.ABIValue[],\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): TReturn {\n return Object.fromEntries(\n structFields.map(({ name: key, type }, i) => {\n const abiValue = decodedABITuple[i]\n return [\n key,\n (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)\n ? decodedABITuple[i]\n : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),\n ]\n }),\n ) as TReturn\n}\n\n/**\n * Converts an ARC-56 struct as an ABI tuple.\n * @param struct The struct to convert\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a decoded ABI tuple\n */\nexport function getABITupleFromABIStruct(\n struct: ABIStruct,\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue[] {\n return structFields.map(({ name: key, type }) => {\n const value = struct[key]\n return typeof type === 'string' && !structs[type]\n ? (value as algosdk.ABIValue)\n : getABITupleFromABIStruct(value as ABIStruct, typeof type === 'string' ? structs[type] : type, structs)\n })\n}\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | algosdk.ABIValue\n}\n\n/**\n * Returns the decoded ABI value (or struct for a struct type)\n * for the given raw Algorand value given an ARC-56 type and defined ARC-56 structs.\n * @param value The raw Algorand value (bytes or uint64)\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The decoded ABI value or struct\n */\nexport function getABIDecodedValue(\n value: Uint8Array | number | bigint,\n type: string,\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue | ABIStruct {\n if (type === 'AVMBytes' || typeof value !== 'object') return value\n if (type === 'AVMString') return Buffer.from(value).toString('utf-8')\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(value)\n if (structs[type]) {\n const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value)\n return getABIStructFromABITuple(tupleValue, structs[type], structs)\n }\n return algosdk.ABIType.from(type).decode(value)\n}\n\n/**\n * Returns the ABI-encoded value for the given value.\n * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The binary ABI-encoded value\n */\nexport function getABIEncodedValue(\n value: Uint8Array | algosdk.ABIValue | ABIStruct,\n type: string,\n structs: Record<string, StructField[]>,\n): Uint8Array {\n if (typeof value === 'object' && value instanceof Uint8Array) return value\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').encode(value as bigint | number)\n if (type === 'AVMBytes' || type === 'AVMString') {\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array)) throw new Error(`Expected bytes value for ${type}, but got ${value}`)\n return value\n }\n if (structs[type]) {\n const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs)\n if (Array.isArray(value)) {\n tupleType.encode(value as algosdk.ABIValue[])\n } else {\n return tupleType.encode(getABITupleFromABIStruct(value as ABIStruct, structs[type], structs))\n }\n }\n return algosdk.ABIType.from(type).encode(value as algosdk.ABIValue)\n}\n\n/**\n * Returns the ARC-56 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 `Arc56Method`\n */\nexport function getArc56Method(methodNameOrSignature: string, appSpec: Arc56Contract): Arc56Method {\n let method: Method\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) => new algosdk.ABIMethod(m).getSignature())\n .join(', ')}`,\n )\n }\n method = methods[0]\n } else {\n const m = appSpec.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodNameOrSignature)\n if (!m) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n method = m\n }\n return new Arc56Method(method)\n}\n\n/**\n * Checks for decode errors on the AppCallTransactionResult and maps the return value to the specified generic type\n *\n * @param returnValue The smart contract response\n * @param method The method that was called\n * @param structs The struct fields from the app spec\n * @returns The smart contract response with an updated return value\n */\nexport function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(\n returnValue: ABIReturn | undefined,\n method: Method | Arc56Method,\n structs: Record<string, StructField[]>,\n): TReturn {\n const m = 'method' in method ? method.method : method\n const type = m.returns.struct ?? m.returns.type\n if (returnValue?.decodeError) {\n throw returnValue.decodeError\n }\n if (type === undefined || type === 'void' || returnValue?.returnValue === undefined) return undefined as TReturn\n\n if (type === 'AVMBytes') return returnValue.rawReturnValue as TReturn\n if (type === 'AVMString') return Buffer.from(returnValue.rawReturnValue).toString('utf-8') as TReturn\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue) as TReturn\n\n if (structs[type]) {\n return getABIStructFromABITuple(returnValue.returnValue as algosdk.ABIValue[], structs[type], structs) as TReturn\n }\n\n return returnValue.returnValue as TReturn\n}\n\n/****************/\n/** ARC-56 spec */\n/****************/\n\n/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Arc56Contract {\n /** The ARCs used and/or supported by this contract. All contracts implicity support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the interface */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be define\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: SourceInfo[]\n /** Clear program information */\n clear: SourceInfo[]\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the teal (not including TMPL_ prefix) to their respecive types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABIType | AVMType | StructName\n /** If given, the the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABIType | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Method {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes or uint64 */\n data: string | number\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type: ABIType | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n */\n source: 'box' | 'global' | 'local' | 'literal'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport interface Event {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABIType = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport interface StructField {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport interface StorageKey {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABIType | AVMType | StructName\n\n /** The type of the value */\n valueType: ABIType | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport interface StorageMap {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABIType | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABIType | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\nexport interface SourceInfo {\n /** The line of pre-compiled TEAL */\n teal?: number\n /** The program counter offset(s) that correspond to this line of TEAL */\n pc?: Array<number>\n /** A human-readable string that describes the error when the program fails at this given line of TEAL */\n errorMessage?: string\n /** The line of the dissasembled TEAL this line of pre-compiled TEAL corresponds to */\n disassembledTeal?: number\n}\n"],"names":[],"mappings":";;;;AAkBA;;AAEG;AACU,MAAA,WAAY,SAAQ,OAAO,CAAC,SAAS,CAAA;AAIhD,IAAA,WAAA,CAAmB,MAAc,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAA;QADI,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;AAE/B,QAAA,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACpC,YAAA,GAAG,GAAG;AACN,YAAA,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,kBAAkB,CAAC,G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AAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAY,CAAA;AAE7G,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;AACjB,QAAA,OAAO,wBAAwB,CAAC,WAAW,CAAC,WAAiC,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAY,CAAA;KAClH;IAED,OAAO,WAAW,CAAC,WAAsB,CAAA;AAC3C;;;;;;;;;;;"}
@@ -25,8 +25,12 @@ class Arc56Method extends algosdk.ABIMethod {
25
25
  * @param struct The ARC-56 struct definition
26
26
  * @returns The `ABITupleType`
27
27
  */
28
- function getABITupleTypeFromABIStructDefinition(struct) {
29
- return new algosdk.ABITupleType(Object.values(struct).map((v) => (typeof v === 'string' ? algosdk.ABIType.from(v) : getABITupleTypeFromABIStructDefinition(v))));
28
+ function getABITupleTypeFromABIStructDefinition(struct, structs) {
29
+ return new algosdk.ABITupleType(struct.map((v) => typeof v.type === 'string'
30
+ ? structs[v.type]
31
+ ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)
32
+ : algosdk.ABIType.from(v.type)
33
+ : getABITupleTypeFromABIStructDefinition(v.type, structs)));
30
34
  }
31
35
  /**
32
36
  * Converts a decoded ABI tuple as a struct.
@@ -35,10 +39,15 @@ function getABITupleTypeFromABIStructDefinition(struct) {
35
39
  * @returns The struct as a Record<string, any>
36
40
  */
37
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- function getABIStructFromABITuple(decodedABITuple, structFields) {
39
- return Object.fromEntries(Object.entries(structFields).map(([key, type], i) => {
42
+ function getABIStructFromABITuple(decodedABITuple, structFields, structs) {
43
+ return Object.fromEntries(structFields.map(({ name: key, type }, i) => {
40
44
  const abiValue = decodedABITuple[i];
41
- return [key, typeof type === 'string' || !Array.isArray(abiValue) ? decodedABITuple[i] : getABIStructFromABITuple(abiValue, type)];
45
+ return [
46
+ key,
47
+ (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)
48
+ ? decodedABITuple[i]
49
+ : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),
50
+ ];
42
51
  }));
43
52
  }
44
53
  /**
@@ -47,10 +56,12 @@ function getABIStructFromABITuple(decodedABITuple, structFields) {
47
56
  * @param structFields The struct fields from an ARC-56 app spec
48
57
  * @returns The struct as a decoded ABI tuple
49
58
  */
50
- function getABITupleFromABIStruct(struct, structFields) {
51
- return Object.entries(structFields).map(([key, type]) => {
59
+ function getABITupleFromABIStruct(struct, structFields, structs) {
60
+ return structFields.map(({ name: key, type }) => {
52
61
  const value = struct[key];
53
- return typeof type === 'string' ? value : getABITupleFromABIStruct(value, type);
62
+ return typeof type === 'string' && !structs[type]
63
+ ? value
64
+ : getABITupleFromABIStruct(value, typeof type === 'string' ? structs[type] : type, structs);
54
65
  });
55
66
  }
56
67
  /**
@@ -62,11 +73,15 @@ function getABITupleFromABIStruct(struct, structFields) {
62
73
  * @returns The decoded ABI value or struct
63
74
  */
64
75
  function getABIDecodedValue(value, type, structs) {
65
- if (type === 'bytes' || typeof value !== 'object')
76
+ if (type === 'AVMBytes' || typeof value !== 'object')
66
77
  return value;
78
+ if (type === 'AVMString')
79
+ return Buffer.from(value).toString('utf-8');
80
+ if (type === 'AVMUint64')
81
+ return algosdk.ABIType.from('uint64').decode(value);
67
82
  if (structs[type]) {
68
- const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type]).decode(value);
69
- return getABIStructFromABITuple(tupleValue, structs[type]);
83
+ const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value);
84
+ return getABIStructFromABITuple(tupleValue, structs[type], structs);
70
85
  }
71
86
  return algosdk.ABIType.from(type).decode(value);
72
87
  }
@@ -80,7 +95,9 @@ function getABIDecodedValue(value, type, structs) {
80
95
  function getABIEncodedValue(value, type, structs) {
81
96
  if (typeof value === 'object' && value instanceof Uint8Array)
82
97
  return value;
83
- if (type === 'bytes') {
98
+ if (type === 'AVMUint64')
99
+ return algosdk.ABIType.from('uint64').encode(value);
100
+ if (type === 'AVMBytes' || type === 'AVMString') {
84
101
  if (typeof value === 'string')
85
102
  return Buffer.from(value, 'utf-8');
86
103
  if (typeof value !== 'object' || !(value instanceof Uint8Array))
@@ -88,12 +105,12 @@ function getABIEncodedValue(value, type, structs) {
88
105
  return value;
89
106
  }
90
107
  if (structs[type]) {
91
- const tupleType = getABITupleTypeFromABIStructDefinition(structs[type]);
108
+ const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs);
92
109
  if (Array.isArray(value)) {
93
110
  tupleType.encode(value);
94
111
  }
95
112
  else {
96
- return tupleType.encode(getABITupleFromABIStruct(value, structs[type]));
113
+ return tupleType.encode(getABITupleFromABIStruct(value, structs[type], structs));
97
114
  }
98
115
  }
99
116
  return algosdk.ABIType.from(type).encode(value);
@@ -142,10 +159,14 @@ function getArc56ReturnValue(returnValue, method, structs) {
142
159
  }
143
160
  if (type === undefined || type === 'void' || returnValue?.returnValue === undefined)
144
161
  return undefined;
145
- if (type === 'bytes')
162
+ if (type === 'AVMBytes')
146
163
  return returnValue.rawReturnValue;
164
+ if (type === 'AVMString')
165
+ return Buffer.from(returnValue.rawReturnValue).toString('utf-8');
166
+ if (type === 'AVMUint64')
167
+ return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue);
147
168
  if (structs[type]) {
148
- return getABIStructFromABITuple(returnValue.returnValue, structs[type]);
169
+ return getABIStructFromABITuple(returnValue.returnValue, structs[type], structs);
149
170
  }
150
171
  return returnValue.returnValue;
151
172
  }
@@ -1 +1 @@
1
- {"version":3,"file":"app-arc56.mjs","sources":["../../src/types/app-arc56.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;AAEG;AACU,MAAA,WAAY,SAAQ,OAAO,CAAC,SAAS,CAAA;AAchD,IAAA,WAAA,CAAmB,MAAc,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAA;QADI,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;AAE/B,QAA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GAAG,MAAM,CAAA;AACrD,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA;AAC/C,IAAA,IAAI,WAAW,EAAE,WAAW,EAAE;QAC5B,MAAM,WAAW,CAAC,WAAW,CAAA;KAC9B;AACD,IAAA,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,SAAoB,CAAA;IAEhH,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,WAAW,CAAC,cAAyB,CAAA;AAElE,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,OAAO,wBAAwB,CAAC,WAAW,CAAC,WAAiC,EAAE,OAAO,CAAC,IAAI,CAAiB,CAAY,CAAA;KACzH;IAED,OAAO,WAAW,CAAC,WAAsB,CAAA;AAC3C;;;;"}
1
+ {"version":3,"file":"app-arc56.mjs","sources":["../../src/types/app-arc56.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { ABIReturn } from './app'\nimport { Expand } from './expand'\n\n/** Type to describe an argument within an `Arc56Method`. */\nexport type Arc56MethodArg = Expand<\n Omit<Method['args'][number], 'type'> & {\n type: algosdk.ABIArgumentType\n }\n>\n\n/** Type to describe a return type within an `Arc56Method`. */\nexport type Arc56MethodReturnType = Expand<\n Omit<Method['returns'], 'type'> & {\n type: algosdk.ABIReturnType\n }\n>\n\n/**\n * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.\n */\nexport class Arc56Method extends algosdk.ABIMethod {\n override readonly args: Array<Arc56MethodArg>\n override readonly returns: Arc56MethodReturnType\n\n constructor(public method: Method) {\n super(method)\n this.args = method.args.map((arg) => ({\n ...arg,\n type: algosdk.abiTypeIsTransaction(arg.type) || algosdk.abiTypeIsReference(arg.type) ? arg.type : algosdk.ABIType.from(arg.type),\n }))\n this.returns = {\n ...this.method.returns,\n type: this.method.returns.type === 'void' ? 'void' : algosdk.ABIType.from(this.method.returns.type),\n }\n }\n\n override toJSON(): Method {\n return this.method\n }\n}\n\n/**\n * Returns the `ABITupleType` for the given ARC-56 struct definition\n * @param struct The ARC-56 struct definition\n * @returns The `ABITupleType`\n */\nexport function getABITupleTypeFromABIStructDefinition(\n struct: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABITupleType {\n return new algosdk.ABITupleType(\n struct.map((v) =>\n typeof v.type === 'string'\n ? structs[v.type]\n ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)\n : algosdk.ABIType.from(v.type)\n : getABITupleTypeFromABIStructDefinition(v.type, structs),\n ),\n )\n}\n\n/**\n * Converts a decoded ABI tuple as a struct.\n * @param decodedABITuple The decoded ABI tuple value\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a Record<string, any>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(\n decodedABITuple: algosdk.ABIValue[],\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): TReturn {\n return Object.fromEntries(\n structFields.map(({ name: key, type }, i) => {\n const abiValue = decodedABITuple[i]\n return [\n key,\n (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)\n ? decodedABITuple[i]\n : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),\n ]\n }),\n ) as TReturn\n}\n\n/**\n * Converts an ARC-56 struct as an ABI tuple.\n * @param struct The struct to convert\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a decoded ABI tuple\n */\nexport function getABITupleFromABIStruct(\n struct: ABIStruct,\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue[] {\n return structFields.map(({ name: key, type }) => {\n const value = struct[key]\n return typeof type === 'string' && !structs[type]\n ? (value as algosdk.ABIValue)\n : getABITupleFromABIStruct(value as ABIStruct, typeof type === 'string' ? structs[type] : type, structs)\n })\n}\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | algosdk.ABIValue\n}\n\n/**\n * Returns the decoded ABI value (or struct for a struct type)\n * for the given raw Algorand value given an ARC-56 type and defined ARC-56 structs.\n * @param value The raw Algorand value (bytes or uint64)\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The decoded ABI value or struct\n */\nexport function getABIDecodedValue(\n value: Uint8Array | number | bigint,\n type: string,\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue | ABIStruct {\n if (type === 'AVMBytes' || typeof value !== 'object') return value\n if (type === 'AVMString') return Buffer.from(value).toString('utf-8')\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(value)\n if (structs[type]) {\n const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value)\n return getABIStructFromABITuple(tupleValue, structs[type], structs)\n }\n return algosdk.ABIType.from(type).decode(value)\n}\n\n/**\n * Returns the ABI-encoded value for the given value.\n * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The binary ABI-encoded value\n */\nexport function getABIEncodedValue(\n value: Uint8Array | algosdk.ABIValue | ABIStruct,\n type: string,\n structs: Record<string, StructField[]>,\n): Uint8Array {\n if (typeof value === 'object' && value instanceof Uint8Array) return value\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').encode(value as bigint | number)\n if (type === 'AVMBytes' || type === 'AVMString') {\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array)) throw new Error(`Expected bytes value for ${type}, but got ${value}`)\n return value\n }\n if (structs[type]) {\n const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs)\n if (Array.isArray(value)) {\n tupleType.encode(value as algosdk.ABIValue[])\n } else {\n return tupleType.encode(getABITupleFromABIStruct(value as ABIStruct, structs[type], structs))\n }\n }\n return algosdk.ABIType.from(type).encode(value as algosdk.ABIValue)\n}\n\n/**\n * Returns the ARC-56 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 `Arc56Method`\n */\nexport function getArc56Method(methodNameOrSignature: string, appSpec: Arc56Contract): Arc56Method {\n let method: Method\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) => new algosdk.ABIMethod(m).getSignature())\n .join(', ')}`,\n )\n }\n method = methods[0]\n } else {\n const m = appSpec.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodNameOrSignature)\n if (!m) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n method = m\n }\n return new Arc56Method(method)\n}\n\n/**\n * Checks for decode errors on the AppCallTransactionResult and maps the return value to the specified generic type\n *\n * @param returnValue The smart contract response\n * @param method The method that was called\n * @param structs The struct fields from the app spec\n * @returns The smart contract response with an updated return value\n */\nexport function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(\n returnValue: ABIReturn | undefined,\n method: Method | Arc56Method,\n structs: Record<string, StructField[]>,\n): TReturn {\n const m = 'method' in method ? method.method : method\n const type = m.returns.struct ?? m.returns.type\n if (returnValue?.decodeError) {\n throw returnValue.decodeError\n }\n if (type === undefined || type === 'void' || returnValue?.returnValue === undefined) return undefined as TReturn\n\n if (type === 'AVMBytes') return returnValue.rawReturnValue as TReturn\n if (type === 'AVMString') return Buffer.from(returnValue.rawReturnValue).toString('utf-8') as TReturn\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue) as TReturn\n\n if (structs[type]) {\n return getABIStructFromABITuple(returnValue.returnValue as algosdk.ABIValue[], structs[type], structs) as TReturn\n }\n\n return returnValue.returnValue as TReturn\n}\n\n/****************/\n/** ARC-56 spec */\n/****************/\n\n/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Arc56Contract {\n /** The ARCs used and/or supported by this contract. All contracts implicity support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the interface */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be define\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: SourceInfo[]\n /** Clear program information */\n clear: SourceInfo[]\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the teal (not including TMPL_ prefix) to their respecive types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABIType | AVMType | StructName\n /** If given, the the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABIType | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Method {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes or uint64 */\n data: string | number\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type: ABIType | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n */\n source: 'box' | 'global' | 'local' | 'literal'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport interface Event {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABIType = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport interface StructField {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport interface StorageKey {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABIType | AVMType | StructName\n\n /** The type of the value */\n valueType: ABIType | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport interface StorageMap {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABIType | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABIType | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\nexport interface SourceInfo {\n /** The line of pre-compiled TEAL */\n teal?: number\n /** The program counter offset(s) that correspond to this line of TEAL */\n pc?: Array<number>\n /** A human-readable string that describes the error when the program fails at this given line of TEAL */\n errorMessage?: string\n /** The line of the dissasembled TEAL this line of pre-compiled TEAL corresponds to */\n disassembledTeal?: number\n}\n"],"names":[],"mappings":";;AAkBA;;AAEG;AACU,MAAA,WAAY,SAAQ,OAAO,CAAC,SAAS,CAAA;AAIhD,IAAA,WAAA,CAAmB,MAAc,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAA;QADI,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;AAE/B,QAAA,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACpC,YAAA,GAAG,GAAG;AACN,YAAA,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,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