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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. package/_virtual/rolldown_runtime.js +10 -15
  2. package/algo25/index.d.ts +2 -0
  3. package/algo25/index.js +9 -0
  4. package/algo25/index.mjs +3 -0
  5. package/algod-client/index.d.ts +3 -7
  6. package/algod-client/index.js +2 -5
  7. package/algod-client/index.mjs +2 -2
  8. package/index.d.ts +1 -2
  9. package/index.js +0 -7
  10. package/index.mjs +1 -2
  11. package/indexer-client/index.d.ts +2 -2
  12. package/indexer-client/index.js +6 -6
  13. package/indexer-client/index.mjs +2 -2
  14. package/{indexer-lookup.d.ts → indexer-client/indexer-lookup.d.ts} +8 -11
  15. package/{indexer-lookup.mjs → indexer-client/indexer-lookup.js} +6 -10
  16. package/indexer-client/indexer-lookup.js.map +1 -0
  17. package/{indexer-lookup.js → indexer-client/indexer-lookup.mjs} +3 -18
  18. package/indexer-client/indexer-lookup.mjs.map +1 -0
  19. package/kmd-client/index.d.ts +1 -2
  20. package/kmd-client/index.js +0 -5
  21. package/kmd-client/index.mjs +1 -2
  22. package/package.json +1 -6
  23. package/packages/abi/src/abi-method.d.ts +1 -1
  24. package/packages/abi/src/abi-method.js +1 -1
  25. package/packages/abi/src/abi-method.js.map +1 -1
  26. package/packages/abi/src/abi-method.mjs +1 -1
  27. package/packages/abi/src/abi-method.mjs.map +1 -1
  28. package/packages/abi/src/abi-type.d.ts +1 -1
  29. package/packages/abi/src/abi-type.js +4 -2
  30. package/packages/abi/src/abi-type.js.map +1 -1
  31. package/packages/abi/src/abi-type.mjs +4 -2
  32. package/packages/abi/src/abi-type.mjs.map +1 -1
  33. package/packages/abi/src/arc56-contract.js +1 -0
  34. package/packages/abi/src/arc56-contract.js.map +1 -1
  35. package/packages/abi/src/arc56-contract.mjs +1 -0
  36. package/packages/abi/src/arc56-contract.mjs.map +1 -1
  37. package/packages/algo25/src/index.d.ts +40 -0
  38. package/packages/algo25/src/index.js +45 -1
  39. package/packages/algo25/src/index.js.map +1 -1
  40. package/packages/algo25/src/index.mjs +40 -2
  41. package/packages/algo25/src/index.mjs.map +1 -1
  42. package/packages/algod_client/src/apis/api-service.d.ts +44 -44
  43. package/packages/algod_client/src/apis/api-service.js +155 -155
  44. package/packages/algod_client/src/apis/api-service.js.map +1 -1
  45. package/packages/algod_client/src/apis/api-service.mjs +155 -155
  46. package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
  47. package/packages/algod_client/src/core/api-error.js +3 -1
  48. package/packages/algod_client/src/core/api-error.js.map +1 -1
  49. package/packages/algod_client/src/core/api-error.mjs +3 -1
  50. package/packages/algod_client/src/core/api-error.mjs.map +1 -1
  51. package/packages/algod_client/src/core/model-runtime.js +6 -6
  52. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  53. package/packages/algod_client/src/core/model-runtime.mjs +8 -8
  54. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  55. package/packages/algod_client/src/models/account-participation.js +4 -4
  56. package/packages/algod_client/src/models/account-participation.js.map +1 -1
  57. package/packages/algod_client/src/models/account-participation.mjs +4 -4
  58. package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
  59. package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
  60. package/packages/algod_client/src/models/application-state-schema.js +2 -2
  61. package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
  62. package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
  63. package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
  64. package/packages/algod_client/src/models/asset-params.js +2 -1
  65. package/packages/algod_client/src/models/asset-params.js.map +1 -1
  66. package/packages/algod_client/src/models/asset-params.mjs +2 -1
  67. package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
  68. package/packages/algod_client/src/models/block-response.js +1 -2
  69. package/packages/algod_client/src/models/block-response.js.map +1 -1
  70. package/packages/algod_client/src/models/block-response.mjs +2 -3
  71. package/packages/algod_client/src/models/block-response.mjs.map +1 -1
  72. package/packages/algod_client/src/models/block.d.ts +60 -40
  73. package/packages/algod_client/src/models/block.js +184 -108
  74. package/packages/algod_client/src/models/block.js.map +1 -1
  75. package/packages/algod_client/src/models/block.mjs +184 -108
  76. package/packages/algod_client/src/models/block.mjs.map +1 -1
  77. package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
  78. package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
  79. package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
  80. package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
  81. package/packages/algod_client/src/models/simulate-request.js +1 -1
  82. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  83. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  84. package/packages/algod_client/src/models/simulate-response.js +6 -1
  85. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  86. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  87. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  88. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
  89. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
  90. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
  91. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
  92. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
  93. package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
  94. package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
  95. package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
  96. package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
  97. package/packages/common/src/address.js +0 -14
  98. package/packages/common/src/address.js.map +1 -1
  99. package/packages/common/src/address.mjs +1 -14
  100. package/packages/common/src/address.mjs.map +1 -1
  101. package/packages/common/src/codecs/composite/map.js +7 -4
  102. package/packages/common/src/codecs/composite/map.js.map +1 -1
  103. package/packages/common/src/codecs/composite/map.mjs +7 -4
  104. package/packages/common/src/codecs/composite/map.mjs.map +1 -1
  105. package/packages/common/src/codecs/composite/record.js +0 -1
  106. package/packages/common/src/codecs/composite/record.js.map +1 -1
  107. package/packages/common/src/codecs/primitives/address.js +0 -1
  108. package/packages/common/src/codecs/primitives/address.js.map +1 -1
  109. package/packages/common/src/codecs/primitives/bytes.js +0 -1
  110. package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
  111. package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
  112. package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
  113. package/packages/common/src/codecs/wire.js +0 -1
  114. package/packages/common/src/codecs/wire.js.map +1 -1
  115. package/packages/common/src/json.mjs +2 -2
  116. package/packages/common/src/json.mjs.map +1 -1
  117. package/packages/common/src/msgpack.js +0 -1
  118. package/packages/common/src/msgpack.js.map +1 -1
  119. package/packages/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
  120. package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
  121. package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
  122. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
  123. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.map +1 -1
  124. package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
  125. package/packages/indexer_client/src/apis/api-service.js +12 -12
  126. package/packages/indexer_client/src/apis/api-service.js.map +1 -1
  127. package/packages/indexer_client/src/apis/api-service.mjs +12 -12
  128. package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
  129. package/packages/indexer_client/src/core/api-error.js +3 -1
  130. package/packages/indexer_client/src/core/api-error.js.map +1 -1
  131. package/packages/indexer_client/src/core/api-error.mjs +3 -1
  132. package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
  133. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  134. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  135. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  136. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  137. package/packages/indexer_client/src/models/account-participation.js +4 -4
  138. package/packages/indexer_client/src/models/account-participation.js.map +1 -1
  139. package/packages/indexer_client/src/models/account-participation.mjs +4 -4
  140. package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
  141. package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
  142. package/packages/indexer_client/src/models/application-state-schema.js +2 -2
  143. package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
  144. package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
  145. package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
  146. package/packages/indexer_client/src/models/asset-params.js +2 -1
  147. package/packages/indexer_client/src/models/asset-params.js.map +1 -1
  148. package/packages/indexer_client/src/models/asset-params.mjs +2 -1
  149. package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
  150. package/packages/indexer_client/src/models/block.d.ts +5 -5
  151. package/packages/indexer_client/src/models/block.js +13 -13
  152. package/packages/indexer_client/src/models/block.js.map +1 -1
  153. package/packages/indexer_client/src/models/block.mjs +13 -13
  154. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  155. package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
  156. package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
  157. package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
  158. package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
  159. package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
  160. package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
  161. package/packages/indexer_client/src/models/eval-delta.js +2 -2
  162. package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
  163. package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
  164. package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
  165. package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
  166. package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
  167. package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
  168. package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
  169. package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
  170. package/packages/indexer_client/src/models/participation-updates.js +2 -2
  171. package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
  172. package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
  173. package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
  174. package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
  175. package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
  176. package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
  177. package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
  178. package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
  179. package/packages/indexer_client/src/models/state-schema.js +2 -2
  180. package/packages/indexer_client/src/models/state-schema.js.map +1 -1
  181. package/packages/indexer_client/src/models/state-schema.mjs +2 -2
  182. package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
  183. package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
  184. package/packages/indexer_client/src/models/teal-key-value.js +2 -2
  185. package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
  186. package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
  187. package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
  188. package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
  189. package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
  190. package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
  191. package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
  192. package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
  193. package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
  194. package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
  195. package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
  196. package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
  197. package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
  198. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
  199. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
  200. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
  201. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
  202. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
  203. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
  204. package/packages/indexer_client/src/models/transaction.d.ts +2 -2
  205. package/packages/indexer_client/src/models/transaction.js +6 -5
  206. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  207. package/packages/indexer_client/src/models/transaction.mjs +6 -5
  208. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  209. package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
  210. package/packages/kmd_client/src/apis/api-service.js +32 -32
  211. package/packages/kmd_client/src/apis/api-service.js.map +1 -1
  212. package/packages/kmd_client/src/apis/api-service.mjs +32 -32
  213. package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
  214. package/packages/kmd_client/src/core/api-error.js +3 -1
  215. package/packages/kmd_client/src/core/api-error.js.map +1 -1
  216. package/packages/kmd_client/src/core/api-error.mjs +3 -1
  217. package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
  218. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  219. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  220. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  221. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  222. package/packages/transact/src/logicsig.d.ts +3 -15
  223. package/packages/transact/src/logicsig.js +16 -36
  224. package/packages/transact/src/logicsig.js.map +1 -1
  225. package/packages/transact/src/logicsig.mjs +18 -36
  226. package/packages/transact/src/logicsig.mjs.map +1 -1
  227. package/packages/transact/src/multisig.d.ts +7 -115
  228. package/packages/transact/src/multisig.js +86 -136
  229. package/packages/transact/src/multisig.js.map +1 -1
  230. package/packages/transact/src/multisig.mjs +87 -117
  231. package/packages/transact/src/multisig.mjs.map +1 -1
  232. package/packages/transact/src/transactions/app-call.d.ts +10 -15
  233. package/packages/transact/src/transactions/app-call.js.map +1 -1
  234. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  235. package/packages/transact/src/transactions/asset-config.d.ts +1 -6
  236. package/packages/transact/src/transactions/asset-config.js.map +1 -1
  237. package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
  238. package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
  239. package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
  240. package/packages/transact/src/transactions/key-registration.d.ts +1 -8
  241. package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
  242. package/packages/transact/src/transactions/reference-types-meta.js +71 -0
  243. package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
  244. package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
  245. package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
  246. package/packages/transact/src/transactions/signed-transaction-meta.js +2 -3
  247. package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
  248. package/packages/transact/src/transactions/signed-transaction-meta.mjs +3 -3
  249. package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
  250. package/packages/transact/src/transactions/signed-transaction.d.ts +7 -3
  251. package/packages/transact/src/transactions/signed-transaction.js +1 -1
  252. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  253. package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
  254. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  255. package/packages/transact/src/transactions/transaction-meta.js +29 -23
  256. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  257. package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
  258. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  259. package/packages/transact/src/transactions/transaction.d.ts +5 -1
  260. package/packages/transact/src/transactions/transaction.js +1 -1
  261. package/packages/transact/src/transactions/transaction.js.map +1 -1
  262. package/packages/transact/src/transactions/transaction.mjs +1 -1
  263. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  264. package/testing/account.js +2 -5
  265. package/testing/account.js.map +1 -1
  266. package/testing/account.mjs +2 -5
  267. package/testing/account.mjs.map +1 -1
  268. package/testing/fixtures/algorand-fixture.d.ts +3 -3
  269. package/testing/fixtures/algorand-fixture.js.map +1 -1
  270. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  271. package/testing/transaction-logger.js +1 -1
  272. package/testing/transaction-logger.mjs +1 -1
  273. package/transact/index.d.ts +11 -10
  274. package/transact/index.js +7 -32
  275. package/transact/index.mjs +7 -10
  276. package/transaction/transaction.js +2 -2
  277. package/transaction/transaction.js.map +1 -1
  278. package/transaction/transaction.mjs +2 -2
  279. package/transaction/transaction.mjs.map +1 -1
  280. package/transactions/app-call.d.ts +5 -4
  281. package/transactions/app-call.js +16 -16
  282. package/transactions/app-call.js.map +1 -1
  283. package/transactions/app-call.mjs +16 -16
  284. package/transactions/app-call.mjs.map +1 -1
  285. package/transactions/asset-config.d.ts +1 -1
  286. package/transactions/asset-config.js +1 -1
  287. package/transactions/asset-config.js.map +1 -1
  288. package/transactions/asset-config.mjs +1 -1
  289. package/transactions/asset-config.mjs.map +1 -1
  290. package/transactions/key-registration.d.ts +1 -1
  291. package/transactions/key-registration.js.map +1 -1
  292. package/transactions/key-registration.mjs.map +1 -1
  293. package/transactions/method-call.d.ts +1 -1
  294. package/transactions/method-call.js +70 -78
  295. package/transactions/method-call.js.map +1 -1
  296. package/transactions/method-call.mjs +70 -78
  297. package/transactions/method-call.mjs.map +1 -1
  298. package/types/account-manager.d.ts +1 -1
  299. package/types/account-manager.js +5 -5
  300. package/types/account-manager.js.map +1 -1
  301. package/types/account-manager.mjs +5 -5
  302. package/types/account-manager.mjs.map +1 -1
  303. package/types/algorand-client-transaction-creator.d.ts +74 -60
  304. package/types/algorand-client-transaction-creator.js +8 -0
  305. package/types/algorand-client-transaction-creator.js.map +1 -1
  306. package/types/algorand-client-transaction-creator.mjs +8 -0
  307. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  308. package/types/algorand-client-transaction-sender.d.ts +79 -65
  309. package/types/algorand-client-transaction-sender.js +8 -1
  310. package/types/algorand-client-transaction-sender.js.map +1 -1
  311. package/types/algorand-client-transaction-sender.mjs +8 -0
  312. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  313. package/types/amount.js +23 -4
  314. package/types/amount.js.map +1 -1
  315. package/types/amount.mjs +20 -2
  316. package/types/amount.mjs.map +1 -1
  317. package/types/app-client.d.ts +174 -169
  318. package/types/app-client.js +2 -3
  319. package/types/app-client.js.map +1 -1
  320. package/types/app-client.mjs +2 -2
  321. package/types/app-client.mjs.map +1 -1
  322. package/types/app-deployer.d.ts +1 -1
  323. package/types/app-deployer.js +3 -3
  324. package/types/app-deployer.js.map +1 -1
  325. package/types/app-deployer.mjs +3 -3
  326. package/types/app-deployer.mjs.map +1 -1
  327. package/types/app-factory.d.ts +70 -67
  328. package/types/app-factory.js +2 -2
  329. package/types/app-factory.js.map +1 -1
  330. package/types/app-factory.mjs +2 -2
  331. package/types/app-factory.mjs.map +1 -1
  332. package/types/app-manager.d.ts +3 -1
  333. package/types/app-manager.js +17 -11
  334. package/types/app-manager.js.map +1 -1
  335. package/types/app-manager.mjs +17 -11
  336. package/types/app-manager.mjs.map +1 -1
  337. package/types/app-spec.js +12 -5
  338. package/types/app-spec.js.map +1 -1
  339. package/types/app-spec.mjs +12 -5
  340. package/types/app-spec.mjs.map +1 -1
  341. package/types/app.d.ts +2 -2
  342. package/types/app.js.map +1 -1
  343. package/types/app.mjs.map +1 -1
  344. package/types/asset-manager.js +1 -1
  345. package/types/asset-manager.js.map +1 -1
  346. package/types/asset-manager.mjs +1 -1
  347. package/types/asset-manager.mjs.map +1 -1
  348. package/types/async-event-emitter.d.ts +3 -6
  349. package/types/async-event-emitter.js.map +1 -1
  350. package/types/async-event-emitter.mjs.map +1 -1
  351. package/types/client-manager.d.ts +1 -1
  352. package/types/client-manager.js.map +1 -1
  353. package/types/client-manager.mjs.map +1 -1
  354. package/types/composer.d.ts +9 -1
  355. package/types/composer.js +49 -37
  356. package/types/composer.js.map +1 -1
  357. package/types/composer.mjs +40 -27
  358. package/types/composer.mjs.map +1 -1
  359. package/types/debugging.d.ts +13 -9
  360. package/types/debugging.js.map +1 -1
  361. package/types/debugging.mjs.map +1 -1
  362. package/types/expand.d.ts +2 -9
  363. package/types/kmd-account-manager.d.ts +1 -0
  364. package/types/kmd-account-manager.js +22 -11
  365. package/types/kmd-account-manager.js.map +1 -1
  366. package/types/kmd-account-manager.mjs +23 -12
  367. package/types/kmd-account-manager.mjs.map +1 -1
  368. package/types/lifecycle-events.d.ts +0 -1
  369. package/types/lifecycle-events.js.map +1 -1
  370. package/types/lifecycle-events.mjs.map +1 -1
  371. package/types/testing.d.ts +2 -2
  372. package/types/transaction.d.ts +1 -1
  373. package/_virtual/rolldown_runtime.mjs +0 -13
  374. package/indexer-lookup.js.map +0 -1
  375. package/indexer-lookup.mjs.map +0 -1
  376. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  377. package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
  378. package/packages/algod_client/src/models/application-local-reference.js +0 -23
  379. package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
  380. package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
  381. package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
  382. package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
  383. package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
  384. package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
  385. package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
  386. package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
  387. package/packages/algod_client/src/models/box-reference.d.ts +0 -17
  388. package/packages/algod_client/src/models/box-reference.js +0 -23
  389. package/packages/algod_client/src/models/box-reference.js.map +0 -1
  390. package/packages/algod_client/src/models/box-reference.mjs +0 -23
  391. package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
  392. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  393. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  394. package/packages/sdk/src/convert.d.ts +0 -17
  395. package/packages/sdk/src/convert.js +0 -28
  396. package/packages/sdk/src/convert.js.map +0 -1
  397. package/packages/sdk/src/convert.mjs +0 -25
  398. package/packages/sdk/src/convert.mjs.map +0 -1
  399. package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
  400. package/packages/sdk/src/encoding/binarydata.js +0 -65
  401. package/packages/sdk/src/encoding/binarydata.js.map +0 -1
  402. package/packages/sdk/src/encoding/binarydata.mjs +0 -60
  403. package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
  404. package/packages/sdk/src/encoding/encoding.d.ts +0 -237
  405. package/packages/sdk/src/encoding/encoding.js +0 -302
  406. package/packages/sdk/src/encoding/encoding.js.map +0 -1
  407. package/packages/sdk/src/encoding/encoding.mjs +0 -287
  408. package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
  409. package/packages/sdk/src/encoding/schema/array.js +0 -35
  410. package/packages/sdk/src/encoding/schema/array.js.map +0 -1
  411. package/packages/sdk/src/encoding/schema/array.mjs +0 -35
  412. package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
  413. package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
  414. package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
  415. package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
  416. package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
  417. package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
  418. package/packages/sdk/src/encoding/schema/map.js +0 -110
  419. package/packages/sdk/src/encoding/schema/map.js.map +0 -1
  420. package/packages/sdk/src/encoding/schema/map.mjs +0 -107
  421. package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
  422. package/packages/sdk/src/encoding/schema/optional.js +0 -46
  423. package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
  424. package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
  425. package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
  426. package/packages/sdk/src/encoding/schema/uint64.js +0 -30
  427. package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
  428. package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
  429. package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
  430. package/packages/sdk/src/encoding/uint64.d.ts +0 -34
  431. package/packages/sdk/src/encoding/uint64.js +0 -34
  432. package/packages/sdk/src/encoding/uint64.js.map +0 -1
  433. package/packages/sdk/src/encoding/uint64.mjs +0 -33
  434. package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
  435. package/packages/sdk/src/index.d.ts +0 -44
  436. package/packages/sdk/src/index.js +0 -62
  437. package/packages/sdk/src/index.js.map +0 -1
  438. package/packages/sdk/src/index.mjs +0 -58
  439. package/packages/sdk/src/index.mjs.map +0 -1
  440. package/packages/sdk/src/nacl/naclWrappers.js +0 -14
  441. package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
  442. package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
  443. package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
  444. package/packages/sdk/src/types/intDecoding.d.ts +0 -28
  445. package/packages/sdk/src/types/intDecoding.js +0 -32
  446. package/packages/sdk/src/types/intDecoding.js.map +0 -1
  447. package/packages/sdk/src/types/intDecoding.mjs +0 -31
  448. package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
  449. package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
  450. package/packages/sdk/src/types/transactions/encoded.js +0 -64
  451. package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
  452. package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
  453. package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
  454. package/packages/sdk/src/utils/utils.d.ts +0 -64
  455. package/packages/sdk/src/utils/utils.js +0 -140
  456. package/packages/sdk/src/utils/utils.js.map +0 -1
  457. package/packages/sdk/src/utils/utils.mjs +0 -128
  458. package/packages/sdk/src/utils/utils.mjs.map +0 -1
  459. package/packages/transact/src/transactions/common.d.ts +0 -37
  460. package/sdk/index.d.ts +0 -10
  461. package/sdk/index.js +0 -59
  462. package/sdk/index.mjs +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"abi-type.mjs","names":["childTypes: ABIType[]","bitSize: number","precision: number","encodedBytes: Uint8Array","typeStrings: string[]","heads: Uint8Array[]","tails: Uint8Array[]","values: ABIValue[]","childType: ABIType","length: number","structName: string","structFields: ABIStructField[]","dynamicSegments: Segment[]","valuePartitions: (Uint8Array | null)[]","result: Uint8Array[]","tupleStrings: string[]"],"sources":["../../../../packages/abi/src/abi-type.ts"],"sourcesContent":["import {\n Address,\n BOOL_FALSE_BYTE,\n BOOL_TRUE_BYTE,\n LENGTH_ENCODE_BYTE_SIZE,\n PUBLIC_KEY_BYTE_LENGTH,\n concatArrays,\n} from '@algorandfoundation/algokit-common'\nimport type { ABIStructValue, ABIValue } from './abi-value'\nimport { StructField } from './arc56-contract'\nimport { bigIntToBytes, bytesToBigInt } from './bigint'\n\nconst STATIC_ARRAY_REGEX = /^([a-z\\d[\\](),]+)\\[(0|[1-9][\\d]*)]$/\nconst UFIXED_REGEX = /^ufixed([1-9][\\d]*)x([1-9][\\d]*)$/\nconst MAX_LEN = 2 ** 16 - 1\n\n/**\n * Information about a single field in a struct\n */\nexport type ABIStructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | ABIStructField[]\n}\n\ninterface Segment {\n left: number\n right: number\n}\n\n/**\n * Represents an Algorand ABI type for encoding and decoding values as defined in [ARC-0004](https://arc.algorand.foundation/ARCs/arc-0004#types).\n *\n * This is the abstract base class for all ABI types.\n */\nexport abstract class ABIType {\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n abstract get name(): string\n\n /**\n * Returns a user-friendly display name for this type.\n * @returns The display name for this type\n */\n get displayName(): string {\n return this.name\n }\n\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n toString(): string {\n return this.name\n }\n\n /**\n * Checks if this ABI type is equal to another.\n * @param other The other ABI type to compare with\n * @returns True if the types are equal, false otherwise\n */\n abstract equals(other: ABIType): boolean\n\n /**\n * Checks if this ABI type is dynamic (variable-length).\n * @returns True if the type is dynamic, false otherwise\n */\n abstract isDynamic(): boolean\n\n /**\n * Gets the byte length of the encoded type for static types.\n * @returns The number of bytes needed to encode this type\n * @throws Error if the type is dynamic\n */\n abstract byteLen(): number\n\n /**\n * Encodes a value according to this ABI type.\n * @param value The value to encode\n * @returns The encoded bytes\n */\n abstract encode(value: ABIValue): Uint8Array\n\n /**\n * Decodes bytes according to this ABI type.\n * @param bytes The bytes to decode\n * @returns The decoded value\n */\n abstract decode(bytes: Uint8Array): ABIValue\n\n /**\n * Creates an ABI type from an ARC-4 type string.\n * @param str The ARC-4 type string (e.g., \"uint256\", \"bool\", \"(uint8,address)\")\n * @returns The corresponding ABI type\n */\n static from(str: string): ABIType {\n if (str.endsWith('[]')) {\n const childType = ABIType.from(str.slice(0, str.length - 2))\n return new ABIArrayDynamicType(childType)\n }\n if (str.endsWith(']')) {\n const stringMatches = str.match(STATIC_ARRAY_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed static array string: ${str}`)\n }\n const arrayLengthStr = stringMatches[2]\n const arrayLength = parseInt(arrayLengthStr, 10)\n if (arrayLength > MAX_LEN) {\n throw new Error(`Array length exceeds limit ${MAX_LEN}`)\n }\n const childType = ABIType.from(stringMatches[1])\n return new ABIArrayStaticType(childType, arrayLength)\n }\n if (str.startsWith('uint')) {\n const digitsOnly = (s: string) => [...s].every((c) => '0123456789'.includes(c))\n const typeSizeStr = str.slice(4, str.length)\n if (!digitsOnly(typeSizeStr)) {\n throw new Error(`Malformed uint string: ${typeSizeStr}`)\n }\n const bitSize = parseInt(typeSizeStr, 10)\n if (bitSize > MAX_LEN) {\n throw new Error(`Malformed uint string: ${bitSize}`)\n }\n return new ABIUintType(bitSize)\n }\n if (str === 'byte') {\n return new ABIByteType()\n }\n if (str.startsWith('ufixed')) {\n const stringMatches = str.match(UFIXED_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed ufixed type: ${str}`)\n }\n const bitSize = parseInt(stringMatches[1], 10)\n const precision = parseInt(stringMatches[2], 10)\n return new ABIUfixedType(bitSize, precision)\n }\n if (str === 'bool') {\n return new ABIBoolType()\n }\n if (str === 'address') {\n return new ABIAddressType()\n }\n if (str === 'string') {\n return new ABIStringType()\n }\n if (str.length >= 2 && str[0] === '(' && str[str.length - 1] === ')') {\n const tupleContent = parseTupleContent(str.slice(1, str.length - 1))\n const childTypes: ABIType[] = []\n for (let i = 0; i < tupleContent.length; i++) {\n const ti = ABIType.from(tupleContent[i])\n childTypes.push(ti)\n }\n return new ABITupleType(childTypes)\n }\n throw new Error(`Cannot convert a string ${str} to an ABI type`)\n }\n}\n\n// ============================================================================\n// Primitive Types\n// ============================================================================\n\n/**\n * An unsigned integer ABI type of a specific bit size.\n */\nexport class ABIUintType extends ABIType {\n /**\n * Creates a new unsigned integer type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n */\n constructor(public readonly bitSize: number) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported uint type bitSize: ${bitSize}`)\n }\n }\n\n get name(): string {\n return `uint${this.bitSize}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUintType && this.bitSize === other.bitSize\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * A fixed-point number ABI type of a specific bit size and precision.\n */\nexport class ABIUfixedType extends ABIType {\n /**\n * Creates a new fixed-point type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n * @param precision The decimal precision (must be between 1 and 160)\n */\n constructor(\n public readonly bitSize: number,\n public readonly precision: number,\n ) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported ufixed type bitSize: ${bitSize}`)\n }\n if (precision > 160 || precision < 1) {\n throw new Error(`Unsupported ufixed type precision: ${precision}`)\n }\n }\n\n get name(): string {\n return `ufixed${this.bitSize}x${this.precision}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUfixedType && this.bitSize === other.bitSize && this.precision === other.precision\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * An Algorand address ABI type.\n */\nexport class ABIAddressType extends ABIType {\n get name(): string {\n return 'address'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIAddressType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return PUBLIC_KEY_BYTE_LENGTH\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value === 'string') {\n return Address.fromString(value).publicKey\n }\n\n if (value instanceof Address) {\n return value.publicKey\n }\n\n throw new Error(`Cannot encode value as address: ${value}`)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n return new Address(bytes)\n }\n}\n\n/**\n * A boolean ABI type.\n */\nexport class ABIBoolType extends ABIType {\n get name(): string {\n return 'bool'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIBoolType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'boolean') {\n throw new Error(`Cannot encode value as bool: ${value}`)\n }\n\n return value ? new Uint8Array([0x80]) : new Uint8Array([0x00])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for bool, got ${bytes.length}`)\n }\n\n return (bytes[0] & 0x80) !== 0\n }\n}\n\n/**\n * A single byte ABI type.\n */\nexport class ABIByteType extends ABIType {\n get name(): string {\n return 'byte'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIByteType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'number' && typeof value !== 'bigint') {\n throw new Error(`Cannot encode value as byte: ${value}`)\n }\n const numberValue = typeof value === 'bigint' ? Number(value) : value\n if (value < 0 || value > 255) {\n throw new Error(`Byte value must be between 0 and 255, got ${numberValue}`)\n }\n\n return new Uint8Array([numberValue])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for byte type, got ${bytes.length}`)\n }\n\n return bytes[0]\n }\n}\n\n/**\n * A dynamic-length string ABI type.\n */\nexport class ABIStringType extends ABIType {\n get name(): string {\n return 'string'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIStringType\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, string is a dynamic type`)\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'string' && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as string: ${value}`)\n }\n\n let encodedBytes: Uint8Array\n if (typeof value === 'string') {\n encodedBytes = new TextEncoder().encode(value)\n } else {\n encodedBytes = value\n }\n const encodedLength = bigIntToBytes(encodedBytes.length, LENGTH_ENCODE_BYTE_SIZE)\n const mergedBytes = new Uint8Array(encodedBytes.length + LENGTH_ENCODE_BYTE_SIZE)\n mergedBytes.set(encodedLength)\n mergedBytes.set(encodedBytes, LENGTH_ENCODE_BYTE_SIZE)\n return mergedBytes\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error(\n `Byte string is too short to be decoded. Actual length is ${bytes.length}, but expected at least ${LENGTH_ENCODE_BYTE_SIZE}`,\n )\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const byteValue = bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length)\n if (byteLength !== byteValue.length) {\n throw new Error(`String length bytes do not match the actual length of string. Expected ${byteLength}, got ${byteValue.length}`)\n }\n return new TextDecoder('utf-8').decode(byteValue)\n }\n}\n\n// ============================================================================\n// Collection Types\n// ============================================================================\n\n/**\n * A tuple ABI type containing other ABI types.\n */\nexport class ABITupleType extends ABIType {\n /**\n * Creates a new tuple type.\n * @param childTypes The types of the tuple elements\n */\n constructor(public readonly childTypes: ABIType[]) {\n super()\n if (childTypes.length > MAX_LEN) {\n throw new Error(`Tuple has too many child types: ${childTypes.length}`)\n }\n }\n\n get name(): string {\n const typeStrings: string[] = []\n for (let i = 0; i < this.childTypes.length; i++) {\n typeStrings[i] = this.childTypes[i].name\n }\n return `(${typeStrings.join(',')})`\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABITupleType)) return false\n if (this.childTypes.length !== other.childTypes.length) return false\n return this.childTypes.every((t, i) => t.equals(other.childTypes[i]))\n }\n\n isDynamic(): boolean {\n return this.childTypes.some((c) => c.isDynamic())\n }\n\n byteLen(): number {\n let size = 0\n let i = 0\n while (i < this.childTypes.length) {\n const childType = this.childTypes[i]\n if (childType instanceof ABIBoolType) {\n const sequenceEndIndex = findBoolSequenceEnd(this.childTypes, i)\n const boolCount = sequenceEndIndex - i + 1\n size += Math.ceil(boolCount / 8)\n i = sequenceEndIndex + 1\n } else {\n size += childType.byteLen()\n i++\n }\n }\n return size\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.toString()}: ${value}`)\n }\n\n const values = Array.from(value)\n\n if (this.childTypes.length !== values.length) {\n throw new Error('Mismatch lengths between the values and types')\n }\n\n const heads: Uint8Array[] = []\n const tails: Uint8Array[] = []\n const isDynamicIndex = new Map<number, boolean>()\n let abiTypesCursor = 0\n\n while (abiTypesCursor < this.childTypes.length) {\n const childType = this.childTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n isDynamicIndex.set(heads.length, true)\n heads.push(new Uint8Array(2)) // Placeholder for dynamic offset\n tails.push(childType.encode(values[abiTypesCursor]))\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(this.childTypes, abiTypesCursor)\n const boolValues = values.slice(abiTypesCursor, boolSequenceEndIndex + 1)\n const compressedBool = compressBools(boolValues)\n heads.push(new Uint8Array([compressedBool]))\n abiTypesCursor = boolSequenceEndIndex\n } else {\n heads.push(childType.encode(values[abiTypesCursor]))\n }\n isDynamicIndex.set(abiTypesCursor, false)\n tails.push(new Uint8Array(0))\n }\n abiTypesCursor += 1\n }\n\n const headLength = heads.reduce((sum, head) => sum + head.length, 0)\n let tailLength = 0\n\n for (let i = 0; i < heads.length; i++) {\n if (isDynamicIndex.get(i)) {\n const headValue = headLength + tailLength\n if (headValue > 0xffff) {\n throw new Error(`Value ${headValue} cannot fit in u16`)\n }\n heads[i] = new Uint8Array([(headValue >> 8) & 0xff, headValue & 0xff])\n }\n tailLength += tails[i].length\n }\n\n const totalLength = heads.reduce((sum, head) => sum + head.length, 0) + tails.reduce((sum, tail) => sum + tail.length, 0)\n const result = new Uint8Array(totalLength)\n let offset = 0\n\n for (const head of heads) {\n result.set(head, offset)\n offset += head.length\n }\n\n for (const tail of tails) {\n result.set(tail, offset)\n offset += tail.length\n }\n\n return result\n }\n\n decode(bytes: Uint8Array): ABIValue[] {\n const valuePartitions = extractValues(this.childTypes, bytes)\n const values: ABIValue[] = []\n\n for (let i = 0; i < this.childTypes.length; i++) {\n const childType = this.childTypes[i]\n const valuePartition = valuePartitions[i]\n const childValue = childType.decode(valuePartition)\n values.push(childValue)\n }\n\n return values\n }\n}\n\n/**\n * A static-length array ABI type.\n */\nexport class ABIArrayStaticType extends ABIType {\n /**\n * Creates a new static array type.\n * @param childType The type of the array elements\n * @param length The fixed length of the array\n */\n constructor(\n public readonly childType: ABIType,\n public readonly length: number,\n ) {\n super()\n if (length < 0 || length > MAX_LEN) {\n throw new Error(`Invalid static array length: ${length}`)\n }\n }\n\n get name(): string {\n return `${this.childType.name}[${this.length}]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayStaticType && this.childType.equals(other.childType) && this.length === other.length\n }\n\n isDynamic(): boolean {\n return this.childType.isDynamic()\n }\n\n byteLen(): number {\n if (this.childType instanceof ABIBoolType) {\n return Math.ceil(this.length / 8)\n }\n return this.childType.byteLen() * this.length\n }\n\n /**\n * Converts this static array type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n return new ABITupleType(Array(this.length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value.length !== this.length) {\n throw new Error(`Value array does not match static array length. Expected ${this.length}, got ${value.length}`)\n }\n const convertedTuple = this.toABITupleType()\n return convertedTuple.encode(value)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const convertedTuple = this.toABITupleType()\n const decoded = convertedTuple.decode(bytes)\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A dynamic-length array ABI type.\n */\nexport class ABIArrayDynamicType extends ABIType {\n /**\n * Creates a new dynamic array type.\n * @param childType The type of the array elements\n */\n constructor(public readonly childType: ABIType) {\n super()\n }\n\n get name(): string {\n return `${this.childType.name}[]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayDynamicType && this.childType.equals(other.childType)\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, dynamic array is a dynamic type`)\n }\n\n /**\n * Converts this dynamic array type to an equivalent tuple type of a given length.\n * @param length The number of elements\n * @returns The equivalent tuple type\n */\n toABITupleType(length: number): ABITupleType {\n return new ABITupleType(Array(length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n const convertedTuple = this.toABITupleType(value.length)\n const encodedTuple = convertedTuple.encode(value)\n const encodedLength = bigIntToBytes(convertedTuple.childTypes.length, LENGTH_ENCODE_BYTE_SIZE)\n return concatArrays(encodedLength, encodedTuple)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const view = new DataView(bytes.buffer, 0, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const convertedTuple = this.toABITupleType(byteLength)\n const decoded = convertedTuple.decode(bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length))\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A struct ABI type with named fields.\n */\nexport class ABIStructType extends ABIType {\n /**\n * Creates a new struct type.\n * @param structName The name of the struct\n * @param structFields The fields of the struct\n */\n constructor(\n public readonly structName: string,\n public readonly structFields: ABIStructField[],\n ) {\n super()\n }\n\n get name(): string {\n const tupleType = this.toABITupleType()\n return tupleType.name\n }\n\n get displayName(): string {\n return this.structName\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABIStructType)) return false\n if (this.structName !== other.structName) return false\n if (this.structFields.length !== other.structFields.length) return false\n return this.structFields.every((f, i) => {\n const otherField = other.structFields[i]\n if (f.name !== otherField.name) return false\n if (Array.isArray(f.type) && Array.isArray(otherField.type)) {\n return JSON.stringify(f.type) === JSON.stringify(otherField.type)\n }\n if (f.type instanceof ABIType && otherField.type instanceof ABIType) {\n return f.type.equals(otherField.type)\n }\n return false\n })\n }\n\n isDynamic(): boolean {\n const tupleType = this.toABITupleType()\n return tupleType.isDynamic()\n }\n\n byteLen(): number {\n const tupleType = this.toABITupleType()\n return tupleType.byteLen()\n }\n\n /**\n * Converts this struct type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n const getABITupleTypeFromABIStructFields = (fields: ABIStructField[]): ABITupleType => {\n const childTypes = fields.map((field) =>\n Array.isArray(field.type)\n ? getABITupleTypeFromABIStructFields(field.type)\n : field.type instanceof ABIStructType\n ? field.type.toABITupleType()\n : field.type,\n )\n return new ABITupleType(childTypes)\n }\n\n return getABITupleTypeFromABIStructFields(this.structFields)\n }\n\n /**\n * Creates an ABIStructType from struct name and struct definitions.\n * @param structName The name of the struct\n * @param structs A record of struct definitions\n * @returns The struct type\n */\n static fromStruct(structName: string, structs: Record<string, StructField[]>): ABIStructType {\n const getStructFieldType = (structFieldType: string | StructField[]): ABIType | ABIStructField[] => {\n // When the input is an array of struct fields\n if (Array.isArray(structFieldType)) {\n return structFieldType.map((structField) => ({\n name: structField.name,\n type: getStructFieldType(structField.type),\n }))\n }\n\n // When the input is a name of another struct\n if (structs[structFieldType]) {\n return ABIStructType.fromStruct(structFieldType, structs)\n }\n\n // When the input in an ABI type name\n return ABIType.from(structFieldType)\n }\n\n if (!structs[structName]) throw new Error('Struct not found')\n\n const fields = structs[structName]\n return new ABIStructType(\n structName,\n fields.map((f) => ({\n name: f.name,\n type: getStructFieldType(f.type),\n })),\n )\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'object' || Array.isArray(value) || value instanceof Uint8Array || value instanceof Address) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n const tupleType = this.toABITupleType()\n const tupleValue = this.getTupleValueFromStructValue(value)\n return tupleType.encode(tupleValue)\n }\n\n decode(bytes: Uint8Array): ABIStructValue {\n const tupleType = this.toABITupleType()\n const tupleValue = tupleType.decode(bytes)\n return this.getStructValueFromTupleValue(tupleValue)\n }\n\n private getTupleValueFromStructValue(structValue: ABIStructValue): ABIValue[] {\n const getTupleValueFromStructFields = (structFields: ABIStructField[], values: ABIValue[]): ABIValue[] => {\n return structFields.map(({ type }, index) => {\n // if type is an array of fields, treat as unnamed struct\n if (Array.isArray(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type, Object.values(value))\n }\n // if type is struct, treat as struct\n if (type instanceof ABIStructType) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type.structFields, Object.values(value))\n }\n return values[index]\n })\n }\n\n return getTupleValueFromStructFields(this.structFields, Object.values(structValue))\n }\n\n private getStructValueFromTupleValue(tupleValue: ABIValue[]): ABIStructValue {\n const getStructFieldValues = (structFields: ABIStructField[], values: ABIValue[]): ABIStructValue => {\n return Object.fromEntries(\n structFields.map(({ name, type }, index) => {\n // When the type is an array of fields, the value must be tuple\n if (Array.isArray(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type, value)]\n }\n // When the type is a struct, the value must be tuple\n if (type instanceof ABIStructType) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type.structFields, value)]\n }\n return [name, values[index]]\n }),\n )\n }\n\n return getStructFieldValues(this.structFields, tupleValue)\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction compressBools(values: ABIValue[]): number {\n if (values.length > 8) {\n throw new Error(`Expected no more than 8 bool values, received ${values.length}`)\n }\n\n let result = 0\n for (let i = 0; i < values.length; i++) {\n if (typeof values[i] !== 'boolean') {\n throw new Error('Expected all values to be boolean')\n }\n if (values[i]) {\n result |= 1 << (7 - i)\n }\n }\n\n return result\n}\n\nfunction findBoolSequenceEnd(abiTypes: ABIType[], currentIndex: number): number {\n let cursor = currentIndex\n while (cursor < abiTypes.length) {\n if (abiTypes[cursor] instanceof ABIBoolType) {\n if (cursor - currentIndex + 1 === 8 || cursor === abiTypes.length - 1) {\n return cursor\n }\n cursor++\n } else {\n return cursor - 1\n }\n }\n return cursor - 1\n}\n\nfunction extractValues(abiTypes: ABIType[], bytes: Uint8Array): Uint8Array[] {\n const dynamicSegments: Segment[] = []\n const valuePartitions: (Uint8Array | null)[] = []\n let bytesCursor = 0\n let abiTypesCursor = 0\n\n while (abiTypesCursor < abiTypes.length) {\n const childType = abiTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n if (bytes.length - bytesCursor < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error('Byte array is too short to be decoded')\n }\n\n const dynamicIndex = (bytes[bytesCursor] << 8) | bytes[bytesCursor + 1]\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n if (dynamicIndex < lastSegment.left) {\n throw new Error('Dynamic index segment miscalculation: left is greater than right index')\n }\n lastSegment.right = dynamicIndex\n }\n\n dynamicSegments.push({ left: dynamicIndex, right: 0 })\n valuePartitions.push(null)\n bytesCursor += LENGTH_ENCODE_BYTE_SIZE\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(abiTypes, abiTypesCursor)\n for (let j = 0; j <= boolSequenceEndIndex - abiTypesCursor; j++) {\n const boolMask = BOOL_TRUE_BYTE >> j\n if ((bytes[bytesCursor] & boolMask) > 0) {\n valuePartitions.push(new Uint8Array([BOOL_TRUE_BYTE]))\n } else {\n valuePartitions.push(new Uint8Array([BOOL_FALSE_BYTE]))\n }\n }\n abiTypesCursor = boolSequenceEndIndex\n bytesCursor += 1\n } else {\n const childTypeSize = childType.byteLen()\n if (bytesCursor + childTypeSize > bytes.length) {\n throw new Error(\n `Index out of bounds, trying to access bytes[${bytesCursor}..${bytesCursor + childTypeSize}] but slice has length ${bytes.length}`,\n )\n }\n valuePartitions.push(bytes.slice(bytesCursor, bytesCursor + childTypeSize))\n bytesCursor += childTypeSize\n }\n }\n\n if (abiTypesCursor !== abiTypes.length - 1 && bytesCursor >= bytes.length) {\n throw new Error('Input bytes not enough to decode')\n }\n abiTypesCursor += 1\n }\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n lastSegment.right = bytes.length\n } else if (bytesCursor < bytes.length) {\n throw new Error('Input bytes not fully consumed')\n }\n\n for (let i = 0; i < dynamicSegments.length; i++) {\n const segment = dynamicSegments[i]\n if (segment.left > segment.right) {\n throw new Error('Dynamic segment should display a [l, r] space with l <= r')\n }\n if (i !== dynamicSegments.length - 1 && segment.right !== dynamicSegments[i + 1].left) {\n throw new Error('Dynamic segments should be consecutive')\n }\n }\n\n let segmentIndex = 0\n for (let i = 0; i < abiTypes.length; i++) {\n const childType = abiTypes[i]\n if (childType.isDynamic()) {\n valuePartitions[i] = bytes.slice(dynamicSegments[segmentIndex].left, dynamicSegments[segmentIndex].right)\n segmentIndex += 1\n }\n }\n\n const result: Uint8Array[] = []\n for (let i = 0; i < valuePartitions.length; i++) {\n const partition = valuePartitions[i]\n if (partition === null) {\n throw new Error(`Value partition at index ${i} is None`)\n }\n result.push(partition)\n }\n\n return result\n}\n\nexport function parseTupleContent(content: string): string[] {\n if (content === '') {\n return []\n }\n\n if (content.startsWith(',')) {\n throw new Error('The content should not start with comma')\n }\n if (content.endsWith(',')) {\n throw new Error('The content should not end with comma')\n }\n if (content.includes(',,')) {\n throw new Error('The content should not have consecutive commas')\n }\n\n const tupleStrings: string[] = []\n let depth = 0\n let word = ''\n\n for (const ch of content) {\n word += ch\n if (ch === '(') {\n depth += 1\n } else if (ch === ')') {\n depth -= 1\n } else if (ch === ',' && depth === 0) {\n word = word.slice(0, -1) // Remove the comma\n tupleStrings.push(word)\n word = ''\n }\n }\n\n if (word !== '') {\n tupleStrings.push(word)\n }\n\n if (depth !== 0) {\n throw new Error('The content has mismatched parentheses')\n }\n\n return tupleStrings\n}\n"],"mappings":";;;;;;AAYA,MAAM,qBAAqB;AAC3B,MAAM,eAAe;AACrB,MAAM,UAAU,KAAK,KAAK;;;;;;AAsB1B,IAAsB,UAAtB,MAAsB,QAAQ;;;;;CAW5B,IAAI,cAAsB;AACxB,SAAO,KAAK;;;;;;CAOd,WAAmB;AACjB,SAAO,KAAK;;;;;;;CA0Cd,OAAO,KAAK,KAAsB;AAChC,MAAI,IAAI,SAAS,KAAK,CAEpB,QAAO,IAAI,oBADO,QAAQ,KAAK,IAAI,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,CACnB;AAE3C,MAAI,IAA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B,MAAMC,SAAuB,EAAE;AAC/B,MAAK,IAAI,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK;EAC/C,MAAM,YAAY,gBAAgB;AAClC,MAAI,cAAc,KAChB,OAAM,IAAI,MAAM,4BAA4B,EAAE,UAAU;AAE1D,SAAO,KAAK,UAAU;;AAGxB,QAAO;;AAGT,SAAgB,kBAAkB,SAA2B;AAC3D,KAAI,YAAY,GACd,QAAO,EAAE;AAGX,KAAI,QAAQ,WAAW,IAAI,CACzB,OAAM,IAAI,MAAM,0CAA0C;AAE5D,KAAI,QAAQ,SAAS,IAAI,CACvB,OAAM,IAAI,MAAM,wCAAwC;AAE1D,KAAI,QAAQ,SAAS,KAAK,CACxB,OAAM,IAAI,MAAM,iDAAiD;CAGnE,MAAMC,eAAyB,EAAE;CACjC,IAAI,QAAQ;CACZ,IAAI,OAAO;AAEX,MAAK,MAAM,MAAM,SAAS;AACxB,UAAQ;AACR,MAAI,OAAO,IACT,UAAS;WACA,OAAO,IAChB,UAAS;WACA,OAAO,OAAO,UAAU,GAAG;AACpC,UAAO,KAAK,MAAM,GAAG,GAAG;AACxB,gBAAa,KAAK,KAAK;AACvB,UAAO;;;AAIX,KAAI,SAAS,GACX,cAAa,KAAK,KAAK;AAGzB,KAAI,UAAU,EACZ,OAAM,IAAI,MAAM,yCAAyC;AAG3D,QAAO"}
