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

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 (385) hide show
  1. package/_virtual/rolldown_runtime.js +10 -15
  2. package/algo25/index.d.ts +2 -0
  3. package/algo25/index.js +9 -0
  4. package/algo25/index.mjs +3 -0
  5. package/algod-client/index.d.ts +3 -7
  6. package/algod-client/index.js +2 -5
  7. package/algod-client/index.mjs +2 -2
  8. package/index.d.ts +1 -2
  9. package/index.js +0 -7
  10. package/index.mjs +1 -2
  11. package/indexer-client/index.d.ts +2 -2
  12. package/indexer-client/index.js +6 -6
  13. package/indexer-client/index.mjs +2 -2
  14. package/{indexer-lookup.d.ts → indexer-client/indexer-lookup.d.ts} +8 -11
  15. package/{indexer-lookup.mjs → indexer-client/indexer-lookup.js} +6 -10
  16. package/indexer-client/indexer-lookup.js.map +1 -0
  17. package/{indexer-lookup.js → indexer-client/indexer-lookup.mjs} +3 -18
  18. package/indexer-client/indexer-lookup.mjs.map +1 -0
  19. package/kmd-client/index.d.ts +1 -2
  20. package/kmd-client/index.js +0 -5
  21. package/kmd-client/index.mjs +1 -2
  22. package/package.json +1 -1
  23. package/packages/abi/src/abi-method.d.ts +1 -1
  24. package/packages/abi/src/abi-method.js +1 -1
  25. package/packages/abi/src/abi-method.js.map +1 -1
  26. package/packages/abi/src/abi-method.mjs +1 -1
  27. package/packages/abi/src/abi-method.mjs.map +1 -1
  28. package/packages/abi/src/abi-type.d.ts +1 -1
  29. package/packages/abi/src/abi-type.js +4 -2
  30. package/packages/abi/src/abi-type.js.map +1 -1
  31. package/packages/abi/src/abi-type.mjs +4 -2
  32. package/packages/abi/src/abi-type.mjs.map +1 -1
  33. package/packages/abi/src/arc56-contract.js +1 -0
  34. package/packages/abi/src/arc56-contract.js.map +1 -1
  35. package/packages/abi/src/arc56-contract.mjs +1 -0
  36. package/packages/abi/src/arc56-contract.mjs.map +1 -1
  37. package/packages/algo25/src/index.d.ts +40 -0
  38. package/packages/algo25/src/index.js +44 -0
  39. package/packages/algo25/src/index.js.map +1 -1
  40. package/packages/algo25/src/index.mjs +39 -1
  41. package/packages/algo25/src/index.mjs.map +1 -1
  42. package/packages/algod_client/src/apis/api-service.d.ts +44 -44
  43. package/packages/algod_client/src/apis/api-service.js +155 -155
  44. package/packages/algod_client/src/apis/api-service.js.map +1 -1
  45. package/packages/algod_client/src/apis/api-service.mjs +155 -155
  46. package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
  47. package/packages/algod_client/src/core/api-error.js +3 -1
  48. package/packages/algod_client/src/core/api-error.js.map +1 -1
  49. package/packages/algod_client/src/core/api-error.mjs +3 -1
  50. package/packages/algod_client/src/core/api-error.mjs.map +1 -1
  51. package/packages/algod_client/src/core/model-runtime.js +6 -6
  52. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  53. package/packages/algod_client/src/core/model-runtime.mjs +8 -8
  54. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  55. package/packages/algod_client/src/models/account-participation.js +4 -4
  56. package/packages/algod_client/src/models/account-participation.js.map +1 -1
  57. package/packages/algod_client/src/models/account-participation.mjs +4 -4
  58. package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
  59. package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
  60. package/packages/algod_client/src/models/application-state-schema.js +2 -2
  61. package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
  62. package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
  63. package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
  64. package/packages/algod_client/src/models/asset-params.js +2 -1
  65. package/packages/algod_client/src/models/asset-params.js.map +1 -1
  66. package/packages/algod_client/src/models/asset-params.mjs +2 -1
  67. package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
  68. package/packages/algod_client/src/models/block-response.js +1 -2
  69. package/packages/algod_client/src/models/block-response.js.map +1 -1
  70. package/packages/algod_client/src/models/block-response.mjs +2 -3
  71. package/packages/algod_client/src/models/block-response.mjs.map +1 -1
  72. package/packages/algod_client/src/models/block.d.ts +60 -40
  73. package/packages/algod_client/src/models/block.js +184 -108
  74. package/packages/algod_client/src/models/block.js.map +1 -1
  75. package/packages/algod_client/src/models/block.mjs +184 -108
  76. package/packages/algod_client/src/models/block.mjs.map +1 -1
  77. package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
  78. package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
  79. package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
  80. package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
  81. package/packages/algod_client/src/models/simulate-request.js +1 -1
  82. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  83. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  84. package/packages/algod_client/src/models/simulate-response.js +6 -1
  85. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  86. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  87. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  88. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
  89. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
  90. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
  91. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
  92. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
  93. package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
  94. package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
  95. package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
  96. package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
  97. package/packages/common/src/address.js +0 -14
  98. package/packages/common/src/address.js.map +1 -1
  99. package/packages/common/src/address.mjs +1 -14
  100. package/packages/common/src/address.mjs.map +1 -1
  101. package/packages/common/src/codecs/composite/map.js +7 -4
  102. package/packages/common/src/codecs/composite/map.js.map +1 -1
  103. package/packages/common/src/codecs/composite/map.mjs +7 -4
  104. package/packages/common/src/codecs/composite/map.mjs.map +1 -1
  105. package/packages/common/src/codecs/composite/record.js +0 -1
  106. package/packages/common/src/codecs/composite/record.js.map +1 -1
  107. package/packages/common/src/codecs/primitives/address.js +0 -1
  108. package/packages/common/src/codecs/primitives/address.js.map +1 -1
  109. package/packages/common/src/codecs/primitives/bytes.js +0 -1
  110. package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
  111. package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
  112. package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
  113. package/packages/common/src/codecs/wire.js +0 -1
  114. package/packages/common/src/codecs/wire.js.map +1 -1
  115. package/packages/common/src/msgpack.js +0 -1
  116. package/packages/common/src/msgpack.js.map +1 -1
  117. package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
  118. package/packages/indexer_client/src/apis/api-service.js +12 -12
  119. package/packages/indexer_client/src/apis/api-service.js.map +1 -1
  120. package/packages/indexer_client/src/apis/api-service.mjs +12 -12
  121. package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
  122. package/packages/indexer_client/src/core/api-error.js +3 -1
  123. package/packages/indexer_client/src/core/api-error.js.map +1 -1
  124. package/packages/indexer_client/src/core/api-error.mjs +3 -1
  125. package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
  126. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  127. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  128. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  129. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  130. package/packages/indexer_client/src/models/account-participation.js +4 -4
  131. package/packages/indexer_client/src/models/account-participation.js.map +1 -1
  132. package/packages/indexer_client/src/models/account-participation.mjs +4 -4
  133. package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
  134. package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
  135. package/packages/indexer_client/src/models/application-state-schema.js +2 -2
  136. package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
  137. package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
  138. package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
  139. package/packages/indexer_client/src/models/asset-params.js +2 -1
  140. package/packages/indexer_client/src/models/asset-params.js.map +1 -1
  141. package/packages/indexer_client/src/models/asset-params.mjs +2 -1
  142. package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
  143. package/packages/indexer_client/src/models/block.d.ts +5 -5
  144. package/packages/indexer_client/src/models/block.js +13 -13
  145. package/packages/indexer_client/src/models/block.js.map +1 -1
  146. package/packages/indexer_client/src/models/block.mjs +13 -13
  147. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  148. package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
  149. package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
  150. package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
  151. package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
  152. package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
  153. package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
  154. package/packages/indexer_client/src/models/eval-delta.js +2 -2
  155. package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
  156. package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
  157. package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
  158. package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
  159. package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
  160. package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
  161. package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
  162. package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
  163. package/packages/indexer_client/src/models/participation-updates.js +2 -2
  164. package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
  165. package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
  166. package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
  167. package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
  168. package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
  169. package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
  170. package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
  171. package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
  172. package/packages/indexer_client/src/models/state-schema.js +2 -2
  173. package/packages/indexer_client/src/models/state-schema.js.map +1 -1
  174. package/packages/indexer_client/src/models/state-schema.mjs +2 -2
  175. package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
  176. package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
  177. package/packages/indexer_client/src/models/teal-key-value.js +2 -2
  178. package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
  179. package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
  180. package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
  181. package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
  182. package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
  183. package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
  184. package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
  185. package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
  186. package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
  187. package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
  188. package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
  189. package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
  190. package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
  191. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
  192. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
  193. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
  194. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
  195. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
  196. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
  197. package/packages/indexer_client/src/models/transaction.d.ts +2 -2
  198. package/packages/indexer_client/src/models/transaction.js +6 -5
  199. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  200. package/packages/indexer_client/src/models/transaction.mjs +6 -5
  201. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  202. package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
  203. package/packages/kmd_client/src/apis/api-service.js +32 -32
  204. package/packages/kmd_client/src/apis/api-service.js.map +1 -1
  205. package/packages/kmd_client/src/apis/api-service.mjs +32 -32
  206. package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
  207. package/packages/kmd_client/src/core/api-error.js +3 -1
  208. package/packages/kmd_client/src/core/api-error.js.map +1 -1
  209. package/packages/kmd_client/src/core/api-error.mjs +3 -1
  210. package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
  211. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  212. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  213. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  214. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  215. package/packages/sdk/src/encoding/encoding.js +12 -2
  216. package/packages/sdk/src/encoding/encoding.js.map +1 -1
  217. package/packages/sdk/src/encoding/encoding.mjs +12 -1
  218. package/packages/sdk/src/encoding/encoding.mjs.map +1 -1
  219. package/packages/sdk/src/encoding/schema/map.js +0 -2
  220. package/packages/sdk/src/encoding/schema/map.js.map +1 -1
  221. package/packages/transact/src/logicsig.d.ts +3 -15
  222. package/packages/transact/src/logicsig.js +16 -36
  223. package/packages/transact/src/logicsig.js.map +1 -1
  224. package/packages/transact/src/logicsig.mjs +18 -36
  225. package/packages/transact/src/logicsig.mjs.map +1 -1
  226. package/packages/transact/src/multisig.d.ts +7 -115
  227. package/packages/transact/src/multisig.js +86 -136
  228. package/packages/transact/src/multisig.js.map +1 -1
  229. package/packages/transact/src/multisig.mjs +87 -117
  230. package/packages/transact/src/multisig.mjs.map +1 -1
  231. package/packages/transact/src/transactions/app-call.d.ts +10 -15
  232. package/packages/transact/src/transactions/app-call.js.map +1 -1
  233. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  234. package/packages/transact/src/transactions/asset-config.d.ts +1 -6
  235. package/packages/transact/src/transactions/asset-config.js.map +1 -1
  236. package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
  237. package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
  238. package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
  239. package/packages/transact/src/transactions/key-registration.d.ts +1 -8
  240. package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
  241. package/packages/transact/src/transactions/reference-types-meta.js +71 -0
  242. package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
  243. package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
  244. package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
  245. package/packages/transact/src/transactions/signed-transaction-meta.js +2 -3
  246. package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
  247. package/packages/transact/src/transactions/signed-transaction-meta.mjs +3 -3
  248. package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
  249. package/packages/transact/src/transactions/signed-transaction.d.ts +7 -3
  250. package/packages/transact/src/transactions/signed-transaction.js +1 -1
  251. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  252. package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
  253. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  254. package/packages/transact/src/transactions/transaction-meta.js +29 -23
  255. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  256. package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
  257. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  258. package/packages/transact/src/transactions/transaction.d.ts +5 -1
  259. package/packages/transact/src/transactions/transaction.js +1 -1
  260. package/packages/transact/src/transactions/transaction.js.map +1 -1
  261. package/packages/transact/src/transactions/transaction.mjs +1 -1
  262. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  263. package/sdk/index.js +1 -1
  264. package/testing/account.js +2 -5
  265. package/testing/account.js.map +1 -1
  266. package/testing/account.mjs +2 -5
  267. package/testing/account.mjs.map +1 -1
  268. package/testing/fixtures/algorand-fixture.d.ts +3 -3
  269. package/testing/fixtures/algorand-fixture.js.map +1 -1
  270. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  271. package/transact/index.d.ts +11 -10
  272. package/transact/index.js +7 -32
  273. package/transact/index.mjs +7 -10
  274. package/transaction/transaction.js +2 -2
  275. package/transaction/transaction.js.map +1 -1
  276. package/transaction/transaction.mjs +2 -2
  277. package/transaction/transaction.mjs.map +1 -1
  278. package/transactions/app-call.d.ts +5 -4
  279. package/transactions/app-call.js +15 -15
  280. package/transactions/app-call.js.map +1 -1
  281. package/transactions/app-call.mjs +15 -15
  282. package/transactions/app-call.mjs.map +1 -1
  283. package/transactions/asset-config.d.ts +1 -1
  284. package/transactions/asset-config.js +1 -1
  285. package/transactions/asset-config.js.map +1 -1
  286. package/transactions/asset-config.mjs +1 -1
  287. package/transactions/asset-config.mjs.map +1 -1
  288. package/transactions/key-registration.d.ts +1 -1
  289. package/transactions/key-registration.js.map +1 -1
  290. package/transactions/key-registration.mjs.map +1 -1
  291. package/transactions/method-call.d.ts +1 -1
  292. package/transactions/method-call.js +69 -77
  293. package/transactions/method-call.js.map +1 -1
  294. package/transactions/method-call.mjs +69 -77
  295. package/transactions/method-call.mjs.map +1 -1
  296. package/types/account-manager.d.ts +1 -1
  297. package/types/account-manager.js +3 -3
  298. package/types/account-manager.js.map +1 -1
  299. package/types/account-manager.mjs +3 -3
  300. package/types/account-manager.mjs.map +1 -1
  301. package/types/algorand-client-transaction-creator.d.ts +57 -43
  302. package/types/algorand-client-transaction-creator.js +8 -0
  303. package/types/algorand-client-transaction-creator.js.map +1 -1
  304. package/types/algorand-client-transaction-creator.mjs +8 -0
  305. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  306. package/types/algorand-client-transaction-sender.d.ts +62 -48
  307. package/types/algorand-client-transaction-sender.js +8 -1
  308. package/types/algorand-client-transaction-sender.js.map +1 -1
  309. package/types/algorand-client-transaction-sender.mjs +8 -0
  310. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  311. package/types/app-client.d.ts +110 -105
  312. package/types/app-client.js +0 -1
  313. package/types/app-client.js.map +1 -1
  314. package/types/app-client.mjs.map +1 -1
  315. package/types/app-deployer.d.ts +1 -1
  316. package/types/app-deployer.js +2 -2
  317. package/types/app-deployer.js.map +1 -1
  318. package/types/app-deployer.mjs +2 -2
  319. package/types/app-deployer.mjs.map +1 -1
  320. package/types/app-factory.d.ts +44 -41
  321. package/types/app-factory.js.map +1 -1
  322. package/types/app-factory.mjs.map +1 -1
  323. package/types/app-manager.d.ts +3 -1
  324. package/types/app-manager.js +16 -10
  325. package/types/app-manager.js.map +1 -1
  326. package/types/app-manager.mjs +16 -10
  327. package/types/app-manager.mjs.map +1 -1
  328. package/types/app-spec.js +12 -5
  329. package/types/app-spec.js.map +1 -1
  330. package/types/app-spec.mjs +12 -5
  331. package/types/app-spec.mjs.map +1 -1
  332. package/types/app.d.ts +1 -1
  333. package/types/app.js.map +1 -1
  334. package/types/app.mjs.map +1 -1
  335. package/types/asset-manager.js +1 -1
  336. package/types/asset-manager.js.map +1 -1
  337. package/types/asset-manager.mjs +1 -1
  338. package/types/asset-manager.mjs.map +1 -1
  339. package/types/async-event-emitter.d.ts +3 -6
  340. package/types/async-event-emitter.js.map +1 -1
  341. package/types/async-event-emitter.mjs.map +1 -1
  342. package/types/client-manager.d.ts +1 -1
  343. package/types/client-manager.js.map +1 -1
  344. package/types/client-manager.mjs.map +1 -1
  345. package/types/composer.d.ts +9 -1
  346. package/types/composer.js +35 -23
  347. package/types/composer.js.map +1 -1
  348. package/types/composer.mjs +37 -24
  349. package/types/composer.mjs.map +1 -1
  350. package/types/debugging.d.ts +13 -9
  351. package/types/debugging.js.map +1 -1
  352. package/types/debugging.mjs.map +1 -1
  353. package/types/expand.d.ts +2 -9
  354. package/types/kmd-account-manager.d.ts +1 -0
  355. package/types/kmd-account-manager.js +21 -10
  356. package/types/kmd-account-manager.js.map +1 -1
  357. package/types/kmd-account-manager.mjs +22 -11
  358. package/types/kmd-account-manager.mjs.map +1 -1
  359. package/types/lifecycle-events.d.ts +0 -1
  360. package/types/lifecycle-events.js.map +1 -1
  361. package/types/lifecycle-events.mjs.map +1 -1
  362. package/types/testing.d.ts +2 -2
  363. package/types/transaction.d.ts +1 -1
  364. package/_virtual/rolldown_runtime.mjs +0 -13
  365. package/indexer-lookup.js.map +0 -1
  366. package/indexer-lookup.mjs.map +0 -1
  367. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  368. package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
  369. package/packages/algod_client/src/models/application-local-reference.js +0 -23
  370. package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
  371. package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
  372. package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
  373. package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
  374. package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
  375. package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
  376. package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
  377. package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
  378. package/packages/algod_client/src/models/box-reference.d.ts +0 -17
  379. package/packages/algod_client/src/models/box-reference.js +0 -23
  380. package/packages/algod_client/src/models/box-reference.js.map +0 -1
  381. package/packages/algod_client/src/models/box-reference.mjs +0 -23
  382. package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
  383. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  384. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  385. package/packages/transact/src/transactions/common.d.ts +0 -37
