@mysten/sui 2.39.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/CHANGELOG.md +160 -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 +4 -2
  28. package/dist/client/index.mjs +5 -2
  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 +12 -0
  64. package/dist/client/transaction-data.d.mts.map +1 -0
  65. package/dist/client/transaction-data.mjs +469 -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 +3 -1
  72. package/dist/client/utils.d.mts.map +1 -1
  73. package/dist/client/utils.mjs +91 -26
  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 +2 -2
  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 +293 -117
  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/rpc/v2/error_reason.d.mts +176 -1
  137. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
  138. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
  139. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
  140. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
  141. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  142. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
  143. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
  144. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
  145. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  146. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  147. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
  148. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
  149. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
  150. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
  151. package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
  152. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
  153. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
  154. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
  155. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
  156. package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
  157. package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
  158. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
  159. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
  160. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
  161. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
  162. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  163. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
  164. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
  165. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
  166. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
  167. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  168. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +16 -10
  169. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
  170. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
  171. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
  172. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
  173. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  174. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
  175. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
  176. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
  177. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  178. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  179. package/dist/grpc/proto/types.d.mts +7 -7
  180. package/dist/grpc/proto/types.mjs +3 -2
  181. package/dist/grpc/pull-call.d.mts +20 -0
  182. package/dist/grpc/pull-call.d.mts.map +1 -0
  183. package/dist/grpc/pull-call.mjs +28 -0
  184. package/dist/grpc/pull-call.mjs.map +1 -0
  185. package/dist/grpc/stream/call.mjs +238 -0
  186. package/dist/grpc/stream/call.mjs.map +1 -0
  187. package/dist/grpc/stream/families.d.mts +26 -0
  188. package/dist/grpc/stream/families.d.mts.map +1 -0
  189. package/dist/grpc/stream/families.mjs +145 -0
  190. package/dist/grpc/stream/families.mjs.map +1 -0
  191. package/dist/grpc/stream/index.d.mts +41 -0
  192. package/dist/grpc/stream/index.d.mts.map +1 -0
  193. package/dist/grpc/stream/index.mjs +127 -0
  194. package/dist/grpc/stream/index.mjs.map +1 -0
  195. package/dist/grpc/stream/live.mjs +31 -0
  196. package/dist/grpc/stream/live.mjs.map +1 -0
  197. package/dist/grpc/stream/page.mjs +120 -0
  198. package/dist/grpc/stream/page.mjs.map +1 -0
  199. package/dist/grpc/stream-types.d.mts +28 -0
  200. package/dist/grpc/stream-types.d.mts.map +1 -0
  201. package/dist/grpc/transport.d.mts +8 -3
  202. package/dist/grpc/transport.d.mts.map +1 -1
  203. package/dist/grpc/transport.mjs +88 -45
  204. package/dist/grpc/transport.mjs.map +1 -1
  205. package/dist/jsonRpc/index.d.mts +34 -12
  206. package/dist/jsonRpc/index.d.mts.map +1 -0
  207. package/dist/jsonRpc/index.mjs +39 -5
  208. package/dist/jsonRpc/index.mjs.map +1 -0
  209. package/dist/jsonRpc/types.d.mts +420 -0
  210. package/dist/jsonRpc/types.d.mts.map +1 -0
  211. package/dist/keypairs/passkey/keypair.d.mts +1 -1
  212. package/dist/multisig/publickey.d.mts +12 -4
  213. package/dist/multisig/publickey.d.mts.map +1 -1
  214. package/dist/multisig/publickey.mjs +5 -5
  215. package/dist/multisig/publickey.mjs.map +1 -1
  216. package/dist/multisig/signer.d.mts +1 -1
  217. package/dist/transactions/ObjectCache.d.mts +1 -1
  218. package/dist/transactions/ObjectCache.mjs +5 -5
  219. package/dist/transactions/ObjectCache.mjs.map +1 -1
  220. package/dist/transactions/Transaction.d.mts +11 -10
  221. package/dist/transactions/Transaction.d.mts.map +1 -1
  222. package/dist/transactions/Transaction.mjs +17 -6
  223. package/dist/transactions/Transaction.mjs.map +1 -1
  224. package/dist/transactions/data/internal.d.mts +135 -133
  225. package/dist/transactions/data/internal.d.mts.map +1 -1
  226. package/dist/transactions/data/internal.mjs +2 -1
  227. package/dist/transactions/data/internal.mjs.map +1 -1
  228. package/dist/transactions/data/v1.d.mts +239 -239
  229. package/dist/transactions/data/v1.d.mts.map +1 -1
  230. package/dist/transactions/data/v2.d.mts +16 -16
  231. package/dist/transactions/data/v2.d.mts.map +1 -1
  232. package/dist/transactions/executor/parallel.d.mts +2 -2
  233. package/dist/transactions/executor/serial.d.mts +1 -1
  234. package/dist/transactions/executor/serial.mjs +2 -2
  235. package/dist/transactions/executor/serial.mjs.map +1 -1
  236. package/dist/transactions/index.d.mts +3 -2
  237. package/dist/transactions/index.mjs +4 -3
  238. package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
  239. package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
  240. package/dist/transactions/resolve.d.mts +6 -0
  241. package/dist/transactions/resolve.d.mts.map +1 -1
  242. package/dist/transactions/resolve.mjs.map +1 -1
  243. package/dist/transactions/restricted-move-calls.d.mts +25 -0
  244. package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
  245. package/dist/transactions/restricted-move-calls.mjs +47 -0
  246. package/dist/transactions/restricted-move-calls.mjs.map +1 -0
  247. package/dist/transactions/serializer.d.mts +1 -4
  248. package/dist/transactions/serializer.d.mts.map +1 -1
  249. package/dist/transactions/serializer.mjs +1 -44
  250. package/dist/transactions/serializer.mjs.map +1 -1
  251. package/dist/transactions/utils.d.mts +0 -1
  252. package/dist/transactions/utils.d.mts.map +1 -1
  253. package/dist/transactions/utils.mjs.map +1 -1
  254. package/dist/utils/abort.mjs +89 -0
  255. package/dist/utils/abort.mjs.map +1 -0
  256. package/dist/utils/coin-reservation.mjs +1 -4
  257. package/dist/utils/coin-reservation.mjs.map +1 -1
  258. package/dist/utils/index.mjs +1 -1
  259. package/dist/utils/sui-types.mjs +1 -1
  260. package/dist/verify/index.d.mts +2 -2
  261. package/dist/verify/verify.d.mts +74 -24
  262. package/dist/verify/verify.d.mts.map +1 -1
  263. package/dist/verify/verify.mjs +128 -42
  264. package/dist/verify/verify.mjs.map +1 -1
  265. package/dist/version.mjs +1 -1
  266. package/dist/version.mjs.map +1 -1
  267. package/dist/zklogin/bcs.d.mts +14 -14
  268. package/dist/zklogin/publickey.d.mts.map +1 -1
  269. package/dist/zklogin/publickey.mjs +15 -20
  270. package/dist/zklogin/publickey.mjs.map +1 -1
  271. package/docs/bcs.md +2 -2
  272. package/docs/clients/core.md +19 -18
  273. package/docs/clients/executing.md +53 -8
  274. package/docs/clients/graphql.md +81 -11
  275. package/docs/clients/grpc.md +31 -15
  276. package/docs/clients/index.md +8 -7
  277. package/docs/clients/querying.md +134 -30
  278. package/docs/clients/streaming.md +324 -0
  279. package/docs/cryptography/index.md +85 -58
  280. package/docs/llms-index.md +4 -2
  281. package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
  282. package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
  283. package/docs/migrations/sui-3.0/index.md +250 -0
  284. package/docs/plugins.md +10 -10
  285. package/docs/sdk-building.md +3 -4
  286. package/docs/transactions/coins-and-balances.md +6 -11
  287. package/docs/transactions/reference.md +36 -1
  288. package/package.json +2 -3
  289. package/src/bcs/bcs.ts +80 -41
  290. package/src/bcs/effects.ts +61 -25
  291. package/src/bcs/index.ts +2 -0
  292. package/src/bcs/transactions.ts +36 -17
  293. package/src/bcs/types.ts +10 -4
  294. package/src/client/core-resolver.ts +3 -5
  295. package/src/client/core.ts +180 -8
  296. package/src/client/errors.ts +12 -0
  297. package/src/client/index.ts +4 -1
  298. package/src/client/mvr.ts +37 -10
  299. package/src/client/query-filters.ts +151 -97
  300. package/src/client/stream/adapter.ts +110 -0
  301. package/src/client/stream/errors.ts +40 -0
  302. package/src/client/stream/filter.ts +17 -0
  303. package/src/client/stream/follow.ts +63 -0
  304. package/src/client/stream/index.ts +9 -0
  305. package/src/client/stream/pager.ts +158 -0
  306. package/src/client/stream/plan.ts +147 -0
  307. package/src/client/stream/position.ts +143 -0
  308. package/src/client/stream/run.ts +147 -0
  309. package/src/client/stream/session.ts +259 -0
  310. package/src/client/stream/status.ts +44 -0
  311. package/src/client/stream/token.ts +104 -0
  312. package/src/client/transaction-data.ts +587 -0
  313. package/src/client/transaction-resolver.ts +158 -69
  314. package/src/client/types.ts +530 -115
  315. package/src/client/utils.ts +147 -50
  316. package/src/cryptography/publickey.ts +12 -1
  317. package/src/cryptography/signature.ts +6 -3
  318. package/src/graphql/client.ts +204 -135
  319. package/src/graphql/core.ts +446 -139
  320. package/src/graphql/errors.ts +24 -0
  321. package/src/graphql/filters.ts +48 -0
  322. package/src/graphql/generated/queries.ts +1455 -277
  323. package/src/graphql/generated/schema.graphql +282 -9
  324. package/src/graphql/generated/tada-env.ts +933 -4
  325. package/src/graphql/queries/checkpoints.graphql +34 -0
  326. package/src/graphql/queries/getDynamicFields.graphql +1 -0
  327. package/src/graphql/queries/listEvents.graphql +16 -24
  328. package/src/graphql/queries/streams.graphql +212 -0
  329. package/src/graphql/queries/transactions.graphql +71 -28
  330. package/src/graphql/queries/verifySignature.graphql +17 -0
  331. package/src/graphql/sse-parser.ts +99 -0
  332. package/src/graphql/stream/families.ts +515 -0
  333. package/src/graphql/stream/index.ts +55 -0
  334. package/src/graphql/stream/live.ts +70 -0
  335. package/src/graphql/stream/page.ts +47 -0
  336. package/src/graphql/stream/query.ts +52 -0
  337. package/src/graphql/subscribe.ts +83 -0
  338. package/src/grpc/client.ts +81 -79
  339. package/src/grpc/core.ts +388 -274
  340. package/src/grpc/filters.ts +59 -60
  341. package/src/grpc/grpc-web-pull.ts +360 -0
  342. package/src/grpc/index.ts +5 -0
  343. package/src/grpc/network-error.ts +33 -0
  344. package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
  345. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
  346. package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
  347. package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
  348. package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
  349. package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
  350. package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
  351. package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
  352. package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
  353. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
  354. package/src/grpc/pull-call.ts +54 -0
  355. package/src/grpc/stream/call.ts +317 -0
  356. package/src/grpc/stream/families.ts +228 -0
  357. package/src/grpc/stream/index.ts +182 -0
  358. package/src/grpc/stream/live.ts +33 -0
  359. package/src/grpc/stream/page.ts +161 -0
  360. package/src/grpc/stream-types.ts +33 -0
  361. package/src/grpc/transport.ts +116 -59
  362. package/src/jsonRpc/index.ts +60 -17
  363. package/src/jsonRpc/types.ts +421 -0
  364. package/src/multisig/publickey.ts +19 -7
  365. package/src/transactions/ObjectCache.ts +6 -6
  366. package/src/transactions/Transaction.ts +30 -6
  367. package/src/transactions/data/internal.ts +2 -0
  368. package/src/transactions/executor/serial.ts +2 -2
  369. package/src/transactions/index.ts +8 -1
  370. package/src/transactions/resolve.ts +6 -0
  371. package/src/transactions/restricted-move-calls.ts +87 -0
  372. package/src/transactions/serializer.ts +0 -70
  373. package/src/transactions/utils.ts +0 -37
  374. package/src/utils/abort.ts +101 -0
  375. package/src/verify/index.ts +1 -0
  376. package/src/verify/verify.ts +190 -62
  377. package/src/version.ts +1 -1
  378. package/src/zklogin/publickey.ts +18 -34
  379. package/dist/client/core-resolver.d.mts +0 -9
  380. package/dist/client/core-resolver.d.mts.map +0 -1
  381. package/dist/jsonRpc/client.d.mts +0 -507
  382. package/dist/jsonRpc/client.d.mts.map +0 -1
  383. package/dist/jsonRpc/client.mjs +0 -868
  384. package/dist/jsonRpc/client.mjs.map +0 -1
  385. package/dist/jsonRpc/core.d.mts +0 -168
  386. package/dist/jsonRpc/core.d.mts.map +0 -1
  387. package/dist/jsonRpc/core.mjs +0 -1054
  388. package/dist/jsonRpc/core.mjs.map +0 -1
  389. package/dist/jsonRpc/errors.d.mts +0 -27
  390. package/dist/jsonRpc/errors.d.mts.map +0 -1
  391. package/dist/jsonRpc/errors.mjs +0 -50
  392. package/dist/jsonRpc/errors.mjs.map +0 -1
  393. package/dist/jsonRpc/http-transport.d.mts +0 -62
  394. package/dist/jsonRpc/http-transport.d.mts.map +0 -1
  395. package/dist/jsonRpc/http-transport.mjs +0 -60
  396. package/dist/jsonRpc/http-transport.mjs.map +0 -1
  397. package/dist/jsonRpc/network.d.mts +0 -9
  398. package/dist/jsonRpc/network.d.mts.map +0 -1
  399. package/dist/jsonRpc/network.mjs +0 -18
  400. package/dist/jsonRpc/network.mjs.map +0 -1
  401. package/dist/jsonRpc/types/chain.d.mts +0 -169
  402. package/dist/jsonRpc/types/chain.d.mts.map +0 -1
  403. package/dist/jsonRpc/types/changes.d.mts +0 -48
  404. package/dist/jsonRpc/types/changes.d.mts.map +0 -1
  405. package/dist/jsonRpc/types/coins.d.mts +0 -15
  406. package/dist/jsonRpc/types/coins.d.mts.map +0 -1
  407. package/dist/jsonRpc/types/common.d.mts +0 -9
  408. package/dist/jsonRpc/types/common.d.mts.map +0 -1
  409. package/dist/jsonRpc/types/generated.d.mts +0 -1976
  410. package/dist/jsonRpc/types/generated.d.mts.map +0 -1
  411. package/dist/jsonRpc/types/index.d.mts +0 -6
  412. package/dist/jsonRpc/types/params.d.mts +0 -898
  413. package/dist/jsonRpc/types/params.d.mts.map +0 -1
  414. package/src/graphql/generated/tsconfig.tada.json +0 -11
  415. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
  416. package/src/jsonRpc/client.ts +0 -1252
  417. package/src/jsonRpc/core.ts +0 -1557
  418. package/src/jsonRpc/errors.ts +0 -57
  419. package/src/jsonRpc/http-transport.ts +0 -118
  420. package/src/jsonRpc/network.ts +0 -21
  421. package/src/jsonRpc/types/chain.ts +0 -190
  422. package/src/jsonRpc/types/changes.ts +0 -35
  423. package/src/jsonRpc/types/coins.ts +0 -14
  424. package/src/jsonRpc/types/common.ts +0 -8
  425. package/src/jsonRpc/types/generated.ts +0 -2165
  426. package/src/jsonRpc/types/index.ts +0 -9
  427. package/src/jsonRpc/types/params.ts +0 -908
