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

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 (487) hide show
  1. package/_virtual/rolldown_runtime.js +10 -15
  2. package/abi/index.d.ts +2 -1
  3. package/abi/index.js +3 -0
  4. package/abi/index.mjs +2 -1
  5. package/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 +5 -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 -3
  29. package/packages/abi/src/abi-type.js +7 -36
  30. package/packages/abi/src/abi-type.js.map +1 -1
  31. package/packages/abi/src/abi-type.mjs +7 -36
  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/abi/src/utils.d.ts +22 -0
  38. package/packages/abi/src/utils.js +57 -0
  39. package/packages/abi/src/utils.js.map +1 -0
  40. package/packages/abi/src/utils.mjs +55 -0
  41. package/packages/abi/src/utils.mjs.map +1 -0
  42. package/packages/algo25/src/index.js +1 -1
  43. package/packages/algo25/src/index.mjs +1 -1
  44. package/packages/algod_client/src/apis/api-service.d.ts +44 -44
  45. package/packages/algod_client/src/apis/api-service.js +155 -155
  46. package/packages/algod_client/src/apis/api-service.js.map +1 -1
  47. package/packages/algod_client/src/apis/api-service.mjs +155 -155
  48. package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
  49. package/packages/algod_client/src/core/api-error.js +3 -1
  50. package/packages/algod_client/src/core/api-error.js.map +1 -1
  51. package/packages/algod_client/src/core/api-error.mjs +3 -1
  52. package/packages/algod_client/src/core/api-error.mjs.map +1 -1
  53. package/packages/algod_client/src/core/model-runtime.js +6 -6
  54. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  55. package/packages/algod_client/src/core/model-runtime.mjs +8 -8
  56. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  57. package/packages/algod_client/src/models/account-participation.js +4 -4
  58. package/packages/algod_client/src/models/account-participation.js.map +1 -1
  59. package/packages/algod_client/src/models/account-participation.mjs +4 -4
  60. package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
  61. package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
  62. package/packages/algod_client/src/models/application-state-schema.js +2 -2
  63. package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
  64. package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
  65. package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
  66. package/packages/algod_client/src/models/asset-params.js +2 -1
  67. package/packages/algod_client/src/models/asset-params.js.map +1 -1
  68. package/packages/algod_client/src/models/asset-params.mjs +2 -1
  69. package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
  70. package/packages/algod_client/src/models/block-response.js +1 -2
  71. package/packages/algod_client/src/models/block-response.js.map +1 -1
  72. package/packages/algod_client/src/models/block-response.mjs +2 -3
  73. package/packages/algod_client/src/models/block-response.mjs.map +1 -1
  74. package/packages/algod_client/src/models/block.d.ts +60 -40
  75. package/packages/algod_client/src/models/block.js +184 -108
  76. package/packages/algod_client/src/models/block.js.map +1 -1
  77. package/packages/algod_client/src/models/block.mjs +184 -108
  78. package/packages/algod_client/src/models/block.mjs.map +1 -1
  79. package/packages/algod_client/src/models/eval-delta-key-value.js +2 -2
  80. package/packages/algod_client/src/models/eval-delta-key-value.js.map +1 -1
  81. package/packages/algod_client/src/models/eval-delta-key-value.mjs +2 -2
  82. package/packages/algod_client/src/models/eval-delta-key-value.mjs.map +1 -1
  83. package/packages/algod_client/src/models/eval-delta.js +2 -2
  84. package/packages/algod_client/src/models/eval-delta.js.map +1 -1
  85. package/packages/algod_client/src/models/eval-delta.mjs +2 -2
  86. package/packages/algod_client/src/models/eval-delta.mjs.map +1 -1
  87. package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
  88. package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
  89. package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
  90. package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
  91. package/packages/algod_client/src/models/simulate-request.js +1 -1
  92. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  93. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  94. package/packages/algod_client/src/models/simulate-response.js +6 -1
  95. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  96. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  97. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  98. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
  99. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
  100. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
  101. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
  102. package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
  103. package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
  104. package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
  105. package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
  106. package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
  107. package/packages/common/src/address.d.ts +0 -1
  108. package/packages/common/src/address.js +4 -17
  109. package/packages/common/src/address.js.map +1 -1
  110. package/packages/common/src/address.mjs +5 -17
  111. package/packages/common/src/address.mjs.map +1 -1
  112. package/packages/common/src/codecs/composite/map.js +7 -4
  113. package/packages/common/src/codecs/composite/map.js.map +1 -1
  114. package/packages/common/src/codecs/composite/map.mjs +7 -4
  115. package/packages/common/src/codecs/composite/map.mjs.map +1 -1
  116. package/packages/common/src/codecs/composite/record.js +0 -1
  117. package/packages/common/src/codecs/composite/record.js.map +1 -1
  118. package/packages/common/src/codecs/primitives/address.js +0 -1
  119. package/packages/common/src/codecs/primitives/address.js.map +1 -1
  120. package/packages/common/src/codecs/primitives/bytes-base64.js +26 -0
  121. package/packages/common/src/codecs/primitives/bytes-base64.js.map +1 -0
  122. package/packages/common/src/codecs/primitives/bytes-base64.mjs +25 -0
  123. package/packages/common/src/codecs/primitives/bytes-base64.mjs.map +1 -0
  124. package/packages/common/src/codecs/primitives/bytes.js +0 -1
  125. package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
  126. package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
  127. package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
  128. package/packages/common/src/codecs/wire.js +0 -1
  129. package/packages/common/src/codecs/wire.js.map +1 -1
  130. package/packages/common/src/json.mjs +2 -2
  131. package/packages/common/src/json.mjs.map +1 -1
  132. package/packages/common/src/msgpack.js +0 -1
  133. package/packages/common/src/msgpack.js.map +1 -1
  134. package/packages/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
  135. package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
  136. package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
  137. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
  138. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.map +1 -1
  139. package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
  140. package/packages/indexer_client/src/apis/api-service.js +12 -12
  141. package/packages/indexer_client/src/apis/api-service.js.map +1 -1
  142. package/packages/indexer_client/src/apis/api-service.mjs +12 -12
  143. package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
  144. package/packages/indexer_client/src/core/api-error.js +3 -1
  145. package/packages/indexer_client/src/core/api-error.js.map +1 -1
  146. package/packages/indexer_client/src/core/api-error.mjs +3 -1
  147. package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
  148. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  149. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  150. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  151. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  152. package/packages/indexer_client/src/models/account-participation.js +4 -4
  153. package/packages/indexer_client/src/models/account-participation.js.map +1 -1
  154. package/packages/indexer_client/src/models/account-participation.mjs +4 -4
  155. package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
  156. package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
  157. package/packages/indexer_client/src/models/application-state-schema.js +2 -2
  158. package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
  159. package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
  160. package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
  161. package/packages/indexer_client/src/models/asset-params.js +2 -1
  162. package/packages/indexer_client/src/models/asset-params.js.map +1 -1
  163. package/packages/indexer_client/src/models/asset-params.mjs +2 -1
  164. package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
  165. package/packages/indexer_client/src/models/block.d.ts +5 -5
  166. package/packages/indexer_client/src/models/block.js +13 -13
  167. package/packages/indexer_client/src/models/block.js.map +1 -1
  168. package/packages/indexer_client/src/models/block.mjs +13 -13
  169. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  170. package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
  171. package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
  172. package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
  173. package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
  174. package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
  175. package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
  176. package/packages/indexer_client/src/models/eval-delta.js +2 -2
  177. package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
  178. package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
  179. package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
  180. package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
  181. package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
  182. package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
  183. package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
  184. package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
  185. package/packages/indexer_client/src/models/participation-updates.js +2 -2
  186. package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
  187. package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
  188. package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
  189. package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
  190. package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
  191. package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
  192. package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
  193. package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
  194. package/packages/indexer_client/src/models/state-schema.js +2 -2
  195. package/packages/indexer_client/src/models/state-schema.js.map +1 -1
  196. package/packages/indexer_client/src/models/state-schema.mjs +2 -2
  197. package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
  198. package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
  199. package/packages/indexer_client/src/models/teal-key-value.js +2 -2
  200. package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
  201. package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
  202. package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
  203. package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
  204. package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
  205. package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
  206. package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
  207. package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
  208. package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
  209. package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
  210. package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
  211. package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
  212. package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
  213. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
  214. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
  215. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
  216. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
  217. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
  218. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
  219. package/packages/indexer_client/src/models/transaction-state-proof.d.ts +1 -1
  220. package/packages/indexer_client/src/models/transaction-state-proof.js +2 -2
  221. package/packages/indexer_client/src/models/transaction-state-proof.js.map +1 -1
  222. package/packages/indexer_client/src/models/transaction-state-proof.mjs +2 -2
  223. package/packages/indexer_client/src/models/transaction-state-proof.mjs.map +1 -1
  224. package/packages/indexer_client/src/models/transaction.d.ts +2 -2
  225. package/packages/indexer_client/src/models/transaction.js +6 -5
  226. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  227. package/packages/indexer_client/src/models/transaction.mjs +6 -5
  228. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  229. package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
  230. package/packages/kmd_client/src/apis/api-service.js +32 -32
  231. package/packages/kmd_client/src/apis/api-service.js.map +1 -1
  232. package/packages/kmd_client/src/apis/api-service.mjs +32 -32
  233. package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
  234. package/packages/kmd_client/src/core/api-error.js +3 -1
  235. package/packages/kmd_client/src/core/api-error.js.map +1 -1
  236. package/packages/kmd_client/src/core/api-error.mjs +3 -1
  237. package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
  238. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  239. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  240. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  241. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  242. package/packages/transact/src/logicsig.d.ts +35 -33
  243. package/packages/transact/src/logicsig.js +74 -76
  244. package/packages/transact/src/logicsig.js.map +1 -1
  245. package/packages/transact/src/logicsig.mjs +77 -78
  246. package/packages/transact/src/logicsig.mjs.map +1 -1
  247. package/packages/transact/src/multisig.d.ts +11 -116
  248. package/packages/transact/src/multisig.js +106 -136
  249. package/packages/transact/src/multisig.js.map +1 -1
  250. package/packages/transact/src/multisig.mjs +108 -118
  251. package/packages/transact/src/multisig.mjs.map +1 -1
  252. package/packages/transact/src/signer.js +9 -2
  253. package/packages/transact/src/signer.js.map +1 -1
  254. package/packages/transact/src/signer.mjs +10 -3
  255. package/packages/transact/src/signer.mjs.map +1 -1
  256. package/packages/transact/src/transactions/app-call.d.ts +10 -15
  257. package/packages/transact/src/transactions/app-call.js.map +1 -1
  258. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  259. package/packages/transact/src/transactions/asset-config.d.ts +1 -6
  260. package/packages/transact/src/transactions/asset-config.js.map +1 -1
  261. package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
  262. package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
  263. package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
  264. package/packages/transact/src/transactions/key-registration.d.ts +1 -8
  265. package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
  266. package/packages/transact/src/transactions/reference-types-meta.js +71 -0
  267. package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
  268. package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
  269. package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
  270. package/packages/transact/src/transactions/signed-transaction-meta.js +8 -9
  271. package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
  272. package/packages/transact/src/transactions/signed-transaction-meta.mjs +8 -8
  273. package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
  274. package/packages/transact/src/transactions/signed-transaction.d.ts +10 -6
  275. package/packages/transact/src/transactions/signed-transaction.js +1 -1
  276. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  277. package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
  278. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  279. package/packages/transact/src/transactions/state-proof.d.ts +1 -1
  280. package/packages/transact/src/transactions/transaction-meta.js +29 -23
  281. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  282. package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
  283. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  284. package/packages/transact/src/transactions/transaction.d.ts +5 -2
  285. package/packages/transact/src/transactions/transaction.js +5 -4
  286. package/packages/transact/src/transactions/transaction.js.map +1 -1
  287. package/packages/transact/src/transactions/transaction.mjs +5 -4
  288. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  289. package/testing/account.js +1 -2
  290. package/testing/account.js.map +1 -1
  291. package/testing/account.mjs +1 -2
  292. package/testing/account.mjs.map +1 -1
  293. package/testing/fixtures/algorand-fixture.d.ts +3 -3
  294. package/testing/fixtures/algorand-fixture.js.map +1 -1
  295. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  296. package/testing/transaction-logger.js +1 -1
  297. package/testing/transaction-logger.mjs +1 -1
  298. package/transact/index.d.ts +11 -10
  299. package/transact/index.js +7 -31
  300. package/transact/index.mjs +7 -10
  301. package/transaction/transaction.js +2 -2
  302. package/transaction/transaction.js.map +1 -1
  303. package/transaction/transaction.mjs +2 -2
  304. package/transaction/transaction.mjs.map +1 -1
  305. package/transactions/app-call.d.ts +5 -4
  306. package/transactions/app-call.js +16 -16
  307. package/transactions/app-call.js.map +1 -1
  308. package/transactions/app-call.mjs +16 -16
  309. package/transactions/app-call.mjs.map +1 -1
  310. package/transactions/asset-config.d.ts +1 -1
  311. package/transactions/asset-config.js +1 -1
  312. package/transactions/asset-config.js.map +1 -1
  313. package/transactions/asset-config.mjs +1 -1
  314. package/transactions/asset-config.mjs.map +1 -1
  315. package/transactions/key-registration.d.ts +1 -1
  316. package/transactions/key-registration.js.map +1 -1
  317. package/transactions/key-registration.mjs.map +1 -1
  318. package/transactions/method-call.d.ts +1 -1
  319. package/transactions/method-call.js +77 -84
  320. package/transactions/method-call.js.map +1 -1
  321. package/transactions/method-call.mjs +77 -84
  322. package/transactions/method-call.mjs.map +1 -1
  323. package/types/account-manager.d.ts +7 -9
  324. package/types/account-manager.js +17 -7
  325. package/types/account-manager.js.map +1 -1
  326. package/types/account-manager.mjs +17 -7
  327. package/types/account-manager.mjs.map +1 -1
  328. package/types/algorand-client-transaction-creator.d.ts +53 -39
  329. package/types/algorand-client-transaction-creator.js +8 -0
  330. package/types/algorand-client-transaction-creator.js.map +1 -1
  331. package/types/algorand-client-transaction-creator.mjs +8 -0
  332. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  333. package/types/algorand-client-transaction-sender.d.ts +58 -44
  334. package/types/algorand-client-transaction-sender.js +8 -1
  335. package/types/algorand-client-transaction-sender.js.map +1 -1
  336. package/types/algorand-client-transaction-sender.mjs +8 -0
  337. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  338. package/types/amount.js +23 -4
  339. package/types/amount.js.map +1 -1
  340. package/types/amount.mjs +20 -2
  341. package/types/amount.mjs.map +1 -1
  342. package/types/app-client.d.ts +111 -106
  343. package/types/app-client.js +2 -3
  344. package/types/app-client.js.map +1 -1
  345. package/types/app-client.mjs +2 -2
  346. package/types/app-client.mjs.map +1 -1
  347. package/types/app-deployer.d.ts +1 -1
  348. package/types/app-deployer.js +3 -3
  349. package/types/app-deployer.js.map +1 -1
  350. package/types/app-deployer.mjs +3 -3
  351. package/types/app-deployer.mjs.map +1 -1
  352. package/types/app-factory.d.ts +44 -41
  353. package/types/app-factory.js +2 -2
  354. package/types/app-factory.js.map +1 -1
  355. package/types/app-factory.mjs +2 -2
  356. package/types/app-factory.mjs.map +1 -1
  357. package/types/app-manager.d.ts +3 -1
  358. package/types/app-manager.js +17 -11
  359. package/types/app-manager.js.map +1 -1
  360. package/types/app-manager.mjs +17 -11
  361. package/types/app-manager.mjs.map +1 -1
  362. package/types/app-spec.js +12 -5
  363. package/types/app-spec.js.map +1 -1
  364. package/types/app-spec.mjs +12 -5
  365. package/types/app-spec.mjs.map +1 -1
  366. package/types/app.d.ts +2 -2
  367. package/types/app.js.map +1 -1
  368. package/types/app.mjs.map +1 -1
  369. package/types/asset-manager.js +1 -1
  370. package/types/asset-manager.js.map +1 -1
  371. package/types/asset-manager.mjs +1 -1
  372. package/types/asset-manager.mjs.map +1 -1
  373. package/types/async-event-emitter.d.ts +3 -6
  374. package/types/async-event-emitter.js.map +1 -1
  375. package/types/async-event-emitter.mjs.map +1 -1
  376. package/types/client-manager.d.ts +1 -1
  377. package/types/client-manager.js.map +1 -1
  378. package/types/client-manager.mjs.map +1 -1
  379. package/types/composer.d.ts +11 -3
  380. package/types/composer.js +55 -46
  381. package/types/composer.js.map +1 -1
  382. package/types/composer.mjs +46 -36
  383. package/types/composer.mjs.map +1 -1
  384. package/types/debugging.d.ts +13 -9
  385. package/types/debugging.js.map +1 -1
  386. package/types/debugging.mjs.map +1 -1
  387. package/types/expand.d.ts +2 -9
  388. package/types/kmd-account-manager.d.ts +1 -0
  389. package/types/kmd-account-manager.js +22 -11
  390. package/types/kmd-account-manager.js.map +1 -1
  391. package/types/kmd-account-manager.mjs +23 -12
  392. package/types/kmd-account-manager.mjs.map +1 -1
  393. package/types/lifecycle-events.d.ts +0 -1
  394. package/types/lifecycle-events.js.map +1 -1
  395. package/types/lifecycle-events.mjs.map +1 -1
  396. package/types/testing.d.ts +4 -4
  397. package/types/transaction.d.ts +1 -1
  398. package/_virtual/rolldown_runtime.mjs +0 -13
  399. package/indexer-lookup.js.map +0 -1
  400. package/indexer-lookup.mjs.map +0 -1
  401. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  402. package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
  403. package/packages/algod_client/src/models/application-local-reference.js +0 -23
  404. package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
  405. package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
  406. package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
  407. package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
  408. package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
  409. package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
  410. package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
  411. package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
  412. package/packages/algod_client/src/models/box-reference.d.ts +0 -17
  413. package/packages/algod_client/src/models/box-reference.js +0 -23
  414. package/packages/algod_client/src/models/box-reference.js.map +0 -1
  415. package/packages/algod_client/src/models/box-reference.mjs +0 -23
  416. package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
  417. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  418. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  419. package/packages/sdk/src/convert.d.ts +0 -17
  420. package/packages/sdk/src/convert.js +0 -28
  421. package/packages/sdk/src/convert.js.map +0 -1
  422. package/packages/sdk/src/convert.mjs +0 -25
  423. package/packages/sdk/src/convert.mjs.map +0 -1
  424. package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
  425. package/packages/sdk/src/encoding/binarydata.js +0 -65
  426. package/packages/sdk/src/encoding/binarydata.js.map +0 -1
  427. package/packages/sdk/src/encoding/binarydata.mjs +0 -60
  428. package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
  429. package/packages/sdk/src/encoding/encoding.d.ts +0 -237
  430. package/packages/sdk/src/encoding/encoding.js +0 -302
  431. package/packages/sdk/src/encoding/encoding.js.map +0 -1
  432. package/packages/sdk/src/encoding/encoding.mjs +0 -287
  433. package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
  434. package/packages/sdk/src/encoding/schema/array.js +0 -35
  435. package/packages/sdk/src/encoding/schema/array.js.map +0 -1
  436. package/packages/sdk/src/encoding/schema/array.mjs +0 -35
  437. package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
  438. package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
  439. package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
  440. package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
  441. package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
  442. package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
  443. package/packages/sdk/src/encoding/schema/map.js +0 -110
  444. package/packages/sdk/src/encoding/schema/map.js.map +0 -1
  445. package/packages/sdk/src/encoding/schema/map.mjs +0 -107
  446. package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
  447. package/packages/sdk/src/encoding/schema/optional.js +0 -46
  448. package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
  449. package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
  450. package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
  451. package/packages/sdk/src/encoding/schema/uint64.js +0 -30
  452. package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
  453. package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
  454. package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
  455. package/packages/sdk/src/encoding/uint64.d.ts +0 -34
  456. package/packages/sdk/src/encoding/uint64.js +0 -34
  457. package/packages/sdk/src/encoding/uint64.js.map +0 -1
  458. package/packages/sdk/src/encoding/uint64.mjs +0 -33
  459. package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
  460. package/packages/sdk/src/index.d.ts +0 -44
  461. package/packages/sdk/src/index.js +0 -62
  462. package/packages/sdk/src/index.js.map +0 -1
  463. package/packages/sdk/src/index.mjs +0 -58
  464. package/packages/sdk/src/index.mjs.map +0 -1
  465. package/packages/sdk/src/nacl/naclWrappers.js +0 -14
  466. package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
  467. package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
  468. package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
  469. package/packages/sdk/src/types/intDecoding.d.ts +0 -28
  470. package/packages/sdk/src/types/intDecoding.js +0 -32
  471. package/packages/sdk/src/types/intDecoding.js.map +0 -1
  472. package/packages/sdk/src/types/intDecoding.mjs +0 -31
  473. package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
  474. package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
  475. package/packages/sdk/src/types/transactions/encoded.js +0 -64
  476. package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
  477. package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
  478. package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
  479. package/packages/sdk/src/utils/utils.d.ts +0 -64
  480. package/packages/sdk/src/utils/utils.js +0 -140
  481. package/packages/sdk/src/utils/utils.js.map +0 -1
  482. package/packages/sdk/src/utils/utils.mjs +0 -128
  483. package/packages/sdk/src/utils/utils.mjs.map +0 -1
  484. package/packages/transact/src/transactions/common.d.ts +0 -37
  485. package/sdk/index.d.ts +0 -10
  486. package/sdk/index.js +0 -59
  487. package/sdk/index.mjs +0 -11
