@mysten/sui 2.39.0 → 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 +162 -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 +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 +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/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.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/name_service.client.d.mts +4 -4
  152. package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
  153. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
  154. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
  155. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
  156. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
  157. package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
  158. package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
  159. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
  160. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
  161. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
  162. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
  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 +20 -14
  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 +14 -13
  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 +3 -4
  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
@@ -88,19 +88,17 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
88
88
  * Verifies that the signature is valid for for the provided message
89
89
  */
90
90
  async verify(_message, _signature) {
91
- throw Error("does not support");
91
+ throw new Error("zkLogin signatures can only be verified for personal messages and transactions");
92
92
  }
93
93
  /**
94
94
  * Verifies that the signature is valid for for the provided PersonalMessage
95
95
  */
96
96
  verifyPersonalMessage(message, signature) {
97
97
  const parsedSignature = parseSerializedZkLoginSignature(signature);
98
- return graphqlVerifyZkLoginSignature({
98
+ return verifyOnNode(this.#client, {
99
99
  address: this.toSuiAddress(),
100
- bytes: toBase64(message),
101
- signature: parsedSignature.serializedSignature,
102
- intentScope: "PersonalMessage",
103
- client: this.#client
100
+ personalMessage: message,
101
+ signature: parsedSignature.serializedSignature
104
102
  });
105
103
  }
106
104
  /**
@@ -108,19 +106,18 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
108
106
  */
109
107
  verifyTransaction(transaction, signature) {
110
108
  const parsedSignature = parseSerializedZkLoginSignature(signature);
111
- return graphqlVerifyZkLoginSignature({
109
+ return verifyOnNode(this.#client, {
112
110
  address: this.toSuiAddress(),
113
- bytes: toBase64(transaction),
114
- signature: parsedSignature.serializedSignature,
115
- intentScope: "TransactionData",
116
- client: this.#client
111
+ transaction,
112
+ signature: parsedSignature.serializedSignature
117
113
  });
118
114
  }
119
115
  /**
120
116
  * Verifies that the public key is associated with the provided address
121
117
  */
122
118
  verifyAddress(address) {
123
- return address === super.toSuiAddress() || address === this.#toLegacyAddress();
119
+ const normalized = normalizeSuiAddress(address);
120
+ return normalized === super.toSuiAddress() || normalized === this.#toLegacyAddress();
124
121
  }
125
122
  };
126
123
  function toZkLoginPublicIdentifier(addressSeed, iss, options) {
@@ -142,15 +139,13 @@ function normalizeZkLoginPublicKeyBytes(bytes, legacyAddress) {
142
139
  data.set(seedBytes, issByteLength);
143
140
  return data;
144
141
  }
145
- async function graphqlVerifyZkLoginSignature({ address, bytes, signature, intentScope, client }) {
146
- if (!client) throw new Error("A Sui Client (GRPC, GraphQL, or JSON RPC) is required to verify zkLogin signatures");
147
- const resp = await client.core.verifyZkLoginSignature({
148
- bytes,
149
- signature,
150
- intentScope,
151
- address
142
+ async function verifyOnNode(client, options) {
143
+ if (!client) throw new Error("A Sui Client (gRPC or GraphQL) is required to verify zkLogin signatures");
144
+ const { valid } = await client.core.verifySignature({
145
+ ...options,
146
+ checkAddressAliases: false
152
147
  });
153
- return resp.success === true && resp.errors.length === 0;
148
+ return valid;
154
149
  }
155
150
  function parseSerializedZkLoginSignature(signature) {
156
151
  const bytes = typeof signature === "string" ? fromBase64(signature) : signature;
@@ -1 +1 @@
1
- {"version":3,"file":"publickey.mjs","names":["#client","#data","#legacyAddress","#toLegacyAddress"],"sources":["../../src/zklogin/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64, toHex } from '@mysten/bcs';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\nimport { PublicKey } from '../cryptography/publickey.js';\nimport type { PublicKeyInitData } from '../cryptography/publickey.js';\nimport { SIGNATURE_SCHEME_TO_FLAG } from '../cryptography/signature-scheme.js';\nimport { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport type { ZkLoginSignatureInputs } from './bcs.js';\nimport { extractClaimValue } from './jwt-utils.js';\nimport { parseZkLoginSignature } from './signature.js';\nimport { normalizeZkLoginIssuer, toBigEndianBytes, toPaddedBigEndianBytes } from './utils.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\n/**\n * A zkLogin public identifier\n */\nexport class ZkLoginPublicIdentifier extends PublicKey {\n\t#data: Uint8Array<ArrayBuffer>;\n\t#client?: ClientWithCoreApi;\n\t#legacyAddress: boolean;\n\n\t/**\n\t * Create a new ZkLoginPublicIdentifier object\n\t * @param value zkLogin public identifier as buffer or base-64 encoded string\n\t */\n\tconstructor(value: PublicKeyInitData, { client }: { client?: ClientWithCoreApi } = {}) {\n\t\tsuper();\n\n\t\tthis.#client = client;\n\n\t\tif (typeof value === 'string') {\n\t\t\tthis.#data = fromBase64(value);\n\t\t} else if (value instanceof Uint8Array) {\n\t\t\tthis.#data = value as Uint8Array<ArrayBuffer>;\n\t\t} else {\n\t\t\tthis.#data = Uint8Array.from(value);\n\t\t}\n\t\tthis.#legacyAddress = this.#data.length !== this.#data[0] + 1 + 32;\n\n\t\tif (this.#legacyAddress) {\n\t\t\tthis.#data = normalizeZkLoginPublicKeyBytes(this.#data, false);\n\t\t}\n\t}\n\n\t/**\n\t * Whether this identifier resolves to the deprecated legacy address derivation.\n\t */\n\tget legacyAddress(): boolean {\n\t\treturn this.#legacyAddress;\n\t}\n\n\tstatic fromBytes(\n\t\tbytes: Uint8Array,\n\t\t{\n\t\t\tclient,\n\t\t\taddress,\n\t\t\tlegacyAddress,\n\t\t}: { client?: ClientWithCoreApi; address?: string; legacyAddress?: boolean } = {},\n\t) {\n\t\tlet publicKey: ZkLoginPublicIdentifier;\n\n\t\tif (legacyAddress === true) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (legacyAddress === false) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (address) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\n\t\t\tif (publicKey.toSuiAddress() !== address) {\n\t\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\t\tclient,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(bytes, {\n\t\t\t\tclient,\n\t\t\t});\n\t\t}\n\n\t\tif (address && publicKey.toSuiAddress() !== address) {\n\t\t\tthrow new Error('Public key bytes do not match the provided address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\tstatic fromProof(address: string, proof: ZkLoginSignatureInputs) {\n\t\tconst { issBase64Details, addressSeed } = proof;\n\t\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\n\t\tconst legacyPublicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: true,\n\t\t});\n\n\t\tif (legacyPublicKey.toSuiAddress() === address) {\n\t\t\treturn legacyPublicKey;\n\t\t}\n\n\t\tconst publicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: false,\n\t\t});\n\n\t\tif (publicKey.toSuiAddress() !== address) {\n\t\t\tthrow new Error('Proof does not match address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\t/**\n\t * Checks if two zkLogin public identifiers are equal\n\t */\n\toverride equals(publicKey: ZkLoginPublicIdentifier): boolean {\n\t\treturn super.equals(publicKey);\n\t}\n\n\toverride toSuiAddress(): string {\n\t\tif (this.#legacyAddress) {\n\t\t\treturn this.#toLegacyAddress();\n\t\t}\n\n\t\treturn super.toSuiAddress();\n\t}\n\n\t#toLegacyAddress() {\n\t\tconst legacyBytes = normalizeZkLoginPublicKeyBytes(this.#data, true);\n\t\tconst addressBytes = new Uint8Array(legacyBytes.length + 1);\n\t\taddressBytes[0] = this.flag();\n\t\taddressBytes.set(legacyBytes, 1);\n\t\treturn normalizeSuiAddress(\n\t\t\tbytesToHex(blake2b(addressBytes, { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the zkLogin public identifier\n\t */\n\ttoRawBytes(): Uint8Array<ArrayBuffer> {\n\t\treturn this.#data;\n\t}\n\n\t/**\n\t * Return the Sui address associated with this ZkLogin public identifier\n\t */\n\tflag(): number {\n\t\treturn SIGNATURE_SCHEME_TO_FLAG['ZkLogin'];\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tasync verify(_message: Uint8Array, _signature: Uint8Array | string): Promise<boolean> {\n\t\tthrow Error('does not support');\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\n\t\treturn graphqlVerifyZkLoginSignature({\n\t\t\t// Verify against this identifier's address, not one derived from the signature, so a\n\t\t\t// signature from a different zkLogin identity is rejected (as the chain does for multisig).\n\t\t\taddress: this.toSuiAddress(),\n\t\t\tbytes: toBase64(message),\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t\tintentScope: 'PersonalMessage',\n\t\t\tclient: this.#client,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\t\treturn graphqlVerifyZkLoginSignature({\n\t\t\taddress: this.toSuiAddress(),\n\t\t\tbytes: toBase64(transaction),\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t\tintentScope: 'TransactionData',\n\t\t\tclient: this.#client,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t */\n\toverride verifyAddress(address: string): boolean {\n\t\treturn address === super.toSuiAddress() || address === this.#toLegacyAddress();\n\t}\n}\n\n// Derive the public identifier for zklogin based on address seed and iss.\nexport function toZkLoginPublicIdentifier(\n\taddressSeed: bigint,\n\tiss: string,\n\toptions: { client?: ClientWithCoreApi; legacyAddress: boolean },\n): ZkLoginPublicIdentifier {\n\tif (options.legacyAddress === undefined) {\n\t\tthrow new Error('legacyAddress parameter must be specified');\n\t}\n\t// Consists of iss_bytes_len || iss_bytes || padded_32_byte_address_seed.\n\tconst addressSeedBytesBigEndian = options.legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\n\tconst issBytes = new TextEncoder().encode(normalizeZkLoginIssuer(iss));\n\tconst tmp = new Uint8Array(1 + issBytes.length + addressSeedBytesBigEndian.length);\n\ttmp.set([issBytes.length], 0);\n\ttmp.set(issBytes, 1);\n\ttmp.set(addressSeedBytesBigEndian, 1 + issBytes.length);\n\treturn new ZkLoginPublicIdentifier(tmp, options);\n}\n\nfunction normalizeZkLoginPublicKeyBytes(bytes: Uint8Array, legacyAddress: boolean) {\n\tconst issByteLength = bytes[0] + 1;\n\tconst addressSeed = BigInt(`0x${toHex(bytes.slice(issByteLength))}`);\n\tconst seedBytes = legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\tconst data = new Uint8Array(issByteLength + seedBytes.length);\n\tdata.set(bytes.slice(0, issByteLength), 0);\n\tdata.set(seedBytes, issByteLength);\n\treturn data;\n}\n\nasync function graphqlVerifyZkLoginSignature({\n\taddress,\n\tbytes,\n\tsignature,\n\tintentScope,\n\tclient,\n}: {\n\taddress: string;\n\tbytes: string;\n\tsignature: string;\n\tintentScope: 'PersonalMessage' | 'TransactionData';\n\tclient?: ClientWithCoreApi;\n}) {\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t'A Sui Client (GRPC, GraphQL, or JSON RPC) is required to verify zkLogin signatures',\n\t\t);\n\t}\n\tconst resp = await client.core.verifyZkLoginSignature({\n\t\tbytes,\n\t\tsignature,\n\t\tintentScope,\n\t\taddress: address,\n\t});\n\n\treturn resp.success === true && resp.errors.length === 0;\n}\n\nexport function parseSerializedZkLoginSignature(signature: Uint8Array | string) {\n\tconst bytes = typeof signature === 'string' ? fromBase64(signature) : signature;\n\n\tif (bytes[0] !== SIGNATURE_SCHEME_TO_FLAG.ZkLogin) {\n\t\tthrow new Error('Invalid signature scheme');\n\t}\n\n\tconst signatureBytes = bytes.slice(1);\n\tconst { inputs, maxEpoch, userSignature } = parseZkLoginSignature(signatureBytes);\n\tconst { issBase64Details, addressSeed } = inputs;\n\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\tconst publicIdentifier = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\tlegacyAddress: false,\n\t});\n\treturn {\n\t\tserializedSignature: toBase64(bytes),\n\t\tsignatureScheme: 'ZkLogin' as const,\n\t\tzkLogin: {\n\t\t\tinputs,\n\t\t\tmaxEpoch,\n\t\t\tuserSignature,\n\t\t\tiss,\n\t\t\taddressSeed: BigInt(addressSeed),\n\t\t},\n\t\tsignature: bytes,\n\t\tpublicK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BAAyB,QACzC,OAAM,IAAI,MAAM,2BAA2B;CAI5C,MAAM,EAAE,QAAQ,UAAU,kBAAkB,sBADrB,MAAM,MAAM,EAAE,CAC4C;CACjF,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,MAAM,kBAA0B,kBAAkB,MAAM;CAC9D,MAAM,mBAAmB,0BAA0B,OAAO,YAAY,EAAE,KAAK,EAC5E,eAAe,OACf,CAAC;AACF,QAAO;EACN,qBAAqB,SAAS,MAAM;EACpC,iBAAiB;EACjB,SAAS;GACR;GACA;GACA;GACA;GACA,aAAa,OAAO,YAAY;GAChC;EACD,WAAW;EACX,WAAW,iBAAiB,YAAY;EACxC"}
1
+ {"version":3,"file":"publickey.mjs","names":["#client","#data","#legacyAddress","#toLegacyAddress"],"sources":["../../src/zklogin/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64, toHex } from '@mysten/bcs';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\nimport { PublicKey } from '../cryptography/publickey.js';\nimport type { PublicKeyInitData } from '../cryptography/publickey.js';\nimport { SIGNATURE_SCHEME_TO_FLAG } from '../cryptography/signature-scheme.js';\nimport { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport type { ZkLoginSignatureInputs } from './bcs.js';\nimport { extractClaimValue } from './jwt-utils.js';\nimport { parseZkLoginSignature } from './signature.js';\nimport { normalizeZkLoginIssuer, toBigEndianBytes, toPaddedBigEndianBytes } from './utils.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\nimport type { SuiClientTypes } from '../client/types.js';\n\n/**\n * A zkLogin public identifier\n */\nexport class ZkLoginPublicIdentifier extends PublicKey {\n\t#data: Uint8Array<ArrayBuffer>;\n\t#client?: ClientWithCoreApi;\n\t#legacyAddress: boolean;\n\n\t/**\n\t * Create a new ZkLoginPublicIdentifier object\n\t * @param value zkLogin public identifier as buffer or base-64 encoded string\n\t */\n\tconstructor(value: PublicKeyInitData, { client }: { client?: ClientWithCoreApi } = {}) {\n\t\tsuper();\n\n\t\tthis.#client = client;\n\n\t\tif (typeof value === 'string') {\n\t\t\tthis.#data = fromBase64(value);\n\t\t} else if (value instanceof Uint8Array) {\n\t\t\tthis.#data = value as Uint8Array<ArrayBuffer>;\n\t\t} else {\n\t\t\tthis.#data = Uint8Array.from(value);\n\t\t}\n\t\tthis.#legacyAddress = this.#data.length !== this.#data[0] + 1 + 32;\n\n\t\tif (this.#legacyAddress) {\n\t\t\tthis.#data = normalizeZkLoginPublicKeyBytes(this.#data, false);\n\t\t}\n\t}\n\n\t/**\n\t * Whether this identifier resolves to the deprecated legacy address derivation.\n\t */\n\tget legacyAddress(): boolean {\n\t\treturn this.#legacyAddress;\n\t}\n\n\tstatic fromBytes(\n\t\tbytes: Uint8Array,\n\t\t{\n\t\t\tclient,\n\t\t\taddress,\n\t\t\tlegacyAddress,\n\t\t}: { client?: ClientWithCoreApi; address?: string; legacyAddress?: boolean } = {},\n\t) {\n\t\tlet publicKey: ZkLoginPublicIdentifier;\n\n\t\tif (legacyAddress === true) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (legacyAddress === false) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (address) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\n\t\t\tif (publicKey.toSuiAddress() !== address) {\n\t\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\t\tclient,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(bytes, {\n\t\t\t\tclient,\n\t\t\t});\n\t\t}\n\n\t\tif (address && publicKey.toSuiAddress() !== address) {\n\t\t\tthrow new Error('Public key bytes do not match the provided address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\tstatic fromProof(address: string, proof: ZkLoginSignatureInputs) {\n\t\tconst { issBase64Details, addressSeed } = proof;\n\t\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\n\t\tconst legacyPublicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: true,\n\t\t});\n\n\t\tif (legacyPublicKey.toSuiAddress() === address) {\n\t\t\treturn legacyPublicKey;\n\t\t}\n\n\t\tconst publicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: false,\n\t\t});\n\n\t\tif (publicKey.toSuiAddress() !== address) {\n\t\t\tthrow new Error('Proof does not match address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\t/**\n\t * Checks if two zkLogin public identifiers are equal\n\t */\n\toverride equals(publicKey: ZkLoginPublicIdentifier): boolean {\n\t\treturn super.equals(publicKey);\n\t}\n\n\toverride toSuiAddress(): string {\n\t\tif (this.#legacyAddress) {\n\t\t\treturn this.#toLegacyAddress();\n\t\t}\n\n\t\treturn super.toSuiAddress();\n\t}\n\n\t#toLegacyAddress() {\n\t\tconst legacyBytes = normalizeZkLoginPublicKeyBytes(this.#data, true);\n\t\tconst addressBytes = new Uint8Array(legacyBytes.length + 1);\n\t\taddressBytes[0] = this.flag();\n\t\taddressBytes.set(legacyBytes, 1);\n\t\treturn normalizeSuiAddress(\n\t\t\tbytesToHex(blake2b(addressBytes, { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the zkLogin public identifier\n\t */\n\ttoRawBytes(): Uint8Array<ArrayBuffer> {\n\t\treturn this.#data;\n\t}\n\n\t/**\n\t * Return the Sui address associated with this ZkLogin public identifier\n\t */\n\tflag(): number {\n\t\treturn SIGNATURE_SCHEME_TO_FLAG['ZkLogin'];\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tasync verify(_message: Uint8Array, _signature: Uint8Array | string): Promise<boolean> {\n\t\tthrow new Error(\n\t\t\t'zkLogin signatures can only be verified for personal messages and transactions',\n\t\t);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\n\t\treturn verifyOnNode(this.#client, {\n\t\t\t// Verify against this identifier's address, not one derived from the signature, so a\n\t\t\t// signature from a different zkLogin identity is rejected (as the chain does for multisig).\n\t\t\taddress: this.toSuiAddress(),\n\t\t\tpersonalMessage: message,\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\t\treturn verifyOnNode(this.#client, {\n\t\t\taddress: this.toSuiAddress(),\n\t\t\ttransaction,\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t */\n\toverride verifyAddress(address: string): boolean {\n\t\tconst normalized = normalizeSuiAddress(address);\n\t\treturn normalized === super.toSuiAddress() || normalized === this.#toLegacyAddress();\n\t}\n}\n\n// Derive the public identifier for zklogin based on address seed and iss.\nexport function toZkLoginPublicIdentifier(\n\taddressSeed: bigint,\n\tiss: string,\n\toptions: { client?: ClientWithCoreApi; legacyAddress: boolean },\n): ZkLoginPublicIdentifier {\n\tif (options.legacyAddress === undefined) {\n\t\tthrow new Error('legacyAddress parameter must be specified');\n\t}\n\t// Consists of iss_bytes_len || iss_bytes || padded_32_byte_address_seed.\n\tconst addressSeedBytesBigEndian = options.legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\n\tconst issBytes = new TextEncoder().encode(normalizeZkLoginIssuer(iss));\n\tconst tmp = new Uint8Array(1 + issBytes.length + addressSeedBytesBigEndian.length);\n\ttmp.set([issBytes.length], 0);\n\ttmp.set(issBytes, 1);\n\ttmp.set(addressSeedBytesBigEndian, 1 + issBytes.length);\n\treturn new ZkLoginPublicIdentifier(tmp, options);\n}\n\nfunction normalizeZkLoginPublicKeyBytes(bytes: Uint8Array, legacyAddress: boolean) {\n\tconst issByteLength = bytes[0] + 1;\n\tconst addressSeed = BigInt(`0x${toHex(bytes.slice(issByteLength))}`);\n\tconst seedBytes = legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\tconst data = new Uint8Array(issByteLength + seedBytes.length);\n\tdata.set(bytes.slice(0, issByteLength), 0);\n\tdata.set(seedBytes, issByteLength);\n\treturn data;\n}\n\nasync function verifyOnNode(\n\tclient: ClientWithCoreApi | undefined,\n\toptions: SuiClientTypes.VerifySignatureOptions,\n) {\n\tif (!client) {\n\t\tthrow new Error('A Sui Client (gRPC or GraphQL) is required to verify zkLogin signatures');\n\t}\n\t// A public key checks its own signatures, not an account's alias set.\n\tconst { valid } = await client.core.verifySignature({ ...options, checkAddressAliases: false });\n\treturn valid;\n}\n\nexport function parseSerializedZkLoginSignature(signature: Uint8Array | string) {\n\tconst bytes = typeof signature === 'string' ? fromBase64(signature) : signature;\n\n\tif (bytes[0] !== SIGNATURE_SCHEME_TO_FLAG.ZkLogin) {\n\t\tthrow new Error('Invalid signature scheme');\n\t}\n\n\tconst signatureBytes = bytes.slice(1);\n\tconst { inputs, maxEpoch, userSignature } = parseZkLoginSignature(signatureBytes);\n\tconst { issBase64Details, addressSeed } = inputs;\n\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\tconst publicIdentifier = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\tlegacyAddress: false,\n\t});\n\treturn {\n\t\tserializedSignature: toBase64(bytes),\n\t\tsignatureScheme: 'ZkLogin' as const,\n\t\tzkLogin: {\n\t\t\tinputs,\n\t\t\tmaxEpoch,\n\t\t\tuserSignature,\n\t\t\tiss,\n\t\t\taddressSeed: BigInt(addressSeed),\n\t\t},\n\t\tsignature: bytes,\n\t\tpublicKey: publicIdentifier.toRawBytes(),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,0BAAb,MAAa,gCAAgC,UAAU;CACtD;CACA;CACA;;;;;CAMA,YAAY,OAA0B,EAAE,WAA2C,EAAE,EAAE;AACtF,SAAO;AAEP,QAAKA,SAAU;AAEf,MAAI,OAAO,UAAU,SACpB,OAAKC,OAAQ,WAAW,MAAM;WACpB,iBAAiB,WAC3B,OAAKA,OAAQ;MAEb,OAAKA,OAAQ,WAAW,KAAK,MAAM;AAEpC,QAAKC,gBAAiB,MAAKD,KAAM,WAAW,MAAKA,KAAM,KAAK,IAAI;AAEhE,MAAI,MAAKC,cACR,OAAKD,OAAQ,+BAA+B,MAAKA,MAAO,MAAM;;;;;CAOhE,IAAI,gBAAyB;AAC5B,SAAO,MAAKC;;CAGb,OAAO,UACN,OACA,EACC,QACA,SACA,kBAC8E,EAAE,EAChF;EACD,IAAI;AAEJ,MAAI,kBAAkB,KACrB,aAAY,IAAI,wBAAwB,+BAA+B,OAAO,KAAK,EAAE,EACpF,QACA,CAAC;WACQ,kBAAkB,MAC5B,aAAY,IAAI,wBAAwB,+BAA+B,OAAO,MAAM,EAAE,EACrF,QACA,CAAC;WACQ,SAAS;AACnB,eAAY,IAAI,wBAAwB,+BAA+B,OAAO,MAAM,EAAE,EACrF,QACA,CAAC;AAEF,OAAI,UAAU,cAAc,KAAK,QAChC,aAAY,IAAI,wBAAwB,+BAA+B,OAAO,KAAK,EAAE,E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,MAAM,0EAA0E;CAG3F,MAAM,EAAE,UAAU,MAAM,OAAO,KAAK,gBAAgB;EAAE,GAAG;EAAS,qBAAqB;EAAO,CAAC;AAC/F,QAAO;;AAGR,SAAgB,gCAAgC,WAAgC;CAC/E,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;AAEtE,KAAI,MAAM,OAAO,yBAAyB,QACzC,OAAM,IAAI,MAAM,2BAA2B;CAI5C,MAAM,EAAE,QAAQ,UAAU,kBAAkB,sBADrB,MAAM,MAAM,EAAE,CAC4C;CACjF,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,MAAM,kBAA0B,kBAAkB,MAAM;CAC9D,MAAM,mBAAmB,0BAA0B,OAAO,YAAY,EAAE,KAAK,EAC5E,eAAe,OACf,CAAC;AACF,QAAO;EACN,qBAAqB,SAAS,MAAM;EACpC,iBAAiB;EACjB,SAAS;GACR;GACA;GACA;GACA;GACA,aAAa,OAAO,YAAY;GAChC;EACD,WAAW;EACX,WAAW,iBAAiB,YAAY;EACxC"}
package/docs/bcs.md CHANGED
@@ -132,8 +132,8 @@ if (effects.V2.status.$kind === 'Success') {
132
132
  }
133
133
 
134
134
  // Access changed objects
135
- for (const [objectId, change] of effects.V2.changedObjects) {
136
- console.log('Object:', objectId);
135
+ for (const change of effects.V2.changedObjects) {
136
+ console.log('Object:', change.objectId);
137
137
  console.log('Output state:', change.outputState.$kind);
138
138
  }
139
139
  ```
@@ -3,8 +3,8 @@
3
3
  > The transport-agnostic client contract that SDKs and libraries build against
4
4
 
5
5
  The Core API is the contract every Sui client implements. It exists so that libraries do not have to
6
- care which transport their caller chose: an SDK written against the Core API works with
7
- `SuiGrpcClient`, `SuiGraphQLClient`, and the deprecated `SuiJsonRpcClient` alike.
6
+ care which transport their caller chose: an SDK written against the Core API works with both
7
+ `SuiGrpcClient` and `SuiGraphQLClient`.
8
8
 
9
9
  > **Note:** This page is for SDK and library authors. If you are writing application code, create a client and
10
10
  > call its [top-level methods](/sui/clients/querying) directly. You do not need `client.core`.
@@ -59,17 +59,16 @@ documents them in full, with options, include flags, and response shapes.
59
59
  | Dynamic fields | `listDynamicFields`, `getDynamicField`, `getDynamicObjectField` |
60
60
  | Transactions | `getTransaction`, `executeTransaction`, `signAndExecuteTransaction`, `waitForTransaction` |
61
61
  | Simulation | `simulateTransaction` |
62
- | History | `listTransactions`, `listEvents` |
62
+ | History | `listTransactions`, `listEvents`, `listCheckpoints` |
63
63
  | Move | `getMoveFunction` |
64
64
  | Names | `resolveNameServiceAddress`, `defaultNameServiceName`, `mvr` |
65
65
  | Network | `getReferenceGasPrice`, `getCurrentSystemState`, `getProtocolConfig`, `getChainIdentifier` |
66
- | Verification | `verifyZkLoginSignature` |
66
+ | Verification | `verifySignature` (`verifyZkLoginSignature` is deprecated), `getAddressAliases` |
67
67
  | Building | `resolveTransactionPlugin` |
68
68
 
69
69
  `SuiGrpcClient` and `SuiGraphQLClient` also expose every one of these as a top-level method, so the
70
70
  choice between `client.core.getObject()` and `client.getObject()` is about portability rather than
71
- reach. The deprecated `SuiJsonRpcClient` is the exception: it implements the contract on
72
- `client.core`, but its own top-level methods keep their legacy JSON-RPC names and shapes.
71
+ reach.
73
72
 
74
73
  ## Typing library code
75
74
 
@@ -135,6 +134,7 @@ function describeOwner(owner: SuiClientTypes.ObjectOwner) {
135
134
  | `TransactionEffects` | Detailed effects from transaction execution |
136
135
  | `Event` | Emitted event from a transaction |
137
136
  | `EventEntry` | Queried event with its ledger position |
137
+ | `Checkpoint` | Checkpoint summary: sequence number, digest, epoch, and timestamp (`timestampMs`) |
138
138
  | `TransactionFilter` | Filter for transaction queries |
139
139
  | `EventFilter` | Filter for event queries |
140
140
  | `ObjectOwner` | Union of all owner types |
@@ -152,18 +152,19 @@ Option types follow a predictable naming scheme (`GetObjectOptions`, `ListCoinsO
152
152
  All transports produce the same shapes, but they read from different backends, and a few differences
153
153
  are visible to callers. Library code that runs against any client should account for them.
154
154
 
155
- | Behavior | What differs |
156
- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
157
- | `include: { json: true }` | Field shapes vary between implementations. Use `content` and parse BCS when the result must be stable |
158
- | `include: { events: true }` | GraphQL returns at most the first 50 events of a transaction; gRPC and JSON-RPC return all of them |
159
- | JSON-RPC query gaps | `EventEntry.checkpoint` is `null`, and a bare generic `eventType` filter matches nothing where gRPC and GraphQL match any instantiation |
160
- | Page-size caps | Over-large `limit` values are silently truncated on gRPC and rejected with an error on GraphQL and JSON-RPC |
161
- | Short pages | gRPC bounds how much ledger a filtered query scans, so a page can be short or empty with `hasNextPage: true` |
162
- | Read-after-write | GraphQL reads an index that trails execution. Use `waitForTransaction` before reading your own writes |
163
-
164
- Two constraints are enforced by the client itself, so they fail the same way everywhere: a query
165
- takes at most one of `after` or `before`, and paginating transactions filtered by `function`
166
- requires a fully qualified `package::module::function`.
155
+ | Behavior | What differs |
156
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
157
+ | `include: { json: true }` | Field shapes vary between implementations. Use `content` and parse BCS when the result must be stable |
158
+ | `include: { events: true }` | When executing or simulating, GraphQL returns at most the first 50 events of a transaction; gRPC returns all of them |
159
+ | Page-size caps | Over-large `limit` values are silently truncated on gRPC and rejected with an error on GraphQL |
160
+ | Short pages | Servers bound how much ledger a filtered query scans, so a page can be short or empty with `hasNextPage: true` on either transport |
161
+ | Window ends | On GraphQL, any page that reaches a cursor bound, including a descending read with only `after`, may report `hasNextPage: true`; the next page is empty |
162
+ | Reused history cursors | A cursor passed with a different filter or checkpoint range gives transport-specific results |
163
+ | Top-level `status.error` | GraphQL distinguishes only `MoveAbort`, and reports other errors as `Unknown`; gRPC returns the typed kinds. Use `effects.status` for the typed error |
164
+ | Read-after-write | Use `waitForTransaction` before reading your own writes. List queries can trail it on either transport, so poll them |
165
+
166
+ Invalid filter combinations and checkpoint ranges are rejected by the client itself, so they fail
167
+ the same way on every transport.
167
168
 
168
169
  ## Client services
169
170
 
@@ -65,11 +65,52 @@ Execution, simulation, and [`getTransaction`](/sui/clients/querying#gettransacti
65
65
  | ---------------- | ------------------------------------------------------------------ |
66
66
  | `effects` | Execution effects: created, mutated, and deleted objects, gas used |
67
67
  | `events` | Move events emitted during execution |
68
- | `transaction` | The full transaction data (sender, gas config, inputs, commands) |
68
+ | `transaction` | Ledger data: sender, gas config, expiration, and transaction kind |
69
69
  | `balanceChanges` | Balance changes for each affected address and coin type |
70
70
  | `objectTypes` | Map of object ID to type for all changed objects |
71
71
  | `bcs` | Raw BCS-encoded transaction bytes |
72
72
 
73
+ ### Transaction data
74
+
75
+ `include: { transaction: true }` returns transaction data with `sender`, `gasData`, `expiration`,
76
+ `inputs`, `commands`, and `kind`. `inputs` and `commands` hold the inputs and commands of a
77
+ programmable or programmable system transaction, and are empty for every other kind. Use
78
+ `kind.$kind` to identify the transaction type and access its payload:
79
+
80
+ ```typescript
81
+ const result = await client.getTransaction({
82
+ digest,
83
+ include: { transaction: true },
84
+ });
85
+ const { transaction: data } = result.Transaction ?? result.FailedTransaction;
86
+
87
+ switch (data.kind.$kind) {
88
+ case 'ProgrammableTransaction':
89
+ console.log(data.kind.ProgrammableTransaction.inputs);
90
+ console.log(data.kind.ProgrammableTransaction.commands);
91
+ break;
92
+ case 'Genesis':
93
+ console.log(data.kind.Genesis.objects.length);
94
+ break;
95
+ case 'Unknown':
96
+ console.log('Transaction kind not supported by this SDK version');
97
+ break;
98
+ default:
99
+ console.log('System transaction:', data.kind.$kind);
100
+ }
101
+ ```
102
+
103
+ `ProgrammableTransaction` and `ProgrammableSystemTransaction` contain `inputs` and `commands`. Other
104
+ kinds, such as `Genesis`, `ChangeEpoch`, and `RandomnessStateUpdate`, have their own payloads.
105
+
106
+ If the SDK does not recognize a transaction's kind, or cannot map one of its inputs or commands,
107
+ `kind` is `{ $kind: 'Unknown', Unknown: true }` and `inputs` and `commands` are empty; `sender`,
108
+ `gasData`, and `expiration` are still set. Upgrade the SDK to read kinds added by newer network
109
+ versions.
110
+
111
+ To decode transaction bytes yourself, use `parseTransactionDataBcs` from `@mysten/sui/client`. It
112
+ returns the same shape, but throws on bytes that use a variant the SDK does not know.
113
+
73
114
  ## `waitForTransaction`
74
115
 
75
116
  Reads are served from indexed state, which trails execution slightly. Wait before reading a
@@ -87,6 +128,9 @@ const { balance } = await client.getBalance({ owner: myAddress });
87
128
  It also accepts a `digest` instead of a result, along with `timeout` and a `pollSchedule` array of
88
129
  backoff delays.
89
130
 
131
+ `waitForTransaction` resolves once the transaction can be fetched from the client's server; reads of
132
+ your own writes through that client are then expected to see it.
133
+
90
134
  ## `simulateTransaction`
91
135
 
92
136
  Dry-run a transaction without executing it, to estimate gas, inspect return values, or validate it
@@ -110,10 +154,11 @@ Two further options change how the node runs the simulation:
110
154
  | Option | Effect |
111
155
  | ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
112
156
  | `checksEnabled` | Set `false` to skip transaction validation, so non-public and non-entry functions can be inspected. Defaults to `true` |
113
- | `doGasSelection` | gRPC and GraphQL only. Overrides whether the node selects real gas. Defaults to `true` only when gas payment is `[]` |
114
-
115
- A transaction with no gas payment is simulated with a mocked gas coin, which also funds anything
116
- drawn from `tx.gas`, so the result validates the transaction and estimates gas but is not a preview
117
- of what the sender would spend. To simulate with the sender's real gas, set gas coins on the
118
- transaction, or on gRPC and GraphQL set an empty gas payment and let the node select gas. The
119
- result's `gasPaymentMocked` field reports which case ran.
157
+ | `doGasSelection` | Overrides whether the node selects real gas. Defaults to `true` only when gas payment is `[]` |
158
+
159
+ When the node does not select gas, a transaction with no gas coins is simulated with a mocked gas
160
+ coin unless the sender's address balance covers the budget. The mocked coin also funds anything
161
+ drawn from `tx.gas`. The result validates the transaction and estimates gas, but is not a preview of
162
+ what the sender would spend. To simulate with the sender's real gas, set gas coins on the
163
+ transaction, or set an empty gas payment and let the node select gas. The result's
164
+ `gasPaymentMocked` field reports whether gas was mocked.
@@ -1,6 +1,6 @@
1
1
  # SuiGraphQLClient
2
2
 
3
- > Connect to Sui over GraphQL and write type-safe custom queries
3
+ > Connect to Sui over GraphQL with type-safe queries and subscriptions
4
4
 
5
5
  `SuiGraphQLClient` talks to the Sui GraphQL API. It implements the same client API as
6
6
  `SuiGrpcClient`, so anything on [Querying data](/sui/clients/querying) and
@@ -25,14 +25,24 @@ itself. The rest of this page covers writing those queries; see the
25
25
 
26
26
  The constructor takes:
27
27
 
28
- | Option | Description |
29
- | --------- | -------------------------------------------------------------- |
30
- | `url` | GraphQL endpoint |
31
- | `network` | Network the endpoint serves, used for caching and MVR defaults |
32
- | `headers` | Extra headers sent with every request, such as an API key |
33
- | `fetch` | Custom `fetch` implementation |
34
- | `queries` | Named documents callable through [`execute`](#named-queries) |
35
- | `mvr` | Move Registry overrides |
28
+ | Option | Description |
29
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
30
+ | `url` | GraphQL endpoint: an absolute http(s) URL, or a path such as `/graphql` in a browser or with a custom `fetch` |
31
+ | `subscriptionUrl` | Subscription endpoint; defaults to `url` with `/subscriptions` appended |
32
+ | `network` | Network the endpoint serves, used for caching and MVR defaults |
33
+ | `headers` | Extra headers sent with every request, such as an API key |
34
+ | `fetch` | Custom `fetch` implementation |
35
+ | `queries` | Named documents callable through [`execute`](#named-queries) |
36
+ | `mvr` | Move Registry overrides |
37
+ | `restrictedMoveCalls` | Move calls transactions built with this client can't make; see [Restricted Move calls](/sui/transactions/reference#restricted-move-calls) |
38
+
39
+ Public endpoints:
40
+
41
+ | Network | URL |
42
+ | ------- | ---------------------------------------- |
43
+ | Mainnet | `https://graphql.mainnet.sui.io/graphql` |
44
+ | Testnet | `https://graphql.testnet.sui.io/graphql` |
45
+ | Devnet | `https://graphql.devnet.sui.io/graphql` |
36
46
 
37
47
  ## Writing queries
38
48
 
@@ -114,7 +124,10 @@ if (errors?.length) {
114
124
  }
115
125
  ```
116
126
 
117
- A transport-level failure (a non-2xx response) throws `SuiGraphQLRequestError` instead.
127
+ A transport-level failure (a network error, a non-2xx response or a malformed body) throws
128
+ `SuiGraphQLRequestError` instead. Its `reason` is set when repeating the request may succeed:
129
+ `Unavailable` for network failures and HTTP 503, `RateLimited` for HTTP 429, and `ServerError` for
130
+ HTTP 408 and other 5xx responses except 501.
118
131
 
119
132
  ### Named queries
120
133
 
@@ -143,4 +156,61 @@ Results and variables stay typed from the document the name resolves to.
143
156
  GraphQL reads an index that trails execution slightly, so a transaction `executeTransaction` has
144
157
  already returned might not appear in a query for a moment. Use
145
158
  [`waitForTransaction`](/sui/clients/executing#waitfortransaction) before reading back a
146
- transaction's effects.
159
+ transaction's effects.
160
+
161
+ ## Subscriptions
162
+
163
+ To follow checkpoints, transactions, or events with history replay, resume tokens, and reconnection,
164
+ use [ledger streams](./streaming.mdx).
165
+
166
+ Use `subscribe` for any subscription document the endpoint supports. Results and variables are
167
+ inferred from typed documents, just as with `query`:
168
+
169
+ ```typescript
170
+
171
+ const client = new SuiGraphQLClient({
172
+ url: 'https://graphql.devnet.sui.io/graphql',
173
+ network: 'devnet',
174
+ });
175
+ const checkpoints = graphql(`
176
+ subscription Checkpoints {
177
+ checkpoints {
178
+ cursor
179
+ node {
180
+ sequenceNumber
181
+ digest
182
+ }
183
+ }
184
+ }
185
+ `);
186
+
187
+ for await (const result of client.subscribe({ query: checkpoints })) {
188
+ if (result.errors?.length) {
189
+ console.error(result.errors);
190
+ continue;
191
+ }
192
+ console.log(result.data?.checkpoints);
193
+ }
194
+ ```
195
+
196
+ Subscriptions stream server-sent events over HTTP POST, using the client's `headers` and `fetch`.
197
+ Set `subscriptionUrl` if your provider serves subscriptions at a different URL.
198
+
199
+ Each result keeps its GraphQL `errors` alongside any partial data. HTTP, network and malformed
200
+ response failures throw `SuiGraphQLRequestError`. The loop ends when the server closes the
201
+ subscription, and `subscribe` does not reconnect.
202
+
203
+ The request starts when iteration starts. `break` out of the loop to close the subscription.
204
+ Aborting the signal also closes it, but rejects the pending iteration with the abort reason:
205
+
206
+ ```typescript
207
+ const controller = new AbortController();
208
+
209
+ try {
210
+ for await (const result of client.subscribe({ query: checkpoints, signal: controller.signal })) {
211
+ console.log(result.data?.checkpoints);
212
+ }
213
+ } catch (error) {
214
+ if (!controller.signal.aborted) throw error;
215
+ }
216
+ ```
@@ -3,8 +3,7 @@
3
3
  > >- Connect to Sui over gRPC, with native service clients and real-time subscriptions
4
4
 
5
5
  `SuiGrpcClient` talks to the full node gRPC API. It is the recommended default for application code
6
- and SDK integrations: it reads directly from a full node, and it is the only client with real-time
7
- subscriptions.
6
+ and SDK integrations: it reads directly from a full node.
8
7
 
9
8
  ```typescript
10
9
 
@@ -53,6 +52,8 @@ const transaction = result.Transaction ?? result.FailedTransaction;
53
52
  console.log(transaction.digest, result.protoJson);
54
53
  ```
55
54
 
55
+ The [ledger stream](/sui/clients/streaming#grpc-options) methods also take a native `grpcFilter`.
56
+
56
57
  ## Transport options
57
58
 
58
59
  By default, `SuiGrpcClient` uses `GrpcWebFetchTransport`, which works in browsers and Node.js
@@ -62,14 +63,25 @@ you can configure a transport and handle its errors without adding `@protobuf-ts
62
63
  dependency.
63
64
 
64
65
  That class extends the transport of the same name from
65
- [protobuf-ts](https://github.com/timostamm/protobuf-ts) and fixes two defects in it:
66
+ [protobuf-ts](https://github.com/timostamm/protobuf-ts) and differs from it in these ways:
66
67
 
67
68
  - It decodes status messages, rather than delivering them as `Object%20not%20found:%200x1`.
68
69
  - It codes a call that an abort ended from the reason the abort carried: `DEADLINE_EXCEEDED` for an
69
70
  `AbortSignal.timeout`, the status on a reason carrying one, and `CANCELLED` otherwise. Upstream
70
71
  reports all but a standard `AbortError` cancellation as `INTERNAL`.
72
+ - It reports network failures, such as a failed fetch or a failed response body read, as
73
+ `UNAVAILABLE` rather than `INTERNAL`.
74
+ - It rejects a `baseUrl` that is neither an absolute http(s) URL nor a path starting with `/`. A
75
+ path works only where `fetch` can resolve it, such as in a browser or with a custom `fetch`.
76
+
77
+ A custom `fetch` must honour the request's `signal`, which the transport relies on to end aborted
78
+ calls.
79
+
80
+ Build custom gRPC-web transports from this class to keep this behaviour.
71
81
 
72
- Build custom gRPC-web transports from this class to retain these error-handling fixes.
82
+ Browser clients need the endpoint to expose the `grpc-status` and `grpc-message` headers through
83
+ CORS (`Access-Control-Expose-Headers`); otherwise a response that carries its status only in headers
84
+ fails.
73
85
 
74
86
  `SuiGrpcClient` adds an `x-sui-client-protocol-version` request header with the highest Sui protocol
75
87
  version whose types the SDK can decode. This applies to all transports, including native gRPC, and
@@ -89,7 +101,7 @@ one is not forwarded.
89
101
  const client = new SuiGrpcClient({
90
102
  network: 'testnet',
91
103
  baseUrl: 'https://your-custom-grpc-endpoint.com',
92
- format: 'binary', // default is 'text' (base64-encoded)
104
+ format: 'text', // default is 'binary'; use 'text' for proxies that only support base64
93
105
  });
94
106
  ```
95
107
 
@@ -99,8 +111,6 @@ Build the transport yourself to share one between clients, or to subclass it:
99
111
 
100
112
  const transport = new GrpcWebFetchTransport({
101
113
  baseUrl: 'https://your-custom-grpc-endpoint.com',
102
- format: 'binary', // default is 'text' (base64-encoded)
103
- // Additional transport options like fetchInit
104
114
  });
105
115
 
106
116
  const client = new SuiGrpcClient({
@@ -111,9 +121,13 @@ const client = new SuiGrpcClient({
111
121
 
112
122
  ### Native gRPC transport
113
123
 
114
- For server-side applications (Node.js, Bun, and others), use the native gRPC transport with
115
- `@protobuf-ts/grpc-transport` and `@grpc/grpc-js`. This speaks HTTP/2 and the native gRPC protocol
116
- rather than the gRPC-web translation layer.
124
+ For server-side applications (Node.js, Bun, and others), requests can also use the native gRPC
125
+ transport from `@protobuf-ts/grpc-transport` and `@grpc/grpc-js`. This speaks HTTP/2 and the native
126
+ gRPC protocol rather than the gRPC-web translation layer. Unary calls and bounded list methods such
127
+ as `listCheckpoints`, `listTransactions` and `listEvents` work on it.
128
+
129
+ The resumable ledger streams (`streamCheckpoints`, `streamTransactions` and `streamEvents`) work on
130
+ any transport.
117
131
 
118
132
  ```npm
119
133
  npm install @protobuf-ts/grpc-transport @grpc/grpc-js
@@ -147,9 +161,8 @@ const { response } = await client.ledgerService.getTransaction({
147
161
  });
148
162
  ```
149
163
 
150
- A field you did not ask for comes back unset, which is the most common surprise when moving from a
151
- JSON-RPC mindset: an empty field usually means it was not requested rather than that it has no
152
- value.
164
+ A field you did not ask for comes back unset: an empty field usually means it was not requested
165
+ rather than that it has no value.
153
166
 
154
167
  The top-level methods build masks for you from their `include` options, adding the paths each option
155
168
  needs on top of the handful every result carries. That is the main reason to prefer them: field
@@ -240,7 +253,7 @@ useful when you drop to a service client for the request but still want the unif
240
253
 
241
254
  const { response } = await client.ledgerService.getTransaction({
242
255
  digest: 'ABC123...',
243
- readMask: { paths: ['digest', 'effects'] },
256
+ readMask: { paths: ['digest', 'transaction.sender', 'effects'] },
244
257
  });
245
258
 
246
259
  // Same discriminated union that client.getTransaction() returns
@@ -402,4 +415,7 @@ Checkpoint subscriptions recover differently. `subscribeCheckpoints` reports its
402
415
  checkpoint sequence number rather than a watermark cursor, and `listCheckpoints` bounds a scan with
403
416
  `startCheckpoint` and `endCheckpoint` rather than `options.after` and `options.before`. Replay that
404
417
  gap by listing from the sequence number after the last one you processed, up to the sequence number
405
- the new subscription started at.
418
+ the new subscription started at.
419
+
420
+ [Ledger streams](/sui/clients/streaming) do this for you: they resume from a saved token and replay
421
+ the gap automatically.
@@ -6,17 +6,17 @@ A client is how your code reads from and writes to the Sui network. There are tw
6
6
  and they implement the same API (the same method names, options, and response shapes), so the choice
7
7
  is about which transport suits your application, not about which features you get.
8
8
 
9
- | Client | Choose it for |
10
- | ------------------------------------------ | ------------------------------------------------------------------------------------- |
11
- | [`SuiGrpcClient`](/sui/clients/grpc) | The default. Reads from a full node, and the only client with real-time subscriptions |
12
- | [`SuiGraphQLClient`](/sui/clients/graphql) | Reads from the indexer, and custom queries written against the GraphQL schema |
9
+ | Client | Choose it for |
10
+ | ------------------------------------------ | ----------------------------------------------------------------------------- |
11
+ | [`SuiGrpcClient`](/sui/clients/grpc) | The default. Reads from a full node |
12
+ | [`SuiGraphQLClient`](/sui/clients/graphql) | Reads from the indexer, and custom queries written against the GraphQL schema |
13
13
 
14
14
  Both are fully supported primary choices. Pick `SuiGrpcClient` if you have no particular reason to
15
15
  prefer one, and `SuiGraphQLClient` when your application wants to query the GraphQL schema directly.
16
16
  Because they share an API, moving between them is mostly a matter of changing the constructor.
17
17
 
18
- > **Note:** JSON-RPC is deprecated. See the [migration guide](/sui/migrations/sui-2.0/json-rpc-migration) if
19
- > you maintain existing JSON-RPC code.
18
+ > **Note:** The JSON-RPC client was removed in `@mysten/sui` 3.0. See the [3.0 migration
19
+ > guide](/sui/migrations/sui-3.0) if you are moving existing JSON-RPC code.
20
20
 
21
21
  ## Quick start
22
22
 
@@ -108,7 +108,8 @@ const result = await graphqlClient.query({
108
108
 
109
109
  gRPC adds [raw list RPCs](/sui/clients/grpc#using-service-clients) and
110
110
  [subscriptions](/sui/clients/grpc#subscriptions); GraphQL adds
111
- [custom queries](/sui/clients/graphql#writing-queries) against the schema.
111
+ [custom queries](/sui/clients/graphql#writing-queries) against the schema and
112
+ [subscriptions](/sui/clients/graphql#subscriptions).
112
113
 
113
114
  ## Client extensions
114
115