@haneullabs/haneul 2.5.1 → 2.13.0

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 (454) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +36 -36
  3. package/dist/bcs/bcs.d.mts +6 -7
  4. package/dist/bcs/bcs.d.mts.map +1 -1
  5. package/dist/bcs/bcs.mjs.map +1 -1
  6. package/dist/bcs/effects.mjs.map +1 -1
  7. package/dist/bcs/index.d.mts +2 -2
  8. package/dist/bcs/index.d.mts.map +1 -1
  9. package/dist/bcs/index.mjs +2 -2
  10. package/dist/bcs/index.mjs.map +1 -1
  11. package/dist/bcs/pure.d.mts.map +1 -1
  12. package/dist/bcs/type-tag-serializer.d.mts.map +1 -1
  13. package/dist/bcs/types.d.mts +0 -1
  14. package/dist/bcs/types.d.mts.map +1 -1
  15. package/dist/client/cache.d.mts.map +1 -1
  16. package/dist/client/client.d.mts.map +1 -1
  17. package/dist/client/core-resolver.d.mts.map +1 -1
  18. package/dist/client/core-resolver.mjs +87 -68
  19. package/dist/client/core-resolver.mjs.map +1 -1
  20. package/dist/client/core.d.mts +9 -8
  21. package/dist/client/core.d.mts.map +1 -1
  22. package/dist/client/core.mjs +29 -10
  23. package/dist/client/core.mjs.map +1 -1
  24. package/dist/client/errors.d.mts.map +1 -1
  25. package/dist/client/mvr.d.mts +0 -1
  26. package/dist/client/mvr.d.mts.map +1 -1
  27. package/dist/client/types.d.mts +110 -24
  28. package/dist/client/types.d.mts.map +1 -1
  29. package/dist/client/utils.d.mts.map +1 -1
  30. package/dist/client/utils.mjs +7 -7
  31. package/dist/client/utils.mjs.map +1 -1
  32. package/dist/cryptography/index.d.mts +2 -2
  33. package/dist/cryptography/index.mjs +2 -2
  34. package/dist/cryptography/intent.d.mts +2 -2
  35. package/dist/cryptography/intent.d.mts.map +1 -1
  36. package/dist/cryptography/intent.mjs +2 -2
  37. package/dist/cryptography/intent.mjs.map +1 -1
  38. package/dist/cryptography/keypair.d.mts +3 -3
  39. package/dist/cryptography/keypair.d.mts.map +1 -1
  40. package/dist/cryptography/keypair.mjs +3 -3
  41. package/dist/cryptography/keypair.mjs.map +1 -1
  42. package/dist/cryptography/mnemonics.d.mts +5 -5
  43. package/dist/cryptography/mnemonics.d.mts.map +1 -1
  44. package/dist/cryptography/mnemonics.mjs +7 -7
  45. package/dist/cryptography/mnemonics.mjs.map +1 -1
  46. package/dist/cryptography/publickey.d.mts +2 -3
  47. package/dist/cryptography/publickey.d.mts.map +1 -1
  48. package/dist/cryptography/publickey.mjs +10 -10
  49. package/dist/cryptography/publickey.mjs.map +1 -1
  50. package/dist/cryptography/signature-scheme.d.mts.map +1 -1
  51. package/dist/cryptography/signature.d.mts +10 -13
  52. package/dist/cryptography/signature.d.mts.map +1 -1
  53. package/dist/cryptography/signature.mjs +2 -2
  54. package/dist/cryptography/signature.mjs.map +1 -1
  55. package/dist/faucet/faucet.d.mts +2 -2
  56. package/dist/faucet/faucet.d.mts.map +1 -1
  57. package/dist/faucet/faucet.mjs +2 -2
  58. package/dist/faucet/faucet.mjs.map +1 -1
  59. package/dist/faucet/index.d.mts +2 -2
  60. package/dist/faucet/index.mjs +2 -2
  61. package/dist/graphql/client.d.mts +20 -5
  62. package/dist/graphql/client.d.mts.map +1 -1
  63. package/dist/graphql/client.mjs +55 -7
  64. package/dist/graphql/client.mjs.map +1 -1
  65. package/dist/graphql/core.d.mts +6 -5
  66. package/dist/graphql/core.d.mts.map +1 -1
  67. package/dist/graphql/core.mjs +43 -47
  68. package/dist/graphql/core.mjs.map +1 -1
  69. package/dist/graphql/generated/queries.d.mts +0 -1
  70. package/dist/graphql/generated/queries.d.mts.map +1 -1
  71. package/dist/graphql/generated/queries.mjs +46 -10
  72. package/dist/graphql/generated/queries.mjs.map +1 -1
  73. package/dist/graphql/generated/tada-env.d.mts +706 -98
  74. package/dist/graphql/generated/tada-env.d.mts.map +1 -1
  75. package/dist/graphql/index.d.mts +2 -2
  76. package/dist/graphql/index.mjs +2 -2
  77. package/dist/graphql/schema/index.d.mts +0 -1
  78. package/dist/graphql/schema/index.d.mts.map +1 -1
  79. package/dist/graphql/types.d.mts.map +1 -1
  80. package/dist/grpc/client.d.mts +20 -5
  81. package/dist/grpc/client.d.mts.map +1 -1
  82. package/dist/grpc/client.mjs +47 -7
  83. package/dist/grpc/client.mjs.map +1 -1
  84. package/dist/grpc/core.d.mts +6 -5
  85. package/dist/grpc/core.d.mts.map +1 -1
  86. package/dist/grpc/core.mjs +35 -34
  87. package/dist/grpc/core.mjs.map +1 -1
  88. package/dist/grpc/index.d.mts +2 -2
  89. package/dist/grpc/index.mjs +2 -2
  90. package/dist/grpc/proto/google/protobuf/any.d.mts +0 -1
  91. package/dist/grpc/proto/google/protobuf/any.d.mts.map +1 -1
  92. package/dist/grpc/proto/google/protobuf/duration.d.mts +0 -1
  93. package/dist/grpc/proto/google/protobuf/duration.d.mts.map +1 -1
  94. package/dist/grpc/proto/google/protobuf/field_mask.d.mts +0 -1
  95. package/dist/grpc/proto/google/protobuf/field_mask.d.mts.map +1 -1
  96. package/dist/grpc/proto/google/protobuf/struct.d.mts +1 -2
  97. package/dist/grpc/proto/google/protobuf/struct.d.mts.map +1 -1
  98. package/dist/grpc/proto/google/protobuf/timestamp.d.mts +0 -1
  99. package/dist/grpc/proto/google/protobuf/timestamp.d.mts.map +1 -1
  100. package/dist/grpc/proto/google/rpc/status.d.mts +0 -1
  101. package/dist/grpc/proto/google/rpc/status.d.mts.map +1 -1
  102. package/dist/grpc/proto/haneul/rpc/v2/argument.d.mts +1 -2
  103. package/dist/grpc/proto/haneul/rpc/v2/argument.d.mts.map +1 -1
  104. package/dist/grpc/proto/haneul/rpc/v2/balance_change.d.mts +0 -1
  105. package/dist/grpc/proto/haneul/rpc/v2/balance_change.d.mts.map +1 -1
  106. package/dist/grpc/proto/haneul/rpc/v2/bcs.d.mts +1 -2
  107. package/dist/grpc/proto/haneul/rpc/v2/bcs.d.mts.map +1 -1
  108. package/dist/grpc/proto/haneul/rpc/v2/bcs.mjs.map +1 -1
  109. package/dist/grpc/proto/haneul/rpc/v2/checkpoint.d.mts +0 -1
  110. package/dist/grpc/proto/haneul/rpc/v2/checkpoint.d.mts.map +1 -1
  111. package/dist/grpc/proto/haneul/rpc/v2/checkpoint_contents.d.mts +0 -1
  112. package/dist/grpc/proto/haneul/rpc/v2/checkpoint_contents.d.mts.map +1 -1
  113. package/dist/grpc/proto/haneul/rpc/v2/checkpoint_summary.d.mts +1 -2
  114. package/dist/grpc/proto/haneul/rpc/v2/checkpoint_summary.d.mts.map +1 -1
  115. package/dist/grpc/proto/haneul/rpc/v2/effects.d.mts +5 -6
  116. package/dist/grpc/proto/haneul/rpc/v2/effects.d.mts.map +1 -1
  117. package/dist/grpc/proto/haneul/rpc/v2/epoch.d.mts +0 -1
  118. package/dist/grpc/proto/haneul/rpc/v2/epoch.d.mts.map +1 -1
  119. package/dist/grpc/proto/haneul/rpc/v2/error_reason.d.mts +1 -1
  120. package/dist/grpc/proto/haneul/rpc/v2/error_reason.d.mts.map +1 -1
  121. package/dist/grpc/proto/haneul/rpc/v2/event.d.mts +0 -1
  122. package/dist/grpc/proto/haneul/rpc/v2/event.d.mts.map +1 -1
  123. package/dist/grpc/proto/haneul/rpc/v2/executed_transaction.d.mts +0 -1
  124. package/dist/grpc/proto/haneul/rpc/v2/executed_transaction.d.mts.map +1 -1
  125. package/dist/grpc/proto/haneul/rpc/v2/execution_status.d.mts +8 -9
  126. package/dist/grpc/proto/haneul/rpc/v2/execution_status.d.mts.map +1 -1
  127. package/dist/grpc/proto/haneul/rpc/v2/execution_status.mjs +4 -4
  128. package/dist/grpc/proto/haneul/rpc/v2/execution_status.mjs.map +1 -1
  129. package/dist/grpc/proto/haneul/rpc/v2/gas_cost_summary.d.mts +0 -1
  130. package/dist/grpc/proto/haneul/rpc/v2/gas_cost_summary.d.mts.map +1 -1
  131. package/dist/grpc/proto/haneul/rpc/v2/input.d.mts +3 -4
  132. package/dist/grpc/proto/haneul/rpc/v2/input.d.mts.map +1 -1
  133. package/dist/grpc/proto/haneul/rpc/v2/jwk.d.mts +0 -1
  134. package/dist/grpc/proto/haneul/rpc/v2/jwk.d.mts.map +1 -1
  135. package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts +4 -5
  136. package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts.map +1 -1
  137. package/dist/grpc/proto/haneul/rpc/v2/ledger_service.d.mts +0 -1
  138. package/dist/grpc/proto/haneul/rpc/v2/ledger_service.d.mts.map +1 -1
  139. package/dist/grpc/proto/haneul/rpc/v2/move_package.d.mts +5 -6
  140. package/dist/grpc/proto/haneul/rpc/v2/move_package.d.mts.map +1 -1
  141. package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts +4 -5
  142. package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts.map +1 -1
  143. package/dist/grpc/proto/haneul/rpc/v2/move_package_service.d.mts +0 -1
  144. package/dist/grpc/proto/haneul/rpc/v2/move_package_service.d.mts.map +1 -1
  145. package/dist/grpc/proto/haneul/rpc/v2/name_service.client.d.mts +4 -5
  146. package/dist/grpc/proto/haneul/rpc/v2/name_service.client.d.mts.map +1 -1
  147. package/dist/grpc/proto/haneul/rpc/v2/name_service.d.mts +0 -1
  148. package/dist/grpc/proto/haneul/rpc/v2/name_service.d.mts.map +1 -1
  149. package/dist/grpc/proto/haneul/rpc/v2/object.d.mts +38 -2
  150. package/dist/grpc/proto/haneul/rpc/v2/object.d.mts.map +1 -1
  151. package/dist/grpc/proto/haneul/rpc/v2/object.mjs +26 -1
  152. package/dist/grpc/proto/haneul/rpc/v2/object.mjs.map +1 -1
  153. package/dist/grpc/proto/haneul/rpc/v2/object_reference.d.mts +0 -1
  154. package/dist/grpc/proto/haneul/rpc/v2/object_reference.d.mts.map +1 -1
  155. package/dist/grpc/proto/haneul/rpc/v2/owner.d.mts +1 -2
  156. package/dist/grpc/proto/haneul/rpc/v2/owner.d.mts.map +1 -1
  157. package/dist/grpc/proto/haneul/rpc/v2/protocol_config.d.mts +0 -1
  158. package/dist/grpc/proto/haneul/rpc/v2/protocol_config.d.mts.map +1 -1
  159. package/dist/grpc/proto/haneul/rpc/v2/signature.d.mts +1 -2
  160. package/dist/grpc/proto/haneul/rpc/v2/signature.d.mts.map +1 -1
  161. package/dist/grpc/proto/haneul/rpc/v2/signature.mjs.map +1 -1
  162. package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.d.mts +2 -2
  163. package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.d.mts.map +1 -1
  164. package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.mjs +1 -1
  165. package/dist/grpc/proto/haneul/rpc/v2/signature_scheme.mjs.map +1 -1
  166. package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts +4 -5
  167. package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.client.d.mts.map +1 -1
  168. package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.d.mts +0 -1
  169. package/dist/grpc/proto/haneul/rpc/v2/signature_verification_service.d.mts.map +1 -1
  170. package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts +4 -5
  171. package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts.map +1 -1
  172. package/dist/grpc/proto/haneul/rpc/v2/state_service.d.mts +4 -5
  173. package/dist/grpc/proto/haneul/rpc/v2/state_service.d.mts.map +1 -1
  174. package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts +4 -5
  175. package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts.map +1 -1
  176. package/dist/grpc/proto/haneul/rpc/v2/subscription_service.d.mts +0 -1
  177. package/dist/grpc/proto/haneul/rpc/v2/subscription_service.d.mts.map +1 -1
  178. package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts +3 -4
  179. package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts.map +1 -1
  180. package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs +1 -1
  181. package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs.map +1 -1
  182. package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts +4 -5
  183. package/dist/grpc/proto/haneul/rpc/v2/transaction.d.mts.map +1 -1
  184. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts +0 -1
  185. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts.map +1 -1
  186. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.d.mts +9 -2
  187. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  188. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.mjs +23 -12
  189. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.mjs.map +1 -1
  190. package/dist/grpc/proto/types.d.mts +2 -2
  191. package/dist/grpc/proto/types.d.mts.map +1 -1
  192. package/dist/grpc/proto/types.mjs +2 -1
  193. package/dist/jsonRpc/client.d.mts +4 -7
  194. package/dist/jsonRpc/client.d.mts.map +1 -1
  195. package/dist/jsonRpc/client.mjs +4 -33
  196. package/dist/jsonRpc/client.mjs.map +1 -1
  197. package/dist/jsonRpc/core.d.mts +8 -15
  198. package/dist/jsonRpc/core.d.mts.map +1 -1
  199. package/dist/jsonRpc/core.mjs +81 -34
  200. package/dist/jsonRpc/core.mjs.map +1 -1
  201. package/dist/jsonRpc/errors.d.mts.map +1 -1
  202. package/dist/jsonRpc/http-transport.d.mts +1 -17
  203. package/dist/jsonRpc/http-transport.d.mts.map +1 -1
  204. package/dist/jsonRpc/http-transport.mjs +0 -23
  205. package/dist/jsonRpc/http-transport.mjs.map +1 -1
  206. package/dist/jsonRpc/index.d.mts +3 -3
  207. package/dist/jsonRpc/network.d.mts.map +1 -1
  208. package/dist/jsonRpc/types/chain.d.mts.map +1 -1
  209. package/dist/jsonRpc/types/changes.d.mts.map +1 -1
  210. package/dist/jsonRpc/types/coins.d.mts.map +1 -1
  211. package/dist/jsonRpc/types/common.d.mts +1 -2
  212. package/dist/jsonRpc/types/common.d.mts.map +1 -1
  213. package/dist/jsonRpc/types/generated.d.mts +101 -129
  214. package/dist/jsonRpc/types/generated.d.mts.map +1 -1
  215. package/dist/jsonRpc/types/index.d.mts +1 -1
  216. package/dist/jsonRpc/types/params.d.mts +9 -14
  217. package/dist/jsonRpc/types/params.d.mts.map +1 -1
  218. package/dist/keypairs/ed25519/keypair.d.mts +8 -6
  219. package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
  220. package/dist/keypairs/ed25519/keypair.mjs +13 -9
  221. package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
  222. package/dist/keypairs/ed25519/publickey.d.mts +0 -1
  223. package/dist/keypairs/ed25519/publickey.d.mts.map +1 -1
  224. package/dist/keypairs/passkey/keypair.d.mts +12 -5
  225. package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
  226. package/dist/keypairs/passkey/keypair.mjs +20 -7
  227. package/dist/keypairs/passkey/keypair.mjs.map +1 -1
  228. package/dist/keypairs/passkey/publickey.d.mts +0 -1
  229. package/dist/keypairs/passkey/publickey.d.mts.map +1 -1
  230. package/dist/keypairs/passkey/types.d.mts.map +1 -1
  231. package/dist/keypairs/secp256k1/keypair.d.mts +3 -3
  232. package/dist/keypairs/secp256k1/keypair.d.mts.map +1 -1
  233. package/dist/keypairs/secp256k1/keypair.mjs +6 -6
  234. package/dist/keypairs/secp256k1/keypair.mjs.map +1 -1
  235. package/dist/keypairs/secp256k1/publickey.d.mts +0 -1
  236. package/dist/keypairs/secp256k1/publickey.d.mts.map +1 -1
  237. package/dist/keypairs/secp256r1/keypair.d.mts +3 -3
  238. package/dist/keypairs/secp256r1/keypair.d.mts.map +1 -1
  239. package/dist/keypairs/secp256r1/keypair.mjs +6 -6
  240. package/dist/keypairs/secp256r1/keypair.mjs.map +1 -1
  241. package/dist/keypairs/secp256r1/publickey.d.mts +0 -1
  242. package/dist/keypairs/secp256r1/publickey.d.mts.map +1 -1
  243. package/dist/multisig/publickey.d.mts +1 -0
  244. package/dist/multisig/publickey.d.mts.map +1 -1
  245. package/dist/multisig/publickey.mjs +8 -8
  246. package/dist/multisig/publickey.mjs.map +1 -1
  247. package/dist/multisig/signer.d.mts.map +1 -1
  248. package/dist/transactions/Arguments.d.mts.map +1 -1
  249. package/dist/transactions/Commands.d.mts +1 -1
  250. package/dist/transactions/Commands.d.mts.map +1 -1
  251. package/dist/transactions/Commands.mjs.map +1 -1
  252. package/dist/transactions/Inputs.d.mts.map +1 -1
  253. package/dist/transactions/ObjectCache.d.mts +3 -3
  254. package/dist/transactions/ObjectCache.d.mts.map +1 -1
  255. package/dist/transactions/Transaction.d.mts +32 -6
  256. package/dist/transactions/Transaction.d.mts.map +1 -1
  257. package/dist/transactions/Transaction.mjs +23 -1
  258. package/dist/transactions/Transaction.mjs.map +1 -1
  259. package/dist/transactions/TransactionData.d.mts.map +1 -1
  260. package/dist/transactions/TransactionData.mjs +8 -8
  261. package/dist/transactions/TransactionData.mjs.map +1 -1
  262. package/dist/transactions/data/internal.d.mts +109 -109
  263. package/dist/transactions/data/internal.d.mts.map +1 -1
  264. package/dist/transactions/data/internal.mjs.map +1 -1
  265. package/dist/transactions/data/v1.d.mts +220 -221
  266. package/dist/transactions/data/v1.d.mts.map +1 -1
  267. package/dist/transactions/data/v2.d.mts +16 -16
  268. package/dist/transactions/data/v2.d.mts.map +1 -1
  269. package/dist/transactions/data/v2.mjs.map +1 -1
  270. package/dist/transactions/executor/caching.mjs +2 -2
  271. package/dist/transactions/executor/caching.mjs.map +1 -1
  272. package/dist/transactions/executor/parallel.d.mts +1 -1
  273. package/dist/transactions/executor/parallel.d.mts.map +1 -1
  274. package/dist/transactions/executor/parallel.mjs +1 -1
  275. package/dist/transactions/executor/parallel.mjs.map +1 -1
  276. package/dist/transactions/executor/serial.d.mts +3 -3
  277. package/dist/transactions/executor/serial.d.mts.map +1 -1
  278. package/dist/transactions/executor/serial.mjs.map +1 -1
  279. package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
  280. package/dist/transactions/intents/CoinWithBalance.mjs +174 -97
  281. package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
  282. package/dist/transactions/object.d.mts.map +1 -1
  283. package/dist/transactions/pure.d.mts.map +1 -1
  284. package/dist/transactions/pure.mjs +12 -12
  285. package/dist/transactions/pure.mjs.map +1 -1
  286. package/dist/transactions/resolve.d.mts.map +1 -1
  287. package/dist/transactions/resolve.mjs +3 -3
  288. package/dist/transactions/resolve.mjs.map +1 -1
  289. package/dist/transactions/serializer.d.mts.map +1 -1
  290. package/dist/transactions/serializer.mjs +15 -15
  291. package/dist/transactions/serializer.mjs.map +1 -1
  292. package/dist/transactions/utils.d.mts +0 -1
  293. package/dist/transactions/utils.d.mts.map +1 -1
  294. package/dist/utils/coin-reservation.mjs +67 -0
  295. package/dist/utils/coin-reservation.mjs.map +1 -0
  296. package/dist/utils/constants.d.mts +2 -1
  297. package/dist/utils/constants.d.mts.map +1 -1
  298. package/dist/utils/constants.mjs +2 -1
  299. package/dist/utils/constants.mjs.map +1 -1
  300. package/dist/utils/derived-objects.d.mts +0 -1
  301. package/dist/utils/derived-objects.d.mts.map +1 -1
  302. package/dist/utils/dynamic-fields.d.mts.map +1 -1
  303. package/dist/utils/dynamic-fields.mjs +4 -4
  304. package/dist/utils/dynamic-fields.mjs.map +1 -1
  305. package/dist/utils/format.d.mts.map +1 -1
  306. package/dist/utils/haneul-types.d.mts.map +1 -1
  307. package/dist/utils/haneul-types.mjs +8 -0
  308. package/dist/utils/haneul-types.mjs.map +1 -1
  309. package/dist/utils/haneulns.d.mts.map +1 -1
  310. package/dist/utils/index.d.mts +2 -2
  311. package/dist/utils/index.mjs +2 -2
  312. package/dist/utils/move-registry.d.mts.map +1 -1
  313. package/dist/verify/index.d.mts +2 -2
  314. package/dist/verify/index.mjs +2 -2
  315. package/dist/verify/verify.d.mts +2 -2
  316. package/dist/verify/verify.d.mts.map +1 -1
  317. package/dist/verify/verify.mjs +2 -2
  318. package/dist/verify/verify.mjs.map +1 -1
  319. package/dist/version.mjs +1 -1
  320. package/dist/version.mjs.map +1 -1
  321. package/dist/zklogin/address.d.mts.map +1 -1
  322. package/dist/zklogin/bcs.d.mts +14 -14
  323. package/dist/zklogin/bcs.d.mts.map +1 -1
  324. package/dist/zklogin/jwt-decode.d.mts +0 -1
  325. package/dist/zklogin/jwt-decode.d.mts.map +1 -1
  326. package/dist/zklogin/jwt-utils.d.mts +0 -1
  327. package/dist/zklogin/jwt-utils.d.mts.map +1 -1
  328. package/dist/zklogin/nonce.d.mts.map +1 -1
  329. package/dist/zklogin/nonce.mjs +1 -1
  330. package/dist/zklogin/nonce.mjs.map +1 -1
  331. package/dist/zklogin/poseidon.d.mts.map +1 -1
  332. package/dist/zklogin/publickey.d.mts +0 -1
  333. package/dist/zklogin/publickey.d.mts.map +1 -1
  334. package/dist/zklogin/signature.d.mts.map +1 -1
  335. package/dist/zklogin/utils.d.mts.map +1 -1
  336. package/dist/zklogin/utils.mjs +1 -1
  337. package/dist/zklogin/utils.mjs.map +1 -1
  338. package/docs/bcs.md +132 -0
  339. package/docs/clients/core.md +616 -0
  340. package/docs/clients/graphql.md +99 -0
  341. package/docs/clients/grpc.md +152 -0
  342. package/docs/clients/index.md +93 -0
  343. package/docs/clients/json-rpc.md +235 -0
  344. package/docs/cryptography/keypairs.md +259 -0
  345. package/docs/cryptography/multisig.md +192 -0
  346. package/docs/cryptography/passkey.md +111 -0
  347. package/docs/cryptography/webcrypto-signer.md +81 -0
  348. package/docs/executors.md +148 -0
  349. package/docs/faucet.md +26 -0
  350. package/docs/hello-haneul.md +115 -0
  351. package/docs/index.md +56 -0
  352. package/docs/install.md +61 -0
  353. package/docs/llm-docs.md +32 -0
  354. package/docs/llms-index.md +66 -0
  355. package/docs/migrations/0.38.md +57 -0
  356. package/docs/migrations/haneul-1.0.md +454 -0
  357. package/docs/migrations/haneul-2.0/agent-prompt.md +42 -0
  358. package/docs/migrations/haneul-2.0/dapp-kit.md +350 -0
  359. package/docs/migrations/haneul-2.0/deepbook-v3.md +33 -0
  360. package/docs/migrations/haneul-2.0/haneul.md +341 -0
  361. package/docs/migrations/haneul-2.0/haneulns.md +42 -0
  362. package/docs/migrations/haneul-2.0/index.md +161 -0
  363. package/docs/migrations/haneul-2.0/json-rpc-migration.md +399 -0
  364. package/docs/migrations/haneul-2.0/kiosk.md +120 -0
  365. package/docs/migrations/haneul-2.0/sdk-maintainers.md +91 -0
  366. package/docs/migrations/haneul-2.0/seal.md +14 -0
  367. package/docs/migrations/haneul-2.0/wallet-builders.md +66 -0
  368. package/docs/migrations/haneul-2.0/walrus.md +41 -0
  369. package/docs/migrations/haneul-2.0/zksend.md +94 -0
  370. package/docs/plugins.md +255 -0
  371. package/docs/sdk-building.md +341 -0
  372. package/docs/transaction-building/basics.md +297 -0
  373. package/docs/transaction-building/gas.md +62 -0
  374. package/docs/transaction-building/intents.md +61 -0
  375. package/docs/transaction-building/offline.md +71 -0
  376. package/docs/transaction-building/sponsored-transactions.md +22 -0
  377. package/docs/utils/derived_objects.md +80 -0
  378. package/docs/utils/index.md +53 -0
  379. package/docs/zklogin.md +78 -0
  380. package/package.json +199 -199
  381. package/src/bcs/bcs.ts +13 -13
  382. package/src/bcs/effects.ts +20 -20
  383. package/src/bcs/index.ts +2 -2
  384. package/src/client/core-resolver.ts +150 -100
  385. package/src/client/core.ts +62 -22
  386. package/src/client/types.ts +109 -24
  387. package/src/cryptography/index.ts +2 -2
  388. package/src/cryptography/keypair.ts +2 -2
  389. package/src/cryptography/mnemonics.ts +7 -7
  390. package/src/cryptography/publickey.ts +8 -8
  391. package/src/faucet/faucet.ts +1 -1
  392. package/src/faucet/index.ts +1 -1
  393. package/src/graphql/client.ts +100 -8
  394. package/src/graphql/core.ts +73 -80
  395. package/src/graphql/generated/queries.ts +301 -51
  396. package/src/graphql/generated/schema.graphql +407 -104
  397. package/src/graphql/generated/tada-env.ts +779 -58
  398. package/src/graphql/index.ts +1 -1
  399. package/src/graphql/queries/getAllBalances.graphql +1 -1
  400. package/src/graphql/queries/getBalance.graphql +1 -1
  401. package/src/graphql/queries/getCoins.graphql +2 -2
  402. package/src/graphql/queries/getDynamicFields.graphql +9 -1
  403. package/src/graphql/queries/getMoveFunction.graphql +1 -1
  404. package/src/graphql/queries/getProtocolConfig.graphql +18 -0
  405. package/src/graphql/queries/nameService.graphql +1 -1
  406. package/src/graphql/queries/objects.graphql +11 -1
  407. package/src/graphql/queries/transactions.graphql +1 -3
  408. package/src/graphql/queries/verifyZkLoginSignature.graphql +1 -2
  409. package/src/grpc/client.ts +66 -8
  410. package/src/grpc/core.ts +74 -35
  411. package/src/grpc/index.ts +1 -1
  412. package/src/grpc/proto/haneul/rpc/v2/bcs.ts +1 -1
  413. package/src/grpc/proto/haneul/rpc/v2/execution_status.ts +4 -4
  414. package/src/grpc/proto/haneul/rpc/v2/object.ts +44 -0
  415. package/src/grpc/proto/haneul/rpc/v2/signature.ts +1 -1
  416. package/src/grpc/proto/haneul/rpc/v2/signature_scheme.ts +1 -1
  417. package/src/grpc/proto/haneul/rpc/v2/system_state.ts +4 -4
  418. package/src/grpc/proto/haneul/rpc/v2/transaction_execution_service.ts +16 -0
  419. package/src/jsonRpc/client.ts +5 -23
  420. package/src/jsonRpc/core.ts +114 -41
  421. package/src/jsonRpc/http-transport.ts +0 -52
  422. package/src/jsonRpc/index.ts +0 -1
  423. package/src/jsonRpc/types/common.ts +0 -1
  424. package/src/jsonRpc/types/generated.ts +2 -2
  425. package/src/jsonRpc/types/params.ts +6 -6
  426. package/src/keypairs/ed25519/keypair.ts +14 -10
  427. package/src/keypairs/passkey/keypair.ts +22 -8
  428. package/src/keypairs/secp256k1/keypair.ts +6 -6
  429. package/src/keypairs/secp256r1/keypair.ts +6 -6
  430. package/src/multisig/publickey.ts +1 -1
  431. package/src/transactions/Commands.ts +1 -1
  432. package/src/transactions/Transaction.ts +38 -1
  433. package/src/transactions/TransactionData.ts +3 -3
  434. package/src/transactions/__tests__/bcs.test.ts +3 -3
  435. package/src/transactions/data/internal.ts +12 -12
  436. package/src/transactions/data/v2.ts +6 -6
  437. package/src/transactions/executor/caching.ts +2 -2
  438. package/src/transactions/executor/parallel.ts +1 -2
  439. package/src/transactions/executor/serial.ts +1 -1
  440. package/src/transactions/intents/CoinWithBalance.ts +247 -121
  441. package/src/utils/coin-reservation.ts +84 -0
  442. package/src/utils/constants.ts +2 -0
  443. package/src/utils/haneul-types.ts +16 -1
  444. package/src/utils/index.ts +1 -0
  445. package/src/verify/index.ts +1 -1
  446. package/src/verify/verify.ts +1 -1
  447. package/src/version.ts +1 -1
  448. package/src/zklogin/nonce.ts +1 -1
  449. package/src/zklogin/utils.ts +1 -1
  450. package/dist/jsonRpc/rpc-websocket-client.d.mts +0 -26
  451. package/dist/jsonRpc/rpc-websocket-client.d.mts.map +0 -1
  452. package/dist/jsonRpc/rpc-websocket-client.mjs +0 -135
  453. package/dist/jsonRpc/rpc-websocket-client.mjs.map +0 -1
  454. package/src/jsonRpc/rpc-websocket-client.ts +0 -241
