@mysten/sui 2.39.1 → 3.0.1

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 (425) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/README.md +5 -188
  3. package/dist/bcs/bcs.d.mts +6 -6
  4. package/dist/bcs/bcs.d.mts.map +1 -1
  5. package/dist/bcs/bcs.mjs +49 -22
  6. package/dist/bcs/bcs.mjs.map +1 -1
  7. package/dist/bcs/effects.mjs +49 -20
  8. package/dist/bcs/effects.mjs.map +1 -1
  9. package/dist/bcs/index.d.mts +1441 -624
  10. package/dist/bcs/index.d.mts.map +1 -1
  11. package/dist/bcs/index.mjs +2 -1
  12. package/dist/bcs/index.mjs.map +1 -1
  13. package/dist/bcs/transactions.d.mts +1059 -0
  14. package/dist/bcs/transactions.d.mts.map +1 -0
  15. package/dist/bcs/transactions.mjs +33 -14
  16. package/dist/bcs/transactions.mjs.map +1 -1
  17. package/dist/bcs/types.d.mts +6 -1
  18. package/dist/bcs/types.d.mts.map +1 -1
  19. package/dist/client/core-resolver.mjs +4 -4
  20. package/dist/client/core-resolver.mjs.map +1 -1
  21. package/dist/client/core.d.mts +55 -4
  22. package/dist/client/core.d.mts.map +1 -1
  23. package/dist/client/core.mjs +98 -1
  24. package/dist/client/core.mjs.map +1 -1
  25. package/dist/client/errors.mjs +11 -1
  26. package/dist/client/errors.mjs.map +1 -1
  27. package/dist/client/index.d.mts +5 -3
  28. package/dist/client/index.mjs +6 -3
  29. package/dist/client/mvr.d.mts +12 -2
  30. package/dist/client/mvr.d.mts.map +1 -1
  31. package/dist/client/mvr.mjs +34 -13
  32. package/dist/client/mvr.mjs.map +1 -1
  33. package/dist/client/query-filters.mjs +80 -76
  34. package/dist/client/query-filters.mjs.map +1 -1
  35. package/dist/client/stream/adapter.d.mts +102 -0
  36. package/dist/client/stream/adapter.d.mts.map +1 -0
  37. package/dist/client/stream/errors.d.mts +14 -0
  38. package/dist/client/stream/errors.d.mts.map +1 -0
  39. package/dist/client/stream/errors.mjs +25 -0
  40. package/dist/client/stream/errors.mjs.map +1 -0
  41. package/dist/client/stream/filter.mjs +18 -0
  42. package/dist/client/stream/filter.mjs.map +1 -0
  43. package/dist/client/stream/follow.mjs +48 -0
  44. package/dist/client/stream/follow.mjs.map +1 -0
  45. package/dist/client/stream/index.d.mts +4 -0
  46. package/dist/client/stream/pager.mjs +123 -0
  47. package/dist/client/stream/pager.mjs.map +1 -0
  48. package/dist/client/stream/plan.mjs +79 -0
  49. package/dist/client/stream/plan.mjs.map +1 -0
  50. package/dist/client/stream/position.d.mts +30 -0
  51. package/dist/client/stream/position.d.mts.map +1 -0
  52. package/dist/client/stream/position.mjs +121 -0
  53. package/dist/client/stream/position.mjs.map +1 -0
  54. package/dist/client/stream/run.d.mts +2 -0
  55. package/dist/client/stream/run.mjs +99 -0
  56. package/dist/client/stream/run.mjs.map +1 -0
  57. package/dist/client/stream/session.mjs +205 -0
  58. package/dist/client/stream/session.mjs.map +1 -0
  59. package/dist/client/stream/status.mjs +47 -0
  60. package/dist/client/stream/status.mjs.map +1 -0
  61. package/dist/client/stream/token.mjs +80 -0
  62. package/dist/client/stream/token.mjs.map +1 -0
  63. package/dist/client/transaction-data.d.mts +17 -0
  64. package/dist/client/transaction-data.d.mts.map +1 -0
  65. package/dist/client/transaction-data.mjs +472 -0
  66. package/dist/client/transaction-data.mjs.map +1 -0
  67. package/dist/client/transaction-resolver.mjs +102 -58
  68. package/dist/client/transaction-resolver.mjs.map +1 -1
  69. package/dist/client/types.d.mts +560 -240
  70. package/dist/client/types.d.mts.map +1 -1
  71. package/dist/client/utils.d.mts +2 -2
  72. package/dist/client/utils.d.mts.map +1 -1
  73. package/dist/client/utils.mjs +91 -30
  74. package/dist/client/utils.mjs.map +1 -1
  75. package/dist/cryptography/index.d.mts +1 -1
  76. package/dist/cryptography/keypair.d.mts +1 -1
  77. package/dist/cryptography/publickey.d.mts +11 -0
  78. package/dist/cryptography/publickey.d.mts.map +1 -1
  79. package/dist/cryptography/publickey.mjs +12 -1
  80. package/dist/cryptography/publickey.mjs.map +1 -1
  81. package/dist/cryptography/signature.d.mts +8 -8
  82. package/dist/cryptography/signature.mjs +18 -7
  83. package/dist/cryptography/signature.mjs.map +1 -1
  84. package/dist/graphql/client.d.mts +51 -35
  85. package/dist/graphql/client.d.mts.map +1 -1
  86. package/dist/graphql/client.mjs +125 -69
  87. package/dist/graphql/client.mjs.map +1 -1
  88. package/dist/graphql/core.d.mts +14 -9
  89. package/dist/graphql/core.d.mts.map +1 -1
  90. package/dist/graphql/core.mjs +294 -118
  91. package/dist/graphql/core.mjs.map +1 -1
  92. package/dist/graphql/errors.d.mts +20 -0
  93. package/dist/graphql/errors.d.mts.map +1 -0
  94. package/dist/graphql/errors.mjs +19 -0
  95. package/dist/graphql/errors.mjs.map +1 -0
  96. package/dist/graphql/filters.mjs +32 -0
  97. package/dist/graphql/filters.mjs.map +1 -0
  98. package/dist/graphql/generated/queries.d.mts.map +1 -1
  99. package/dist/graphql/generated/queries.mjs +1216 -208
  100. package/dist/graphql/generated/queries.mjs.map +1 -1
  101. package/dist/graphql/generated/tada-env.d.mts +820 -11
  102. package/dist/graphql/index.d.mts +2 -1
  103. package/dist/graphql/index.mjs +2 -1
  104. package/dist/graphql/sse-parser.mjs +82 -0
  105. package/dist/graphql/sse-parser.mjs.map +1 -0
  106. package/dist/graphql/stream/families.mjs +306 -0
  107. package/dist/graphql/stream/families.mjs.map +1 -0
  108. package/dist/graphql/stream/index.mjs +38 -0
  109. package/dist/graphql/stream/index.mjs.map +1 -0
  110. package/dist/graphql/stream/live.mjs +60 -0
  111. package/dist/graphql/stream/live.mjs.map +1 -0
  112. package/dist/graphql/stream/page.mjs +38 -0
  113. package/dist/graphql/stream/page.mjs.map +1 -0
  114. package/dist/graphql/stream/query.mjs +47 -0
  115. package/dist/graphql/stream/query.mjs.map +1 -0
  116. package/dist/graphql/subscribe.mjs +70 -0
  117. package/dist/graphql/subscribe.mjs.map +1 -0
  118. package/dist/grpc/client.d.mts +31 -27
  119. package/dist/grpc/client.d.mts.map +1 -1
  120. package/dist/grpc/client.mjs +42 -46
  121. package/dist/grpc/client.mjs.map +1 -1
  122. package/dist/grpc/core.d.mts +13 -6
  123. package/dist/grpc/core.d.mts.map +1 -1
  124. package/dist/grpc/core.mjs +254 -166
  125. package/dist/grpc/core.mjs.map +1 -1
  126. package/dist/grpc/filters.mjs +44 -34
  127. package/dist/grpc/filters.mjs.map +1 -1
  128. package/dist/grpc/grpc-web-pull.mjs +245 -0
  129. package/dist/grpc/grpc-web-pull.mjs.map +1 -0
  130. package/dist/grpc/index.d.mts +2 -1
  131. package/dist/grpc/index.mjs +1 -1
  132. package/dist/grpc/network-error.mjs +31 -0
  133. package/dist/grpc/network-error.mjs.map +1 -0
  134. package/dist/grpc/proto/google/rpc/error_details.mjs +306 -0
  135. package/dist/grpc/proto/google/rpc/error_details.mjs.map +1 -0
  136. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  137. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +176 -1
  138. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
  139. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
  140. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
  141. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
  142. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  143. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
  144. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
  145. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
  146. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  147. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  148. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
  149. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
  150. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
  151. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
  152. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  153. package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
  154. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
  155. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
  156. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
  157. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
  158. package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
  159. package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
  160. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
  161. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
  162. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
  163. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
  164. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  165. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
  166. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
  167. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
  168. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
  169. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  170. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +20 -14
  171. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
  172. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
  173. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
  174. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
  175. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  176. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
  177. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
  178. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
  179. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  180. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  181. package/dist/grpc/proto/types.d.mts +7 -7
  182. package/dist/grpc/proto/types.mjs +3 -2
  183. package/dist/grpc/pull-call.d.mts +20 -0
  184. package/dist/grpc/pull-call.d.mts.map +1 -0
  185. package/dist/grpc/pull-call.mjs +28 -0
  186. package/dist/grpc/pull-call.mjs.map +1 -0
  187. package/dist/grpc/stream/call.mjs +238 -0
  188. package/dist/grpc/stream/call.mjs.map +1 -0
  189. package/dist/grpc/stream/families.d.mts +26 -0
  190. package/dist/grpc/stream/families.d.mts.map +1 -0
  191. package/dist/grpc/stream/families.mjs +145 -0
  192. package/dist/grpc/stream/families.mjs.map +1 -0
  193. package/dist/grpc/stream/index.d.mts +41 -0
  194. package/dist/grpc/stream/index.d.mts.map +1 -0
  195. package/dist/grpc/stream/index.mjs +127 -0
  196. package/dist/grpc/stream/index.mjs.map +1 -0
  197. package/dist/grpc/stream/live.mjs +31 -0
  198. package/dist/grpc/stream/live.mjs.map +1 -0
  199. package/dist/grpc/stream/page.mjs +120 -0
  200. package/dist/grpc/stream/page.mjs.map +1 -0
  201. package/dist/grpc/stream-types.d.mts +28 -0
  202. package/dist/grpc/stream-types.d.mts.map +1 -0
  203. package/dist/grpc/transport.d.mts +8 -3
  204. package/dist/grpc/transport.d.mts.map +1 -1
  205. package/dist/grpc/transport.mjs +88 -45
  206. package/dist/grpc/transport.mjs.map +1 -1
  207. package/dist/jsonRpc/index.d.mts +34 -12
  208. package/dist/jsonRpc/index.d.mts.map +1 -0
  209. package/dist/jsonRpc/index.mjs +39 -5
  210. package/dist/jsonRpc/index.mjs.map +1 -0
  211. package/dist/jsonRpc/types.d.mts +420 -0
  212. package/dist/jsonRpc/types.d.mts.map +1 -0
  213. package/dist/keypairs/passkey/keypair.d.mts +1 -1
  214. package/dist/multisig/publickey.d.mts +12 -4
  215. package/dist/multisig/publickey.d.mts.map +1 -1
  216. package/dist/multisig/publickey.mjs +5 -5
  217. package/dist/multisig/publickey.mjs.map +1 -1
  218. package/dist/multisig/signer.d.mts +1 -1
  219. package/dist/transactions/ObjectCache.d.mts +1 -1
  220. package/dist/transactions/ObjectCache.mjs +5 -5
  221. package/dist/transactions/ObjectCache.mjs.map +1 -1
  222. package/dist/transactions/Transaction.d.mts +10 -9
  223. package/dist/transactions/Transaction.d.mts.map +1 -1
  224. package/dist/transactions/Transaction.mjs +17 -6
  225. package/dist/transactions/Transaction.mjs.map +1 -1
  226. package/dist/transactions/data/internal.d.mts +2 -0
  227. package/dist/transactions/data/internal.d.mts.map +1 -1
  228. package/dist/transactions/data/internal.mjs +2 -1
  229. package/dist/transactions/data/internal.mjs.map +1 -1
  230. package/dist/transactions/executor/parallel.d.mts +2 -2
  231. package/dist/transactions/executor/serial.d.mts +1 -1
  232. package/dist/transactions/executor/serial.mjs +2 -2
  233. package/dist/transactions/executor/serial.mjs.map +1 -1
  234. package/dist/transactions/index.d.mts +3 -2
  235. package/dist/transactions/index.mjs +4 -3
  236. package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
  237. package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
  238. package/dist/transactions/resolve.d.mts +6 -0
  239. package/dist/transactions/resolve.d.mts.map +1 -1
  240. package/dist/transactions/resolve.mjs.map +1 -1
  241. package/dist/transactions/restricted-move-calls.d.mts +25 -0
  242. package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
  243. package/dist/transactions/restricted-move-calls.mjs +47 -0
  244. package/dist/transactions/restricted-move-calls.mjs.map +1 -0
  245. package/dist/transactions/serializer.d.mts +1 -4
  246. package/dist/transactions/serializer.d.mts.map +1 -1
  247. package/dist/transactions/serializer.mjs +1 -44
  248. package/dist/transactions/serializer.mjs.map +1 -1
  249. package/dist/transactions/utils.d.mts +0 -1
  250. package/dist/transactions/utils.d.mts.map +1 -1
  251. package/dist/transactions/utils.mjs.map +1 -1
  252. package/dist/utils/abort.mjs +89 -0
  253. package/dist/utils/abort.mjs.map +1 -0
  254. package/dist/utils/coin-reservation.mjs +1 -4
  255. package/dist/utils/coin-reservation.mjs.map +1 -1
  256. package/dist/utils/index.mjs +1 -1
  257. package/dist/utils/sui-types.mjs +1 -1
  258. package/dist/verify/index.d.mts +2 -2
  259. package/dist/verify/verify.d.mts +74 -24
  260. package/dist/verify/verify.d.mts.map +1 -1
  261. package/dist/verify/verify.mjs +128 -42
  262. package/dist/verify/verify.mjs.map +1 -1
  263. package/dist/version.mjs +1 -1
  264. package/dist/version.mjs.map +1 -1
  265. package/dist/zklogin/bcs.d.mts +14 -14
  266. package/dist/zklogin/publickey.d.mts.map +1 -1
  267. package/dist/zklogin/publickey.mjs +15 -20
  268. package/dist/zklogin/publickey.mjs.map +1 -1
  269. package/docs/bcs.md +2 -2
  270. package/docs/clients/core.md +19 -18
  271. package/docs/clients/executing.md +53 -8
  272. package/docs/clients/graphql.md +81 -11
  273. package/docs/clients/grpc.md +31 -15
  274. package/docs/clients/index.md +8 -7
  275. package/docs/clients/querying.md +134 -30
  276. package/docs/clients/streaming.md +324 -0
  277. package/docs/cryptography/index.md +85 -58
  278. package/docs/llms-index.md +4 -2
  279. package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
  280. package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
  281. package/docs/migrations/sui-3.0/index.md +247 -0
  282. package/docs/plugins.md +10 -10
  283. package/docs/sdk-building.md +3 -4
  284. package/docs/transactions/coins-and-balances.md +6 -11
  285. package/docs/transactions/reference.md +36 -1
  286. package/package.json +4 -5
  287. package/src/bcs/bcs.ts +80 -41
  288. package/src/bcs/effects.ts +61 -25
  289. package/src/bcs/index.ts +2 -0
  290. package/src/bcs/transactions.ts +36 -17
  291. package/src/bcs/types.ts +10 -4
  292. package/src/client/core-resolver.ts +3 -5
  293. package/src/client/core.ts +180 -8
  294. package/src/client/errors.ts +12 -0
  295. package/src/client/index.ts +4 -2
  296. package/src/client/mvr.ts +37 -10
  297. package/src/client/query-filters.ts +151 -97
  298. package/src/client/stream/adapter.ts +110 -0
  299. package/src/client/stream/errors.ts +40 -0
  300. package/src/client/stream/filter.ts +17 -0
  301. package/src/client/stream/follow.ts +63 -0
  302. package/src/client/stream/index.ts +9 -0
  303. package/src/client/stream/pager.ts +158 -0
  304. package/src/client/stream/plan.ts +147 -0
  305. package/src/client/stream/position.ts +143 -0
  306. package/src/client/stream/run.ts +147 -0
  307. package/src/client/stream/session.ts +259 -0
  308. package/src/client/stream/status.ts +44 -0
  309. package/src/client/stream/token.ts +104 -0
  310. package/src/client/transaction-data.ts +610 -0
  311. package/src/client/transaction-resolver.ts +158 -69
  312. package/src/client/types.ts +530 -115
  313. package/src/client/utils.ts +146 -61
  314. package/src/cryptography/publickey.ts +12 -1
  315. package/src/cryptography/signature.ts +6 -3
  316. package/src/graphql/client.ts +204 -135
  317. package/src/graphql/core.ts +446 -139
  318. package/src/graphql/errors.ts +24 -0
  319. package/src/graphql/filters.ts +48 -0
  320. package/src/graphql/generated/queries.ts +1455 -277
  321. package/src/graphql/generated/schema.graphql +282 -9
  322. package/src/graphql/generated/tada-env.ts +933 -4
  323. package/src/graphql/queries/checkpoints.graphql +34 -0
  324. package/src/graphql/queries/getDynamicFields.graphql +1 -0
  325. package/src/graphql/queries/listEvents.graphql +16 -24
  326. package/src/graphql/queries/streams.graphql +212 -0
  327. package/src/graphql/queries/transactions.graphql +71 -28
  328. package/src/graphql/queries/verifySignature.graphql +17 -0
  329. package/src/graphql/sse-parser.ts +99 -0
  330. package/src/graphql/stream/families.ts +515 -0
  331. package/src/graphql/stream/index.ts +55 -0
  332. package/src/graphql/stream/live.ts +70 -0
  333. package/src/graphql/stream/page.ts +47 -0
  334. package/src/graphql/stream/query.ts +52 -0
  335. package/src/graphql/subscribe.ts +83 -0
  336. package/src/grpc/client.ts +81 -79
  337. package/src/grpc/core.ts +388 -274
  338. package/src/grpc/filters.ts +59 -60
  339. package/src/grpc/grpc-web-pull.ts +360 -0
  340. package/src/grpc/index.ts +5 -0
  341. package/src/grpc/network-error.ts +33 -0
  342. package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
  343. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
  344. package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
  345. package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
  346. package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
  347. package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
  348. package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
  349. package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
  350. package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
  351. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
  352. package/src/grpc/pull-call.ts +54 -0
  353. package/src/grpc/stream/call.ts +317 -0
  354. package/src/grpc/stream/families.ts +228 -0
  355. package/src/grpc/stream/index.ts +182 -0
  356. package/src/grpc/stream/live.ts +33 -0
  357. package/src/grpc/stream/page.ts +161 -0
  358. package/src/grpc/stream-types.ts +33 -0
  359. package/src/grpc/transport.ts +116 -59
  360. package/src/jsonRpc/index.ts +60 -17
  361. package/src/jsonRpc/types.ts +421 -0
  362. package/src/multisig/publickey.ts +19 -7
  363. package/src/transactions/ObjectCache.ts +6 -6
  364. package/src/transactions/Transaction.ts +30 -6
  365. package/src/transactions/data/internal.ts +2 -0
  366. package/src/transactions/executor/serial.ts +2 -2
  367. package/src/transactions/index.ts +8 -1
  368. package/src/transactions/resolve.ts +6 -0
  369. package/src/transactions/restricted-move-calls.ts +87 -0
  370. package/src/transactions/serializer.ts +0 -70
  371. package/src/transactions/utils.ts +0 -37
  372. package/src/utils/abort.ts +101 -0
  373. package/src/verify/index.ts +1 -0
  374. package/src/verify/verify.ts +190 -62
  375. package/src/version.ts +1 -1
  376. package/src/zklogin/publickey.ts +18 -34
  377. package/dist/client/core-resolver.d.mts +0 -9
  378. package/dist/client/core-resolver.d.mts.map +0 -1
  379. package/dist/jsonRpc/client.d.mts +0 -507
  380. package/dist/jsonRpc/client.d.mts.map +0 -1
  381. package/dist/jsonRpc/client.mjs +0 -868
  382. package/dist/jsonRpc/client.mjs.map +0 -1
  383. package/dist/jsonRpc/core.d.mts +0 -168
  384. package/dist/jsonRpc/core.d.mts.map +0 -1
  385. package/dist/jsonRpc/core.mjs +0 -1054
  386. package/dist/jsonRpc/core.mjs.map +0 -1
  387. package/dist/jsonRpc/errors.d.mts +0 -27
  388. package/dist/jsonRpc/errors.d.mts.map +0 -1
  389. package/dist/jsonRpc/errors.mjs +0 -50
  390. package/dist/jsonRpc/errors.mjs.map +0 -1
  391. package/dist/jsonRpc/http-transport.d.mts +0 -62
  392. package/dist/jsonRpc/http-transport.d.mts.map +0 -1
  393. package/dist/jsonRpc/http-transport.mjs +0 -60
  394. package/dist/jsonRpc/http-transport.mjs.map +0 -1
  395. package/dist/jsonRpc/network.d.mts +0 -9
  396. package/dist/jsonRpc/network.d.mts.map +0 -1
  397. package/dist/jsonRpc/network.mjs +0 -18
  398. package/dist/jsonRpc/network.mjs.map +0 -1
  399. package/dist/jsonRpc/types/chain.d.mts +0 -169
  400. package/dist/jsonRpc/types/chain.d.mts.map +0 -1
  401. package/dist/jsonRpc/types/changes.d.mts +0 -48
  402. package/dist/jsonRpc/types/changes.d.mts.map +0 -1
  403. package/dist/jsonRpc/types/coins.d.mts +0 -15
  404. package/dist/jsonRpc/types/coins.d.mts.map +0 -1
  405. package/dist/jsonRpc/types/common.d.mts +0 -9
  406. package/dist/jsonRpc/types/common.d.mts.map +0 -1
  407. package/dist/jsonRpc/types/generated.d.mts +0 -1976
  408. package/dist/jsonRpc/types/generated.d.mts.map +0 -1
  409. package/dist/jsonRpc/types/index.d.mts +0 -6
  410. package/dist/jsonRpc/types/params.d.mts +0 -898
  411. package/dist/jsonRpc/types/params.d.mts.map +0 -1
  412. package/src/graphql/generated/tsconfig.tada.json +0 -11
  413. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
  414. package/src/jsonRpc/client.ts +0 -1252
  415. package/src/jsonRpc/core.ts +0 -1557
  416. package/src/jsonRpc/errors.ts +0 -57
  417. package/src/jsonRpc/http-transport.ts +0 -118
  418. package/src/jsonRpc/network.ts +0 -21
  419. package/src/jsonRpc/types/chain.ts +0 -190
  420. package/src/jsonRpc/types/changes.ts +0 -35
  421. package/src/jsonRpc/types/coins.ts +0 -14
  422. package/src/jsonRpc/types/common.ts +0 -8
  423. package/src/jsonRpc/types/generated.ts +0 -2165
  424. package/src/jsonRpc/types/index.ts +0 -9
  425. package/src/jsonRpc/types/params.ts +0 -908