@@ -1,13 +1,22 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { CoreClient } from '../client/core.js';
4
+ import { CoreClient, type LedgerStreamRequest } from '../client/core.js';
5
+ import type { AnyLedgerStreamAdapter } from '../client/stream/adapter.js';
5
6
  import { raceSignal } from '../client/mvr.js';
6
7
  import type { SuiClientTypes } from '../client/types.js';
8
+ import { grpcTransactionToLedgerTransactionData } from '../client/transaction-data.js';
7
9
  import { SUI_TYPE_ARG } from '../utils/constants.js';
8
- import type { GraphQLQueryOptions, SuiGraphQLClient } from './client.js';
10
+ import type { GraphQLQueryOptions, OpenSubscription, SuiGraphQLClient } from './client.js';
9
11
  import type {
12
+ Checkpoint_FieldsFragment,
13
+ GetTransactionEventsQuery,
14
+ GetTransactionEventsQueryVariables,
15
+ GetTransactionObjectChangesQuery,
16
+ GetTransactionObjectChangesQueryVariables,
17
+ Event_FieldsFragment,
10
18
  Object_Owner_FieldsFragment,
19
+ Transaction_EventFragment,
11
20
  Transaction_FieldsFragment,
12
21
  } from './generated/queries.js';
13
22
 