@@ -1,13 +1,13 @@
1
1
  import { normalizeStructTag } from "../../utils/haneul-types.mjs";
2
- import { bcs as suiBcs } from "../../bcs/index.mjs";
2
+ import { bcs as haneulBcs } from "../../bcs/index.mjs";
3
3
  import { TransactionCommands } from "../Commands.mjs";
4
4
  import { Inputs } from "../Inputs.mjs";
5
- import { bigint, object, parse, string } from "valibot";
5
+ import { bigint, object, optional, parse, picklist, string } from "valibot";
6
6
 
7
7
  //#region src/transactions/intents/CoinWithBalance.ts
8
8
  const COIN_WITH_BALANCE = "CoinWithBalance";
9
- const SUI_TYPE = normalizeStructTag("0x2::haneul::HANEUL");
10
- function coinWithBalance({ type = SUI_TYPE, balance, useGasCoin = true }) {
9
+ const HANEUL_TYPE = normalizeStructTag("0x2::haneul::HANEUL");
10
+ function coinWithBalance({ type = HANEUL_TYPE, balance, useGasCoin = true }) {
11
11
  let coinResult = null;
12
12
  return (tx) => {
13
13
  if (coinResult) return coinResult;
@@ -17,25 +17,60 @@ function coinWithBalance({ type = SUI_TYPE, balance, useGasCoin = true }) {
17
17
  name: COIN_WITH_BALANCE,
18
18
  inputs: {},
19
19
  data: {
20
- type: coinType === SUI_TYPE && useGasCoin ? "gas" : coinType,
21
- balance: BigInt(balance)
20
+ type: coinType === HANEUL_TYPE && useGasCoin ? "gas" : coinType,
21
+ balance: BigInt(balance),
22
+ outputKind: "coin"
22
23
  }
23
24
  }));
24
25
  return coinResult;
25
26
  };
