wowok 2.1.40 → 2.1.41

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 (399) hide show
  1. package/dist/cjs/bcs/bcs.js +1 -253
  2. package/dist/cjs/bcs/effects.js +1 -199
  3. package/dist/cjs/bcs/index.js +1 -51
  4. package/dist/cjs/bcs/pure.js +1 -36
  5. package/dist/cjs/bcs/type-tag-serializer.js +1 -104
  6. package/dist/cjs/bcs/types.js +1 -3
  7. package/dist/cjs/client/index.js +1 -4
  8. package/dist/cjs/client/network.js +1 -15
  9. package/dist/cjs/cryptography/index.js +1 -6
  10. package/dist/cjs/cryptography/intent.js +1 -14
  11. package/dist/cjs/cryptography/keypair.js +1 -74
  12. package/dist/cjs/cryptography/mnemonics.js +1 -20
  13. package/dist/cjs/cryptography/publickey.js +1 -80
  14. package/dist/cjs/cryptography/signature-scheme.js +1 -22
  15. package/dist/cjs/cryptography/signature.js +1 -41
  16. package/dist/cjs/experimental/cache.js +1 -58
  17. package/dist/cjs/experimental/client.js +1 -19
  18. package/dist/cjs/experimental/core.js +1 -80
  19. package/dist/cjs/experimental/errors.js +1 -24
  20. package/dist/cjs/experimental/index.js +1 -5
  21. package/dist/cjs/experimental/persistent-storage.js +1 -220
  22. package/dist/cjs/experimental/persistent-storage.test.js +1 -144
  23. package/dist/cjs/experimental/transports/utils.js +1 -96
  24. package/dist/cjs/experimental/types.js +1 -1
  25. package/dist/cjs/faucet/faucet.js +1 -99
  26. package/dist/cjs/faucet/index.js +1 -1
  27. package/dist/cjs/grpc/client.js +1 -42
  28. package/dist/cjs/grpc/core.js +1 -587
  29. package/dist/cjs/grpc/index.js +1 -2
  30. package/dist/cjs/grpc/proto/google/protobuf/any.js +1 -106
  31. package/dist/cjs/grpc/proto/google/protobuf/duration.js +1 -58
  32. package/dist/cjs/grpc/proto/google/protobuf/empty.js +1 -7
  33. package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +1 -47
  34. package/dist/cjs/grpc/proto/google/protobuf/struct.js +1 -191
  35. package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +1 -91
  36. package/dist/cjs/grpc/proto/google/rpc/error_details.js +1 -265
  37. package/dist/cjs/grpc/proto/google/rpc/status.js +1 -23
  38. package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +1 -46
  39. package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
  40. package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +1 -22
  41. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
  42. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
  43. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
  44. package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +1 -271
  45. package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +1 -64
  46. package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
  47. package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +1 -62
  48. package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
  49. package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
  50. package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
  51. package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +1 -61
  52. package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +1 -57
  53. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
  54. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
  55. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +1 -447
  56. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
  57. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
  58. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
  59. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +1 -109
  60. package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +1 -90
  61. package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
  62. package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +1 -39
  63. package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
  64. package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +1 -501
  65. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
  66. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
  67. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
  68. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
  69. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +1 -504
  70. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
  71. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
  72. package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +1 -709
  73. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1 -950
  74. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
  75. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
  76. package/dist/cjs/index.js +1 -22
  77. package/dist/cjs/jsonRpc/client.js +1 -516
  78. package/dist/cjs/jsonRpc/core.js +1 -587
  79. package/dist/cjs/jsonRpc/errors.js +1 -38
  80. package/dist/cjs/jsonRpc/http-transport.js +1 -70
  81. package/dist/cjs/jsonRpc/index.js +1 -3
  82. package/dist/cjs/jsonRpc/json-rpc-resolver.js +1 -296
  83. package/dist/cjs/jsonRpc/rpc-websocket-client.js +1 -155
  84. package/dist/cjs/jsonRpc/types/chain.js +1 -1
  85. package/dist/cjs/jsonRpc/types/changes.js +1 -1
  86. package/dist/cjs/jsonRpc/types/coins.js +1 -1
  87. package/dist/cjs/jsonRpc/types/common.js +1 -1
  88. package/dist/cjs/jsonRpc/types/generated.js +1 -1
  89. package/dist/cjs/jsonRpc/types/index.js +1 -1
  90. package/dist/cjs/jsonRpc/types/params.js +1 -1
  91. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +1 -58
  92. package/dist/cjs/keypairs/ed25519/index.js +1 -2
  93. package/dist/cjs/keypairs/ed25519/keypair.js +1 -90
  94. package/dist/cjs/keypairs/ed25519/publickey.js +1 -50
  95. package/dist/cjs/keypairs/index.js +1 -4
  96. package/dist/cjs/keypairs/passkey/index.js +1 -2
  97. package/dist/cjs/keypairs/passkey/keypair.js +1 -155
  98. package/dist/cjs/keypairs/passkey/publickey.js +1 -117
  99. package/dist/cjs/keypairs/passkey/types.js +1 -1
  100. package/dist/cjs/keypairs/secp256k1/index.js +1 -2
  101. package/dist/cjs/keypairs/secp256k1/keypair.js +1 -82
  102. package/dist/cjs/keypairs/secp256k1/publickey.js +1 -51
  103. package/dist/cjs/keypairs/secp256r1/index.js +1 -2
  104. package/dist/cjs/keypairs/secp256r1/keypair.js +1 -78
  105. package/dist/cjs/keypairs/secp256r1/publickey.js +1 -52
  106. package/dist/cjs/multisig/index.js +1 -2
  107. package/dist/cjs/multisig/publickey.js +1 -201
  108. package/dist/cjs/multisig/signer.js +1 -58
  109. package/dist/cjs/transactions/Arguments.js +1 -9
  110. package/dist/cjs/transactions/Commands.js +1 -102
  111. package/dist/cjs/transactions/Inputs.js +1 -52
  112. package/dist/cjs/transactions/ObjectCache.js +1 -205
  113. package/dist/cjs/transactions/Transaction.js +1 -574
  114. package/dist/cjs/transactions/TransactionData.js +1 -409
  115. package/dist/cjs/transactions/__tests__/Transaction.test.js +1 -160
  116. package/dist/cjs/transactions/__tests__/bcs.test.js +1 -182
  117. package/dist/cjs/transactions/data/internal.js +1 -169
  118. package/dist/cjs/transactions/data/v1.js +1 -469
  119. package/dist/cjs/transactions/data/v2.js +1 -97
  120. package/dist/cjs/transactions/executor/caching.js +1 -65
  121. package/dist/cjs/transactions/executor/parallel.js +1 -347
  122. package/dist/cjs/transactions/executor/queue.js +1 -59
  123. package/dist/cjs/transactions/executor/serial.js +1 -99
  124. package/dist/cjs/transactions/hash.js +1 -8
  125. package/dist/cjs/transactions/index.js +1 -12
  126. package/dist/cjs/transactions/intents/CoinWithBalance.js +1 -145
  127. package/dist/cjs/transactions/object.js +1 -87
  128. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +1 -11
  129. package/dist/cjs/transactions/pure.js +1 -36
  130. package/dist/cjs/transactions/resolve.js +1 -69
  131. package/dist/cjs/transactions/serializer.js +1 -167
  132. package/dist/cjs/transactions/utils.js +1 -121
  133. package/dist/cjs/utils/constants.js +1 -18
  134. package/dist/cjs/utils/derived-objects.js +1 -8
  135. package/dist/cjs/utils/dynamic-fields.js +1 -17
  136. package/dist/cjs/utils/format.js +1 -11
  137. package/dist/cjs/utils/index.js +1 -8
  138. package/dist/cjs/utils/move-registry.js +1 -24
  139. package/dist/cjs/utils/sui-types.js +1 -66
  140. package/dist/cjs/utils/suins.js +1 -33
  141. package/dist/cjs/verify/index.js +1 -1
  142. package/dist/cjs/verify/verify.js +1 -87
  143. package/dist/cjs/version.js +1 -2
  144. package/dist/cjs/w/call/allocation.js +1 -345
  145. package/dist/cjs/w/call/arb.js +1 -103
  146. package/dist/cjs/w/call/arbitration.js +1 -1192
  147. package/dist/cjs/w/call/base.js +1 -293
  148. package/dist/cjs/w/call/contact.js +1 -345
  149. package/dist/cjs/w/call/demand.js +1 -681
  150. package/dist/cjs/w/call/entity.js +1 -173
  151. package/dist/cjs/w/call/guard-ins.js +1 -4449
  152. package/dist/cjs/w/call/guard.d.ts +111 -0
  153. package/dist/cjs/w/call/guard.js +1 -1048
  154. package/dist/cjs/w/call/index.js +1 -22
  155. package/dist/cjs/w/call/machine.js +1 -1127
  156. package/dist/cjs/w/call/order.js +1 -337
  157. package/dist/cjs/w/call/passport.js +1 -220
  158. package/dist/cjs/w/call/payment.js +1 -178
  159. package/dist/cjs/w/call/permission.js +1 -1162
  160. package/dist/cjs/w/call/personal.js +1 -139
  161. package/dist/cjs/w/call/progress.js +1 -678
  162. package/dist/cjs/w/call/proof.js +1 -66
  163. package/dist/cjs/w/call/repository.js +1 -1024
  164. package/dist/cjs/w/call/resource.js +1 -108
  165. package/dist/cjs/w/call/reward.js +1 -675
  166. package/dist/cjs/w/call/service.js +1 -1960
  167. package/dist/cjs/w/call/treasury.js +1 -873
  168. package/dist/cjs/w/call/util.d.ts +1 -0
  169. package/dist/cjs/w/call/util.js +1 -566
  170. package/dist/cjs/w/common.js +1 -571
  171. package/dist/cjs/w/exception.js +1 -618
  172. package/dist/cjs/w/index.js +1 -8
  173. package/dist/cjs/w/local/account.js +1 -656
  174. package/dist/cjs/w/local/cache.js +1 -161
  175. package/dist/cjs/w/local/config.js +1 -43
  176. package/dist/cjs/w/local/index.js +1 -228
  177. package/dist/cjs/w/local/local.js +1 -574
  178. package/dist/cjs/w/local/storage.js +1 -185
  179. package/dist/cjs/w/local/token.js +1 -131
  180. package/dist/cjs/w/local/util.js +1 -26
  181. package/dist/cjs/w/local/wip.js +1 -864
  182. package/dist/cjs/w/messenger/crypto.js +1 -380
  183. package/dist/cjs/w/messenger/index.js +1 -4
  184. package/dist/cjs/w/messenger/messenger-api.js +1 -1154
  185. package/dist/cjs/w/messenger/messenger-manager.js +1 -1003
  186. package/dist/cjs/w/messenger/messenger.js +1 -1093
  187. package/dist/cjs/w/messenger/server.js +1 -343
  188. package/dist/cjs/w/messenger/session.js +1 -628
  189. package/dist/cjs/w/messenger/storage.js +1 -1023
  190. package/dist/cjs/w/messenger/templates/wts-html-template.js +1 -371
  191. package/dist/cjs/w/messenger/types.js +1 -76
  192. package/dist/cjs/w/messenger/utils.js +1 -12
  193. package/dist/cjs/w/query/bult-in.js +1 -95
  194. package/dist/cjs/w/query/event.js +1 -137
  195. package/dist/cjs/w/query/index.js +1 -5
  196. package/dist/cjs/w/query/object.js +1 -1550
  197. package/dist/cjs/w/query/received.js +1 -62
  198. package/dist/cjs/w/query/util.js +1 -49
  199. package/dist/cjs/w/util.js +1 -587
  200. package/dist/esm/bcs/bcs.js +1 -253
  201. package/dist/esm/bcs/effects.js +1 -199
  202. package/dist/esm/bcs/index.js +1 -51
  203. package/dist/esm/bcs/pure.js +1 -36
  204. package/dist/esm/bcs/type-tag-serializer.js +1 -104
  205. package/dist/esm/bcs/types.js +1 -3
  206. package/dist/esm/client/index.js +1 -4
  207. package/dist/esm/client/network.js +1 -15
  208. package/dist/esm/cryptography/index.js +1 -6
  209. package/dist/esm/cryptography/intent.js +1 -14
  210. package/dist/esm/cryptography/keypair.js +1 -74
  211. package/dist/esm/cryptography/mnemonics.js +1 -20
  212. package/dist/esm/cryptography/publickey.js +1 -80
  213. package/dist/esm/cryptography/signature-scheme.js +1 -22
  214. package/dist/esm/cryptography/signature.js +1 -41
  215. package/dist/esm/experimental/cache.js +1 -58
  216. package/dist/esm/experimental/client.js +1 -19
  217. package/dist/esm/experimental/core.js +1 -80
  218. package/dist/esm/experimental/errors.js +1 -24
  219. package/dist/esm/experimental/index.js +1 -5
  220. package/dist/esm/experimental/persistent-storage.js +1 -220
  221. package/dist/esm/experimental/persistent-storage.test.js +1 -144
  222. package/dist/esm/experimental/transports/utils.js +1 -96
  223. package/dist/esm/experimental/types.js +1 -1
  224. package/dist/esm/faucet/faucet.js +1 -99
  225. package/dist/esm/faucet/index.js +1 -1
  226. package/dist/esm/grpc/client.js +1 -42
  227. package/dist/esm/grpc/core.js +1 -587
  228. package/dist/esm/grpc/index.js +1 -2
  229. package/dist/esm/grpc/proto/google/protobuf/any.js +1 -106
  230. package/dist/esm/grpc/proto/google/protobuf/duration.js +1 -58
  231. package/dist/esm/grpc/proto/google/protobuf/empty.js +1 -7
  232. package/dist/esm/grpc/proto/google/protobuf/field_mask.js +1 -47
  233. package/dist/esm/grpc/proto/google/protobuf/struct.js +1 -191
  234. package/dist/esm/grpc/proto/google/protobuf/timestamp.js +1 -91
  235. package/dist/esm/grpc/proto/google/rpc/error_details.js +1 -265
  236. package/dist/esm/grpc/proto/google/rpc/status.js +1 -23
  237. package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +1 -46
  238. package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
  239. package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +1 -22
  240. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
  241. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
  242. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
  243. package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +1 -271
  244. package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +1 -64
  245. package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
  246. package/dist/esm/grpc/proto/sui/rpc/v2/event.js +1 -62
  247. package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
  248. package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
  249. package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
  250. package/dist/esm/grpc/proto/sui/rpc/v2/input.js +1 -61
  251. package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +1 -57
  252. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
  253. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
  254. package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +1 -447
  255. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
  256. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
  257. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
  258. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +1 -109
  259. package/dist/esm/grpc/proto/sui/rpc/v2/object.js +1 -90
  260. package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
  261. package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +1 -39
  262. package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
  263. package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +1 -501
  264. package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
  265. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
  266. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
  267. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
  268. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +1 -504
  269. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
  270. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
  271. package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +1 -709
  272. package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +1 -950
  273. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
  274. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
  275. package/dist/esm/index.js +1 -22
  276. package/dist/esm/jsonRpc/client.js +1 -516
  277. package/dist/esm/jsonRpc/core.js +1 -587
  278. package/dist/esm/jsonRpc/errors.js +1 -38
  279. package/dist/esm/jsonRpc/http-transport.js +1 -70
  280. package/dist/esm/jsonRpc/index.js +1 -3
  281. package/dist/esm/jsonRpc/json-rpc-resolver.js +1 -296
  282. package/dist/esm/jsonRpc/rpc-websocket-client.js +1 -155
  283. package/dist/esm/jsonRpc/types/chain.js +1 -1
  284. package/dist/esm/jsonRpc/types/changes.js +1 -1
  285. package/dist/esm/jsonRpc/types/coins.js +1 -1
  286. package/dist/esm/jsonRpc/types/common.js +1 -1
  287. package/dist/esm/jsonRpc/types/generated.js +1 -1
  288. package/dist/esm/jsonRpc/types/index.js +1 -1
  289. package/dist/esm/jsonRpc/types/params.js +1 -1
  290. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +1 -58
  291. package/dist/esm/keypairs/ed25519/index.js +1 -2
  292. package/dist/esm/keypairs/ed25519/keypair.js +1 -90
  293. package/dist/esm/keypairs/ed25519/publickey.js +1 -50
  294. package/dist/esm/keypairs/index.js +1 -4
  295. package/dist/esm/keypairs/passkey/index.js +1 -2
  296. package/dist/esm/keypairs/passkey/keypair.js +1 -155
  297. package/dist/esm/keypairs/passkey/publickey.js +1 -117
  298. package/dist/esm/keypairs/passkey/types.js +1 -1
  299. package/dist/esm/keypairs/secp256k1/index.js +1 -2
  300. package/dist/esm/keypairs/secp256k1/keypair.js +1 -82
  301. package/dist/esm/keypairs/secp256k1/publickey.js +1 -51
  302. package/dist/esm/keypairs/secp256r1/index.js +1 -2
  303. package/dist/esm/keypairs/secp256r1/keypair.js +1 -78
  304. package/dist/esm/keypairs/secp256r1/publickey.js +1 -52
  305. package/dist/esm/multisig/index.js +1 -2
  306. package/dist/esm/multisig/publickey.js +1 -201
  307. package/dist/esm/multisig/signer.js +1 -58
  308. package/dist/esm/transactions/Arguments.js +1 -9
  309. package/dist/esm/transactions/Commands.js +1 -102
  310. package/dist/esm/transactions/Inputs.js +1 -52
  311. package/dist/esm/transactions/ObjectCache.js +1 -205
  312. package/dist/esm/transactions/Transaction.js +1 -574
  313. package/dist/esm/transactions/TransactionData.js +1 -409
  314. package/dist/esm/transactions/__tests__/Transaction.test.js +1 -160
  315. package/dist/esm/transactions/__tests__/bcs.test.js +1 -182
  316. package/dist/esm/transactions/data/internal.js +1 -169
  317. package/dist/esm/transactions/data/v1.js +1 -469
  318. package/dist/esm/transactions/data/v2.js +1 -97
  319. package/dist/esm/transactions/executor/caching.js +1 -65
  320. package/dist/esm/transactions/executor/parallel.js +1 -347
  321. package/dist/esm/transactions/executor/queue.js +1 -59
  322. package/dist/esm/transactions/executor/serial.js +1 -99
  323. package/dist/esm/transactions/hash.js +1 -8
  324. package/dist/esm/transactions/index.js +1 -12
  325. package/dist/esm/transactions/intents/CoinWithBalance.js +1 -145
  326. package/dist/esm/transactions/object.js +1 -87
  327. package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +1 -11
  328. package/dist/esm/transactions/pure.js +1 -36
  329. package/dist/esm/transactions/resolve.js +1 -69
  330. package/dist/esm/transactions/serializer.js +1 -167
  331. package/dist/esm/transactions/utils.js +1 -121
  332. package/dist/esm/utils/constants.js +1 -18
  333. package/dist/esm/utils/derived-objects.js +1 -8
  334. package/dist/esm/utils/dynamic-fields.js +1 -17
  335. package/dist/esm/utils/format.js +1 -11
  336. package/dist/esm/utils/index.js +1 -8
  337. package/dist/esm/utils/move-registry.js +1 -24
  338. package/dist/esm/utils/sui-types.js +1 -66
  339. package/dist/esm/utils/suins.js +1 -33
  340. package/dist/esm/verify/index.js +1 -1
  341. package/dist/esm/verify/verify.js +1 -87
  342. package/dist/esm/version.js +1 -2
  343. package/dist/esm/w/call/allocation.js +1 -345
  344. package/dist/esm/w/call/arb.js +1 -103
  345. package/dist/esm/w/call/arbitration.js +1 -1192
  346. package/dist/esm/w/call/base.js +1 -293
  347. package/dist/esm/w/call/contact.js +1 -345
  348. package/dist/esm/w/call/demand.js +1 -681
  349. package/dist/esm/w/call/entity.js +1 -173
  350. package/dist/esm/w/call/guard-ins.js +1 -4449
  351. package/dist/esm/w/call/guard.d.ts +111 -0
  352. package/dist/esm/w/call/guard.js +1 -1048
  353. package/dist/esm/w/call/index.js +1 -22
  354. package/dist/esm/w/call/machine.js +1 -1127
  355. package/dist/esm/w/call/order.js +1 -337
  356. package/dist/esm/w/call/passport.js +1 -220
  357. package/dist/esm/w/call/payment.js +1 -178
  358. package/dist/esm/w/call/permission.js +1 -1162
  359. package/dist/esm/w/call/personal.js +1 -139
  360. package/dist/esm/w/call/progress.js +1 -678
  361. package/dist/esm/w/call/proof.js +1 -66
  362. package/dist/esm/w/call/repository.js +1 -1024
  363. package/dist/esm/w/call/resource.js +1 -108
  364. package/dist/esm/w/call/reward.js +1 -675
  365. package/dist/esm/w/call/service.js +1 -1960
  366. package/dist/esm/w/call/treasury.js +1 -873
  367. package/dist/esm/w/call/util.d.ts +1 -0
  368. package/dist/esm/w/call/util.js +1 -566
  369. package/dist/esm/w/common.js +1 -571
  370. package/dist/esm/w/exception.js +1 -618
  371. package/dist/esm/w/index.js +1 -8
  372. package/dist/esm/w/local/account.js +1 -656
  373. package/dist/esm/w/local/cache.js +1 -161
  374. package/dist/esm/w/local/config.js +1 -43
  375. package/dist/esm/w/local/index.js +1 -228
  376. package/dist/esm/w/local/local.js +1 -574
  377. package/dist/esm/w/local/storage.js +1 -185
  378. package/dist/esm/w/local/token.js +1 -131
  379. package/dist/esm/w/local/util.js +1 -26
  380. package/dist/esm/w/local/wip.js +1 -864
  381. package/dist/esm/w/messenger/crypto.js +1 -380
  382. package/dist/esm/w/messenger/index.js +1 -4
  383. package/dist/esm/w/messenger/messenger-api.js +1 -1154
  384. package/dist/esm/w/messenger/messenger-manager.js +1 -1003
  385. package/dist/esm/w/messenger/messenger.js +1 -1093
  386. package/dist/esm/w/messenger/server.js +1 -343
  387. package/dist/esm/w/messenger/session.js +1 -628
  388. package/dist/esm/w/messenger/storage.js +1 -1023
  389. package/dist/esm/w/messenger/templates/wts-html-template.js +1 -371
  390. package/dist/esm/w/messenger/types.js +1 -76
  391. package/dist/esm/w/messenger/utils.js +1 -12
  392. package/dist/esm/w/query/bult-in.js +1 -95
  393. package/dist/esm/w/query/event.js +1 -137
  394. package/dist/esm/w/query/index.js +1 -5
  395. package/dist/esm/w/query/object.js +1 -1550
  396. package/dist/esm/w/query/received.js +1 -62
  397. package/dist/esm/w/query/util.js +1 -49
  398. package/dist/esm/w/util.js +1 -587
  399. package/package.json +5 -2