@@ -24,62 +33,90 @@ import {
24
33
  GetCoinMetadataDocument,
25
34
  GetCoinsDocument,
26
35
  GetCurrentSystemStateDocument,
36
+ GetDynamicFieldsDocument,
27
37
  GetMoveFunctionDocument,
28
38
  GetProtocolConfigDocument,
29
39
  GetOwnedObjectsDocument,
30
40
  GetReferenceGasPriceDocument,
31
41
  GetTransactionBlockDocument,
42
+ GetTransactionEventsDocument,
43
+ GetTransactionObjectChangesDocument,
44
+ ListCheckpointsDocument,
32
45
  ListEventsDocument,
33
46
  ListTransactionsDocument,
34
47
  MultiGetObjectsDocument,
35
48
  ResolveNameServiceAddressDocument,
36
49
  ResolveTransactionDocument,
37
50
  SimulateTransactionDocument,
38
- VerifyZkLoginSignatureDocument,
39
- ZkLoginIntentScope,
51
+ IntentScope,
52
+ VerifySignatureDocument,
40
53
  } from './generated/queries.js';
41
54
  import { ObjectError, SimulationError, TransactionError } from '../client/errors.js';
42
55
  import { chunk, fromBase64, toBase64 } from '@mysten/utils';
43
56
  import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
44
57
  import {
58
+ decodeSignature,
45
59
  formatMoveAbortMessage,
46
60
  isMockedGasObjectId,
47
61
  parseTransactionEffectsBcs,
62
+ resolveVerifySignatureOptions,
48
63
  transactionBytesHaveEmptyGasPayment,
49
64
  } from '../client/utils.js';
50
65
  import type { OpenMoveTypeSignatureBody, OpenMoveTypeSignature } from './types.js';
51
66
  import {
52
67
  transactionDataToGrpcTransaction,
53
68
  transactionToGrpcJson,
54
- grpcTransactionToTransactionData,
55
69
  } from '../client/transaction-resolver.js';
56
70
  import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from '../client/address-balance-transaction-expiration.js';
57
71
  import { BalanceChange as BalanceChangeType } from '../grpc/proto/sui/rpc/v2/balance_change.js';
58
72
  import { TransactionEffects as TransactionEffectsType } from '../grpc/proto/sui/rpc/v2/effects.js';
59
73
  import { Transaction as GrpcTransactionType } from '../grpc/proto/sui/rpc/v2/transaction.js';
74
+ import { isJsonObject } from '@protobuf-ts/runtime';
75
+ import type { EnumInfo, IMessageType, JsonValue } from '@protobuf-ts/runtime';
60
76
  import { TransactionDataBuilder } from '../transactions/TransactionData.js';
61
77
  import type { BuildTransactionOptions } from '../transactions/index.js';
62
78
  import {
79
+ resolveCheckpointRange,
63
80
  resolveEventFilter,
64
81
  resolvePagination,
65
82
  resolveTransactionFilter,
66
- validateTransactionQuery,
67
83
  } from '../client/query-filters.js';
84
+ import {
85
+ toGraphQLCheckpointBounds,
86
+ toGraphQLEventFilter,
87
+ toGraphQLTransactionFilter,
88
+ } from './filters.js';
89
+ import { graphQLLedgerStreamAdapter } from './stream/index.js';
68
90
 
69
91
  const GRAPHQL_OBJECT_BATCH_SIZE = 40;
70
92
 