1
+ {"version":3,"file":"abi-type.mjs","names":["childTypes: ABIType[]","bitSize: number","precision: number","encodedBytes: Uint8Array","typeStrings: string[]","heads: Uint8Array[]","tails: Uint8Array[]","values: ABIValue[]","childType: ABIType","length: number","structName: string","structFields: ABIStructField[]","dynamicSegments: Segment[]","valuePartitions: (Uint8Array | null)[]","result: Uint8Array[]","tupleStrings: string[]"],"sources":["../../../../packages/abi/src/abi-type.ts"],"sourcesContent":["import {\n Address,\n BOOL_FALSE_BYTE,\n BOOL_TRUE_BYTE,\n LENGTH_ENCODE_BYTE_SIZE,\n PUBLIC_KEY_BYTE_LENGTH,\n concatArrays,\n} from '@algorandfoundation/algokit-common'\nimport type { ABIStructValue, ABIValue } from './abi-value'\nimport { StructField } from './arc56-contract'\nimport { bigIntToBytes, bytesToBigInt } from './bigint'\n\nconst STATIC_ARRAY_REGEX = /^([a-z\\d[\\](),]+)\\[(0|[1-9][\\d]*)]$/\nconst UFIXED_REGEX = /^ufixed([1-9][\\d]*)x([1-9][\\d]*)$/\nconst MAX_LEN = 2 ** 16 - 1\n\n/**\n * Information about a single field in a struct\n */\nexport type ABIStructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | ABIStructField[]\n}\n\ninterface Segment {\n left: number\n right: number\n}\n\n/**\n * Represents an Algorand ABI type for encoding and decoding values as defined in [ARC-0004](https://arc.algorand.foundation/ARCs/arc-0004#types).\n *\n * This is the abstract base class for all ABI types.\n */\nexport abstract class ABIType {\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n abstract get name(): string\n\n /**\n * Returns a user-friendly display name for this type.\n * @returns The display name for this type\n */\n get displayName(): string {\n return this.name\n }\n\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n toString(): string {\n return this.name\n }\n\n /**\n * Checks if this ABI type is equal to another.\n * @param other The other ABI type to compare with\n * @returns True if the types are equal, false otherwise\n */\n abstract equals(other: ABIType): boolean\n\n /**\n * Checks if this ABI type is dynamic (variable-length).\n * @returns True if the type is dynamic, false otherwise\n */\n abstract isDynamic(): boolean\n\n /**\n * Gets the byte length of the encoded type for static types.\n * @returns The number of bytes needed to encode this type\n * @throws Error if the type is dynamic\n */\n abstract byteLen(): number\n\n /**\n * Encodes a value according to this ABI type.\n * @param value The value to encode\n * @returns The encoded bytes\n */\n abstract encode(value: ABIValue): Uint8Array\n\n /**\n * Decodes bytes according to this ABI type.\n * @param bytes The bytes to decode\n * @returns The decoded value\n */\n abstract decode(bytes: Uint8Array): ABIValue\n\n /**\n * Creates an ABI type from an ARC-4 type string.\n * @param str The ARC-4 type string (e.g., \"uint256\", \"bool\", \"(uint8,address)\")\n * @returns The corresponding ABI type\n */\n static from(str: string): ABIType {\n if (str.endsWith('[]')) {\n const childType = ABIType.from(str.slice(0, str.length - 2))\n return new ABIArrayDynamicType(childType)\n }\n if (str.endsWith(']')) {\n const stringMatches = str.match(STATIC_ARRAY_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed static array string: ${str}`)\n }\n const arrayLengthStr = stringMatches[2]\n const arrayLength = parseInt(arrayLengthStr, 10)\n if (arrayLength > MAX_LEN) {\n throw new Error(`Array length exceeds limit ${MAX_LEN}`)\n }\n const childType = ABIType.from(stringMatches[1])\n return new ABIArrayStaticType(childType, arrayLength)\n }\n if (str.startsWith('uint')) {\n const digitsOnly = (s: string) => [...s].every((c) => '0123456789'.includes(c))\n const typeSizeStr = str.slice(4, str.length)\n if (!digitsOnly(typeSizeStr)) {\n throw new Error(`Malformed uint string: ${typeSizeStr}`)\n }\n const bitSize = parseInt(typeSizeStr, 10)\n if (bitSize > MAX_LEN) {\n throw new Error(`Malformed uint string: ${bitSize}`)\n }\n return new ABIUintType(bitSize)\n }\n if (str === 'byte') {\n return new ABIByteType()\n }\n if (str.startsWith('ufixed')) {\n const stringMatches = str.match(UFIXED_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed ufixed type: ${str}`)\n }\n const bitSize = parseInt(stringMatches[1], 10)\n const precision = parseInt(stringMatches[2], 10)\n return new ABIUfixedType(bitSize, precision)\n }\n if (str === 'bool') {\n return new ABIBoolType()\n }\n if (str === 'address') {\n return new ABIAddressType()\n }\n if (str === 'string') {\n return new ABIStringType()\n }\n if (str.length >= 2 && str[0] === '(' && str[str.length - 1] === ')') {\n const tupleContent = parseTupleContent(str.slice(1, str.length - 1))\n const childTypes: ABIType[] = []\n for (let i = 0; i < tupleContent.length; i++) {\n const ti = ABIType.from(tupleContent[i])\n childTypes.push(ti)\n }\n return new ABITupleType(childTypes)\n }\n throw new Error(`Cannot convert a string ${str} to an ABI type`)\n }\n}\n\n// ============================================================================\n// Primitive Types\n// ============================================================================\n\n/**\n * An unsigned integer ABI type of a specific bit size.\n */\nexport class ABIUintType extends ABIType {\n /**\n * Creates a new unsigned integer type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n */\n constructor(public readonly bitSize: number) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported uint type bitSize: ${bitSize}`)\n }\n }\n\n get name(): string {\n return `uint${this.bitSize}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUintType && this.bitSize === other.bitSize\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * A fixed-point number ABI type of a specific bit size and precision.\n */\nexport class ABIUfixedType extends ABIType {\n /**\n * Creates a new fixed-point type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n * @param precision The decimal precision (must be between 1 and 160)\n */\n constructor(\n public readonly bitSize: number,\n public readonly precision: number,\n ) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported ufixed type bitSize: ${bitSize}`)\n }\n if (precision > 160 || precision < 1) {\n throw new Error(`Unsupported ufixed type precision: ${precision}`)\n }\n }\n\n get name(): string {\n return `ufixed${this.bitSize}x${this.precision}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUfixedType && this.bitSize === other.bitSize && this.precision === other.precision\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * An Algorand address ABI type.\n */\nexport class ABIAddressType extends ABIType {\n get name(): string {\n return 'address'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIAddressType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return PUBLIC_KEY_BYTE_LENGTH\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value === 'string') {\n return Address.fromString(value).publicKey\n }\n\n if (value instanceof Address) {\n return value.publicKey\n }\n\n if (value instanceof Uint8Array && value.length === 32) {\n return value\n }\n\n throw new Error(`Cannot encode value as address: ${value}`)\n }\n\n decode(bytes: Uint8Array): string {\n return new Address(bytes).toString()\n }\n}\n\n/**\n * A boolean ABI type.\n */\nexport class ABIBoolType extends ABIType {\n get name(): string {\n return 'bool'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIBoolType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'boolean') {\n throw new Error(`Cannot encode value as bool: ${value}`)\n }\n\n return value ? new Uint8Array([0x80]) : new Uint8Array([0x00])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for bool, got ${bytes.length}`)\n }\n\n return (bytes[0] & 0x80) !== 0\n }\n}\n\n/**\n * A single byte ABI type.\n */\nexport class ABIByteType extends ABIType {\n get name(): string {\n return 'byte'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIByteType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'number' && typeof value !== 'bigint') {\n throw new Error(`Cannot encode value as byte: ${value}`)\n }\n const numberValue = typeof value === 'bigint' ? Number(value) : value\n if (value < 0 || value > 255) {\n throw new Error(`Byte value must be between 0 and 255, got ${numberValue}`)\n }\n\n return new Uint8Array([numberValue])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for byte type, got ${bytes.length}`)\n }\n\n return bytes[0]\n }\n}\n\n/**\n * A dynamic-length string ABI type.\n */\nexport class ABIStringType extends ABIType {\n get name(): string {\n return 'string'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIStringType\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, string is a dynamic type`)\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'string' && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as string: ${value}`)\n }\n\n let encodedBytes: Uint8Array\n if (typeof value === 'string') {\n encodedBytes = new TextEncoder().encode(value)\n } else {\n encodedBytes = value\n }\n const encodedLength = bigIntToBytes(encodedBytes.length, LENGTH_ENCODE_BYTE_SIZE)\n const mergedBytes = new Uint8Array(encodedBytes.length + LENGTH_ENCODE_BYTE_SIZE)\n mergedBytes.set(encodedLength)\n mergedBytes.set(encodedBytes, LENGTH_ENCODE_BYTE_SIZE)\n return mergedBytes\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error(\n `Byte string is too short to be decoded. Actual length is ${bytes.length}, but expected at least ${LENGTH_ENCODE_BYTE_SIZE}`,\n )\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const byteValue = bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length)\n if (byteLength !== byteValue.length) {\n throw new Error(`String length bytes do not match the actual length of string. Expected ${byteLength}, got ${byteValue.length}`)\n }\n return new TextDecoder('utf-8').decode(byteValue)\n }\n}\n\n// ============================================================================\n// Collection Types\n// ============================================================================\n\n/**\n * A tuple ABI type containing other ABI types.\n */\nexport class ABITupleType extends ABIType {\n /**\n * Creates a new tuple type.\n * @param childTypes The types of the tuple elements\n */\n constructor(public readonly childTypes: ABIType[]) {\n super()\n if (childTypes.length > MAX_LEN) {\n throw new Error(`Tuple has too many child types: ${childTypes.length}`)\n }\n }\n\n get name(): string {\n const typeStrings: string[] = []\n for (let i = 0; i < this.childTypes.length; i++) {\n typeStrings[i] = this.childTypes[i].name\n }\n return `(${typeStrings.join(',')})`\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABITupleType)) return false\n if (this.childTypes.length !== other.childTypes.length) return false\n return this.childTypes.every((t, i) => t.equals(other.childTypes[i]))\n }\n\n isDynamic(): boolean {\n return this.childTypes.some((c) => c.isDynamic())\n }\n\n byteLen(): number {\n let size = 0\n let i = 0\n while (i < this.childTypes.length) {\n const childType = this.childTypes[i]\n if (childType instanceof ABIBoolType) {\n const sequenceEndIndex = findBoolSequenceEnd(this.childTypes, i)\n const boolCount = sequenceEndIndex - i + 1\n size += Math.ceil(boolCount / 8)\n i = sequenceEndIndex + 1\n } else {\n size += childType.byteLen()\n i++\n }\n }\n return size\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.toString()}: ${value}`)\n }\n\n const values = Array.from(value)\n\n if (this.childTypes.length !== values.length) {\n throw new Error('Mismatch lengths between the values and types')\n }\n\n const heads: Uint8Array[] = []\n const tails: Uint8Array[] = []\n const isDynamicIndex = new Map<number, boolean>()\n let abiTypesCursor = 0\n\n while (abiTypesCursor < this.childTypes.length) {\n const childType = this.childTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n isDynamicIndex.set(heads.length, true)\n heads.push(new Uint8Array(2)) // Placeholder for dynamic offset\n tails.push(childType.encode(values[abiTypesCursor]))\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(this.childTypes, abiTypesCursor)\n const boolValues = values.slice(abiTypesCursor, boolSequenceEndIndex + 1)\n const compressedBool = compressBools(boolValues)\n heads.push(new Uint8Array([compressedBool]))\n abiTypesCursor = boolSequenceEndIndex\n } else {\n heads.push(childType.encode(values[abiTypesCursor]))\n }\n isDynamicIndex.set(abiTypesCursor, false)\n tails.push(new Uint8Array(0))\n }\n abiTypesCursor += 1\n }\n\n const headLength = heads.reduce((sum, head) => sum + head.length, 0)\n let tailLength = 0\n\n for (let i = 0; i < heads.length; i++) {\n if (isDynamicIndex.get(i)) {\n const headValue = headLength + tailLength\n if (headValue > 0xffff) {\n throw new Error(`Value ${headValue} cannot fit in u16`)\n }\n heads[i] = new Uint8Array([(headValue >> 8) & 0xff, headValue & 0xff])\n }\n tailLength += tails[i].length\n }\n\n const totalLength = heads.reduce((sum, head) => sum + head.length, 0) + tails.reduce((sum, tail) => sum + tail.length, 0)\n const result = new Uint8Array(totalLength)\n let offset = 0\n\n for (const head of heads) {\n result.set(head, offset)\n offset += head.length\n }\n\n for (const tail of tails) {\n result.set(tail, offset)\n offset += tail.length\n }\n\n return result\n }\n\n decode(bytes: Uint8Array): ABIValue[] {\n const valuePartitions = extractValues(this.childTypes, bytes)\n const values: ABIValue[] = []\n\n for (let i = 0; i < this.childTypes.length; i++) {\n const childType = this.childTypes[i]\n const valuePartition = valuePartitions[i]\n const childValue = childType.decode(valuePartition)\n values.push(childValue)\n }\n\n return values\n }\n}\n\n/**\n * A static-length array ABI type.\n */\nexport class ABIArrayStaticType extends ABIType {\n /**\n * Creates a new static array type.\n * @param childType The type of the array elements\n * @param length The fixed length of the array\n */\n constructor(\n public readonly childType: ABIType,\n public readonly length: number,\n ) {\n super()\n if (length < 0 || length > MAX_LEN) {\n throw new Error(`Invalid static array length: ${length}`)\n }\n }\n\n get name(): string {\n return `${this.childType.name}[${this.length}]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayStaticType && this.childType.equals(other.childType) && this.length === other.length\n }\n\n isDynamic(): boolean {\n return this.childType.isDynamic()\n }\n\n byteLen(): number {\n if (this.childType instanceof ABIBoolType) {\n return Math.ceil(this.length / 8)\n }\n return this.childType.byteLen() * this.length\n }\n\n /**\n * Converts this static array type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n return new ABITupleType(Array(this.length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value.length !== this.length) {\n throw new Error(`Value array does not match static array length. Expected ${this.length}, got ${value.length}`)\n }\n const convertedTuple = this.toABITupleType()\n return convertedTuple.encode(value)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const convertedTuple = this.toABITupleType()\n const decoded = convertedTuple.decode(bytes)\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A dynamic-length array ABI type.\n */\nexport class ABIArrayDynamicType extends ABIType {\n /**\n * Creates a new dynamic array type.\n * @param childType The type of the array elements\n */\n constructor(public readonly childType: ABIType) {\n super()\n }\n\n get name(): string {\n return `${this.childType.name}[]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayDynamicType && this.childType.equals(other.childType)\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, dynamic array is a dynamic type`)\n }\n\n /**\n * Converts this dynamic array type to an equivalent tuple type of a given length.\n * @param length The number of elements\n * @returns The equivalent tuple type\n */\n toABITupleType(length: number): ABITupleType {\n return new ABITupleType(Array(length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n const convertedTuple = this.toABITupleType(value.length)\n const encodedTuple = convertedTuple.encode(value)\n const encodedLength = bigIntToBytes(convertedTuple.childTypes.length, LENGTH_ENCODE_BYTE_SIZE)\n return concatArrays(encodedLength, encodedTuple)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const view = new DataView(bytes.buffer, 0, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const convertedTuple = this.toABITupleType(byteLength)\n const decoded = convertedTuple.decode(bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length))\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A struct ABI type with named fields.\n */\nexport class ABIStructType extends ABIType {\n /**\n * Creates a new struct type.\n * @param structName The name of the struct\n * @param structFields The fields of the struct\n */\n constructor(\n public readonly structName: string,\n public readonly structFields: ABIStructField[],\n ) {\n super()\n }\n\n get name(): string {\n const tupleType = this.toABITupleType()\n return tupleType.name\n }\n\n get displayName(): string {\n return this.structName\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABIStructType)) return false\n if (this.structName !== other.structName) return false\n if (this.structFields.length !== other.structFields.length) return false\n return this.structFields.every((f, i) => {\n const otherField = other.structFields[i]\n if (f.name !== otherField.name) return false\n if (Array.isArray(f.type) && Array.isArray(otherField.type)) {\n return JSON.stringify(f.type) === JSON.stringify(otherField.type)\n }\n if (f.type instanceof ABIType && otherField.type instanceof ABIType) {\n return f.type.equals(otherField.type)\n }\n return false\n })\n }\n\n isDynamic(): boolean {\n const tupleType = this.toABITupleType()\n return tupleType.isDynamic()\n }\n\n byteLen(): number {\n const tupleType = this.toABITupleType()\n return tupleType.byteLen()\n }\n\n /**\n * Converts this struct type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n const getABITupleTypeFromABIStructFields = (fields: ABIStructField[]): ABITupleType => {\n const childTypes = fields.map((field) =>\n Array.isArray(field.type)\n ? getABITupleTypeFromABIStructFields(field.type)\n : field.type instanceof ABIStructType\n ? field.type.toABITupleType()\n : field.type,\n )\n return new ABITupleType(childTypes)\n }\n\n return getABITupleTypeFromABIStructFields(this.structFields)\n }\n\n /**\n * Creates an ABIStructType from struct name and struct definitions.\n * @param structName The name of the struct\n * @param structs A record of struct definitions\n * @returns The struct type\n */\n static fromStruct(structName: string, structs: Record<string, StructField[]>): ABIStructType {\n const getStructFieldType = (structFieldType: string | StructField[]): ABIType | ABIStructField[] => {\n // When the input is an array of struct fields\n if (Array.isArray(structFieldType)) {\n return structFieldType.map((structField) => ({\n name: structField.name,\n type: getStructFieldType(structField.type),\n }))\n }\n\n // When the input is a name of another struct\n if (structs[structFieldType]) {\n return ABIStructType.fromStruct(structFieldType, structs)\n }\n\n // When the input in an ABI type name\n return ABIType.from(structFieldType)\n }\n\n if (!structs[structName]) throw new Error('Struct not found')\n\n const fields = structs[structName]\n return new ABIStructType(\n structName,\n fields.map((f) => ({\n name: f.name,\n type: getStructFieldType(f.type),\n })),\n )\n }\n\n encode(value: ABIValue): Uint8Array {\n if (value instanceof Uint8Array || value instanceof Address || typeof value !== 'object') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n const tupleType = this.toABITupleType()\n if (Array.isArray(value)) {\n return tupleType.encode(value)\n }\n\n const tupleValue = this.getTupleValueFromStructValue(value)\n return tupleType.encode(tupleValue)\n }\n\n decode(bytes: Uint8Array): ABIStructValue {\n const tupleType = this.toABITupleType()\n const tupleValue = tupleType.decode(bytes)\n return this.getStructValueFromTupleValue(tupleValue)\n }\n\n private getTupleValueFromStructValue(structValue: ABIStructValue): ABIValue[] {\n const getTupleValueFromStructFields = (structFields: ABIStructField[], values: ABIValue[]): ABIValue[] => {\n return structFields.map(({ type }, index) => {\n // if type is an array of fields, treat as unnamed struct\n if (Array.isArray(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type, Object.values(value))\n }\n // if type is struct, treat as struct\n if (type instanceof ABIStructType) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type.structFields, Object.values(value))\n }\n return values[index]\n })\n }\n\n return getTupleValueFromStructFields(this.structFields, Object.values(structValue))\n }\n\n private getStructValueFromTupleValue(tupleValue: ABIValue[]): ABIStructValue {\n const getStructFieldValues = (structFields: ABIStructField[], values: ABIValue[]): ABIStructValue => {\n return Object.fromEntries(\n structFields.map(({ name, type }, index) => {\n // When the type is an array of fields, the value must be tuple\n if (Array.isArray(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type, value)]\n }\n // When the type is a struct, the value must be tuple\n if (type instanceof ABIStructType) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type.structFields, value)]\n }\n return [name, values[index]]\n }),\n )\n }\n\n return getStructFieldValues(this.structFields, tupleValue)\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction compressBools(values: ABIValue[]): number {\n if (values.length > 8) {\n throw new Error(`Expected no more than 8 bool values, received ${values.length}`)\n }\n\n let result = 0\n for (let i = 0; i < values.length; i++) {\n if (typeof values[i] !== 'boolean') {\n throw new Error('Expected all values to be boolean')\n }\n if (values[i]) {\n result |= 1 << (7 - i)\n }\n }\n\n return result\n}\n\nfunction findBoolSequenceEnd(abiTypes: ABIType[], currentIndex: number): number {\n let cursor = currentIndex\n while (cursor < abiTypes.length) {\n if (abiTypes[cursor] instanceof ABIBoolType) {\n if (cursor - currentIndex + 1 === 8 || cursor === abiTypes.length - 1) {\n return cursor\n }\n cursor++\n } else {\n return cursor - 1\n }\n }\n return cursor - 1\n}\n\nfunction extractValues(abiTypes: ABIType[], bytes: Uint8Array): Uint8Array[] {\n const dynamicSegments: Segment[] = []\n const valuePartitions: (Uint8Array | null)[] = []\n let bytesCursor = 0\n let abiTypesCursor = 0\n\n while (abiTypesCursor < abiTypes.length) {\n const childType = abiTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n if (bytes.length - bytesCursor < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error('Byte array is too short to be decoded')\n }\n\n const dynamicIndex = (bytes[bytesCursor] << 8) | bytes[bytesCursor + 1]\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n if (dynamicIndex < lastSegment.left) {\n throw new Error('Dynamic index segment miscalculation: left is greater than right index')\n }\n lastSegment.right = dynamicIndex\n }\n\n dynamicSegments.push({ left: dynamicIndex, right: 0 })\n valuePartitions.push(null)\n bytesCursor += LENGTH_ENCODE_BYTE_SIZE\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(abiTypes, abiTypesCursor)\n for (let j = 0; j <= boolSequenceEndIndex - abiTypesCursor; j++) {\n const boolMask = BOOL_TRUE_BYTE >> j\n if ((bytes[bytesCursor] & boolMask) > 0) {\n valuePartitions.push(new Uint8Array([BOOL_TRUE_BYTE]))\n } else {\n valuePartitions.push(new Uint8Array([BOOL_FALSE_BYTE]))\n }\n }\n abiTypesCursor = boolSequenceEndIndex\n bytesCursor += 1\n } else {\n const childTypeSize = childType.byteLen()\n if (bytesCursor + childTypeSize > bytes.length) {\n throw new Error(\n `Index out of bounds, trying to access bytes[${bytesCursor}..${bytesCursor + childTypeSize}] but slice has length ${bytes.length}`,\n )\n }\n valuePartitions.push(bytes.slice(bytesCursor, bytesCursor + childTypeSize))\n bytesCursor += childTypeSize\n }\n }\n\n if (abiTypesCursor !== abiTypes.length - 1 && bytesCursor >= bytes.length) {\n throw new Error('Input bytes not enough to decode')\n }\n abiTypesCursor += 1\n }\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n lastSegment.right = bytes.length\n } else if (bytesCursor < bytes.length) {\n throw new Error('Input bytes not fully consumed')\n }\n\n for (let i = 0; i < dynamicSegments.length; i++) {\n const segment = dynamicSegments[i]\n if (segment.left > segment.right) {\n throw new Error('Dynamic segment should display a [l, r] space with l <= r')\n }\n if (i !== dynamicSegments.length - 1 && segment.right !== dynamicSegments[i + 1].left) {\n throw new Error('Dynamic segments should be consecutive')\n }\n }\n\n let segmentIndex = 0\n for (let i = 0; i < abiTypes.length; i++) {\n const childType = abiTypes[i]\n if (childType.isDynamic()) {\n valuePartitions[i] = bytes.slice(dynamicSegments[segmentIndex].left, dynamicSegments[segmentIndex].right)\n segmentIndex += 1\n }\n }\n\n const result: Uint8Array[] = []\n for (let i = 0; i < valuePartitions.length; i++) {\n const partition = valuePartitions[i]\n if (partition === null) {\n throw new Error(`Value partition at index ${i} is None`)\n }\n result.push(partition)\n }\n\n return result\n}\n\nexport function parseTupleContent(content: string): string[] {\n if (content === '') {\n return []\n }\n\n if (content.startsWith(',')) {\n throw new Error('The content should not start with comma')\n }\n if (content.endsWith(',')) {\n throw new Error('The content should not end with comma')\n }\n if (content.includes(',,')) {\n throw new Error('The content should not have consecutive commas')\n }\n\n const tupleStrings: string[] = []\n let depth = 0\n let word = ''\n\n for (const ch of content) {\n word += ch\n if (ch === '(') {\n depth += 1\n } else if (ch === ')') {\n depth -= 1\n } else if (ch === ',' && depth === 0) {\n word = word.slice(0, -1) // Remove the comma\n tupleStrings.push(word)\n word = ''\n }\n }\n\n if (word !== '') {\n tupleStrings.push(word)\n }\n\n if (depth !== 0) {\n throw new Error('The content has mismatched parentheses')\n }\n\n return tupleStrings\n}\n"],"mappings":";;;;;;AAYA,MAAM,qBAAqB;AAC3B,MAAM,eAAe;AACrB,MAAM,UAAU,KAAK,KAAK;;;;;;AAsB1B,IAAsB,UAAtB,MAAsB,QAAQ;;;;;CAW5B,IAAI,cAAsB;AACxB,SAAO,KAAK;;;;;;CAOd,WAAmB;AACjB,SAAO,KAAK;;;;;;;CA0Cd,OAAO,KAAK,KAAsB;AAChC,MAAI,IAAI,SAAS,KAAK,CAEpB,QAAO,IAAI,oBADO,QAAQ,KAAK,IAAI,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,CACnB;AAE3C,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,gBAAgB,IAAI,MAAM,mBAAmB;AACnD,OAAI,CAAC,iBAAiB,cAAc,WAAW,EAC7C,OAAM,IAAI,MAAM,kCAAkC,MAAM;GAE1D,MAAM,iBAAiB,cAAc;GACrC,MAAM,cAAc,SAAS,gBAAgB,GAAG;AAChD,OAAI,cAAc,QAChB,OAAM,IAAI,MAAM,8BAA8B,UAAU;AAG1D,UAAO,IAAI,mBADO,QAAQ,KAAK,cAAc,GAAG,EACP,YAAY;;AAEvD,MAAI,IAAI,WAAW,OAAO,EAAE;GAC1B,MAAM,cAAc,MAAc,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,aAAa,SAAS,EAAE,CAAC;GAC/E,MAAM,cAAc,IAAI,MAAM,GAAG,IAAI,OAAO;AAC5C,OAAI,CAAC,WAAW,YAAY,CAC1B,OAAM,IAAI,MAAM,0BAA0B,cAAc;GAE1D,MAAM,UAAU,SAAS,aAAa,GAAG;AACzC,OAAI,UAAU,QACZ,OAAM,IAAI,MAAM,0BAA0B,UAAU;AAEtD,UAAO,IAAI,YAAY,QAAQ;;AAEjC,MAAI,QAAQ,OACV,QAAO,IAAI,aAAa;AAE1B,M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,UAAU,GAAG;AACpC,UAAO,KAAK,MAAM,GAAG,GAAG;AACxB,gBAAa,KAAK,KAAK;AACvB,UAAO;;;AAIX,KAAI,SAAS,GACX,cAAa,KAAK,KAAK;AAGzB,KAAI,UAAU,EACZ,OAAM,IAAI,MAAM,yCAAyC;AAG3D,QAAO"}
@@ -1,6 +1,7 @@
1
1
  const require_abi_type = require('./abi-type.js');