@@ -1,1054 +0,0 @@
1
- import { normalizeStructTag, normalizeSuiAddress } from "../utils/sui-types.mjs";
2
- import { TypeTagSerializer } from "../bcs/type-tag-serializer.mjs";
3
- import { bcs as suiBcs } from "../bcs/index.mjs";
4
- import { deriveDynamicFieldID } from "../utils/dynamic-fields.mjs";
5
- import { raceSignal } from "../client/mvr.mjs";
6
- import { CoreClient } from "../client/core.mjs";
7
- import { TransactionDataBuilder } from "../transactions/TransactionData.mjs";
8
- import { SUI_FRAMEWORK_ADDRESS, SUI_SYSTEM_ADDRESS } from "../utils/constants.mjs";
9
- import { formatMoveAbortMessage, isMockedGasObjectId, parseTransactionBcs, parseTransactionEffectsBcs } from "../client/utils.mjs";
10
- import { ObjectError, TransactionError } from "../client/errors.mjs";
11
- import { resolveEventFilter, resolvePagination, resolveTransactionFilter, validateTransactionQuery } from "../client/query-filters.mjs";
12
- import { JsonRpcError } from "./errors.mjs";
13
- import { computeGasBudget, coreClientResolveTransactionPlugin } from "../client/core-resolver.mjs";
14
- import { Transaction } from "../transactions/Transaction.mjs";
15
- import { fromBase58, fromBase64 } from "@mysten/bcs";
16
- import { chunk } from "@mysten/utils";
17
-
18
- //#region src/jsonRpc/core.ts
19
- const MAX_GAS = 5e10;
20
- function mapJsonRpcObjectError(response, requestedObjectId) {
21
- switch (response.code) {
22
- case "notExists": return new ObjectError(response.code, `Object ${response.object_id} does not exist`, {
23
- cause: response,
24
- reason: "notFound",
25
- objectId: requestedObjectId ?? response.object_id
26
- });
27
- case "dynamicFieldNotFound": return new ObjectError(response.code, `Dynamic field not found for object ${response.parent_object_id}`, {
28
- cause: response,
29
- reason: "notFound",
30
- objectId: requestedObjectId ?? response.parent_object_id
31
- });
32
- case "deleted": return new ObjectError(response.code, `Object ${response.object_id} has been deleted`, {
33
- cause: response,
34
- reason: "deleted",
35
- objectId: requestedObjectId ?? response.object_id
36
- });
37
- case "displayError": return new ObjectError(response.code, `Display error: ${response.error}`, {
38
- cause: response,
39
- reason: "unknown",
40
- objectId: requestedObjectId
41
- });
42
- case "unknown":
43
- default: return new ObjectError(response.code, `Unknown error while loading object${requestedObjectId ? ` ${requestedObjectId}` : ""}`, {
44
- cause: response,
45
- reason: "unknown",
46
- objectId: requestedObjectId
47
- });
48
- }
49
- }
50
- function isJsonRpcTransactionNotFound(error, digest) {
51
- if (!(error instanceof JsonRpcError) || error.code !== -32602) return false;
52
- return error.message === `Invalid Params: Transaction ${digest} not found` || error.message === `Could not find the referenced transaction [TransactionDigest(${digest})].`;
53
- }
54
- function parseJsonRpcExecutionStatus(status, abortError) {
55
- if (status.status === "success") return {
56
- success: true,
57
- error: null
58
- };
59
- const rawMessage = status.error ?? "Unknown";
60
- if (abortError) {
61
- const commandMatch = rawMessage.match(/in command (\d+)/);
62
- const command = commandMatch ? parseInt(commandMatch[1], 10) : void 0;
63
- const instructionMatch = rawMessage.match(/instruction:\s*(\d+)/);
64
- const instruction = instructionMatch ? parseInt(instructionMatch[1], 10) : void 0;
65
- const moduleParts = abortError.module_id?.split("::") ?? [];
66
- const pkg = moduleParts[0] ? normalizeSuiAddress(moduleParts[0]) : void 0;
67
- const module = moduleParts[1];
68
- return {
69
- success: false,
70
- error: {
71
- $kind: "MoveAbort",
72
- message: formatMoveAbortMessage({
73
- command,
74
- location: pkg && module ? {
75
- package: pkg,
76
- module,
77
- functionName: abortError.function ?? void 0,
78
- instruction
79
- } : void 0,
80
- abortCode: String(abortError.error_code ?? 0),
81
- cleverError: abortError.line != null ? { lineNumber: abortError.line } : void 0
82
- }),
83
- command,
84
- MoveAbort: {
85
- abortCode: String(abortError.error_code ?? 0),
86
- location: abortError.module_id ? {
87
- package: normalizeSuiAddress(abortError.module_id.split("::")[0] ?? ""),
88
- module: abortError.module_id.split("::")[1] ?? "",
89
- functionName: abortError.function ?? void 0,
90
- instruction
91
- } : void 0
92
- }
93
- }
94
- };
95
- }
96
- return {
97
- success: false,
98
- error: {
99
- $kind: "Unknown",
100
- message: rawMessage,
101
- Unknown: null
102
- }
103
- };
104
- }
105
- /**
106
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
107
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
108
- */
109
- var JSONRpcCoreClient = class extends CoreClient {
110
- #jsonRpcClient;
111
- /**
112
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
113
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
114
- */
115
- constructor({ jsonRpcClient, mvr }) {
116
- super({
117
- network: jsonRpcClient.network,
118
- base: jsonRpcClient,
119
- mvr
120
- });
121
- this.#jsonRpcClient = jsonRpcClient;
122
- }
123
- /**
124
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
125
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
126
- */
127
- async getObjects(options) {
128
- const batches = chunk(options.objectIds, 50);
129
- const results = [];
130
- for (const batch of batches) {
131
- const objects = await this.#jsonRpcClient.multiGetObjects({
132
- ids: batch,
133
- options: {
134
- showOwner: true,
135
- showType: true,
136
- showBcs: options.include?.content || options.include?.objectBcs ? true : false,
137
- showPreviousTransaction: options.include?.previousTransaction || options.include?.objectBcs ? true : false,
138
- showStorageRebate: options.include?.objectBcs ?? false,
139
- showContent: options.include?.json ?? false,
140
- showDisplay: options.include?.display ?? false
141
- },
142
- signal: options.signal
143
- });
144
- for (const [idx, object] of objects.entries()) if (object.error) results.push(mapJsonRpcObjectError(object.error, batch[idx]));
145
- else results.push(parseObject(object.data, options.include));
146
- }
147
- return { objects: results };
148
- }
149
- /**
150
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
151
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
152
- */
153
- async listOwnedObjects(options) {
154
- let filter = null;
155
- if (options.type) {
156
- const parts = options.type.split("::");
157
- if (parts.length === 1) filter = { Package: options.type };
158
- else if (parts.length === 2) filter = { MoveModule: {
159
- package: parts[0],
160
- module: parts[1]
161
- } };
162
- else filter = { StructType: options.type };
163
- }
164
- const objects = await this.#jsonRpcClient.getOwnedObjects({
165
- owner: options.owner,
166
- limit: options.limit,
167
- cursor: options.cursor,
168
- options: {
169
- showOwner: true,
170
- showType: true,
171
- showBcs: options.include?.content || options.include?.objectBcs ? true : false,
172
- showPreviousTransaction: options.include?.previousTransaction || options.include?.objectBcs ? true : false,
173
- showStorageRebate: options.include?.objectBcs ?? false,
174
- showContent: options.include?.json ?? false,
175
- showDisplay: options.include?.display ?? false
176
- },
177
- filter,
178
- signal: options.signal
179
- });
180
- return {
181
- objects: objects.data.map((result) => {
182
- if (result.error) throw mapJsonRpcObjectError(result.error);
183
- return parseObject(result.data, options.include);
184
- }),
185
- hasNextPage: objects.hasNextPage,
186
- cursor: objects.nextCursor ?? null
187
- };
188
- }
189
- /**
190
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
191
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
192
- */
193
- async listCoins(options) {
194
- const coins = await this.#jsonRpcClient.getCoins({
195
- owner: options.owner,
196
- coinType: options.coinType,
197
- limit: options.limit,
198
- cursor: options.cursor,
199
- signal: options.signal
200
- });
201
- return {
202
- objects: coins.data.map((coin) => ({
203
- objectId: coin.coinObjectId,
204
- version: coin.version,
205
- digest: coin.digest,
206
- balance: coin.balance,
207
- type: normalizeStructTag(`0x2::coin::Coin<${coin.coinType}>`),
208
- owner: {
209
- $kind: "AddressOwner",
210
- AddressOwner: options.owner
211
- }
212
- })),
213
- hasNextPage: coins.hasNextPage,
214
- cursor: coins.nextCursor ?? null
215
- };
216
- }
217
- /**
218
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
219
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
220
- */
221
- async getBalance(options) {
222
- const balance = await this.#jsonRpcClient.getBalance({
223
- owner: options.owner,
224
- coinType: options.coinType,
225
- signal: options.signal
226
- });
227
- const addressBalance = balance.fundsInAddressBalance ?? "0";
228
- const coinBalance = String(BigInt(balance.totalBalance) - BigInt(addressBalance));
229
- return { balance: {
230
- coinType: normalizeStructTag(balance.coinType),
231
- balance: balance.totalBalance,
232
- coinBalance,
233
- addressBalance
234
- } };
235
- }
236
- /**
237
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
238
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
239
- */
240
- async getCoinMetadata(options) {
241
- const coinType = (await this.mvr.resolveType({
242
- type: options.coinType,
243
- signal: options.signal
244
- })).type;
245
- const result = await this.#jsonRpcClient.getCoinMetadata({
246
- coinType,
247
- signal: options.signal
248
- });
249
- if (!result) return { coinMetadata: null };
250
- return { coinMetadata: {
251
- id: result.id ?? null,
252
- decimals: result.decimals,
253
- name: result.name,
254
- symbol: result.symbol,
255
- description: result.description,
256
- iconUrl: result.iconUrl ?? null
257
- } };
258
- }
259
- /**
260
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
261
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
262
- */
263
- async listBalances(options) {
264
- return {
265
- balances: (await this.#jsonRpcClient.getAllBalances({
266
- owner: options.owner,
267
- signal: options.signal
268
- })).map((balance) => {
269
- const addressBalance = balance.fundsInAddressBalance ?? "0";
270
- const coinBalance = String(BigInt(balance.totalBalance) - BigInt(addressBalance));
271
- return {
272
- coinType: normalizeStructTag(balance.coinType),
273
- balance: balance.totalBalance,
274
- coinBalance,
275
- addressBalance
276
- };
277
- }),
278
- hasNextPage: false,
279
- cursor: null
280
- };
281
- }
282
- /**
283
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
284
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
285
- */
286
- async getTransaction(options) {
287
- try {
288
- return parseTransaction(await this.#jsonRpcClient.getTransactionBlock({
289
- digest: options.digest,
290
- options: {
291
- showRawInput: true,
292
- showEffects: true,
293
- showObjectChanges: options.include?.objectTypes ?? false,
294
- showRawEffects: options.include?.effects ?? false,
295
- showEvents: options.include?.events ?? false,
296
- showBalanceChanges: options.include?.balanceChanges ?? false
297
- },
298
- signal: options.signal
299
- }), options.include);
300
- } catch (error) {
301
- if (isJsonRpcTransactionNotFound(error, options.digest)) throw new TransactionError("notFound", options.digest, { cause: error });
302
- throw error;
303
- }
304
- }
305
- /**
306
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
307
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
308
- */
309
- async executeTransaction(options) {
310
- return parseTransaction(await this.#jsonRpcClient.executeTransactionBlock({
311
- transactionBlock: options.transaction,
312
- signature: options.signatures,
313
- options: {
314
- showRawInput: true,
315
- showEffects: true,
316
- showRawEffects: options.include?.effects ?? false,
317
- showEvents: options.include?.events ?? false,
318
- showObjectChanges: options.include?.objectTypes ?? false,
319
- showBalanceChanges: options.include?.balanceChanges ?? false
320
- },
321
- signal: options.signal
322
- }), options.include);
323
- }
324
- /**
325
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
326
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
327
- */
328
- async simulateTransaction(options) {
329
- if (!(options.transaction instanceof Uint8Array)) await options.transaction.build({
330
- client: this,
331
- onlyTransactionKind: true
332
- });
333
- const tx = Transaction.from(options.transaction);
334
- const data = options.transaction instanceof Uint8Array ? null : TransactionDataBuilder.restore(options.transaction.getData());
335
- const transactionBytes = data ? data.build({ overrides: { gasData: {
336
- budget: data.gasData.budget ?? String(MAX_GAS),
337
- price: data.gasData.price ?? String(await this.#jsonRpcClient.getReferenceGasPrice({ signal: options.signal })),
338
- payment: data.gasData.payment ?? []
339
- } } }) : options.transaction;
340
- const sender = tx.getData().sender ?? normalizeSuiAddress("0x0");
341
- const checksDisabled = options.checksEnabled === false;
342
- let dryRunResult = null;
343
- try {
344
- dryRunResult = await this.#jsonRpcClient.dryRunTransactionBlock({
345
- transactionBlock: transactionBytes,
346
- signal: options.signal
347
- });
348
- } catch (e) {
349
- if (!checksDisabled) throw e;
350
- }
351
- let devInspectResult = null;
352
- if (options.include?.commandResults || checksDisabled) try {
353
- devInspectResult = await this.#jsonRpcClient.devInspectTransactionBlock({
354
- sender,
355
- transactionBlock: tx,
356
- signal: options.signal
357
- });
358
- } catch {}
359
- const dryRunFailed = !dryRunResult || dryRunResult.effects.status.status !== "success";
360
- const effectsSource = checksDisabled && dryRunFailed && devInspectResult ? devInspectResult : dryRunResult ?? devInspectResult;
361
- if (!effectsSource) throw new Error("simulateTransaction failed: no results from dryRun or devInspect");
362
- const { effects, objectTypes } = parseTransactionEffectsJson({
363
- effects: effectsSource.effects,
364
- objectChanges: (!dryRunFailed ? dryRunResult?.objectChanges : null) ?? []
365
- });
366
- let parsedTransaction;
367
- if (options.include?.transaction) {
368
- parsedTransaction = parseTransactionBcs(transactionBytes);
369
- if (data && !dryRunFailed && effects.gasUsed) {
370
- if (!data.gasData.budget) parsedTransaction.gasData.budget = computeGasBudget(effects.gasUsed);
371
- }
372
- }
373
- const transactionData = {
374
- digest: TransactionDataBuilder.getDigestFromBytes(transactionBytes),
375
- epoch: null,
376
- timestampMs: null,
377
- checkpoint: null,
378
- status: effects.status,
379
- effects: options.include?.effects ? effects : void 0,
380
- objectTypes: options.include?.objectTypes ? objectTypes : void 0,
381
- signatures: [],
382
- transaction: parsedTransaction ?? void 0,
383
- bcs: options.include?.bcs ? transactionBytes : void 0,
384
- balanceChanges: options.include?.balanceChanges && dryRunResult && !dryRunFailed ? dryRunResult.balanceChanges.map((change) => ({
385
- coinType: normalizeStructTag(change.coinType),
386
- address: parseOwnerAddress(change.owner),
387
- amount: change.amount
388
- })) : void 0,
389
- events: options.include?.events ? effectsSource.events?.map((event) => ({
390
- packageId: event.packageId,
391
- module: event.transactionModule,
392
- sender: event.sender,
393
- eventType: event.type,
394
- bcs: "bcs" in event ? fromBase64(event.bcs) : new Uint8Array(),
395
- json: event.parsedJson ?? null
396
- })) ?? [] : void 0
397
- };
398
- let commandResults;
399
- if (options.include?.commandResults && devInspectResult?.results) commandResults = devInspectResult.results.map((result) => ({
400
- returnValues: (result.returnValues ?? []).map(([bytes]) => ({ bcs: new Uint8Array(bytes) })),
401
- mutatedReferences: (result.mutableReferenceOutputs ?? []).map(([, bytes]) => ({ bcs: new Uint8Array(bytes) }))
402
- }));
403
- const gasPaymentMocked = isMockedGasObjectId(effects.gasObject?.objectId);
404
- return effects.status.success ? {
405
- $kind: "Transaction",
406
- Transaction: transactionData,
407
- commandResults,
408
- gasPaymentMocked
409
- } : {
410
- $kind: "FailedTransaction",
411
- FailedTransaction: transactionData,
412
- commandResults,
413
- gasPaymentMocked
414
- };
415
- }
416
- /**
417
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
418
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
419
- */
420
- async getReferenceGasPrice(options) {
421
- const referenceGasPrice = await this.#jsonRpcClient.getReferenceGasPrice({ signal: options?.signal });
422
- return { referenceGasPrice: String(referenceGasPrice) };
423
- }
424
- /**
425
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
426
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
427
- */
428
- async getProtocolConfig(options) {
429
- const result = await this.#jsonRpcClient.getProtocolConfig({ signal: options?.signal });
430
- const attributes = {};
431
- for (const [key, value] of Object.entries(result.attributes)) if (value === null) attributes[key] = null;
432
- else if ("u16" in value) attributes[key] = value.u16;
433
- else if ("u32" in value) attributes[key] = value.u32;
434
- else if ("u64" in value) attributes[key] = value.u64;
435
- else if ("f64" in value) attributes[key] = value.f64;
436
- else if ("bool" in value) attributes[key] = value.bool;
437
- else {
438
- const entries = Object.entries(value);
439
- attributes[key] = entries.length === 1 ? String(entries[0][1]) : JSON.stringify(value);
440
- }
441
- return { protocolConfig: {
442
- protocolVersion: result.protocolVersion,
443
- featureFlags: { ...result.featureFlags },
444
- attributes
445
- } };
446
- }
447
- /**
448
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
449
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
450
- */
451
- async getCurrentSystemState(options) {
452
- const systemState = await this.#jsonRpcClient.getLatestSuiSystemState({ signal: options?.signal });
453
- return { systemState: {
454
- systemStateVersion: systemState.systemStateVersion,
455
- epoch: systemState.epoch,
456
- protocolVersion: systemState.protocolVersion,
457
- referenceGasPrice: systemState.referenceGasPrice?.toString() ?? null,
458
- epochStartTimestampMs: systemState.epochStartTimestampMs,
459
- safeMode: systemState.safeMode,
460
- safeModeStorageRewards: systemState.safeModeStorageRewards,
461
- safeModeComputationRewards: systemState.safeModeComputationRewards,
462
- safeModeStorageRebates: systemState.safeModeStorageRebates,
463
- safeModeNonRefundableStorageFee: systemState.safeModeNonRefundableStorageFee,
464
- parameters: {
465
- epochDurationMs: systemState.epochDurationMs,
466
- stakeSubsidyStartEpoch: systemState.stakeSubsidyStartEpoch,
467
- maxValidatorCount: systemState.maxValidatorCount,
468
- minValidatorJoiningStake: systemState.minValidatorJoiningStake,
469
- validatorLowStakeThreshold: systemState.validatorLowStakeThreshold,
470
- validatorLowStakeGracePeriod: systemState.validatorLowStakeGracePeriod
471
- },
472
- storageFund: {
473
- totalObjectStorageRebates: systemState.storageFundTotalObjectStorageRebates,
474
- nonRefundableBalance: systemState.storageFundNonRefundableBalance
475
- },
476
- stakeSubsidy: {
477
- balance: systemState.stakeSubsidyBalance,
478
- distributionCounter: systemState.stakeSubsidyDistributionCounter,
479
- currentDistributionAmount: systemState.stakeSubsidyCurrentDistributionAmount,
480
- stakeSubsidyPeriodLength: systemState.stakeSubsidyPeriodLength,
481
- stakeSubsidyDecreaseRate: systemState.stakeSubsidyDecreaseRate
482
- }
483
- } };
484
- }
485
- /**
486
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
487
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
488
- */
489
- async listDynamicFields(options) {
490
- const dynamicFields = await this.#jsonRpcClient.getDynamicFields({
491
- parentId: options.parentId,
492
- limit: options.limit,
493
- cursor: options.cursor,
494
- signal: options.signal
495
- });
496
- return {
497
- dynamicFields: dynamicFields.data.map((dynamicField) => {
498
- const isDynamicObject = dynamicField.type === "DynamicObject";
499
- const fullType = isDynamicObject ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name.type}>, 0x2::object::ID>` : `0x2::dynamic_field::Field<${dynamicField.name.type}, ${dynamicField.objectType}>`;
500
- const bcsBytes = fromBase64(dynamicField.bcsName);
501
- const derivedNameType = isDynamicObject ? `0x2::dynamic_object_field::Wrapper<${dynamicField.name.type}>` : dynamicField.name.type;
502
- return {
503
- $kind: isDynamicObject ? "DynamicObject" : "DynamicField",
504
- fieldId: deriveDynamicFieldID(options.parentId, derivedNameType, bcsBytes),
505
- type: normalizeStructTag(fullType),
506
- name: {
507
- type: dynamicField.name.type,
508
- bcs: bcsBytes
509
- },
510
- valueType: dynamicField.objectType,
511
- childId: isDynamicObject ? dynamicField.objectId : void 0
512
- };
513
- }),
514
- hasNextPage: dynamicFields.hasNextPage,
515
- cursor: dynamicFields.nextCursor
516
- };
517
- }
518
- /**
519
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
520
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
521
- */
522
- async listTransactions(options) {
523
- const filter = options.filter ? await resolveTransactionFilter(this.mvr, options.filter, options.signal) : void 0;
524
- const pagination = resolvePagination(options);
525
- const { descending, after, before } = pagination;
526
- validateTransactionQuery(filter, pagination);
527
- const page = await this.#jsonRpcClient.queryTransactionBlocks({
528
- filter: filter && (filter.$kind === "sender" ? { FromAddress: filter.sender } : { MoveFunction: {
529
- package: filter.package,
530
- module: filter.module ?? null,
531
- function: filter.function ?? null
532
- } }),
533
- cursor: after ?? before,
534
- limit: pagination.limit,
535
- order: descending ? "descending" : "ascending",
536
- options: {
537
- showRawInput: true,
538
- showEffects: true,
539
- showObjectChanges: options.include?.objectTypes ?? false,
540
- showRawEffects: options.include?.effects ?? false,
541
- showEvents: options.include?.events ?? false,
542
- showBalanceChanges: options.include?.balanceChanges ?? false
543
- },
544
- signal: options.signal
545
- });
546
- return {
547
- transactions: page.data.map((transaction) => parseTransaction(transaction, options.include)),
548
- hasNextPage: page.hasNextPage,
549
- startCursor: page.data[0]?.digest ?? null,
550
- endCursor: page.data.length ? page.nextCursor ?? page.data[page.data.length - 1].digest : null
551
- };
552
- }
553
- /**
554
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
555
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
556
- */
557
- async listEvents(options) {
558
- const filter = options.filter ? await resolveEventFilter(this.mvr, options.filter, options.signal) : void 0;
559
- const { descending, after, before, limit } = resolvePagination(options);
560
- const cursor = after ?? before;
561
- const page = await this.#jsonRpcClient.queryEvents({
562
- query: !filter ? { All: [] } : filter.$kind === "sender" ? { Sender: filter.sender } : filter.$kind === "emitModule" ? { MoveModule: {
563
- package: filter.package,
564
- module: filter.module
565
- } } : filter.$kind === "eventTypeModule" ? { MoveEventModule: {
566
- package: filter.package,
567
- module: filter.module
568
- } } : { MoveEventType: filter.eventType },
569
- cursor: cursor ? parseEventCursor(cursor) : void 0,
570
- limit,
571
- order: descending ? "descending" : "ascending",
572
- signal: options.signal
573
- });
574
- return {
575
- events: page.data.map((event) => ({
576
- packageId: normalizeSuiAddress(event.packageId),
577
- module: event.transactionModule,
578
- sender: normalizeSuiAddress(event.sender),
579
- eventType: normalizeStructTag(event.type),
580
- bcs: event.bcsEncoding === "base58" ? fromBase58(event.bcs) : fromBase64(event.bcs),
581
- json: event.parsedJson ?? null,
582
- checkpoint: null,
583
- transactionDigest: event.id.txDigest,
584
- eventIndex: Number(event.id.eventSeq)
585
- })),
586
- hasNextPage: page.hasNextPage,
587
- startCursor: page.data.length ? JSON.stringify(page.data[0].id) : null,
588
- endCursor: page.data.length && page.nextCursor ? JSON.stringify(page.nextCursor) : page.data.length ? JSON.stringify(page.data[page.data.length - 1].id) : null
589
- };
590
- }
591
- /**
592
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
593
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
594
- */
595
- async verifyZkLoginSignature(options) {
596
- const result = await this.#jsonRpcClient.verifyZkLoginSignature({
597
- signal: options.signal,
598
- bytes: options.bytes,
599
- signature: options.signature,
600
- intentScope: options.intentScope,
601
- author: options.address
602
- });
603
- return {
604
- success: result.success,
605
- errors: result.errors
606
- };
607
- }
608
- /**
609
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
610
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
611
- */
612
- async defaultNameServiceName(options) {
613
- return { data: { name: (await this.#jsonRpcClient.resolveNameServiceNames(options)).data[0] ?? null } };
614
- }
615
- /**
616
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
617
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
618
- */
619
- async resolveNameServiceAddress(options) {
620
- return { address: await this.#jsonRpcClient.resolveNameServiceAddress(options) };
621
- }
622
- /**
623
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
624
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
625
- */
626
- resolveTransactionPlugin() {
627
- return coreClientResolveTransactionPlugin;
628
- }
629
- /**
630
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
631
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
632
- */
633
- async getMoveFunction(options) {
634
- const resolvedPackageId = (await this.mvr.resolvePackage({
635
- package: options.packageId,
636
- signal: options.signal
637
- })).package;
638
- const result = await this.#jsonRpcClient.getNormalizedMoveFunction({
639
- package: resolvedPackageId,
640
- module: options.moduleName,
641
- function: options.name,
642
- signal: options.signal
643
- });
644
- return { function: {
645
- packageId: normalizeSuiAddress(resolvedPackageId),
646
- moduleName: options.moduleName,
647
- name: options.name,
648
- visibility: parseVisibility(result.visibility),
649
- isEntry: result.isEntry,
650
- typeParameters: result.typeParameters.map((abilities) => ({
651
- isPhantom: false,
652
- constraints: parseAbilities(abilities)
653
- })),
654
- parameters: result.parameters.map((param) => parseNormalizedSuiMoveType(param)),
655
- returns: result.return.map((ret) => parseNormalizedSuiMoveType(ret))
656
- } };
657
- }
658
- /**
659
- * @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
660
- * from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
661
- */
662
- async getChainIdentifier(options) {
663
- const cached = this.cache.read(["chainIdentifier"], async () => {
664
- return { chainIdentifier: (await this.#jsonRpcClient.getCheckpoint({ id: "0" })).digest };
665
- });
666
- return raceSignal(Promise.resolve(cached), options?.signal);
667
- }
668
- };
669
- function serializeObjectToBcs(object) {
670
- if (object.bcs?.dataType !== "moveObject") return;
671
- try {
672
- const typeStr = normalizeStructTag(object.bcs.type);
673
- let moveObjectType;
674
- const normalizedSuiFramework = normalizeSuiAddress(SUI_FRAMEWORK_ADDRESS);
675
- const gasCoinType = normalizeStructTag(`${SUI_FRAMEWORK_ADDRESS}::coin::Coin<${SUI_FRAMEWORK_ADDRESS}::sui::SUI>`);
676
- const stakedSuiType = normalizeStructTag(`${SUI_SYSTEM_ADDRESS}::staking_pool::StakedSui`);
677
- const coinPrefix = `${normalizedSuiFramework}::coin::Coin<`;
678
- if (typeStr === gasCoinType) moveObjectType = { GasCoin: null };
679
- else if (typeStr === stakedSuiType) moveObjectType = { StakedSui: null };
680
- else if (typeStr.startsWith(coinPrefix)) {
681
- const innerTypeMatch = typeStr.match(/* @__PURE__ */ new RegExp(`${normalizedSuiFramework.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}::coin::Coin<(.+)>$`));
682
- if (innerTypeMatch) moveObjectType = { Coin: TypeTagSerializer.parseFromStr(innerTypeMatch[1], true) };
683
- else throw new Error("Failed to parse Coin type");
684
- } else {
685
- const typeTag = TypeTagSerializer.parseFromStr(typeStr, true);
686
- if (typeof typeTag !== "object" || !("struct" in typeTag)) throw new Error("Expected struct type tag");
687
- moveObjectType = { Other: typeTag.struct };
688
- }
689
- const contents = fromBase64(object.bcs.bcsBytes);
690
- const owner = convertOwnerToBcs(object.owner);
691
- return suiBcs.Object.serialize({
692
- data: { Move: {
693
- type: moveObjectType,
694
- hasPublicTransfer: object.bcs.hasPublicTransfer,
695
- version: object.bcs.version,
696
- contents
697
- } },
698
- owner,
699
- previousTransaction: object.previousTransaction,
700
- storageRebate: object.storageRebate
701
- }).toBytes();
702
- } catch {
703
- return;
704
- }
705
- }
706
- function parseObject(object, include) {
707
- const bcsContent = object.bcs?.dataType === "moveObject" ? fromBase64(object.bcs.bcsBytes) : void 0;
708
- const objectBcs = include?.objectBcs ? serializeObjectToBcs(object) : void 0;
709
- const type = object.type && object.type.includes("::") ? normalizeStructTag(object.type) : object.type ?? "";
710
- const jsonContent = include?.json && object.content?.dataType === "moveObject" ? object.content.fields : include?.json ? null : void 0;
711
- const displayData = include?.display ? object.display?.data != null ? {
712
- output: object.display.data,
713
- errors: null
714
- } : null : void 0;
715
- return {
716
- objectId: object.objectId,
717
- version: object.version,
718
- digest: object.digest,
719
- type,
720
- content: include?.content ? bcsContent : void 0,
721
- owner: parseOwner(object.owner),
722
- previousTransaction: include?.previousTransaction ? object.previousTransaction ?? void 0 : void 0,
723
- objectBcs,
724
- json: jsonContent,
725
- display: displayData
726
- };
727
- }
728
- function parseOwner(owner) {
729
- if (owner === "Immutable") return {
730
- $kind: "Immutable",
731
- Immutable: true
732
- };
733
- if ("ConsensusAddressOwner" in owner) return {
734
- $kind: "ConsensusAddressOwner",
735
- ConsensusAddressOwner: {
736
- owner: owner.ConsensusAddressOwner.owner,
737
- startVersion: owner.ConsensusAddressOwner.start_version
738
- }
739
- };
740
- if ("AddressOwner" in owner) return {
741
- $kind: "AddressOwner",
742
- AddressOwner: owner.AddressOwner
743
- };
744
- if ("ObjectOwner" in owner) return {
745
- $kind: "ObjectOwner",
746
- ObjectOwner: owner.ObjectOwner
747
- };
748
- if ("Shared" in owner) return {
749
- $kind: "Shared",
750
- Shared: { initialSharedVersion: owner.Shared.initial_shared_version }
751
- };
752
- throw new Error(`Unknown owner type: ${JSON.stringify(owner)}`);
753
- }
754
- function convertOwnerToBcs(owner) {
755
- if (owner === "Immutable") return { Immutable: null };
756
- if ("AddressOwner" in owner) return { AddressOwner: owner.AddressOwner };
757
- if ("ObjectOwner" in owner) return { ObjectOwner: owner.ObjectOwner };
758
- if ("Shared" in owner) return { Shared: { initialSharedVersion: owner.Shared.initial_shared_version } };
759
- if (typeof owner === "object" && owner !== null && "ConsensusAddressOwner" in owner) return { ConsensusAddressOwner: {
760
- startVersion: owner.ConsensusAddressOwner.start_version,
761
- owner: owner.ConsensusAddressOwner.owner
762
- } };
763
- throw new Error(`Unknown owner type: ${JSON.stringify(owner)}`);
764
- }
765
- function parseOwnerAddress(owner) {
766
- if (owner === "Immutable") return null;
767
- if ("ConsensusAddressOwner" in owner) return owner.ConsensusAddressOwner.owner;
768
- if ("AddressOwner" in owner) return owner.AddressOwner;
769
- if ("ObjectOwner" in owner) return owner.ObjectOwner;
770
- if ("Shared" in owner) return null;
771
- throw new Error(`Unknown owner type: ${JSON.stringify(owner)}`);
772
- }
773
- function parseEventCursor(cursor) {
774
- try {
775
- const parsed = JSON.parse(cursor);
776
- if (typeof parsed?.txDigest !== "string" || typeof parsed?.eventSeq !== "string") throw new Error("malformed event cursor");
777
- return parsed;
778
- } catch {
779
- throw new Error(`Invalid event cursor: ${cursor}`);
780
- }
781
- }
782
- function parseTransaction(transaction, include) {
783
- const objectTypes = {};
784
- if (include?.objectTypes) transaction.objectChanges?.forEach((change) => {
785
- if (change.type !== "published") objectTypes[change.objectId] = normalizeStructTag(change.objectType);
786
- });
787
- let transactionData;
788
- let signatures = [];
789
- let bcsBytes;
790
- if (transaction.rawTransaction) {
791
- const parsedTx = suiBcs.SenderSignedData.parse(fromBase64(transaction.rawTransaction))[0];
792
- signatures = parsedTx.txSignatures;
793
- if (include?.transaction || include?.bcs) {
794
- const bytes = suiBcs.TransactionData.serialize(parsedTx.intentMessage.value).toBytes();
795
- if (include?.bcs) bcsBytes = bytes;
796
- if (include?.transaction) transactionData = { ...TransactionDataBuilder.restore({
797
- version: 2,
798
- sender: parsedTx.intentMessage.value.V1.sender,
799
- expiration: parsedTx.intentMessage.value.V1.expiration,
800
- gasData: parsedTx.intentMessage.value.V1.gasData,
801
- inputs: parsedTx.intentMessage.value.V1.kind.ProgrammableTransaction.inputs,
802
- commands: parsedTx.intentMessage.value.V1.kind.ProgrammableTransaction.commands
803
- }) };
804
- }
805
- }
806
- const status = transaction.effects?.status ? parseJsonRpcExecutionStatus(transaction.effects.status, transaction.effects.abortError) : {
807
- success: false,
808
- error: {
809
- $kind: "Unknown",
810
- message: "Unknown",
811
- Unknown: null
812
- }
813
- };
814
- const effectsBytes = transaction.rawEffects ? new Uint8Array(transaction.rawEffects) : null;
815
- const result = {
816
- digest: transaction.digest,
817
- epoch: transaction.effects?.executedEpoch ?? null,
818
- timestampMs: transaction.timestampMs == null ? null : Number(transaction.timestampMs),
819
- checkpoint: transaction.checkpoint ?? null,
820
- status,
821
- effects: include?.effects && effectsBytes ? parseTransactionEffectsBcs(effectsBytes) : void 0,
822
- objectTypes: include?.objectTypes ? objectTypes : void 0,
823
- transaction: transactionData,
824
- bcs: bcsBytes,
825
- signatures,
826
- balanceChanges: include?.balanceChanges ? transaction.balanceChanges?.map((change) => ({
827
- coinType: normalizeStructTag(change.coinType),
828
- address: parseOwnerAddress(change.owner),
829
- amount: change.amount
830
- })) ?? [] : void 0,
831
- events: include?.events ? transaction.events?.map((event) => ({
832
- packageId: event.packageId,
833
- module: event.transactionModule,
834
- sender: event.sender,
835
- eventType: event.type,
836
- bcs: "bcs" in event ? fromBase64(event.bcs) : new Uint8Array(),
837
- json: event.parsedJson ?? null
838
- })) ?? [] : void 0
839
- };
840
- return status.success ? {
841
- $kind: "Transaction",
842
- Transaction: result
843
- } : {
844
- $kind: "FailedTransaction",
845
- FailedTransaction: result
846
- };
847
- }
848
- function parseTransactionEffectsJson({ bytes, effects, objectChanges }) {
849
- const changedObjects = [];
850
- const unchangedConsensusObjects = [];
851
- const objectTypes = {};
852
- objectChanges?.forEach((change) => {
853
- switch (change.type) {
854
- case "published":
855
- changedObjects.push({
856
- objectId: change.packageId,
857
- inputState: "DoesNotExist",
858
- inputVersion: null,
859
- inputDigest: null,
860
- inputOwner: null,
861
- outputState: "PackageWrite",
862
- outputVersion: change.version,
863
- outputDigest: change.digest,
864
- outputOwner: null,
865
- idOperation: "Created"
866
- });
867
- break;
868
- case "transferred":
869
- changedObjects.push({
870
- objectId: change.objectId,
871
- inputState: "Exists",
872
- inputVersion: change.version,
873
- inputDigest: change.digest,
874
- inputOwner: {
875
- $kind: "AddressOwner",
876
- AddressOwner: change.sender
877
- },
878
- outputState: "ObjectWrite",
879
- outputVersion: change.version,
880
- outputDigest: change.digest,
881
- outputOwner: parseOwner(change.recipient),
882
- idOperation: "None"
883
- });
884
- objectTypes[change.objectId] = normalizeStructTag(change.objectType);
885
- break;
886
- case "mutated":
887
- changedObjects.push({
888
- objectId: change.objectId,
889
- inputState: "Exists",
890
- inputVersion: change.previousVersion,
891
- inputDigest: null,
892
- inputOwner: parseOwner(change.owner),
893
- outputState: "ObjectWrite",
894
- outputVersion: change.version,
895
- outputDigest: change.digest,
896
- outputOwner: parseOwner(change.owner),
897
- idOperation: "None"
898
- });
899
- objectTypes[change.objectId] = normalizeStructTag(change.objectType);
900
- break;
901
- case "deleted":
902
- changedObjects.push({
903
- objectId: change.objectId,
904
- inputState: "Exists",
905
- inputVersion: change.version,
906
- inputDigest: effects.deleted?.find((d) => d.objectId === change.objectId)?.digest ?? null,
907
- inputOwner: null,
908
- outputState: "DoesNotExist",
909
- outputVersion: null,
910
- outputDigest: null,
911
- outputOwner: null,
912
- idOperation: "Deleted"
913
- });
914
- objectTypes[change.objectId] = normalizeStructTag(change.objectType);
915
- break;
916
- case "wrapped":
917
- changedObjects.push({
918
- objectId: change.objectId,
919
- inputState: "Exists",
920
- inputVersion: change.version,
921
- inputDigest: null,
922
- inputOwner: {
923
- $kind: "AddressOwner",
924
- AddressOwner: change.sender
925
- },
926
- outputState: "ObjectWrite",
927
- outputVersion: change.version,
928
- outputDigest: effects.wrapped?.find((w) => w.objectId === change.objectId)?.digest ?? null,
929
- outputOwner: {
930
- $kind: "ObjectOwner",
931
- ObjectOwner: change.sender
932
- },
933
- idOperation: "None"
934
- });
935
- objectTypes[change.objectId] = normalizeStructTag(change.objectType);
936
- break;
937
- case "created":
938
- changedObjects.push({
939
- objectId: change.objectId,
940
- inputState: "DoesNotExist",
941
- inputVersion: null,
942
- inputDigest: null,
943
- inputOwner: null,
944
- outputState: "ObjectWrite",
945
- outputVersion: change.version,
946
- outputDigest: change.digest,
947
- outputOwner: parseOwner(change.owner),
948
- idOperation: "Created"
949
- });
950
- objectTypes[change.objectId] = normalizeStructTag(change.objectType);
951
- break;
952
- }
953
- });
954
- const hasGasObject = normalizeSuiAddress(effects.gasObject.reference.objectId) !== normalizeSuiAddress("0x0");
955
- let lamportVersion = null;
956
- if (hasGasObject) lamportVersion = effects.gasObject.reference.version;
957
- else for (const change of changedObjects) if (change.outputVersion && (lamportVersion === null || BigInt(change.outputVersion) > BigInt(lamportVersion))) lamportVersion = change.outputVersion;
958
- return {
959
- objectTypes,
960
- effects: {
961
- bcs: bytes ?? null,
962
- version: 2,
963
- status: parseJsonRpcExecutionStatus(effects.status, effects.abortError),
964
- gasUsed: effects.gasUsed,
965
- transactionDigest: effects.transactionDigest,
966
- gasObject: hasGasObject ? {
967
- objectId: effects.gasObject.reference.objectId,
968
- inputState: "Exists",
969
- inputVersion: null,
970
- inputDigest: null,
971
- inputOwner: null,
972
- outputState: "ObjectWrite",
973
- outputVersion: effects.gasObject.reference.version,
974
- outputDigest: effects.gasObject.reference.digest,
975
- outputOwner: parseOwner(effects.gasObject.owner),
976
- idOperation: "None"
977
- } : null,
978
- eventsDigest: effects.eventsDigest ?? null,
979
- dependencies: effects.dependencies ?? [],
980
- lamportVersion,
981
- changedObjects,
982
- unchangedConsensusObjects,
983
- auxiliaryDataDigest: null
984
- }
985
- };
986
- }
987
- function parseNormalizedSuiMoveType(type) {
988
- if (typeof type !== "string") {
989
- if ("Reference" in type) return {
990
- reference: "immutable",
991
- body: parseNormalizedSuiMoveTypeBody(type.Reference)
992
- };
993
- if ("MutableReference" in type) return {
994
- reference: "mutable",
995
- body: parseNormalizedSuiMoveTypeBody(type.MutableReference)
996
- };
997
- }
998
- return {
999
- reference: null,
1000
- body: parseNormalizedSuiMoveTypeBody(type)
1001
- };
1002
- }
1003
- function parseNormalizedSuiMoveTypeBody(type) {
1004
- switch (type) {
1005
- case "Address": return { $kind: "address" };
1006
- case "Bool": return { $kind: "bool" };
1007
- case "U8": return { $kind: "u8" };
1008
- case "U16": return { $kind: "u16" };
1009
- case "U32": return { $kind: "u32" };
1010
- case "U64": return { $kind: "u64" };
1011
- case "U128": return { $kind: "u128" };
1012
- case "U256": return { $kind: "u256" };
1013
- }
1014
- if (typeof type === "string") throw new Error(`Unknown type: ${type}`);
1015
- if ("Vector" in type) return {
1016
- $kind: "vector",
1017
- vector: parseNormalizedSuiMoveTypeBody(type.Vector)
1018
- };
1019
- if ("Struct" in type) return {
1020
- $kind: "datatype",
1021
- datatype: {
1022
- typeName: `${normalizeSuiAddress(type.Struct.address)}::${type.Struct.module}::${type.Struct.name}`,
1023
- typeParameters: type.Struct.typeArguments.map((t) => parseNormalizedSuiMoveTypeBody(t))
1024
- }
1025
- };
1026
- if ("TypeParameter" in type) return {
1027
- $kind: "typeParameter",
1028
- index: type.TypeParameter
1029
- };
1030
- throw new Error(`Unknown type: ${JSON.stringify(type)}`);
1031
- }
1032
- function parseAbilities(abilitySet) {
1033
- return abilitySet.abilities.map((ability) => {
1034
- switch (ability) {
1035
- case "Copy": return "copy";
1036
- case "Drop": return "drop";
1037
- case "Store": return "store";
1038
- case "Key": return "key";
1039
- default: return "unknown";
1040
- }
1041
- });
1042
- }
1043
- function parseVisibility(visibility) {
1044
- switch (visibility) {
1045
- case "Public": return "public";
1046
- case "Private": return "private";
1047
- case "Friend": return "friend";
1048
- default: return "unknown";
1049
- }
1050
- }
1051
-
1052
- //#endregion
1053
- export { JSONRpcCoreClient };
1054
- //# sourceMappingURL=core.mjs.map