@@ -91,7 +91,7 @@ var AppManager = class AppManager {
91
91
  * @returns The app information
92
92
  */
93
93
  async getById(appId) {
94
- const app = await this._algod.getApplicationById(appId);
94
+ const app = await this._algod.applicationById(appId);
95
95
  const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({
96
96
  key: kv.key,
97
97
  value: kv.value
@@ -102,12 +102,13 @@ var AppManager = class AppManager {
102
102
  approvalProgram: app.params.approvalProgram,
103
103
  clearStateProgram: app.params.clearStateProgram,
104
104
  creator: app.params.creator,
105
- localInts: Number(app.params.localStateSchema?.numUint ?? 0),
106
- localByteSlices: Number(app.params.localStateSchema?.numByteSlice ?? 0),
107
- globalInts: Number(app.params.globalStateSchema?.numUint ?? 0),
108
- globalByteSlices: Number(app.params.globalStateSchema?.numByteSlice ?? 0),
109
- extraProgramPages: Number(app.params.extraProgramPages ?? 0),
110
- globalState: AppManager.decodeAppState(convertedGlobalState)
105
+ localInts: app.params.localStateSchema?.numUints ?? 0,
106
+ localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,
107
+ globalInts: app.params.globalStateSchema?.numUints ?? 0,
108
+ globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,
109
+ extraProgramPages: app.params.extraProgramPages ?? 0,
110
+ globalState: AppManager.decodeAppState(convertedGlobalState),
111
+ version: app.params.version
111
112
  };
112
113
  }
113
114
  /**
@@ -154,7 +155,7 @@ var AppManager = class AppManager {
154
155
  * ```
155
156
  */
156
157
  async getBoxNames(appId) {
157
- return (await this._algod.getApplicationBoxes(appId)).boxes.map((b) => {
158
+ return (await this._algod.applicationBoxes(appId)).boxes.map((b) => {
158
159
  return {
159
160
  nameRaw: b.name,
160
161
  nameBase64: Buffer.from(b.name).toString("base64"),
@@ -175,7 +176,7 @@ var AppManager = class AppManager {
175
176
  async getBoxValue(appId, boxName) {
176
177
  const boxId = typeof boxName === "object" && "nameRaw" in boxName ? boxName.nameRaw : boxName;
177
178
  const name = AppManager.getBoxReference(boxId).name;
178
- return (await this._algod.getApplicationBoxByName(Number(appId), name)).value;
179
+ return (await this._algod.applicationBoxByName(Number(appId), name)).value;
179
180
  }
180
181
  /**
181
182
  * Returns the value of the given box names for the given app.
@@ -297,7 +298,12 @@ var AppManager = class AppManager {
297
298
  * ```
298
299
  */
299
300
  static getABIReturn(confirmation, method) {
300
- if (!method || method.returns.type === "void") return;
301
+ if (!method || !confirmation) return;
302
+ if (method.returns.type === "void") return {
303
+ method,
304
+ rawReturnValue: void 0,
305
+ returnValue: void 0
306
+ };
301
307
  try {
302
308
  const logs = confirmation.logs || [];
303
309
  if (logs.length === 0) throw new Error(`App call transaction did not log a return value`);
@@ -1 +1 @@
1
- {"version":3,"file":"app-manager.mjs","names":["valueBase64: string","valueRaw: Buffer","result: string[]"],"sources":["../../src/types/app-manager.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { AlgodClient, EvalDelta, PendingTransactionResponse, TealValue } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress, getAddress, getApplicationAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, BoxReference as TransactionBoxReference } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport {\n ABI_RETURN_PREFIX,\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `AddressWithSigner` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | AddressWithTransactionSigner\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: AlgodClient\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: AlgodClient) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.tealCompile(tealCode, { sourcemap: true })\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(compiled.sourcemap as { version: number; sources: string[]; names: string[]; mappings: string }),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.getApplicationById(appId)\n const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return {\n appId: BigInt(app.id),\n appAddress: getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: Number(app.params.localStateSchema?.numUint ?? 0),\n localByteSlices: Number(app.params.localStateSchema?.numByteSlice ?? 0),\n globalInts: Number(app.params.globalStateSchema?.numUint ?? 0),\n globalByteSlices: Number(app.params.globalStateSchema?.numByteSlice ?? 0),\n extraProgramPages: Number(app.params.extraProgramPages ?? 0),\n globalState: AppManager.decodeAppState(convertedGlobalState),\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: ReadableAddress) {\n const appInfo = await this._algod.accountApplicationInformation(getAddress(address).toString(), Number(appId))\n\n if (!appInfo.appLocalState) {\n throw new Error(\"Couldn't find local state\")\n }\n\n // If keyValue is undefined or empty, return empty state\n if (!appInfo.appLocalState.keyValue || appInfo.appLocalState.keyValue.length === 0) {\n return {}\n }\n\n const convertedState = appInfo.appLocalState.keyValue.map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return AppManager.decodeAppState(convertedState)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.getApplicationBoxes(appId)\n return boxResult.boxes.map((b: { name: Uint8Array }) => {\n return {\n nameRaw: b.name,\n nameBase64: Buffer.from(b.name).toString('base64'),\n name: Buffer.from(b.name).toString('utf-8'),\n }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name)\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): TransactionBoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appId: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as TransactionBoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: TealValue | EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = Number('action' in tealValue ? tealValue.action : tealValue.type)\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = {\n keyRaw,\n keyBase64,\n value: BigInt(value),\n }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(confirmation: PendingTransactionResponse, method: ABIMethod | undefined): ABIReturn | undefined {\n if (!method || method.returns.type === 'void') {\n return undefined\n }\n\n try {\n const logs = confirmation.logs || []\n if (logs.length === 0) {\n throw new Error(`App call transaction did not log a return value`)\n }\n const lastLog = logs[logs.length - 1]\n if (!AppManager.hasAbiReturnPrefix(lastLog)) {\n throw new Error(`App call transaction did not log an ABI return value`)\n }\n\n const rawReturnValue = new Uint8Array(lastLog.slice(4))\n return {\n method: method,\n rawReturnValue,\n decodeError: undefined,\n returnValue: method.returns.type.decode(rawReturnValue),\n }\n } catch (err) {\n return {\n method: method,\n rawReturnValue: undefined,\n decodeError: err as Error,\n returnValue: undefined,\n }\n }\n }\n\n private static hasAbiReturnPrefix(log: Uint8Array): boolean {\n if (log.length < ABI_RETURN_PREFIX.length) {\n return false\n }\n for (let i = 0; i < ABI_RETURN_PREFIX.length; i++) {\n if (log[i] !== ABI_RETURN_PREFIX[i]) {\n return false\n }\n }\n return true\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"mappings":";;;;;;AAkGA,IAAa,aAAb,MAAa,WAAW;CACtB,AAAQ;CACR,AAAQ,sBAAoD,EAAE;;;;;CAM9D,YAAY,OAAoB;AAC9B,OAAK,SAAS;;;;;;;;;;;;;;;;;CAkB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MAAM,aAAa,mBAAmB,MAAM,OAAO,OAAO,SAAS;AACnE,MAAI,eAAe,OACjB;EAEF,MAAM,gBAAgB,aAAa,MAAM;AACzC,OACG,eAAe,KAAK,CAAC,sBAAsB,KAAK,aAAa,GAAG,MAChE,iBAAiB,KAAK,UAAU,CAAC,sBAAsB,KAAK,eAAe,EAE5E,QAAO;AAET,UAAQ;;;AAKZ,SAAS,sBAAsB,MAAuB;AACpD,QAAO,KAAK,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,SAAS"}
1
+ {"version":3,"file":"app-manager.mjs","names":["valueBase64: string","valueRaw: Buffer","result: string[]"],"sources":["../../src/types/app-manager.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { AlgodClient, EvalDelta, PendingTransactionResponse, TealValue } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress, getAddress, getApplicationAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, BoxReference as TransactionBoxReference } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport {\n ABI_RETURN_PREFIX,\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n /** The number of updates to the application programs */\n version?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `AddressWithSigner` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | AddressWithTransactionSigner\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: AlgodClient\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: AlgodClient) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.tealCompile(tealCode, { sourcemap: true })\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(compiled.sourcemap as { version: number; sources: string[]; names: string[]; mappings: string }),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.applicationById(appId)\n const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({ key: kv.key, value: kv.value }))\n\n return {\n appId: BigInt(app.id),\n appAddress: getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: app.params.localStateSchema?.numUints ?? 0,\n localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,\n globalInts: app.params.globalStateSchema?.numUints ?? 0,\n globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,\n extraProgramPages: app.params.extraProgramPages ?? 0,\n globalState: AppManager.decodeAppState(convertedGlobalState),\n version: app.params.version,\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: ReadableAddress) {\n const appInfo = await this._algod.accountApplicationInformation(getAddress(address).toString(), Number(appId))\n\n if (!appInfo.appLocalState) {\n throw new Error(\"Couldn't find local state\")\n }\n\n // If keyValue is undefined or empty, return empty state\n if (!appInfo.appLocalState.keyValue || appInfo.appLocalState.keyValue.length === 0) {\n return {}\n }\n\n const convertedState = appInfo.appLocalState.keyValue.map((kv) => ({ key: kv.key, value: kv.value }))\n\n return AppManager.decodeAppState(convertedState)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.applicationBoxes(appId)\n return boxResult.boxes.map((b: { name: Uint8Array }) => {\n return { nameRaw: b.name, nameBase64: Buffer.from(b.name).toString('base64'), name: Buffer.from(b.name).toString('utf-8') }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.applicationBoxByName(Number(appId), name)\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): TransactionBoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appId: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as TransactionBoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: TealValue | EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = Number('action' in tealValue ? tealValue.action : tealValue.type)\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = { keyRaw, keyBase64, value: BigInt(value) }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(confirmation: PendingTransactionResponse | undefined, method: ABIMethod | undefined): ABIReturn | undefined {\n if (!method || !confirmation) {\n return undefined\n }\n\n if (method.returns.type === 'void') {\n return { method, rawReturnValue: undefined, returnValue: undefined }\n }\n\n try {\n const logs = confirmation.logs || []\n if (logs.length === 0) {\n throw new Error(`App call transaction did not log a return value`)\n }\n const lastLog = logs[logs.length - 1]\n if (!AppManager.hasAbiReturnPrefix(lastLog)) {\n throw new Error(`App call transaction did not log an ABI return value`)\n }\n\n const rawReturnValue = new Uint8Array(lastLog.slice(4))\n return { method: method, rawReturnValue, decodeError: undefined, returnValue: method.returns.type.decode(rawReturnValue) }\n } catch (err) {\n return { method: method, rawReturnValue: undefined, decodeError: err as Error, returnValue: undefined }\n }\n }\n\n private static hasAbiReturnPrefix(log: Uint8Array): boolean {\n if (log.length < ABI_RETURN_PREFIX.length) {\n return false\n }\n for (let i = 0; i < ABI_RETURN_PREFIX.length; i++) {\n if (log[i] !== ABI_RETURN_PREFIX[i]) {\n return false\n }\n }\n return true\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"mappings":";;;;;;AAoGA,IAAa,aAAb,MAAa,WAAW;CACtB,AAAQ;CACR,AAAQ,sBAAoD,EAAE;;;;;CAM9D,YAAY,OAAoB;AAC9B,OAAK,SAAS;;;;;;;;;;;;;;;;;CAkBhB,MAAM,YAAY,UAAyC;AACzD,MAAI,KAAK,oBAAoB,UAC3B,QAAO,KAAK,oBAAoB;EAGlC,MAAM,WAAW,MAAM,KAAK,OAAO,YAAY,UAAU,EAAE,WAAW,MAAM,CAAC;EAC7E,MAAM,SAAS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C,OACG,eAAe,KAAK,CAAC,sBAAsB,KAAK,aAAa,GAAG,MAChE,iBAAiB,KAAK,UAAU,CAAC,sBAAsB,KAAK,eAAe,EAE5E,QAAO;AAET,UAAQ;;;AAKZ,SAAS,sBAAsB,MAAuB;AACpD,QAAO,KAAK,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,SAAS"}
package/types/app-spec.js CHANGED
@@ -35,16 +35,23 @@ function arc32ToArc56(appSpec) {
35
35
  if (c.update_application && ["ALL", type].includes(c.update_application)) actions$1.push("UpdateApplication");
36
36
  return actions$1;
37
37
  };
38
- const getDefaultArgValue = (type, defaultArg) => {
38
+ const getDefaultArgValue = (defaultArg) => {
39
39
  if (!defaultArg) return void 0;
40
40
  if (defaultArg.source === "abi-method") return {
41
41
  source: "method",
42
42
  data: defaultArg.data.name
43
43
  };
44
+ const mappedSource = defaultArg.source === "constant" ? "literal" : defaultArg.source === "global-state" ? "global" : "local";
45
+ let defaultValueType = void 0;
46
+ if (mappedSource === "literal") {
47
+ if (typeof defaultArg.data === "number") defaultValueType = "uint64";
48
+ else if (typeof defaultArg.data === "string") defaultValueType = "AVMString";
49
+ }
50
+ const argData = typeof defaultArg.data === "number" ? require_abi_type.ABIType.from("uint64").encode(defaultArg.data) : typeof defaultArg.data === "string" ? new TextEncoder().encode(defaultArg.data) : defaultArg.data;
44
51
  return {
45
- source: defaultArg.source === "constant" ? "literal" : defaultArg.source === "global-state" ? "global" : "local",
46
- data: Buffer.from(typeof defaultArg.data === "number" ? require_abi_type.ABIType.from("uint64").encode(defaultArg.data) : defaultArg.data).toString("base64"),
47
- type: type === "string" ? "AVMString" : type
52
+ source: mappedSource,
53
+ data: Buffer.from(argData).toString("base64"),
54
+ type: defaultValueType
48
55
  };
49
56
  };
50
57
  return {
@@ -60,7 +67,7 @@ function arc32ToArc56(appSpec) {
60
67
  type: a.type,
61
68
  desc: a.desc,
62
69
  struct: a.name ? hint(m)?.structs?.[a.name]?.name : void 0,
63
- defaultValue: getDefaultArgValue(a.type, !a.name ? void 0 : hint(m)?.default_arguments?.[a.name])
70
+ defaultValue: getDefaultArgValue(!a.name ? void 0 : hint(m)?.default_arguments?.[a.name])
64
71
  })),
65
72
  returns: {
66
73
  type: m.returns.type,
@@ -1 +1 @@
1
- {"version":3,"file":"app-spec.js","names":["hint","actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]","actions","ABITypeClass"],"sources":["../../src/types/app-spec.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIType as ABITypeClass,\n ARC28Event,\n Arc56Contract,\n Arc56Method,\n StorageKey,\n StructField,\n} from '@algorandfoundation/algokit-abi'\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[getABIMethodParamsSignature(m)] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (\n type: string,\n defaultArg: DefaultArgument | undefined,\n ): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n return {\n source: defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local',\n data: Buffer.from(\n typeof defaultArg.data === 'number' ? ABITypeClass.from('uint64').encode(defaultArg.data) : defaultArg.data,\n ).toString('base64'),\n type: type === 'string' ? 'AVMString' : type,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(a.type, !a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\nfunction getABIMethodParamsSignature(params: ABIMethodParams) {\n const args = params.args.map((a) => a.type).join(',')\n return `${params.name}(${args})${params.returns.type}`\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\ninterface ABIContractParams {\n name: string\n desc?: string\n networks?: ABIContractNetworks\n methods: ABIMethodParams[]\n events?: ARC28Event[]\n}\n\ninterface ABIContractNetworks {\n [network: string]: ABIContractNetworkInfo\n}\n\ninterface ABIContractNetworkInfo {\n appID: number\n}\n\ninterface ABIMethodParams {\n name: string\n desc?: string\n args: ABIMethodArgParams[]\n returns: ABIMethodReturnParams\n /** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */\n readonly?: boolean\n /** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */\n events?: ARC28Event[]\n}\n\ninterface ABIMethodArgParams {\n type: string\n name?: string\n desc?: string\n}\n\ninterface ABIMethodReturnParams {\n type: string\n desc?: string\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethod\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,aAAa,SAAiC;CAC5D,MAAM,eAAe,OAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,WAAS,OAAO,QAAQA,OAAK,WAAW,EAAE,CAAC,CAAC;CACvG,MAAM,UAAU,OAAO,YACrB,aAAa,KAAK,CAAC,GAAG,YAAY;EAChC,MAAM,SAAS,OAAO,SA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QAAQ,OAAO,MAAM,SAAS,CAAC,KAAK,MAAM,CACvD,EAAE,IACF;KACE,KAAK,OAAO,KAAK,EAAE,GAAG,KAAK,QAAQ,CAAC,SAAS,SAAS;KACtD,SAAS;KACT,WAAW,EAAE,GAAG,SAAS,WAAW,cAAc;KAClD,MAAM,EAAE,GAAG;KACZ,CACF,CAAC,CACH;IACD,KAAK,EAAE;IACR;GACD,MAAM;IACJ,QAAQ,EAAE;IACV,OAAO,EAAE;IACT,KAAK,EAAE;IACR;GACF;EACD,QAAQ,QAAQ;EAChB,aAAa;GACX,QAAQ,YAAY,SAAS;GAC7B,MAAM,YAAY,OAAO;GAC1B;EACD,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,kBAAkB;EAClB,YAAY;EACZ,mBAAmB;EACpB;;AAGH,SAAS,4BAA4B,QAAyB;CAC5D,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI;AACrD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,OAAO,QAAQ"}
1
+ {"version":3,"file":"app-spec.js","names":["hint","actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]","actions","defaultValueType: string | undefined","ABITypeClass"],"sources":["../../src/types/app-spec.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIType as ABITypeClass,\n ARC28Event,\n Arc56Contract,\n Arc56Method,\n StorageKey,\n StructField,\n} from '@algorandfoundation/algokit-abi'\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[getABIMethodParamsSignature(m)] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (defaultArg: DefaultArgument | undefined): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n const mappedSource = defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local'\n\n // type is only set for literal source\n let defaultValueType: string | undefined = undefined\n if (mappedSource === 'literal') {\n if (typeof defaultArg.data === 'number') {\n defaultValueType = 'uint64'\n } else if (typeof defaultArg.data === 'string') {\n defaultValueType = 'AVMString'\n }\n }\n\n const argData =\n typeof defaultArg.data === 'number'\n ? ABITypeClass.from('uint64').encode(defaultArg.data)\n : typeof defaultArg.data === 'string'\n ? new TextEncoder().encode(defaultArg.data)\n : defaultArg.data\n\n return {\n source: mappedSource,\n data: Buffer.from(argData).toString('base64'),\n type: defaultValueType,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(!a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\nfunction getABIMethodParamsSignature(params: ABIMethodParams) {\n const args = params.args.map((a) => a.type).join(',')\n return `${params.name}(${args})${params.returns.type}`\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\ninterface ABIContractParams {\n name: string\n desc?: string\n networks?: ABIContractNetworks\n methods: ABIMethodParams[]\n events?: ARC28Event[]\n}\n\ninterface ABIContractNetworks {\n [network: string]: ABIContractNetworkInfo\n}\n\ninterface ABIContractNetworkInfo {\n appID: number\n}\n\ninterface ABIMethodParams {\n name: string\n desc?: string\n args: ABIMethodArgParams[]\n returns: ABIMethodReturnParams\n /** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */\n readonly?: boolean\n /** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */\n events?: ARC28Event[]\n}\n\ninterface ABIMethodArgParams {\n type: string\n name?: string\n desc?: string\n}\n\ninterface ABIMethodReturnParams {\n type: string\n desc?: string\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethod\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,aAAa,SAAiC;CAC5D,MAAM,eAAe,OAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,WAAS,OAAO,QAAQA,OAAK,WAAW,EAAE,CAAC,CAAC;CACvG,MAAM,UAAU,OAAO,YACrB,aAAa,KAAK,CAAC,GAAG,YAAY;EAChC,MAAM,SAAS,OAAO,SAAS,KAAK,OAAO;GAAE,MAAM,EAAE;GAAI,MAAM,EAAE;GAAI,EAAE;AACvE,SAAO,CAAC,OAAO,MAAM,OAAO;GAC5B,CACH;CACD,MAAM,QAAQ,MAAuB,QAAQ,MAAM,4BAA4B,EAAE;CACjF,MAAM,WAAW,GAAoB,SAA4B;AAE/D,SAAO,KAAK,EAAE,EAAE,gBAAgB,SAAY,oBAAoB,KAAK,EAAE,EAAE,aAAc,KAAK,GAAG,EAAE;;CAEnG,MAAM,eAAe,SAA4B;AAC/C,SAAO,oBAAoB,QAAQ,kBAAkB,KAAK;;CAE5D,MAAM,uBAAuB,GAAe,SAA4B;EACtE,MAAMC,YAAwG,EAAE;AAChH,MAAI,EAAE,aAAa,CAAC,OAAO,KAAK,CAAC,SAAS,EAAE,UAAU,CAAE,WAAQ,KAAK,W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ACR;GACF;EACD,QAAQ,QAAQ;EAChB,aAAa;GACX,QAAQ,YAAY,SAAS;GAC7B,MAAM,YAAY,OAAO;GAC1B;EACD,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,kBAAkB;EAClB,YAAY;EACZ,mBAAmB;EACpB;;AAGH,SAAS,4BAA4B,QAAyB;CAC5D,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI;AACrD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,OAAO,QAAQ"}
@@ -35,16 +35,23 @@ function arc32ToArc56(appSpec) {
35
35
  if (c.update_application && ["ALL", type].includes(c.update_application)) actions$1.push("UpdateApplication");
36
36
  return actions$1;
37
37
  };
38
- const getDefaultArgValue = (type, defaultArg) => {
38
+ const getDefaultArgValue = (defaultArg) => {
39
39
  if (!defaultArg) return void 0;
40
40
  if (defaultArg.source === "abi-method") return {
41
41
  source: "method",
42
42
  data: defaultArg.data.name
43
43
  };
44
+ const mappedSource = defaultArg.source === "constant" ? "literal" : defaultArg.source === "global-state" ? "global" : "local";
45
+ let defaultValueType = void 0;
46
+ if (mappedSource === "literal") {
47
+ if (typeof defaultArg.data === "number") defaultValueType = "uint64";
48
+ else if (typeof defaultArg.data === "string") defaultValueType = "AVMString";
49
+ }
50
+ const argData = typeof defaultArg.data === "number" ? ABIType.from("uint64").encode(defaultArg.data) : typeof defaultArg.data === "string" ? new TextEncoder().encode(defaultArg.data) : defaultArg.data;
44
51
  return {
45
- source: defaultArg.source === "constant" ? "literal" : defaultArg.source === "global-state" ? "global" : "local",
46
- data: Buffer.from(typeof defaultArg.data === "number" ? ABIType.from("uint64").encode(defaultArg.data) : defaultArg.data).toString("base64"),
47
- type: type === "string" ? "AVMString" : type
52
+ source: mappedSource,
53
+ data: Buffer.from(argData).toString("base64"),
54
+ type: defaultValueType
48
55
  };
49
56
  };
50
57
  return {
@@ -60,7 +67,7 @@ function arc32ToArc56(appSpec) {
60
67
  type: a.type,
61
68
  desc: a.desc,
62
69
  struct: a.name ? hint(m)?.structs?.[a.name]?.name : void 0,
63
- defaultValue: getDefaultArgValue(a.type, !a.name ? void 0 : hint(m)?.default_arguments?.[a.name])
70
+ defaultValue: getDefaultArgValue(!a.name ? void 0 : hint(m)?.default_arguments?.[a.name])
64
71
  })),
65
72
  returns: {
66
73
  type: m.returns.type,
@@ -1 +1 @@
1
- {"version":3,"file":"app-spec.mjs","names":["hint","actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]","actions","ABITypeClass"],"sources":["../../src/types/app-spec.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIType as ABITypeClass,\n ARC28Event,\n Arc56Contract,\n Arc56Method,\n StorageKey,\n StructField,\n} from '@algorandfoundation/algokit-abi'\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[getABIMethodParamsSignature(m)] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (\n type: string,\n defaultArg: DefaultArgument | undefined,\n ): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n return {\n source: defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local',\n data: Buffer.from(\n typeof defaultArg.data === 'number' ? ABITypeClass.from('uint64').encode(defaultArg.data) : defaultArg.data,\n ).toString('base64'),\n type: type === 'string' ? 'AVMString' : type,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(a.type, !a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\nfunction getABIMethodParamsSignature(params: ABIMethodParams) {\n const args = params.args.map((a) => a.type).join(',')\n return `${params.name}(${args})${params.returns.type}`\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\ninterface ABIContractParams {\n name: string\n desc?: string\n networks?: ABIContractNetworks\n methods: ABIMethodParams[]\n events?: ARC28Event[]\n}\n\ninterface ABIContractNetworks {\n [network: string]: ABIContractNetworkInfo\n}\n\ninterface ABIContractNetworkInfo {\n appID: number\n}\n\ninterface ABIMethodParams {\n name: string\n desc?: string\n args: ABIMethodArgParams[]\n returns: ABIMethodReturnParams\n /** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */\n readonly?: boolean\n /** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */\n events?: ARC28Event[]\n}\n\ninterface ABIMethodArgParams {\n type: string\n name?: string\n desc?: string\n}\n\ninterface ABIMethodReturnParams {\n type: string\n desc?: string\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethod\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,aAAa,SAAiC;CAC5D,MAAM,eAAe,OAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,WAAS,OAAO,QAAQA,OAAK,WAAW,EAAE,CAA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WAAW,cAAc;KAClD,MAAM,EAAE,GAAG;KACZ,CACF,CAAC,CACH;IACD,OAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,OAAO,MAAM,SAAS,CAAC,KAAK,MAAM,CACvD,EAAE,IACF;KACE,KAAK,OAAO,KAAK,EAAE,GAAG,KAAK,QAAQ,CAAC,SAAS,SAAS;KACtD,SAAS;KACT,WAAW,EAAE,GAAG,SAAS,WAAW,cAAc;KAClD,MAAM,EAAE,GAAG;KACZ,CACF,CAAC,CACH;IACD,KAAK,EAAE;IACR;GACD,MAAM;IACJ,QAAQ,EAAE;IACV,OAAO,EAAE;IACT,KAAK,EAAE;IACR;GACF;EACD,QAAQ,QAAQ;EAChB,aAAa;GACX,QAAQ,YAAY,SAAS;GAC7B,MAAM,YAAY,OAAO;GAC1B;EACD,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,kBAAkB;EAClB,YAAY;EACZ,mBAAmB;EACpB;;AAGH,SAAS,4BAA4B,QAAyB;CAC5D,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI;AACrD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,OAAO,QAAQ"}
1
+ {"version":3,"file":"app-spec.mjs","names":["hint","actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]","actions","defaultValueType: string | undefined","ABITypeClass"],"sources":["../../src/types/app-spec.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIType as ABITypeClass,\n ARC28Event,\n Arc56Contract,\n Arc56Method,\n StorageKey,\n StructField,\n} from '@algorandfoundation/algokit-abi'\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[getABIMethodParamsSignature(m)] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (defaultArg: DefaultArgument | undefined): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n const mappedSource = defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local'\n\n // type is only set for literal source\n let defaultValueType: string | undefined = undefined\n if (mappedSource === 'literal') {\n if (typeof defaultArg.data === 'number') {\n defaultValueType = 'uint64'\n } else if (typeof defaultArg.data === 'string') {\n defaultValueType = 'AVMString'\n }\n }\n\n const argData =\n typeof defaultArg.data === 'number'\n ? ABITypeClass.from('uint64').encode(defaultArg.data)\n : typeof defaultArg.data === 'string'\n ? new TextEncoder().encode(defaultArg.data)\n : defaultArg.data\n\n return {\n source: mappedSource,\n data: Buffer.from(argData).toString('base64'),\n type: defaultValueType,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(!a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\nfunction getABIMethodParamsSignature(params: ABIMethodParams) {\n const args = params.args.map((a) => a.type).join(',')\n return `${params.name}(${args})${params.returns.type}`\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\ninterface ABIContractParams {\n name: string\n desc?: string\n networks?: ABIContractNetworks\n methods: ABIMethodParams[]\n events?: ARC28Event[]\n}\n\ninterface ABIContractNetworks {\n [network: string]: ABIContractNetworkInfo\n}\n\ninterface ABIContractNetworkInfo {\n appID: number\n}\n\ninterface ABIMethodParams {\n name: string\n desc?: string\n args: ABIMethodArgParams[]\n returns: ABIMethodReturnParams\n /** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */\n readonly?: boolean\n /** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */\n events?: ARC28Event[]\n}\n\ninterface ABIMethodArgParams {\n type: string\n name?: string\n desc?: string\n}\n\ninterface ABIMethodReturnParams {\n type: string\n desc?: string\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethod\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,aAAa,SAAiC;CAC5D,MAAM,eAAe,OAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,WAAS,OAAO,QAAQA,OAAK,WAAW,EAAE,CAAC,CAAC;CACvG,MAAM,UAAU,OAAO,YACrB,aAAa,KAAK,CAAC,GAAG,YAAY;EAChC,MAAM,SAAS,OAAO,SAAS,KAAK,OAAO;GAAE,MAAM,EAAE;GAAI,MAAM,EAAE;GAAI,EAAE;AACvE,SAAO,CAAC,OAAO,MAAM,OAAO;GAC5B,CACH;CACD,MAAM,QAAQ,MAAuB,QAAQ,MAAM,4BAA4B,EAAE;CACjF,MAAM,WAAW,GAAoB,SAA4B;AAE/D,SAAO,KAAK,EAAE,EAAE,gBAAgB,SAAY,oBAAoB,KAAK,EAAE,EAAE,aAAc,KAAK,GAAG,EAAE;;CAEnG,MAAM,eAAe,SAA4B;AAC/C,SAAO,oBAAoB,QAAQ,kBAAkB,KAAK;;CAE5D,MAAM,uBAAuB,GAAe,SAA4B;EACtE,MAAMC,YAA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AC,CACH;IACD,KAAK,EAAE;IACR;GACD,MAAM;IACJ,QAAQ,EAAE;IACV,OAAO,EAAE;IACT,KAAK,EAAE;IACR;GACF;EACD,QAAQ,QAAQ;EAChB,aAAa;GACX,QAAQ,YAAY,SAAS;GAC7B,MAAM,YAAY,OAAO;GAC1B;EACD,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,kBAAkB;EAClB,YAAY;EACZ,mBAAmB;EACpB;;AAGH,SAAS,4BAA4B,QAAyB;CAC5D,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI;AACrD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,OAAO,QAAQ"}
package/types/app.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Address } from "../packages/common/src/address.js";
2
+ import { Expand } from "../packages/common/src/expand.js";
2
3
  import { ABIValue } from "../packages/abi/src/abi-value.js";
3
4
  import { ABIType } from "../packages/abi/src/abi-type.js";
4
5
  import { ABIMethod, ABIReturn } from "../packages/abi/src/abi-method.js";
@@ -7,7 +8,6 @@ import { Transaction } from "../packages/transact/src/transactions/transaction.j
7
8
  import { SuggestedParams } from "../packages/algod_client/src/models/suggested-params.js";
8
9
  import { ProgramSourceMap } from "../packages/sdk/src/logic/sourcemap.js";
9
10
  import { BoxIdentifier, BoxReference as BoxReference$1 } from "./app-manager.js";
10
- import { Expand } from "./expand.js";
11
11
  import { SendSingleTransactionResult, SendTransactionFrom, SendTransactionParams, SendTransactionResult, SendTransactionResults, TransactionNote, TransactionToSign } from "./transaction.js";
12
12
  import { TransactionWithSigner } from "../transaction/transaction.js";
13
13
 
package/types/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","names":[],"sources":["../../src/types/app.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, BoxReference as TransactBoxReference, Transaction } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { TransactionWithSigner } from '../transaction'\nimport { BoxIdentifier, BoxReference } from './app-manager'\nimport { Expand } from './expand'\nimport {\n SendSingleTransactionResult,\n SendTransactionFrom,\n SendTransactionParams,\n SendTransactionResult,\n SendTransactionResults,\n TransactionNote,\n TransactionToSign,\n} from './transaction'\ntype SourceMap = ProgramSourceMap\n\n/** The name of the TEAL template variable for deploy-time immutability control */\nexport const UPDATABLE_TEMPLATE_NAME = 'TMPL_UPDATABLE'\n\n/** The name of the TEAL template variable for deploy-time permanence control */\nexport const DELETABLE_TEMPLATE_NAME = 'TMPL_DELETABLE'\n\n/** The app create/update [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) transaction note prefix */\nexport const APP_DEPLOY_NOTE_DAPP = 'ALGOKIT_DEPLOYER'\n\n/** The maximum number of bytes in a single app code page */\nexport const APP_PAGE_MAX_SIZE = 2048\n\n/** First 4 bytes of SHA-512/256 hash of \"return\" for retrieving ABI return values */\nexport const ABI_RETURN_PREFIX = new Uint8Array([21, 31, 124, 117])\n\n/** Information about an Algorand app */\nexport interface AppReference {\n /** The id of the app */\n appId: number | bigint\n /** The Algorand address of the account associated with the app */\n appAddress: string\n}\n\n/** Common app call arguments for ABI and non-ABI (raw) calls */\nexport interface CoreAppCallArgs {\n /** The optional lease for the transaction */\n lease?: string | Uint8Array\n /** Any box references to load */\n boxes?: (TransactBoxReference | BoxReference | BoxIdentifier)[]\n /** The address of any accounts to load in */\n accounts?: (string | Address)[]\n /** IDs of any apps to load into the foreignApps array */\n apps?: number[]\n /** IDs of any assets to load into the foreignAssets array */\n assets?: number[]\n /** Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction.\n *\n * **Note:** Use with extreme caution and review the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying) first.\n */\n rekeyTo?: SendTransactionFrom | string\n}\n\n/**\n * App call args with non-ABI (raw) values (minus some processing like encoding strings as binary)\n */\nexport interface RawAppCallArgs extends CoreAppCallArgs {\n /** Any application arguments to pass through */\n appArgs?: (Uint8Array | string)[]\n /** Property to aid intellisense */\n method?: undefined\n}\n\n/** An argument for an ABI method, either a primitive value, or a transaction with or without signer, or the unawaited async return value of an algokit method that returns a `SendTransactionResult` */\nexport type ABIAppCallArg =\n | ABIValue\n | TransactionWithSigner\n | TransactionToSign\n | Transaction\n | Promise<SendTransactionResult>\n | SendTransactionResult\n | undefined\n\n/**\n * App call args for an ABI call\n */\nexport type ABIAppCallArgs = CoreAppCallArgs & {\n /** The ABI method to call */\n method: ABIMethod\n /** The ABI method args to pass in */\n methodArgs: ABIAppCallArg[]\n}\n\n/** Arguments to pass to an app call either:\n * * The raw app call values to pass through into the transaction (after processing); or\n * * An ABI method definition (method and args)\n **/\nexport type AppCallArgs = RawAppCallArgs | ABIAppCallArgs\n\n/** Parameters representing a call to an app. */\nexport interface AppCallParams extends SendTransactionParams {\n /** The id of the app to call */\n appId: number | bigint\n /** The type of call, everything except create (see `createApp`) and update (see `updateApp`) */\n callType: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n /** The account to make the call from */\n from: SendTransactionFrom\n /** Optional transaction parameters */\n transactionParams?: SuggestedParams\n /** The (optional) transaction note */\n note?: TransactionNote\n /** The arguments passed in to the app call */\n args?: AppCallArgs\n}\n\n/** Parameters representing the storage schema of an app. */\nexport interface AppStorageSchema {\n /** Restricts number of ints in per-user local state */\n localInts: number\n /** Restricts number of byte slices in per-user local state */\n localByteSlices: number\n /** Restricts number of ints in global state */\n globalInts: number\n /** Restricts number of byte slices in global state */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract; if left blank then the right number of pages will be calculated based on the teal code size */\n extraPages?: number\n}\n\n/** Information about a compiled teal program */\nexport interface CompiledTeal {\n /** Original TEAL code */\n teal: string\n /** The compiled code */\n compiled: string\n /** The hash returned by the compiler */\n compiledHash: string\n /** The base64 encoded code as a byte array */\n compiledBase64ToBytes: Uint8Array\n /** Source map from the compilation */\n sourceMap: SourceMap\n}\n\nexport interface AppCallTransactionResultOfType<T> extends SendTransactionResults, SendTransactionResult {\n /** If an ABI method was called the processed return value */\n return?: T\n}\n\n/** Result from calling an app */\nexport type AppCallTransactionResult = AppCallTransactionResultOfType<ABIReturn>\n\n/**\n * The payload of the metadata to add to the transaction note when deploying an app, noting it will be prefixed with `APP_DEPLOY_NOTE_PREFIX`.\n */\nexport interface AppDeployMetadata {\n /** The unique name identifier of the app within the creator account */\n name: string\n /** The version of app that is / will be deployed */\n version: string\n /** Whether or not the app is deletable / permanent / unspecified */\n deletable?: boolean\n /** Whether or not the app is updatable / immutable / unspecified */\n updatable?: boolean\n}\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppReference, AppDeployMetadata {\n /** The round the app was created */\n createdRound: number\n /** The last round that the app was updated */\n updatedRound: number\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n creator: Readonly<string>\n apps: Readonly<{\n [name: string]: AppMetadata\n }>\n}\n\n/** Dictionary of deploy-time parameters to replace in a teal template.\n *\n * Note: Looks for `TMPL_{parameter}` for template replacements i.e. you can leave out the `TMPL_`.\n *\n */\nexport interface TealTemplateParams {\n [key: string]: string | bigint | number | Uint8Array\n}\n\n/** What action to perform when deploying an app and an update is detected in the TEAL code */\nexport enum OnUpdate {\n /** Fail the deployment */\n Fail,\n /** Update the app */\n UpdateApp,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** What action to perform when deploying an app and a breaking schema change is detected */\nexport enum OnSchemaBreak {\n /** Fail the deployment */\n Fail,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** The result of compiling the approval and clear state TEAL programs for an app */\nexport interface AppCompilationResult {\n /** The result of compiling the approval program */\n compiledApproval: CompiledTeal\n /** The result of compiling the clear state program */\n compiledClear: CompiledTeal\n}\n\nexport type AppReturn<TReturn> = {\n /** The ABI method call return value */\n return?: TReturn\n}\n\n/** Result from sending a single app transaction. */\nexport type SendAppTransactionResult = Expand<\n SendSingleTransactionResult & {\n /** If an ABI method was called the processed return value */\n return?: ABIReturn\n }\n>\n\n/** Result from sending a single app transaction. */\nexport type SendAppUpdateTransactionResult = Expand<SendAppTransactionResult & Partial<AppCompilationResult>>\n\n/** Result from sending a single app transaction. */\nexport type SendAppCreateTransactionResult = Expand<\n SendAppUpdateTransactionResult & {\n /** The id of the created app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n }\n>\n\n/** Object holding app state values */\nexport interface AppState {\n [key: string]:\n | {\n value: bigint\n keyRaw: Uint8Array\n keyBase64: string\n }\n | {\n value: string\n valueRaw: Uint8Array\n valueBase64: string\n keyRaw: Uint8Array\n keyBase64: string\n }\n}\n\n/**\n * The name of a box storage box */\nexport interface BoxName {\n /** Name in UTF-8 */\n name: string\n /** Name in binary bytes */\n nameRaw: Uint8Array\n /** Name in Base64 */\n nameBase64: string\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValueRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: number | bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: string | Uint8Array | BoxName\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValuesRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: number\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: (string | Uint8Array | BoxName)[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n"],"mappings":";;;AAoBA,MAAa,0BAA0B;;AAGvC,MAAa,0BAA0B;;AAGvC,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;;AAGjC,MAAa,oBAAoB,IAAI,WAAW;CAAC;CAAI;CAAI;CAAK;CAAI,CAAC;;AAiKnE,IAAY,gDAAL;;AAEL;;AAEA;;AAEA;;AAEA;;;;AAIF,IAAY,0DAAL;;AAEL;;AAEA;;AAEA"}
1
+ {"version":3,"file":"app.js","names":[],"sources":["../../src/types/app.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, Expand } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, BoxReference as TransactBoxReference, Transaction } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { TransactionWithSigner } from '../transaction'\nimport { BoxIdentifier, BoxReference } from './app-manager'\nimport {\n SendSingleTransactionResult,\n SendTransactionFrom,\n SendTransactionParams,\n SendTransactionResult,\n SendTransactionResults,\n TransactionNote,\n TransactionToSign,\n} from './transaction'\ntype SourceMap = ProgramSourceMap\n\n/** The name of the TEAL template variable for deploy-time immutability control */\nexport const UPDATABLE_TEMPLATE_NAME = 'TMPL_UPDATABLE'\n\n/** The name of the TEAL template variable for deploy-time permanence control */\nexport const DELETABLE_TEMPLATE_NAME = 'TMPL_DELETABLE'\n\n/** The app create/update [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) transaction note prefix */\nexport const APP_DEPLOY_NOTE_DAPP = 'ALGOKIT_DEPLOYER'\n\n/** The maximum number of bytes in a single app code page */\nexport const APP_PAGE_MAX_SIZE = 2048\n\n/** First 4 bytes of SHA-512/256 hash of \"return\" for retrieving ABI return values */\nexport const ABI_RETURN_PREFIX = new Uint8Array([21, 31, 124, 117])\n\n/** Information about an Algorand app */\nexport interface AppReference {\n /** The id of the app */\n appId: number | bigint\n /** The Algorand address of the account associated with the app */\n appAddress: string\n}\n\n/** Common app call arguments for ABI and non-ABI (raw) calls */\nexport interface CoreAppCallArgs {\n /** The optional lease for the transaction */\n lease?: string | Uint8Array\n /** Any box references to load */\n boxes?: (TransactBoxReference | BoxReference | BoxIdentifier)[]\n /** The address of any accounts to load in */\n accounts?: (string | Address)[]\n /** IDs of any apps to load into the foreignApps array */\n apps?: number[]\n /** IDs of any assets to load into the foreignAssets array */\n assets?: number[]\n /** Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction.\n *\n * **Note:** Use with extreme caution and review the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying) first.\n */\n rekeyTo?: SendTransactionFrom | string\n}\n\n/**\n * App call args with non-ABI (raw) values (minus some processing like encoding strings as binary)\n */\nexport interface RawAppCallArgs extends CoreAppCallArgs {\n /** Any application arguments to pass through */\n appArgs?: (Uint8Array | string)[]\n /** Property to aid intellisense */\n method?: undefined\n}\n\n/** An argument for an ABI method, either a primitive value, or a transaction with or without signer, or the unawaited async return value of an algokit method that returns a `SendTransactionResult` */\nexport type ABIAppCallArg =\n | ABIValue\n | TransactionWithSigner\n | TransactionToSign\n | Transaction\n | Promise<SendTransactionResult>\n | SendTransactionResult\n | undefined\n\n/**\n * App call args for an ABI call\n */\nexport type ABIAppCallArgs = CoreAppCallArgs & {\n /** The ABI method to call */\n method: ABIMethod\n /** The ABI method args to pass in */\n methodArgs: ABIAppCallArg[]\n}\n\n/** Arguments to pass to an app call either:\n * * The raw app call values to pass through into the transaction (after processing); or\n * * An ABI method definition (method and args)\n **/\nexport type AppCallArgs = RawAppCallArgs | ABIAppCallArgs\n\n/** Parameters representing a call to an app. */\nexport interface AppCallParams extends SendTransactionParams {\n /** The id of the app to call */\n appId: number | bigint\n /** The type of call, everything except create (see `createApp`) and update (see `updateApp`) */\n callType: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n /** The account to make the call from */\n from: SendTransactionFrom\n /** Optional transaction parameters */\n transactionParams?: SuggestedParams\n /** The (optional) transaction note */\n note?: TransactionNote\n /** The arguments passed in to the app call */\n args?: AppCallArgs\n}\n\n/** Parameters representing the storage schema of an app. */\nexport interface AppStorageSchema {\n /** Restricts number of ints in per-user local state */\n localInts: number\n /** Restricts number of byte slices in per-user local state */\n localByteSlices: number\n /** Restricts number of ints in global state */\n globalInts: number\n /** Restricts number of byte slices in global state */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract; if left blank then the right number of pages will be calculated based on the teal code size */\n extraPages?: number\n}\n\n/** Information about a compiled teal program */\nexport interface CompiledTeal {\n /** Original TEAL code */\n teal: string\n /** The compiled code */\n compiled: string\n /** The hash returned by the compiler */\n compiledHash: string\n /** The base64 encoded code as a byte array */\n compiledBase64ToBytes: Uint8Array\n /** Source map from the compilation */\n sourceMap: SourceMap\n}\n\nexport interface AppCallTransactionResultOfType<T> extends SendTransactionResults, SendTransactionResult {\n /** If an ABI method was called the processed return value */\n return?: T\n}\n\n/** Result from calling an app */\nexport type AppCallTransactionResult = AppCallTransactionResultOfType<ABIReturn>\n\n/**\n * The payload of the metadata to add to the transaction note when deploying an app, noting it will be prefixed with `APP_DEPLOY_NOTE_PREFIX`.\n */\nexport interface AppDeployMetadata {\n /** The unique name identifier of the app within the creator account */\n name: string\n /** The version of app that is / will be deployed */\n version: string\n /** Whether or not the app is deletable / permanent / unspecified */\n deletable?: boolean\n /** Whether or not the app is updatable / immutable / unspecified */\n updatable?: boolean\n}\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppReference, AppDeployMetadata {\n /** The round the app was created */\n createdRound: number\n /** The last round that the app was updated */\n updatedRound: number\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n creator: Readonly<string>\n apps: Readonly<{\n [name: string]: AppMetadata\n }>\n}\n\n/** Dictionary of deploy-time parameters to replace in a teal template.\n *\n * Note: Looks for `TMPL_{parameter}` for template replacements i.e. you can leave out the `TMPL_`.\n *\n */\nexport interface TealTemplateParams {\n [key: string]: string | bigint | number | Uint8Array\n}\n\n/** What action to perform when deploying an app and an update is detected in the TEAL code */\nexport enum OnUpdate {\n /** Fail the deployment */\n Fail,\n /** Update the app */\n UpdateApp,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** What action to perform when deploying an app and a breaking schema change is detected */\nexport enum OnSchemaBreak {\n /** Fail the deployment */\n Fail,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** The result of compiling the approval and clear state TEAL programs for an app */\nexport interface AppCompilationResult {\n /** The result of compiling the approval program */\n compiledApproval: CompiledTeal\n /** The result of compiling the clear state program */\n compiledClear: CompiledTeal\n}\n\nexport type AppReturn<TReturn> = {\n /** The ABI method call return value */\n return?: TReturn\n}\n\n/** Result from sending a single app transaction. */\nexport type SendAppTransactionResult = Expand<\n SendSingleTransactionResult & {\n /** If an ABI method was called the processed return value */\n return?: ABIReturn\n }\n>\n\n/** Result from sending a single app transaction. */\nexport type SendAppUpdateTransactionResult = Expand<SendAppTransactionResult & Partial<AppCompilationResult>>\n\n/** Result from sending a single app transaction. */\nexport type SendAppCreateTransactionResult = Expand<\n SendAppUpdateTransactionResult & {\n /** The id of the created app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n }\n>\n\n/** Object holding app state values */\nexport interface AppState {\n [key: string]:\n | {\n value: bigint\n keyRaw: Uint8Array\n keyBase64: string\n }\n | {\n value: string\n valueRaw: Uint8Array\n valueBase64: string\n keyRaw: Uint8Array\n keyBase64: string\n }\n}\n\n/**\n * The name of a box storage box */\nexport interface BoxName {\n /** Name in UTF-8 */\n name: string\n /** Name in binary bytes */\n nameRaw: Uint8Array\n /** Name in Base64 */\n nameBase64: string\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValueRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: number | bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: string | Uint8Array | BoxName\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValuesRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: number\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: (string | Uint8Array | BoxName)[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n"],"mappings":";;;AAmBA,MAAa,0BAA0B;;AAGvC,MAAa,0BAA0B;;AAGvC,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;;AAGjC,MAAa,oBAAoB,IAAI,WAAW;CAAC;CAAI;CAAI;CAAK;CAAI,CAAC;;AAiKnE,IAAY,gDAAL;;AAEL;;AAEA;;AAEA;;AAEA;;;;AAIF,IAAY,0DAAL;;AAEL;;AAEA;;AAEA"}
package/types/app.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.mjs","names":[],"sources":["../../src/types/app.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, BoxReference as TransactBoxReference, Transaction } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { TransactionWithSigner } from '../transaction'\nimport { BoxIdentifier, BoxReference } from './app-manager'\nimport { Expand } from './expand'\nimport {\n SendSingleTransactionResult,\n SendTransactionFrom,\n SendTransactionParams,\n SendTransactionResult,\n SendTransactionResults,\n TransactionNote,\n TransactionToSign,\n} from './transaction'\ntype SourceMap = ProgramSourceMap\n\n/** The name of the TEAL template variable for deploy-time immutability control */\nexport const UPDATABLE_TEMPLATE_NAME = 'TMPL_UPDATABLE'\n\n/** The name of the TEAL template variable for deploy-time permanence control */\nexport const DELETABLE_TEMPLATE_NAME = 'TMPL_DELETABLE'\n\n/** The app create/update [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) transaction note prefix */\nexport const APP_DEPLOY_NOTE_DAPP = 'ALGOKIT_DEPLOYER'\n\n/** The maximum number of bytes in a single app code page */\nexport const APP_PAGE_MAX_SIZE = 2048\n\n/** First 4 bytes of SHA-512/256 hash of \"return\" for retrieving ABI return values */\nexport const ABI_RETURN_PREFIX = new Uint8Array([21, 31, 124, 117])\n\n/** Information about an Algorand app */\nexport interface AppReference {\n /** The id of the app */\n appId: number | bigint\n /** The Algorand address of the account associated with the app */\n appAddress: string\n}\n\n/** Common app call arguments for ABI and non-ABI (raw) calls */\nexport interface CoreAppCallArgs {\n /** The optional lease for the transaction */\n lease?: string | Uint8Array\n /** Any box references to load */\n boxes?: (TransactBoxReference | BoxReference | BoxIdentifier)[]\n /** The address of any accounts to load in */\n accounts?: (string | Address)[]\n /** IDs of any apps to load into the foreignApps array */\n apps?: number[]\n /** IDs of any assets to load into the foreignAssets array */\n assets?: number[]\n /** Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction.\n *\n * **Note:** Use with extreme caution and review the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying) first.\n */\n rekeyTo?: SendTransactionFrom | string\n}\n\n/**\n * App call args with non-ABI (raw) values (minus some processing like encoding strings as binary)\n */\nexport interface RawAppCallArgs extends CoreAppCallArgs {\n /** Any application arguments to pass through */\n appArgs?: (Uint8Array | string)[]\n /** Property to aid intellisense */\n method?: undefined\n}\n\n/** An argument for an ABI method, either a primitive value, or a transaction with or without signer, or the unawaited async return value of an algokit method that returns a `SendTransactionResult` */\nexport type ABIAppCallArg =\n | ABIValue\n | TransactionWithSigner\n | TransactionToSign\n | Transaction\n | Promise<SendTransactionResult>\n | SendTransactionResult\n | undefined\n\n/**\n * App call args for an ABI call\n */\nexport type ABIAppCallArgs = CoreAppCallArgs & {\n /** The ABI method to call */\n method: ABIMethod\n /** The ABI method args to pass in */\n methodArgs: ABIAppCallArg[]\n}\n\n/** Arguments to pass to an app call either:\n * * The raw app call values to pass through into the transaction (after processing); or\n * * An ABI method definition (method and args)\n **/\nexport type AppCallArgs = RawAppCallArgs | ABIAppCallArgs\n\n/** Parameters representing a call to an app. */\nexport interface AppCallParams extends SendTransactionParams {\n /** The id of the app to call */\n appId: number | bigint\n /** The type of call, everything except create (see `createApp`) and update (see `updateApp`) */\n callType: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n /** The account to make the call from */\n from: SendTransactionFrom\n /** Optional transaction parameters */\n transactionParams?: SuggestedParams\n /** The (optional) transaction note */\n note?: TransactionNote\n /** The arguments passed in to the app call */\n args?: AppCallArgs\n}\n\n/** Parameters representing the storage schema of an app. */\nexport interface AppStorageSchema {\n /** Restricts number of ints in per-user local state */\n localInts: number\n /** Restricts number of byte slices in per-user local state */\n localByteSlices: number\n /** Restricts number of ints in global state */\n globalInts: number\n /** Restricts number of byte slices in global state */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract; if left blank then the right number of pages will be calculated based on the teal code size */\n extraPages?: number\n}\n\n/** Information about a compiled teal program */\nexport interface CompiledTeal {\n /** Original TEAL code */\n teal: string\n /** The compiled code */\n compiled: string\n /** The hash returned by the compiler */\n compiledHash: string\n /** The base64 encoded code as a byte array */\n compiledBase64ToBytes: Uint8Array\n /** Source map from the compilation */\n sourceMap: SourceMap\n}\n\nexport interface AppCallTransactionResultOfType<T> extends SendTransactionResults, SendTransactionResult {\n /** If an ABI method was called the processed return value */\n return?: T\n}\n\n/** Result from calling an app */\nexport type AppCallTransactionResult = AppCallTransactionResultOfType<ABIReturn>\n\n/**\n * The payload of the metadata to add to the transaction note when deploying an app, noting it will be prefixed with `APP_DEPLOY_NOTE_PREFIX`.\n */\nexport interface AppDeployMetadata {\n /** The unique name identifier of the app within the creator account */\n name: string\n /** The version of app that is / will be deployed */\n version: string\n /** Whether or not the app is deletable / permanent / unspecified */\n deletable?: boolean\n /** Whether or not the app is updatable / immutable / unspecified */\n updatable?: boolean\n}\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppReference, AppDeployMetadata {\n /** The round the app was created */\n createdRound: number\n /** The last round that the app was updated */\n updatedRound: number\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n creator: Readonly<string>\n apps: Readonly<{\n [name: string]: AppMetadata\n }>\n}\n\n/** Dictionary of deploy-time parameters to replace in a teal template.\n *\n * Note: Looks for `TMPL_{parameter}` for template replacements i.e. you can leave out the `TMPL_`.\n *\n */\nexport interface TealTemplateParams {\n [key: string]: string | bigint | number | Uint8Array\n}\n\n/** What action to perform when deploying an app and an update is detected in the TEAL code */\nexport enum OnUpdate {\n /** Fail the deployment */\n Fail,\n /** Update the app */\n UpdateApp,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** What action to perform when deploying an app and a breaking schema change is detected */\nexport enum OnSchemaBreak {\n /** Fail the deployment */\n Fail,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** The result of compiling the approval and clear state TEAL programs for an app */\nexport interface AppCompilationResult {\n /** The result of compiling the approval program */\n compiledApproval: CompiledTeal\n /** The result of compiling the clear state program */\n compiledClear: CompiledTeal\n}\n\nexport type AppReturn<TReturn> = {\n /** The ABI method call return value */\n return?: TReturn\n}\n\n/** Result from sending a single app transaction. */\nexport type SendAppTransactionResult = Expand<\n SendSingleTransactionResult & {\n /** If an ABI method was called the processed return value */\n return?: ABIReturn\n }\n>\n\n/** Result from sending a single app transaction. */\nexport type SendAppUpdateTransactionResult = Expand<SendAppTransactionResult & Partial<AppCompilationResult>>\n\n/** Result from sending a single app transaction. */\nexport type SendAppCreateTransactionResult = Expand<\n SendAppUpdateTransactionResult & {\n /** The id of the created app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n }\n>\n\n/** Object holding app state values */\nexport interface AppState {\n [key: string]:\n | {\n value: bigint\n keyRaw: Uint8Array\n keyBase64: string\n }\n | {\n value: string\n valueRaw: Uint8Array\n valueBase64: string\n keyRaw: Uint8Array\n keyBase64: string\n }\n}\n\n/**\n * The name of a box storage box */\nexport interface BoxName {\n /** Name in UTF-8 */\n name: string\n /** Name in binary bytes */\n nameRaw: Uint8Array\n /** Name in Base64 */\n nameBase64: string\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValueRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: number | bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: string | Uint8Array | BoxName\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValuesRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: number\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: (string | Uint8Array | BoxName)[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n"],"mappings":";;AAoBA,MAAa,0BAA0B;;AAGvC,MAAa,0BAA0B;;AAGvC,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;;AAGjC,MAAa,oBAAoB,IAAI,WAAW;CAAC;CAAI;CAAI;CAAK;CAAI,CAAC;;AAiKnE,IAAY,gDAAL;;AAEL;;AAEA;;AAEA;;AAEA;;;;AAIF,IAAY,0DAAL;;AAEL;;AAEA;;AAEA"}
1
+ {"version":3,"file":"app.mjs","names":[],"sources":["../../src/types/app.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, Expand } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, BoxReference as TransactBoxReference, Transaction } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { TransactionWithSigner } from '../transaction'\nimport { BoxIdentifier, BoxReference } from './app-manager'\nimport {\n SendSingleTransactionResult,\n SendTransactionFrom,\n SendTransactionParams,\n SendTransactionResult,\n SendTransactionResults,\n TransactionNote,\n TransactionToSign,\n} from './transaction'\ntype SourceMap = ProgramSourceMap\n\n/** The name of the TEAL template variable for deploy-time immutability control */\nexport const UPDATABLE_TEMPLATE_NAME = 'TMPL_UPDATABLE'\n\n/** The name of the TEAL template variable for deploy-time permanence control */\nexport const DELETABLE_TEMPLATE_NAME = 'TMPL_DELETABLE'\n\n/** The app create/update [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) transaction note prefix */\nexport const APP_DEPLOY_NOTE_DAPP = 'ALGOKIT_DEPLOYER'\n\n/** The maximum number of bytes in a single app code page */\nexport const APP_PAGE_MAX_SIZE = 2048\n\n/** First 4 bytes of SHA-512/256 hash of \"return\" for retrieving ABI return values */\nexport const ABI_RETURN_PREFIX = new Uint8Array([21, 31, 124, 117])\n\n/** Information about an Algorand app */\nexport interface AppReference {\n /** The id of the app */\n appId: number | bigint\n /** The Algorand address of the account associated with the app */\n appAddress: string\n}\n\n/** Common app call arguments for ABI and non-ABI (raw) calls */\nexport interface CoreAppCallArgs {\n /** The optional lease for the transaction */\n lease?: string | Uint8Array\n /** Any box references to load */\n boxes?: (TransactBoxReference | BoxReference | BoxIdentifier)[]\n /** The address of any accounts to load in */\n accounts?: (string | Address)[]\n /** IDs of any apps to load into the foreignApps array */\n apps?: number[]\n /** IDs of any assets to load into the foreignAssets array */\n assets?: number[]\n /** Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction.\n *\n * **Note:** Use with extreme caution and review the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying) first.\n */\n rekeyTo?: SendTransactionFrom | string\n}\n\n/**\n * App call args with non-ABI (raw) values (minus some processing like encoding strings as binary)\n */\nexport interface RawAppCallArgs extends CoreAppCallArgs {\n /** Any application arguments to pass through */\n appArgs?: (Uint8Array | string)[]\n /** Property to aid intellisense */\n method?: undefined\n}\n\n/** An argument for an ABI method, either a primitive value, or a transaction with or without signer, or the unawaited async return value of an algokit method that returns a `SendTransactionResult` */\nexport type ABIAppCallArg =\n | ABIValue\n | TransactionWithSigner\n | TransactionToSign\n | Transaction\n | Promise<SendTransactionResult>\n | SendTransactionResult\n | undefined\n\n/**\n * App call args for an ABI call\n */\nexport type ABIAppCallArgs = CoreAppCallArgs & {\n /** The ABI method to call */\n method: ABIMethod\n /** The ABI method args to pass in */\n methodArgs: ABIAppCallArg[]\n}\n\n/** Arguments to pass to an app call either:\n * * The raw app call values to pass through into the transaction (after processing); or\n * * An ABI method definition (method and args)\n **/\nexport type AppCallArgs = RawAppCallArgs | ABIAppCallArgs\n\n/** Parameters representing a call to an app. */\nexport interface AppCallParams extends SendTransactionParams {\n /** The id of the app to call */\n appId: number | bigint\n /** The type of call, everything except create (see `createApp`) and update (see `updateApp`) */\n callType: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n /** The account to make the call from */\n from: SendTransactionFrom\n /** Optional transaction parameters */\n transactionParams?: SuggestedParams\n /** The (optional) transaction note */\n note?: TransactionNote\n /** The arguments passed in to the app call */\n args?: AppCallArgs\n}\n\n/** Parameters representing the storage schema of an app. */\nexport interface AppStorageSchema {\n /** Restricts number of ints in per-user local state */\n localInts: number\n /** Restricts number of byte slices in per-user local state */\n localByteSlices: number\n /** Restricts number of ints in global state */\n globalInts: number\n /** Restricts number of byte slices in global state */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract; if left blank then the right number of pages will be calculated based on the teal code size */\n extraPages?: number\n}\n\n/** Information about a compiled teal program */\nexport interface CompiledTeal {\n /** Original TEAL code */\n teal: string\n /** The compiled code */\n compiled: string\n /** The hash returned by the compiler */\n compiledHash: string\n /** The base64 encoded code as a byte array */\n compiledBase64ToBytes: Uint8Array\n /** Source map from the compilation */\n sourceMap: SourceMap\n}\n\nexport interface AppCallTransactionResultOfType<T> extends SendTransactionResults, SendTransactionResult {\n /** If an ABI method was called the processed return value */\n return?: T\n}\n\n/** Result from calling an app */\nexport type AppCallTransactionResult = AppCallTransactionResultOfType<ABIReturn>\n\n/**\n * The payload of the metadata to add to the transaction note when deploying an app, noting it will be prefixed with `APP_DEPLOY_NOTE_PREFIX`.\n */\nexport interface AppDeployMetadata {\n /** The unique name identifier of the app within the creator account */\n name: string\n /** The version of app that is / will be deployed */\n version: string\n /** Whether or not the app is deletable / permanent / unspecified */\n deletable?: boolean\n /** Whether or not the app is updatable / immutable / unspecified */\n updatable?: boolean\n}\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppReference, AppDeployMetadata {\n /** The round the app was created */\n createdRound: number\n /** The last round that the app was updated */\n updatedRound: number\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n creator: Readonly<string>\n apps: Readonly<{\n [name: string]: AppMetadata\n }>\n}\n\n/** Dictionary of deploy-time parameters to replace in a teal template.\n *\n * Note: Looks for `TMPL_{parameter}` for template replacements i.e. you can leave out the `TMPL_`.\n *\n */\nexport interface TealTemplateParams {\n [key: string]: string | bigint | number | Uint8Array\n}\n\n/** What action to perform when deploying an app and an update is detected in the TEAL code */\nexport enum OnUpdate {\n /** Fail the deployment */\n Fail,\n /** Update the app */\n UpdateApp,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** What action to perform when deploying an app and a breaking schema change is detected */\nexport enum OnSchemaBreak {\n /** Fail the deployment */\n Fail,\n /** Delete the app and create a new one in its place */\n ReplaceApp,\n /** Create a new app */\n AppendApp,\n}\n\n/** The result of compiling the approval and clear state TEAL programs for an app */\nexport interface AppCompilationResult {\n /** The result of compiling the approval program */\n compiledApproval: CompiledTeal\n /** The result of compiling the clear state program */\n compiledClear: CompiledTeal\n}\n\nexport type AppReturn<TReturn> = {\n /** The ABI method call return value */\n return?: TReturn\n}\n\n/** Result from sending a single app transaction. */\nexport type SendAppTransactionResult = Expand<\n SendSingleTransactionResult & {\n /** If an ABI method was called the processed return value */\n return?: ABIReturn\n }\n>\n\n/** Result from sending a single app transaction. */\nexport type SendAppUpdateTransactionResult = Expand<SendAppTransactionResult & Partial<AppCompilationResult>>\n\n/** Result from sending a single app transaction. */\nexport type SendAppCreateTransactionResult = Expand<\n SendAppUpdateTransactionResult & {\n /** The id of the created app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n }\n>\n\n/** Object holding app state values */\nexport interface AppState {\n [key: string]:\n | {\n value: bigint\n keyRaw: Uint8Array\n keyBase64: string\n }\n | {\n value: string\n valueRaw: Uint8Array\n valueBase64: string\n keyRaw: Uint8Array\n keyBase64: string\n }\n}\n\n/**\n * The name of a box storage box */\nexport interface BoxName {\n /** Name in UTF-8 */\n name: string\n /** Name in binary bytes */\n nameRaw: Uint8Array\n /** Name in Base64 */\n nameBase64: string\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValueRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: number | bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: string | Uint8Array | BoxName\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * @deprecated Use `types/app-manager/BoxValuesRequestParams` instead.\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: number\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: (string | Uint8Array | BoxName)[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n"],"mappings":";;AAmBA,MAAa,0BAA0B;;AAGvC,MAAa,0BAA0B;;AAGvC,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;;AAGjC,MAAa,oBAAoB,IAAI,WAAW;CAAC;CAAI;CAAI;CAAK;CAAI,CAAC;;AAiKnE,IAAY,gDAAL;;AAEL;;AAEA;;AAEA;;AAEA;;;;AAIF,IAAY,0DAAL;;AAEL;;AAEA;;AAEA"}
@@ -32,7 +32,7 @@ var AssetManager = class {
32
32
  * @returns The asset information
33
33
  */
34
34
  async getById(assetId) {
35
- const asset = await this._algod.getAssetById(assetId);
35
+ const asset = await this._algod.assetById(assetId);
36
36
  return {
37
37
  assetId: BigInt(asset.id),
38
38
  total: BigInt(asset.params.total),