71
93
  export class GraphQLCoreClient extends CoreClient {
72
94
  #graphqlClient: SuiGraphQLClient;
95
+ #subscribe: OpenSubscription;
73
96
 
74
97
  constructor({
75
98
  graphqlClient,
76
99
  mvr,
100
+ restrictedMoveCalls,
101
+ subscribe,
77
102
  }: {
78
103
  graphqlClient: SuiGraphQLClient;
79
104
  mvr?: SuiClientTypes.MvrOptions;
105
+ restrictedMoveCalls?: readonly string[];
106
+ subscribe: OpenSubscription;
80
107
  }) {
81
- super({ network: graphqlClient.network, base: graphqlClient, mvr });
108
+ super({ network: graphqlClient.network, base: graphqlClient, mvr, restrictedMoveCalls });
82
109
  this.#graphqlClient = graphqlClient;
110
+ this.#subscribe = subscribe;
111
+ }
112
+
113
+ protected override createLedgerStreamAdapter(
114
+ request: LedgerStreamRequest,
115
+ ): AnyLedgerStreamAdapter {
116
+ return graphQLLedgerStreamAdapter(
117
+ { client: this.#graphqlClient, subscribe: this.#subscribe, mvr: this.mvr },
118
+ request,
119
+ );
83
120
  }
84
121
 
85
122
  async #graphqlQuery<
@@ -104,6 +141,15 @@ export class GraphQLCoreClient extends CoreClient {
104
141
  return extractedData as NonNullable<Data>;
105
142
  }
106
143
 
144
+ #withAllPages(transaction: Transaction_FieldsFragment, signal?: AbortSignal) {
145
+ return withAllPages(transaction, {
146
+ events: (variables) =>
147
+ this.#graphqlQuery({ query: GetTransactionEventsDocument, variables, signal }),
148
+ objectChanges: (variables) =>
149
+ this.#graphqlQuery({ query: GetTransactionObjectChangesDocument, variables, signal }),
150
+ });
151
+ }
152
+
107
153
  async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
108
154
  options: SuiClientTypes.GetObjectsOptions<Include>,
109
155
  ): Promise<SuiClientTypes.GetObjectsResponse<Include>> {
@@ -379,19 +425,14 @@ export class GraphQLCoreClient extends CoreClient {
379
425
  signal: options.signal,
380
426
  variables: {
381
427
  digest: options.digest,
382
- includeTransaction: options.include?.transaction ?? false,
383
- includeEffects: options.include?.effects ?? false,
384
- includeEvents: options.include?.events ?? false,
385
- includeBalanceChanges: options.include?.balanceChanges ?? false,
386
- includeObjectTypes: options.include?.objectTypes ?? false,
387
- includeBcs: options.include?.bcs ?? false,
428
+ ...transactionIncludeVariables(options.include),
388
429
  },
389
430
  },
390
431
  (result) => result.transaction,
391
432
  () => new TransactionError('notFound', options.digest),
392
433
  );
393
434
 
394
- return parseTransaction(result, options.include);
435
+ return parseTransaction(await this.#withAllPages(result, options.signal), options.include);
395
436
  }
396
437
  async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
397
438
  options: SuiClientTypes.ExecuteTransactionOptions<Include>,
@@ -403,12 +444,7 @@ export class GraphQLCoreClient extends CoreClient {
403
444
  variables: {
404
445
  transactionDataBcs: toBase64(options.transaction),
405
446
  signatures: options.signatures,
406
- includeTransaction: options.include?.transaction ?? false,
407
- includeEffects: options.include?.effects ?? false,
408
- includeEvents: options.include?.events ?? false,
409
- includeBalanceChanges: options.include?.balanceChanges ?? false,
410
- includeObjectTypes: options.include?.objectTypes ?? false,
411
- includeBcs: options.include?.bcs ?? false,
447
+ ...transactionIncludeVariables(options.include),
412
448
  },
413
449
  },
414
450
  (result) => result.executeTransaction,
@@ -417,7 +453,7 @@ export class GraphQLCoreClient extends CoreClient {
417
453
  return parseTransaction(result.effects?.transaction!, options.include);
418
454
  }
419
455
  async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
420
- options: SuiClientTypes.SimulateTransactionOptions<Include> & { doGasSelection?: boolean },
456
+ options: SuiClientTypes.SimulateTransactionOptions<Include>,
421
457
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
422
458
  if (!(options.transaction instanceof Uint8Array)) {
423
459
  await options.transaction.prepareForSerialization({ client: this });
@@ -445,13 +481,8 @@ export class GraphQLCoreClient extends CoreClient {
445
481
  },
446
482
  }
447
483
  : transactionToGrpcJson(options.transaction),
448
- includeTransaction: options.include?.transaction ?? false,
449
- includeEffects: options.include?.effects ?? false,
450
- includeEvents: options.include?.events ?? false,
451
- includeBalanceChanges: options.include?.balanceChanges ?? false,
452
- includeObjectTypes: options.include?.objectTypes ?? false,
484
+ ...transactionIncludeVariables(options.include),
453
485
  includeCommandResults: options.include?.commandResults ?? false,
454
- includeBcs: options.include?.bcs ?? false,
455
486
  doGasSelection,
456
487
  checksEnabled: options.checksEnabled ?? true,
457
488
  },
@@ -643,61 +674,113 @@ export class GraphQLCoreClient extends CoreClient {
643
674
  };
644
675
  }
645
676
 