26
27
  }
28
+ function createBalance({ type = HANEUL_TYPE, balance, useGasCoin = true }) {
29
+ let balanceResult = null;
30
+ return (tx) => {
31
+ if (balanceResult) return balanceResult;
32
+ tx.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);
33
+ const coinType = type === "gas" ? type : normalizeStructTag(type);
34
+ balanceResult = tx.add(TransactionCommands.Intent({
35
+ name: COIN_WITH_BALANCE,
36
+ inputs: {},
37
+ data: {
38
+ type: coinType === HANEUL_TYPE && useGasCoin ? "gas" : coinType,
39
+ balance: BigInt(balance),
40
+ outputKind: "balance"
41
+ }
42
+ }));
43
+ return balanceResult;
44
+ };
45
+ }
27
46
  const CoinWithBalanceData = object({
28
47
  type: string(),
29
- balance: bigint()
48
+ balance: bigint(),
49
+ outputKind: optional(picklist(["coin", "balance"]))
30
50
  });
31
51
  async function resolveCoinBalance(transactionData, buildOptions, next) {
32
52
  const coinTypes = /* @__PURE__ */ new Set();
33
53
  const totalByType = /* @__PURE__ */ new Map();
54
+ const intentsByType = /* @__PURE__ */ new Map();
34
55
  if (!transactionData.sender) throw new Error("Sender must be set to resolve CoinWithBalance");
35
- for (const command of transactionData.commands) if (command.$kind === "$Intent" && command.$Intent.name === COIN_WITH_BALANCE) {
36
- const { type, balance } = parse(CoinWithBalanceData, command.$Intent.data);
37
- if (type !== "gas" && balance > 0n) coinTypes.add(type);
56
+ for (const [i, command] of transactionData.commands.entries()) {
57
+ if (command.$kind !== "$Intent" || command.$Intent.name !== COIN_WITH_BALANCE) continue;
58
+ const { type, balance, outputKind } = parse(CoinWithBalanceData, command.$Intent.data);
59
+ if (balance === 0n) {
60
+ const coinType = type === "gas" ? HANEUL_TYPE : type;
61
+ transactionData.replaceCommand(i, TransactionCommands.MoveCall({
62
+ target: (outputKind ?? "coin") === "balance" ? "0x2::balance::zero" : "0x2::coin::zero",
63
+ typeArguments: [coinType]
64
+ }));
65
+ continue;
66
+ }
67
+ if (type !== "gas") coinTypes.add(type);
38
68
  totalByType.set(type, (totalByType.get(type) ?? 0n) + balance);
69
+ if (!intentsByType.has(type)) intentsByType.set(type, []);
70
+ intentsByType.get(type).push({
71
+ balance,
72
+ outputKind: outputKind ?? "coin"
73
+ });
39
74
  }
40
75
  const usedIds = /* @__PURE__ */ new Set();
41
76
  for (const input of transactionData.inputs) {
@@ -58,94 +93,140 @@ async function resolveCoinBalance(transactionData, buildOptions, next) {
58
93
  addressBalanceByType.set(coinType, addressBalance);
59
94
  }), totalByType.has("gas") ? await client.core.getBalance({
60
95
  owner: transactionData.sender,
61
- coinType: SUI_TYPE
96
+ coinType: HANEUL_TYPE
62
97
  }).then(({ balance }) => {
63
98
  addressBalanceByType.set("gas", BigInt(balance.addressBalance));
64
99
  }) : null]);
65
100
  const mergedCoins = /* @__PURE__ */ new Map();
66
- for (const [index, transaction] of transactionData.commands.entries()) {
67
- if (transaction.$kind !== "$Intent" || transaction.$Intent.name !== COIN_WITH_BALANCE) continue;
68
- const { type, balance } = transaction.$Intent.data;
69
- if (balance === 0n) {
70
- transactionData.replaceCommand(index, TransactionCommands.MoveCall({
71
- target: "0x2::coin::zero",
72
- typeArguments: [type === "gas" ? SUI_TYPE : type]
73
- }));
101
+ const exactBalanceByType = /* @__PURE__ */ new Map();
102
+ const typeState = /* @__PURE__ */ new Map();
103
+ let index = 0;
104
+ while (index < transactionData.commands.length) {
105
+ const transaction = transactionData.commands[index];
106
+ if (transaction.$kind !== "$Intent" || transaction.$Intent.name !== COIN_WITH_BALANCE) {
107
+ index++;
74
108
  continue;
75
109
  }
110
+ const { type, balance } = transaction.$Intent.data;
111
+ const coinType = type === "gas" ? HANEUL_TYPE : type;
112
+ const totalRequired = totalByType.get(type);
113
+ const addressBalance = addressBalanceByType.get(type) ?? 0n;
76
114
  const commands = [];
77
- if (addressBalanceByType.get(type) >= totalByType.get(type)) commands.push(TransactionCommands.MoveCall({
78
- target: "0x2::coin::redeem_funds",
79
- typeArguments: [type === "gas" ? SUI_TYPE : type],
80
- arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
81
- reservation: {
82
- $kind: "MaxAmountU64",
83
- MaxAmountU64: String(balance)
84
- },
85
- typeArg: {
86
- $kind: "Balance",
87
- Balance: type === "gas" ? SUI_TYPE : type
88
- },
89
- withdrawFrom: {
90
- $kind: "Sender",
91
- Sender: true
115
+ let intentResult;
116
+ const intentsForType = intentsByType.get(type) ?? [];
117
+ if (intentsForType.every((i) => i.outputKind === "balance") && addressBalance >= totalRequired) {
118
+ commands.push(TransactionCommands.MoveCall({
119
+ target: "0x2::balance::redeem_funds",
120
+ typeArguments: [coinType],
121
+ arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
122
+ reservation: {
123
+ $kind: "MaxAmountU64",
124
+ MaxAmountU64: String(balance)
125
+ },
126
+ typeArg: {
127
+ $kind: "Balance",
128
+ Balance: coinType
129
+ },
130
+ withdrawFrom: {
131
+ $kind: "Sender",
132
+ Sender: true
133
+ }
134
+ }))]
135
+ }));
136
+ intentResult = {
137
+ $kind: "NestedResult",
138
+ NestedResult: [index + commands.length - 1, 0]
139
+ };
140
+ } else {
141
+ if (!typeState.has(type)) {
142
+ const intents = intentsForType;
143
+ const sources = [];
144
+ if (type === "gas") sources.push({
145
+ $kind: "GasCoin",
146
+ GasCoin: true
147
+ });
148
+ else {
149
+ const coins = coinsByType.get(type);
150
+ const loadedCoinBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), 0n);
151
+ const abNeeded = totalRequired > loadedCoinBalance ? totalRequired - loadedCoinBalance : 0n;
152
+ exactBalanceByType.set(type, loadedCoinBalance + abNeeded === totalRequired);
153
+ for (const coin of coins) sources.push(transactionData.addInput("object", Inputs.ObjectRef({
154
+ objectId: coin.objectId,
155
+ digest: coin.digest,
156
+ version: coin.version
157
+ })));
158
+ if (abNeeded > 0n) {
159
+ commands.push(TransactionCommands.MoveCall({
160
+ target: "0x2::coin::redeem_funds",
161
+ typeArguments: [coinType],
162
+ arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
163
+ reservation: {
164
+ $kind: "MaxAmountU64",
165
+ MaxAmountU64: String(abNeeded)
166
+ },
167
+ typeArg: {
168
+ $kind: "Balance",
169
+ Balance: coinType
170
+ },
171
+ withdrawFrom: {
172
+ $kind: "Sender",
173
+ Sender: true
174
+ }
175
+ }))]
176
+ }));
177
+ sources.push({
178
+ $kind: "Result",
179
+ Result: index + commands.length - 1
180
+ });
181
+ }
92
182
  }
93
- }))]
94
- }));
95
- else {
96
- if (!mergedCoins.has(type)) {
97
- const addressBalance = addressBalanceByType.get(type) ?? 0n;
98
- const coinType = type === "gas" ? SUI_TYPE : type;
99
- let baseCoin;
100
- let restCoins;
101
- if (type === "gas") {
102
- baseCoin = {
103
- $kind: "GasCoin",
104
- GasCoin: true
105
- };
106
- restCoins = [];
107
- } else [baseCoin, ...restCoins] = coinsByType.get(type).map((coin) => transactionData.addInput("object", Inputs.ObjectRef({
108
- objectId: coin.objectId,
109
- digest: coin.digest,
110
- version: coin.version
111
- })));
112
- if (addressBalance > 0n) {
113
- commands.push(TransactionCommands.MoveCall({
114
- target: "0x2::coin::redeem_funds",
115
- typeArguments: [coinType],
116
- arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
117
- reservation: {
118
- $kind: "MaxAmountU64",
119
- MaxAmountU64: String(addressBalance)
120
- },
121
- typeArg: {
122
- $kind: "Balance",
123
- Balance: coinType
124
- },
125
- withdrawFrom: {
126
- $kind: "Sender",
127
- Sender: true
128
- }
129
- }))]
130
- }));
131
- commands.push(TransactionCommands.MergeCoins(baseCoin, [{
132
- $kind: "Result",
133
- Result: index + commands.length - 1
134
- }, ...restCoins]));
135
- } else if (restCoins.length > 0) commands.push(TransactionCommands.MergeCoins(baseCoin, restCoins));
183
+ const baseCoin = sources[0];
184
+ const rest = sources.slice(1);
185
+ for (let i = 0; i < rest.length; i += 500) commands.push(TransactionCommands.MergeCoins(baseCoin, rest.slice(i, i + 500)));
136
186
  mergedCoins.set(type, baseCoin);
187
+ const splitCmdIndex = index + commands.length;
188
+ commands.push(TransactionCommands.SplitCoins(baseCoin, intents.map((i) => transactionData.addInput("pure", Inputs.Pure(haneulBcs.u64().serialize(i.balance))))));
189
+ const results = [];
190
+ for (let i = 0; i < intents.length; i++) {
191
+ const splitResult = {
192
+ $kind: "NestedResult",
193
+ NestedResult: [splitCmdIndex, i]
194
+ };
195
+ if (intents[i].outputKind === "balance") {
196
+ commands.push(TransactionCommands.MoveCall({
197
+ target: "0x2::coin::into_balance",
198
+ typeArguments: [coinType],
199
+ arguments: [splitResult]
200
+ }));
201
+ results.push({
202
+ $kind: "NestedResult",
203
+ NestedResult: [index + commands.length - 1, 0]
204
+ });
205
+ } else results.push(splitResult);
206
+ }
207
+ typeState.set(type, {
208
+ results,
209
+ nextIntent: 0
210
+ });
137
211
  }
138
- commands.push(TransactionCommands.SplitCoins(mergedCoins.get(type), [transactionData.addInput("pure", Inputs.Pure(suiBcs.u64().serialize(balance)))]));
212
+ const state = typeState.get(type);
213
+ intentResult = state.results[state.nextIntent++];
139
214
  }