@@ -1,409 +1 @@
1
- import { toBase58 } from "@mysten/bcs";
2
- import { parse } from "valibot";
3
- import { bcs } from "../bcs/index.js";
4
- import { normalizeWowAddress } from "../utils/sui-types.js";
5
- import { ArgumentSchema, TransactionDataSchema } from "./data/internal.js";
6
- import { transactionDataFromV1 } from "./data/v1.js";
7
- import { hashTypedData } from "./hash.js";
8
- import { getIdFromCallArg, remapCommandArguments } from "./utils.js";
9
- function prepareWowAddress(address) {
10
- return normalizeWowAddress(address).replace("0x", "");
11
- }
12
- export class TransactionDataBuilder {
13
- static fromKindBytes(bytes) {
14
- const kind = bcs.TransactionKind.parse(bytes);
15
- const programmableTx = kind.ProgrammableTransaction;
16
- if (!programmableTx) {
17
- throw new Error("Unable to deserialize from bytes.");
18
- }
19
- return TransactionDataBuilder.restore({
20
- version: 2,
21
- sender: null,
22
- expiration: null,
23
- gasData: {
24
- budget: null,
25
- owner: null,
26
- payment: null,
27
- price: null,
28
- },
29
- inputs: programmableTx.inputs,
30
- commands: programmableTx.commands,
31
- });
32
- }
33
- static fromBytes(bytes) {
34
- const rawData = bcs.TransactionData.parse(bytes);
35
- const data = rawData?.V1;
36
- const programmableTx = data.kind.ProgrammableTransaction;
37
- if (!data || !programmableTx) {
38
- throw new Error("Unable to deserialize from bytes.");
39
- }
40
- return TransactionDataBuilder.restore({
41
- version: 2,
42
- sender: data.sender,
43
- expiration: data.expiration,
44
- gasData: data.gasData,
45
- inputs: programmableTx.inputs,
46
- commands: programmableTx.commands,
47
- });
48
- }
49
- static restore(data) {
50
- if (data.version === 2) {
51
- return new TransactionDataBuilder(parse(TransactionDataSchema, data));
52
- }
53
- else {
54
- return new TransactionDataBuilder(parse(TransactionDataSchema, transactionDataFromV1(data)));
55
- }
56
- }
57
- static getDigestFromBytes(bytes) {
58
- const hash = hashTypedData("TransactionData", bytes);
59
- return toBase58(hash);
60
- }
61
- get gasConfig() {
62
- return this.gasData;
63
- }
64
- set gasConfig(value) {
65
- this.gasData = value;
66
- }
67
- version = 2;
68
- sender;
69
- expiration;
70
- gasData;
71
- inputs;
72
- commands;
73
- constructor(clone) {
74
- this.sender = clone?.sender ?? null;
75
- this.expiration = clone?.expiration ?? null;
76
- this.inputs = clone?.inputs ?? [];
77
- this.commands = clone?.commands ?? [];
78
- this.gasData = clone?.gasData ?? {
79
- budget: null,
80
- price: null,
81
- owner: null,
82
- payment: null,
83
- };
84
- }
85
- build({ maxSizeBytes = Infinity, overrides, onlyTransactionKind, } = {}) {
86
- const inputs = this.inputs;
87
- const commands = this.commands;
88
- const kind = {
89
- ProgrammableTransaction: {
90
- inputs,
91
- commands,
92
- },
93
- };
94
- if (onlyTransactionKind) {
95
- return bcs.TransactionKind.serialize(kind, {
96
- maxSize: maxSizeBytes,
97
- }).toBytes();
98
- }
99
- const expiration = overrides?.expiration ?? this.expiration;
100
- const sender = overrides?.sender ?? this.sender;
101
- const gasData = {
102
- ...this.gasData,
103
- ...overrides?.gasConfig,
104
- ...overrides?.gasData,
105
- };
106
- if (!sender) {
107
- throw new Error("Missing transaction sender");
108
- }
109
- if (!gasData.budget) {
110
- throw new Error("Missing gas budget");
111
- }
112
- if (!gasData.payment) {
113
- throw new Error("Missing gas payment");
114
- }
115
- if (!gasData.price) {
116
- throw new Error("Missing gas price");
117
- }
118
- const transactionData = {
119
- sender: prepareWowAddress(sender),
120
- expiration: expiration ? expiration : { None: true },
121
- gasData: {
122
- payment: gasData.payment,
123
- owner: prepareWowAddress(this.gasData.owner ?? sender),
124
- price: BigInt(gasData.price),
125
- budget: BigInt(gasData.budget),
126
- },
127
- kind: {
128
- ProgrammableTransaction: {
129
- inputs,
130
- commands,
131
- },
132
- },
133
- };
134
- return bcs.TransactionData.serialize({ V1: transactionData }, { maxSize: maxSizeBytes }).toBytes();
135
- }
136
- addInput(type, arg) {
137
- const index = this.inputs.length;
138
- this.inputs.push(arg);
139
- return { Input: index, type, $kind: "Input" };
140
- }
141
- getInputUses(index, fn) {
142
- this.mapArguments((arg, command) => {
143
- if (arg.$kind === "Input" && arg.Input === index) {
144
- fn(arg, command);
145
- }
146
- return arg;
147
- });
148
- }
149
- mapCommandArguments(index, fn) {
150
- const command = this.commands[index];
151
- switch (command.$kind) {
152
- case "MoveCall":
153
- command.MoveCall.arguments = command.MoveCall.arguments.map((arg) => fn(arg, command, index));
154
- break;
155
- case "TransferObjects":
156
- command.TransferObjects.objects =
157
- command.TransferObjects.objects.map((arg) => fn(arg, command, index));
158
- command.TransferObjects.address = fn(command.TransferObjects.address, command, index);
159
- break;
160
- case "SplitCoins":
161
- command.SplitCoins.coin = fn(command.SplitCoins.coin, command, index);
162
- command.SplitCoins.amounts = command.SplitCoins.amounts.map((arg) => fn(arg, command, index));
163
- break;
164
- case "MergeCoins":
165
- command.MergeCoins.destination = fn(command.MergeCoins.destination, command, index);
166
- command.MergeCoins.sources = command.MergeCoins.sources.map((arg) => fn(arg, command, index));
167
- break;
168
- case "MakeMoveVec":
169
- command.MakeMoveVec.elements = command.MakeMoveVec.elements.map((arg) => fn(arg, command, index));
170
- break;
171
- case "Upgrade":
172
- command.Upgrade.ticket = fn(command.Upgrade.ticket, command, index);
173
- break;
174
- case "$Intent":
175
- const inputs = command.$Intent.inputs;
176
- command.$Intent.inputs = {};
177
- for (const [key, value] of Object.entries(inputs)) {
178
- command.$Intent.inputs[key] = Array.isArray(value)
179
- ? value.map((arg) => fn(arg, command, index))
180
- : fn(value, command, index);
181
- }
182
- break;
183
- case "Publish":
184
- break;
185
- default:
186
- throw new Error(`Unexpected transaction kind: ${command.$kind}`);
187
- }
188
- }
189
- mapArguments(fn) {
190
- for (const commandIndex of this.commands.keys()) {
191
- this.mapCommandArguments(commandIndex, fn);
192
- }
193
- }
194
- replaceCommand(index, replacement, resultIndex = index) {
195
- if (!Array.isArray(replacement)) {
196
- this.commands[index] = replacement;
197
- return;
198
- }
199
- const sizeDiff = replacement.length - 1;
200
- this.commands.splice(index, 1, ...structuredClone(replacement));
201
- this.mapArguments((arg, _command, commandIndex) => {
202
- if (commandIndex < index + replacement.length) {
203
- return arg;
204
- }
205
- if (typeof resultIndex !== "number") {
206
- if ((arg.$kind === "Result" && arg.Result === index) ||
207
- (arg.$kind === "NestedResult" &&
208
- arg.NestedResult[0] === index)) {
209
- if (!("NestedResult" in arg) || arg.NestedResult[1] === 0) {
210
- return parse(ArgumentSchema, structuredClone(resultIndex));
211
- }
212
- else {
213
- throw new Error(`Cannot replace command ${index} with a specific result type: NestedResult[${index}, ${arg.NestedResult[1]}] references a nested element that cannot be mapped to the replacement result`);
214
- }
215
- }
216
- }
217
- switch (arg.$kind) {
218
- case "Result":
219
- if (arg.Result === index &&
220
- typeof resultIndex === "number") {
221
- arg.Result = resultIndex;
222
- }
223
- if (arg.Result > index) {
224
- arg.Result += sizeDiff;
225
- }
226
- break;
227
- case "NestedResult":
228
- if (arg.NestedResult[0] === index &&
229
- typeof resultIndex === "number") {
230
- return {
231
- $kind: "NestedResult",
232
- NestedResult: [resultIndex, arg.NestedResult[1]],
233
- };
234
- }
235
- if (arg.NestedResult[0] > index) {
236
- arg.NestedResult[0] += sizeDiff;
237
- }
238
- break;
239
- }
240
- return arg;
241
- });
242
- }
243
- replaceCommandWithTransaction(index, otherTransaction, result) {
244
- if (result.$kind !== "Result" && result.$kind !== "NestedResult") {
245
- throw new Error("Result must be of kind Result or NestedResult");
246
- }
247
- this.insertTransaction(index, otherTransaction);
248
- this.replaceCommand(index + otherTransaction.commands.length, [], "Result" in result
249
- ? { NestedResult: [result.Result + index, 0] }
250
- : {
251
- NestedResult: [
252
- result
253
- .NestedResult[0] + index,
254
- result
255
- .NestedResult[1],
256
- ],
257
- });
258
- }
259
- insertTransaction(atCommandIndex, otherTransaction) {
260
- const inputMapping = new Map();
261
- const commandMapping = new Map();
262
- for (let i = 0; i < otherTransaction.inputs.length; i++) {
263
- const otherInput = otherTransaction.inputs[i];
264
- const id = getIdFromCallArg(otherInput);
265
- let existingIndex = -1;
266
- if (id !== undefined) {
267
- existingIndex = this.inputs.findIndex((input) => getIdFromCallArg(input) === id);
268
- if (existingIndex !== -1 &&
269
- this.inputs[existingIndex].Object?.SharedObject &&
270
- otherInput.Object?.SharedObject) {
271
- this.inputs[existingIndex].Object.SharedObject.mutable =
272
- this.inputs[existingIndex].Object.SharedObject
273
- .mutable || otherInput.Object.SharedObject.mutable;
274
- }
275
- }
276
- if (existingIndex !== -1) {
277
- inputMapping.set(i, existingIndex);
278
- }
279
- else {
280
- const newIndex = this.inputs.length;
281
- this.inputs.push(otherInput);
282
- inputMapping.set(i, newIndex);
283
- }
284
- }
285
- for (let i = 0; i < otherTransaction.commands.length; i++) {
286
- commandMapping.set(i, atCommandIndex + i);
287
- }
288
- const remappedCommands = [];
289
- for (let i = 0; i < otherTransaction.commands.length; i++) {
290
- const command = structuredClone(otherTransaction.commands[i]);
291
- remapCommandArguments(command, inputMapping, commandMapping);
292
- remappedCommands.push(command);
293
- }
294
- this.commands.splice(atCommandIndex, 0, ...remappedCommands);
295
- const sizeDiff = remappedCommands.length;
296
- if (sizeDiff > 0) {
297
- this.mapArguments((arg, _command, commandIndex) => {
298
- if (commandIndex >= atCommandIndex &&
299
- commandIndex < atCommandIndex + remappedCommands.length) {
300
- return arg;
301
- }
302
- switch (arg.$kind) {
303
- case "Result":
304
- if (arg.Result >= atCommandIndex) {
305
- arg.Result += sizeDiff;
306
- }
307
- break;
308
- case "NestedResult":
309
- if (arg.NestedResult[0] >= atCommandIndex) {
310
- arg.NestedResult[0] += sizeDiff;
311
- }
312
- break;
313
- }
314
- return arg;
315
- });
316
- }
317
- }
318
- getDigest() {
319
- const bytes = this.build({ onlyTransactionKind: false });
320
- return TransactionDataBuilder.getDigestFromBytes(bytes);
321
- }
322
- snapshot() {
323
- return parse(TransactionDataSchema, this);
324
- }
325
- shallowClone() {
326
- return new TransactionDataBuilder({
327
- version: this.version,
328
- sender: this.sender,
329
- expiration: this.expiration,
330
- gasData: {
331
- ...this.gasData,
332
- },
333
- inputs: [...this.inputs],
334
- commands: [...this.commands],
335
- });
336
- }
337
- applyResolvedData(resolved) {
338
- if (!this.sender) {
339
- this.sender = resolved.sender ?? null;
340
- }
341
- if (!this.expiration) {
342
- this.expiration = resolved.expiration ?? null;
343
- }
344
- if (!this.gasData.budget) {
345
- this.gasData.budget = resolved.gasData.budget;
346
- }
347
- if (!this.gasData.owner) {
348
- this.gasData.owner = resolved.gasData.owner ?? null;
349
- }
350
- if (!this.gasData.payment) {
351
- this.gasData.payment = resolved.gasData.payment;
352
- }
353
- if (!this.gasData.price) {
354
- this.gasData.price = resolved.gasData.price;
355
- }
356
- for (let i = 0; i < this.inputs.length; i++) {
357
- const input = this.inputs[i];
358
- const resolvedInput = resolved.inputs[i];
359
- switch (input.$kind) {
360
- case "UnresolvedPure":
361
- if (resolvedInput.$kind !== "Pure") {
362
- throw new Error(`Expected input at index ${i} to resolve to a Pure argument, but got ${JSON.stringify(resolvedInput)}`);
363
- }
364
- this.inputs[i] = resolvedInput;
365
- break;
366
- case "UnresolvedObject":
367
- if (resolvedInput.$kind !== "Object") {
368
- throw new Error(`Expected input at index ${i} to resolve to an Object argument, but got ${JSON.stringify(resolvedInput)}`);
369
- }
370
- if (resolvedInput.Object.$kind === "ImmOrOwnedObject" ||
371
- resolvedInput.Object.$kind === "Receiving") {
372
- const original = input.UnresolvedObject;
373
- const resolved = resolvedInput.Object.ImmOrOwnedObject ??
374
- resolvedInput.Object.Receiving;
375
- if (normalizeWowAddress(original.objectId) !==
376
- normalizeWowAddress(resolved.objectId) ||
377
- (original.version != null &&
378
- original.version !== resolved.version) ||
379
- (original.digest != null &&
380
- original.digest !== resolved.digest) ||
381
- original.mutable != null ||
382
- original.initialSharedVersion != null) {
383
- throw new Error(`Input at index ${i} did not match unresolved object. ${JSON.stringify(original)} is not compatible with ${JSON.stringify(resolved)}`);
384
- }
385
- }
386
- else if (resolvedInput.Object.$kind === "SharedObject") {
387
- const original = input.UnresolvedObject;
388
- const resolved = resolvedInput.Object.SharedObject;
389
- if (normalizeWowAddress(original.objectId) !==
390
- normalizeWowAddress(resolved.objectId) ||
391
- (original.initialSharedVersion != null &&
392
- original.initialSharedVersion !==
393
- resolved.initialSharedVersion) ||
394
- (original.mutable != null &&
395
- original.mutable !== resolved.mutable) ||
396
- original.version != null ||
397
- original.digest != null) {
398
- throw new Error(`Input at index ${i} did not match unresolved object. ${JSON.stringify(original)} is not compatible with ${JSON.stringify(resolved)}`);
399
- }
400
- }
401
- else {
402
- throw new Error(`Input at index ${i} resolved to an unexpected Object kind: ${JSON.stringify(resolvedInput.Object)}`);
403
- }
404
- this.inputs[i] = resolvedInput;
405
- break;
406
- }
407
- }
408
- }
409
- }
1
+ import{toBase58}from'@mysten/bcs';import{parse}from'valibot';import{bcs}from'../bcs/index.js';import{normalizeWowAddress}from'../utils/sui-types.js';import{ArgumentSchema,TransactionDataSchema}from'./data/internal.js';import{transactionDataFromV1}from'./data/v1.js';import{hashTypedData}from'./hash.js';import{getIdFromCallArg,remapCommandArguments}from'./utils.js';function prepareWowAddress(a){return normalizeWowAddress(a)['replace']('0x','');}export class TransactionDataBuilder{static['fromKindBytes'](a){const b=bcs['TransactionKind']['parse'](a),c=b['ProgrammableTransaction'];if(!c)throw new Error('Unable\x20to\x20deserialize\x20from\x20bytes.');return TransactionDataBuilder['restore']({'version':0x2,'sender':null,'expiration':null,'gasData':{'budget':null,'owner':null,'payment':null,'price':null},'inputs':c['inputs'],'commands':c['commands']});}static['fromBytes'](a){const b=bcs['TransactionData']['parse'](a),c=b?.['V1'],d=c['kind']['ProgrammableTransaction'];if(!c||!d)throw new Error('Unable\x20to\x20deserialize\x20from\x20bytes.');return TransactionDataBuilder['restore']({'version':0x2,'sender':c['sender'],'expiration':c['expiration'],'gasData':c['gasData'],'inputs':d['inputs'],'commands':d['commands']});}static['restore'](a){return a['version']===0x2?new TransactionDataBuilder(parse(TransactionDataSchema,a)):new TransactionDataBuilder(parse(TransactionDataSchema,transactionDataFromV1(a)));}static['getDigestFromBytes'](a){const b=hashTypedData('TransactionData',a);return toBase58(b);}get['gasConfig'](){return this['gasData'];}set['gasConfig'](a){this['gasData']=a;}['version']=0x2;['sender'];['expiration'];['gasData'];['inputs'];['commands'];constructor(a){this['sender']=a?.['sender']??null,this['expiration']=a?.['expiration']??null,this['inputs']=a?.['inputs']??[],this['commands']=a?.['commands']??[],this['gasData']=a?.['gasData']??{'budget':null,'price':null,'owner':null,'payment':null};}['build']({maxSizeBytes:maxSizeBytes=Infinity,overrides:a,onlyTransactionKind:b}={}){const c=this['inputs'],d=this['commands'],e={'ProgrammableTransaction':{'inputs':c,'commands':d}};if(b)return bcs['TransactionKind']['serialize'](e,{'maxSize':maxSizeBytes})['toBytes']();const f=a?.['expiration']??this['expiration'],g=a?.['sender']??this['sender'],h={...this['gasData'],...a?.['gasConfig'],...a?.['gasData']};if(!g)throw new Error('Missing\x20transaction\x20sender');if(!h['budget'])throw new Error('Missing\x20gas\x20budget');if(!h['payment'])throw new Error('Missing\x20gas\x20payment');if(!h['price'])throw new Error('Missing\x20gas\x20price');const i={'sender':prepareWowAddress(g),'expiration':f?f:{'None':!![]},'gasData':{'payment':h['payment'],'owner':prepareWowAddress(this['gasData']['owner']??g),'price':BigInt(h['price']),'budget':BigInt(h['budget'])},'kind':{'ProgrammableTransaction':{'inputs':c,'commands':d}}};return bcs['TransactionData']['serialize']({'V1':i},{'maxSize':maxSizeBytes})['toBytes']();}['addInput'](a,b){const c=this['inputs']['length'];return this['inputs']['push'](b),{'Input':c,'type':a,'$kind':'Input'};}['getInputUses'](a,b){this['mapArguments']((c,d)=>{return c['$kind']==='Input'&&c['Input']===a&&b(c,d),c;});}['mapCommandArguments'](a,b){const c=this['commands'][a];switch(c['$kind']){case'MoveCall':c['MoveCall']['arguments']=c['MoveCall']['arguments']['map'](e=>b(e,c,a));break;case'TransferObjects':c['TransferObjects']['objects']=c['TransferObjects']['objects']['map'](e=>b(e,c,a)),c['TransferObjects']['address']=b(c['TransferObjects']['address'],c,a);break;case'SplitCoins':c['SplitCoins']['coin']=b(c['SplitCoins']['coin'],c,a),c['SplitCoins']['amounts']=c['SplitCoins']['amounts']['map'](e=>b(e,c,a));break;case'MergeCoins':c['MergeCoins']['destination']=b(c['MergeCoins']['destination'],c,a),c['MergeCoins']['sources']=c['MergeCoins']['sources']['map'](e=>b(e,c,a));break;case'MakeMoveVec':c['MakeMoveVec']['elements']=c['MakeMoveVec']['elements']['map'](e=>b(e,c,a));break;case'Upgrade':c['Upgrade']['ticket']=b(c['Upgrade']['ticket'],c,a);break;case'$Intent':const d=c['$Intent']['inputs'];c['$Intent']['inputs']={};for(const [e,f]of Object['entries'](d)){c['$Intent']['inputs'][e]=Array['isArray'](f)?f['map'](g=>b(g,c,a)):b(f,c,a);}break;case'Publish':break;default:throw new Error('Unexpected\x20transaction\x20kind:\x20'+c['$kind']);}}['mapArguments'](a){for(const b of this['commands']['keys']()){this['mapCommandArguments'](b,a);}}['replaceCommand'](a,b,c=a){if(!Array['isArray'](b)){this['commands'][a]=b;return;}const d=b['length']-0x1;this['commands']['splice'](a,0x1,...structuredClone(b)),this['mapArguments']((e,f,g)=>{if(g<a+b['length'])return e;if(typeof c!=='number'){if(e['$kind']==='Result'&&e['Result']===a||e['$kind']==='NestedResult'&&e['NestedResult'][0x0]===a){if(!('NestedResult'in e)||e['NestedResult'][0x1]===0x0)return parse(ArgumentSchema,structuredClone(c));else throw new Error('Cannot\x20replace\x20command\x20'+a+'\x20with\x20a\x20specific\x20result\x20type:\x20NestedResult['+a+',\x20'+e['NestedResult'][0x1]+']\x20references\x20a\x20nested\x20element\x20that\x20cannot\x20be\x20mapped\x20to\x20the\x20replacement\x20result');}}switch(e['$kind']){case'Result':e['Result']===a&&typeof c==='number'&&(e['Result']=c);e['Result']>a&&(e['Result']+=d);break;case'NestedResult':if(e['NestedResult'][0x0]===a&&typeof c==='number')return{'$kind':'NestedResult','NestedResult':[c,e['NestedResult'][0x1]]};e['NestedResult'][0x0]>a&&(e['NestedResult'][0x0]+=d);break;}return e;});}['replaceCommandWithTransaction'](a,b,c){if(c['$kind']!=='Result'&&c['$kind']!=='NestedResult')throw new Error('Result\x20must\x20be\x20of\x20kind\x20Result\x20or\x20NestedResult');this['insertTransaction'](a,b),this['replaceCommand'](a+b['commands']['length'],[],'Result'in c?{'NestedResult':[c['Result']+a,0x0]}:{'NestedResult':[c['NestedResult'][0x0]+a,c['NestedResult'][0x1]]});}['insertTransaction'](a,b){const c=new Map(),d=new Map();for(let g=0x0;g<b['inputs']['length'];g++){const h=b['inputs'][g],j=getIdFromCallArg(h);let k=-0x1;j!==undefined&&(k=this['inputs']['findIndex'](l=>getIdFromCallArg(l)===j),k!==-0x1&&this['inputs'][k]['Object']?.['SharedObject']&&h['Object']?.['SharedObject']&&(this['inputs'][k]['Object']['SharedObject']['mutable']=this['inputs'][k]['Object']['SharedObject']['mutable']||h['Object']['SharedObject']['mutable']));if(k!==-0x1)c['set'](g,k);else{const l=this['inputs']['length'];this['inputs']['push'](h),c['set'](g,l);}}for(let m=0x0;m<b['commands']['length'];m++){d['set'](m,a+m);}const e=[];for(let n=0x0;n<b['commands']['length'];n++){const o=structuredClone(b['commands'][n]);remapCommandArguments(o,c,d),e['push'](o);}this['commands']['splice'](a,0x0,...e);const f=e['length'];f>0x0&&this['mapArguments']((p,q,r)=>{if(r>=a&&r<a+e['length'])return p;switch(p['$kind']){case'Result':p['Result']>=a&&(p['Result']+=f);break;case'NestedResult':p['NestedResult'][0x0]>=a&&(p['NestedResult'][0x0]+=f);break;}return p;});}['getDigest'](){const a=this['build']({'onlyTransactionKind':![]});return TransactionDataBuilder['getDigestFromBytes'](a);}['snapshot'](){return parse(TransactionDataSchema,this);}['shallowClone'](){return new TransactionDataBuilder({'version':this['version'],'sender':this['sender'],'expiration':this['expiration'],'gasData':{...this['gasData']},'inputs':[...this['inputs']],'commands':[...this['commands']]});}['applyResolvedData'](a){!this['sender']&&(this['sender']=a['sender']??null);!this['expiration']&&(this['expiration']=a['expiration']??null);!this['gasData']['budget']&&(this['gasData']['budget']=a['gasData']['budget']);!this['gasData']['owner']&&(this['gasData']['owner']=a['gasData']['owner']??null);!this['gasData']['payment']&&(this['gasData']['payment']=a['gasData']['payment']);!this['gasData']['price']&&(this['gasData']['price']=a['gasData']['price']);for(let b=0x0;b<this['inputs']['length'];b++){const c=this['inputs'][b],d=a['inputs'][b];switch(c['$kind']){case'UnresolvedPure':if(d['$kind']!=='Pure')throw new Error('Expected\x20input\x20at\x20index\x20'+b+'\x20to\x20resolve\x20to\x20a\x20Pure\x20argument,\x20but\x20got\x20'+JSON['stringify'](d));this['inputs'][b]=d;break;case'UnresolvedObject':if(d['$kind']!=='Object')throw new Error('Expected\x20input\x20at\x20index\x20'+b+'\x20to\x20resolve\x20to\x20an\x20Object\x20argument,\x20but\x20got\x20'+JSON['stringify'](d));if(d['Object']['$kind']==='ImmOrOwnedObject'||d['Object']['$kind']==='Receiving'){const e=c['UnresolvedObject'],f=d['Object']['ImmOrOwnedObject']??d['Object']['Receiving'];if(normalizeWowAddress(e['objectId'])!==normalizeWowAddress(f['objectId'])||e['version']!=null&&e['version']!==f['version']||e['digest']!=null&&e['digest']!==f['digest']||e['mutable']!=null||e['initialSharedVersion']!=null)throw new Error('Input\x20at\x20index\x20'+b+'\x20did\x20not\x20match\x20unresolved\x20object.\x20'+JSON['stringify'](e)+'\x20is\x20not\x20compatible\x20with\x20'+JSON['stringify'](f));}else{if(d['Object']['$kind']==='SharedObject'){const g=c['UnresolvedObject'],h=d['Object']['SharedObject'];if(normalizeWowAddress(g['objectId'])!==normalizeWowAddress(h['objectId'])||g['initialSharedVersion']!=null&&g['initialSharedVersion']!==h['initialSharedVersion']||g['mutable']!=null&&g['mutable']!==h['mutable']||g['version']!=null||g['digest']!=null)throw new Error('Input\x20at\x20index\x20'+b+'\x20did\x20not\x20match\x20unresolved\x20object.\x20'+JSON['stringify'](g)+'\x20is\x20not\x20compatible\x20with\x20'+JSON['stringify'](h));}else throw new Error('Input\x20at\x20index\x20'+b+'\x20resolved\x20to\x20an\x20unexpected\x20Object\x20kind:\x20'+JSON['stringify'](d['Object']));}this['inputs'][b]=d;break;}}}}
@@ -1,160 +1 @@
1
- import { toBase58 } from "@mysten/bcs";
2
- import { describe, expect, it } from "vitest";
3
- import { bcs } from "../../bcs/index.js";
4
- import { Commands, Transaction } from "../index.js";
5
- import { Inputs } from "../Inputs.js";
6
- it("can construct and serialize an empty tranaction", () => {
7
- const tx = new Transaction();
8
- expect(() => tx.serialize()).not.toThrow();
9
- });
10
- it("can construct a receiving transaction argument", () => {
11
- const tx = new Transaction();
12
- tx.object(Inputs.ReceivingRef(ref()));
13
- expect(() => tx.serialize()).not.toThrow();
14
- });
15
- it("receiving transaction argument different from object argument", () => {
16
- const oref = ref();
17
- const rtx = new Transaction();
18
- rtx.object(Inputs.ReceivingRef(oref));
19
- const otx = new Transaction();
20
- otx.object(Inputs.ObjectRef(oref));
21
- expect(() => rtx.serialize()).not.toThrow();
22
- expect(() => otx.serialize()).not.toThrow();
23
- expect(otx.serialize()).not.toEqual(rtx.serialize());
24
- });
25
- it("can be serialized and deserialized to the same values", () => {
26
- const tx = new Transaction();
27
- tx.add(Commands.SplitCoins(tx.gas, [tx.pure.u64(100)]));
28
- const serialized = tx.serialize();
29
- const tx2 = Transaction.from(serialized);
30
- expect(serialized).toEqual(tx2.serialize());
31
- });
32
- it("allows transfer with the result of split Commands", () => {
33
- const tx = new Transaction();
34
- const coin = tx.add(Commands.SplitCoins(tx.gas, [tx.pure.u64(100)]));
35
- tx.add(Commands.TransferObjects([coin], tx.object("0x2")));
36
- });
37
- it("supports nested results through either array index or destructuring", () => {
38
- const tx = new Transaction();
39
- const registerResult = tx.add(Commands.MoveCall({
40
- target: "0x2::game::register",
41
- }));
42
- const [nft, account] = registerResult;
43
- expect(nft).toBe(registerResult[0]);
44
- expect(account).toBe(registerResult[1]);
45
- });
46
- describe("offline build", () => {
47
- it("builds an empty transaction offline when provided sufficient data", async () => {
48
- const tx = setup();
49
- await tx.build();
50
- });
51
- it("supports epoch expiration", async () => {
52
- const tx = setup();
53
- tx.setExpiration({ Epoch: 1 });
54
- await tx.build();
55
- });
56
- it("builds a split transaction", async () => {
57
- const tx = setup();
58
- tx.add(Commands.SplitCoins(tx.gas, [tx.pure.u64(100)]));
59
- await tx.build();
60
- });
61
- it("breaks reference equality", () => {
62
- const tx = setup();
63
- const tx2 = Transaction.from(tx);
64
- tx.setGasBudget(999);
65
- expect(tx2.blockData).not.toEqual(tx.blockData);
66
- expect(tx.blockData).not.toBe(tx.blockData);
67
- expect(tx.blockData.gasConfig).not.toBe(tx.blockData.gasConfig);
68
- expect(tx.blockData.transactions).not.toBe(tx.blockData.transactions);
69
- expect(tx.blockData.inputs).not.toBe(tx.blockData.inputs);
70
- });
71
- it("can determine the type of inputs for built-in Commands", async () => {
72
- const tx = setup();
73
- tx.splitCoins(tx.gas, [100]);
74
- await tx.build();
75
- });
76
- it("supports pre-serialized inputs as Uint8Array", async () => {
77
- const tx = setup();
78
- const inputBytes = bcs.U64.serialize(100n).toBytes();
79
- tx.add(Commands.SplitCoins(tx.gas, [tx.pure(inputBytes)]));
80
- await tx.build();
81
- });
82
- it("builds a more complex interaction", async () => {
83
- const tx = setup();
84
- const coin = tx.splitCoins(tx.gas, [100]);
85
- tx.add(Commands.MergeCoins(tx.gas, [
86
- coin,
87
- tx.object(Inputs.ObjectRef(ref())),
88
- ]));
89
- tx.add(Commands.MoveCall({
90
- target: "0x2::devnet_nft::mint",
91
- typeArguments: [],
92
- arguments: [
93
- tx.pure.string("foo"),
94
- tx.pure.string("bar"),
95
- tx.pure.string("baz"),
96
- ],
97
- }));
98
- await tx.build();
99
- });
100
- it("uses a receiving argument", async () => {
101
- const tx = setup();
102
- tx.object(Inputs.ObjectRef(ref()));
103
- const coin = tx.splitCoins(tx.gas, [100]);
104
- tx.add(Commands.MergeCoins(tx.gas, [
105
- coin,
106
- tx.object(Inputs.ObjectRef(ref())),
107
- ]));
108
- tx.add(Commands.MoveCall({
109
- target: "0x2::devnet_nft::mint",
110
- typeArguments: [],
111
- arguments: [
112
- tx.object(Inputs.ObjectRef(ref())),
113
- tx.object(Inputs.ReceivingRef(ref())),
114
- ],
115
- }));
116
- const bytes = await tx.build();
117
- const tx2 = Transaction.from(bytes);
118
- const bytes2 = await tx2.build();
119
- expect(bytes).toEqual(bytes2);
120
- });
121
- it("builds a more complex interaction", async () => {
122
- const tx = setup();
123
- const coin = tx.splitCoins(tx.gas, [100]);
124
- tx.add(Commands.MergeCoins(tx.gas, [
125
- coin,
126
- tx.object(Inputs.ObjectRef(ref())),
127
- ]));
128
- tx.add(Commands.MoveCall({
129
- target: "0x2::devnet_nft::mint",
130
- typeArguments: [],
131
- arguments: [
132
- tx.pure.string("foo"),
133
- tx.pure.string("bar"),
134
- tx.pure.string("baz"),
135
- ],
136
- }));
137
- const bytes = await tx.build();
138
- const tx2 = Transaction.from(bytes);
139
- const bytes2 = await tx2.build();
140
- expect(bytes).toEqual(bytes2);
141
- });
142
- });
143
- function ref() {
144
- return {
145
- objectId: (Math.random() * 100000).toFixed(0).padEnd(64, "0"),
146
- version: String((Math.random() * 10000).toFixed(0)),
147
- digest: toBase58(new Uint8Array([
148
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
149
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2,
150
- ])),
151
- };
152
- }
153
- function setup() {
154
- const tx = new Transaction();
155
- tx.setSender("0x2");
156
- tx.setGasPrice(5);
157
- tx.setGasBudget(100);
158
- tx.setGasPayment([ref()]);
159
- return tx;
160
- }
1
+ import{toBase58}from'@mysten/bcs';import{describe,expect,it}from'vitest';import{bcs}from'../../bcs/index.js';import{Commands,Transaction}from'../index.js';import{Inputs}from'../Inputs.js';it('can\x20construct\x20and\x20serialize\x20an\x20empty\x20tranaction',()=>{const a=new Transaction();expect(()=>a['serialize']())['not']['toThrow']();}),it('can\x20construct\x20a\x20receiving\x20transaction\x20argument',()=>{const a=new Transaction();a['object'](Inputs['ReceivingRef'](ref())),expect(()=>a['serialize']())['not']['toThrow']();}),it('receiving\x20transaction\x20argument\x20different\x20from\x20object\x20argument',()=>{const a=ref(),b=new Transaction();b['object'](Inputs['ReceivingRef'](a));const c=new Transaction();c['object'](Inputs['ObjectRef'](a)),expect(()=>b['serialize']())['not']['toThrow'](),expect(()=>c['serialize']())['not']['toThrow'](),expect(c['serialize']())['not']['toEqual'](b['serialize']());}),it('can\x20be\x20serialized\x20and\x20deserialized\x20to\x20the\x20same\x20values',()=>{const a=new Transaction();a['add'](Commands['SplitCoins'](a['gas'],[a['pure']['u64'](0x64)]));const b=a['serialize'](),c=Transaction['from'](b);expect(b)['toEqual'](c['serialize']());}),it('allows\x20transfer\x20with\x20the\x20result\x20of\x20split\x20Commands',()=>{const a=new Transaction(),b=a['add'](Commands['SplitCoins'](a['gas'],[a['pure']['u64'](0x64)]));a['add'](Commands['TransferObjects']([b],a['object']('0x2')));}),it('supports\x20nested\x20results\x20through\x20either\x20array\x20index\x20or\x20destructuring',()=>{const a=new Transaction(),b=a['add'](Commands['MoveCall']({'target':'0x2::game::register'})),[c,d]=b;expect(c)['toBe'](b[0x0]),expect(d)['toBe'](b[0x1]);}),describe('offline\x20build',()=>{it('builds\x20an\x20empty\x20transaction\x20offline\x20when\x20provided\x20sufficient\x20data',async()=>{const a=setup();await a['build']();}),it('supports\x20epoch\x20expiration',async()=>{const a=setup();a['setExpiration']({'Epoch':0x1}),await a['build']();}),it('builds\x20a\x20split\x20transaction',async()=>{const a=setup();a['add'](Commands['SplitCoins'](a['gas'],[a['pure']['u64'](0x64)])),await a['build']();}),it('breaks\x20reference\x20equality',()=>{const a=setup(),b=Transaction['from'](a);a['setGasBudget'](0x3e7),expect(b['blockData'])['not']['toEqual'](a['blockData']),expect(a['blockData'])['not']['toBe'](a['blockData']),expect(a['blockData']['gasConfig'])['not']['toBe'](a['blockData']['gasConfig']),expect(a['blockData']['transactions'])['not']['toBe'](a['blockData']['transactions']),expect(a['blockData']['inputs'])['not']['toBe'](a['blockData']['inputs']);}),it('can\x20determine\x20the\x20type\x20of\x20inputs\x20for\x20built-in\x20Commands',async()=>{const a=setup();a['splitCoins'](a['gas'],[0x64]),await a['build']();}),it('supports\x20pre-serialized\x20inputs\x20as\x20Uint8Array',async()=>{const a=setup(),b=bcs['U64']['serialize'](0x64n)['toBytes']();a['add'](Commands['SplitCoins'](a['gas'],[a['pure'](b)])),await a['build']();}),it('builds\x20a\x20more\x20complex\x20interaction',async()=>{const a=setup(),b=a['splitCoins'](a['gas'],[0x64]);a['add'](Commands['MergeCoins'](a['gas'],[b,a['object'](Inputs['ObjectRef'](ref()))])),a['add'](Commands['MoveCall']({'target':'0x2::devnet_nft::mint','typeArguments':[],'arguments':[a['pure']['string']('foo'),a['pure']['string']('bar'),a['pure']['string']('baz')]})),await a['build']();}),it('uses\x20a\x20receiving\x20argument',async()=>{const a=setup();a['object'](Inputs['ObjectRef'](ref()));const b=a['splitCoins'](a['gas'],[0x64]);a['add'](Commands['MergeCoins'](a['gas'],[b,a['object'](Inputs['ObjectRef'](ref()))])),a['add'](Commands['MoveCall']({'target':'0x2::devnet_nft::mint','typeArguments':[],'arguments':[a['object'](Inputs['ObjectRef'](ref())),a['object'](Inputs['ReceivingRef'](ref()))]}));const c=await a['build'](),d=Transaction['from'](c),e=await d['build']();expect(c)['toEqual'](e);}),it('builds\x20a\x20more\x20complex\x20interaction',async()=>{const a=setup(),b=a['splitCoins'](a['gas'],[0x64]);a['add'](Commands['MergeCoins'](a['gas'],[b,a['object'](Inputs['ObjectRef'](ref()))])),a['add'](Commands['MoveCall']({'target':'0x2::devnet_nft::mint','typeArguments':[],'arguments':[a['pure']['string']('foo'),a['pure']['string']('bar'),a['pure']['string']('baz')]}));const c=await a['build'](),d=Transaction['from'](c),e=await d['build']();expect(c)['toEqual'](e);});});function ref(){return{'objectId':(Math['random']()*0x186a0)['toFixed'](0x0)['padEnd'](0x40,'0'),'version':String((Math['random']()*0x2710)['toFixed'](0x0)),'digest':toBase58(new Uint8Array([0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x1,0x2]))};}function setup(){const a=new Transaction();return a['setSender']('0x2'),a['setGasPrice'](0x5),a['setGasBudget'](0x64),a['setGasPayment']([ref()]),a;}