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,574 +1 @@
1
- var _a;
2
- import { fromBase64, isSerializedBcs } from "@mysten/bcs";
3
- import { is, parse } from "valibot";
4
- import { normalizeWowAddress } from "../utils/sui-types.js";
5
- import { Commands } from "./Commands.js";
6
- import { ArgumentSchema, NormalizedCallArg, ObjectRefSchema, TransactionExpiration, } from "./data/internal.js";
7
- import { serializeV1TransactionData } from "./data/v1.js";
8
- import { SerializedTransactionDataV2Schema } from "./data/v2.js";
9
- import { Inputs } from "./Inputs.js";
10
- import { needsTransactionResolution, resolveTransactionPlugin, } from "./resolve.js";
11
- import { createObjectMethods } from "./object.js";
12
- import { createPure } from "./pure.js";
13
- import { TransactionDataBuilder } from "./TransactionData.js";
14
- import { getIdFromCallArg } from "./utils.js";
15
- import { namedPackagesPlugin } from "./plugins/NamedPackagesPlugin.js";
16
- function createTransactionResult(index, length = Infinity) {
17
- const baseResult = {
18
- $kind: "Result",
19
- get Result() {
20
- return typeof index === "function" ? index() : index;
21
- },
22
- };
23
- const nestedResults = [];
24
- const nestedResultFor = (resultIndex) => (nestedResults[resultIndex] ??= {
25
- $kind: "NestedResult",
26
- get NestedResult() {
27
- return [
28
- typeof index === "function" ? index() : index,
29
- resultIndex,
30
- ];
31
- },
32
- });
33
- return new Proxy(baseResult, {
34
- set() {
35
- throw new Error("The transaction result is a proxy, and does not support setting properties directly");
36
- },
37
- get(target, property) {
38
- if (property in target) {
39
- return Reflect.get(target, property);
40
- }
41
- if (property === Symbol.iterator) {
42
- return function* () {
43
- let i = 0;
44
- while (i < length) {
45
- yield nestedResultFor(i);
46
- i++;
47
- }
48
- };
49
- }
50
- if (typeof property === "symbol")
51
- return;
52
- const resultIndex = parseInt(property, 10);
53
- if (Number.isNaN(resultIndex) || resultIndex < 0)
54
- return;
55
- return nestedResultFor(resultIndex);
56
- },
57
- });
58
- }
59
- const TRANSACTION_BRAND = Symbol.for("@mysten/transaction");
60
- export function isTransaction(obj) {
61
- return (!!obj &&
62
- typeof obj === "object" &&
63
- obj[TRANSACTION_BRAND] === true);
64
- }
65
- const modulePluginRegistry = {
66
- buildPlugins: new Map(),
67
- serializationPlugins: new Map(),
68
- };
69
- const TRANSACTION_REGISTRY_KEY = Symbol.for("@mysten/transaction/registry");
70
- function getGlobalPluginRegistry() {
71
- try {
72
- const target = globalThis;
73
- if (!target[TRANSACTION_REGISTRY_KEY]) {
74
- target[TRANSACTION_REGISTRY_KEY] = modulePluginRegistry;
75
- }
76
- return target[TRANSACTION_REGISTRY_KEY];
77
- }
78
- catch {
79
- return modulePluginRegistry;
80
- }
81
- }
82
- export class Transaction {
83
- #serializationPlugins;
84
- #buildPlugins;
85
- #intentResolvers = new Map();
86
- #inputSection = [];
87
- #commandSection = [];
88
- #availableResults = new Set();
89
- #pendingPromises = new Set();
90
- #added = new Map();
91
- static fromKind(serialized) {
92
- const tx = new _a();
93
- tx.#data = TransactionDataBuilder.fromKindBytes(typeof serialized === "string"
94
- ? fromBase64(serialized)
95
- : serialized);
96
- tx.#inputSection = tx.#data.inputs.slice();
97
- tx.#commandSection = tx.#data.commands.slice();
98
- tx.#availableResults = new Set(tx.#commandSection.map((_, i) => i));
99
- return tx;
100
- }
101
- static from(transaction) {
102
- const newTransaction = new _a();
103
- if (isTransaction(transaction)) {
104
- newTransaction.#data = TransactionDataBuilder.restore(transaction.getData());
105
- }
106
- else if (typeof transaction !== "string" ||
107
- !transaction.startsWith("{")) {
108
- newTransaction.#data = TransactionDataBuilder.fromBytes(typeof transaction === "string"
109
- ? fromBase64(transaction)
110
- : transaction);
111
- }
112
- else {
113
- newTransaction.#data = TransactionDataBuilder.restore(JSON.parse(transaction));
114
- }
115
- newTransaction.#inputSection = newTransaction.#data.inputs.slice();
116
- newTransaction.#commandSection = newTransaction.#data.commands.slice();
117
- newTransaction.#availableResults = new Set(newTransaction.#commandSection.map((_, i) => i));
118
- return newTransaction;
119
- }
120
- static registerGlobalSerializationPlugin(stepOrStep, step) {
121
- getGlobalPluginRegistry().serializationPlugins.set(stepOrStep, step ?? stepOrStep);
122
- }
123
- static unregisterGlobalSerializationPlugin(name) {
124
- getGlobalPluginRegistry().serializationPlugins.delete(name);
125
- }
126
- static registerGlobalBuildPlugin(stepOrStep, step) {
127
- getGlobalPluginRegistry().buildPlugins.set(stepOrStep, step ?? stepOrStep);
128
- }
129
- static unregisterGlobalBuildPlugin(name) {
130
- getGlobalPluginRegistry().buildPlugins.delete(name);
131
- }
132
- addSerializationPlugin(step) {
133
- this.#serializationPlugins.push(step);
134
- }
135
- addBuildPlugin(step) {
136
- this.#buildPlugins.push(step);
137
- }
138
- addIntentResolver(intent, resolver) {
139
- if (this.#intentResolvers.has(intent) &&
140
- this.#intentResolvers.get(intent) !== resolver) {
141
- throw new Error(`Intent resolver for ${intent} already exists`);
142
- }
143
- this.#intentResolvers.set(intent, resolver);
144
- }
145
- setSender(sender) {
146
- this.#data.sender = sender;
147
- }
148
- setSenderIfNotSet(sender) {
149
- if (!this.#data.sender) {
150
- this.#data.sender = sender;
151
- }
152
- }
153
- setExpiration(expiration) {
154
- this.#data.expiration = expiration
155
- ? parse(TransactionExpiration, expiration)
156
- : null;
157
- }
158
- setGasPrice(price) {
159
- this.#data.gasConfig.price = String(price);
160
- }
161
- setGasBudget(budget) {
162
- this.#data.gasConfig.budget = String(budget);
163
- }
164
- setGasBudgetIfNotSet(budget) {
165
- if (this.#data.gasData.budget == null) {
166
- this.#data.gasConfig.budget = String(budget);
167
- }
168
- }
169
- setGasOwner(owner) {
170
- this.#data.gasConfig.owner = owner;
171
- }
172
- setGasPayment(payments) {
173
- this.#data.gasConfig.payment = payments.map((payment) => parse(ObjectRefSchema, payment));
174
- }
175
- #data;
176
- get blockData() {
177
- return serializeV1TransactionData(this.#data.snapshot());
178
- }
179
- getData() {
180
- return this.#data.snapshot();
181
- }
182
- get [TRANSACTION_BRAND]() {
183
- return true;
184
- }
185
- get pure() {
186
- Object.defineProperty(this, "pure", {
187
- enumerable: false,
188
- value: createPure((value) => {
189
- if (isSerializedBcs(value)) {
190
- return this.#addInput("pure", {
191
- $kind: "Pure",
192
- Pure: {
193
- bytes: value.toBase64(),
194
- },
195
- });
196
- }
197
- return this.#addInput("pure", is(NormalizedCallArg, value)
198
- ? parse(NormalizedCallArg, value)
199
- : value instanceof Uint8Array
200
- ? Inputs.Pure(value)
201
- : {
202
- $kind: "UnresolvedPure",
203
- UnresolvedPure: { value },
204
- });
205
- }),
206
- });
207
- return this.pure;
208
- }
209
- constructor() {
210
- const globalPlugins = getGlobalPluginRegistry();
211
- this.#data = new TransactionDataBuilder();
212
- this.#buildPlugins = [...globalPlugins.buildPlugins.values()];
213
- this.#serializationPlugins = [
214
- ...globalPlugins.serializationPlugins.values(),
215
- ];
216
- }
217
- get gas() {
218
- return { $kind: "GasCoin", GasCoin: true };
219
- }
220
- object = createObjectMethods((value) => {
221
- if (typeof value === "function") {
222
- return this.object(this.add(value));
223
- }
224
- if (typeof value === "object" && is(ArgumentSchema, value)) {
225
- return value;
226
- }
227
- const id = getIdFromCallArg(value);
228
- const inserted = this.#data.inputs.find((i) => id === getIdFromCallArg(i));
229
- if (inserted?.Object?.SharedObject &&
230
- typeof value === "object" &&
231
- value.Object?.SharedObject) {
232
- inserted.Object.SharedObject.mutable =
233
- inserted.Object.SharedObject.mutable ||
234
- value.Object.SharedObject.mutable;
235
- }
236
- return inserted
237
- ? {
238
- $kind: "Input",
239
- Input: this.#data.inputs.indexOf(inserted),
240
- type: "object",
241
- }
242
- : this.#addInput("object", typeof value === "string"
243
- ? {
244
- $kind: "UnresolvedObject",
245
- UnresolvedObject: {
246
- objectId: normalizeWowAddress(value),
247
- },
248
- }
249
- : value);
250
- });
251
- objectRef(...args) {
252
- return this.object(Inputs.ObjectRef(...args));
253
- }
254
- receivingRef(...args) {
255
- return this.object(Inputs.ReceivingRef(...args));
256
- }
257
- sharedObjectRef(...args) {
258
- return this.object(Inputs.SharedObjectRef(...args));
259
- }
260
- #fork() {
261
- const fork = new _a();
262
- fork.#data = this.#data;
263
- fork.#serializationPlugins = this.#serializationPlugins;
264
- fork.#buildPlugins = this.#buildPlugins;
265
- fork.#intentResolvers = this.#intentResolvers;
266
- fork.#pendingPromises = this.#pendingPromises;
267
- fork.#availableResults = new Set(this.#availableResults);
268
- fork.#added = this.#added;
269
- this.#inputSection.push(fork.#inputSection);
270
- this.#commandSection.push(fork.#commandSection);
271
- return fork;
272
- }
273
- add(command) {
274
- if (typeof command === "function") {
275
- if (this.#added.has(command)) {
276
- return this.#added.get(command);
277
- }
278
- const fork = this.#fork();
279
- const result = command(fork);
280
- if (!(result && typeof result === "object" && "then" in result)) {
281
- this.#availableResults = fork.#availableResults;
282
- this.#added.set(command, result);
283
- return result;
284
- }
285
- const placeholder = this.#addCommand({
286
- $kind: "$Intent",
287
- $Intent: {
288
- name: "AsyncTransactionThunk",
289
- inputs: {},
290
- data: {
291
- resultIndex: this.#data.commands.length,
292
- result: null,
293
- },
294
- },
295
- });
296
- this.#pendingPromises.add(Promise.resolve(result).then((result) => {
297
- placeholder.$Intent.data.result = result;
298
- }));
299
- const txResult = createTransactionResult(() => placeholder.$Intent.data.resultIndex);
300
- this.#added.set(command, txResult);
301
- return txResult;
302
- }
303
- else {
304
- this.#addCommand(command);
305
- }
306
- return createTransactionResult(this.#data.commands.length - 1);
307
- }
308
- #addCommand(command) {
309
- const resultIndex = this.#data.commands.length;
310
- this.#commandSection.push(command);
311
- this.#availableResults.add(resultIndex);
312
- this.#data.commands.push(command);
313
- this.#data.mapCommandArguments(resultIndex, (arg) => {
314
- if (arg.$kind === "Result" &&
315
- !this.#availableResults.has(arg.Result)) {
316
- throw new Error(`Result { Result: ${arg.Result} } is not available to use in the current transaction`);
317
- }
318
- if (arg.$kind === "NestedResult" &&
319
- !this.#availableResults.has(arg.NestedResult[0])) {
320
- throw new Error(`Result { NestedResult: [${arg.NestedResult[0]}, ${arg.NestedResult[1]}] } is not available to use in the current transaction`);
321
- }
322
- if (arg.$kind === "Input" &&
323
- arg.Input >= this.#data.inputs.length) {
324
- throw new Error(`Input { Input: ${arg.Input} } references an input that does not exist in the current transaction`);
325
- }
326
- return arg;
327
- });
328
- return command;
329
- }
330
- #addInput(type, input) {
331
- this.#inputSection.push(input);
332
- return this.#data.addInput(type, input);
333
- }
334
- #normalizeTransactionArgument(arg) {
335
- if (isSerializedBcs(arg)) {
336
- return this.pure(arg);
337
- }
338
- return this.#resolveArgument(arg);
339
- }
340
- #resolveArgument(arg) {
341
- if (typeof arg === "function") {
342
- const resolved = this.add(arg);
343
- if (typeof resolved === "function") {
344
- return this.#resolveArgument(resolved);
345
- }
346
- return parse(ArgumentSchema, resolved);
347
- }
348
- return parse(ArgumentSchema, arg);
349
- }
350
- splitCoins(coin, amounts) {
351
- const command = Commands.SplitCoins(typeof coin === "string"
352
- ? this.object(coin)
353
- : this.#resolveArgument(coin), amounts.map((amount) => typeof amount === "number" ||
354
- typeof amount === "bigint" ||
355
- typeof amount === "string"
356
- ? this.pure.u64(amount)
357
- : this.#normalizeTransactionArgument(amount)));
358
- this.#addCommand(command);
359
- return createTransactionResult(this.#data.commands.length - 1, amounts.length);
360
- }
361
- mergeCoins(destination, sources) {
362
- return this.add(Commands.MergeCoins(this.object(destination), sources.map((src) => this.object(src))));
363
- }
364
- publish({ modules, dependencies, }) {
365
- return this.add(Commands.Publish({
366
- modules,
367
- dependencies,
368
- }));
369
- }
370
- upgrade({ modules, dependencies, package: packageId, ticket, }) {
371
- return this.add(Commands.Upgrade({
372
- modules,
373
- dependencies,
374
- package: packageId,
375
- ticket: this.object(ticket),
376
- }));
377
- }
378
- moveCall({ arguments: args, ...input }) {
379
- return this.add(Commands.MoveCall({
380
- ...input,
381
- arguments: args?.map((arg) => this.#normalizeTransactionArgument(arg)),
382
- }));
383
- }
384
- transferObjects(objects, address) {
385
- return this.add(Commands.TransferObjects(objects.map((obj) => this.object(obj)), typeof address === "string"
386
- ? this.pure.address(address)
387
- : this.#normalizeTransactionArgument(address)));
388
- }
389
- makeMoveVec({ type, elements, }) {
390
- return this.add(Commands.MakeMoveVec({
391
- type,
392
- elements: elements.map((obj) => this.object(obj)),
393
- }));
394
- }
395
- serialize() {
396
- return JSON.stringify(serializeV1TransactionData(this.#data.snapshot()));
397
- }
398
- async toJSON(options = {}) {
399
- await this.prepareForSerialization(options);
400
- const fullyResolved = this.isFullyResolved();
401
- return JSON.stringify(parse(SerializedTransactionDataV2Schema, fullyResolved
402
- ? {
403
- ...this.#data.snapshot(),
404
- digest: this.#data.getDigest(),
405
- }
406
- : this.#data.snapshot()), (_key, value) => typeof value === "bigint" ? value.toString() : value, 2);
407
- }
408
- async sign(options) {
409
- const { signer, ...buildOptions } = options;
410
- const bytes = await this.build(buildOptions);
411
- return signer.signTransaction(bytes);
412
- }
413
- isFullyResolved() {
414
- if (!this.#data.sender) {
415
- return false;
416
- }
417
- if (this.#pendingPromises.size > 0) {
418
- return false;
419
- }
420
- if (this.#data.commands.some((cmd) => cmd.$Intent)) {
421
- return false;
422
- }
423
- if (needsTransactionResolution(this.#data, {})) {
424
- return false;
425
- }
426
- return true;
427
- }
428
- async build(options = {}) {
429
- await this.prepareForSerialization(options);
430
- await this.#prepareBuild(options);
431
- return this.#data.build({
432
- onlyTransactionKind: options.onlyTransactionKind,
433
- });
434
- }
435
- async getDigest(options = {}) {
436
- await this.prepareForSerialization(options);
437
- await this.#prepareBuild(options);
438
- return this.#data.getDigest();
439
- }
440
- async #prepareBuild(options) {
441
- if (!options.onlyTransactionKind && !this.#data.sender) {
442
- throw new Error("Missing transaction sender");
443
- }
444
- await this.#runPlugins([...this.#buildPlugins, resolveTransactionPlugin], options);
445
- }
446
- async #runPlugins(plugins, options) {
447
- try {
448
- const createNext = (i) => {
449
- if (i >= plugins.length) {
450
- return () => { };
451
- }
452
- const plugin = plugins[i];
453
- return async () => {
454
- const next = createNext(i + 1);
455
- let calledNext = false;
456
- let nextResolved = false;
457
- await plugin(this.#data, options, async () => {
458
- if (calledNext) {
459
- throw new Error(`next() was call multiple times in TransactionPlugin ${i}`);
460
- }
461
- calledNext = true;
462
- await next();
463
- nextResolved = true;
464
- });
465
- if (!calledNext) {
466
- throw new Error(`next() was not called in TransactionPlugin ${i}`);
467
- }
468
- if (!nextResolved) {
469
- throw new Error(`next() was not awaited in TransactionPlugin ${i}`);
470
- }
471
- };
472
- };
473
- await createNext(0)();
474
- }
475
- finally {
476
- this.#inputSection = this.#data.inputs.slice();
477
- this.#commandSection = this.#data.commands.slice();
478
- this.#availableResults = new Set(this.#commandSection.map((_, i) => i));
479
- }
480
- }
481
- async #waitForPendingTasks() {
482
- while (this.#pendingPromises.size > 0) {
483
- const newPromise = Promise.all(this.#pendingPromises);
484
- this.#pendingPromises.clear();
485
- this.#pendingPromises.add(newPromise);
486
- await newPromise;
487
- this.#pendingPromises.delete(newPromise);
488
- }
489
- }
490
- #sortCommandsAndInputs() {
491
- const unorderedCommands = this.#data.commands;
492
- const unorderedInputs = this.#data.inputs;
493
- const orderedCommands = this.#commandSection.flat(Infinity);
494
- const orderedInputs = this.#inputSection.flat(Infinity);
495
- if (orderedCommands.length !== unorderedCommands.length) {
496
- throw new Error("Unexpected number of commands found in transaction data");
497
- }
498
- if (orderedInputs.length !== unorderedInputs.length) {
499
- throw new Error("Unexpected number of inputs found in transaction data");
500
- }
501
- const filteredCommands = orderedCommands.filter((cmd) => cmd.$Intent?.name !== "AsyncTransactionThunk");
502
- this.#data.commands = filteredCommands;
503
- this.#data.inputs = orderedInputs;
504
- this.#commandSection = filteredCommands;
505
- this.#inputSection = orderedInputs;
506
- this.#availableResults = new Set(filteredCommands.map((_, i) => i));
507
- function getOriginalIndex(index) {
508
- const command = unorderedCommands[index];
509
- if (command.$Intent?.name === "AsyncTransactionThunk") {
510
- const result = command.$Intent.data
511
- .result;
512
- if (result == null) {
513
- throw new Error("AsyncTransactionThunk has not been resolved");
514
- }
515
- return getOriginalIndex(result.Result);
516
- }
517
- const updated = filteredCommands.indexOf(command);
518
- if (updated === -1) {
519
- throw new Error("Unable to find original index for command");
520
- }
521
- return updated;
522
- }
523
- this.#data.mapArguments((arg) => {
524
- if (arg.$kind === "Input") {
525
- const updated = orderedInputs.indexOf(unorderedInputs[arg.Input]);
526
- if (updated === -1) {
527
- throw new Error("Input has not been resolved");
528
- }
529
- return { ...arg, Input: updated };
530
- }
531
- else if (arg.$kind === "Result") {
532
- const updated = getOriginalIndex(arg.Result);
533
- return { ...arg, Result: updated };
534
- }
535
- else if (arg.$kind === "NestedResult") {
536
- const updated = getOriginalIndex(arg.NestedResult[0]);
537
- return { ...arg, NestedResult: [updated, arg.NestedResult[1]] };
538
- }
539
- return arg;
540
- });
541
- for (const [i, cmd] of unorderedCommands.entries()) {
542
- if (cmd.$Intent?.name === "AsyncTransactionThunk") {
543
- try {
544
- cmd.$Intent.data.resultIndex = getOriginalIndex(i);
545
- }
546
- catch {
547
- }
548
- }
549
- }
550
- }
551
- async prepareForSerialization(options) {
552
- await this.#waitForPendingTasks();
553
- this.#sortCommandsAndInputs();
554
- const intents = new Set();
555
- for (const command of this.#data.commands) {
556
- if (command.$Intent) {
557
- intents.add(command.$Intent.name);
558
- }
559
- }
560
- const steps = [...this.#serializationPlugins];
561
- for (const intent of intents) {
562
- if (options.supportedIntents?.includes(intent)) {
563
- continue;
564
- }
565
- if (!this.#intentResolvers.has(intent)) {
566
- throw new Error(`Missing intent resolver for ${intent}`);
567
- }
568
- steps.push(this.#intentResolvers.get(intent));
569
- }
570
- steps.push(namedPackagesPlugin());
571
- await this.#runPlugins(steps, options);
572
- }
573
- }
574
- _a = Transaction;
1
+ var _a;import{fromBase64,isSerializedBcs}from'@mysten/bcs';import{is,parse}from'valibot';import{normalizeWowAddress}from'../utils/sui-types.js';import{Commands}from'./Commands.js';import{ArgumentSchema,NormalizedCallArg,ObjectRefSchema,TransactionExpiration}from'./data/internal.js';import{serializeV1TransactionData}from'./data/v1.js';import{SerializedTransactionDataV2Schema}from'./data/v2.js';import{Inputs}from'./Inputs.js';import{needsTransactionResolution,resolveTransactionPlugin}from'./resolve.js';import{createObjectMethods}from'./object.js';import{createPure}from'./pure.js';import{TransactionDataBuilder}from'./TransactionData.js';import{getIdFromCallArg}from'./utils.js';import{namedPackagesPlugin}from'./plugins/NamedPackagesPlugin.js';function createTransactionResult(a,b=Infinity){const c={'$kind':'Result',get 'Result'(){return typeof a==='function'?a():a;}},d=[],e=f=>d[f]??={'$kind':'NestedResult',get 'NestedResult'(){return[typeof a==='function'?a():a,f];}};return new Proxy(c,{'set'(){throw new Error('The\x20transaction\x20result\x20is\x20a\x20proxy,\x20and\x20does\x20not\x20support\x20setting\x20properties\x20directly');},'get'(f,g){if(g in f)return Reflect['get'](f,g);if(g===Symbol['iterator'])return function*(){let j=0x0;while(j<b){yield e(j),j++;}};if(typeof g==='symbol')return;const h=parseInt(g,0xa);if(Number['isNaN'](h)||h<0x0)return;return e(h);}});}const TRANSACTION_BRAND=Symbol['for']('@mysten/transaction');export function isTransaction(a){return!!a&&typeof a==='object'&&a[TRANSACTION_BRAND]===!![];}const modulePluginRegistry={'buildPlugins':new Map(),'serializationPlugins':new Map()},TRANSACTION_REGISTRY_KEY=Symbol['for']('@mysten/transaction/registry');function getGlobalPluginRegistry(){try{const a=globalThis;return!a[TRANSACTION_REGISTRY_KEY]&&(a[TRANSACTION_REGISTRY_KEY]=modulePluginRegistry),a[TRANSACTION_REGISTRY_KEY];}catch{return modulePluginRegistry;}}export class Transaction{#serializationPlugins;#buildPlugins;#intentResolvers=new Map();#inputSection=[];#commandSection=[];#availableResults=new Set();#pendingPromises=new Set();#added=new Map();static['fromKind'](a){const b=new _a();return b.#data=TransactionDataBuilder['fromKindBytes'](typeof a==='string'?fromBase64(a):a),b.#inputSection=b.#data['inputs']['slice'](),b.#commandSection=b.#data['commands']['slice'](),b.#availableResults=new Set(b.#commandSection['map']((c,d)=>d)),b;}static['from'](a){const b=new _a();if(isTransaction(a))b.#data=TransactionDataBuilder['restore'](a['getData']());else typeof a!=='string'||!a['startsWith']('{')?b.#data=TransactionDataBuilder['fromBytes'](typeof a==='string'?fromBase64(a):a):b.#data=TransactionDataBuilder['restore'](JSON['parse'](a));return b.#inputSection=b.#data['inputs']['slice'](),b.#commandSection=b.#data['commands']['slice'](),b.#availableResults=new Set(b.#commandSection['map']((c,d)=>d)),b;}static['registerGlobalSerializationPlugin'](a,b){getGlobalPluginRegistry()['serializationPlugins']['set'](a,b??a);}static['unregisterGlobalSerializationPlugin'](a){getGlobalPluginRegistry()['serializationPlugins']['delete'](a);}static['registerGlobalBuildPlugin'](a,b){getGlobalPluginRegistry()['buildPlugins']['set'](a,b??a);}static['unregisterGlobalBuildPlugin'](a){getGlobalPluginRegistry()['buildPlugins']['delete'](a);}['addSerializationPlugin'](a){this.#serializationPlugins['push'](a);}['addBuildPlugin'](a){this.#buildPlugins['push'](a);}['addIntentResolver'](a,b){if(this.#intentResolvers['has'](a)&&this.#intentResolvers['get'](a)!==b)throw new Error('Intent\x20resolver\x20for\x20'+a+'\x20already\x20exists');this.#intentResolvers['set'](a,b);}['setSender'](a){this.#data['sender']=a;}['setSenderIfNotSet'](a){!this.#data['sender']&&(this.#data['sender']=a);}['setExpiration'](a){this.#data['expiration']=a?parse(TransactionExpiration,a):null;}['setGasPrice'](a){this.#data['gasConfig']['price']=String(a);}['setGasBudget'](a){this.#data['gasConfig']['budget']=String(a);}['setGasBudgetIfNotSet'](a){this.#data['gasData']['budget']==null&&(this.#data['gasConfig']['budget']=String(a));}['setGasOwner'](a){this.#data['gasConfig']['owner']=a;}['setGasPayment'](a){this.#data['gasConfig']['payment']=a['map'](b=>parse(ObjectRefSchema,b));}#data;get['blockData'](){return serializeV1TransactionData(this.#data['snapshot']());}['getData'](){return this.#data['snapshot']();}get[TRANSACTION_BRAND](){return!![];}get['pure'](){return Object['defineProperty'](this,'pure',{'enumerable':![],'value':createPure(a=>{if(isSerializedBcs(a))return this.#addInput('pure',{'$kind':'Pure','Pure':{'bytes':a['toBase64']()}});return this.#addInput('pure',is(NormalizedCallArg,a)?parse(NormalizedCallArg,a):a instanceof Uint8Array?Inputs['Pure'](a):{'$kind':'UnresolvedPure','UnresolvedPure':{'value':a}});})}),this['pure'];}constructor(){const a=getGlobalPluginRegistry();this.#data=new TransactionDataBuilder(),this.#buildPlugins=[...a['buildPlugins']['values']()],this.#serializationPlugins=[...a['serializationPlugins']['values']()];}get['gas'](){return{'$kind':'GasCoin','GasCoin':!![]};}['object']=createObjectMethods(value=>{if(typeof value==='function')return this['object'](this['add'](value));if(typeof value==='object'&&is(ArgumentSchema,value))return value;const id=getIdFromCallArg(value),inserted=this.#data['inputs']['find'](i=>id===getIdFromCallArg(i));return inserted?.['Object']?.['SharedObject']&&typeof value==='object'&&value['Object']?.['SharedObject']&&(inserted['Object']['SharedObject']['mutable']=inserted['Object']['SharedObject']['mutable']||value['Object']['SharedObject']['mutable']),inserted?{'$kind':'Input','Input':this.#data['inputs']['indexOf'](inserted),'type':'object'}:this.#addInput('object',typeof value==='string'?{'$kind':'UnresolvedObject','UnresolvedObject':{'objectId':normalizeWowAddress(value)}}:value);});['objectRef'](...a){return this['object'](Inputs['ObjectRef'](...a));}['receivingRef'](...a){return this['object'](Inputs['ReceivingRef'](...a));}['sharedObjectRef'](...a){return this['object'](Inputs['SharedObjectRef'](...a));}#fork(){const a=new _a();return a.#data=this.#data,a.#serializationPlugins=this.#serializationPlugins,a.#buildPlugins=this.#buildPlugins,a.#intentResolvers=this.#intentResolvers,a.#pendingPromises=this.#pendingPromises,a.#availableResults=new Set(this.#availableResults),a.#added=this.#added,this.#inputSection['push'](a.#inputSection),this.#commandSection['push'](a.#commandSection),a;}['add'](a){if(typeof a==='function'){if(this.#added['has'](a))return this.#added['get'](a);const b=this.#fork(),c=a(b);if(!(c&&typeof c==='object'&&'then'in c))return this.#availableResults=b.#availableResults,this.#added['set'](a,c),c;const d=this.#addCommand({'$kind':'$Intent','$Intent':{'name':'AsyncTransactionThunk','inputs':{},'data':{'resultIndex':this.#data['commands']['length'],'result':null}}});this.#pendingPromises['add'](Promise['resolve'](c)['then'](f=>{d['$Intent']['data']['result']=f;}));const e=createTransactionResult(()=>d['$Intent']['data']['resultIndex']);return this.#added['set'](a,e),e;}else this.#addCommand(a);return createTransactionResult(this.#data['commands']['length']-0x1);}#addCommand(a){const b=this.#data['commands']['length'];return this.#commandSection['push'](a),this.#availableResults['add'](b),this.#data['commands']['push'](a),this.#data['mapCommandArguments'](b,c=>{if(c['$kind']==='Result'&&!this.#availableResults['has'](c['Result']))throw new Error('Result\x20{\x20Result:\x20'+c['Result']+'\x20}\x20is\x20not\x20available\x20to\x20use\x20in\x20the\x20current\x20transaction');if(c['$kind']==='NestedResult'&&!this.#availableResults['has'](c['NestedResult'][0x0]))throw new Error('Result\x20{\x20NestedResult:\x20['+c['NestedResult'][0x0]+',\x20'+c['NestedResult'][0x1]+']\x20}\x20is\x20not\x20available\x20to\x20use\x20in\x20the\x20current\x20transaction');if(c['$kind']==='Input'&&c['Input']>=this.#data['inputs']['length'])throw new Error('Input\x20{\x20Input:\x20'+c['Input']+'\x20}\x20references\x20an\x20input\x20that\x20does\x20not\x20exist\x20in\x20the\x20current\x20transaction');return c;}),a;}#addInput(a,b){return this.#inputSection['push'](b),this.#data['addInput'](a,b);}#normalizeTransactionArgument(a){if(isSerializedBcs(a))return this['pure'](a);return this.#resolveArgument(a);}#resolveArgument(a){if(typeof a==='function'){const b=this['add'](a);if(typeof b==='function')return this.#resolveArgument(b);return parse(ArgumentSchema,b);}return parse(ArgumentSchema,a);}['splitCoins'](a,b){const c=Commands['SplitCoins'](typeof a==='string'?this['object'](a):this.#resolveArgument(a),b['map'](d=>typeof d==='number'||typeof d==='bigint'||typeof d==='string'?this['pure']['u64'](d):this.#normalizeTransactionArgument(d)));return this.#addCommand(c),createTransactionResult(this.#data['commands']['length']-0x1,b['length']);}['mergeCoins'](a,b){return this['add'](Commands['MergeCoins'](this['object'](a),b['map'](c=>this['object'](c))));}['publish']({modules:a,dependencies:b}){return this['add'](Commands['Publish']({'modules':a,'dependencies':b}));}['upgrade']({modules:a,dependencies:b,package:c,ticket:d}){return this['add'](Commands['Upgrade']({'modules':a,'dependencies':b,'package':c,'ticket':this['object'](d)}));}['moveCall']({arguments:a,...b}){return this['add'](Commands['MoveCall']({...b,'arguments':a?.['map'](c=>this.#normalizeTransactionArgument(c))}));}['transferObjects'](a,b){return this['add'](Commands['TransferObjects'](a['map'](c=>this['object'](c)),typeof b==='string'?this['pure']['address'](b):this.#normalizeTransactionArgument(b)));}['makeMoveVec']({type:a,elements:b}){return this['add'](Commands['MakeMoveVec']({'type':a,'elements':b['map'](c=>this['object'](c))}));}['serialize'](){return JSON['stringify'](serializeV1TransactionData(this.#data['snapshot']()));}async['toJSON'](a={}){await this['prepareForSerialization'](a);const b=this['isFullyResolved']();return JSON['stringify'](parse(SerializedTransactionDataV2Schema,b?{...this.#data['snapshot'](),'digest':this.#data['getDigest']()}:this.#data['snapshot']()),(c,d)=>typeof d==='bigint'?d['toString']():d,0x2);}async['sign'](a){const {signer:b,...c}=a,d=await this['build'](c);return b['signTransaction'](d);}['isFullyResolved'](){if(!this.#data['sender'])return![];if(this.#pendingPromises['size']>0x0)return![];if(this.#data['commands']['some'](a=>a['$Intent']))return![];if(needsTransactionResolution(this.#data,{}))return![];return!![];}async['build'](a={}){return await this['prepareForSerialization'](a),await this.#prepareBuild(a),this.#data['build']({'onlyTransactionKind':a['onlyTransactionKind']});}async['getDigest'](a={}){return await this['prepareForSerialization'](a),await this.#prepareBuild(a),this.#data['getDigest']();}async #prepareBuild(a){if(!a['onlyTransactionKind']&&!this.#data['sender'])throw new Error('Missing\x20transaction\x20sender');await this.#runPlugins([...this.#buildPlugins,resolveTransactionPlugin],a);}async #runPlugins(a,b){try{const c=d=>{if(d>=a['length'])return()=>{};const e=a[d];return async()=>{const f=c(d+0x1);let g=![],h=![];await e(this.#data,b,async()=>{if(g)throw new Error('next()\x20was\x20call\x20multiple\x20times\x20in\x20TransactionPlugin\x20'+d);g=!![],await f(),h=!![];});if(!g)throw new Error('next()\x20was\x20not\x20called\x20in\x20TransactionPlugin\x20'+d);if(!h)throw new Error('next()\x20was\x20not\x20awaited\x20in\x20TransactionPlugin\x20'+d);};};await c(0x0)();}finally{this.#inputSection=this.#data['inputs']['slice'](),this.#commandSection=this.#data['commands']['slice'](),this.#availableResults=new Set(this.#commandSection['map']((d,e)=>e));}}async #waitForPendingTasks(){while(this.#pendingPromises['size']>0x0){const a=Promise['all'](this.#pendingPromises);this.#pendingPromises['clear'](),this.#pendingPromises['add'](a),await a,this.#pendingPromises['delete'](a);}}#sortCommandsAndInputs(){const a=this.#data['commands'],b=this.#data['inputs'],c=this.#commandSection['flat'](Infinity),d=this.#inputSection['flat'](Infinity);if(c['length']!==a['length'])throw new Error('Unexpected\x20number\x20of\x20commands\x20found\x20in\x20transaction\x20data');if(d['length']!==b['length'])throw new Error('Unexpected\x20number\x20of\x20inputs\x20found\x20in\x20transaction\x20data');const e=c['filter'](g=>g['$Intent']?.['name']!=='AsyncTransactionThunk');this.#data['commands']=e,this.#data['inputs']=d,this.#commandSection=e,this.#inputSection=d,this.#availableResults=new Set(e['map']((g,h)=>h));function f(g){const h=a[g];if(h['$Intent']?.['name']==='AsyncTransactionThunk'){const k=h['$Intent']['data']['result'];if(k==null)throw new Error('AsyncTransactionThunk\x20has\x20not\x20been\x20resolved');return f(k['Result']);}const j=e['indexOf'](h);if(j===-0x1)throw new Error('Unable\x20to\x20find\x20original\x20index\x20for\x20command');return j;}this.#data['mapArguments'](g=>{if(g['$kind']==='Input'){const h=d['indexOf'](b[g['Input']]);if(h===-0x1)throw new Error('Input\x20has\x20not\x20been\x20resolved');return{...g,'Input':h};}else{if(g['$kind']==='Result'){const j=f(g['Result']);return{...g,'Result':j};}else{if(g['$kind']==='NestedResult'){const k=f(g['NestedResult'][0x0]);return{...g,'NestedResult':[k,g['NestedResult'][0x1]]};}}}return g;});for(const [g,h]of a['entries']()){if(h['$Intent']?.['name']==='AsyncTransactionThunk')try{h['$Intent']['data']['resultIndex']=f(g);}catch{}}}async['prepareForSerialization'](a){await this.#waitForPendingTasks(),this.#sortCommandsAndInputs();const b=new Set();for(const d of this.#data['commands']){d['$Intent']&&b['add'](d['$Intent']['name']);}const c=[...this.#serializationPlugins];for(const e of b){if(a['supportedIntents']?.['includes'](e))continue;if(!this.#intentResolvers['has'](e))throw new Error('Missing\x20intent\x20resolver\x20for\x20'+e);c['push'](this.#intentResolvers['get'](e));}c['push'](namedPackagesPlugin()),await this.#runPlugins(c,a);}}_a=Transaction;