646
- async listDynamicFields(
647
- options: SuiClientTypes.ListDynamicFieldsOptions,
648
- ): Promise<SuiClientTypes.ListDynamicFieldsResponse> {
649
- return this.#graphqlClient.listDynamicFields(options);
677
+ async listDynamicFields<Include extends SuiClientTypes.DynamicFieldInclude = {}>(
678
+ options: SuiClientTypes.ListDynamicFieldsOptions<Include>,
679
+ ): Promise<SuiClientTypes.ListDynamicFieldsResponse<Include>> {
680
+ const includeValue = options.include?.value ?? false;
681
+
682
+ const result = await this.#graphqlQuery(
683
+ {
684
+ query: GetDynamicFieldsDocument,
685
+ signal: options.signal,
686
+ variables: {
687
+ parentId: options.parentId,
688
+ first: options.limit,
689
+ cursor: options.cursor,
690
+ includeValue,
691
+ },
692
+ },
693
+ (result) => result.address?.dynamicFields,
694
+ );
695
+
696
+ return {
697
+ dynamicFields: result.nodes.map((dynamicField) => {
698
+ const nameType = dynamicField.name?.type?.repr!;
699
+ const isDynamicObject = dynamicField.value?.__typename === 'MoveObject';
700
+ const valueType =
701
+ dynamicField.value?.__typename === 'MoveObject'
702
+ ? dynamicField.value.contents?.type?.repr!
703
+ : dynamicField.value?.type?.repr!;
704
+ const fieldType = isDynamicObject
705
+ ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${nameType}>,0x2::object::ID>`
706
+ : `0x2::dynamic_field::Field<${nameType},${valueType}>`;
707
+
708
+ let value: SuiClientTypes.DynamicFieldValue | undefined;
709
+ if (includeValue) {
710
+ const valueBcs =
711
+ dynamicField.value?.__typename === 'MoveObject'
712
+ ? dynamicField.value.contents?.bcs
713
+ : dynamicField.value?.__typename === 'MoveValue'
714
+ ? dynamicField.value.bcs
715
+ : null;
716
+ if (valueBcs == null) {
717
+ throw new Error(`Missing value for dynamic field ${dynamicField.address}`);
718
+ }
719
+ value = { type: valueType, bcs: fromBase64(valueBcs) };
720
+ }
721
+
722
+ return {
723
+ $kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
724
+ fieldId: dynamicField.address,
725
+ type: normalizeStructTag(fieldType),
726
+ name: {
727
+ type: nameType,
728
+ bcs: fromBase64(dynamicField.name?.bcs!),
729
+ },
730
+ valueType,
731
+ childId:
732
+ dynamicField.value?.__typename === 'MoveObject'
733
+ ? dynamicField.value.address
734
+ : undefined,
735
+ value,
736
+ } as SuiClientTypes.DynamicFieldEntry<Include>;
737
+ }),
738
+ cursor: result.pageInfo.endCursor ?? null,
739
+ hasNextPage: result.pageInfo.hasNextPage,
740
+ };
650
741
  }
651
742
 
652
743
  async listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
653
744
  options: SuiClientTypes.ListTransactionsOptions<Include>,
654
745
  ): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
655
- const pagination = resolvePagination(options);
656
- const { descending, after, before, limit } = pagination;
746
+ const { descending, after, before, limit } = resolvePagination(options);
747
+ const range = resolveCheckpointRange(options);
657
748
  const filter = options.filter
658
749
  ? await resolveTransactionFilter(this.mvr, options.filter, options.signal)
659
750
  : undefined;
660
- validateTransactionQuery(filter, pagination);
751
+ const graphqlFilter = toGraphQLTransactionFilter(filter, range);
661
752
 
662
753
  const transactions = await this.#graphqlQuery(
663
754
  {
664
755
  query: ListTransactionsDocument,
665
756
  signal: options.signal,
666
757
  variables: {
667
- filter: filter && {
668
- sentAddress: filter.$kind === 'sender' ? filter.sender : undefined,
669
- function:
670
- filter.$kind === 'function'
671
- ? [filter.package, filter.module, filter.function].filter(Boolean).join('::')
672
- : undefined,
673
- },
758
+ filter: graphqlFilter,
674
759
  first: descending ? undefined : limit,
675
760
  after,
676
761
  last: descending ? limit : undefined,
677
762
  before,
678
- includeTransaction: options.include?.transaction ?? false,
679
- includeEffects: options.include?.effects ?? false,
680
- includeEvents: options.include?.events ?? false,
681
- includeBalanceChanges: options.include?.balanceChanges ?? false,
682
- includeObjectTypes: options.include?.objectTypes ?? false,
683
- includeBcs: options.include?.bcs ?? false,
763
+ ...transactionIncludeVariables(options.include),
684
764
  },
685
765
  },
686
766
  (result) => result.transactions,
687
767
  );
688
768
 
689
769
  // Backwards pagination returns nodes in ascending order, so reverse them for descending reads
690
- const nodes = descending ? [...transactions.nodes].reverse() : transactions.nodes;
770
+ const nodes = transactions.edges.map((edge) => edge.node);
771
+ if (descending) nodes.reverse();
772
+
773
+ // One transaction at a time, so a page can't start dozens of nested reads at once
774
+ const completed = [];
775
+ for (const transaction of nodes) {
776
+ completed.push(
777
+ parseTransaction(await this.#withAllPages(transaction, options.signal), options.include),
778
+ );
779
+ }
691
780
 
692
781
  return {
693
- transactions: nodes.map((transaction) => parseTransaction(transaction, options.include)),
694
- hasNextPage: descending
695
- ? transactions.pageInfo.hasPreviousPage
696
- : transactions.pageInfo.hasNextPage,
697
- startCursor:
698
- (descending ? transactions.pageInfo.endCursor : transactions.pageInfo.startCursor) ?? null,
699
- endCursor:
700
- (descending ? transactions.pageInfo.startCursor : transactions.pageInfo.endCursor) ?? null,
782
+ transactions: completed,
783
+ ...listPageCursors(transactions, descending),
701
784
  };
702
785
  }
703
786
 
@@ -705,26 +788,18 @@ export class GraphQLCoreClient extends CoreClient {
705
788
  options: SuiClientTypes.ListEventsOptions,
706
789
  ): Promise<SuiClientTypes.ListEventsResponse> {
707
790
  const { descending, after, before, limit } = resolvePagination(options);
791
+ const range = resolveCheckpointRange(options);
708
792
  const filter = options.filter
709
793
  ? await resolveEventFilter(this.mvr, options.filter, options.signal)
710
794
  : undefined;
795
+ const graphqlFilter = toGraphQLEventFilter(filter, range);
711
796
 
712
797
  const events = await this.#graphqlQuery(
713
798
  {
714
799
  query: ListEventsDocument,
715
800
  signal: options.signal,
716
801
  variables: {
717
- filter: filter && {
718
- sender: filter.$kind === 'sender' ? filter.sender : undefined,
719
- module:
720
- filter.$kind === 'emitModule' ? `${filter.package}::${filter.module}` : undefined,
721
- type:
722
- filter.$kind === 'eventTypeModule'
723
- ? `${filter.package}::${filter.module}`
724
- : filter.$kind === 'eventType'
725
- ? filter.eventType
726
- : undefined,
727
- },
802
+ filter: graphqlFilter,
728
803
  first: descending ? undefined : limit,
729
804
  after,
730
805
  last: descending ? limit : undefined,
@@ -735,61 +810,94 @@ export class GraphQLCoreClient extends CoreClient {
735
810
  );
736
811
 
737
812
  // Backwards pagination returns nodes in ascending order, so reverse them for descending reads
738
- const nodes = descending ? [...events.nodes].reverse() : events.nodes;
813
+ const nodes = events.edges.map((edge) => edge.node);
814
+ if (descending) nodes.reverse();
739
815
 
740
816
  return {
741
- events: nodes.map((event): SuiClientTypes.EventEntry => {
742
- const packageId = event.transactionModule?.package?.address;
743
- const module = event.transactionModule?.name;
744
- const sender = event.sender?.address;
745
- const eventType = event.contents?.type?.repr;
746
- const transactionDigest = event.transaction?.digest;
747
-
748
- if (!packageId || !module || !sender || !eventType || !transactionDigest) {
749
- throw new Error('listEvents response is missing expected event fields');
750
- }
751
-
752
- return {
753
- packageId: normalizeSuiAddress(packageId),
754
- module,
755
- sender: normalizeSuiAddress(sender),
756
- eventType: normalizeStructTag(eventType),
757
- bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
758
- json: (event.contents?.json as Record<string, unknown>) ?? null,
759
- checkpoint: event.transaction?.effects?.checkpoint?.sequenceNumber?.toString() ?? null,
760
- transactionDigest,
761
- eventIndex: event.sequenceNumber,
762
- };
817
+ events: nodes.map((event) => {
818
+ const checkpoint = event.transaction?.effects?.checkpoint?.sequenceNumber;
819
+ return parseGraphQLEvent(
820
+ event,
821
+ checkpoint == null ? null : String(checkpoint),
822
+ 'listEvents',
823
+ );
763
824
  }),
764
- hasNextPage: descending ? events.pageInfo.hasPreviousPage : events.pageInfo.hasNextPage,
765
- startCursor: (descending ? events.pageInfo.endCursor : events.pageInfo.startCursor) ?? null,
766
- endCursor: (descending ? events.pageInfo.startCursor : events.pageInfo.endCursor) ?? null,
825
+ ...listPageCursors(events, descending),
826
+ };
827
+ }
828
+
829
+ async listCheckpoints(
830
+ options: SuiClientTypes.ListCheckpointsOptions,
831
+ ): Promise<SuiClientTypes.ListCheckpointsResponse> {
832
+ const { descending, after, before, limit } = resolvePagination(options);
833
+ const filter = toGraphQLCheckpointBounds(resolveCheckpointRange(options));
834
+
835
+ const checkpoints = await this.#graphqlQuery(
836
+ {
837
+ query: ListCheckpointsDocument,
838
+ signal: options.signal,
839
+ variables: {
840
+ filter,
841
+ first: descending ? undefined : limit,
842
+ after,
843
+ last: descending ? limit : undefined,
844
+ before,
845
+ },
846
+ },
847
+ (result) => result.checkpoints,
848
+ );
849
+
850
+ // Backwards pagination returns nodes in ascending order, so reverse them for descending reads
851
+ const nodes = checkpoints.edges.map((edge) => edge.node);
852
+ if (descending) nodes.reverse();
853
+
854
+ return {
855
+ checkpoints: nodes.map((checkpoint) => parseGraphQLCheckpoint(checkpoint, 'listCheckpoints')),
856
+ ...listPageCursors(checkpoints, descending),
767
857
  };
768
858
  }
769
859
 
770
- async verifyZkLoginSignature(
771
- options: SuiClientTypes.VerifyZkLoginSignatureOptions,
772
- ): Promise<SuiClientTypes.ZkLoginVerifyResponse> {
773
- const intentScope =
774
- options.intentScope === 'TransactionData'
775
- ? ZkLoginIntentScope.TransactionData
776
- : ZkLoginIntentScope.PersonalMessage;
860
+ async verifySignature(
861
+ options: SuiClientTypes.VerifySignatureOptions,
862
+ ): Promise<SuiClientTypes.VerifySignatureResponse> {
863
+ const { intentScope, message, address, checkAddressAliases } =
864
+ resolveVerifySignatureOptions(options);
865
+ const signature = decodeSignature(options.signature);
866
+ if (!signature) {
867
+ return { valid: false, reason: 'Cannot parse signature' };
868
+ }
777
869
 
778
- const { data } = await this.#graphqlClient.query({
779
- query: VerifyZkLoginSignatureDocument,
870
+ const { data, errors } = await this.#graphqlClient.query({
871
+ query: VerifySignatureDocument,
780
872
  signal: options.signal,
781
873
  variables: {
782
- bytes: options.bytes,
783
- signature: options.signature,
784
- intentScope,
785
- author: options.address,
874
+ message: toBase64(message),
875
+ signature: toBase64(signature),
876
+ intentScope:
877
+ intentScope === 'TransactionData'
878
+ ? IntentScope.TransactionData
879
+ : IntentScope.PersonalMessage,
880
+ author: address,
881
+ checkAddressAliases,
786
882
  },
787
883
  });
788
884
 
789
- return {
790
- success: data?.verifyZkLoginSignature?.success ?? false,
791
- errors: [],
792
- };
885
+ // The server reports an invalid signature, a signer outside the alias set and undecodable
886
+ // transaction bytes as bad user input on the field.
887
+ const failure = errors?.find(
888
+ (error) =>
889
+ error.path?.[0] === 'verifySignature' && error.extensions?.code === 'BAD_USER_INPUT',
890
+ );
891
+ if (failure) {
892
+ return { valid: false, reason: failure.message };
893
+ }
894
+ handleGraphQLErrors(errors);
895
+
896
+ const success = data?.verifySignature?.success;
897
+ if (typeof success !== 'boolean') {
898
+ throw new Error('The node returned no signature verification verdict');
899
+ }
900
+ return success ? { valid: true } : { valid: false, reason: 'Signature is not valid' };
793
901
  }
794
902
 
795
903
  async defaultNameServiceName(
@@ -992,6 +1100,7 @@ export type GraphQLResponseErrors = Array<{
992
1100
  message: string;
993
1101
  locations?: { line: number; column: number }[];
994
1102
  path?: (string | number)[];
1103
+ extensions?: { code?: unknown };
995
1104
  }>;
996
1105
 
997
1106
  function mapDisplay(
@@ -1051,7 +1160,147 @@ function mapOwner(owner: Object_Owner_FieldsFragment): SuiClientTypes.ObjectOwne
1051
1160
  }
1052
1161
  }
1053
1162
 
1054
- function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
1163
+ /** `source` names the response in the error thrown when required fields are missing. */
1164
+ export function parseGraphQLCheckpoint(
1165
+ checkpoint: Checkpoint_FieldsFragment,
1166
+ source: string,
1167
+ ): SuiClientTypes.Checkpoint {
1168
+ const timestampMs = checkpoint.timestamp ? Date.parse(checkpoint.timestamp) : NaN;
1169
+ const epoch = checkpoint.epoch?.epochId;
1170
+
1171
+ if (!checkpoint.digest || Number.isNaN(timestampMs) || epoch == null) {
1172
+ throw new Error(`${source} response is missing expected checkpoint fields`);
1173
+ }
1174
+
1175
+ return {
1176
+ sequenceNumber: String(checkpoint.sequenceNumber),
1177
+ digest: checkpoint.digest,
1178
+ epoch: String(epoch),
1179
+ timestampMs,
1180
+ };
1181
+ }
1182
+
1183
+ /** `source` names the response in the error thrown when required fields are missing. */
1184
+ function parseGraphQLEventFields(
1185
+ event: Transaction_EventFragment,
1186
+ source: string,
1187
+ ): SuiClientTypes.Event {
1188
+ const packageId = event.transactionModule?.package?.address;
1189
+ const module = event.transactionModule?.name;
1190
+ const eventType = event.contents?.type?.repr;
1191
+
1192
+ if (!packageId || !module || !eventType) {
1193
+ throw new Error(`${source} response is missing expected event fields`);
1194
+ }
1195
+
1196
+ return {
1197
+ packageId: normalizeSuiAddress(packageId),
1198
+ module,
1199
+ // System transactions have no sender; gRPC reports the zero address for their events.
1200
+ sender: normalizeSuiAddress(event.sender?.address ?? '0x0'),
1201
+ eventType: normalizeStructTag(eventType),
1202
+ bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
1203
+ json: (event.contents?.json as Record<string, unknown>) ?? null,
1204
+ };
1205
+ }
1206
+
1207
+ /** `source` names the response in the error thrown when required fields are missing. */
1208
+ export function parseGraphQLEvent(
1209
+ event: Event_FieldsFragment,
1210
+ checkpoint: string | null,
1211
+ source: string,
1212
+ ): SuiClientTypes.EventEntry {
1213
+ const transactionDigest = event.transaction?.digest;
1214
+ if (!transactionDigest || checkpoint == null) {
1215
+ throw new Error(`${source} response is missing expected event fields`);
1216
+ }
1217
+
1218
+ return {
1219
+ ...parseGraphQLEventFields(event, source),
1220
+ checkpoint,
1221
+ transactionDigest,
1222
+ eventIndex: event.sequenceNumber,
1223
+ };
1224
+ }
1225
+
1226
+ /** `TRANSACTION_FIELDS` variables for `include`, shared so every query selects the same fields. */
1227
+ export function transactionIncludeVariables(include: SuiClientTypes.TransactionInclude = {}) {
1228
+ return {
1229
+ includeTransaction: include.transaction ?? false,
1230
+ includeEffects: include.effects ?? false,
1231
+ includeEvents: include.events ?? false,
1232
+ includeBalanceChanges: include.balanceChanges ?? false,
1233
+ includeObjectTypes: include.objectTypes ?? false,
1234
+ includeBcs: include.bcs ?? false,
1235
+ };
1236
+ }
1237
+
1238
+ export interface TransactionPageReaders {
1239
+ events: (variables: GetTransactionEventsQueryVariables) => Promise<GetTransactionEventsQuery>;
1240
+ objectChanges: (
1241
+ variables: GetTransactionObjectChangesQueryVariables,
1242
+ ) => Promise<GetTransactionObjectChangesQuery>;
1243
+ }
1244
+
1245
+ /** Page size of the events and object changes nested in `TRANSACTION_FIELDS`. */
1246
+ const NESTED_PAGE_SIZE = 50;
1247
+
1248
+ /**
1249
+ * The transaction with all of its events and object changes. The nested lists carry no page info,
1250
+ * which keeps checkpoint scans under the service's output-node limit, so a full nested list is read
1251
+ * again by digest, to the end.
1252
+ */
1253
+ export async function withAllPages(
1254
+ transaction: Transaction_FieldsFragment,
1255
+ read: TransactionPageReaders,
1256
+ ): Promise<Transaction_FieldsFragment> {
1257
+ const effects = transaction.effects;
1258
+ const full = (list?: { nodes: unknown[] } | null) => list?.nodes.length === NESTED_PAGE_SIZE;
1259
+ if (!full(effects?.events) && !full(effects?.objectChanges)) {
1260
+ return transaction;
1261
+ }
1262
+ const { digest } = transaction;
1263
+ const [events, objectChanges] = await Promise.all([
1264
+ full(effects!.events)
1265
+ ? readAll(digest, async (after) => {
1266
+ const data = await read.events({ digest, after });
1267
+ return data.transaction?.effects?.events;
1268
+ })
1269
+ : effects!.events,
1270
+ full(effects!.objectChanges)
1271
+ ? readAll(digest, async (after) => {
1272
+ const data = await read.objectChanges({ digest, after });
1273
+ return data.transaction?.effects?.objectChanges;
1274
+ })
1275
+ : effects!.objectChanges,
1276
+ ]);
1277
+ return { ...transaction, effects: { ...effects!, events, objectChanges } };
1278
+ }
1279
+
1280
+ async function readAll<Node>(
1281
+ digest: string,
1282
+ next: (
1283
+ after: string | null,
1284
+ ) => Promise<
1285
+ | { pageInfo: { hasNextPage: boolean; endCursor?: string | null }; nodes: Node[] }
1286
+ | null
1287
+ | undefined
1288
+ >,
1289
+ ): Promise<{ nodes: Node[] }> {
1290
+ const nodes: Node[] = [];
1291
+ let after: string | null = null;
1292
+ for (;;) {
1293
+ const page = await next(after);
1294
+ if (!page) {
1295
+ throw new Error(`Missing a page of transaction ${digest}`);
1296
+ }
1297
+ nodes.push(...page.nodes);
1298
+ if (!page.pageInfo.hasNextPage || page.nodes.length === 0) return { nodes };
1299
+ after = page.pageInfo.endCursor ?? null;
1300
+ }
1301
+ }
1302
+
1303
+ export function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
1055
1304
  transaction: Transaction_FieldsFragment,
1056
1305
  include?: Include,
1057
1306
  ): SuiClientTypes.TransactionResult<Include> {
@@ -1062,6 +1311,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1062
1311
  if (effectsJson) {
1063
1312
  const effects = TransactionEffectsType.fromJson(
1064
1313
  effectsJson as Parameters<typeof TransactionEffectsType.fromJson>[0],
1314
+ { ignoreUnknownFields: true },
1065
1315
  );
1066
1316
  effects.changedObjects?.forEach((change) => {
1067
1317
  if (change.objectId && change.objectType) {
@@ -1088,6 +1338,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1088
1338
  balanceChanges = balanceChangesJson.map((json) => {
1089
1339
  const change = BalanceChangeType.fromJson(
1090
1340
  json as Parameters<typeof BalanceChangeType.fromJson>[0],
1341
+ { ignoreUnknownFields: true },
1091
1342
  );
1092
1343
  return {
1093
1344
  coinType: change.coinType!,
@@ -1110,19 +1361,17 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1110
1361
  };
1111
1362
 
1112
1363
  let transactionData: SuiClientTypes.TransactionData | undefined;
1113
- if (include?.transaction && transaction.transactionJson) {
1114
- const grpcTx = GrpcTransactionType.fromJson(
1115
- transaction.transactionJson as Parameters<typeof GrpcTransactionType.fromJson>[0],
1364
+ if (include?.transaction) {
1365
+ if (!transaction.transactionJson) {
1366
+ throw new Error('Transaction data is required but missing from GraphQL response');
1367
+ }
1368
+ // `transactionJson` is the gRPC JSON encoding. Unknown fields are ignored, as binary decoding
1369
+ // ignores them over gRPC.
1370
+ const grpcTransaction = GrpcTransactionType.fromJson(
1371
+ unknownEnumsAsNumbers(GrpcTransactionType, transaction.transactionJson as JsonValue),
1372
+ { ignoreUnknownFields: true },
1116
1373
  );
1117
- const resolved = grpcTransactionToTransactionData(grpcTx);
1118
- transactionData = {
1119
- gasData: resolved.gasData,
1120
- sender: resolved.sender,
1121
- expiration: resolved.expiration,
1122
- commands: resolved.commands,
1123
- inputs: resolved.inputs,
1124
- version: resolved.version,
1125
- };
1374
+ transactionData = grpcTransactionToLedgerTransactionData(grpcTransaction);
1126
1375
  }
1127
1376
 
1128
1377
  const bcsBytes =
@@ -1133,6 +1382,8 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1133
1382
 
1134
1383
  const result: SuiClientTypes.Transaction<Include> = {
1135
1384
  digest: transaction.digest!,
1385
+ // System transactions have no sender over GraphQL; gRPC reports them as 0x0.
1386
+ sender: normalizeSuiAddress(transaction.sender?.address ?? '0x0'),
1136
1387
  status,
1137
1388
  effects: (include?.effects
1138
1389
  ? parseTransactionEffectsBcs(fromBase64(transaction.effects?.effectsBcs!))
@@ -1148,18 +1399,9 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1148
1399
  signatures: transaction.signatures.map((sig) => sig.signatureBytes!),
1149
1400
  balanceChanges: balanceChanges as SuiClientTypes.Transaction<Include>['balanceChanges'],
1150
1401
  events: (include?.events
1151
- ? (transaction.effects?.events?.nodes.map((event) => {
1152
- const eventType = event.contents?.type?.repr!;
1153
- const [packageId, module] = eventType.split('::');
1154
- return {
1155
- packageId,
1156
- module,
1157
- sender: event.sender?.address!,
1158
- eventType,
1159
- bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
1160
- json: (event.contents?.json as Record<string, unknown>) ?? null,
1161
- };
1162
- }) ?? [])
1402
+ ? (transaction.effects?.events?.nodes.map((event) =>
1403
+ parseGraphQLEventFields(event, 'Transaction'),
1404
+ ) ?? [])
1163
1405
  : undefined) as SuiClientTypes.Transaction<Include>['events'],
1164
1406
  };
1165
1407
 
@@ -1168,6 +1410,34 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1168
1410
  : { $kind: 'FailedTransaction', Transaction: undefined as never, FailedTransaction: result };
1169
1411
  }
1170
1412
 
1413
+ /**
1414
+ * Replaces each enum string this SDK does not know with an unknown number, which is what binary
1415
+ * decoding gives over gRPC, so the shared mapper treats it the same way. A lenient JSON parse would
1416
+ * drop it, and the mapper would then read the field's default.
1417
+ */
1418
+ function unknownEnumsAsNumbers(type: IMessageType<object>, json: JsonValue): JsonValue {
1419
+ if (!isJsonObject(json) || type.typeName.startsWith('google.protobuf.')) return json;
1420
+ const result = { ...json };
1421
+ for (const field of type.fields) {
1422
+ const key = field.jsonName in json ? field.jsonName : field.localName;
1423
+ const value = json[key];
1424
+ if (value == null) continue;
1425
+ const map = (item: JsonValue): JsonValue =>
1426
+ field.kind === 'message'
1427
+ ? unknownEnumsAsNumbers(field.T(), item)
1428
+ : field.kind === 'enum' && typeof item === 'string' && !isKnownEnum(field.T(), item)
1429
+ ? -1
1430
+ : item;
1431
+ result[key] = Array.isArray(value) ? value.map(map) : map(value);
1432
+ }
1433
+ return result;
1434
+ }
1435
+
1436
+ function isKnownEnum([, values, prefix]: EnumInfo, name: string) {
1437
+ const local = prefix && name.startsWith(prefix) ? name.slice(prefix.length) : name;
1438
+ return typeof (values as Record<string, unknown>)[local] === 'number';
1439
+ }
1440
+
1171
1441
  function parseNormalizedSuiMoveType(type: OpenMoveTypeSignature): SuiClientTypes.OpenSignature {
1172
1442
  let reference: 'mutable' | 'immutable' | null = null;
1173
1443
 
@@ -1187,12 +1457,13 @@ function parseGraphQLExecutionError(
1187
1457
  executionError: GraphQLExecutionError | null | undefined,
1188
1458
  ): SuiClientTypes.ExecutionError {
1189
1459
  const name = mapGraphQLExecutionErrorKind(executionError);
1460
+ // The GraphQL schema has no field for the failing command; it is only in the message ("in 3rd command").
1461
+ const commandMatch = executionError?.message?.match(/in (\d+)\w* command/);
1462
+ const command = commandMatch ? parseInt(commandMatch[1], 10) - 1 : undefined;
1190
1463
 
1191
1464
  if (name === 'MoveAbort' && executionError?.abortCode != null) {
1192
1465
  const location = parseGraphQLMoveLocation(executionError);
1193
1466
  const cleverError = parseGraphQLCleverError(executionError);
1194
- const commandMatch = executionError.message?.match(/in (\d+)\w* command/);
1195
- const command = commandMatch ? parseInt(commandMatch[1], 10) - 1 : undefined;
1196
1467
 
1197
1468
  return {
1198
1469
  $kind: 'MoveAbort',
@@ -1227,6 +1498,7 @@ function parseGraphQLExecutionError(
1227
1498
  return {
1228
1499
  $kind: 'Unknown',
1229
1500
  message: executionError?.message ?? 'Transaction failed',
1501
+ command,
1230
1502
  Unknown: null,
1231
1503
  };
1232
1504
  }
@@ -1261,12 +1533,17 @@ function parseGraphQLMoveLocation(
1261
1533
  function parseGraphQLCleverError(
1262
1534
  executionError: GraphQLExecutionError,
1263
1535
  ): SuiClientTypes.CleverError | undefined {
1264
- const hasCleverError = executionError.identifier || executionError.constant;
1265
- if (!hasCleverError) {
1536
+ // The server reports a source line only when it resolved a clever error.
1537
+ if (executionError.sourceLineNumber == null) {
1266
1538
  return undefined;
1267
1539
  }
1268
1540
 
1541
+ // For a clever error that declares a code, the server reports that code (a u8) as the
1542
+ // abort code; otherwise the abort code is the raw clever error bitset.
1543
+ const abortCode = BigInt(executionError.abortCode!);
1544
+
1269
1545
  return {
1546
+ errorCode: abortCode <= 255n ? Number(abortCode) : undefined,
1270
1547
  constantName: executionError.identifier ?? undefined,
1271
1548
  value: executionError.constant ?? undefined,
1272
1549
  lineNumber: executionError.sourceLineNumber ?? undefined,
@@ -1325,3 +1602,33 @@ function parseNormalizedSuiMoveTypeBody(
1325
1602
 
1326
1603
  throw new Error(`Unknown type: ${JSON.stringify(type)}`);
1327
1604
  }
1605
+
1606
+ /**
1607
+ * Page cursors for the list queries, matching the gRPC client: a page that can continue resumes
1608
+ * from the server's cursor (which may be a scan position past the last item), a final page ends at
1609
+ * its last item, and an empty final page has no cursors.
1610
+ */
1611
+ function listPageCursors(
1612
+ connection: {
1613
+ pageInfo: {
1614
+ hasNextPage: boolean;
1615
+ hasPreviousPage: boolean;
1616
+ startCursor?: string | null;
1617
+ endCursor?: string | null;
1618
+ };
1619
+ edges: { cursor: string }[];
1620
+ },
1621
+ descending: boolean,
1622
+ ) {
1623
+ const { pageInfo } = connection;
1624
+ const edges = descending ? [...connection.edges].reverse() : connection.edges;
1625
+ const resumeFrom = (descending ? pageInfo.startCursor : pageInfo.endCursor) ?? null;
1626
+ const hasNextPage =
1627
+ resumeFrom !== null && (descending ? pageInfo.hasPreviousPage : pageInfo.hasNextPage);
1628
+
1629
+ return {
1630
+ hasNextPage,
1631
+ startCursor: edges[0]?.cursor ?? null,
1632
+ endCursor: hasNextPage ? resumeFrom : (edges.at(-1)?.cursor ?? null),
1633
+ };
1634
+ }