140
- transactionData.replaceCommand(index, commands);
141
- transactionData.mapArguments((arg, _command, commandIndex) => {
142
- if (commandIndex >= index && commandIndex < index + commands.length) return arg;
143
- if (arg.$kind === "Result" && arg.Result === index) return {
144
- $kind: "NestedResult",
145
- NestedResult: [index + commands.length - 1, 0]
146
- };
147
- return arg;
148
- });
215
+ transactionData.replaceCommand(index, commands, intentResult);
216
+ index += commands.length;
217
+ }
218
+ for (const [type, mergedCoin] of mergedCoins) {
219
+ if (type === "gas") continue;
220
+ if (intentsByType.get(type)?.some((i) => i.outputKind === "balance")) transactionData.commands.push(TransactionCommands.MoveCall({
221
+ target: "0x2::coin::send_funds",
222
+ typeArguments: [type],
223
+ arguments: [mergedCoin, transactionData.addInput("pure", Inputs.Pure(haneulBcs.Address.serialize(transactionData.sender)))]
224
+ }));
225
+ else if (exactBalanceByType.get(type)) transactionData.commands.push(TransactionCommands.MoveCall({
226
+ target: "0x2::coin::destroy_zero",
227
+ typeArguments: [type],
228
+ arguments: [mergedCoin]
229
+ }));
149
230
  }
150
231
  return next();
151
232
  }
@@ -174,20 +255,16 @@ async function getCoinsAndBalanceOfType({ coinType, balance, client, owner, used
174
255
  cursor
175
256
  });
176
257
  await balanceRequest;
177
- if (remainingBalance > 0n) {
178
- for (const coin of objects) {
179
- if (usedIds.has(coin.objectId)) continue;
180
- const coinBalance = BigInt(coin.balance);
181
- coins.push(coin);
182
- remainingBalance -= coinBalance;
183
- if (remainingBalance <= 0) break;
184
- }
185
- if (hasNextPage) return loadMoreCoins(nextCursor);
258
+ for (const coin of objects) {
259
+ if (usedIds.has(coin.objectId)) continue;
260
+ coins.push(coin);
261
+ remainingBalance -= BigInt(coin.balance);
186
262
  }
263
+ if (remainingBalance > 0n && hasNextPage) return loadMoreCoins(nextCursor);
187
264
  return coins;
188
265
  }
189
266
  }
190
267
 
191
268
  //#endregion
192
- export { COIN_WITH_BALANCE, coinWithBalance, resolveCoinBalance };
269
+ export { COIN_WITH_BALANCE, coinWithBalance, createBalance, resolveCoinBalance };
193
270
  //# sourceMappingURL=CoinWithBalance.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CoinWithBalance.mjs","names":["bcs","balance"],"sources":["../../../src/transactions/intents/CoinWithBalance.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferInput } from 'valibot';\nimport { bigint, object, parse, string } from 'valibot';\n\nimport { bcs } from '../../bcs/index.js';\nimport { normalizeStructTag } from '../../utils/haneul-types.js';\nimport { TransactionCommands } from '../Commands.js';\nimport type { Argument } from '../data/internal.js';\nimport { Inputs } from '../Inputs.js';\nimport type { BuildTransactionOptions } from '../resolve.js';\nimport type { Transaction, TransactionResult } from '../Transaction.js';\nimport type { TransactionDataBuilder } from '../TransactionData.js';\nimport type { ClientWithCoreApi, HaneulClientTypes } from '../../client/index.js';\n\nexport const COIN_WITH_BALANCE = 'CoinWithBalance';\nconst SUI_TYPE = normalizeStructTag('0x2::haneul::HANEUL');\n\nexport function coinWithBalance({\n\ttype = SUI_TYPE,\n\tbalance,\n\tuseGasCoin = true,\n}: {\n\tbalance: bigint | number;\n\ttype?: string;\n\tuseGasCoin?: boolean;\n}): (tx: Transaction) => TransactionResult {\n\tlet coinResult: TransactionResult | null = null;\n\n\treturn (tx: Transaction) => {\n\t\tif (coinResult) {\n\t\t\treturn coinResult;\n\t\t}\n\n\t\ttx.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);\n\t\tconst coinType = type === 'gas' ? type : normalizeStructTag(type);\n\n\t\tcoinResult = tx.add(\n\t\t\tTransactionCommands.Intent({\n\t\t\t\tname: COIN_WITH_BALANCE,\n\t\t\t\tinputs: {},\n\t\t\t\tdata: {\n\t\t\t\t\ttype: coinType === SUI_TYPE && useGasCoin ? 'gas' : coinType,\n\t\t\t\t\tbalance: BigInt(balance),\n\t\t\t\t} satisfies InferInput<typeof CoinWithBalanceData>,\n\t\t\t}),\n\t\t);\n\n\t\treturn coinResult;\n\t};\n}\n\nconst CoinWithBalanceData = object({\n\ttype: string(),\n\tbalance: bigint(),\n});\n\nexport async function resolveCoinBalance(\n\ttransactionData: TransactionDataBuilder,\n\tbuildOptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tconst coinTypes = new Set<string>();\n\tconst totalByType = new Map<string, bigint>();\n\n\tif (!transactionData.sender) {\n\t\tthrow new Error('Sender must be set to resolve CoinWithBalance');\n\t}\n\n\tfor (const command of transactionData.commands) {\n\t\tif (command.$kind === '$Intent' && command.$Intent.name === COIN_WITH_BALANCE) {\n\t\t\tconst { type, balance } = parse(CoinWithBalanceData, command.$Intent.data);\n\n\t\t\tif (type !== 'gas' && balance > 0n) {\n\t\t\t\tcoinTypes.add(type);\n\t\t\t}\n\n\t\t\ttotalByType.set(type, (totalByType.get(type) ?? 0n) + balance);\n\t\t}\n\t}\n\tconst usedIds = new Set<string>();\n\n\tfor (const input of transactionData.inputs) {\n\t\tif (input.Object?.ImmOrOwnedObject) {\n\t\t\tusedIds.add(input.Object.ImmOrOwnedObject.objectId);\n\t\t}\n\t\tif (input.UnresolvedObject?.objectId) {\n\t\t\tusedIds.add(input.UnresolvedObject.objectId);\n\t\t}\n\t}\n\n\tconst coinsByType = new Map<string, HaneulClientTypes.Coin[]>();\n\tconst addressBalanceByType = new Map<string, bigint>();\n\tconst client = buildOptions.client;\n\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t'Client must be provided to build or serialize transactions with CoinWithBalance intents',\n\t\t);\n\t}\n\n\tawait Promise.all([\n\t\t...[...coinTypes].map(async (coinType) => {\n\t\t\tconst { coins, addressBalance } = await getCoinsAndBalanceOfType({\n\t\t\t\tcoinType,\n\t\t\t\tbalance: totalByType.get(coinType)!,\n\t\t\t\tclient,\n\t\t\t\towner: transactionData.sender!,\n\t\t\t\tusedIds,\n\t\t\t});\n\n\t\t\tcoinsByType.set(coinType, coins);\n\t\t\taddressBalanceByType.set(coinType, addressBalance);\n\t\t}),\n\t\ttotalByType.has('gas')\n\t\t\t? await client.core\n\t\t\t\t\t.getBalance({\n\t\t\t\t\t\towner: transactionData.sender!,\n\t\t\t\t\t\tcoinType: SUI_TYPE,\n\t\t\t\t\t})\n\t\t\t\t\t.then(({ balance }) => {\n\t\t\t\t\t\taddressBalanceByType.set('gas', BigInt(balance.addressBalance));\n\t\t\t\t\t})\n\t\t\t: null,\n\t]);\n\n\tconst mergedCoins = new Map<string, Argument>();\n\n\tfor (const [index, transaction] of transactionData.commands.entries()) {\n\t\tif (transaction.$kind !== '$Intent' || transaction.$Intent.name !== COIN_WITH_BALANCE) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { type, balance } = transaction.$Intent.data as {\n\t\t\ttype: string;\n\t\t\tbalance: bigint;\n\t\t};\n\n\t\tif (balance === 0n) {\n\t\t\ttransactionData.replaceCommand(\n\t\t\t\tindex,\n\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\ttarget: '0x2::coin::zero',\n\t\t\t\t\ttypeArguments: [type === 'gas' ? SUI_TYPE : type],\n\t\t\t\t}),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst commands = [];\n\n\t\tif (addressBalanceByType.get(type)! >= totalByType.get(type)!) {\n\t\t\tcommands.push(\n\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\ttarget: '0x2::coin::redeem_funds',\n\t\t\t\t\ttypeArguments: [type === 'gas' ? SUI_TYPE : type],\n\t\t\t\t\targuments: [\n\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t'withdrawal',\n\t\t\t\t\t\t\tInputs.FundsWithdrawal({\n\t\t\t\t\t\t\t\treservation: {\n\t\t\t\t\t\t\t\t\t$kind: 'MaxAmountU64',\n\t\t\t\t\t\t\t\t\tMaxAmountU64: String(balance),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttypeArg: {\n\t\t\t\t\t\t\t\t\t$kind: 'Balance',\n\t\t\t\t\t\t\t\t\tBalance: type === 'gas' ? SUI_TYPE : type,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twithdrawFrom: {\n\t\t\t\t\t\t\t\t\t$kind: 'Sender',\n\t\t\t\t\t\t\t\t\tSender: true,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\tif (!mergedCoins.has(type)) {\n\t\t\t\tconst addressBalance = addressBalanceByType.get(type) ?? 0n;\n\t\t\t\tconst coinType = type === 'gas' ? SUI_TYPE : type;\n\n\t\t\t\tlet baseCoin: Argument;\n\t\t\t\tlet restCoins: Argument[];\n\n\t\t\t\tif (type === 'gas') {\n\t\t\t\t\tbaseCoin = { $kind: 'GasCoin', GasCoin: true };\n\t\t\t\t\trestCoins = [];\n\t\t\t\t} else {\n\t\t\t\t\t[baseCoin, ...restCoins] = coinsByType.get(type)!.map((coin) =>\n\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t'object',\n\t\t\t\t\t\t\tInputs.ObjectRef({\n\t\t\t\t\t\t\t\tobjectId: coin.objectId,\n\t\t\t\t\t\t\t\tdigest: coin.digest,\n\t\t\t\t\t\t\t\tversion: coin.version,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (addressBalance > 0n) {\n\t\t\t\t\tcommands.push(\n\t\t\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\t\t\ttarget: '0x2::coin::redeem_funds',\n\t\t\t\t\t\t\ttypeArguments: [coinType],\n\t\t\t\t\t\t\targuments: [\n\t\t\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t\t\t'withdrawal',\n\t\t\t\t\t\t\t\t\tInputs.FundsWithdrawal({\n\t\t\t\t\t\t\t\t\t\treservation: {\n\t\t\t\t\t\t\t\t\t\t\t$kind: 'MaxAmountU64',\n\t\t\t\t\t\t\t\t\t\t\tMaxAmountU64: String(addressBalance),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\ttypeArg: {\n\t\t\t\t\t\t\t\t\t\t\t$kind: 'Balance',\n\t\t\t\t\t\t\t\t\t\t\tBalance: coinType,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\twithdrawFrom: {\n\t\t\t\t\t\t\t\t\t\t\t$kind: 'Sender',\n\t\t\t\t\t\t\t\t\t\t\tSender: true,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tcommands.push(\n\t\t\t\t\t\tTransactionCommands.MergeCoins(baseCoin, [\n\t\t\t\t\t\t\t{ $kind: 'Result', Result: index + commands.length - 1 },\n\t\t\t\t\t\t\t...restCoins,\n\t\t\t\t\t\t]),\n\t\t\t\t\t);\n\t\t\t\t} else if (restCoins.length > 0) {\n\t\t\t\t\tcommands.push(TransactionCommands.MergeCoins(baseCoin, restCoins));\n\t\t\t\t}\n\n\t\t\t\tmergedCoins.set(type, baseCoin);\n\t\t\t}\n\n\t\t\tcommands.push(\n\t\t\t\tTransactionCommands.SplitCoins(mergedCoins.get(type)!, [\n\t\t\t\t\ttransactionData.addInput('pure', Inputs.Pure(bcs.u64().serialize(balance))),\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\n\t\ttransactionData.replaceCommand(index, commands);\n\n\t\ttransactionData.mapArguments((arg, _command, commandIndex) => {\n\t\t\tif (commandIndex >= index && commandIndex < index + commands.length) {\n\t\t\t\treturn arg;\n\t\t\t}\n\n\t\t\tif (arg.$kind === 'Result' && arg.Result === index) {\n\t\t\t\treturn {\n\t\t\t\t\t$kind: 'NestedResult',\n\t\t\t\t\tNestedResult: [index + commands.length - 1, 0],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\t}\n\n\treturn next();\n}\n\nasync function getCoinsAndBalanceOfType({\n\tcoinType,\n\tbalance,\n\tclient,\n\towner,\n\tusedIds,\n}: {\n\tcoinType: string;\n\tbalance: bigint;\n\tclient: ClientWithCoreApi;\n\towner: string;\n\tusedIds: Set<string>;\n}): Promise<{\n\tcoins: HaneulClientTypes.Coin[];\n\tbalance: bigint;\n\taddressBalance: bigint;\n\tcoinBalance: bigint;\n}> {\n\tlet remainingBalance = balance;\n\tconst coins: HaneulClientTypes.Coin[] = [];\n\tconst balanceRequest = client.core.getBalance({ owner, coinType }).then(({ balance }) => {\n\t\tremainingBalance -= BigInt(balance.addressBalance);\n\n\t\treturn balance;\n\t});\n\n\tconst [allCoins, balanceResponse] = await Promise.all([loadMoreCoins(), balanceRequest]);\n\n\tif (BigInt(balanceResponse.balance) < balance) {\n\t\tthrow new Error(\n\t\t\t`Insufficient balance of ${coinType} for owner ${owner}. Required: ${balance}, Available: ${\n\t\t\t\tbalance - remainingBalance\n\t\t\t}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tcoins: allCoins,\n\t\tbalance: BigInt(balanceResponse.coinBalance),\n\t\taddressBalance: BigInt(balanceResponse.addressBalance),\n\t\tcoinBalance: BigInt(balanceResponse.coinBalance),\n\t};\n\n\tasync function loadMoreCoins(cursor: string | null = null): Promise<HaneulClientTypes.Coin[]> {\n\t\tconst {\n\t\t\tobjects,\n\t\t\thasNextPage,\n\t\t\tcursor: nextCursor,\n\t\t} = await client.core.listCoins({\n\t\t\towner,\n\t\t\tcoinType,\n\t\t\tcursor,\n\t\t});\n\n\t\tawait balanceRequest;\n\n\t\tif (remainingBalance > 0n) {\n\t\t\tfor (const coin of objects) {\n\t\t\t\tif (usedIds.has(coin.objectId)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst coinBalance = BigInt(coin.balance);\n\n\t\t\t\tcoins.push(coin);\n\t\t\t\tremainingBalance -= coinBalance;\n\n\t\t\t\tif (remainingBalance <= 0) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasNextPage) {\n\t\t\t\treturn loadMoreCoins(nextCursor);\n\t\t\t}\n\t\t}\n\n\t\treturn coins;\n\t}\n}\n"],"mappings":";;;;;;;AAgBA,MAAa,oBAAoB;AACjC,MAAM,WAAW,mBAAmB,sBAAsB;AAE1D,SAAgB,gBA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AAGR,OAAI,IAAI,UAAU,YAAY,IAAI,WAAW,MAC5C,QAAO;IACN,OAAO;IACP,cAAc,CAAC,QAAQ,SAAS,SAAS,GAAG,EAAE;IAC9C;AAGF,UAAO;IACN;;AAGH,QAAO,MAAM;;AAGd,eAAe,yBAAyB,EACvC,UACA,SACA,QACA,OACA,WAYE;CACF,IAAI,mBAAmB;CACvB,MAAM,QAAkC,EAAE;CAC1C,MAAM,iBAAiB,OAAO,KAAK,WAAW;EAAE;EAAO;EAAU,CAAC,CAAC,MAAM,EAAE,yBAAc;AACxF,sBAAoB,OAAOC,UAAQ,eAAe;AAElD,SAAOA;GACN;CAEF,MAAM,CAAC,UAAU,mBAAmB,MAAM,QAAQ,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC;AAExF,KAAI,OAAO,gBAAgB,QAAQ,GAAG,QACrC,OAAM,IAAI,MACT,2BAA2B,SAAS,aAAa,MAAM,cAAc,QAAQ,eAC5E,UAAU,mBAEX;AAGF,QAAO;EACN,OAAO;EACP,SAAS,OAAO,gBAAgB,YAAY;EAC5C,gBAAgB,OAAO,gBAAgB,eAAe;EACtD,aAAa,OAAO,gBAAgB,YAAY;EAChD;CAED,eAAe,cAAc,SAAwB,MAAyC;EAC7F,MAAM,EACL,SACA,aACA,QAAQ,eACL,MAAM,OAAO,KAAK,UAAU;GAC/B;GACA;GACA;GACA,CAAC;AAEF,QAAM;AAEN,MAAI,mBAAmB,IAAI;AAC1B,QAAK,MAAM,QAAQ,SAAS;AAC3B,QAAI,QAAQ,IAAI,KAAK,SAAS,CAC7B;IAGD,MAAM,cAAc,OAAO,KAAK,QAAQ;AAExC,UAAM,KAAK,KAAK;AAChB,wBAAoB;AAEpB,QAAI,oBAAoB,EACvB;;AAIF,OAAI,YACH,QAAO,cAAc,WAAW;;AAIlC,SAAO"}