2
2
 
3
3
  //#region packages/abi/src/arc56-contract.ts
4
+ /** ARC-56 spec */
4
5
  /** Storage Helper Functions */
5
6
  /**
6
7
  * Resolves a storage type string (ABI type, AVM type, or struct name) into an ABIType or AVMType
@@ -1 +1 @@
1
- {"version":3,"file":"arc56-contract.js","names":["ABIStructType","ABIType","result: Record<string, ABIStorageKey>","result: Record<string, ABIStorageMap>"],"sources":["../../../../packages/abi/src/arc56-contract.ts"],"sourcesContent":["/****************/\n/** ARC-56 spec */\n/****************/\n\nimport { ABIStructType, ABIType } from './abi-type'\n\n/** Describes a single key in app storage with parsed ABI types */\nexport type ABIStorageKey = {\n /** The bytes of the key encoded as base64 */\n key: string\n /** The parsed type of the key (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the value (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what this storage key holds */\n desc?: string\n}\n\n/** Describes a storage map with parsed ABI types */\nexport type ABIStorageMap = {\n /** The parsed type of the keys in the map (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the values in the map (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The base64-encoded prefix of the map keys */\n prefix?: string\n}\n\n/** Describes the entire contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Contract = {\n /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the type */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be defined\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Arc56Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: ProgramSourceInfo\n /** Clear program information */\n clear: ProgramSourceInfo\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABITypeName | AVMType | StructName\n /** If given, the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABITypeName | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Method = {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABITypeName | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value\n */\n source: 'box' | 'global' | 'local' | 'literal' | 'method'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport type Event = {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABITypeName = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport type StructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABITypeName | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport type StorageKey = {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABITypeName | AVMType | StructName\n\n /** The type of the value */\n valueType: ABITypeName | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport type StorageMap = {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABITypeName | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABITypeName | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\ntype SourceInfo = {\n /** The program counter value(s). Could be offset if pcOffsetMethod is not \"none\" */\n pc: Array<number>\n /** A human-readable string that describes the error when the program fails at the given PC */\n errorMessage?: string\n /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n teal?: number\n /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n source?: string\n}\n\nexport type ProgramSourceInfo = {\n /** The source information for the program */\n sourceInfo: SourceInfo[]\n /** How the program counter offset is calculated\n * - none: The pc values in sourceInfo are not offset\n * - cblocks: The pc values in sourceInfo are offset by the PC of the first op following the last cblock at the top of the program\n */\n pcOffsetMethod: 'none' | 'cblocks'\n}\n\n/*************************/\n/** Storage Helper Functions */\n/*************************/\n\n/**\n * Resolves a storage type string (ABI type, AVM type, or struct name) into an ABIType or AVMType\n * @param typeStr The type string to resolve\n * @param structs The structs defined in the contract\n * @returns The parsed ABIType or AVMType string\n */\nfunction resolveStorageType(typeStr: string, structs: Record<string, StructField[]>): ABIType | AVMType {\n // Check if it's an AVM type\n if (typeStr === 'AVMBytes' || typeStr === 'AVMString' || typeStr === 'AVMUint64') {\n return typeStr as AVMType\n }\n\n // Check if it's a struct type\n if (structs[typeStr]) {\n return ABIStructType.fromStruct(typeStr, structs)\n }\n\n // Otherwise parse as ABI type\n try {\n return ABIType.from(typeStr)\n } catch (error) {\n throw new Error(`Failed to parse storage type '${typeStr}': ${error}`)\n }\n}\n\n/**\n * Converts a StorageKey to an ABIStorageKey with parsed types\n * @param storageKey The storage key to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageKey\n */\nfunction convertStorageKey(storageKey: StorageKey, structs: Record<string, StructField[]>): ABIStorageKey {\n const keyType = resolveStorageType(storageKey.keyType, structs)\n const valueType = resolveStorageType(storageKey.valueType, structs)\n\n return {\n key: storageKey.key,\n keyType,\n valueType,\n desc: storageKey.desc,\n }\n}\n\n/**\n * Converts a StorageMap to an ABIStorageMap with parsed types\n * @param storageMap The storage map to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageMap\n */\nfunction convertStorageMap(storageMap: StorageMap, structs: Record<string, StructField[]>): ABIStorageMap {\n const keyType = resolveStorageType(storageMap.keyType, structs)\n const valueType = resolveStorageType(storageMap.valueType, structs)\n\n return {\n keyType,\n valueType,\n desc: storageMap.desc,\n prefix: storageMap.prefix,\n }\n}\n\n/**\n * Get a specific global storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getGlobalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.global[keyName]\n if (!storageKey) {\n throw new Error(`Global storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific local storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getLocalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.local[keyName]\n if (!storageKey) {\n throw new Error(`Local storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific box storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getBoxABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.box[keyName]\n if (!storageKey) {\n throw new Error(`Box storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get all global storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getGlobalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.global)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getLocalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.local)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getBoxABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.box)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get a specific global storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getGlobalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.global[mapName]\n if (!storageMap) {\n throw new Error(`Global storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific local storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getLocalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.local[mapName]\n if (!storageMap) {\n throw new Error(`Local storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific box storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getBoxABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.box[mapName]\n if (!storageMap) {\n throw new Error(`Box storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get all global storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getGlobalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.global)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getLocalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.local)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getBoxABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.box)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n"],"mappings":";;;;;;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AA2B,SAAS,KAAK,GAAG;AAE1F,QAAO,kBAAkB,YAAY,SAAS,QAAQ;;;;;;;AAQxD,SAAgB,wBAAwB,UAAwD;CAC9F,MAAMC,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,OAAO,CACzE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO;;;;;;;AAQT,SAAgB,uBAAuB,UAAwD;CAC7F,MAAMA,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,MAAM,CACxE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO;;;;;;;AAQT,SAAgB,qBAAqB,UAAwD;CAC3F,MAAMA,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,IAAI,CACtE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO"}
1
+ {"version":3,"file":"arc56-contract.js","names":["ABIStructType","ABIType","result: Record<string, ABIStorageKey>","result: Record<string, ABIStorageMap>"],"sources":["../../../../packages/abi/src/arc56-contract.ts"],"sourcesContent":["/****************/\n/** ARC-56 spec */\n/****************/\n\nimport { ABIStructType, ABIType } from './abi-type'\n\n/** Describes a single key in app storage with parsed ABI types */\nexport type ABIStorageKey = {\n /** The bytes of the key encoded as base64 */\n key: string\n /** The parsed type of the key (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the value (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what this storage key holds */\n desc?: string\n}\n\n/** Describes a storage map with parsed ABI types */\nexport type ABIStorageMap = {\n /** The parsed type of the keys in the map (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the values in the map (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The base64-encoded prefix of the map keys */\n prefix?: string\n}\n\n/** Describes the entire contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Contract = {\n /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the type */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be defined\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Arc56Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: ProgramSourceInfo\n /** Clear program information */\n clear: ProgramSourceInfo\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABITypeName | AVMType | StructName\n /** If given, the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABITypeName | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Method = {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABITypeName | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value\n */\n source: 'box' | 'global' | 'local' | 'literal' | 'method'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport type Event = {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABITypeName = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport type StructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABITypeName | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport type StorageKey = {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABITypeName | AVMType | StructName\n\n /** The type of the value */\n valueType: ABITypeName | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport type StorageMap = {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABITypeName | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABITypeName | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\ntype SourceInfo = {\n /** The program counter value(s). Could be offset if pcOffsetMethod is not \"none\" */\n pc: Array<number>\n /** A human-readable string that describes the error when the program fails at the given PC */\n errorMessage?: string\n /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n teal?: number\n /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n source?: string\n}\n\nexport type ProgramSourceInfo = {\n /** The source information for the program */\n sourceInfo: SourceInfo[]\n /** How the program counter offset is calculated\n * - none: The pc values in sourceInfo are not offset\n * - cblocks: The pc values in sourceInfo are offset by the PC of the first op following the last cblock at the top of the program\n */\n pcOffsetMethod: 'none' | 'cblocks'\n}\n\n/*************************/\n/** Storage Helper Functions */\n/*************************/\n\n/**\n * Resolves a storage type string (ABI type, AVM type, or struct name) into an ABIType or AVMType\n * @param typeStr The type string to resolve\n * @param structs The structs defined in the contract\n * @returns The parsed ABIType or AVMType string\n */\nfunction resolveStorageType(typeStr: string, structs: Record<string, StructField[]>): ABIType | AVMType {\n // Check if it's an AVM type\n if (typeStr === 'AVMBytes' || typeStr === 'AVMString' || typeStr === 'AVMUint64') {\n return typeStr as AVMType\n }\n\n // Check if it's a struct type\n if (structs[typeStr]) {\n return ABIStructType.fromStruct(typeStr, structs)\n }\n\n // Otherwise parse as ABI type\n try {\n return ABIType.from(typeStr)\n } catch (error) {\n throw new Error(`Failed to parse storage type '${typeStr}': ${error}`)\n }\n}\n\n/**\n * Converts a StorageKey to an ABIStorageKey with parsed types\n * @param storageKey The storage key to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageKey\n */\nfunction convertStorageKey(storageKey: StorageKey, structs: Record<string, StructField[]>): ABIStorageKey {\n const keyType = resolveStorageType(storageKey.keyType, structs)\n const valueType = resolveStorageType(storageKey.valueType, structs)\n\n return {\n key: storageKey.key,\n keyType,\n valueType,\n desc: storageKey.desc,\n }\n}\n\n/**\n * Converts a StorageMap to an ABIStorageMap with parsed types\n * @param storageMap The storage map to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageMap\n */\nfunction convertStorageMap(storageMap: StorageMap, structs: Record<string, StructField[]>): ABIStorageMap {\n const keyType = resolveStorageType(storageMap.keyType, structs)\n const valueType = resolveStorageType(storageMap.valueType, structs)\n\n return {\n keyType,\n valueType,\n desc: storageMap.desc,\n prefix: storageMap.prefix,\n }\n}\n\n/**\n * Get a specific global storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getGlobalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.global[keyName]\n if (!storageKey) {\n throw new Error(`Global storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific local storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getLocalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.local[keyName]\n if (!storageKey) {\n throw new Error(`Local storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific box storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getBoxABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.box[keyName]\n if (!storageKey) {\n throw new Error(`Box storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get all global storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getGlobalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.global)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getLocalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.local)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getBoxABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.box)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get a specific global storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getGlobalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.global[mapName]\n if (!storageMap) {\n throw new Error(`Global storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific local storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getLocalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.local[mapName]\n if (!storageMap) {\n throw new Error(`Local storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific box storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getBoxABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.box[mapName]\n if (!storageMap) {\n throw new Error(`Box storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get all global storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getGlobalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.global)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getLocalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.local)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getBoxABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.box)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;AA6TA,SAAS,mBAAmB,SAAiB,SAA2D;AAEtG,KAAI,YAAY,cAAc,YAAY,eAAe,YAAY,YACnE,QAAO;AAIT,KAAI,QAAQ,SACV,QAAOA,+BAAc,WAAW,SAAS,QAAQ;AAInD,KAAI;AACF,SAAOC,yBAAQ,KAAK,QAAQ;UACrB,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,QAAQ,KAAK,QAAQ;;;;;;;;;AAU1E,SAAS,kBAAkB,YAAwB,SAAuD;CACxG,MAAM,UAAU,mBAAmB,WAAW,SAAS,QAAQ;CAC/D,MAAM,YAAY,mBAAmB,WAAW,WAAW,QAAQ;AAEnE,QAAO;EACL,KAAK,WAAW;EAChB;EACA;EACA,MAAM,WAAW;EAClB;;;;;;;;AASH,SAAS,kBAAkB,YAAwB,SAAuD;AAIxG,QAAO;EACL,SAJc,mBAAmB,WAAW,SAAS,QAAQ;EAK7D,WAJgB,mBAAmB,WAAW,WAAW,QAAQ;EAKjE,MAAM,WAAW;EACjB,QAAQ,WAAW;EACpB;;;;;;;;;AAUH,SAAgB,uBAAuB,UAAyB,SAAgC;CAC9F,MAAM,aAAa,SAAS,MAAM,KAAK,OAAO;AAC9C,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,uBAAuB,QAAQ,2BAA2B,SAAS,KAAK,GAAG;AAE7F,QAAO,kBAAkB,YAAY,SAAS,QAAQ;;;;;;;;;AAUxD,SAAgB,sBAAsB,UAAyB,SAAgC;CAC7F,MAAM,aAAa,SAAS,MAAM,KAAK,MAAM;AAC7C,KAAI,CAAC,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CAAC,WACH,OAAM,IAAI,MAAM,sBAAsB,QAAQ,2BAA2B,SAAS,KAAK,GAAG;AAE5F,QAAO,kBAAkB,YAAY,SAAS,QAAQ;;;;;;;;;AAUxD,SAAgB,oBAAoB,UAAyB,SAAgC;CAC3F,MAAM,aAAa,SAAS,MAAM,KAAK,IAAI;AAC3C,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,oBAAoB,QAAQ,2BAA2B,SAAS,KAAK,GAAG;AAE1F,QAAO,kBAAkB,YAAY,SAAS,QAAQ;;;;;;;AAQxD,SAAgB,wBAAwB,UAAwD;CAC9F,MAAMC,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,OAAO,CACzE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO;;;;;;;AAQT,SAAgB,uBAAuB,UAAwD;CAC7F,MAAMA,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,MAAM,CACxE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO;;;;;;;AAQT,SAAgB,qBAAqB,UAAwD;CAC3F,MAAMA,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,IAAI,CACtE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO"}
@@ -1,6 +1,7 @@
1
1
  import { ABIStructType, ABIType } from "./abi-type.mjs";
2
2
 
3
3
  //#region packages/abi/src/arc56-contract.ts
4
+ /** ARC-56 spec */
4
5
  /** Storage Helper Functions */
5
6
  /**
6
7
  * Resolves a storage type string (ABI type, AVM type, or struct name) into an ABIType or AVMType
@@ -1 +1 @@
1
- {"version":3,"file":"arc56-contract.mjs","names":["result: Record<string, ABIStorageKey>","result: Record<string, ABIStorageMap>"],"sources":["../../../../packages/abi/src/arc56-contract.ts"],"sourcesContent":["/****************/\n/** ARC-56 spec */\n/****************/\n\nimport { ABIStructType, ABIType } from './abi-type'\n\n/** Describes a single key in app storage with parsed ABI types */\nexport type ABIStorageKey = {\n /** The bytes of the key encoded as base64 */\n key: string\n /** The parsed type of the key (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the value (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what this storage key holds */\n desc?: string\n}\n\n/** Describes a storage map with parsed ABI types */\nexport type ABIStorageMap = {\n /** The parsed type of the keys in the map (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the values in the map (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The base64-encoded prefix of the map keys */\n prefix?: string\n}\n\n/** Describes the entire contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Contract = {\n /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the type */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be defined\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Arc56Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: ProgramSourceInfo\n /** Clear program information */\n clear: ProgramSourceInfo\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABITypeName | AVMType | StructName\n /** If given, the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABITypeName | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Method = {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABITypeName | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value\n */\n source: 'box' | 'global' | 'local' | 'literal' | 'method'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport type Event = {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABITypeName = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport type StructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABITypeName | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport type StorageKey = {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABITypeName | AVMType | StructName\n\n /** The type of the value */\n valueType: ABITypeName | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport type StorageMap = {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABITypeName | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABITypeName | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\ntype SourceInfo = {\n /** The program counter value(s). Could be offset if pcOffsetMethod is not \"none\" */\n pc: Array<number>\n /** A human-readable string that describes the error when the program fails at the given PC */\n errorMessage?: string\n /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n teal?: number\n /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n source?: string\n}\n\nexport type ProgramSourceInfo = {\n /** The source information for the program */\n sourceInfo: SourceInfo[]\n /** How the program counter offset is calculated\n * - none: The pc values in sourceInfo are not offset\n * - cblocks: The pc values in sourceInfo are offset by the PC of the first op following the last cblock at the top of the program\n */\n pcOffsetMethod: 'none' | 'cblocks'\n}\n\n/*************************/\n/** Storage Helper Functions */\n/*************************/\n\n/**\n * Resolves a storage type string (ABI type, AVM type, or struct name) into an ABIType or AVMType\n * @param typeStr The type string to resolve\n * @param structs The structs defined in the contract\n * @returns The parsed ABIType or AVMType string\n */\nfunction resolveStorageType(typeStr: string, structs: Record<string, StructField[]>): ABIType | AVMType {\n // Check if it's an AVM type\n if (typeStr === 'AVMBytes' || typeStr === 'AVMString' || typeStr === 'AVMUint64') {\n return typeStr as AVMType\n }\n\n // Check if it's a struct type\n if (structs[typeStr]) {\n return ABIStructType.fromStruct(typeStr, structs)\n }\n\n // Otherwise parse as ABI type\n try {\n return ABIType.from(typeStr)\n } catch (error) {\n throw new Error(`Failed to parse storage type '${typeStr}': ${error}`)\n }\n}\n\n/**\n * Converts a StorageKey to an ABIStorageKey with parsed types\n * @param storageKey The storage key to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageKey\n */\nfunction convertStorageKey(storageKey: StorageKey, structs: Record<string, StructField[]>): ABIStorageKey {\n const keyType = resolveStorageType(storageKey.keyType, structs)\n const valueType = resolveStorageType(storageKey.valueType, structs)\n\n return {\n key: storageKey.key,\n keyType,\n valueType,\n desc: storageKey.desc,\n }\n}\n\n/**\n * Converts a StorageMap to an ABIStorageMap with parsed types\n * @param storageMap The storage map to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageMap\n */\nfunction convertStorageMap(storageMap: StorageMap, structs: Record<string, StructField[]>): ABIStorageMap {\n const keyType = resolveStorageType(storageMap.keyType, structs)\n const valueType = resolveStorageType(storageMap.valueType, structs)\n\n return {\n keyType,\n valueType,\n desc: storageMap.desc,\n prefix: storageMap.prefix,\n }\n}\n\n/**\n * Get a specific global storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getGlobalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.global[keyName]\n if (!storageKey) {\n throw new Error(`Global storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific local storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getLocalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.local[keyName]\n if (!storageKey) {\n throw new Error(`Local storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific box storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getBoxABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.box[keyName]\n if (!storageKey) {\n throw new Error(`Box storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get all global storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getGlobalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.global)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getLocalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.local)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getBoxABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.box)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get a specific global storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getGlobalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.global[mapName]\n if (!storageMap) {\n throw new Error(`Global storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific local storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getLocalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.local[mapName]\n if (!storageMap) {\n throw new Error(`Local storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific box storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getBoxABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.box[mapName]\n if (!storageMap) {\n throw new Error(`Box storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get all global storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getGlobalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.global)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getLocalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.local)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getBoxABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.box)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n"],"mappings":";;;;;;;;;;AA6TA,SAAS,mBAAmB,SAAiB,SAA2D;AAEtG,KAAI,YAAY,cAAc,YAAY,eAAe,YAAY,YACnE,QAAO;AAIT,KAAI,QAAQ,SACV,QAAO,cAAc,WAAW,SAAS,QAAQ;AAInD,KAAI;AACF,SAAO,QAAQ,KAAK,QAAQ;UACrB,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,QAAQ,KAAK,QAAQ;;;;;;;;;AAU1E,SAAS,kBAAkB,YAAwB,SAAuD;CACxG,MAAM,UAAU,mBAAmB,WAAW,SAAS,QAAQ;CAC/D,MAAM,YAAY,mBAAmB,WAAW,WAAW,QAAQ;AAEnE,QAAO;EACL,KAAK,WAAW;EAChB;EACA;EACA,MAAM,WAAW;EAClB;;;;;;;;AASH,SAAS,kBAAkB,YAAwB,SAAuD;AAIxG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AwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,IAAI,CACtE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO"}
1
+ {"version":3,"file":"arc56-contract.mjs","names":["result: Record<string, ABIStorageKey>","result: Record<string, ABIStorageMap>"],"sources":["../../../../packages/abi/src/arc56-contract.ts"],"sourcesContent":["/****************/\n/** ARC-56 spec */\n/****************/\n\nimport { ABIStructType, ABIType } from './abi-type'\n\n/** Describes a single key in app storage with parsed ABI types */\nexport type ABIStorageKey = {\n /** The bytes of the key encoded as base64 */\n key: string\n /** The parsed type of the key (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the value (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what this storage key holds */\n desc?: string\n}\n\n/** Describes a storage map with parsed ABI types */\nexport type ABIStorageMap = {\n /** The parsed type of the keys in the map (ABI type or AVM type) */\n keyType: ABIType | AVMType\n /** The parsed type of the values in the map (ABI type or AVM type) */\n valueType: ABIType | AVMType\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The base64-encoded prefix of the map keys */\n prefix?: string\n}\n\n/** Describes the entire contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Contract = {\n /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the type */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be defined\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Arc56Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: ProgramSourceInfo\n /** Clear program information */\n clear: ProgramSourceInfo\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABITypeName | AVMType | StructName\n /** If given, the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABITypeName | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This type is an extension of the type described in ARC-4 */\nexport type Arc56Method = {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABITypeName | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value\n */\n source: 'box' | 'global' | 'local' | 'literal' | 'method'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABITypeName\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport type Event = {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABITypeName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABITypeName = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport type StructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABITypeName | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport type StorageKey = {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABITypeName | AVMType | StructName\n\n /** The type of the value */\n valueType: ABITypeName | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport type StorageMap = {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABITypeName | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABITypeName | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\ntype SourceInfo = {\n /** The program counter value(s). Could be offset if pcOffsetMethod is not \"none\" */\n pc: Array<number>\n /** A human-readable string that describes the error when the program fails at the given PC */\n errorMessage?: string\n /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n teal?: number\n /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n source?: string\n}\n\nexport type ProgramSourceInfo = {\n /** The source information for the program */\n sourceInfo: SourceInfo[]\n /** How the program counter offset is calculated\n * - none: The pc values in sourceInfo are not offset\n * - cblocks: The pc values in sourceInfo are offset by the PC of the first op following the last cblock at the top of the program\n */\n pcOffsetMethod: 'none' | 'cblocks'\n}\n\n/*************************/\n/** Storage Helper Functions */\n/*************************/\n\n/**\n * Resolves a storage type string (ABI type, AVM type, or struct name) into an ABIType or AVMType\n * @param typeStr The type string to resolve\n * @param structs The structs defined in the contract\n * @returns The parsed ABIType or AVMType string\n */\nfunction resolveStorageType(typeStr: string, structs: Record<string, StructField[]>): ABIType | AVMType {\n // Check if it's an AVM type\n if (typeStr === 'AVMBytes' || typeStr === 'AVMString' || typeStr === 'AVMUint64') {\n return typeStr as AVMType\n }\n\n // Check if it's a struct type\n if (structs[typeStr]) {\n return ABIStructType.fromStruct(typeStr, structs)\n }\n\n // Otherwise parse as ABI type\n try {\n return ABIType.from(typeStr)\n } catch (error) {\n throw new Error(`Failed to parse storage type '${typeStr}': ${error}`)\n }\n}\n\n/**\n * Converts a StorageKey to an ABIStorageKey with parsed types\n * @param storageKey The storage key to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageKey\n */\nfunction convertStorageKey(storageKey: StorageKey, structs: Record<string, StructField[]>): ABIStorageKey {\n const keyType = resolveStorageType(storageKey.keyType, structs)\n const valueType = resolveStorageType(storageKey.valueType, structs)\n\n return {\n key: storageKey.key,\n keyType,\n valueType,\n desc: storageKey.desc,\n }\n}\n\n/**\n * Converts a StorageMap to an ABIStorageMap with parsed types\n * @param storageMap The storage map to convert\n * @param structs The structs defined in the contract\n * @returns The converted ABIStorageMap\n */\nfunction convertStorageMap(storageMap: StorageMap, structs: Record<string, StructField[]>): ABIStorageMap {\n const keyType = resolveStorageType(storageMap.keyType, structs)\n const valueType = resolveStorageType(storageMap.valueType, structs)\n\n return {\n keyType,\n valueType,\n desc: storageMap.desc,\n prefix: storageMap.prefix,\n }\n}\n\n/**\n * Get a specific global storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getGlobalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.global[keyName]\n if (!storageKey) {\n throw new Error(`Global storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific local storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getLocalABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.local[keyName]\n if (!storageKey) {\n throw new Error(`Local storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get a specific box storage key with parsed ABI types\n * @param contract The ARC-56 contract\n * @param keyName The name of the storage key\n * @returns The ABIStorageKey with parsed types\n * @throws Error if the key is not found\n */\nexport function getBoxABIStorageKey(contract: Arc56Contract, keyName: string): ABIStorageKey {\n const storageKey = contract.state.keys.box[keyName]\n if (!storageKey) {\n throw new Error(`Box storage key '${keyName}' not found in contract '${contract.name}'`)\n }\n return convertStorageKey(storageKey, contract.structs)\n}\n\n/**\n * Get all global storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getGlobalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.global)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getLocalABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.local)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage keys with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage key names to ABIStorageKey objects\n */\nexport function getBoxABIStorageKeys(contract: Arc56Contract): Record<string, ABIStorageKey> {\n const result: Record<string, ABIStorageKey> = {}\n for (const [name, storageKey] of Object.entries(contract.state.keys.box)) {\n result[name] = convertStorageKey(storageKey, contract.structs)\n }\n return result\n}\n\n/**\n * Get a specific global storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getGlobalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.global[mapName]\n if (!storageMap) {\n throw new Error(`Global storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific local storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getLocalABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.local[mapName]\n if (!storageMap) {\n throw new Error(`Local storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get a specific box storage map with parsed ABI types\n * @param contract The ARC-56 contract\n * @param mapName The name of the storage map\n * @returns The ABIStorageMap with parsed types\n * @throws Error if the map is not found\n */\nexport function getBoxABIStorageMap(contract: Arc56Contract, mapName: string): ABIStorageMap {\n const storageMap = contract.state.maps.box[mapName]\n if (!storageMap) {\n throw new Error(`Box storage map '${mapName}' not found in contract '${contract.name}'`)\n }\n return convertStorageMap(storageMap, contract.structs)\n}\n\n/**\n * Get all global storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getGlobalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.global)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all local storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getLocalABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.local)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n\n/**\n * Get all box storage maps with parsed ABI types\n * @param contract The ARC-56 contract\n * @returns A record of storage map names to ABIStorageMap objects\n */\nexport function getBoxABIStorageMaps(contract: Arc56Contract): Record<string, ABIStorageMap> {\n const result: Record<string, ABIStorageMap> = {}\n for (const [name, storageMap] of Object.entries(contract.state.maps.box)) {\n result[name] = convertStorageMap(storageMap, contract.structs)\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;AA6TA,SAAS,mBAAmB,SAAiB,SAA2D;AAEtG,KAAI,YAAY,cAAc,YAAY,eAAe,YAAY,YACnE,QAAO;AAIT,KAAI,QAAQ,SACV,QAAO,cAAc,WAAW,SAAS,QAAQ;AAInD,KAAI;AACF,SAAO,QAAQ,KAAK,QAAQ;UACrB,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,QAAQ,KAAK,QAAQ;;;;;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;;AAQT,SAAgB,uBAAuB,UAAwD;CAC7F,MAAMA,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,MAAM,CACxE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO;;;;;;;AAQT,SAAgB,qBAAqB,UAAwD;CAC3F,MAAMA,SAAwC,EAAE;AAChD,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,MAAM,KAAK,IAAI,CACtE,QAAO,QAAQ,kBAAkB,YAAY,SAAS,QAAQ;AAEhE,QAAO"}
@@ -0,0 +1,40 @@
1
+ //#region packages/algo25/src/index.d.ts
2
+ declare const FAIL_TO_DECODE_MNEMONIC_ERROR_MSG = "failed to decode mnemonic";
3
+ declare const NOT_IN_WORDS_LIST_ERROR_MSG = "the mnemonic contains a word that is not in the wordlist";
4
+ /**
5
+ * mnemonicFromSeed converts a 32-byte key into a 25 word mnemonic. The generated mnemonic includes a checksum.
6
+ * Each word in the mnemonic represents 11 bits of data, and the last 11 bits are reserved for the checksum.
7
+ * @param seed - 32 bytes long seed
8
+ * @returns 25 words mnemonic
9
+ */
10
+ declare function mnemonicFromSeed(seed: Uint8Array): string;
11
+ /**
12
+ * seedFromMnemonic converts a mnemonic generated using this library into the source key used to create it.
13
+ * It returns an error if the passed mnemonic has an incorrect checksum, if the number of words is unexpected, or if one
14
+ * of the passed words is not found in the words list.
15
+ * @param mnemonic - 25 words mnemonic
16
+ * @returns 32 bytes long seed
17
+ */
18
+ declare function seedFromMnemonic(mnemonic: string): Uint8Array;
19
+ /**
20
+ * secretKeyToMnemonic takes an Algorand secret key and returns the corresponding mnemonic.
21
+ * @param sk - Algorand secret key
22
+ * @returns Secret key's associated mnemonic
23
+ */
24
+ declare function secretKeyToMnemonic(sk: Uint8Array): string;
25
+ /**
26
+ * mnemonicToMasterDerivationKey takes a mnemonic string and returns the corresponding master derivation key.
27
+ * @param mn - 25 words Algorand mnemonic
28
+ * @returns Uint8Array
29
+ * @throws error if fails to decode the mnemonic
30
+ */
31
+ declare function mnemonicToMasterDerivationKey(mn: string): Uint8Array;
32
+ /**
33
+ * masterDerivationKeyToMnemonic takes a master derivation key and returns the corresponding mnemonic.
34
+ * @param mdk - Uint8Array
35
+ * @returns string mnemonic
36
+ */
37
+ declare function masterDerivationKeyToMnemonic(mdk: Uint8Array): string;
38
+ //#endregion
39
+ export { FAIL_TO_DECODE_MNEMONIC_ERROR_MSG, NOT_IN_WORDS_LIST_ERROR_MSG, masterDerivationKeyToMnemonic, mnemonicFromSeed, mnemonicToMasterDerivationKey, secretKeyToMnemonic, seedFromMnemonic };
40
+ //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,10 @@
1
- const require_crypto = require('../../common/src/crypto.js');
2
1
  const require_english = require('./english.js');
2
+ const require_crypto = require('../../common/src/crypto.js');
3
3
 
4
4
  //#region packages/algo25/src/index.ts
5
5
  const FAIL_TO_DECODE_MNEMONIC_ERROR_MSG = "failed to decode mnemonic";
6
6
  const NOT_IN_WORDS_LIST_ERROR_MSG = "the mnemonic contains a word that is not in the wordlist";
7
+ const SEED_BTYES_LENGTH = 32;
7
8
  function toUint11Array(buffer8) {
8
9
  const buffer11 = [];
9
10
  let acc = 0;
@@ -30,6 +31,18 @@ function applyWords(nums) {
30
31
  function computeChecksum(seed) {
31
32
  return applyWords(toUint11Array(require_crypto.hash(seed)))[0];
32
33
  }
34
+ /**
35
+ * mnemonicFromSeed converts a 32-byte key into a 25 word mnemonic. The generated mnemonic includes a checksum.
36
+ * Each word in the mnemonic represents 11 bits of data, and the last 11 bits are reserved for the checksum.
37
+ * @param seed - 32 bytes long seed
38
+ * @returns 25 words mnemonic
39
+ */
40
+ function mnemonicFromSeed(seed) {
41
+ if (seed.length !== SEED_BTYES_LENGTH) throw new RangeError(`Seed length must be ${SEED_BTYES_LENGTH}`);
42
+ const words = applyWords(toUint11Array(seed));
43
+ const checksumWord = computeChecksum(seed);
44
+ return `${words.join(" ")} ${checksumWord}`;
45
+ }
33
46
  function toUint8Array(buffer11) {
34
47
  const buffer8 = [];
35
48
  let acc = 0;
@@ -69,7 +82,38 @@ function seedFromMnemonic(mnemonic) {
69
82
  if (computeChecksum(uint8Array) === checksum) return uint8Array;
70
83
  throw new Error(FAIL_TO_DECODE_MNEMONIC_ERROR_MSG);
71
84
  }
85
+ /**
86
+ * secretKeyToMnemonic takes an Algorand secret key and returns the corresponding mnemonic.
87
+ * @param sk - Algorand secret key
88
+ * @returns Secret key's associated mnemonic
89
+ */
90
+ function secretKeyToMnemonic(sk) {
91
+ return mnemonicFromSeed(sk.slice(0, SEED_BTYES_LENGTH));
92
+ }
93
+ /**
94
+ * mnemonicToMasterDerivationKey takes a mnemonic string and returns the corresponding master derivation key.
95
+ * @param mn - 25 words Algorand mnemonic
96
+ * @returns Uint8Array
97
+ * @throws error if fails to decode the mnemonic
98
+ */
99
+ function mnemonicToMasterDerivationKey(mn) {
100
+ return seedFromMnemonic(mn);
101
+ }
102
+ /**
103
+ * masterDerivationKeyToMnemonic takes a master derivation key and returns the corresponding mnemonic.
104
+ * @param mdk - Uint8Array
105
+ * @returns string mnemonic
106
+ */
107
+ function masterDerivationKeyToMnemonic(mdk) {
108
+ return mnemonicFromSeed(mdk);
109
+ }
72
110
 
73
111
  //#endregion
112
+ exports.FAIL_TO_DECODE_MNEMONIC_ERROR_MSG = FAIL_TO_DECODE_MNEMONIC_ERROR_MSG;
113
+ exports.NOT_IN_WORDS_LIST_ERROR_MSG = NOT_IN_WORDS_LIST_ERROR_MSG;
114
+ exports.masterDerivationKeyToMnemonic = masterDerivationKeyToMnemonic;
115
+ exports.mnemonicFromSeed = mnemonicFromSeed;
116
+ exports.mnemonicToMasterDerivationKey = mnemonicToMasterDerivationKey;
117
+ exports.secretKeyToMnemonic = secretKeyToMnemonic;
74
118
  exports.seedFromMnemonic = seedFromMnemonic;
75
119
  //# sourceMappingURL=index.js.map