@@ -1,302 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.js');
2
- const require_intDecoding = require('../types/intDecoding.js');
3
- const require_utils = require('../utils/utils.js');
4
- const require_binarydata = require('./binarydata.js');
5
- let algorand_msgpack = require("algorand-msgpack");
6
- algorand_msgpack = require_rolldown_runtime.__toESM(algorand_msgpack);
7
-
8
- //#region packages/sdk/src/encoding/encoding.ts
9
- const ERROR_CONTAINS_EMPTY_STRING = "The object contains empty or 0 values. First empty or 0 value encountered during encoding: ";
10
- /**
11
- * containsEmpty returns true if any of the object's values are empty, false otherwise.
12
- * Empty arrays considered empty
13
- * @param obj - The object to check
14
- * @returns \{true, empty key\} if contains empty, \{false, undefined\} otherwise
15
- */
16
- function containsEmpty(obj) {
17
- for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) {
18
- if (!obj[key] || obj[key].length === 0) return {
19
- containsEmpty: true,
20
- firstEmptyKey: key
21
- };
22
- }
23
- return {
24
- containsEmpty: false,
25
- firstEmptyKey: void 0
26
- };
27
- }
28
- /**
29
- * msgpackRawEncode encodes objects using msgpack, regardless of whether there are
30
- * empty or 0 value fields.
31
- * @param obj - a dictionary to be encoded. May or may not contain empty or 0 values.
32
- * @returns msgpack representation of the object
33
- */
34
- function msgpackRawEncode(obj) {
35
- return (0, algorand_msgpack.encode)(obj, { sortKeys: true });
36
- }
37
- /**
38
- * encodeObj takes a javascript object and returns its msgpack encoding
39
- * Note that the encoding sorts the fields alphabetically
40
- * @param o - js object to be encoded. Must not contain empty or 0 values.
41
- * @returns Uint8Array binary representation
42
- * @throws Error containing ERROR_CONTAINS_EMPTY_STRING if the object contains empty or zero values
43
- *
44
- * @deprecated Use {@link msgpackRawEncode} instead. Note that function does not
45
- * check for empty values like this one does.
46
- */
47
- function encodeObj(obj) {
48
- const emptyCheck = containsEmpty(obj);
49
- if (emptyCheck.containsEmpty) throw new Error(ERROR_CONTAINS_EMPTY_STRING + emptyCheck.firstEmptyKey);
50
- return msgpackRawEncode(obj);
51
- }
52
- function intDecodingToIntMode(intDecoding) {
53
- switch (intDecoding) {
54
- case require_intDecoding.default.UNSAFE: return algorand_msgpack.IntMode.UNSAFE_NUMBER;
55
- case require_intDecoding.default.SAFE: return algorand_msgpack.IntMode.SAFE_NUMBER;
56
- case require_intDecoding.default.MIXED: return algorand_msgpack.IntMode.MIXED;
57
- case require_intDecoding.default.BIGINT: return algorand_msgpack.IntMode.BIGINT;
58
- default: throw new Error(`Invalid intDecoding: ${intDecoding}`);
59
- }
60
- }
61
- /**
62
- * Decodes msgpack bytes into a plain JavaScript object.
63
- * @param buffer - The msgpack bytes to decode
64
- * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.
65
- * @returns The decoded object
66
- */
67
- function msgpackRawDecode(buffer, options) {
68
- return (0, algorand_msgpack.decode)(buffer, { intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : algorand_msgpack.IntMode.BIGINT });
69
- }
70
- /**
71
- * decodeObj takes a Uint8Array and returns its javascript obj
72
- * @param o - Uint8Array to decode
73
- * @returns object
74
- *
75
- * @deprecated Use {@link msgpackRawDecode} instead. Note that this function uses `IntDecoding.MIXED`
76
- * while `msgpackRawDecode` defaults to `IntDecoding.BIGINT` for int decoding, though it is
77
- * configurable.
78
- */
79
- function decodeObj(o) {
80
- return msgpackRawDecode(o, { intDecoding: require_intDecoding.default.MIXED });
81
- }
82
- /**
83
- * Decodes msgpack bytes into a Map object. This supports decoding non-string map keys.
84
- * @param encoded - The msgpack bytes to decode
85
- * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.
86
- * @returns The decoded Map object
87
- */
88
- function msgpackRawDecodeAsMap(encoded, options) {
89
- return (0, algorand_msgpack.decode)(encoded, {
90
- intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : algorand_msgpack.IntMode.BIGINT,
91
- useMap: true
92
- });
93
- }
94
- function msgpackRawDecodeAsMapWithRawStrings(encoded, options) {
95
- return (0, algorand_msgpack.decode)(encoded, {
96
- intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : algorand_msgpack.IntMode.BIGINT,
97
- useMap: true,
98
- rawBinaryStringKeys: true,
99
- rawBinaryStringValues: true,
100
- useRawBinaryStringClass: true
101
- });
102
- }
103
- function msgpackEncodingDataToJSONEncodingData(e) {
104
- if (e === null || e === void 0) return e;
105
- if (e instanceof Uint8Array) return require_binarydata.bytesToBase64(e);
106
- if (Array.isArray(e)) return e.map(msgpackEncodingDataToJSONEncodingData);
107
- if (e instanceof Map) {
108
- const obj = {};
109
- for (const [k, v] of e) {
110
- if (typeof k !== "string") throw new Error(`JSON map key must be a string: ${k}`);
111
- obj[k] = msgpackEncodingDataToJSONEncodingData(v);
112
- }
113
- return obj;
114
- }
115
- return e;
116
- }
117
- function jsonEncodingDataToMsgpackEncodingData(e) {
118
- if (e === null || e === void 0) return e;
119
- if (typeof e === "string" || typeof e === "number" || typeof e === "bigint" || typeof e === "boolean") return e;
120
- if (Array.isArray(e)) return e.map(jsonEncodingDataToMsgpackEncodingData);
121
- if (typeof e === "object") {
122
- const obj = /* @__PURE__ */ new Map();
123
- for (const [key, value] of Object.entries(e)) obj.set(key, jsonEncodingDataToMsgpackEncodingData(value));
124
- return obj;
125
- }
126
- throw new Error(`Invalid JSON encoding data: ${e}`);
127
- }
128
- var MsgpackObjectPathSegmentKind = /* @__PURE__ */ function(MsgpackObjectPathSegmentKind$1) {
129
- MsgpackObjectPathSegmentKind$1[MsgpackObjectPathSegmentKind$1["MAP_VALUE"] = 0] = "MAP_VALUE";
130
- MsgpackObjectPathSegmentKind$1[MsgpackObjectPathSegmentKind$1["ARRAY_ELEMENT"] = 1] = "ARRAY_ELEMENT";
131
- return MsgpackObjectPathSegmentKind$1;
132
- }(MsgpackObjectPathSegmentKind || {});
133
- /**
134
- * This class is used to index into an encoded msgpack object and extract raw strings.
135
- */
136
- var MsgpackRawStringProvider = class MsgpackRawStringProvider {
137
- parent;
138
- baseObjectBytes;
139
- segment;
140
- resolvedCache = null;
141
- resolvedCachePresent = false;
142
- constructor({ parent, segment, baseObjectBytes }) {
143
- this.parent = parent;
144
- this.segment = segment;
145
- this.baseObjectBytes = baseObjectBytes;
146
- }
147
- /**
148
- * Create a new provider that resolves to the current provider's map value at the given key.
149
- */
150
- withMapValue(key) {
151
- return new MsgpackRawStringProvider({
152
- parent: this,
153
- segment: {
154
- kind: MsgpackObjectPathSegmentKind.MAP_VALUE,
155
- key
156
- }
157
- });
158
- }
159
- /**
160
- * Create a new provider that resolves to the current provider's array element at the given index.
161
- */
162
- withArrayElement(index) {
163
- return new MsgpackRawStringProvider({
164
- parent: this,
165
- segment: {
166
- kind: MsgpackObjectPathSegmentKind.ARRAY_ELEMENT,
167
- key: index
168
- }
169
- });
170
- }
171
- /**
172
- * Get the raw string at the current location. If the current location is not a raw string, an error is thrown.
173
- */
174
- getRawStringAtCurrentLocation() {
175
- const resolved = this.resolve();
176
- if (resolved instanceof algorand_msgpack.RawBinaryString) return resolved.rawBinaryValue;
177
- throw new Error(`Invalid type. Expected RawBinaryString, got ${resolved} (${typeof resolved})`);
178
- }
179
- /**
180
- * Get the raw string map keys and values at the current location. If the current location is not a map, an error is thrown.
181
- */
182
- getRawStringKeysAndValuesAtCurrentLocation() {
183
- const resolved = this.resolve();
184
- if (!(resolved instanceof Map)) throw new Error(`Invalid type. Expected Map, got ${resolved} (${typeof resolved})`);
185
- const keysAndValues = /* @__PURE__ */ new Map();
186
- for (const [key, value] of resolved) if (key instanceof algorand_msgpack.RawBinaryString) keysAndValues.set(key.rawBinaryValue, value);
187
- else throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${key} (${typeof key})`);
188
- return keysAndValues;
189
- }
190
- /**
191
- * Resolve the provider by extracting the value it indicates from the base msgpack object.
192
- */
193
- resolve() {
194
- if (this.resolvedCachePresent) return this.resolvedCache;
195
- let parentResolved;
196
- if (this.parent) parentResolved = this.parent.resolve();
197
- else parentResolved = msgpackRawDecodeAsMapWithRawStrings(this.baseObjectBytes);
198
- if (!this.segment) {
199
- this.resolvedCache = parentResolved;
200
- this.resolvedCachePresent = true;
201
- return parentResolved;
202
- }
203
- if (this.segment.kind === MsgpackObjectPathSegmentKind.MAP_VALUE) {
204
- if (!(parentResolved instanceof Map)) throw new Error(`Invalid type. Expected Map, got ${parentResolved} (${typeof parentResolved})`);
205
- if (typeof this.segment.key === "string" || this.segment.key instanceof Uint8Array || this.segment.key instanceof algorand_msgpack.RawBinaryString) {
206
- const targetBytes = this.segment.key instanceof algorand_msgpack.RawBinaryString ? this.segment.key.rawBinaryValue : require_binarydata.coerceToBytes(this.segment.key);
207
- const targetIsRawString = typeof this.segment.key === "string" || this.segment.key instanceof algorand_msgpack.RawBinaryString;
208
- for (const [key, value] of parentResolved) {
209
- let potentialKeyBytes;
210
- if (targetIsRawString) {
211
- if (key instanceof algorand_msgpack.RawBinaryString) potentialKeyBytes = key.rawBinaryValue;
212
- } else if (key instanceof Uint8Array) potentialKeyBytes = key;
213
- if (potentialKeyBytes && require_utils.arrayEqual(targetBytes, potentialKeyBytes)) {
214
- this.resolvedCache = value;
215
- break;
216
- }
217
- }
218
- } else this.resolvedCache = parentResolved.get(this.segment.key);
219
- this.resolvedCachePresent = true;
220
- return this.resolvedCache;
221
- }
222
- if (this.segment.kind === MsgpackObjectPathSegmentKind.ARRAY_ELEMENT) {
223
- if (!Array.isArray(parentResolved)) throw new Error(`Invalid type. Expected Array, got ${parentResolved} (${typeof parentResolved})`);
224
- this.resolvedCache = parentResolved[this.segment.key];
225
- this.resolvedCachePresent = true;
226
- return this.resolvedCache;
227
- }
228
- throw new Error(`Invalid segment kind: ${this.segment.kind}`);
229
- }
230
- /**
231
- * Get the path string of the current location indicated by the provider. Useful for debugging.
232
- */
233
- getPathString() {
234
- const parentPathString = this.parent ? this.parent.getPathString() : "root";
235
- if (!this.segment) return parentPathString;
236
- if (this.segment.kind === MsgpackObjectPathSegmentKind.MAP_VALUE) return `${parentPathString} -> map key "${this.segment.key}" (${typeof this.segment.key})`;
237
- if (this.segment.kind === MsgpackObjectPathSegmentKind.ARRAY_ELEMENT) return `${parentPathString} -> array index ${this.segment.key} (${typeof this.segment.key})`;
238
- return `${parentPathString} -> unknown segment kind ${this.segment.kind}`;
239
- }
240
- };
241
- /**
242
- * A Schema is used to prepare objects for encoding and decoding from msgpack and JSON.
243
- *
244
- * Schemas represent a specific type.
245
- */
246
- var Schema = class {};
247
- /**
248
- * Decode a msgpack byte array to an Encodable object.
249
- * @param encoded - The msgpack bytes to decode
250
- * @param c - The class of the object to decode. This class must match the object that was encoded.
251
- * @returns An instance of the class with the decoded data
252
- */
253
- function decodeMsgpack(encoded, c) {
254
- const decoded = msgpackRawDecodeAsMap(encoded);
255
- const rawStringProvider = new MsgpackRawStringProvider({ baseObjectBytes: encoded });
256
- return c.fromEncodingData(c.encodingSchema.fromPreparedMsgpack(decoded, rawStringProvider));
257
- }
258
- /**
259
- * Encode an Encodable object to a msgpack byte array.
260
- * @param e - The object to encode
261
- * @returns A msgpack byte array encoding of the object
262
- */
263
- function encodeMsgpack(e) {
264
- return msgpackRawEncode(e.getEncodingSchema().prepareMsgpack(e.toEncodingData()));
265
- }
266
- /**
267
- * Decode a JSON string to an Encodable object.
268
- * @param encoded - The JSON string to decode
269
- * @param c - The class of the object to decode. This class must match the object that was encoded.
270
- * @returns An instance of the class with the decoded data
271
- */
272
- function decodeJSON(encoded, c) {
273
- const decoded = require_utils.parseJSON(encoded, { intDecoding: require_intDecoding.default.BIGINT });
274
- return c.fromEncodingData(c.encodingSchema.fromPreparedJSON(decoded));
275
- }
276
- /**
277
- * Encode an Encodable object to a JSON string.
278
- * @param e - The object to encode
279
- * @param options - Optional encoding options. See {@link EncodeJSONOptions} for more information.
280
- * @returns A JSON string encoding of the object
281
- */
282
- function encodeJSON(e, options) {
283
- const { space,...prepareJSONOptions } = options ?? {};
284
- return require_utils.stringifyJSON(e.getEncodingSchema().prepareJSON(e.toEncodingData(), prepareJSONOptions), void 0, space);
285
- }
286
-
287
- //#endregion
288
- exports.ERROR_CONTAINS_EMPTY_STRING = ERROR_CONTAINS_EMPTY_STRING;
289
- exports.MsgpackRawStringProvider = MsgpackRawStringProvider;
290
- exports.Schema = Schema;
291
- exports.decodeJSON = decodeJSON;
292
- exports.decodeMsgpack = decodeMsgpack;
293
- exports.decodeObj = decodeObj;
294
- exports.encodeJSON = encodeJSON;
295
- exports.encodeMsgpack = encodeMsgpack;
296
- exports.encodeObj = encodeObj;
297
- exports.jsonEncodingDataToMsgpackEncodingData = jsonEncodingDataToMsgpackEncodingData;
298
- exports.msgpackEncodingDataToJSONEncodingData = msgpackEncodingDataToJSONEncodingData;
299
- exports.msgpackRawDecode = msgpackRawDecode;
300
- exports.msgpackRawDecodeAsMap = msgpackRawDecodeAsMap;
301
- exports.msgpackRawEncode = msgpackRawEncode;
302
- //# sourceMappingURL=encoding.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encoding.js","names":["IntDecoding","IntMode","bytesToBase64","obj: { [key: string]: JSONEncodingData }","RawBinaryString","parentResolved: MsgpackEncodingData","coerceToBytes","potentialKeyBytes: Uint8Array | undefined","arrayEqual","decoded: JSONEncodingData","parseJSON","stringifyJSON"],"sources":["../../../../../packages/sdk/src/encoding/encoding.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * This file is a wrapper of msgpack.js.\n * The wrapper was written in order to ensure correct encoding of Algorand Transaction and other formats.\n * In particular, it matches go-algorand blockchain client, written in go (https://www.github.com/algorand/go-algorand.\n * Algorand's msgpack encoding follows to following rules -\n * 1. Every integer must be encoded to the smallest type possible (0-255-\\>8bit, 256-65535-\\>16bit, etx)\n * 2. All fields names must be sorted\n * 3. All empty and 0 fields should be omitted\n * 4. Every positive number must be encoded as uint\n * 5. Binary blob should be used for binary data and string for strings\n * */\n\nimport {\n DecoderOptions,\n EncoderOptions,\n IntMode,\n RawBinaryString,\n decode as msgpackDecode,\n encode as msgpackEncode,\n} from 'algorand-msgpack'\nimport IntDecoding from '../types/intDecoding.js'\nimport { arrayEqual, parseJSON, stringifyJSON } from '../utils/utils.js'\nimport { bytesToBase64, coerceToBytes } from './binarydata.js'\n\n// Errors\nexport const ERROR_CONTAINS_EMPTY_STRING = 'The object contains empty or 0 values. First empty or 0 value encountered during encoding: '\n\n/**\n * containsEmpty returns true if any of the object's values are empty, false otherwise.\n * Empty arrays considered empty\n * @param obj - The object to check\n * @returns \\{true, empty key\\} if contains empty, \\{false, undefined\\} otherwise\n */\nfunction containsEmpty(obj: Record<string | number | symbol, any>) {\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n if (!obj[key] || obj[key].length === 0) {\n return { containsEmpty: true, firstEmptyKey: key }\n }\n }\n }\n return { containsEmpty: false, firstEmptyKey: undefined }\n}\n\n/**\n * msgpackRawEncode encodes objects using msgpack, regardless of whether there are\n * empty or 0 value fields.\n * @param obj - a dictionary to be encoded. May or may not contain empty or 0 values.\n * @returns msgpack representation of the object\n */\nexport function msgpackRawEncode(obj: unknown) {\n // enable the canonical option\n const options: EncoderOptions = { sortKeys: true }\n return msgpackEncode(obj, options)\n}\n\n/**\n * encodeObj takes a javascript object and returns its msgpack encoding\n * Note that the encoding sorts the fields alphabetically\n * @param o - js object to be encoded. Must not contain empty or 0 values.\n * @returns Uint8Array binary representation\n * @throws Error containing ERROR_CONTAINS_EMPTY_STRING if the object contains empty or zero values\n *\n * @deprecated Use {@link msgpackRawEncode} instead. Note that function does not\n * check for empty values like this one does.\n */\nexport function encodeObj(obj: Record<string | number | symbol, any>) {\n // Check for empty values\n const emptyCheck = containsEmpty(obj)\n if (emptyCheck.containsEmpty) {\n throw new Error(ERROR_CONTAINS_EMPTY_STRING + emptyCheck.firstEmptyKey)\n }\n return msgpackRawEncode(obj)\n}\n\nfunction intDecodingToIntMode(intDecoding: IntDecoding): IntMode {\n switch (intDecoding) {\n case IntDecoding.UNSAFE:\n return IntMode.UNSAFE_NUMBER\n case IntDecoding.SAFE:\n return IntMode.SAFE_NUMBER\n case IntDecoding.MIXED:\n return IntMode.MIXED\n case IntDecoding.BIGINT:\n return IntMode.BIGINT\n default:\n throw new Error(`Invalid intDecoding: ${intDecoding}`)\n }\n}\n\n/**\n * Decodes msgpack bytes into a plain JavaScript object.\n * @param buffer - The msgpack bytes to decode\n * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.\n * @returns The decoded object\n */\nexport function msgpackRawDecode(buffer: ArrayLike<number>, options?: { intDecoding: IntDecoding }) {\n const decoderOptions: DecoderOptions = {\n intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : IntMode.BIGINT,\n }\n return msgpackDecode(buffer, decoderOptions)\n}\n\n/**\n * decodeObj takes a Uint8Array and returns its javascript obj\n * @param o - Uint8Array to decode\n * @returns object\n *\n * @deprecated Use {@link msgpackRawDecode} instead. Note that this function uses `IntDecoding.MIXED`\n * while `msgpackRawDecode` defaults to `IntDecoding.BIGINT` for int decoding, though it is\n * configurable.\n */\nexport function decodeObj(o: ArrayLike<number>) {\n return msgpackRawDecode(o, { intDecoding: IntDecoding.MIXED })\n}\n\n/**\n * Decodes msgpack bytes into a Map object. This supports decoding non-string map keys.\n * @param encoded - The msgpack bytes to decode\n * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.\n * @returns The decoded Map object\n */\nexport function msgpackRawDecodeAsMap(encoded: ArrayLike<number>, options?: { intDecoding: IntDecoding }) {\n const decoderOptions: DecoderOptions = {\n intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : IntMode.BIGINT,\n useMap: true,\n }\n return msgpackDecode(encoded, decoderOptions)\n}\n\nfunction msgpackRawDecodeAsMapWithRawStrings(encoded: ArrayLike<number>, options?: { intDecoding: IntDecoding }) {\n const decoderOptions: DecoderOptions = {\n intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : IntMode.BIGINT,\n useMap: true,\n rawBinaryStringKeys: true,\n rawBinaryStringValues: true,\n useRawBinaryStringClass: true,\n }\n return msgpackDecode(encoded, decoderOptions)\n}\n\nexport type MsgpackEncodingData =\n | null\n | undefined\n | string\n | number\n | bigint\n | boolean\n | Uint8Array\n | MsgpackEncodingData[]\n | Map<string | number | bigint | Uint8Array, MsgpackEncodingData>\n\nexport type JSONEncodingData =\n | null\n | undefined\n | string\n | number\n | bigint\n | boolean\n | JSONEncodingData[]\n | { [key: string]: JSONEncodingData }\n\nexport function msgpackEncodingDataToJSONEncodingData(e: MsgpackEncodingData): JSONEncodingData {\n if (e === null || e === undefined) {\n return e as JSONEncodingData\n }\n if (e instanceof Uint8Array) {\n return bytesToBase64(e)\n }\n if (Array.isArray(e)) {\n return e.map(msgpackEncodingDataToJSONEncodingData)\n }\n if (e instanceof Map) {\n const obj: { [key: string]: JSONEncodingData } = {}\n for (const [k, v] of e) {\n if (typeof k !== 'string') {\n throw new Error(`JSON map key must be a string: ${k}`)\n }\n obj[k] = msgpackEncodingDataToJSONEncodingData(v)\n }\n return obj\n }\n return e\n}\n\nexport function jsonEncodingDataToMsgpackEncodingData(e: JSONEncodingData): MsgpackEncodingData {\n if (e === null || e === undefined) {\n return e as MsgpackEncodingData\n }\n if (\n typeof e === 'string' || // Note, this will not convert base64 to Uint8Array\n typeof e === 'number' ||\n typeof e === 'bigint' ||\n typeof e === 'boolean'\n ) {\n return e\n }\n if (Array.isArray(e)) {\n return e.map(jsonEncodingDataToMsgpackEncodingData)\n }\n if (typeof e === 'object') {\n const obj = new Map<string, MsgpackEncodingData>()\n for (const [key, value] of Object.entries(e)) {\n obj.set(key, jsonEncodingDataToMsgpackEncodingData(value))\n }\n return obj\n }\n throw new Error(`Invalid JSON encoding data: ${e}`)\n}\n\nenum MsgpackObjectPathSegmentKind {\n MAP_VALUE,\n ARRAY_ELEMENT,\n}\n\ninterface MsgpackObjectPathSegment {\n kind: MsgpackObjectPathSegmentKind\n key: string | number | bigint | Uint8Array | RawBinaryString\n}\n\n/**\n * This class is used to index into an encoded msgpack object and extract raw strings.\n */\nexport class MsgpackRawStringProvider {\n private readonly parent?: MsgpackRawStringProvider\n\n private readonly baseObjectBytes?: ArrayLike<number>\n\n private readonly segment?: MsgpackObjectPathSegment\n\n private resolvedCache: MsgpackEncodingData = null\n private resolvedCachePresent = false\n\n public constructor({\n parent,\n segment,\n baseObjectBytes,\n }:\n | {\n parent: MsgpackRawStringProvider\n segment: MsgpackObjectPathSegment\n baseObjectBytes?: undefined\n }\n | {\n parent?: undefined\n segment?: undefined\n baseObjectBytes: ArrayLike<number>\n }) {\n this.parent = parent\n this.segment = segment\n this.baseObjectBytes = baseObjectBytes\n }\n\n /**\n * Create a new provider that resolves to the current provider's map value at the given key.\n */\n public withMapValue(key: string | number | bigint | Uint8Array | RawBinaryString): MsgpackRawStringProvider {\n return new MsgpackRawStringProvider({\n parent: this,\n segment: {\n kind: MsgpackObjectPathSegmentKind.MAP_VALUE,\n key,\n },\n })\n }\n\n /**\n * Create a new provider that resolves to the current provider's array element at the given index.\n */\n public withArrayElement(index: number): MsgpackRawStringProvider {\n return new MsgpackRawStringProvider({\n parent: this,\n segment: {\n kind: MsgpackObjectPathSegmentKind.ARRAY_ELEMENT,\n key: index,\n },\n })\n }\n\n /**\n * Get the raw string at the current location. If the current location is not a raw string, an error is thrown.\n */\n public getRawStringAtCurrentLocation(): Uint8Array {\n const resolved = this.resolve()\n if (resolved instanceof RawBinaryString) {\n // Decoded rawBinaryValue will always be a Uint8Array\n return resolved.rawBinaryValue as Uint8Array\n }\n throw new Error(`Invalid type. Expected RawBinaryString, got ${resolved} (${typeof resolved})`)\n }\n\n /**\n * Get the raw string map keys and values at the current location. If the current location is not a map, an error is thrown.\n */\n public getRawStringKeysAndValuesAtCurrentLocation(): Map<Uint8Array, MsgpackEncodingData> {\n const resolved = this.resolve()\n if (!(resolved instanceof Map)) {\n throw new Error(`Invalid type. Expected Map, got ${resolved} (${typeof resolved})`)\n }\n const keysAndValues = new Map<Uint8Array, MsgpackEncodingData>()\n for (const [key, value] of resolved) {\n if (key instanceof RawBinaryString) {\n // Decoded rawBinaryValue will always be a Uint8Array\n keysAndValues.set(key.rawBinaryValue as Uint8Array, value)\n } else {\n throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${key} (${typeof key})`)\n }\n }\n return keysAndValues\n }\n\n /**\n * Resolve the provider by extracting the value it indicates from the base msgpack object.\n */\n private resolve(): MsgpackEncodingData {\n if (this.resolvedCachePresent) {\n return this.resolvedCache\n }\n let parentResolved: MsgpackEncodingData\n if (this.parent) {\n parentResolved = this.parent.resolve()\n } else {\n // Need to parse baseObjectBytes\n parentResolved = msgpackRawDecodeAsMapWithRawStrings(this.baseObjectBytes!) as MsgpackEncodingData\n }\n if (!this.segment) {\n this.resolvedCache = parentResolved\n this.resolvedCachePresent = true\n return parentResolved\n }\n if (this.segment.kind === MsgpackObjectPathSegmentKind.MAP_VALUE) {\n if (!(parentResolved instanceof Map)) {\n throw new Error(`Invalid type. Expected Map, got ${parentResolved} (${typeof parentResolved})`)\n }\n // All decoded map keys will be raw strings, and Map objects compare complex values by reference,\n // so we must check all the values for value-equality.\n if (typeof this.segment.key === 'string' || this.segment.key instanceof Uint8Array || this.segment.key instanceof RawBinaryString) {\n const targetBytes =\n this.segment.key instanceof RawBinaryString\n ? // Decoded rawBinaryValue will always be a Uint8Array\n (this.segment.key.rawBinaryValue as Uint8Array)\n : coerceToBytes(this.segment.key)\n const targetIsRawString = typeof this.segment.key === 'string' || this.segment.key instanceof RawBinaryString\n for (const [key, value] of parentResolved) {\n let potentialKeyBytes: Uint8Array | undefined\n if (targetIsRawString) {\n if (key instanceof RawBinaryString) {\n // Decoded rawBinaryValue will always be a Uint8Array\n potentialKeyBytes = key.rawBinaryValue as Uint8Array\n }\n } else if (key instanceof Uint8Array) {\n potentialKeyBytes = key\n }\n if (potentialKeyBytes && arrayEqual(targetBytes, potentialKeyBytes)) {\n this.resolvedCache = value\n break\n }\n }\n } else {\n this.resolvedCache = parentResolved.get(this.segment.key)\n }\n this.resolvedCachePresent = true\n return this.resolvedCache\n }\n if (this.segment.kind === MsgpackObjectPathSegmentKind.ARRAY_ELEMENT) {\n if (!Array.isArray(parentResolved)) {\n throw new Error(`Invalid type. Expected Array, got ${parentResolved} (${typeof parentResolved})`)\n }\n this.resolvedCache = parentResolved[this.segment.key as number]\n this.resolvedCachePresent = true\n return this.resolvedCache\n }\n throw new Error(`Invalid segment kind: ${this.segment.kind}`)\n }\n\n /**\n * Get the path string of the current location indicated by the provider. Useful for debugging.\n */\n public getPathString(): string {\n const parentPathString = this.parent ? this.parent.getPathString() : 'root'\n if (!this.segment) {\n return parentPathString\n }\n if (this.segment.kind === MsgpackObjectPathSegmentKind.MAP_VALUE) {\n return `${parentPathString} -> map key \"${this.segment.key}\" (${typeof this.segment.key})`\n }\n if (this.segment.kind === MsgpackObjectPathSegmentKind.ARRAY_ELEMENT) {\n return `${parentPathString} -> array index ${this.segment.key} (${typeof this.segment.key})`\n }\n return `${parentPathString} -> unknown segment kind ${this.segment.kind}`\n }\n}\n\n/**\n * Options for {@link Schema.prepareJSON}\n */\nexport interface PrepareJSONOptions {\n /**\n * If true, allows invalid UTF-8 binary strings to be converted to JSON strings.\n *\n * Otherwise, an error will be thrown if encoding a binary string to a JSON cannot be done losslessly.\n */\n lossyBinaryStringConversion?: boolean\n}\n\n/**\n * A Schema is used to prepare objects for encoding and decoding from msgpack and JSON.\n *\n * Schemas represent a specific type.\n */\nexport abstract class Schema {\n /**\n * Get the default value for this type.\n */\n public abstract defaultValue(): unknown\n\n /**\n * Checks if the value is the default value for this type.\n * @param data - The value to check\n * @returns True if the value is the default value, false otherwise\n */\n public abstract isDefaultValue(data: unknown): boolean\n\n /**\n * Prepares the encoding data for encoding to msgpack.\n * @param data - Encoding data to be prepared.\n * @returns A value ready to be msgpack encoded.\n */\n public abstract prepareMsgpack(data: unknown): MsgpackEncodingData\n\n /**\n * Restores the encoding data from a msgpack encoding object.\n * @param encoded - The msgpack encoding object to restore.\n * @param rawStringProvider - A provider for raw strings.\n * @returns The original encoding data.\n */\n public abstract fromPreparedMsgpack(encoded: MsgpackEncodingData, rawStringProvider: MsgpackRawStringProvider): unknown\n\n /**\n * Prepares the encoding data for encoding to JSON.\n * @param data - The JSON encoding data to be prepared.\n * @returns A value ready to be JSON encoded.\n */\n public abstract prepareJSON(data: unknown, options: PrepareJSONOptions): JSONEncodingData\n\n /**\n * Restores the encoding data from a JSON encoding object.\n * @param encoded - The JSON encoding object to restore.\n * @returns The original encoding data.\n */\n public abstract fromPreparedJSON(encoded: JSONEncodingData): unknown\n}\n\n/**\n * An interface for objects that can be encoded and decoded to/from msgpack and JSON.\n */\nexport interface Encodable {\n /**\n * Extract the encoding data for this object. This data, after being prepared by the encoding\n * Schema, can be encoded to msgpack or JSON.\n */\n toEncodingData(): unknown\n /**\n * Get the encoding Schema for this object, used to prepare the encoding data for msgpack and JSON.\n */\n getEncodingSchema(): Schema\n}\n\n/**\n * A type that represents the class of an Encodable object.\n */\nexport interface EncodableClass<T extends Encodable> {\n /**\n * Create a new instance of this class from the given encoding data.\n * @param data - The encoding data to create the object from\n */\n fromEncodingData(data: unknown): T\n /**\n * The encoding Schema for this class, used to prepare encoding data from msgpack and JSON.\n */\n readonly encodingSchema: Schema\n}\n\n/**\n * Decode a msgpack byte array to an Encodable object.\n * @param encoded - The msgpack bytes to decode\n * @param c - The class of the object to decode. This class must match the object that was encoded.\n * @returns An instance of the class with the decoded data\n */\nexport function decodeMsgpack<T extends Encodable>(encoded: ArrayLike<number>, c: EncodableClass<T>): T {\n const decoded = msgpackRawDecodeAsMap(encoded) as MsgpackEncodingData\n const rawStringProvider = new MsgpackRawStringProvider({\n baseObjectBytes: encoded,\n })\n return c.fromEncodingData(c.encodingSchema.fromPreparedMsgpack(decoded, rawStringProvider))\n}\n\n/**\n * Encode an Encodable object to a msgpack byte array.\n * @param e - The object to encode\n * @returns A msgpack byte array encoding of the object\n */\nexport function encodeMsgpack(e: Encodable): Uint8Array {\n return msgpackRawEncode(e.getEncodingSchema().prepareMsgpack(e.toEncodingData()))\n}\n\n/**\n * Decode a JSON string to an Encodable object.\n * @param encoded - The JSON string to decode\n * @param c - The class of the object to decode. This class must match the object that was encoded.\n * @returns An instance of the class with the decoded data\n */\nexport function decodeJSON<T extends Encodable>(encoded: string, c: EncodableClass<T>): T {\n const decoded: JSONEncodingData = parseJSON(encoded, {\n intDecoding: IntDecoding.BIGINT,\n })\n return c.fromEncodingData(c.encodingSchema.fromPreparedJSON(decoded) as JSONEncodingData)\n}\n\nexport interface EncodeJSONOptions {\n /**\n * Adds indentation, white space, and line break characters to the return-value JSON text to make\n * it easier to read.\n */\n space?: string | number\n\n /**\n * If true, allows invalid UTF-8 binary strings to be converted to JSON strings.\n *\n * Otherwise, an error will be thrown if encoding a binary string to a JSON cannot be done losslessly.\n */\n lossyBinaryStringConversion?: boolean\n}\n\n/**\n * Encode an Encodable object to a JSON string.\n * @param e - The object to encode\n * @param options - Optional encoding options. See {@link EncodeJSONOptions} for more information.\n * @returns A JSON string encoding of the object\n */\nexport function encodeJSON(e: Encodable, options?: EncodeJSONOptions): string {\n const { space, ...prepareJSONOptions } = options ?? {}\n const prepared = e.getEncodingSchema().prepareJSON(e.toEncodingData(), prepareJSONOptions)\n return stringifyJSON(prepared, undefined, space)\n}\n"],"mappings":";;;;;;;;AA0BA,MAAa,8BAA8B;;;;;;;AAQ3C,SAAS,cAAc,KAA4C;AACjE,MAAK,MAAM,OAAO,IAChB,KAAI,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI,EAChD;MAAI,CAAC,IAAI,QAAQ,IAAI,KAAK,WAAW,EACnC,QAAO;GAAE,eAAe;GAAM,eAAe;GAAK;;AAIxD,QAAO;EAAE,eAAe;EAAO,eAAe;EAAW;;;;;;;;AAS3D,SAAgB,iBAAiB,KAAc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AAC,CAAC;;;;;;;;AASnF,SAAgB,WAAgC,SAAiB,GAAyB;CACxF,MAAMC,UAA4BC,wBAAU,SAAS,EACnD,aAAaV,4BAAY,QAC1B,CAAC;AACF,QAAO,EAAE,iBAAiB,EAAE,eAAe,iBAAiB,QAAQ,CAAqB;;;;;;;;AAwB3F,SAAgB,WAAW,GAAc,SAAqC;CAC5E,MAAM,EAAE,MAAO,GAAG,uBAAuB,WAAW,EAAE;AAEtD,QAAOW,4BADU,EAAE,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAC3D,QAAW,MAAM"}
@@ -1,287 +0,0 @@
1
- import intDecoding_default from "../types/intDecoding.mjs";
2
- import { arrayEqual, parseJSON, stringifyJSON } from "../utils/utils.mjs";
3
- import { bytesToBase64, coerceToBytes } from "./binarydata.mjs";
4
- import { IntMode, RawBinaryString, decode, encode } from "algorand-msgpack";
5
-
6
- //#region packages/sdk/src/encoding/encoding.ts
7
- const ERROR_CONTAINS_EMPTY_STRING = "The object contains empty or 0 values. First empty or 0 value encountered during encoding: ";
8
- /**
9
- * containsEmpty returns true if any of the object's values are empty, false otherwise.
10
- * Empty arrays considered empty
11
- * @param obj - The object to check
12
- * @returns \{true, empty key\} if contains empty, \{false, undefined\} otherwise
13
- */
14
- function containsEmpty(obj) {
15
- for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) {
16
- if (!obj[key] || obj[key].length === 0) return {
17
- containsEmpty: true,
18
- firstEmptyKey: key
19
- };
20
- }
21
- return {
22
- containsEmpty: false,
23
- firstEmptyKey: void 0
24
- };
25
- }
26
- /**
27
- * msgpackRawEncode encodes objects using msgpack, regardless of whether there are
28
- * empty or 0 value fields.
29
- * @param obj - a dictionary to be encoded. May or may not contain empty or 0 values.
30
- * @returns msgpack representation of the object
31
- */
32
- function msgpackRawEncode(obj) {
33
- return encode(obj, { sortKeys: true });
34
- }
35
- /**
36
- * encodeObj takes a javascript object and returns its msgpack encoding
37
- * Note that the encoding sorts the fields alphabetically
38
- * @param o - js object to be encoded. Must not contain empty or 0 values.
39
- * @returns Uint8Array binary representation
40
- * @throws Error containing ERROR_CONTAINS_EMPTY_STRING if the object contains empty or zero values
41
- *
42
- * @deprecated Use {@link msgpackRawEncode} instead. Note that function does not
43
- * check for empty values like this one does.
44
- */
45
- function encodeObj(obj) {
46
- const emptyCheck = containsEmpty(obj);
47
- if (emptyCheck.containsEmpty) throw new Error(ERROR_CONTAINS_EMPTY_STRING + emptyCheck.firstEmptyKey);
48
- return msgpackRawEncode(obj);
49
- }
50
- function intDecodingToIntMode(intDecoding) {
51
- switch (intDecoding) {
52
- case intDecoding_default.UNSAFE: return IntMode.UNSAFE_NUMBER;
53
- case intDecoding_default.SAFE: return IntMode.SAFE_NUMBER;
54
- case intDecoding_default.MIXED: return IntMode.MIXED;
55
- case intDecoding_default.BIGINT: return IntMode.BIGINT;
56
- default: throw new Error(`Invalid intDecoding: ${intDecoding}`);
57
- }
58
- }
59
- /**
60
- * Decodes msgpack bytes into a plain JavaScript object.
61
- * @param buffer - The msgpack bytes to decode
62
- * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.
63
- * @returns The decoded object
64
- */
65
- function msgpackRawDecode(buffer, options) {
66
- return decode(buffer, { intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : IntMode.BIGINT });
67
- }
68
- /**
69
- * decodeObj takes a Uint8Array and returns its javascript obj
70
- * @param o - Uint8Array to decode
71
- * @returns object
72
- *
73
- * @deprecated Use {@link msgpackRawDecode} instead. Note that this function uses `IntDecoding.MIXED`
74
- * while `msgpackRawDecode` defaults to `IntDecoding.BIGINT` for int decoding, though it is
75
- * configurable.
76
- */
77
- function decodeObj(o) {
78
- return msgpackRawDecode(o, { intDecoding: intDecoding_default.MIXED });
79
- }
80
- /**
81
- * Decodes msgpack bytes into a Map object. This supports decoding non-string map keys.
82
- * @param encoded - The msgpack bytes to decode
83
- * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.
84
- * @returns The decoded Map object
85
- */
86
- function msgpackRawDecodeAsMap(encoded, options) {
87
- return decode(encoded, {
88
- intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : IntMode.BIGINT,
89
- useMap: true
90
- });
91
- }
92
- function msgpackRawDecodeAsMapWithRawStrings(encoded, options) {
93
- return decode(encoded, {
94
- intMode: options?.intDecoding ? intDecodingToIntMode(options?.intDecoding) : IntMode.BIGINT,
95
- useMap: true,
96
- rawBinaryStringKeys: true,
97
- rawBinaryStringValues: true,
98
- useRawBinaryStringClass: true
99
- });
100
- }
101
- function msgpackEncodingDataToJSONEncodingData(e) {
102
- if (e === null || e === void 0) return e;
103
- if (e instanceof Uint8Array) return bytesToBase64(e);
104
- if (Array.isArray(e)) return e.map(msgpackEncodingDataToJSONEncodingData);
105
- if (e instanceof Map) {
106
- const obj = {};
107
- for (const [k, v] of e) {
108
- if (typeof k !== "string") throw new Error(`JSON map key must be a string: ${k}`);
109
- obj[k] = msgpackEncodingDataToJSONEncodingData(v);
110
- }
111
- return obj;
112
- }
113
- return e;
114
- }
115
- function jsonEncodingDataToMsgpackEncodingData(e) {
116
- if (e === null || e === void 0) return e;
117
- if (typeof e === "string" || typeof e === "number" || typeof e === "bigint" || typeof e === "boolean") return e;
118
- if (Array.isArray(e)) return e.map(jsonEncodingDataToMsgpackEncodingData);
119
- if (typeof e === "object") {
120
- const obj = /* @__PURE__ */ new Map();
121
- for (const [key, value] of Object.entries(e)) obj.set(key, jsonEncodingDataToMsgpackEncodingData(value));
122
- return obj;
123
- }
124
- throw new Error(`Invalid JSON encoding data: ${e}`);
125
- }
126
- var MsgpackObjectPathSegmentKind = /* @__PURE__ */ function(MsgpackObjectPathSegmentKind$1) {
127
- MsgpackObjectPathSegmentKind$1[MsgpackObjectPathSegmentKind$1["MAP_VALUE"] = 0] = "MAP_VALUE";
128
- MsgpackObjectPathSegmentKind$1[MsgpackObjectPathSegmentKind$1["ARRAY_ELEMENT"] = 1] = "ARRAY_ELEMENT";
129
- return MsgpackObjectPathSegmentKind$1;
130
- }(MsgpackObjectPathSegmentKind || {});
131
- /**
132
- * This class is used to index into an encoded msgpack object and extract raw strings.
133
- */
134
- var MsgpackRawStringProvider = class MsgpackRawStringProvider {
135
- parent;
136
- baseObjectBytes;
137
- segment;
138
- resolvedCache = null;
139
- resolvedCachePresent = false;
140
- constructor({ parent, segment, baseObjectBytes }) {
141
- this.parent = parent;
142
- this.segment = segment;
143
- this.baseObjectBytes = baseObjectBytes;
144
- }
145
- /**
146
- * Create a new provider that resolves to the current provider's map value at the given key.
147
- */
148
- withMapValue(key) {
149
- return new MsgpackRawStringProvider({
150
- parent: this,
151
- segment: {
152
- kind: MsgpackObjectPathSegmentKind.MAP_VALUE,
153
- key
154
- }
155
- });
156
- }
157
- /**
158
- * Create a new provider that resolves to the current provider's array element at the given index.
159
- */
160
- withArrayElement(index) {
161
- return new MsgpackRawStringProvider({
162
- parent: this,
163
- segment: {
164
- kind: MsgpackObjectPathSegmentKind.ARRAY_ELEMENT,
165
- key: index
166
- }
167
- });
168
- }
169
- /**
170
- * Get the raw string at the current location. If the current location is not a raw string, an error is thrown.
171
- */
172
- getRawStringAtCurrentLocation() {
173
- const resolved = this.resolve();
174
- if (resolved instanceof RawBinaryString) return resolved.rawBinaryValue;
175
- throw new Error(`Invalid type. Expected RawBinaryString, got ${resolved} (${typeof resolved})`);
176
- }
177
- /**
178
- * Get the raw string map keys and values at the current location. If the current location is not a map, an error is thrown.
179
- */
180
- getRawStringKeysAndValuesAtCurrentLocation() {
181
- const resolved = this.resolve();
182
- if (!(resolved instanceof Map)) throw new Error(`Invalid type. Expected Map, got ${resolved} (${typeof resolved})`);
183
- const keysAndValues = /* @__PURE__ */ new Map();
184
- for (const [key, value] of resolved) if (key instanceof RawBinaryString) keysAndValues.set(key.rawBinaryValue, value);
185
- else throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${key} (${typeof key})`);
186
- return keysAndValues;
187
- }
188
- /**
189
- * Resolve the provider by extracting the value it indicates from the base msgpack object.
190
- */
191
- resolve() {
192
- if (this.resolvedCachePresent) return this.resolvedCache;
193
- let parentResolved;
194
- if (this.parent) parentResolved = this.parent.resolve();
195
- else parentResolved = msgpackRawDecodeAsMapWithRawStrings(this.baseObjectBytes);
196
- if (!this.segment) {
197
- this.resolvedCache = parentResolved;
198
- this.resolvedCachePresent = true;
199
- return parentResolved;
200
- }
201
- if (this.segment.kind === MsgpackObjectPathSegmentKind.MAP_VALUE) {
202
- if (!(parentResolved instanceof Map)) throw new Error(`Invalid type. Expected Map, got ${parentResolved} (${typeof parentResolved})`);
203
- if (typeof this.segment.key === "string" || this.segment.key instanceof Uint8Array || this.segment.key instanceof RawBinaryString) {
204
- const targetBytes = this.segment.key instanceof RawBinaryString ? this.segment.key.rawBinaryValue : coerceToBytes(this.segment.key);
205
- const targetIsRawString = typeof this.segment.key === "string" || this.segment.key instanceof RawBinaryString;
206
- for (const [key, value] of parentResolved) {
207
- let potentialKeyBytes;
208
- if (targetIsRawString) {
209
- if (key instanceof RawBinaryString) potentialKeyBytes = key.rawBinaryValue;
210
- } else if (key instanceof Uint8Array) potentialKeyBytes = key;
211
- if (potentialKeyBytes && arrayEqual(targetBytes, potentialKeyBytes)) {
212
- this.resolvedCache = value;
213
- break;
214
- }
215
- }
216
- } else this.resolvedCache = parentResolved.get(this.segment.key);
217
- this.resolvedCachePresent = true;
218
- return this.resolvedCache;
219
- }
220
- if (this.segment.kind === MsgpackObjectPathSegmentKind.ARRAY_ELEMENT) {
221
- if (!Array.isArray(parentResolved)) throw new Error(`Invalid type. Expected Array, got ${parentResolved} (${typeof parentResolved})`);
222
- this.resolvedCache = parentResolved[this.segment.key];
223
- this.resolvedCachePresent = true;
224
- return this.resolvedCache;
225
- }
226
- throw new Error(`Invalid segment kind: ${this.segment.kind}`);
227
- }
228
- /**
229
- * Get the path string of the current location indicated by the provider. Useful for debugging.
230
- */
231
- getPathString() {
232
- const parentPathString = this.parent ? this.parent.getPathString() : "root";
233
- if (!this.segment) return parentPathString;
234
- if (this.segment.kind === MsgpackObjectPathSegmentKind.MAP_VALUE) return `${parentPathString} -> map key "${this.segment.key}" (${typeof this.segment.key})`;
235
- if (this.segment.kind === MsgpackObjectPathSegmentKind.ARRAY_ELEMENT) return `${parentPathString} -> array index ${this.segment.key} (${typeof this.segment.key})`;
236
- return `${parentPathString} -> unknown segment kind ${this.segment.kind}`;
237
- }
238
- };
239
- /**
240
- * A Schema is used to prepare objects for encoding and decoding from msgpack and JSON.
241
- *
242
- * Schemas represent a specific type.
243
- */
244
- var Schema = class {};
245
- /**
246
- * Decode a msgpack byte array to an Encodable object.
247
- * @param encoded - The msgpack bytes to decode
248
- * @param c - The class of the object to decode. This class must match the object that was encoded.
249
- * @returns An instance of the class with the decoded data
250
- */
251
- function decodeMsgpack(encoded, c) {
252
- const decoded = msgpackRawDecodeAsMap(encoded);
253
- const rawStringProvider = new MsgpackRawStringProvider({ baseObjectBytes: encoded });
254
- return c.fromEncodingData(c.encodingSchema.fromPreparedMsgpack(decoded, rawStringProvider));
255
- }
256
- /**
257
- * Encode an Encodable object to a msgpack byte array.
258
- * @param e - The object to encode
259
- * @returns A msgpack byte array encoding of the object
260
- */
261
- function encodeMsgpack(e) {
262
- return msgpackRawEncode(e.getEncodingSchema().prepareMsgpack(e.toEncodingData()));
263
- }
264
- /**
265
- * Decode a JSON string to an Encodable object.
266
- * @param encoded - The JSON string to decode
267
- * @param c - The class of the object to decode. This class must match the object that was encoded.
268
- * @returns An instance of the class with the decoded data
269
- */
270
- function decodeJSON(encoded, c) {
271
- const decoded = parseJSON(encoded, { intDecoding: intDecoding_default.BIGINT });
272
- return c.fromEncodingData(c.encodingSchema.fromPreparedJSON(decoded));
273
- }
274
- /**
275
- * Encode an Encodable object to a JSON string.
276
- * @param e - The object to encode
277
- * @param options - Optional encoding options. See {@link EncodeJSONOptions} for more information.
278
- * @returns A JSON string encoding of the object
279
- */
280
- function encodeJSON(e, options) {
281
- const { space,...prepareJSONOptions } = options ?? {};
282
- return stringifyJSON(e.getEncodingSchema().prepareJSON(e.toEncodingData(), prepareJSONOptions), void 0, space);
283
- }
284
-
285
- //#endregion
286
- export { ERROR_CONTAINS_EMPTY_STRING, MsgpackRawStringProvider, Schema, decodeJSON, decodeMsgpack, decodeObj, encodeJSON, encodeMsgpack, encodeObj, jsonEncodingDataToMsgpackEncodingData, msgpackEncodingDataToJSONEncodingData, msgpackRawDecode, msgpackRawDecodeAsMap, msgpackRawEncode };
287
- //# sourceMappingURL=encoding.mjs.map