@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
@@ -0,0 +1,259 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { sleep } from '../../utils/abort.js';
5
+ import type { SuiClientTypes } from '../types.js';
6
+ import type { Bound, CoreFrame, LedgerStreamAdapter, LiveEvent } from './adapter.js';
7
+ import { StreamDisconnected } from './errors.js';
8
+ import { readPages } from './pager.js';
9
+ import type { StreamPlan } from './plan.js';
10
+ import { comparePositions, nextUncoveredAt, type StreamPosition } from './position.js';
11
+ import type { StatusReporter } from './status.js';
12
+ import { encodeToken, filterHash, sameBytes, type StreamToken } from './token.js';
13
+
14
+ /** A live feed opened through `StreamSession.openFeed`. */
15
+ export interface LiveFeed<Item> extends AsyncIterable<LiveEvent<Item>> {
16
+ /** Reads the first Item or Progress. Iterating the feed yields it again first. */
17
+ first(): Promise<LiveEvent<Item>>;
18
+ close(): Promise<void>;
19
+ }
20
+
21
+ /**
22
+ * The committed state of one stream, shared by every attempt. Tokens and reconnects resume from
23
+ * the committed position. Every event goes through `#isStale` then `#commit`, which keeps delivery
24
+ * exactly-once across reconnects and overlapping gap replays.
25
+ */
26
+ export class StreamSession<Item, Frame extends { resumeToken: string }> {
27
+ readonly signal: AbortSignal;
28
+ readonly #plan: StreamPlan;
29
+ readonly #adapter: LedgerStreamAdapter<Item, Frame>;
30
+ readonly #frames: SuiClientTypes.StreamFrameOptions;
31
+ readonly #status: StatusReporter;
32
+ readonly #identity: Omit<StreamToken, 'position'>;
33
+ readonly #ascending: boolean;
34
+
35
+ #committed: StreamPosition | undefined;
36
+ #nextUncovered: bigint | null = null;
37
+ #attemptStart: StreamPosition | undefined;
38
+ #retentionLimit = false;
39
+
40
+ constructor(options: {
41
+ plan: StreamPlan;
42
+ identity: { chain: string; filter: unknown };
43
+ adapter: LedgerStreamAdapter<Item, Frame>;
44
+ frames: SuiClientTypes.StreamFrameOptions | undefined;
45
+ status: StatusReporter;
46
+ signal: AbortSignal;
47
+ }) {
48
+ const { plan, adapter } = options;
49
+ this.signal = options.signal;
50
+ this.#plan = plan;
51
+ this.#adapter = adapter;
52
+ this.#frames = options.frames ?? {};
53
+ this.#status = options.status;
54
+ this.#ascending = plan.order === 'ascending';
55
+ this.#identity = {
56
+ transport: adapter.transport,
57
+ family: adapter.family,
58
+ chain: options.identity.chain,
59
+ filter: filterHash(options.identity.filter),
60
+ order: plan.order,
61
+ };
62
+ const start = plan.start;
63
+ if (start && 'position' in start) this.#committed = start.position;
64
+ if (start && this.#ascending) {
65
+ this.#nextUncovered =
66
+ 'checkpoint' in start ? start.checkpoint : nextUncoveredAt(start.position, adapter.family);
67
+ }
68
+ }
69
+
70
+ /** Resume point: the last committed position, else the planned start. */
71
+ get start(): Bound | undefined {
72
+ return this.#committed ? { position: this.#committed } : this.#plan.start;
73
+ }
74
+
75
+ get committed(): StreamPosition | undefined {
76
+ return this.#committed;
77
+ }
78
+
79
+ /** Ascending: the first checkpoint not covered by what was delivered so far, if known. */
80
+ get nextUncovered(): bigint | null {
81
+ return this.#nextUncovered;
82
+ }
83
+
84
+ beginAttempt() {
85
+ this.#attemptStart = this.#committed;
86
+ }
87
+
88
+ /**
89
+ * Whether this attempt committed a new position; if so, the retry budget resets. `subscribing()`
90
+ * and `deliver()` rebaseline the attempt, so a live feed failure counts only what the feed
91
+ * delivered, not the gap replay that repeats on every attempt.
92
+ */
93
+ advancedThisAttempt(): boolean {
94
+ return this.#committed !== this.#attemptStart;
95
+ }
96
+
97
+ /** The live subscription is about to open. */
98
+ subscribing() {
99
+ this.#attemptStart = this.#committed;
100
+ }
101
+
102
+ /** Reads passes until one is complete, waiting `pollInterval` while the index lags. */
103
+ async *replay(end: bigint | undefined): AsyncGenerator<CoreFrame<Frame>, void> {
104
+ while (!(yield* this.#pass(end))) await sleep(this.#plan.pollInterval, this.signal);
105
+ }
106
+
107
+ /** Commits a position no event reported, so a token exists before the first match. */
108
+ async *baseline(position: StreamPosition): AsyncGenerator<CoreFrame<Frame>, void> {
109
+ yield* this.#commit({ $kind: 'Progress', position });
110
+ }
111
+
112
+ /** This attempt received a response. Reports `Connected`; progress is counted separately. */
113
+ connected() {
114
+ this.#status.connected();
115
+ }
116
+
117
+ openFeed(events: AsyncIterable<LiveEvent<Item>>): LiveFeed<Item> {
118
+ return new FeedReader(events, () => this.connected());
119
+ }
120
+
121
+ /** Commits each new event of the feed. A feed's end is a disconnect. */
122
+ async *deliver(feed: LiveFeed<Item>): AsyncGenerator<CoreFrame<Frame>, never> {
123
+ this.#attemptStart = this.#committed;
124
+ for await (const event of feed) {
125
+ if (!this.#isStale(event)) yield* this.#commit(event);
126
+ }
127
+ throw new StreamDisconnected();
128
+ }
129
+
130
+ async *complete(): AsyncGenerator<SuiClientTypes.StreamCompletionFrame, void> {
131
+ this.signal.throwIfAborted();
132
+ if (!this.#frames.completion) return;
133
+ yield {
134
+ $kind: 'Complete',
135
+ reason: this.#retentionLimit ? 'retentionLimit' : this.#plan.completion,
136
+ ...(this.#committed && { resumeToken: this.#token(this.#committed) }),
137
+ };
138
+ }
139
+
140
+ // One pager pass. Returns whether it is complete.
141
+ async *#pass(end: bigint | undefined): AsyncGenerator<CoreFrame<Frame>, boolean> {
142
+ const pass = readPages(this.#adapter, {
143
+ start: this.start,
144
+ end,
145
+ order: this.#plan.order,
146
+ signal: this.signal,
147
+ });
148
+ try {
149
+ while (true) {
150
+ const next = await pass.next();
151
+ this.#status.connected();
152
+ if (next.done) {
153
+ this.#retentionLimit ||= next.value.retentionLimit;
154
+ return next.value.complete;
155
+ }
156
+ if (!this.#isStale(next.value)) yield* this.#commit(next.value);
157
+ }
158
+ } finally {
159
+ await pass.return({ complete: false, retentionLimit: false });
160
+ }
161
+ }
162
+
163
+ /** Whether everything at `event`'s position was already delivered. */
164
+ #isStale({ $kind, position }: LiveEvent<Item>): boolean {
165
+ const committed = this.#committed;
166
+ // A reconnect that repeats a resume cursor without a checkpoint; positions with one are
167
+ // compared by `#isBehind`.
168
+ if (
169
+ position.checkpoint === null &&
170
+ committed?.checkpoint === null &&
171
+ sameBytes(position.cursor!, committed.cursor!)
172
+ ) {
173
+ return true;
174
+ }
175
+ const next = this.#ascending ? this.#nextUncovered : null;
176
+ if ($kind === 'Progress') {
177
+ const at = this.#nextUncoveredAt(position);
178
+ return (
179
+ (next !== null && at !== null && at < next) || this.#isBehind(position, committed, true)
180
+ );
181
+ }
182
+ return (
183
+ (next !== null && position.checkpoint !== null && position.checkpoint < next) ||
184
+ this.#isBehind(position, committed, true)
185
+ );
186
+ }
187
+
188
+ async *#commit(event: LiveEvent<Item>): AsyncGenerator<CoreFrame<Frame>, void> {
189
+ // An event the adapter already buffered is neither committed nor delivered after an abort.
190
+ this.signal.throwIfAborted();
191
+ const { position } = event;
192
+ const at = this.#ascending ? this.#nextUncoveredAt(position) : null;
193
+ if (at !== null && (this.#nextUncovered === null || at > this.#nextUncovered)) {
194
+ this.#nextUncovered = at;
195
+ }
196
+ this.#committed = position;
197
+ if (event.$kind === 'Item') {
198
+ const frame = this.#adapter.mapItem(event.item);
199
+ yield { ...frame, resumeToken: this.#token(position) } as Frame;
200
+ } else if (this.#frames.progress) {
201
+ yield { $kind: 'Progress', resumeToken: this.#token(position) };
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Whether `a` comes before `b` (or equals it, when `inclusive`) in traversal order. An unknown
207
+ * order counts as not behind: the event is delivered at least once, never lost.
208
+ */
209
+ #isBehind(a: StreamPosition, b: StreamPosition | undefined, inclusive: boolean): boolean {
210
+ const comparison = b && comparePositions(a, b);
211
+ if (comparison === undefined) return false;
212
+ const traversal = this.#ascending ? comparison : -comparison;
213
+ return traversal < 0 || (inclusive && traversal === 0);
214
+ }
215
+
216
+ #nextUncoveredAt(position: StreamPosition): bigint | null {
217
+ return nextUncoveredAt(position, this.#adapter.family);
218
+ }
219
+
220
+ #token(position: StreamPosition): string {
221
+ return encodeToken({ ...this.#identity, position });
222
+ }
223
+ }
224
+
225
+ /** Reports `Connected` on the feed's first event, and buffers it so the handoff can inspect it. */
226
+ class FeedReader<Item> implements LiveFeed<Item> {
227
+ readonly #iterator: AsyncIterator<LiveEvent<Item>>;
228
+ readonly #onEvent: () => void;
229
+ #pending: LiveEvent<Item> | undefined;
230
+
231
+ constructor(events: AsyncIterable<LiveEvent<Item>>, onEvent: () => void) {
232
+ this.#iterator = events[Symbol.asyncIterator]();
233
+ this.#onEvent = onEvent;
234
+ }
235
+
236
+ async first(): Promise<LiveEvent<Item>> {
237
+ this.#pending ??= await this.#read();
238
+ if (!this.#pending) throw new StreamDisconnected('Live feed ended before its first event');
239
+ return this.#pending;
240
+ }
241
+
242
+ async *[Symbol.asyncIterator](): AsyncGenerator<LiveEvent<Item>> {
243
+ const pending = this.#pending;
244
+ this.#pending = undefined;
245
+ if (pending) yield pending;
246
+ for (let event = await this.#read(); event; event = await this.#read()) yield event;
247
+ }
248
+
249
+ async close() {
250
+ await this.#iterator.return?.();
251
+ }
252
+
253
+ async #read(): Promise<LiveEvent<Item> | undefined> {
254
+ const result = await this.#iterator.next();
255
+ if (result.done) return undefined;
256
+ this.#onEvent();
257
+ return result.value;
258
+ }
259
+ }
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { SuiClientTypes } from '../types.js';
5
+
6
+ /** The only caller of `onStatus`. `Connected` is reported once per attempt. */
7
+ export class StatusReporter {
8
+ readonly #onStatus: ((status: SuiClientTypes.StreamStatus) => void) | undefined;
9
+ #connected = false;
10
+ #callbackFailed = false;
11
+
12
+ constructor(onStatus: ((status: SuiClientTypes.StreamStatus) => void) | undefined) {
13
+ this.#onStatus = onStatus;
14
+ }
15
+
16
+ /** Whether `onStatus` threw. Its error then ends the stream, never retried. */
17
+ get callbackFailed() {
18
+ return this.#callbackFailed;
19
+ }
20
+
21
+ connecting(attempt: number) {
22
+ this.#connected = false;
23
+ this.#emit({ $kind: 'Connecting', attempt });
24
+ }
25
+
26
+ connected() {
27
+ if (this.#connected) return;
28
+ this.#connected = true;
29
+ this.#emit({ $kind: 'Connected' });
30
+ }
31
+
32
+ retrying(attempt: number, delay: number, reason: SuiClientTypes.RetryReason, error: unknown) {
33
+ this.#emit({ $kind: 'Retrying', attempt, delay, reason, error });
34
+ }
35
+
36
+ #emit(status: SuiClientTypes.StreamStatus) {
37
+ try {
38
+ this.#onStatus?.(status);
39
+ } catch (error) {
40
+ this.#callbackFailed = true;
41
+ throw error;
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,104 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { bcs } from '@mysten/bcs';
5
+ import { fromBase64 } from '@mysten/utils';
6
+ import { blake2b } from '@noble/hashes/blake2.js';
7
+
8
+ import type { SuiClientTypes } from '../types.js';
9
+ import type { StreamFamily, StreamTransport } from './adapter.js';
10
+ import { SuiStreamError } from './errors.js';
11
+ import { positionSchema, type StreamPosition } from './position.js';
12
+
13
+ /** Resume token format: `sui-stream:` + base64(BCS envelope). Every enum here is append-only. */
14
+ const TOKEN_PREFIX = 'sui-stream:';
15
+
16
+ const Envelope = bcs.enum('StreamToken', {
17
+ V1: bcs.struct('StreamTokenV1', {
18
+ transport: bcs.enum('StreamTransport', { grpc: null, graphql: null }),
19
+ family: bcs.enum('StreamFamily', { checkpoints: null, transactions: null, events: null }),
20
+ chain: bcs.string(),
21
+ /** blake2b-256 of the canonical resolved filter. */
22
+ filter: bcs.bytes(32),
23
+ order: bcs.enum('StreamOrder', { ascending: null, descending: null }),
24
+ position: positionSchema,
25
+ }),
26
+ });
27
+
28
+ /** A decoded token: the stream it belongs to, and where it resumes. */
29
+ export interface StreamToken {
30
+ transport: StreamTransport;
31
+ family: StreamFamily;
32
+ chain: string;
33
+ filter: Uint8Array;
34
+ order: SuiClientTypes.Order;
35
+ position: StreamPosition;
36
+ }
37
+
38
+ export function encodeToken(token: StreamToken): string {
39
+ const envelope = {
40
+ ...token,
41
+ transport: { [token.transport]: true } as { grpc: true } | { graphql: true },
42
+ family: { [token.family]: true } as
43
+ { checkpoints: true } | { transactions: true } | { events: true },
44
+ order: { [token.order]: true } as { ascending: true } | { descending: true },
45
+ };
46
+ return TOKEN_PREFIX + Envelope.serialize({ V1: envelope }).toBase64();
47
+ }
48
+
49
+ /** Rejects anything `encodeToken` would not produce byte for byte. */
50
+ export function decodeToken(value: string): StreamToken {
51
+ let token: StreamToken;
52
+ try {
53
+ if (!value.startsWith(TOKEN_PREFIX)) throw new Error('missing prefix');
54
+ const { V1 } = Envelope.parse(fromBase64(value.slice(TOKEN_PREFIX.length)));
55
+ token = {
56
+ transport: V1!.transport.$kind,
57
+ family: V1!.family.$kind,
58
+ chain: V1!.chain,
59
+ filter: Uint8Array.from(V1!.filter),
60
+ order: V1!.order.$kind,
61
+ position: V1!.position,
62
+ };
63
+ } catch (cause) {
64
+ throw invalidToken(cause);
65
+ }
66
+ // Re-encoding rejects trailing bytes and non-canonical BCS or base64.
67
+ if (encodeToken(token) !== value) throw invalidToken();
68
+ // Progress has only a cursor; every other position has a checkpoint.
69
+ const { kind, checkpoint, cursor } = token.position;
70
+ if (kind === 'Progress' ? checkpoint !== null || !cursor : checkpoint === null) {
71
+ throw invalidToken();
72
+ }
73
+ return token;
74
+ }
75
+
76
+ export function sameBytes(a: Uint8Array, b: Uint8Array): boolean {
77
+ return a.length === b.length && a.every((byte, index) => byte === b[index]);
78
+ }
79
+
80
+ /** Binds tokens to the resolved filter without growing with it. */
81
+ export function filterHash(filter: unknown): Uint8Array {
82
+ return blake2b(new TextEncoder().encode(canonical(filter)), { dkLen: 32 });
83
+ }
84
+
85
+ /** JSON with sorted keys, so equal filters hash equally regardless of property order. */
86
+ function canonical(value: unknown): string {
87
+ if (value === undefined) return 'null';
88
+ if (typeof value === 'bigint') return JSON.stringify(value.toString());
89
+ if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
90
+ if (value && typeof value === 'object') {
91
+ return `{${Object.entries(value)
92
+ .filter(([, item]) => item !== undefined)
93
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
94
+ .map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`)
95
+ .join(',')}}`;
96
+ }
97
+ return JSON.stringify(value);
98
+ }
99
+
100
+ function invalidToken(cause?: unknown) {
101
+ return new SuiStreamError('InvalidToken', 'Invalid or unsupported stream resume token', {
102
+ cause,
103
+ });
104
+ }