1
+ {"version":3,"file":"CoinWithBalance.mjs","names":["bcs","balance"],"sources":["../../../src/transactions/intents/CoinWithBalance.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferInput } from 'valibot';\nimport { bigint, object, optional, parse, picklist, string } from 'valibot';\n\nimport { bcs } from '../../bcs/index.js';\nimport { normalizeStructTag } from '../../utils/haneul-types.js';\nimport { TransactionCommands } from '../Commands.js';\nimport type { Argument } from '../data/internal.js';\nimport { Inputs } from '../Inputs.js';\nimport type { BuildTransactionOptions } from '../resolve.js';\nimport type { Transaction, TransactionResult } from '../Transaction.js';\nimport type { TransactionDataBuilder } from '../TransactionData.js';\nimport type { ClientWithCoreApi, HaneulClientTypes } from '../../client/index.js';\n\nexport const COIN_WITH_BALANCE = 'CoinWithBalance';\nconst HANEUL_TYPE = normalizeStructTag('0x2::haneul::HANEUL');\n\nexport function coinWithBalance({\n\ttype = HANEUL_TYPE,\n\tbalance,\n\tuseGasCoin = true,\n}: {\n\tbalance: bigint | number;\n\ttype?: string;\n\tuseGasCoin?: boolean;\n}): (tx: Transaction) => TransactionResult {\n\tlet coinResult: TransactionResult | null = null;\n\n\treturn (tx: Transaction) => {\n\t\tif (coinResult) {\n\t\t\treturn coinResult;\n\t\t}\n\n\t\ttx.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);\n\t\tconst coinType = type === 'gas' ? type : normalizeStructTag(type);\n\n\t\tcoinResult = tx.add(\n\t\t\tTransactionCommands.Intent({\n\t\t\t\tname: COIN_WITH_BALANCE,\n\t\t\t\tinputs: {},\n\t\t\t\tdata: {\n\t\t\t\t\ttype: coinType === HANEUL_TYPE && useGasCoin ? 'gas' : coinType,\n\t\t\t\t\tbalance: BigInt(balance),\n\t\t\t\t\toutputKind: 'coin',\n\t\t\t\t} satisfies InferInput<typeof CoinWithBalanceData>,\n\t\t\t}),\n\t\t);\n\n\t\treturn coinResult;\n\t};\n}\n\nexport function createBalance({\n\ttype = HANEUL_TYPE,\n\tbalance,\n\tuseGasCoin = true,\n}: {\n\tbalance: bigint | number;\n\ttype?: string;\n\tuseGasCoin?: boolean;\n}): (tx: Transaction) => TransactionResult {\n\tlet balanceResult: TransactionResult | null = null;\n\n\treturn (tx: Transaction) => {\n\t\tif (balanceResult) {\n\t\t\treturn balanceResult;\n\t\t}\n\n\t\ttx.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);\n\t\tconst coinType = type === 'gas' ? type : normalizeStructTag(type);\n\n\t\tbalanceResult = tx.add(\n\t\t\tTransactionCommands.Intent({\n\t\t\t\tname: COIN_WITH_BALANCE,\n\t\t\t\tinputs: {},\n\t\t\t\tdata: {\n\t\t\t\t\ttype: coinType === HANEUL_TYPE && useGasCoin ? 'gas' : coinType,\n\t\t\t\t\tbalance: BigInt(balance),\n\t\t\t\t\toutputKind: 'balance',\n\t\t\t\t} satisfies InferInput<typeof CoinWithBalanceData>,\n\t\t\t}),\n\t\t);\n\n\t\treturn balanceResult;\n\t};\n}\n\nconst CoinWithBalanceData = object({\n\ttype: string(),\n\tbalance: bigint(),\n\toutputKind: optional(picklist(['coin', 'balance'])),\n});\n\nexport async function resolveCoinBalance(\n\ttransactionData: TransactionDataBuilder,\n\tbuildOptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\ttype IntentInfo = { balance: bigint; outputKind: 'coin' | 'balance' };\n\n\tconst coinTypes = new Set<string>();\n\tconst totalByType = new Map<string, bigint>();\n\tconst intentsByType = new Map<string, IntentInfo[]>();\n\n\tif (!transactionData.sender) {\n\t\tthrow new Error('Sender must be set to resolve CoinWithBalance');\n\t}\n\n\t// First pass: scan intents, collect per-type data, and resolve zero-balance intents in place.\n\tfor (const [i, command] of transactionData.commands.entries()) {\n\t\tif (command.$kind !== '$Intent' || command.$Intent.name !== COIN_WITH_BALANCE) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { type, balance, outputKind } = parse(CoinWithBalanceData, command.$Intent.data);\n\n\t\t// Zero-balance intents are resolved immediately — no coins or AB needed.\n\t\t// This is a 1:1 replacement so indices don't shift.\n\t\tif (balance === 0n) {\n\t\t\tconst coinType = type === 'gas' ? HANEUL_TYPE : type;\n\t\t\ttransactionData.replaceCommand(\n\t\t\t\ti,\n\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\ttarget: (outputKind ?? 'coin') === 'balance' ? '0x2::balance::zero' : '0x2::coin::zero',\n\t\t\t\t\ttypeArguments: [coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (type !== 'gas') {\n\t\t\tcoinTypes.add(type);\n\t\t}\n\n\t\ttotalByType.set(type, (totalByType.get(type) ?? 0n) + balance);\n\n\t\tif (!intentsByType.has(type)) intentsByType.set(type, []);\n\t\tintentsByType.get(type)!.push({ balance, outputKind: outputKind ?? 'coin' });\n\t}\n\n\tconst usedIds = new Set<string>();\n\n\tfor (const input of transactionData.inputs) {\n\t\tif (input.Object?.ImmOrOwnedObject) {\n\t\t\tusedIds.add(input.Object.ImmOrOwnedObject.objectId);\n\t\t}\n\t\tif (input.UnresolvedObject?.objectId) {\n\t\t\tusedIds.add(input.UnresolvedObject.objectId);\n\t\t}\n\t}\n\n\tconst coinsByType = new Map<string, HaneulClientTypes.Coin[]>();\n\tconst addressBalanceByType = new Map<string, bigint>();\n\tconst client = buildOptions.client;\n\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t'Client must be provided to build or serialize transactions with CoinWithBalance intents',\n\t\t);\n\t}\n\n\tawait Promise.all([\n\t\t...[...coinTypes].map(async (coinType) => {\n\t\t\tconst { coins, addressBalance } = await getCoinsAndBalanceOfType({\n\t\t\t\tcoinType,\n\t\t\t\tbalance: totalByType.get(coinType)!,\n\t\t\t\tclient,\n\t\t\t\towner: transactionData.sender!,\n\t\t\t\tusedIds,\n\t\t\t});\n\n\t\t\tcoinsByType.set(coinType, coins);\n\t\t\taddressBalanceByType.set(coinType, addressBalance);\n\t\t}),\n\t\ttotalByType.has('gas')\n\t\t\t? await client.core\n\t\t\t\t\t.getBalance({\n\t\t\t\t\t\towner: transactionData.sender!,\n\t\t\t\t\t\tcoinType: HANEUL_TYPE,\n\t\t\t\t\t})\n\t\t\t\t\t.then(({ balance }) => {\n\t\t\t\t\t\taddressBalanceByType.set('gas', BigInt(balance.addressBalance));\n\t\t\t\t\t})\n\t\t\t: null,\n\t]);\n\n\tconst mergedCoins = new Map<string, Argument>();\n\tconst exactBalanceByType = new Map<string, boolean>();\n\n\t// Per-type state for Path 2 combined splits\n\ttype TypeState = { results: Argument[]; nextIntent: number };\n\tconst typeState = new Map<string, TypeState>();\n\n\tlet index = 0;\n\twhile (index < transactionData.commands.length) {\n\t\tconst transaction = transactionData.commands[index];\n\t\tif (transaction.$kind !== '$Intent' || transaction.$Intent.name !== COIN_WITH_BALANCE) {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { type, balance } = transaction.$Intent.data as {\n\t\t\ttype: string;\n\t\t\tbalance: bigint;\n\t\t};\n\t\tconst coinType = type === 'gas' ? HANEUL_TYPE : type;\n\t\tconst totalRequired = totalByType.get(type)!;\n\t\tconst addressBalance = addressBalanceByType.get(type) ?? 0n;\n\n\t\tconst commands = [];\n\t\tlet intentResult: Argument;\n\n\t\tconst intentsForType = intentsByType.get(type) ?? [];\n\t\tconst allBalance = intentsForType.every((i) => i.outputKind === 'balance');\n\n\t\tif (allBalance && addressBalance >= totalRequired) {\n\t\t\t// Path 1: All balance intents and AB sufficient — direct per-intent withdrawal.\n\t\t\t// No coins touched, enables parallel execution.\n\t\t\tcommands.push(\n\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\ttarget: '0x2::balance::redeem_funds',\n\t\t\t\t\ttypeArguments: [coinType],\n\t\t\t\t\targuments: [\n\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t'withdrawal',\n\t\t\t\t\t\t\tInputs.FundsWithdrawal({\n\t\t\t\t\t\t\t\treservation: {\n\t\t\t\t\t\t\t\t\t$kind: 'MaxAmountU64',\n\t\t\t\t\t\t\t\t\tMaxAmountU64: String(balance),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttypeArg: { $kind: 'Balance', Balance: coinType },\n\t\t\t\t\t\t\t\twithdrawFrom: { $kind: 'Sender', Sender: true },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tintentResult = {\n\t\t\t\t$kind: 'NestedResult',\n\t\t\t\tNestedResult: [index + commands.length - 1, 0],\n\t\t\t};\n\t\t} else {\n\t\t\t// Path 2: Merge and Split — build a merged coin, split all intents at once.\n\n\t\t\tif (!typeState.has(type)) {\n\t\t\t\tconst intents = intentsForType;\n\n\t\t\t\t// Step 1: Build sources and merge\n\t\t\t\tconst sources: Argument[] = [];\n\n\t\t\t\tif (type === 'gas') {\n\t\t\t\t\tsources.push({ $kind: 'GasCoin', GasCoin: true });\n\t\t\t\t} else {\n\t\t\t\t\tconst coins = coinsByType.get(type)!;\n\t\t\t\t\tconst loadedCoinBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), 0n);\n\t\t\t\t\tconst abNeeded =\n\t\t\t\t\t\ttotalRequired > loadedCoinBalance ? totalRequired - loadedCoinBalance : 0n;\n\n\t\t\t\t\texactBalanceByType.set(type, loadedCoinBalance + abNeeded === totalRequired);\n\n\t\t\t\t\tfor (const coin of coins) {\n\t\t\t\t\t\tsources.push(\n\t\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t\t'object',\n\t\t\t\t\t\t\t\tInputs.ObjectRef({\n\t\t\t\t\t\t\t\t\tobjectId: coin.objectId,\n\t\t\t\t\t\t\t\t\tdigest: coin.digest,\n\t\t\t\t\t\t\t\t\tversion: coin.version,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (abNeeded > 0n) {\n\t\t\t\t\t\tcommands.push(\n\t\t\t\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\t\t\t\ttarget: '0x2::coin::redeem_funds',\n\t\t\t\t\t\t\t\ttypeArguments: [coinType],\n\t\t\t\t\t\t\t\targuments: [\n\t\t\t\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t\t\t\t'withdrawal',\n\t\t\t\t\t\t\t\t\t\tInputs.FundsWithdrawal({\n\t\t\t\t\t\t\t\t\t\t\treservation: {\n\t\t\t\t\t\t\t\t\t\t\t\t$kind: 'MaxAmountU64',\n\t\t\t\t\t\t\t\t\t\t\t\tMaxAmountU64: String(abNeeded),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\ttypeArg: { $kind: 'Balance', Balance: coinType },\n\t\t\t\t\t\t\t\t\t\t\twithdrawFrom: { $kind: 'Sender', Sender: true },\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsources.push({ $kind: 'Result', Result: index + commands.length - 1 });\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst baseCoin = sources[0];\n\t\t\t\tconst rest = sources.slice(1);\n\t\t\t\tfor (let i = 0; i < rest.length; i += 500) {\n\t\t\t\t\tcommands.push(TransactionCommands.MergeCoins(baseCoin, rest.slice(i, i + 500)));\n\t\t\t\t}\n\n\t\t\t\tmergedCoins.set(type, baseCoin);\n\n\t\t\t\t// Step 2: Combined SplitCoins for all intents of this type\n\t\t\t\tconst splitCmdIndex = index + commands.length;\n\t\t\t\tcommands.push(\n\t\t\t\t\tTransactionCommands.SplitCoins(\n\t\t\t\t\t\tbaseCoin,\n\t\t\t\t\t\tintents.map((i) =>\n\t\t\t\t\t\t\ttransactionData.addInput('pure', Inputs.Pure(bcs.u64().serialize(i.balance))),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\t// Build per-intent results, adding into_balance conversions for balance intents\n\t\t\t\tconst results: Argument[] = [];\n\t\t\t\tfor (let i = 0; i < intents.length; i++) {\n\t\t\t\t\tconst splitResult: Argument = {\n\t\t\t\t\t\t$kind: 'NestedResult',\n\t\t\t\t\t\tNestedResult: [splitCmdIndex, i],\n\t\t\t\t\t};\n\n\t\t\t\t\tif (intents[i].outputKind === 'balance') {\n\t\t\t\t\t\tcommands.push(\n\t\t\t\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\t\t\t\ttarget: '0x2::coin::into_balance',\n\t\t\t\t\t\t\t\ttypeArguments: [coinType],\n\t\t\t\t\t\t\t\targuments: [splitResult],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresults.push({\n\t\t\t\t\t\t\t$kind: 'NestedResult',\n\t\t\t\t\t\t\tNestedResult: [index + commands.length - 1, 0],\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresults.push(splitResult);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttypeState.set(type, { results, nextIntent: 0 });\n\t\t\t}\n\n\t\t\tconst state = typeState.get(type)!;\n\t\t\tintentResult = state.results[state.nextIntent++];\n\t\t}\n\n\t\ttransactionData.replaceCommand(\n\t\t\tindex,\n\t\t\tcommands,\n\t\t\tintentResult as { NestedResult: [number, number] },\n\t\t);\n\n\t\t// Advance past the replacement. When commands is empty (subsequent intents\n\t\t// of a combined split), the command was removed and the next command shifted\n\t\t// into this position — so we stay at the same index.\n\t\tindex += commands.length;\n\t}\n\n\t// Step 3: Remainder handling\n\tfor (const [type, mergedCoin] of mergedCoins) {\n\t\tif (type === 'gas') continue;\n\n\t\tconst hasBalanceIntent = intentsByType.get(type)?.some((i) => i.outputKind === 'balance');\n\n\t\tif (hasBalanceIntent) {\n\t\t\t// Balance intents exist: send remainder coin back to sender's address balance.\n\t\t\t// coin::send_funds is gasless-eligible and handles zero amounts.\n\t\t\ttransactionData.commands.push(\n\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\ttarget: '0x2::coin::send_funds',\n\t\t\t\t\ttypeArguments: [type],\n\t\t\t\t\targuments: [\n\t\t\t\t\t\tmergedCoin,\n\t\t\t\t\t\ttransactionData.addInput(\n\t\t\t\t\t\t\t'pure',\n\t\t\t\t\t\t\tInputs.Pure(bcs.Address.serialize(transactionData.sender!)),\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (exactBalanceByType.get(type)) {\n\t\t\t// Coin-only with exact match: destroy the zero-value dust coin.\n\t\t\ttransactionData.commands.push(\n\t\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t\ttarget: '0x2::coin::destroy_zero',\n\t\t\t\t\ttypeArguments: [type],\n\t\t\t\t\targuments: [mergedCoin],\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\t// Coin-only with surplus: merged coin stays with sender as an owned object\n\t}\n\n\treturn next();\n}\n\nasync function getCoinsAndBalanceOfType({\n\tcoinType,\n\tbalance,\n\tclient,\n\towner,\n\tusedIds,\n}: {\n\tcoinType: string;\n\tbalance: bigint;\n\tclient: ClientWithCoreApi;\n\towner: string;\n\tusedIds: Set<string>;\n}): Promise<{\n\tcoins: HaneulClientTypes.Coin[];\n\tbalance: bigint;\n\taddressBalance: bigint;\n\tcoinBalance: bigint;\n}> {\n\tlet remainingBalance = balance;\n\tconst coins: HaneulClientTypes.Coin[] = [];\n\tconst balanceRequest = client.core.getBalance({ owner, coinType }).then(({ balance }) => {\n\t\tremainingBalance -= BigInt(balance.addressBalance);\n\n\t\treturn balance;\n\t});\n\n\tconst [allCoins, balanceResponse] = await Promise.all([loadMoreCoins(), balanceRequest]);\n\n\tif (BigInt(balanceResponse.balance) < balance) {\n\t\tthrow new Error(\n\t\t\t`Insufficient balance of ${coinType} for owner ${owner}. Required: ${balance}, Available: ${\n\t\t\t\tbalance - remainingBalance\n\t\t\t}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tcoins: allCoins,\n\t\tbalance: BigInt(balanceResponse.coinBalance),\n\t\taddressBalance: BigInt(balanceResponse.addressBalance),\n\t\tcoinBalance: BigInt(balanceResponse.coinBalance),\n\t};\n\n\tasync function loadMoreCoins(cursor: string | null = null): Promise<HaneulClientTypes.Coin[]> {\n\t\tconst {\n\t\t\tobjects,\n\t\t\thasNextPage,\n\t\t\tcursor: nextCursor,\n\t\t} = await client.core.listCoins({\n\t\t\towner,\n\t\t\tcoinType,\n\t\t\tcursor,\n\t\t});\n\n\t\tawait balanceRequest;\n\n\t\t// Always load all coins from the page (except already-used ones).\n\t\t// This merges all available coins rather than leaving dust.\n\t\tfor (const coin of objects) {\n\t\t\tif (usedIds.has(coin.objectId)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tcoins.push(coin);\n\t\t\tremainingBalance -= BigInt(coin.balance);\n\t\t}\n\n\t\t// Only paginate if loaded coins + AB are still insufficient\n\t\tif (remainingBalance > 0n && hasNextPage) {\n\t\t\treturn loadMoreCoins(nextCursor);\n\t\t}\n\n\t\treturn coins;\n\t}\n}\n"],"mappings":";;;;;;;AAgBA,MAAa,oBAAoB;AACjC,MAAM,cAAc,mBAAmB,sBAAsB;AAE7D,SAAgB,gBAAgB,EAC/B,OAAO,aACP,SACA,aAAa,QAK6B;CAC1C,IAAI,aAAuC;AAE3C,SAAQ,OAAoB;AAC3B,MAAI,WACH,QAAO;AAGR,KAAG,kBAAkB,mBAAmB,mBAAmB;EAC3D,MAAM,WAAW,SAAS,QAAQ,OAAO,mBAAmB,KAAK;AAEjE,eAAa,GAAG,IACf,oBAAoB,OAAO;GAC1B,MAAM;GACN,QAAQ,EAAE;GACV,MAAM;IACL,MAAM,aAAa,eAAe,aAAa,QAAQ;IACvD,SAAS,OAAO,QAAQ;IACxB,YAAY;IACZ;GACD,CAAC,CACF;AAED,SAAO;;;AAIT,SAAgB,cAAc,EAC7B,OAAO,aACP,SACA,aAAa,QAK6B;CAC1C,IAAI,gBAA0C;AAE9C,SAAQ,OAAoB;AAC3B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AM,OAAO,KAAK,UAAU;GAC/B;GACA;GACA;GACA,CAAC;AAEF,QAAM;AAIN,OAAK,MAAM,QAAQ,SAAS;AAC3B,OAAI,QAAQ,IAAI,KAAK,SAAS,CAC7B;AAGD,SAAM,KAAK,KAAK;AAChB,uBAAoB,OAAO,KAAK,QAAQ;;AAIzC,MAAI,mBAAmB,MAAM,YAC5B,QAAO,cAAc,WAAW;AAGjC,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.mts","names":[],"sources":["../../src/transactions/object.ts"],"sourcesContent":[],"mappings":";;;iBAagB,2CAA2C,2BAA2B;UAC9D,yBAAsB;EAD9B,MAAA,CAAA,OAAsE,CAAtE,EAAA;IAA2C,OAAA,CAAA,EAAA,OAAA;EAA2B,CAAA,CAAA,EAKrC,CALqC;EAC9D,KAAA,EAAA,GAAA;EAAsB,MAAA,EAAA,GAAA;EAIG,QAAA,CAAA,QAAA,EAAA;;MAqCE;EAAA,MAAA,CAAA;IAAA,IAAA;IAAA;EAUR,CAVQ,EAAA;;WAUR;EAAA,CAAA,CAAA,EAAA,CAAA,EAAA,EACpC,WADoC,EAAA,GACzB,iBADyB;CACpC"}
1
+ {"version":3,"file":"object.d.mts","names":[],"sources":["../../src/transactions/object.ts"],"mappings":";;;iBAagB,mBAAA,GAAA,CAAuB,UAAA,GAAa,KAAA,EAAO,sBAAA,KAA2B,CAAA;EAAA,QAC9D,sBAAA,GAAsB,CAAA;;IAIhB,OAAA;EAAA,IAAmB,CAAA;;;;IAqCjB,OAAA;EAAA,IAAmB,CAAA;;;;;IAU7B,IAAA;IAAc,KAAA,EAAO,sBAAA;EAAA,KACxC,EAAA,EAAI,WAAA,KAAW,iBAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"pure.d.mts","names":[],"sources":["../../src/transactions/pure.ts"],"sourcesContent":[],"mappings":";;;;iBAUgB,gCAAgC,0BAA0B,eAAe;gBAC7D,oBACpB,aAAa,eAAe,kBAAkB,QAAQ,aACrD,s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AAA,IAAA,GAAA,SAAA,CAAA,EAsCoB,CAtCpB;CAC/B"}
1
+ {"version":3,"file":"pure.d.mts","names":[],"sources":["../../src/transactions/pure.ts"],"mappings":";;;;iBAUgB,UAAA,GAAA,CAAc,QAAA,GAAW,KAAA,EAAO,aAAA,aAA0B,UAAA,KAAe,CAAA;EAAA,cAC7D,YAAA,EAAY,IAAA,EAChC,IAAA,SAAa,YAAA,GAAe,iBAAA,CAAkB,IAAA,IAAQ,IAAA,EAAI,KAAA,EACzD,qBAAA,CAAsB,IAAA,IAC3B,CAAA;EAAA,QAOK,aAAA,aAA0B,UAAA,GAC/B,CAAA;qBAiBqB,CAAA;sBACC,CAAA;sBACA,CAAA;wCACkB,CAAA;yCACC,CAAA;yCACA,CAAA;wBACjB,CAAA;yBACC,CAAA;0BACC,CAAA;yBAAA,CAAA;sBAED,YAAA,EAAY,IAAA,EACjC,IAAA,SAAa,YAAA,GAAe,iBAAA,CAAkB,IAAA,IAAQ,IAAA,EAAI,KAAA,EACzD,QAAA,CAAS,qBAAA,CAAsB,IAAA;IAAW,MAAA;EAAA,IAAgB,CAAA;sBAMtC,YAAA,EAAY,IAAA,EACjC,IAAA,SAAa,YAAA,GAAe,iBAAA,CAAkB,IAAA,IAAQ,IAAA,EAAI,KAAA,EACzD,qBAAA,CAAsB,IAAA,uBAAwB,CAAA;AAAA"}
@@ -1,5 +1,5 @@
1
1
  import { pureBcsSchemaFromTypeName } from "../bcs/pure.mjs";
2
- import { bcs as suiBcs } from "../bcs/index.mjs";
2
+ import { bcs as haneulBcs } from "../bcs/index.mjs";
3
3
  import { isSerializedBcs } from "@haneullabs/bcs";
4
4
 
5
5
  //#region src/transactions/pure.ts
@@ -9,21 +9,21 @@ function createPure(makePure) {
9
9
  if (typeOrSerializedValue instanceof Uint8Array || isSerializedBcs(typeOrSerializedValue)) return makePure(typeOrSerializedValue);
10
10
  throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value");
11
11
  }
12
- pure.u8 = (value) => makePure(suiBcs.U8.serialize(value));
13
- pure.u16 = (value) => makePure(suiBcs.U16.serialize(value));
14
- pure.u32 = (value) => makePure(suiBcs.U32.serialize(value));
15
- pure.u64 = (value) => makePure(suiBcs.U64.serialize(value));
16
- pure.u128 = (value) => makePure(suiBcs.U128.serialize(value));
17
- pure.u256 = (value) => makePure(suiBcs.U256.serialize(value));
18
- pure.bool = (value) => makePure(suiBcs.Bool.serialize(value));
19
- pure.string = (value) => makePure(suiBcs.String.serialize(value));
20
- pure.address = (value) => makePure(suiBcs.Address.serialize(value));
12
+ pure.u8 = (value) => makePure(haneulBcs.U8.serialize(value));
13
+ pure.u16 = (value) => makePure(haneulBcs.U16.serialize(value));
14
+ pure.u32 = (value) => makePure(haneulBcs.U32.serialize(value));
15
+ pure.u64 = (value) => makePure(haneulBcs.U64.serialize(value));
16
+ pure.u128 = (value) => makePure(haneulBcs.U128.serialize(value));
17
+ pure.u256 = (value) => makePure(haneulBcs.U256.serialize(value));
18
+ pure.bool = (value) => makePure(haneulBcs.Bool.serialize(value));
19
+ pure.string = (value) => makePure(haneulBcs.String.serialize(value));
20
+ pure.address = (value) => makePure(haneulBcs.Address.serialize(value));
21
21
  pure.id = pure.address;
22
22
  pure.vector = (type, value) => {
23
- return makePure(suiBcs.vector(pureBcsSchemaFromTypeName(type)).serialize(value));
23
+ return makePure(haneulBcs.vector(pureBcsSchemaFromTypeName(type)).serialize(value));
24
24
  };
25
25
  pure.option = (type, value) => {
26
- return makePure(suiBcs.option(pureBcsSchemaFromTypeName(type)).serialize(value));
26
+ return makePure(haneulBcs.option(pureBcsSchemaFromTypeName(type)).serialize(value));
27
27
  };
28
28
  return pure;
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pure.mjs","names":["bcs"],"sources":["../../src/transactions/pure.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isSerializedBcs } from '@haneullabs/bcs';\nimport type { SerializedBcs } from '@haneullabs/bcs';\n\nimport { bcs } from '../bcs/index.js';\nimport { pureBcsSchemaFromTypeName } from '../bcs/pure.js';\nimport type { PureTypeName, ShapeFromPureTypeName, ValidPureTypeName } from '../bcs/pure.js';\n\nexport function createPure<T>(makePure: (value: SerializedBcs<any, any> | Uint8Array) => T) {\n\tfunction pure<Type extends PureTypeName>(\n\t\ttype: Type extends PureTypeName ? ValidPureTypeName<Type> : Type,\n\t\tvalue: ShapeFromPureTypeName<Type>,\n\t): T;\n\n\tfunction pure(\n\t\t/**\n\t\t * The pure value, serialized to BCS. If this is a Uint8Array, then the value\n\t\t * is assumed to be raw bytes, and will be used directly.\n\t\t */\n\t\tvalue: SerializedBcs<any, any> | Uint8Array,\n\t): T;\n\n\tfunction pure(\n\t\ttypeOrSerializedValue?: PureTypeName | SerializedBcs<any, any> | Uint8Array,\n\t\tvalue?: unknown,\n\t): T {\n\t\tif (typeof typeOrSerializedValue === 'string') {\n\t\t\treturn makePure(pureBcsSchemaFromTypeName(typeOrSerializedValue).serialize(value as never));\n\t\t}\n\n\t\tif (typeOrSerializedValue instanceof Uint8Array || isSerializedBcs(typeOrSerializedValue)) {\n\t\t\treturn makePure(typeOrSerializedValue);\n\t\t}\n\n\t\tthrow new Error('tx.pure must be called either a bcs type name, or a serialized bcs value');\n\t}\n\n\tpure.u8 = (value: number) => makePure(bcs.U8.serialize(value));\n\tpure.u16 = (value: number) => makePure(bcs.U16.serialize(value));\n\tpure.u32 = (value: number) => makePure(bcs.U32.serialize(value));\n\tpure.u64 = (value: bigint | number | string) => makePure(bcs.U64.serialize(value));\n\tpure.u128 = (value: bigint | number | string) => makePure(bcs.U128.serialize(value));\n\tpure.u256 = (value: bigint | number | string) => makePure(bcs.U256.serialize(value));\n\tpure.bool = (value: boolean) => makePure(bcs.Bool.serialize(value));\n\tpure.string = (value: string) => makePure(bcs.String.serialize(value));\n\tpure.address = (value: string) => makePure(bcs.Address.serialize(value));\n\tpure.id = pure.address;\n\tpure.vector = <Type extends PureTypeName>(\n\t\ttype: Type extends PureTypeName ? ValidPureTypeName<Type> : Type,\n\t\tvalue: Iterable<ShapeFromPureTypeName<Type>> & { length: number },\n\t) => {\n\t\treturn makePure(\n\t\t\tbcs.vector(pureBcsSchemaFromTypeName(type as PureTypeName)).serialize(value as never),\n\t\t);\n\t};\n\tpure.option = <Type extends PureTypeName>(\n\t\ttype: Type extends PureTypeName ? ValidPureTypeName<Type> : Type,\n\t\tvalue: ShapeFromPureTypeName<Type> | null | undefined,\n\t) => {\n\t\treturn makePure(bcs.option(pureBcsSchemaFromTypeName(type)).serialize(value as never));\n\t};\n\n\treturn pure;\n}\n"],"mappings":";;;;;AAUA,SAAgB,WAAc,UAA8D;CAc3F,SAAS,KACR,uBACA,OACI;AACJ,MAAI,OAAO,0BAA0B,SACpC,QAAO,SAAS,0BAA0B,sBAAsB,CAAC,UAAU,MAAe,CAAC;AAG5F,MAAI,iCAAiC,cAAc,gBAAgB,sBAAsB,CACxF,QAAO,SAAS,sBAAsB;AAGvC,QAAM,IAAI,MAAM,2EAA2E;;AAG5F,MAAK,MAAM,UAAkB,SAASA,OAAI,GAAG,UAAU,MAAM,CAAC;AAC9D,MAAK,OAAO,UAAkB,SAASA,OAAI,IAAI,UAAU,MAAM,CAAC;AAChE,MAAK,OAAO,UAAkB,SAASA,OAAI,IAAI,UAAU,MAAM,CAAC;AAChE,MAAK,OAAO,UAAoC,SAASA,OAAI,IAAI,UAAU,MAAM,CAAC;AAClF,MAAK,QAAQ,UAAoC,SAASA,OAAI,KAAK,UAAU,MAAM,CAAC;AACpF,MAAK,QAAQ,UAAoC,SAASA,OAAI,KAAK,UAAU,MAAM,CAAC;AACpF,MAAK,QAAQ,UAAmB,SAASA,OAAI,KAAK,UAAU,MAAM,CAAC;AACnE,MAAK,UAAU,UAAkB,SAASA,OAAI,OAAO,UAAU,MAAM,CAAC;AACtE,MAAK,WAAW,UAAkB,SAASA,OAAI,QAAQ,UAAU,MAAM,CAAC;AACxE,MAAK,KAAK,KAAK;AACf,MAAK,UACJ,MACA,UACI;AACJ,SAAO,SACNA,OAAI,OAAO,0BAA0B,KAAqB,CAAC,CAAC,UAAU,MAAe,CACrF;;AAEF,MAAK,UACJ,MACA,UACI;AACJ,SAAO,SAASA,OAAI,OAAO,0BAA0B,KAAK,CAAC,CAAC,UAAU,MAAe,CAAC;;AAGvF,QAAO"}
1
+ {"version":3,"file":"pure.mjs","names":["bcs"],"sources":["../../src/transactions/pure.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isSerializedBcs } from '@haneullabs/bcs';\nimport type { SerializedBcs } from '@haneullabs/bcs';\n\nimport { bcs } from '../bcs/index.js';\nimport { pureBcsSchemaFromTypeName } from '../bcs/pure.js';\nimport type { PureTypeName, ShapeFromPureTypeName, ValidPureTypeName } from '../bcs/pure.js';\n\nexport function createPure<T>(makePure: (value: SerializedBcs<any, any> | Uint8Array) => T) {\n\tfunction pure<Type extends PureTypeName>(\n\t\ttype: Type extends PureTypeName ? ValidPureTypeName<Type> : Type,\n\t\tvalue: ShapeFromPureTypeName<Type>,\n\t): T;\n\n\tfunction pure(\n\t\t/**\n\t\t * The pure value, serialized to BCS. If this is a Uint8Array, then the value\n\t\t * is assumed to be raw bytes, and will be used directly.\n\t\t */\n\t\tvalue: SerializedBcs<any, any> | Uint8Array,\n\t): T;\n\n\tfunction pure(\n\t\ttypeOrSerializedValue?: PureTypeName | SerializedBcs<any, any> | Uint8Array,\n\t\tvalue?: unknown,\n\t): T {\n\t\tif (typeof typeOrSerializedValue === 'string') {\n\t\t\treturn makePure(pureBcsSchemaFromTypeName(typeOrSerializedValue).serialize(value as never));\n\t\t}\n\n\t\tif (typeOrSerializedValue instanceof Uint8Array || isSerializedBcs(typeOrSerializedValue)) {\n\t\t\treturn makePure(typeOrSerializedValue);\n\t\t}\n\n\t\tthrow new Error('tx.pure must be called either a bcs type name, or a serialized bcs value');\n\t}\n\n\tpure.u8 = (value: number) => makePure(bcs.U8.serialize(value));\n\tpure.u16 = (value: number) => makePure(bcs.U16.serialize(value));\n\tpure.u32 = (value: number) => makePure(bcs.U32.serialize(value));\n\tpure.u64 = (value: bigint | number | string) => makePure(bcs.U64.serialize(value));\n\tpure.u128 = (value: bigint | number | string) => makePure(bcs.U128.serialize(value));\n\tpure.u256 = (value: bigint | number | string) => makePure(bcs.U256.serialize(value));\n\tpure.bool = (value: boolean) => makePure(bcs.Bool.serialize(value));\n\tpure.string = (value: string) => makePure(bcs.String.serialize(value));\n\tpure.address = (value: string) => makePure(bcs.Address.serialize(value));\n\tpure.id = pure.address;\n\tpure.vector = <Type extends PureTypeName>(\n\t\ttype: Type extends PureTypeName ? ValidPureTypeName<Type> : Type,\n\t\tvalue: Iterable<ShapeFromPureTypeName<Type>> & { length: number },\n\t) => {\n\t\treturn makePure(\n\t\t\tbcs.vector(pureBcsSchemaFromTypeName(type as PureTypeName)).serialize(value as never),\n\t\t);\n\t};\n\tpure.option = <Type extends PureTypeName>(\n\t\ttype: Type extends PureTypeName ? ValidPureTypeName<Type> : Type,\n\t\tvalue: ShapeFromPureTypeName<Type> | null | undefined,\n\t) => {\n\t\treturn makePure(bcs.option(pureBcsSchemaFromTypeName(type)).serialize(value as never));\n\t};\n\n\treturn pure;\n}\n"],"mappings":";;;;;AAUA,SAAgB,WAAc,UAA8D;CAc3F,SAAS,KACR,uBACA,OACI;AACJ,MAAI,OAAO,0BAA0B,SACpC,QAAO,SAAS,0BAA0B,sBAAsB,CAAC,UAAU,MAAe,CAAC;AAG5F,MAAI,iCAAiC,cAAc,gBAAgB,sBAAsB,CACxF,QAAO,SAAS,sBAAsB;AAGvC,QAAM,IAAI,MAAM,2EAA2E;;AAG5F,MAAK,MAAM,UAAkB,SAASA,UAAI,GAAG,UAAU,MAAM,CAAC;AAC9D,MAAK,OAAO,UAAkB,SAASA,UAAI,IAAI,UAAU,MAAM,CAAC;AAChE,MAAK,OAAO,UAAkB,SAASA,UAAI,IAAI,UAAU,MAAM,CAAC;AAChE,MAAK,OAAO,UAAoC,SAASA,UAAI,IAAI,UAAU,MAAM,CAAC;AAClF,MAAK,QAAQ,UAAoC,SAASA,UAAI,KAAK,UAAU,MAAM,CAAC;AACpF,MAAK,QAAQ,UAAoC,SAASA,UAAI,KAAK,UAAU,MAAM,CAAC;AACpF,MAAK,QAAQ,UAAmB,SAASA,UAAI,KAAK,UAAU,MAAM,CAAC;AACnE,MAAK,UAAU,UAAkB,SAASA,UAAI,OAAO,UAAU,MAAM,CAAC;AACtE,MAAK,WAAW,UAAkB,SAASA,UAAI,QAAQ,UAAU,MAAM,CAAC;AACxE,MAAK,KAAK,KAAK;AACf,MAAK,UACJ,MACA,UACI;AACJ,SAAO,SACNA,UAAI,OAAO,0BAA0B,KAAqB,CAAC,CAAC,UAAU,MAAe,CACrF;;AAEF,MAAK,UACJ,MACA,UACI;AACJ,SAAO,SAASA,UAAI,OAAO,0BAA0B,KAAK,CAAC,CAAC,UAAU,MAAe,CAAC;;AAGvF,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.mts","names":[],"sources":["../../src/transactions/resolve.ts"],"sourcesContent":[],"mappings":";;;;;UAYiB,uBAAA;WACP;;AADV;AAKiB,UAAA,2BAAA,SAAoC,uBAAuB,CAAA;EAIhE,gBAAA,CAAA,EAAA,MAAiB,EAAA;;AAEnB,KAFE,iBAAA,GAEF,CAAA,eAAA,EADQ,sBACR,EAAA,OAAA,EAAA,uBAAA,EAAA,IAAA,EAAA,GAAA,GACG,OADH,CAAA,IAAA,CAAA,EAAA,GAEL,OAFK,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"resolve.d.mts","names":[],"sources":["../../src/transactions/resolve.ts"],"mappings":";;;;;UAYiB,uBAAA;EAChB,MAAA,GAAS,iBAAA;EACT,mBAAA;AAAA;AAAA,UAGgB,2BAAA,SAAoC,uBAAA;EACpD,gBAAA;AAAA;AAAA,KAGW,iBAAA,IACX,eAAA,EAAiB,sBAAA,EACjB,OAAA,EAAS,uBAAA,EACT,IAAA,QAAY,OAAA,WACR,OAAA"}
@@ -1,4 +1,4 @@
1
- import { bcs as suiBcs } from "../bcs/index.mjs";
1
+ import { bcs as haneulBcs } from "../bcs/index.mjs";
2
2
  import { Inputs } from "./Inputs.mjs";
3
3
  import { coreClientResolveTransactionPlugin } from "../client/core-resolver.mjs";
4
4
 
@@ -37,11 +37,11 @@ function normalizeRawArguments(transactionData) {
37
37
  for (const command of transactionData.commands) switch (command.$kind) {
38
38
  case "SplitCoins":
39
39
  command.SplitCoins.amounts.forEach((amount) => {
40
- normalizeRawArgument(amount, suiBcs.U64, transactionData);
40
+ normalizeRawArgument(amount, haneulBcs.U64, transactionData);
41
41
  });
42
42
  break;
43
43
  case "TransferObjects":
44
- normalizeRawArgument(command.TransferObjects.address, suiBcs.Address, transactionData);
44
+ normalizeRawArgument(command.TransferObjects.address, haneulBcs.Address, transactionData);
45
45
  break;
46
46
  }
47
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.mjs","names":["bcs"],"sources":["../../src/transactions/resolve.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Argument } from './data/internal.js';\n\nimport type { ClientWithCoreApi } from '../client/index.js';\nimport type { TransactionDataBuilder } from './TransactionData.js';\nimport type { BcsType } from '@haneullabs/bcs';\nimport { Inputs } from './Inputs.js';\nimport { bcs } from '../bcs/index.js';\nimport { coreClientResolveTransactionPlugin } from '../client/core-resolver.js';\n\nexport interface BuildTransactionOptions {\n\tclient?: ClientWithCoreApi;\n\tonlyTransactionKind?: boolean;\n}\n\nexport interface SerializeTransactionOptions extends BuildTransactionOptions {\n\tsupportedIntents?: string[];\n}\n\nexport type TransactionPlugin = (\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) => Promise<void>;\n\nexport function needsTransactionResolution(\n\tdata: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n): boolean {\n\tif (\n\t\tdata.inputs.some((input) => {\n\t\t\treturn input.UnresolvedObject || input.UnresolvedPure;\n\t\t})\n\t) {\n\t\treturn true;\n\t}\n\n\tif (!options.onlyTransactionKind) {\n\t\tif (!data.gasData.price || !data.gasData.budget || !data.gasData.payment) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (data.gasData.payment.length === 0 && !data.expiration) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport async function resolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tnormalizeRawArguments(transactionData);\n\tif (!needsTransactionResolution(transactionData, options)) {\n\t\tawait validate(transactionData);\n\t\treturn next();\n\t}\n\n\tconst client = getClient(options);\n\tconst plugin = client.core?.resolveTransactionPlugin() ?? coreClientResolveTransactionPlugin;\n\n\treturn plugin(transactionData, options, async () => {\n\t\tawait validate(transactionData);\n\t\tawait next();\n\t});\n}\n\nfunction validate(transactionData: TransactionDataBuilder) {\n\ttransactionData.inputs.forEach((input, index) => {\n\t\tif (input.$kind !== 'Object' && input.$kind !== 'Pure' && input.$kind !== 'FundsWithdrawal') {\n\t\t\tthrow new Error(\n\t\t\t\t`Input at index ${index} has not been resolved. Expected a Pure, Object, or FundsWithdrawal input, but found ${JSON.stringify(\n\t\t\t\t\tinput,\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t});\n}\n\nexport function getClient(options: BuildTransactionOptions) {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No haneul client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\n\treturn options.client;\n}\n\nfunction normalizeRawArguments(transactionData: TransactionDataBuilder) {\n\tfor (const command of transactionData.commands) {\n\t\tswitch (command.$kind) {\n\t\t\tcase 'SplitCoins':\n\t\t\t\tcommand.SplitCoins.amounts.forEach((amount) => {\n\t\t\t\t\tnormalizeRawArgument(amount, bcs.U64, transactionData);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'TransferObjects':\n\t\t\t\tnormalizeRawArgument(command.TransferObjects.address, bcs.Address, transactionData);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction normalizeRawArgument(\n\targ: Argument,\n\tschema: BcsType<any>,\n\ttransactionData: TransactionDataBuilder,\n) {\n\tif (arg.$kind !== 'Input') {\n\t\treturn;\n\t}\n\tconst input = transactionData.inputs[arg.Input];\n\n\tif (input.$kind !== 'UnresolvedPure') {\n\t\treturn;\n\t}\n\n\ttransactionData.inputs[arg.Input] = Inputs.Pure(schema.serialize(input.UnresolvedPure.value));\n}\n"],"mappings":";;;;;AA2BA,SAAgB,2BACf,MACA,SACU;AACV,KACC,KAAK,OAAO,MAAM,UAAU;AAC3B,SAAO,MAAM,oBAAoB,MAAM;GACtC,CAEF,QAAO;AAGR,KAAI,CAAC,QAAQ,qBAAqB;AACjC,MAAI,CAAC,KAAK,QAAQ,SAAS,CAAC,KAAK,QAAQ,UAAU,CAAC,KAAK,QAAQ,QAChE,QAAO;AAGR,MAAI,KAAK,QAAQ,QAAQ,WAAW,KAAK,CAAC,KAAK,WAC9C,QAAO;;AAIT,QAAO;;AAGR,eAAsB,yBACrB,iBACA,SACA,MACC;AACD,uBAAsB,gBAAgB;AACtC,KAAI,CAAC,2BAA2B,iBAAiB,QAAQ,EAAE;AAC1D,QAAM,SAAS,gBAAgB;AAC/B,SAAO,MAAM;;AAMd,SAHe,UAAU,QAAQ,CACX,MAAM,0BAA0B,IAAI,oCAE5C,iBAAiB,SAAS,YAAY;AACnD,QAAM,SAAS,gBAAgB;AAC/B,QAAM,MAAM;GACX;;AAGH,SAAS,SAAS,iBAAyC;AAC1D,iBAAgB,OAAO,SAAS,OAAO,UAAU;AAChD,MAAI,MAAM,UAAU,YAAY,MAAM,UAAU,UAAU,MAAM,UAAU,kBACzE,OAAM,IAAI,MACT,kBAAkB,MAAM,wFAAwF,KAAK,UACpH,MACA,GACD;GAED;;AAGH,SAAgB,UAAU,SAAkC;AAC3D,KAAI,CAAC,QAAQ,OACZ,OAAM,IAAI,MACT,0GACA;AAGF,QAAO,QAAQ;;AAGhB,SAAS,sBAAsB,iBAAyC;AACvE,MAAK,MAAM,WAAW,gBAAgB,SACrC,SAAQ,QAAQ,OAAhB;EACC,KAAK;AACJ,WAAQ,WAAW,QAAQ,SAAS,WAAW;AAC9C,yBAAqB,QAAQA,OAAI,KAAK,gBAAgB;KACrD;AACF;EACD,KAAK;AACJ,wBAAqB,QAAQ,gBAAgB,SAASA,OAAI,SAAS,gBAAgB;AACnF;;;AAKJ,SAAS,qBACR,KACA,QACA,iBACC;AACD,KAAI,IAAI,UAAU,QACjB;CAED,MAAM,QAAQ,gBAAgB,OAAO,IAAI;AAEzC,KAAI,MAAM,UAAU,iBACnB;AAGD,iBAAgB,OAAO,IAAI,SAAS,OAAO,KAAK,OAAO,UAAU,MAAM,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"resolve.mjs","names":["bcs"],"sources":["../../src/transactions/resolve.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Argument } from './data/internal.js';\n\nimport type { ClientWithCoreApi } from '../client/index.js';\nimport type { TransactionDataBuilder } from './TransactionData.js';\nimport type { BcsType } from '@haneullabs/bcs';\nimport { Inputs } from './Inputs.js';\nimport { bcs } from '../bcs/index.js';\nimport { coreClientResolveTransactionPlugin } from '../client/core-resolver.js';\n\nexport interface BuildTransactionOptions {\n\tclient?: ClientWithCoreApi;\n\tonlyTransactionKind?: boolean;\n}\n\nexport interface SerializeTransactionOptions extends BuildTransactionOptions {\n\tsupportedIntents?: string[];\n}\n\nexport type TransactionPlugin = (\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) => Promise<void>;\n\nexport function needsTransactionResolution(\n\tdata: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n): boolean {\n\tif (\n\t\tdata.inputs.some((input) => {\n\t\t\treturn input.UnresolvedObject || input.UnresolvedPure;\n\t\t})\n\t) {\n\t\treturn true;\n\t}\n\n\tif (!options.onlyTransactionKind) {\n\t\tif (!data.gasData.price || !data.gasData.budget || !data.gasData.payment) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (data.gasData.payment.length === 0 && !data.expiration) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport async function resolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tnormalizeRawArguments(transactionData);\n\tif (!needsTransactionResolution(transactionData, options)) {\n\t\tawait validate(transactionData);\n\t\treturn next();\n\t}\n\n\tconst client = getClient(options);\n\tconst plugin = client.core?.resolveTransactionPlugin() ?? coreClientResolveTransactionPlugin;\n\n\treturn plugin(transactionData, options, async () => {\n\t\tawait validate(transactionData);\n\t\tawait next();\n\t});\n}\n\nfunction validate(transactionData: TransactionDataBuilder) {\n\ttransactionData.inputs.forEach((input, index) => {\n\t\tif (input.$kind !== 'Object' && input.$kind !== 'Pure' && input.$kind !== 'FundsWithdrawal') {\n\t\t\tthrow new Error(\n\t\t\t\t`Input at index ${index} has not been resolved. Expected a Pure, Object, or FundsWithdrawal input, but found ${JSON.stringify(\n\t\t\t\t\tinput,\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t});\n}\n\nexport function getClient(options: BuildTransactionOptions) {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No haneul client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\n\treturn options.client;\n}\n\nfunction normalizeRawArguments(transactionData: TransactionDataBuilder) {\n\tfor (const command of transactionData.commands) {\n\t\tswitch (command.$kind) {\n\t\t\tcase 'SplitCoins':\n\t\t\t\tcommand.SplitCoins.amounts.forEach((amount) => {\n\t\t\t\t\tnormalizeRawArgument(amount, bcs.U64, transactionData);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'TransferObjects':\n\t\t\t\tnormalizeRawArgument(command.TransferObjects.address, bcs.Address, transactionData);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction normalizeRawArgument(\n\targ: Argument,\n\tschema: BcsType<any>,\n\ttransactionData: TransactionDataBuilder,\n) {\n\tif (arg.$kind !== 'Input') {\n\t\treturn;\n\t}\n\tconst input = transactionData.inputs[arg.Input];\n\n\tif (input.$kind !== 'UnresolvedPure') {\n\t\treturn;\n\t}\n\n\ttransactionData.inputs[arg.Input] = Inputs.Pure(schema.serialize(input.UnresolvedPure.value));\n}\n"],"mappings":";;;;;AA2BA,SAAgB,2BACf,MACA,SACU;AACV,KACC,KAAK,OAAO,MAAM,UAAU;AAC3B,SAAO,MAAM,oBAAoB,MAAM;GACtC,CAEF,QAAO;AAGR,KAAI,CAAC,QAAQ,qBAAqB;AACjC,MAAI,CAAC,KAAK,QAAQ,SAAS,CAAC,KAAK,QAAQ,UAAU,CAAC,KAAK,QAAQ,QAChE,QAAO;AAGR,MAAI,KAAK,QAAQ,QAAQ,WAAW,KAAK,CAAC,KAAK,WAC9C,QAAO;;AAIT,QAAO;;AAGR,eAAsB,yBACrB,iBACA,SACA,MACC;AACD,uBAAsB,gBAAgB;AACtC,KAAI,CAAC,2BAA2B,iBAAiB,QAAQ,EAAE;AAC1D,QAAM,SAAS,gBAAgB;AAC/B,SAAO,MAAM;;AAMd,SAHe,UAAU,QAAQ,CACX,MAAM,0BAA0B,IAAI,oCAE5C,iBAAiB,SAAS,YAAY;AACnD,QAAM,SAAS,gBAAgB;AAC/B,QAAM,MAAM;GACX;;AAGH,SAAS,SAAS,iBAAyC;AAC1D,iBAAgB,OAAO,SAAS,OAAO,UAAU;AAChD,MAAI,MAAM,UAAU,YAAY,MAAM,UAAU,UAAU,MAAM,UAAU,kBACzE,OAAM,IAAI,MACT,kBAAkB,MAAM,wFAAwF,KAAK,UACpH,MACA,GACD;GAED;;AAGH,SAAgB,UAAU,SAAkC;AAC3D,KAAI,CAAC,QAAQ,OACZ,OAAM,IAAI,MACT,0GACA;AAGF,QAAO,QAAQ;;AAGhB,SAAS,sBAAsB,iBAAyC;AACvE,MAAK,MAAM,WAAW,gBAAgB,SACrC,SAAQ,QAAQ,OAAhB;EACC,KAAK;AACJ,WAAQ,WAAW,QAAQ,SAAS,WAAW;AAC9C,yBAAqB,QAAQA,UAAI,KAAK,gBAAgB;KACrD;AACF;EACD,KAAK;AACJ,wBAAqB,QAAQ,gBAAgB,SAASA,UAAI,SAAS,gBAAgB;AACnF;;;AAKJ,SAAS,qBACR,KACA,QACA,iBACC;AACD,KAAI,IAAI,UAAU,QACjB;CAED,MAAM,QAAQ,gBAAgB,OAAO,IAAI;AAEzC,KAAI,MAAM,UAAU,iBACnB;AAGD,iBAAgB,OAAO,IAAI,SAAS,OAAO,KAAK,OAAO,UAAU,MAAM,eAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.d.mts","names":[],"sources":["../../src/transactions/serializer.ts"],"sourcesContent":[],"mappings":";;;;;;iBAoCgB,gBAAA,gBACA,iBAAA,CAAkB,oBAC/B;iBA4Da,iCAAA,OACT,2BACJ,iBAAA,CAAkB"}
1
+ {"version":3,"file":"serializer.d.mts","names":[],"sources":["../../src/transactions/serializer.ts"],"mappings":";;;;;;iBAoCgB,gBAAA,CACf,aAAA,EAAe,iBAAA,CAAkB,iBAAA,GAC/B,OAAA;AAAA,iBA4Da,iCAAA,CACf,IAAA,EAAM,wBAAA,GACJ,iBAAA,CAAkB,aAAA"}
@@ -1,5 +1,5 @@
1
1
  import { normalizeHaneulAddress } from "../utils/haneul-types.mjs";
2
- import { bcs as suiBcs } from "../bcs/index.mjs";
2
+ import { bcs as haneulBcs } from "../bcs/index.mjs";
3
3
  import { HANEUL_FRAMEWORK_ADDRESS, MOVE_STDLIB_ADDRESS } from "../utils/constants.mjs";
4
4
 
5
5
  //#region src/transactions/serializer.ts
@@ -22,35 +22,35 @@ function isTxContext(param) {
22
22
  }
23
23
  function getPureBcsSchema(typeSignature) {
24
24
  switch (typeSignature.$kind) {
25
- case "address": return suiBcs.Address;
26
- case "bool": return suiBcs.Bool;
27
- case "u8": return suiBcs.U8;
28
- case "u16": return suiBcs.U16;
29
- case "u32": return suiBcs.U32;
30
- case "u64": return suiBcs.U64;
31
- case "u128": return suiBcs.U128;
32
- case "u256": return suiBcs.U256;
25
+ case "address": return haneulBcs.Address;
26
+ case "bool": return haneulBcs.Bool;
27
+ case "u8": return haneulBcs.U8;
28
+ case "u16": return haneulBcs.U16;
29
+ case "u32": return haneulBcs.U32;
30
+ case "u64": return haneulBcs.U64;
31
+ case "u128": return haneulBcs.U128;
32
+ case "u256": return haneulBcs.U256;
33
33
  case "vector": {
34
- if (typeSignature.vector.$kind === "u8") return suiBcs.byteVector().transform({
34
+ if (typeSignature.vector.$kind === "u8") return haneulBcs.byteVector().transform({
35
35
  input: (val) => typeof val === "string" ? new TextEncoder().encode(val) : val,
36
36
  output: (val) => val
37
37
  });
38
38
  const type = getPureBcsSchema(typeSignature.vector);
39
- return type ? suiBcs.vector(type) : null;
39
+ return type ? haneulBcs.vector(type) : null;
40
40
  }
41
41
  case "datatype": {
42
42
  const { package: pkg, module, name } = parseTypeName(typeSignature.datatype.typeName);
43
43
  const normalizedPkg = normalizeHaneulAddress(pkg);
44
44
  if (normalizedPkg === MOVE_STDLIB_ADDRESS) {
45
- if (module === "ascii" && name === "String") return suiBcs.String;
46
- if (module === "string" && name === "String") return suiBcs.String;
45
+ if (module === "ascii" && name === "String") return haneulBcs.String;
46
+ if (module === "string" && name === "String") return haneulBcs.String;
47
47
  if (module === "option" && name === "Option") {
48
48
  const type = getPureBcsSchema(typeSignature.datatype.typeParameters[0]);
49
- return type ? suiBcs.vector(type) : null;
49
+ return type ? haneulBcs.vector(type) : null;
50
50
  }
51
51
  }
52
52
  if (normalizedPkg === HANEUL_FRAMEWORK_ADDRESS) {
53
- if (module === "object" && name === "ID") return suiBcs.Address;
53
+ if (module === "object" && name === "ID") return haneulBcs.Address;
54
54
  }
55
55
  return null;
56
56
  }