@mysten/sui 2.39.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/README.md +5 -188
  3. package/dist/bcs/bcs.d.mts +6 -6
  4. package/dist/bcs/bcs.d.mts.map +1 -1
  5. package/dist/bcs/bcs.mjs +49 -22
  6. package/dist/bcs/bcs.mjs.map +1 -1
  7. package/dist/bcs/effects.mjs +49 -20
  8. package/dist/bcs/effects.mjs.map +1 -1
  9. package/dist/bcs/index.d.mts +1441 -624
  10. package/dist/bcs/index.d.mts.map +1 -1
  11. package/dist/bcs/index.mjs +2 -1
  12. package/dist/bcs/index.mjs.map +1 -1
  13. package/dist/bcs/transactions.d.mts +1059 -0
  14. package/dist/bcs/transactions.d.mts.map +1 -0
  15. package/dist/bcs/transactions.mjs +33 -14
  16. package/dist/bcs/transactions.mjs.map +1 -1
  17. package/dist/bcs/types.d.mts +6 -1
  18. package/dist/bcs/types.d.mts.map +1 -1
  19. package/dist/client/core-resolver.mjs +4 -4
  20. package/dist/client/core-resolver.mjs.map +1 -1
  21. package/dist/client/core.d.mts +55 -4
  22. package/dist/client/core.d.mts.map +1 -1
  23. package/dist/client/core.mjs +98 -1
  24. package/dist/client/core.mjs.map +1 -1
  25. package/dist/client/errors.mjs +11 -1
  26. package/dist/client/errors.mjs.map +1 -1
  27. package/dist/client/index.d.mts +5 -3
  28. package/dist/client/index.mjs +6 -3
  29. package/dist/client/mvr.d.mts +12 -2
  30. package/dist/client/mvr.d.mts.map +1 -1
  31. package/dist/client/mvr.mjs +34 -13
  32. package/dist/client/mvr.mjs.map +1 -1
  33. package/dist/client/query-filters.mjs +80 -76
  34. package/dist/client/query-filters.mjs.map +1 -1
  35. package/dist/client/stream/adapter.d.mts +102 -0
  36. package/dist/client/stream/adapter.d.mts.map +1 -0
  37. package/dist/client/stream/errors.d.mts +14 -0
  38. package/dist/client/stream/errors.d.mts.map +1 -0
  39. package/dist/client/stream/errors.mjs +25 -0
  40. package/dist/client/stream/errors.mjs.map +1 -0
  41. package/dist/client/stream/filter.mjs +18 -0
  42. package/dist/client/stream/filter.mjs.map +1 -0
  43. package/dist/client/stream/follow.mjs +48 -0
  44. package/dist/client/stream/follow.mjs.map +1 -0
  45. package/dist/client/stream/index.d.mts +4 -0
  46. package/dist/client/stream/pager.mjs +123 -0
  47. package/dist/client/stream/pager.mjs.map +1 -0
  48. package/dist/client/stream/plan.mjs +79 -0
  49. package/dist/client/stream/plan.mjs.map +1 -0
  50. package/dist/client/stream/position.d.mts +30 -0
  51. package/dist/client/stream/position.d.mts.map +1 -0
  52. package/dist/client/stream/position.mjs +121 -0
  53. package/dist/client/stream/position.mjs.map +1 -0
  54. package/dist/client/stream/run.d.mts +2 -0
  55. package/dist/client/stream/run.mjs +99 -0
  56. package/dist/client/stream/run.mjs.map +1 -0
  57. package/dist/client/stream/session.mjs +205 -0
  58. package/dist/client/stream/session.mjs.map +1 -0
  59. package/dist/client/stream/status.mjs +47 -0
  60. package/dist/client/stream/status.mjs.map +1 -0
  61. package/dist/client/stream/token.mjs +80 -0
  62. package/dist/client/stream/token.mjs.map +1 -0
  63. package/dist/client/transaction-data.d.mts +17 -0
  64. package/dist/client/transaction-data.d.mts.map +1 -0
  65. package/dist/client/transaction-data.mjs +472 -0
  66. package/dist/client/transaction-data.mjs.map +1 -0
  67. package/dist/client/transaction-resolver.mjs +102 -58
  68. package/dist/client/transaction-resolver.mjs.map +1 -1
  69. package/dist/client/types.d.mts +560 -240
  70. package/dist/client/types.d.mts.map +1 -1
  71. package/dist/client/utils.d.mts +2 -2
  72. package/dist/client/utils.d.mts.map +1 -1
  73. package/dist/client/utils.mjs +91 -30
  74. package/dist/client/utils.mjs.map +1 -1
  75. package/dist/cryptography/index.d.mts +1 -1
  76. package/dist/cryptography/keypair.d.mts +1 -1
  77. package/dist/cryptography/publickey.d.mts +11 -0
  78. package/dist/cryptography/publickey.d.mts.map +1 -1
  79. package/dist/cryptography/publickey.mjs +12 -1
  80. package/dist/cryptography/publickey.mjs.map +1 -1
  81. package/dist/cryptography/signature.d.mts +8 -8
  82. package/dist/cryptography/signature.mjs +18 -7
  83. package/dist/cryptography/signature.mjs.map +1 -1
  84. package/dist/graphql/client.d.mts +51 -35
  85. package/dist/graphql/client.d.mts.map +1 -1
  86. package/dist/graphql/client.mjs +125 -69
  87. package/dist/graphql/client.mjs.map +1 -1
  88. package/dist/graphql/core.d.mts +14 -9
  89. package/dist/graphql/core.d.mts.map +1 -1
  90. package/dist/graphql/core.mjs +294 -118
  91. package/dist/graphql/core.mjs.map +1 -1
  92. package/dist/graphql/errors.d.mts +20 -0
  93. package/dist/graphql/errors.d.mts.map +1 -0
  94. package/dist/graphql/errors.mjs +19 -0
  95. package/dist/graphql/errors.mjs.map +1 -0
  96. package/dist/graphql/filters.mjs +32 -0
  97. package/dist/graphql/filters.mjs.map +1 -0
  98. package/dist/graphql/generated/queries.d.mts.map +1 -1
  99. package/dist/graphql/generated/queries.mjs +1216 -208
  100. package/dist/graphql/generated/queries.mjs.map +1 -1
  101. package/dist/graphql/generated/tada-env.d.mts +820 -11
  102. package/dist/graphql/index.d.mts +2 -1
  103. package/dist/graphql/index.mjs +2 -1
  104. package/dist/graphql/sse-parser.mjs +82 -0
  105. package/dist/graphql/sse-parser.mjs.map +1 -0
  106. package/dist/graphql/stream/families.mjs +306 -0
  107. package/dist/graphql/stream/families.mjs.map +1 -0
  108. package/dist/graphql/stream/index.mjs +38 -0
  109. package/dist/graphql/stream/index.mjs.map +1 -0
  110. package/dist/graphql/stream/live.mjs +60 -0
  111. package/dist/graphql/stream/live.mjs.map +1 -0
  112. package/dist/graphql/stream/page.mjs +38 -0
  113. package/dist/graphql/stream/page.mjs.map +1 -0
  114. package/dist/graphql/stream/query.mjs +47 -0
  115. package/dist/graphql/stream/query.mjs.map +1 -0
  116. package/dist/graphql/subscribe.mjs +70 -0
  117. package/dist/graphql/subscribe.mjs.map +1 -0
  118. package/dist/grpc/client.d.mts +31 -27
  119. package/dist/grpc/client.d.mts.map +1 -1
  120. package/dist/grpc/client.mjs +42 -46
  121. package/dist/grpc/client.mjs.map +1 -1
  122. package/dist/grpc/core.d.mts +13 -6
  123. package/dist/grpc/core.d.mts.map +1 -1
  124. package/dist/grpc/core.mjs +254 -166
  125. package/dist/grpc/core.mjs.map +1 -1
  126. package/dist/grpc/filters.mjs +44 -34
  127. package/dist/grpc/filters.mjs.map +1 -1
  128. package/dist/grpc/grpc-web-pull.mjs +245 -0
  129. package/dist/grpc/grpc-web-pull.mjs.map +1 -0
  130. package/dist/grpc/index.d.mts +2 -1
  131. package/dist/grpc/index.mjs +1 -1
  132. package/dist/grpc/network-error.mjs +31 -0
  133. package/dist/grpc/network-error.mjs.map +1 -0
  134. package/dist/grpc/proto/google/rpc/error_details.mjs +306 -0
  135. package/dist/grpc/proto/google/rpc/error_details.mjs.map +1 -0
  136. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  137. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +176 -1
  138. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
  139. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
  140. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
  141. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
  142. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  143. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
  144. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
  145. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
  146. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  147. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  148. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
  149. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
  150. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
  151. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
  152. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  153. package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
  154. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
  155. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
  156. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
  157. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
  158. package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
  159. package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
  160. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
  161. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
  162. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
  163. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
  164. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  165. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
  166. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
  167. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
  168. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
  169. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  170. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +20 -14
  171. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
  172. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
  173. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
  174. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
  175. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  176. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
  177. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
  178. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
  179. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  180. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  181. package/dist/grpc/proto/types.d.mts +7 -7
  182. package/dist/grpc/proto/types.mjs +3 -2
  183. package/dist/grpc/pull-call.d.mts +20 -0
  184. package/dist/grpc/pull-call.d.mts.map +1 -0
  185. package/dist/grpc/pull-call.mjs +28 -0
  186. package/dist/grpc/pull-call.mjs.map +1 -0
  187. package/dist/grpc/stream/call.mjs +238 -0
  188. package/dist/grpc/stream/call.mjs.map +1 -0
  189. package/dist/grpc/stream/families.d.mts +26 -0
  190. package/dist/grpc/stream/families.d.mts.map +1 -0
  191. package/dist/grpc/stream/families.mjs +145 -0
  192. package/dist/grpc/stream/families.mjs.map +1 -0
  193. package/dist/grpc/stream/index.d.mts +41 -0
  194. package/dist/grpc/stream/index.d.mts.map +1 -0
  195. package/dist/grpc/stream/index.mjs +127 -0
  196. package/dist/grpc/stream/index.mjs.map +1 -0
  197. package/dist/grpc/stream/live.mjs +31 -0
  198. package/dist/grpc/stream/live.mjs.map +1 -0
  199. package/dist/grpc/stream/page.mjs +120 -0
  200. package/dist/grpc/stream/page.mjs.map +1 -0
  201. package/dist/grpc/stream-types.d.mts +28 -0
  202. package/dist/grpc/stream-types.d.mts.map +1 -0
  203. package/dist/grpc/transport.d.mts +8 -3
  204. package/dist/grpc/transport.d.mts.map +1 -1
  205. package/dist/grpc/transport.mjs +88 -45
  206. package/dist/grpc/transport.mjs.map +1 -1
  207. package/dist/jsonRpc/index.d.mts +34 -12
  208. package/dist/jsonRpc/index.d.mts.map +1 -0
  209. package/dist/jsonRpc/index.mjs +39 -5
  210. package/dist/jsonRpc/index.mjs.map +1 -0
  211. package/dist/jsonRpc/types.d.mts +420 -0
  212. package/dist/jsonRpc/types.d.mts.map +1 -0
  213. package/dist/keypairs/passkey/keypair.d.mts +1 -1
  214. package/dist/multisig/publickey.d.mts +12 -4
  215. package/dist/multisig/publickey.d.mts.map +1 -1
  216. package/dist/multisig/publickey.mjs +5 -5
  217. package/dist/multisig/publickey.mjs.map +1 -1
  218. package/dist/multisig/signer.d.mts +1 -1
  219. package/dist/transactions/ObjectCache.d.mts +1 -1
  220. package/dist/transactions/ObjectCache.mjs +5 -5
  221. package/dist/transactions/ObjectCache.mjs.map +1 -1
  222. package/dist/transactions/Transaction.d.mts +10 -9
  223. package/dist/transactions/Transaction.d.mts.map +1 -1
  224. package/dist/transactions/Transaction.mjs +17 -6
  225. package/dist/transactions/Transaction.mjs.map +1 -1
  226. package/dist/transactions/data/internal.d.mts +2 -0
  227. package/dist/transactions/data/internal.d.mts.map +1 -1
  228. package/dist/transactions/data/internal.mjs +2 -1
  229. package/dist/transactions/data/internal.mjs.map +1 -1
  230. package/dist/transactions/executor/parallel.d.mts +2 -2
  231. package/dist/transactions/executor/serial.d.mts +1 -1
  232. package/dist/transactions/executor/serial.mjs +2 -2
  233. package/dist/transactions/executor/serial.mjs.map +1 -1
  234. package/dist/transactions/index.d.mts +3 -2
  235. package/dist/transactions/index.mjs +4 -3
  236. package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
  237. package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
  238. package/dist/transactions/resolve.d.mts +6 -0
  239. package/dist/transactions/resolve.d.mts.map +1 -1
  240. package/dist/transactions/resolve.mjs.map +1 -1
  241. package/dist/transactions/restricted-move-calls.d.mts +25 -0
  242. package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
  243. package/dist/transactions/restricted-move-calls.mjs +47 -0
  244. package/dist/transactions/restricted-move-calls.mjs.map +1 -0
  245. package/dist/transactions/serializer.d.mts +1 -4
  246. package/dist/transactions/serializer.d.mts.map +1 -1
  247. package/dist/transactions/serializer.mjs +1 -44
  248. package/dist/transactions/serializer.mjs.map +1 -1
  249. package/dist/transactions/utils.d.mts +0 -1
  250. package/dist/transactions/utils.d.mts.map +1 -1
  251. package/dist/transactions/utils.mjs.map +1 -1
  252. package/dist/utils/abort.mjs +89 -0
  253. package/dist/utils/abort.mjs.map +1 -0
  254. package/dist/utils/coin-reservation.mjs +1 -4
  255. package/dist/utils/coin-reservation.mjs.map +1 -1
  256. package/dist/utils/index.mjs +1 -1
  257. package/dist/utils/sui-types.mjs +1 -1
  258. package/dist/verify/index.d.mts +2 -2
  259. package/dist/verify/verify.d.mts +74 -24
  260. package/dist/verify/verify.d.mts.map +1 -1
  261. package/dist/verify/verify.mjs +128 -42
  262. package/dist/verify/verify.mjs.map +1 -1
  263. package/dist/version.mjs +1 -1
  264. package/dist/version.mjs.map +1 -1
  265. package/dist/zklogin/bcs.d.mts +14 -14
  266. package/dist/zklogin/publickey.d.mts.map +1 -1
  267. package/dist/zklogin/publickey.mjs +15 -20
  268. package/dist/zklogin/publickey.mjs.map +1 -1
  269. package/docs/bcs.md +2 -2
  270. package/docs/clients/core.md +19 -18
  271. package/docs/clients/executing.md +53 -8
  272. package/docs/clients/graphql.md +81 -11
  273. package/docs/clients/grpc.md +31 -15
  274. package/docs/clients/index.md +8 -7
  275. package/docs/clients/querying.md +134 -30
  276. package/docs/clients/streaming.md +324 -0
  277. package/docs/cryptography/index.md +85 -58
  278. package/docs/llms-index.md +4 -2
  279. package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
  280. package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
  281. package/docs/migrations/sui-3.0/index.md +247 -0
  282. package/docs/plugins.md +10 -10
  283. package/docs/sdk-building.md +3 -4
  284. package/docs/transactions/coins-and-balances.md +6 -11
  285. package/docs/transactions/reference.md +36 -1
  286. package/package.json +4 -5
  287. package/src/bcs/bcs.ts +80 -41
  288. package/src/bcs/effects.ts +61 -25
  289. package/src/bcs/index.ts +2 -0
  290. package/src/bcs/transactions.ts +36 -17
  291. package/src/bcs/types.ts +10 -4
  292. package/src/client/core-resolver.ts +3 -5
  293. package/src/client/core.ts +180 -8
  294. package/src/client/errors.ts +12 -0
  295. package/src/client/index.ts +4 -2
  296. package/src/client/mvr.ts +37 -10
  297. package/src/client/query-filters.ts +151 -97
  298. package/src/client/stream/adapter.ts +110 -0
  299. package/src/client/stream/errors.ts +40 -0
  300. package/src/client/stream/filter.ts +17 -0
  301. package/src/client/stream/follow.ts +63 -0
  302. package/src/client/stream/index.ts +9 -0
  303. package/src/client/stream/pager.ts +158 -0
  304. package/src/client/stream/plan.ts +147 -0
  305. package/src/client/stream/position.ts +143 -0
  306. package/src/client/stream/run.ts +147 -0
  307. package/src/client/stream/session.ts +259 -0
  308. package/src/client/stream/status.ts +44 -0
  309. package/src/client/stream/token.ts +104 -0
  310. package/src/client/transaction-data.ts +610 -0
  311. package/src/client/transaction-resolver.ts +158 -69
  312. package/src/client/types.ts +530 -115
  313. package/src/client/utils.ts +146 -61
  314. package/src/cryptography/publickey.ts +12 -1
  315. package/src/cryptography/signature.ts +6 -3
  316. package/src/graphql/client.ts +204 -135
  317. package/src/graphql/core.ts +446 -139
  318. package/src/graphql/errors.ts +24 -0
  319. package/src/graphql/filters.ts +48 -0
  320. package/src/graphql/generated/queries.ts +1455 -277
  321. package/src/graphql/generated/schema.graphql +282 -9
  322. package/src/graphql/generated/tada-env.ts +933 -4
  323. package/src/graphql/queries/checkpoints.graphql +34 -0
  324. package/src/graphql/queries/getDynamicFields.graphql +1 -0
  325. package/src/graphql/queries/listEvents.graphql +16 -24
  326. package/src/graphql/queries/streams.graphql +212 -0
  327. package/src/graphql/queries/transactions.graphql +71 -28
  328. package/src/graphql/queries/verifySignature.graphql +17 -0
  329. package/src/graphql/sse-parser.ts +99 -0
  330. package/src/graphql/stream/families.ts +515 -0
  331. package/src/graphql/stream/index.ts +55 -0
  332. package/src/graphql/stream/live.ts +70 -0
  333. package/src/graphql/stream/page.ts +47 -0
  334. package/src/graphql/stream/query.ts +52 -0
  335. package/src/graphql/subscribe.ts +83 -0
  336. package/src/grpc/client.ts +81 -79
  337. package/src/grpc/core.ts +388 -274
  338. package/src/grpc/filters.ts +59 -60
  339. package/src/grpc/grpc-web-pull.ts +360 -0
  340. package/src/grpc/index.ts +5 -0
  341. package/src/grpc/network-error.ts +33 -0
  342. package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
  343. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
  344. package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
  345. package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
  346. package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
  347. package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
  348. package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
  349. package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
  350. package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
  351. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
  352. package/src/grpc/pull-call.ts +54 -0
  353. package/src/grpc/stream/call.ts +317 -0
  354. package/src/grpc/stream/families.ts +228 -0
  355. package/src/grpc/stream/index.ts +182 -0
  356. package/src/grpc/stream/live.ts +33 -0
  357. package/src/grpc/stream/page.ts +161 -0
  358. package/src/grpc/stream-types.ts +33 -0
  359. package/src/grpc/transport.ts +116 -59
  360. package/src/jsonRpc/index.ts +60 -17
  361. package/src/jsonRpc/types.ts +421 -0
  362. package/src/multisig/publickey.ts +19 -7
  363. package/src/transactions/ObjectCache.ts +6 -6
  364. package/src/transactions/Transaction.ts +30 -6
  365. package/src/transactions/data/internal.ts +2 -0
  366. package/src/transactions/executor/serial.ts +2 -2
  367. package/src/transactions/index.ts +8 -1
  368. package/src/transactions/resolve.ts +6 -0
  369. package/src/transactions/restricted-move-calls.ts +87 -0
  370. package/src/transactions/serializer.ts +0 -70
  371. package/src/transactions/utils.ts +0 -37
  372. package/src/utils/abort.ts +101 -0
  373. package/src/verify/index.ts +1 -0
  374. package/src/verify/verify.ts +190 -62
  375. package/src/version.ts +1 -1
  376. package/src/zklogin/publickey.ts +18 -34
  377. package/dist/client/core-resolver.d.mts +0 -9
  378. package/dist/client/core-resolver.d.mts.map +0 -1
  379. package/dist/jsonRpc/client.d.mts +0 -507
  380. package/dist/jsonRpc/client.d.mts.map +0 -1
  381. package/dist/jsonRpc/client.mjs +0 -868
  382. package/dist/jsonRpc/client.mjs.map +0 -1
  383. package/dist/jsonRpc/core.d.mts +0 -168
  384. package/dist/jsonRpc/core.d.mts.map +0 -1
  385. package/dist/jsonRpc/core.mjs +0 -1054
  386. package/dist/jsonRpc/core.mjs.map +0 -1
  387. package/dist/jsonRpc/errors.d.mts +0 -27
  388. package/dist/jsonRpc/errors.d.mts.map +0 -1
  389. package/dist/jsonRpc/errors.mjs +0 -50
  390. package/dist/jsonRpc/errors.mjs.map +0 -1
  391. package/dist/jsonRpc/http-transport.d.mts +0 -62
  392. package/dist/jsonRpc/http-transport.d.mts.map +0 -1
  393. package/dist/jsonRpc/http-transport.mjs +0 -60
  394. package/dist/jsonRpc/http-transport.mjs.map +0 -1
  395. package/dist/jsonRpc/network.d.mts +0 -9
  396. package/dist/jsonRpc/network.d.mts.map +0 -1
  397. package/dist/jsonRpc/network.mjs +0 -18
  398. package/dist/jsonRpc/network.mjs.map +0 -1
  399. package/dist/jsonRpc/types/chain.d.mts +0 -169
  400. package/dist/jsonRpc/types/chain.d.mts.map +0 -1
  401. package/dist/jsonRpc/types/changes.d.mts +0 -48
  402. package/dist/jsonRpc/types/changes.d.mts.map +0 -1
  403. package/dist/jsonRpc/types/coins.d.mts +0 -15
  404. package/dist/jsonRpc/types/coins.d.mts.map +0 -1
  405. package/dist/jsonRpc/types/common.d.mts +0 -9
  406. package/dist/jsonRpc/types/common.d.mts.map +0 -1
  407. package/dist/jsonRpc/types/generated.d.mts +0 -1976
  408. package/dist/jsonRpc/types/generated.d.mts.map +0 -1
  409. package/dist/jsonRpc/types/index.d.mts +0 -6
  410. package/dist/jsonRpc/types/params.d.mts +0 -898
  411. package/dist/jsonRpc/types/params.d.mts.map +0 -1
  412. package/src/graphql/generated/tsconfig.tada.json +0 -11
  413. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
  414. package/src/jsonRpc/client.ts +0 -1252
  415. package/src/jsonRpc/core.ts +0 -1557
  416. package/src/jsonRpc/errors.ts +0 -57
  417. package/src/jsonRpc/http-transport.ts +0 -118
  418. package/src/jsonRpc/network.ts +0 -21
  419. package/src/jsonRpc/types/chain.ts +0 -190
  420. package/src/jsonRpc/types/changes.ts +0 -35
  421. package/src/jsonRpc/types/coins.ts +0 -14
  422. package/src/jsonRpc/types/common.ts +0 -8
  423. package/src/jsonRpc/types/generated.ts +0 -2165
  424. package/src/jsonRpc/types/index.ts +0 -9
  425. package/src/jsonRpc/types/params.ts +0 -908
package/src/grpc/core.ts CHANGED
@@ -7,12 +7,11 @@ import {
7
7
  formatMoveAbortMessage,
8
8
  ObjectError,
9
9
  SimulationError,
10
+ SuiStreamError,
10
11
  TransactionError,
11
12
  } from '../client/index.js';
12
13
  import { raceSignal } from '../client/mvr.js';
13
14
  import type { SuiGrpcClient } from './client.js';
14
- import type { Owner } from './proto/sui/rpc/v2/owner.js';
15
- import { Owner_OwnerKind } from './proto/sui/rpc/v2/owner.js';
16
15
  import { chunk, fromBase64, toBase64 } from '@mysten/utils';
17
16
  import type { TransactionEffects } from './proto/sui/rpc/v2/effects.js';
18
17
  import {
@@ -24,6 +23,7 @@ import {
24
23
  import type {
25
24
  ExecutionError as GrpcExecutionError,
26
25
  MoveAbort as GrpcMoveAbort,
26
+ MoveLocation as GrpcMoveLocation,
27
27
  } from './proto/sui/rpc/v2/execution_status.js';
28
28
  import {
29
29
  ExecutionError_ExecutionErrorKind,
@@ -34,6 +34,7 @@ import {
34
34
  import type { BuildTransactionOptions } from '../transactions/index.js';
35
35
  import { TransactionDataBuilder } from '../transactions/index.js';
36
36
  import { bcs } from '../bcs/index.js';
37
+ import { grpcTransactionToLedgerTransactionData } from '../client/transaction-data.js';
37
38
  import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
38
39
  import { SUI_TYPE_ARG } from '../utils/constants.js';
39
40
  import type { OpenSignature, OpenSignatureBody } from './proto/sui/rpc/v2/move_package.js';
@@ -45,34 +46,47 @@ import {
45
46
  } from './proto/sui/rpc/v2/move_package.js';
46
47
  import {
47
48
  applyGrpcResolvedTransaction,
49
+ grpcTimestampToMilliseconds,
50
+ mapOwner,
48
51
  transactionDataToGrpcTransaction,
49
52
  transactionToGrpcTransaction,
50
- grpcTransactionToTransactionData,
51
53
  } from '../client/transaction-resolver.js';
52
54
  import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from '../client/address-balance-transaction-expiration.js';
53
- import { isMockedGasObjectId, transactionBytesHaveEmptyGasPayment } from '../client/utils.js';
55
+ import {
56
+ decodeSignature,
57
+ isMockedGasObjectId,
58
+ resolveVerifySignatureOptions,
59
+ transactionBytesHaveEmptyGasPayment,
60
+ } from '../client/utils.js';
54
61
  import { Value } from './proto/google/protobuf/struct.js';
62
+ import type { VerifySignatureResponse } from './proto/sui/rpc/v2/signature_verification_service.js';
63
+ import { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';
55
64
  import { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
56
65
  import {
57
66
  SimulateTransactionRequest_TransactionChecks,
58
67
  SimulateTransactionResponse,
59
68
  } from './proto/sui/rpc/v2/transaction_execution_service.js';
60
69
  import type { QueryEnd, QueryOptions } from './proto/sui/rpc/v2/query_options.js';
70
+ import type { Checkpoint } from './proto/sui/rpc/v2/checkpoint.js';
71
+ import type { Event } from './proto/sui/rpc/v2/event.js';
61
72
  import { Ordering, QueryEndReason } from './proto/sui/rpc/v2/query_options.js';
62
73
  import type { ResolvedPagination } from '../client/query-filters.js';
63
74
  import { RpcError } from '@protobuf-ts/runtime-rpc';
64
75
  import { GrpcStatusCode } from '@protobuf-ts/grpcweb-transport';
65
76
  import {
77
+ resolveCheckpointRange,
66
78
  resolveEventFilter,
67
79
  resolvePagination,
68
80
  resolveTransactionFilter,
69
- validateTransactionQuery,
70
81
  } from '../client/query-filters.js';
71
82
  import { toGrpcEventFilter, toGrpcTransactionFilter } from './filters.js';
72
- import { hasDecodedStatusMessage } from './transport.js';
83
+ import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
84
+ import { GrpcLedgerStreamAdapter, type GrpcLedgerStreamRequest } from './stream/index.js';
73
85
 
74
86
  export interface GrpcCoreClientOptions extends CoreClientOptions {
75
87
  client: SuiGrpcClient;
88
+ /** The transport ledger streams read from; `SuiGrpcClient` passes its own. */
89
+ transport?: RpcTransport;
76
90
  }
77
91
 
78
92
  function isNameServiceResolutionMiss(error: unknown): boolean {
@@ -86,18 +100,34 @@ function isNameServiceResolutionMiss(error: unknown): boolean {
86
100
  if (code !== GrpcStatusCode[GrpcStatusCode.RESOURCE_EXHAUSTED]) return false;
87
101
 
88
102
  // The service reports an expired name as RESOURCE_EXHAUSTED with no structured reason, so match
89
- // the status text and leave other RESOURCE_EXHAUSTED failures alone. A transport this package did
90
- // not build leaves `grpc-message` encoded, hence the second form.
91
- if (message === 'name has expired') return true;
92
-
93
- return !hasDecodedStatusMessage(error) && message === 'name%20has%20expired';
103
+ // the status text. A transport this package did not build leaves `grpc-message` encoded.
104
+ return message === 'name has expired' || message === 'name%20has%20expired';
94
105
  }
95
106
 
96
107
  export class GrpcCoreClient extends CoreClient {
97
108
  #client: SuiGrpcClient;
98
- constructor({ client, ...options }: GrpcCoreClientOptions) {
109
+ #transport?: RpcTransport;
110
+ constructor({ client, transport, ...options }: GrpcCoreClientOptions) {
99
111
  super(options);
100
112
  this.#client = client;
113
+ this.#transport = transport;
114
+ }
115
+
116
+ protected override createLedgerStreamAdapter(request: GrpcLedgerStreamRequest) {
117
+ // Streams call the transport directly to read responses on demand.
118
+ const transport = this.#transport;
119
+ if (!transport) {
120
+ throw new SuiStreamError('InvalidOptions', 'Ledger streams need a `transport` option');
121
+ }
122
+ return new GrpcLedgerStreamAdapter(
123
+ {
124
+ transport,
125
+ mvr: this.mvr,
126
+ chainIdentifier: async (signal) =>
127
+ (await this.getChainIdentifier({ signal })).chainIdentifier,
128
+ },
129
+ request,
130
+ );
101
131
  }
102
132
 
103
133
  async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
@@ -140,10 +170,7 @@ export class GrpcCoreClient extends CoreClient {
140
170
  if (object.result.oneofKind === 'error') {
141
171
  const error = object.result.error;
142
172
  if (error.code === GrpcStatusCode.NOT_FOUND) {
143
- // Special case for backwards compatibility: missing objects reuse
144
- // the long-standing JSON-RPC `notExists` code instead of the gRPC
145
- // status name, so handlers written against earlier releases keep
146
- // working.
173
+ // Missing objects use the `notExists` code rather than the gRPC status name.
147
174
  return new ObjectError('notExists', error.message, {
148
175
  cause: error,
149
176
  reason: 'notFound',
@@ -450,7 +477,7 @@ export class GrpcCoreClient extends CoreClient {
450
477
  );
451
478
  }
452
479
  async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
453
- options: SuiClientTypes.SimulateTransactionOptions<Include> & { doGasSelection?: boolean },
480
+ options: SuiClientTypes.SimulateTransactionOptions<Include>,
454
481
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
455
482
  // The simulated transaction is nested one level deeper in the response
456
483
  const paths = transactionReadMaskPaths(options.include, 'transaction.');
@@ -638,10 +665,64 @@ export class GrpcCoreClient extends CoreClient {
638
665
  };
639
666
  }
640
667
 
641
- async listDynamicFields(
642
- options: SuiClientTypes.ListDynamicFieldsOptions,
643
- ): Promise<SuiClientTypes.ListDynamicFieldsResponse> {
644
- return this.#client.listDynamicFields(options);
668
+ async listDynamicFields<Include extends SuiClientTypes.DynamicFieldInclude = {}>(
669
+ options: SuiClientTypes.ListDynamicFieldsOptions<Include>,
670
+ ): Promise<SuiClientTypes.ListDynamicFieldsResponse<Include>> {
671
+ const includeValue = options.include?.value ?? false;
672
+ const paths = ['field_id', 'name', 'value_type', 'kind', 'child_id'];
673
+ if (includeValue) {
674
+ // `value` of a dynamic object field is only the child's ID, so read the child's contents too
675
+ paths.push('value', 'child_object.contents');
676
+ }
677
+
678
+ const response = await this.#client.stateService.listDynamicFields(
679
+ {
680
+ parent: options.parentId,
681
+ pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
682
+ pageSize: options.limit,
683
+ readMask: {
684
+ paths,
685
+ },
686
+ },
687
+ { abort: options.signal },
688
+ );
689
+
690
+ return {
691
+ dynamicFields: response.response.dynamicFields.map((field) => {
692
+ const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
693
+ const nameType = field.name?.name!;
694
+ const valueType = field.valueType!;
695
+ const fieldType = isDynamicObject
696
+ ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${nameType}>,0x2::object::ID>`
697
+ : `0x2::dynamic_field::Field<${nameType},${valueType}>`;
698
+
699
+ let value: SuiClientTypes.DynamicFieldValue | undefined;
700
+ if (includeValue) {
701
+ const valueBcs = isDynamicObject
702
+ ? field.childObject?.contents?.value
703
+ : field.value?.value;
704
+ if (valueBcs == null) {
705
+ throw new Error(`Missing value for dynamic field ${field.fieldId}`);
706
+ }
707
+ value = { type: valueType, bcs: valueBcs };
708
+ }
709
+
710
+ return {
711
+ $kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
712
+ fieldId: field.fieldId!,
713
+ type: normalizeStructTag(fieldType),
714
+ name: {
715
+ type: nameType,
716
+ bcs: field.name?.value!,
717
+ },
718
+ valueType,
719
+ childId: isDynamicObject ? field.childId : undefined,
720
+ value,
721
+ } as SuiClientTypes.DynamicFieldEntry<Include>;
722
+ }),
723
+ cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
724
+ hasNextPage: response.response.nextPageToken !== undefined,
725
+ };
645
726
  }
646
727
 
647
728
  async listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
@@ -649,189 +730,146 @@ export class GrpcCoreClient extends CoreClient {
649
730
  ): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
650
731
  const paths = transactionReadMaskPaths(options.include);
651
732
 
733
+ const pagination = resolvePagination(options);
734
+ const range = resolveCheckpointRange(options);
652
735
  const filter = options.filter
653
736
  ? await resolveTransactionFilter(this.mvr, options.filter, options.signal)
654
737
  : undefined;
655
- const pagination = resolvePagination(options);
656
- validateTransactionQuery(filter, pagination);
657
738
 
658
739
  const call = this.#client.ledgerService.listTransactions(
659
740
  {
660
741
  readMask: { paths },
661
- filter: filter && toGrpcTransactionFilter(filter),
662
- // Request one extra item as lookahead: the server reports its item limit as reached
663
- // without scanning past it, so an exact-limit final page is otherwise
664
- // indistinguishable from one with more results
742
+ filter: toGrpcTransactionFilter(filter),
743
+ startCheckpoint: range.start,
744
+ endCheckpoint: range.end,
745
+ // Request one extra item as lookahead (see collectListPage)
665
746
  options: toGrpcQueryOptions(pagination, pagination.limit + 1),
666
747
  },
667
748
  { abort: options.signal },
668
749
  );
669
750
 
670
- const transactions: SuiClientTypes.TransactionResult<Include>[] = [];
671
- let startCursor: string | null = null;
672
- let endCursor: string | null = null;
673
- let frontier: string | null = null;
674
- let end: QueryEnd | undefined;
675
- let sawLookaheadItem = false;
676
-
677
- for await (const frame of call.responses) {
678
- if (frame.watermark?.cursor) {
679
- frontier = toBase64(frame.watermark.cursor);
680
- }
681
- if (frame.transaction) {
682
- if (transactions.length >= pagination.limit) {
683
- sawLookaheadItem = true;
684
- } else {
685
- startCursor ??= frontier;
686
- endCursor = frontier;
687
- transactions.push(
688
- parseGrpcTransactionResponse(frame.transaction, { include: options.include }),
689
- );
690
- }
691
- }
692
- if (frame.end) {
693
- end = frame.end;
694
- }
695
- }
696
-
697
- // ITEM_LIMIT without the lookahead item means the server clamped the requested limit to
698
- // its own maximum, so the filled page is still evidence of a possible next page
699
- const hasNextPage =
700
- sawLookaheadItem ||
701
- end?.reason === QueryEndReason.SCAN_LIMIT ||
702
- end?.reason === QueryEndReason.ITEM_LIMIT;
751
+ const { items, ...page } = await collectListPage(
752
+ call.responses,
753
+ pagination.limit,
754
+ (frame) => frame.transaction,
755
+ (transaction) => parseGrpcTransactionResponse(transaction, { include: options.include }),
756
+ );
703
757
 
704
- return {
705
- transactions,
706
- hasNextPage,
707
- startCursor,
708
- // Scans that stopped early without filling the page continue from the scan frontier
709
- // (so already-scanned positions are not revisited), full pages continue after the last
710
- // returned item, and terminal pages have no positions to continue from
711
- endCursor: sawLookaheadItem ? endCursor : hasNextPage ? (frontier ?? endCursor) : endCursor,
712
- };
758
+ return { transactions: items, ...page };
713
759
  }
714
760
 
715
761
  async listEvents(
716
762
  options: SuiClientTypes.ListEventsOptions,
717
763
  ): Promise<SuiClientTypes.ListEventsResponse> {
718
764
  const pagination = resolvePagination(options);
765
+ const range = resolveCheckpointRange(options);
766
+ const filter = options.filter
767
+ ? await resolveEventFilter(this.mvr, options.filter, options.signal)
768
+ : undefined;
719
769
  const call = this.#client.ledgerService.listEvents(
720
770
  {
721
- readMask: {
722
- paths: [
723
- 'package_id',
724
- 'module',
725
- 'sender',
726
- 'event_type',
727
- 'contents',
728
- 'json',
729
- 'checkpoint',
730
- 'transaction_digest',
731
- 'event_index',
732
- ],
733
- },
734
- filter: options.filter
735
- ? toGrpcEventFilter(await resolveEventFilter(this.mvr, options.filter, options.signal))
736
- : undefined,
737
- // Request one extra item as lookahead: the server reports its item limit as reached
738
- // without scanning past it, so an exact-limit final page is otherwise
739
- // indistinguishable from one with more results
771
+ readMask: { paths: EVENT_READ_MASK_PATHS },
772
+ filter: toGrpcEventFilter(filter),
773
+ startCheckpoint: range.start,
774
+ endCheckpoint: range.end,
775
+ // Request one extra item as lookahead (see collectListPage)
740
776
  options: toGrpcQueryOptions(pagination, pagination.limit + 1),
741
777
  },
742
778
  { abort: options.signal },
743
779
  );
744
780
 
745
- const events: SuiClientTypes.EventEntry[] = [];
746
- let startCursor: string | null = null;
747
- let endCursor: string | null = null;
748
- let frontier: string | null = null;
749
- let end: QueryEnd | undefined;
750
- let sawLookaheadItem = false;
781
+ const { items, ...page } = await collectListPage(
782
+ call.responses,
783
+ pagination.limit,
784
+ (frame) => frame.event,
785
+ (event) => parseGrpcEvent(event, 'listEvents'),
786
+ );
751
787
 
752
- for await (const frame of call.responses) {
753
- if (frame.watermark?.cursor) {
754
- frontier = toBase64(frame.watermark.cursor);
755
- }
756
- if (frame.event) {
757
- if (events.length >= pagination.limit) {
758
- sawLookaheadItem = true;
759
- } else {
760
- startCursor ??= frontier;
761
- endCursor = frontier;
762
- const event = frame.event;
763
- events.push({
764
- packageId: normalizeSuiAddress(event.packageId!),
765
- module: event.module!,
766
- sender: normalizeSuiAddress(event.sender!),
767
- eventType: normalizeStructTag(event.eventType!),
768
- bcs: event.contents?.value ?? new Uint8Array(),
769
- json: event.json ? (Value.toJson(event.json) as Record<string, unknown>) : null,
770
- checkpoint: event.checkpoint?.toString() ?? null,
771
- transactionDigest: event.transactionDigest!,
772
- eventIndex: event.eventIndex!,
773
- });
774
- }
775
- }
776
- if (frame.end) {
777
- end = frame.end;
778
- }
779
- }
788
+ return { events: items, ...page };
789
+ }
780
790
 
781
- // ITEM_LIMIT without the lookahead item means the server clamped the requested limit to
782
- // its own maximum, so the filled page is still evidence of a possible next page
783
- const hasNextPage =
784
- sawLookaheadItem ||
785
- end?.reason === QueryEndReason.SCAN_LIMIT ||
786
- end?.reason === QueryEndReason.ITEM_LIMIT;
791
+ async listCheckpoints(
792
+ options: SuiClientTypes.ListCheckpointsOptions,
793
+ ): Promise<SuiClientTypes.ListCheckpointsResponse> {
794
+ const pagination = resolvePagination(options);
795
+ const range = resolveCheckpointRange(options);
796
+ const call = this.#client.ledgerService.listCheckpoints(
797
+ {
798
+ readMask: { paths: CHECKPOINT_READ_MASK_PATHS },
799
+ startCheckpoint: range.start,
800
+ endCheckpoint: range.end,
801
+ // Request one extra item as lookahead (see collectListPage)
802
+ options: toGrpcQueryOptions(pagination, pagination.limit + 1),
803
+ },
804
+ { abort: options.signal },
805
+ );
787
806
 
788
- return {
789
- events,
790
- hasNextPage,
791
- startCursor,
792
- // Scans that stopped early without filling the page continue from the scan frontier
793
- // (so already-scanned positions are not revisited), full pages continue after the last
794
- // returned item, and terminal pages have no positions to continue from
795
- endCursor: sawLookaheadItem ? endCursor : hasNextPage ? (frontier ?? endCursor) : endCursor,
796
- };
797
- }
807
+ const { items, ...page } = await collectListPage(
808
+ call.responses,
809
+ pagination.limit,
810
+ (frame) => frame.checkpoint,
811
+ (checkpoint) => parseGrpcCheckpoint(checkpoint, 'listCheckpoints'),
812
+ );
798
813
 
799
- async verifyZkLoginSignature(
800
- options: SuiClientTypes.VerifyZkLoginSignatureOptions,
801
- ): Promise<SuiClientTypes.ZkLoginVerifyResponse> {
802
- const messageBytes = fromBase64(options.bytes);
814
+ return { checkpoints: items, ...page };
815
+ }
803
816
 
804
- // For PersonalMessage, the server expects BCS-encoded vector<u8>
805
- // For TransactionData, the server expects the raw BCS-encoded TransactionData as-is
806
- const messageValue =
807
- options.intentScope === 'PersonalMessage'
808
- ? bcs.byteVector().serialize(messageBytes).toBytes()
809
- : messageBytes;
817
+ async verifySignature(
818
+ options: SuiClientTypes.VerifySignatureOptions,
819
+ ): Promise<SuiClientTypes.VerifySignatureResponse> {
820
+ const { intentScope, message, address, checkAddressAliases } =
821
+ resolveVerifySignatureOptions(options);
822
+ const signature = decodeSignature(options.signature);
823
+ if (!signature) {
824
+ return { valid: false, reason: 'Cannot parse signature' };
825
+ }
810
826
 
811
- const { response } = await this.#client.signatureVerificationService.verifySignature(
812
- {
813
- message: {
814
- name: options.intentScope,
815
- value: messageValue,
816
- },
817
- signature: {
818
- bcs: {
819
- value: fromBase64(options.signature),
827
+ let response: VerifySignatureResponse;
828
+ try {
829
+ ({ response } = await this.#client.signatureVerificationService.verifySignature(
830
+ {
831
+ message: {
832
+ name: intentScope,
833
+ // A personal message is sent as a BCS `vector<u8>`, transaction data as-is.
834
+ value:
835
+ intentScope === 'PersonalMessage'
836
+ ? bcs.byteVector().serialize(message).toBytes()
837
+ : message,
820
838
  },
821
839
  signature: {
822
- oneofKind: undefined,
840
+ bcs: { value: signature },
841
+ signature: { oneofKind: undefined },
823
842
  },
843
+ address,
844
+ checkAddressAliases,
845
+ jwks: [],
824
846
  },
825
- address: options.address,
826
- jwks: [],
827
- },
828
- { abort: options.signal },
829
- );
847
+ { abort: options.signal },
848
+ ));
849
+ } catch (error) {
850
+ // The SDK builds every other field, so a rejected argument is a signature the node can't
851
+ // parse.
852
+ if (
853
+ error instanceof RpcError &&
854
+ error.code === GrpcStatusCode[GrpcStatusCode.INVALID_ARGUMENT]
855
+ ) {
856
+ return { valid: false, reason: error.message };
857
+ }
858
+ throw error;
859
+ }
830
860
 
831
- return {
832
- success: response.isValid ?? false,
833
- errors: response.reason ? [response.reason] : [],
834
- };
861
+ if (typeof response.isValid !== 'boolean') {
862
+ throw new Error('The node returned no signature verification verdict');
863
+ }
864
+ // Nodes without alias support ignore the request flag and check the exact address only.
865
+ if (checkAddressAliases && response.addressAliasesChecked !== true) {
866
+ throw new Error(
867
+ 'The node does not support checking address aliases; pass `checkAddressAliases: false` to verify the exact address only.',
868
+ );
869
+ }
870
+ return response.isValid
871
+ ? { valid: true }
872
+ : { valid: false, reason: response.reason ?? 'Signature is not valid' };
835
873
  }
836
874
 
837
875
  async defaultNameServiceName(
@@ -1037,6 +1075,135 @@ export class GrpcCoreClient extends CoreClient {
1037
1075
  }
1038
1076
  }
1039
1077
 
1078
+ export const CHECKPOINT_READ_MASK_PATHS = [
1079
+ 'sequence_number',
1080
+ 'digest',
1081
+ 'summary.epoch',
1082
+ 'summary.timestamp',
1083
+ ];
1084
+
1085
+ export const EVENT_READ_MASK_PATHS = [
1086
+ 'package_id',
1087
+ 'module',
1088
+ 'sender',
1089
+ 'event_type',
1090
+ 'contents',
1091
+ 'json',
1092
+ 'checkpoint',
1093
+ 'transaction_digest',
1094
+ 'event_index',
1095
+ ];
1096
+
1097
+ /** `source` names the response in the error thrown when required fields are missing. */
1098
+ export function parseGrpcCheckpoint(
1099
+ checkpoint: Checkpoint,
1100
+ source: string,
1101
+ ): SuiClientTypes.Checkpoint {
1102
+ const timestamp = checkpoint.summary?.timestamp;
1103
+ if (
1104
+ checkpoint.sequenceNumber == null ||
1105
+ !checkpoint.digest ||
1106
+ checkpoint.summary?.epoch == null ||
1107
+ !timestamp
1108
+ ) {
1109
+ throw new Error(`${source} response is missing expected checkpoint fields`);
1110
+ }
1111
+ return {
1112
+ sequenceNumber: checkpoint.sequenceNumber.toString(),
1113
+ digest: checkpoint.digest,
1114
+ epoch: checkpoint.summary.epoch.toString(),
1115
+ timestampMs: Number(grpcTimestampToMilliseconds(timestamp)),
1116
+ };
1117
+ }
1118
+
1119
+ /** `source` names the response in the error thrown when required fields are missing. */
1120
+ function parseGrpcEventFields(event: Event, source: string): SuiClientTypes.Event {
1121
+ if (!event.packageId || !event.module || !event.sender || !event.eventType) {
1122
+ throw new Error(`${source} response is missing expected event fields`);
1123
+ }
1124
+ return {
1125
+ packageId: normalizeSuiAddress(event.packageId),
1126
+ module: event.module,
1127
+ sender: normalizeSuiAddress(event.sender),
1128
+ eventType: normalizeStructTag(event.eventType),
1129
+ bcs: event.contents?.value ?? new Uint8Array(),
1130
+ json: event.json ? (Value.toJson(event.json) as Record<string, unknown>) : null,
1131
+ };
1132
+ }
1133
+
1134
+ /** `source` names the response in the error thrown when required fields are missing. */
1135
+ export function parseGrpcEvent(event: Event, source: string): SuiClientTypes.EventEntry {
1136
+ if (!event.transactionDigest || event.eventIndex == null || event.checkpoint == null) {
1137
+ throw new Error(`${source} response is missing expected event fields`);
1138
+ }
1139
+ return {
1140
+ ...parseGrpcEventFields(event, source),
1141
+ checkpoint: event.checkpoint.toString(),
1142
+ transactionDigest: event.transactionDigest,
1143
+ eventIndex: event.eventIndex,
1144
+ };
1145
+ }
1146
+
1147
+ /**
1148
+ * Collects one page from a streaming ledger query (listTransactions, listEvents,
1149
+ * listCheckpoints) that was sent with a limit of `limit + 1`. The extra item is a lookahead:
1150
+ * the server reports its item limit as reached without scanning past it, so an exact-limit
1151
+ * final page is otherwise indistinguishable from one with more results.
1152
+ */
1153
+ async function collectListPage<
1154
+ Frame extends { watermark?: { cursor?: Uint8Array }; end?: QueryEnd },
1155
+ Item,
1156
+ Result,
1157
+ >(
1158
+ responses: AsyncIterable<Frame>,
1159
+ limit: number,
1160
+ pick: (frame: Frame) => Item | undefined,
1161
+ map: (item: Item) => Result,
1162
+ ): Promise<SuiClientTypes.LedgerQueryResponse & { items: Result[] }> {
1163
+ const items: Result[] = [];
1164
+ let startCursor: string | null = null;
1165
+ let endCursor: string | null = null;
1166
+ let frontier: string | null = null;
1167
+ let end: QueryEnd | undefined;
1168
+ let sawLookaheadItem = false;
1169
+
1170
+ for await (const frame of responses) {
1171
+ if (frame.watermark?.cursor) {
1172
+ frontier = toBase64(frame.watermark.cursor);
1173
+ }
1174
+ const item = pick(frame);
1175
+ if (item) {
1176
+ if (items.length >= limit) {
1177
+ sawLookaheadItem = true;
1178
+ } else {
1179
+ startCursor ??= frontier;
1180
+ endCursor = frontier;
1181
+ items.push(map(item));
1182
+ }
1183
+ }
1184
+ if (frame.end) {
1185
+ end = frame.end;
1186
+ }
1187
+ }
1188
+
1189
+ // ITEM_LIMIT without the lookahead item means the server clamped the requested limit to
1190
+ // its own maximum, so the filled page is still evidence of a possible next page
1191
+ const hasNextPage =
1192
+ sawLookaheadItem ||
1193
+ end?.reason === QueryEndReason.SCAN_LIMIT ||
1194
+ end?.reason === QueryEndReason.ITEM_LIMIT;
1195
+
1196
+ return {
1197
+ items,
1198
+ hasNextPage,
1199
+ startCursor,
1200
+ // Scans that stopped early without filling the page continue from the scan frontier
1201
+ // (so already-scanned positions are not revisited), full pages continue after the last
1202
+ // returned item, and terminal pages have no positions to continue from
1203
+ endCursor: sawLookaheadItem ? endCursor : hasNextPage ? (frontier ?? endCursor) : endCursor,
1204
+ };
1205
+ }
1206
+
1040
1207
  function toGrpcQueryOptions(pagination: ResolvedPagination, limit: number): QueryOptions {
1041
1208
  return {
1042
1209
  limit,
@@ -1046,26 +1213,27 @@ function toGrpcQueryOptions(pagination: ResolvedPagination, limit: number): Quer
1046
1213
  };
1047
1214
  }
1048
1215
 
1049
- function transactionReadMaskPaths(
1216
+ /**
1217
+ * The read mask paths `parseGrpcTransactionResponse` needs for `include`, under `prefix` (such as
1218
+ * `'transaction.'` for a simulation response).
1219
+ */
1220
+ export function transactionReadMaskPaths(
1050
1221
  include: SuiClientTypes.TransactionInclude | undefined,
1051
1222
  prefix = '',
1052
1223
  ): string[] {
1053
1224
  const paths = [
1054
1225
  'digest',
1055
1226
  'transaction.digest',
1227
+ 'transaction.sender',
1056
1228
  'signatures',
1057
1229
  'effects.status',
1230
+ 'effects.epoch',
1058
1231
  'timestamp',
1059
1232
  'checkpoint',
1060
1233
  ];
1061
1234
 
1062
1235
  if (include?.transaction) {
1063
- paths.push(
1064
- 'transaction.sender',
1065
- 'transaction.gas_payment',
1066
- 'transaction.expiration',
1067
- 'transaction.kind',
1068
- );
1236
+ paths.push('transaction.gas_payment', 'transaction.expiration', 'transaction.kind');
1069
1237
  }
1070
1238
  if (include?.bcs) {
1071
1239
  paths.push('transaction.bcs');
@@ -1080,7 +1248,6 @@ function transactionReadMaskPaths(
1080
1248
  paths.push('events');
1081
1249
  }
1082
1250
  if (include?.objectTypes) {
1083
- // Use effects.changed_objects to match JSON-RPC behavior (which uses objectChanges)
1084
1251
  paths.push('effects.changed_objects.object_type');
1085
1252
  paths.push('effects.changed_objects.object_id');
1086
1253
  }
@@ -1121,53 +1288,6 @@ function mapDisplayProto(
1121
1288
  };
1122
1289
  }
1123
1290
 
1124
- function mapOwner(owner: Owner | null | undefined): SuiClientTypes.ObjectOwner | null {
1125
- if (!owner) {
1126
- return null;
1127
- }
1128
- if (owner.kind === Owner_OwnerKind.IMMUTABLE) {
1129
- return {
1130
- $kind: 'Immutable',
1131
- Immutable: true,
1132
- };
1133
- }
1134
- if (owner.kind === Owner_OwnerKind.ADDRESS) {
1135
- return {
1136
- AddressOwner: owner.address!,
1137
- $kind: 'AddressOwner',
1138
- };
1139
- }
1140
- if (owner.kind === Owner_OwnerKind.OBJECT) {
1141
- return {
1142
- $kind: 'ObjectOwner',
1143
- ObjectOwner: owner.address!,
1144
- };
1145
- }
1146
-
1147
- if (owner.kind === Owner_OwnerKind.SHARED) {
1148
- return {
1149
- $kind: 'Shared',
1150
- Shared: {
1151
- initialSharedVersion: owner.version?.toString()!,
1152
- },
1153
- };
1154
- }
1155
-
1156
- if (owner.kind === Owner_OwnerKind.CONSENSUS_ADDRESS) {
1157
- return {
1158
- $kind: 'ConsensusAddressOwner',
1159
- ConsensusAddressOwner: {
1160
- startVersion: owner.version?.toString()!,
1161
- owner: owner.address!,
1162
- },
1163
- };
1164
- }
1165
-
1166
- throw new Error(
1167
- `Unknown owner kind ${JSON.stringify(owner, (_k, v) => (typeof v === 'bigint' ? v.toString() : v))}`,
1168
- );
1169
- }
1170
-
1171
1291
  function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.ExecutionError {
1172
1292
  const message = error.description ?? 'Unknown error';
1173
1293
  const command = error.command != null ? Number(error.command) : undefined;
@@ -1175,28 +1295,17 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1175
1295
 
1176
1296
  switch (details?.oneofKind) {
1177
1297
  case 'abort': {
1178
- const abort = details.abort;
1179
- const cleverError = abort.cleverError;
1298
+ const moveAbort = parseMoveAbort(details.abort);
1180
1299
  return {
1181
1300
  $kind: 'MoveAbort',
1182
1301
  message: formatMoveAbortMessage({
1183
1302
  command,
1184
- location: abort.location,
1185
- abortCode: String(abort.abortCode ?? 0n),
1186
- cleverError: cleverError
1187
- ? {
1188
- lineNumber:
1189
- cleverError.lineNumber != null ? Number(cleverError.lineNumber) : undefined,
1190
- constantName: cleverError.constantName,
1191
- value:
1192
- cleverError.value?.oneofKind === 'rendered'
1193
- ? cleverError.value.rendered
1194
- : undefined,
1195
- }
1196
- : undefined,
1303
+ location: moveAbort.location,
1304
+ abortCode: moveAbort.abortCode,
1305
+ cleverError: moveAbort.cleverError,
1197
1306
  }),
1198
1307
  command,
1199
- MoveAbort: parseMoveAbort(abort),
1308
+ MoveAbort: moveAbort,
1200
1309
  };
1201
1310
  }
1202
1311
 
@@ -1206,7 +1315,7 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1206
1315
  message,
1207
1316
  command,
1208
1317
  SizeError: {
1209
- name: mapErrorName(error.kind),
1318
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
1210
1319
  size: Number(details.sizeError.size ?? 0n),
1211
1320
  maxSize: Number(details.sizeError.maxSize ?? 0n),
1212
1321
  },
@@ -1219,7 +1328,10 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1219
1328
  command,
1220
1329
  CommandArgumentError: {
1221
1330
  argument: details.commandArgumentError.argument ?? 0,
1222
- name: mapErrorName(details.commandArgumentError.kind),
1331
+ name: mapErrorName(
1332
+ CommandArgumentError_CommandArgumentErrorKind,
1333
+ details.commandArgumentError.kind,
1334
+ ),
1223
1335
  },
1224
1336
  };
1225
1337
 
@@ -1230,7 +1342,10 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1230
1342
  command,
1231
1343
  TypeArgumentError: {
1232
1344
  typeArgument: details.typeArgumentError.typeArgument ?? 0,
1233
- name: mapErrorName(details.typeArgumentError.kind),
1345
+ name: mapErrorName(
1346
+ TypeArgumentError_TypeArgumentErrorKind,
1347
+ details.typeArgumentError.kind,
1348
+ ),
1234
1349
  },
1235
1350
  };
1236
1351
 
@@ -1240,7 +1355,10 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1240
1355
  message,
1241
1356
  command,
1242
1357
  PackageUpgradeError: {
1243
- name: mapErrorName(details.packageUpgradeError.kind),
1358
+ name: mapErrorName(
1359
+ PackageUpgradeError_PackageUpgradeErrorKind,
1360
+ details.packageUpgradeError.kind,
1361
+ ),
1244
1362
  packageId: details.packageUpgradeError.packageId,
1245
1363
  digest: details.packageUpgradeError.digest,
1246
1364
  },
@@ -1263,7 +1381,7 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1263
1381
  message,
1264
1382
  command,
1265
1383
  CoinDenyListError: {
1266
- name: mapErrorName(error.kind),
1384
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
1267
1385
  coinType: details.coinDenyListError.coinType!,
1268
1386
  address: details.coinDenyListError.address,
1269
1387
  },
@@ -1275,7 +1393,7 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1275
1393
  message,
1276
1394
  command,
1277
1395
  CongestedObjects: {
1278
- name: mapErrorName(error.kind),
1396
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
1279
1397
  objects: details.congestedObjects.objects,
1280
1398
  },
1281
1399
  };
@@ -1286,7 +1404,7 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1286
1404
  message,
1287
1405
  command,
1288
1406
  ObjectIdError: {
1289
- name: mapErrorName(error.kind),
1407
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
1290
1408
  objectId: details.objectId,
1291
1409
  },
1292
1410
  };
@@ -1304,7 +1422,7 @@ function parseGrpcExecutionError(error: GrpcExecutionError): SuiClientTypes.Exec
1304
1422
  function parseMoveAbort(abort: GrpcMoveAbort): SuiClientTypes.MoveAbort {
1305
1423
  return {
1306
1424
  abortCode: String(abort.abortCode ?? 0n),
1307
- location: { ...abort.location },
1425
+ location: abort.location && parseMoveLocation(abort.location),
1308
1426
  cleverError: abort.cleverError
1309
1427
  ? {
1310
1428
  errorCode:
@@ -1324,18 +1442,22 @@ function parseMoveAbort(abort: GrpcMoveAbort): SuiClientTypes.MoveAbort {
1324
1442
  };
1325
1443
  }
1326
1444
 
1327
- function mapErrorName(
1328
- kind:
1329
- | ExecutionError_ExecutionErrorKind
1330
- | CommandArgumentError_CommandArgumentErrorKind
1331
- | TypeArgumentError_TypeArgumentErrorKind
1332
- | PackageUpgradeError_PackageUpgradeErrorKind
1333
- | undefined,
1334
- ): string {
1445
+ /** Without the function index, which GraphQL does not report. */
1446
+ function parseMoveLocation(location: GrpcMoveLocation): SuiClientTypes.MoveLocation {
1447
+ return {
1448
+ package: location.package,
1449
+ module: location.module,
1450
+ functionName: location.functionName,
1451
+ instruction: location.instruction,
1452
+ };
1453
+ }
1454
+
1455
+ /** The PascalCase name of a protobuf enum value, from that enum's reverse mapping. */
1456
+ function mapErrorName(names: Record<number, string>, kind: number | undefined): string {
1335
1457
  if (kind == null) {
1336
1458
  return 'Unknown';
1337
1459
  }
1338
- const name = CommandArgumentError_CommandArgumentErrorKind[kind];
1460
+ const name = names[kind];
1339
1461
  if (!name || name.endsWith('_UNKNOWN')) {
1340
1462
  return 'Unknown';
1341
1463
  }
@@ -1532,20 +1654,10 @@ export function parseGrpcTransactionResponse<
1532
1654
  let transactionData: SuiClientTypes.TransactionData | undefined;
1533
1655
  if (include?.transaction) {
1534
1656
  const tx = transaction.transaction;
1535
-
1536
1657
  if (!tx) {
1537
1658
  throw new Error('Transaction data is required but missing from gRPC response');
1538
1659
  }
1539
-
1540
- const resolved = grpcTransactionToTransactionData(tx);
1541
- transactionData = {
1542
- gasData: resolved.gasData,
1543
- sender: resolved.sender,
1544
- expiration: resolved.expiration,
1545
- commands: resolved.commands,
1546
- inputs: resolved.inputs,
1547
- version: resolved.version,
1548
- };
1660
+ transactionData = grpcTransactionToLedgerTransactionData(tx);
1549
1661
  }
1550
1662
 
1551
1663
  const bcsBytes = include?.bcs ? transaction.transaction?.bcs?.value : undefined;
@@ -1569,8 +1681,16 @@ export function parseGrpcTransactionResponse<
1569
1681
  },
1570
1682
  };
1571
1683
 
1684
+ const sender = transaction.transaction?.sender;
1685
+ if (!sender) {
1686
+ throw new Error(
1687
+ 'Transaction sender is missing from gRPC response; include `transaction.sender` in the read mask',
1688
+ );
1689
+ }
1690
+
1572
1691
  const result: SuiClientTypes.Transaction<Include> = {
1573
1692
  digest: transaction.digest!,
1693
+ sender: normalizeSuiAddress(sender),
1574
1694
  epoch: transaction.effects?.epoch?.toString() ?? null,
1575
1695
  timestampMs: transaction.timestamp
1576
1696
  ? Number(transaction.timestamp.seconds) * 1000 +
@@ -1593,14 +1713,8 @@ export function parseGrpcTransactionResponse<
1593
1713
  })) ?? [])
1594
1714
  : undefined) as SuiClientTypes.Transaction<Include>['balanceChanges'],
1595
1715
  events: (include?.events
1596
- ? (transaction.events?.events.map((event) => ({
1597
- packageId: normalizeSuiAddress(event.packageId!),
1598
- module: event.module!,
1599
- sender: normalizeSuiAddress(event.sender!),
1600
- eventType: event.eventType!,
1601
- bcs: event.contents?.value ?? new Uint8Array(),
1602
- json: event.json ? (Value.toJson(event.json) as Record<string, unknown>) : null,
1603
- })) ?? [])
1716
+ ? (transaction.events?.events.map((event) => parseGrpcEventFields(event, 'Transaction')) ??
1717
+ [])
1604
1718
  : undefined) as SuiClientTypes.Transaction<Include>['events'],
1605
1719
  };
1606
1720