@mysten/sui 2.39.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/README.md +5 -188
  3. package/dist/bcs/bcs.d.mts +6 -6
  4. package/dist/bcs/bcs.d.mts.map +1 -1
  5. package/dist/bcs/bcs.mjs +49 -22
  6. package/dist/bcs/bcs.mjs.map +1 -1
  7. package/dist/bcs/effects.mjs +49 -20
  8. package/dist/bcs/effects.mjs.map +1 -1
  9. package/dist/bcs/index.d.mts +1441 -624
  10. package/dist/bcs/index.d.mts.map +1 -1
  11. package/dist/bcs/index.mjs +2 -1
  12. package/dist/bcs/index.mjs.map +1 -1
  13. package/dist/bcs/transactions.d.mts +1059 -0
  14. package/dist/bcs/transactions.d.mts.map +1 -0
  15. package/dist/bcs/transactions.mjs +33 -14
  16. package/dist/bcs/transactions.mjs.map +1 -1
  17. package/dist/bcs/types.d.mts +6 -1
  18. package/dist/bcs/types.d.mts.map +1 -1
  19. package/dist/client/core-resolver.mjs +4 -4
  20. package/dist/client/core-resolver.mjs.map +1 -1
  21. package/dist/client/core.d.mts +55 -4
  22. package/dist/client/core.d.mts.map +1 -1
  23. package/dist/client/core.mjs +98 -1
  24. package/dist/client/core.mjs.map +1 -1
  25. package/dist/client/errors.mjs +11 -1
  26. package/dist/client/errors.mjs.map +1 -1
  27. package/dist/client/index.d.mts +5 -3
  28. package/dist/client/index.mjs +6 -3
  29. package/dist/client/mvr.d.mts +12 -2
  30. package/dist/client/mvr.d.mts.map +1 -1
  31. package/dist/client/mvr.mjs +34 -13
  32. package/dist/client/mvr.mjs.map +1 -1
  33. package/dist/client/query-filters.mjs +80 -76
  34. package/dist/client/query-filters.mjs.map +1 -1
  35. package/dist/client/stream/adapter.d.mts +102 -0
  36. package/dist/client/stream/adapter.d.mts.map +1 -0
  37. package/dist/client/stream/errors.d.mts +14 -0
  38. package/dist/client/stream/errors.d.mts.map +1 -0
  39. package/dist/client/stream/errors.mjs +25 -0
  40. package/dist/client/stream/errors.mjs.map +1 -0
  41. package/dist/client/stream/filter.mjs +18 -0
  42. package/dist/client/stream/filter.mjs.map +1 -0
  43. package/dist/client/stream/follow.mjs +48 -0
  44. package/dist/client/stream/follow.mjs.map +1 -0
  45. package/dist/client/stream/index.d.mts +4 -0
  46. package/dist/client/stream/pager.mjs +123 -0
  47. package/dist/client/stream/pager.mjs.map +1 -0
  48. package/dist/client/stream/plan.mjs +79 -0
  49. package/dist/client/stream/plan.mjs.map +1 -0
  50. package/dist/client/stream/position.d.mts +30 -0
  51. package/dist/client/stream/position.d.mts.map +1 -0
  52. package/dist/client/stream/position.mjs +121 -0
  53. package/dist/client/stream/position.mjs.map +1 -0
  54. package/dist/client/stream/run.d.mts +2 -0
  55. package/dist/client/stream/run.mjs +99 -0
  56. package/dist/client/stream/run.mjs.map +1 -0
  57. package/dist/client/stream/session.mjs +205 -0
  58. package/dist/client/stream/session.mjs.map +1 -0
  59. package/dist/client/stream/status.mjs +47 -0
  60. package/dist/client/stream/status.mjs.map +1 -0
  61. package/dist/client/stream/token.mjs +80 -0
  62. package/dist/client/stream/token.mjs.map +1 -0
  63. package/dist/client/transaction-data.d.mts +17 -0
  64. package/dist/client/transaction-data.d.mts.map +1 -0
  65. package/dist/client/transaction-data.mjs +472 -0
  66. package/dist/client/transaction-data.mjs.map +1 -0
  67. package/dist/client/transaction-resolver.mjs +102 -58
  68. package/dist/client/transaction-resolver.mjs.map +1 -1
  69. package/dist/client/types.d.mts +560 -240
  70. package/dist/client/types.d.mts.map +1 -1
  71. package/dist/client/utils.d.mts +2 -2
  72. package/dist/client/utils.d.mts.map +1 -1
  73. package/dist/client/utils.mjs +91 -30
  74. package/dist/client/utils.mjs.map +1 -1
  75. package/dist/cryptography/index.d.mts +1 -1
  76. package/dist/cryptography/keypair.d.mts +1 -1
  77. package/dist/cryptography/publickey.d.mts +11 -0
  78. package/dist/cryptography/publickey.d.mts.map +1 -1
  79. package/dist/cryptography/publickey.mjs +12 -1
  80. package/dist/cryptography/publickey.mjs.map +1 -1
  81. package/dist/cryptography/signature.d.mts +8 -8
  82. package/dist/cryptography/signature.mjs +18 -7
  83. package/dist/cryptography/signature.mjs.map +1 -1
  84. package/dist/graphql/client.d.mts +51 -35
  85. package/dist/graphql/client.d.mts.map +1 -1
  86. package/dist/graphql/client.mjs +125 -69
  87. package/dist/graphql/client.mjs.map +1 -1
  88. package/dist/graphql/core.d.mts +14 -9
  89. package/dist/graphql/core.d.mts.map +1 -1
  90. package/dist/graphql/core.mjs +294 -118
  91. package/dist/graphql/core.mjs.map +1 -1
  92. package/dist/graphql/errors.d.mts +20 -0
  93. package/dist/graphql/errors.d.mts.map +1 -0
  94. package/dist/graphql/errors.mjs +19 -0
  95. package/dist/graphql/errors.mjs.map +1 -0
  96. package/dist/graphql/filters.mjs +32 -0
  97. package/dist/graphql/filters.mjs.map +1 -0
  98. package/dist/graphql/generated/queries.d.mts.map +1 -1
  99. package/dist/graphql/generated/queries.mjs +1216 -208
  100. package/dist/graphql/generated/queries.mjs.map +1 -1
  101. package/dist/graphql/generated/tada-env.d.mts +820 -11
  102. package/dist/graphql/index.d.mts +2 -1
  103. package/dist/graphql/index.mjs +2 -1
  104. package/dist/graphql/sse-parser.mjs +82 -0
  105. package/dist/graphql/sse-parser.mjs.map +1 -0
  106. package/dist/graphql/stream/families.mjs +306 -0
  107. package/dist/graphql/stream/families.mjs.map +1 -0
  108. package/dist/graphql/stream/index.mjs +38 -0
  109. package/dist/graphql/stream/index.mjs.map +1 -0
  110. package/dist/graphql/stream/live.mjs +60 -0
  111. package/dist/graphql/stream/live.mjs.map +1 -0
  112. package/dist/graphql/stream/page.mjs +38 -0
  113. package/dist/graphql/stream/page.mjs.map +1 -0
  114. package/dist/graphql/stream/query.mjs +47 -0
  115. package/dist/graphql/stream/query.mjs.map +1 -0
  116. package/dist/graphql/subscribe.mjs +70 -0
  117. package/dist/graphql/subscribe.mjs.map +1 -0
  118. package/dist/grpc/client.d.mts +31 -27
  119. package/dist/grpc/client.d.mts.map +1 -1
  120. package/dist/grpc/client.mjs +42 -46
  121. package/dist/grpc/client.mjs.map +1 -1
  122. package/dist/grpc/core.d.mts +13 -6
  123. package/dist/grpc/core.d.mts.map +1 -1
  124. package/dist/grpc/core.mjs +254 -166
  125. package/dist/grpc/core.mjs.map +1 -1
  126. package/dist/grpc/filters.mjs +44 -34
  127. package/dist/grpc/filters.mjs.map +1 -1
  128. package/dist/grpc/grpc-web-pull.mjs +245 -0
  129. package/dist/grpc/grpc-web-pull.mjs.map +1 -0
  130. package/dist/grpc/index.d.mts +2 -1
  131. package/dist/grpc/index.mjs +1 -1
  132. package/dist/grpc/network-error.mjs +31 -0
  133. package/dist/grpc/network-error.mjs.map +1 -0
  134. package/dist/grpc/proto/google/rpc/error_details.mjs +306 -0
  135. package/dist/grpc/proto/google/rpc/error_details.mjs.map +1 -0
  136. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  137. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts +176 -1
  138. package/dist/grpc/proto/sui/rpc/v2/error_reason.d.mts.map +1 -1
  139. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs +175 -0
  140. package/dist/grpc/proto/sui/rpc/v2/error_reason.mjs.map +1 -1
  141. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +2 -2
  142. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  143. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +111 -0
  144. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
  145. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +46 -0
  146. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  147. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  148. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts +24 -1
  149. package/dist/grpc/proto/sui/rpc/v2/move_package_service.d.mts.map +1 -1
  150. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +25 -7
  151. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
  152. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  153. package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
  154. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +111 -9
  155. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -1
  156. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +63 -19
  157. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -1
  158. package/dist/grpc/proto/sui/rpc/v2/signature.d.mts +5 -5
  159. package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
  160. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts +5 -1
  161. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.d.mts.map +1 -1
  162. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs +4 -0
  163. package/dist/grpc/proto/sui/rpc/v2/signature_scheme.mjs.map +1 -1
  164. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  165. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts +20 -1
  166. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
  167. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +30 -13
  168. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
  169. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  170. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +20 -14
  171. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
  172. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +8 -5
  173. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
  174. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts +11 -5
  175. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  176. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +6 -0
  177. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
  178. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +6 -2
  179. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  180. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  181. package/dist/grpc/proto/types.d.mts +7 -7
  182. package/dist/grpc/proto/types.mjs +3 -2
  183. package/dist/grpc/pull-call.d.mts +20 -0
  184. package/dist/grpc/pull-call.d.mts.map +1 -0
  185. package/dist/grpc/pull-call.mjs +28 -0
  186. package/dist/grpc/pull-call.mjs.map +1 -0
  187. package/dist/grpc/stream/call.mjs +238 -0
  188. package/dist/grpc/stream/call.mjs.map +1 -0
  189. package/dist/grpc/stream/families.d.mts +26 -0
  190. package/dist/grpc/stream/families.d.mts.map +1 -0
  191. package/dist/grpc/stream/families.mjs +145 -0
  192. package/dist/grpc/stream/families.mjs.map +1 -0
  193. package/dist/grpc/stream/index.d.mts +41 -0
  194. package/dist/grpc/stream/index.d.mts.map +1 -0
  195. package/dist/grpc/stream/index.mjs +127 -0
  196. package/dist/grpc/stream/index.mjs.map +1 -0
  197. package/dist/grpc/stream/live.mjs +31 -0
  198. package/dist/grpc/stream/live.mjs.map +1 -0
  199. package/dist/grpc/stream/page.mjs +120 -0
  200. package/dist/grpc/stream/page.mjs.map +1 -0
  201. package/dist/grpc/stream-types.d.mts +28 -0
  202. package/dist/grpc/stream-types.d.mts.map +1 -0
  203. package/dist/grpc/transport.d.mts +8 -3
  204. package/dist/grpc/transport.d.mts.map +1 -1
  205. package/dist/grpc/transport.mjs +88 -45
  206. package/dist/grpc/transport.mjs.map +1 -1
  207. package/dist/jsonRpc/index.d.mts +34 -12
  208. package/dist/jsonRpc/index.d.mts.map +1 -0
  209. package/dist/jsonRpc/index.mjs +39 -5
  210. package/dist/jsonRpc/index.mjs.map +1 -0
  211. package/dist/jsonRpc/types.d.mts +420 -0
  212. package/dist/jsonRpc/types.d.mts.map +1 -0
  213. package/dist/keypairs/passkey/keypair.d.mts +1 -1
  214. package/dist/multisig/publickey.d.mts +12 -4
  215. package/dist/multisig/publickey.d.mts.map +1 -1
  216. package/dist/multisig/publickey.mjs +5 -5
  217. package/dist/multisig/publickey.mjs.map +1 -1
  218. package/dist/multisig/signer.d.mts +1 -1
  219. package/dist/transactions/ObjectCache.d.mts +1 -1
  220. package/dist/transactions/ObjectCache.mjs +5 -5
  221. package/dist/transactions/ObjectCache.mjs.map +1 -1
  222. package/dist/transactions/Transaction.d.mts +10 -9
  223. package/dist/transactions/Transaction.d.mts.map +1 -1
  224. package/dist/transactions/Transaction.mjs +17 -6
  225. package/dist/transactions/Transaction.mjs.map +1 -1
  226. package/dist/transactions/data/internal.d.mts +2 -0
  227. package/dist/transactions/data/internal.d.mts.map +1 -1
  228. package/dist/transactions/data/internal.mjs +2 -1
  229. package/dist/transactions/data/internal.mjs.map +1 -1
  230. package/dist/transactions/executor/parallel.d.mts +2 -2
  231. package/dist/transactions/executor/serial.d.mts +1 -1
  232. package/dist/transactions/executor/serial.mjs +2 -2
  233. package/dist/transactions/executor/serial.mjs.map +1 -1
  234. package/dist/transactions/index.d.mts +3 -2
  235. package/dist/transactions/index.mjs +4 -3
  236. package/dist/transactions/intents/AllowanceBalance.mjs +1 -1
  237. package/dist/transactions/intents/CoinWithBalance.mjs +1 -1
  238. package/dist/transactions/resolve.d.mts +6 -0
  239. package/dist/transactions/resolve.d.mts.map +1 -1
  240. package/dist/transactions/resolve.mjs.map +1 -1
  241. package/dist/transactions/restricted-move-calls.d.mts +25 -0
  242. package/dist/transactions/restricted-move-calls.d.mts.map +1 -0
  243. package/dist/transactions/restricted-move-calls.mjs +47 -0
  244. package/dist/transactions/restricted-move-calls.mjs.map +1 -0
  245. package/dist/transactions/serializer.d.mts +1 -4
  246. package/dist/transactions/serializer.d.mts.map +1 -1
  247. package/dist/transactions/serializer.mjs +1 -44
  248. package/dist/transactions/serializer.mjs.map +1 -1
  249. package/dist/transactions/utils.d.mts +0 -1
  250. package/dist/transactions/utils.d.mts.map +1 -1
  251. package/dist/transactions/utils.mjs.map +1 -1
  252. package/dist/utils/abort.mjs +89 -0
  253. package/dist/utils/abort.mjs.map +1 -0
  254. package/dist/utils/coin-reservation.mjs +1 -4
  255. package/dist/utils/coin-reservation.mjs.map +1 -1
  256. package/dist/utils/index.mjs +1 -1
  257. package/dist/utils/sui-types.mjs +1 -1
  258. package/dist/verify/index.d.mts +2 -2
  259. package/dist/verify/verify.d.mts +74 -24
  260. package/dist/verify/verify.d.mts.map +1 -1
  261. package/dist/verify/verify.mjs +128 -42
  262. package/dist/verify/verify.mjs.map +1 -1
  263. package/dist/version.mjs +1 -1
  264. package/dist/version.mjs.map +1 -1
  265. package/dist/zklogin/bcs.d.mts +14 -14
  266. package/dist/zklogin/publickey.d.mts.map +1 -1
  267. package/dist/zklogin/publickey.mjs +15 -20
  268. package/dist/zklogin/publickey.mjs.map +1 -1
  269. package/docs/bcs.md +2 -2
  270. package/docs/clients/core.md +19 -18
  271. package/docs/clients/executing.md +53 -8
  272. package/docs/clients/graphql.md +81 -11
  273. package/docs/clients/grpc.md +31 -15
  274. package/docs/clients/index.md +8 -7
  275. package/docs/clients/querying.md +134 -30
  276. package/docs/clients/streaming.md +324 -0
  277. package/docs/cryptography/index.md +85 -58
  278. package/docs/llms-index.md +4 -2
  279. package/docs/migrations/sui-2.0/dapp-kit.md +3 -2
  280. package/docs/migrations/sui-2.0/json-rpc-migration.md +106 -79
  281. package/docs/migrations/sui-3.0/index.md +247 -0
  282. package/docs/plugins.md +10 -10
  283. package/docs/sdk-building.md +3 -4
  284. package/docs/transactions/coins-and-balances.md +6 -11
  285. package/docs/transactions/reference.md +36 -1
  286. package/package.json +4 -5
  287. package/src/bcs/bcs.ts +80 -41
  288. package/src/bcs/effects.ts +61 -25
  289. package/src/bcs/index.ts +2 -0
  290. package/src/bcs/transactions.ts +36 -17
  291. package/src/bcs/types.ts +10 -4
  292. package/src/client/core-resolver.ts +3 -5
  293. package/src/client/core.ts +180 -8
  294. package/src/client/errors.ts +12 -0
  295. package/src/client/index.ts +4 -2
  296. package/src/client/mvr.ts +37 -10
  297. package/src/client/query-filters.ts +151 -97
  298. package/src/client/stream/adapter.ts +110 -0
  299. package/src/client/stream/errors.ts +40 -0
  300. package/src/client/stream/filter.ts +17 -0
  301. package/src/client/stream/follow.ts +63 -0
  302. package/src/client/stream/index.ts +9 -0
  303. package/src/client/stream/pager.ts +158 -0
  304. package/src/client/stream/plan.ts +147 -0
  305. package/src/client/stream/position.ts +143 -0
  306. package/src/client/stream/run.ts +147 -0
  307. package/src/client/stream/session.ts +259 -0
  308. package/src/client/stream/status.ts +44 -0
  309. package/src/client/stream/token.ts +104 -0
  310. package/src/client/transaction-data.ts +610 -0
  311. package/src/client/transaction-resolver.ts +158 -69
  312. package/src/client/types.ts +530 -115
  313. package/src/client/utils.ts +146 -61
  314. package/src/cryptography/publickey.ts +12 -1
  315. package/src/cryptography/signature.ts +6 -3
  316. package/src/graphql/client.ts +204 -135
  317. package/src/graphql/core.ts +446 -139
  318. package/src/graphql/errors.ts +24 -0
  319. package/src/graphql/filters.ts +48 -0
  320. package/src/graphql/generated/queries.ts +1455 -277
  321. package/src/graphql/generated/schema.graphql +282 -9
  322. package/src/graphql/generated/tada-env.ts +933 -4
  323. package/src/graphql/queries/checkpoints.graphql +34 -0
  324. package/src/graphql/queries/getDynamicFields.graphql +1 -0
  325. package/src/graphql/queries/listEvents.graphql +16 -24
  326. package/src/graphql/queries/streams.graphql +212 -0
  327. package/src/graphql/queries/transactions.graphql +71 -28
  328. package/src/graphql/queries/verifySignature.graphql +17 -0
  329. package/src/graphql/sse-parser.ts +99 -0
  330. package/src/graphql/stream/families.ts +515 -0
  331. package/src/graphql/stream/index.ts +55 -0
  332. package/src/graphql/stream/live.ts +70 -0
  333. package/src/graphql/stream/page.ts +47 -0
  334. package/src/graphql/stream/query.ts +52 -0
  335. package/src/graphql/subscribe.ts +83 -0
  336. package/src/grpc/client.ts +81 -79
  337. package/src/grpc/core.ts +388 -274
  338. package/src/grpc/filters.ts +59 -60
  339. package/src/grpc/grpc-web-pull.ts +360 -0
  340. package/src/grpc/index.ts +5 -0
  341. package/src/grpc/network-error.ts +33 -0
  342. package/src/grpc/proto/sui/rpc/v2/error_reason.ts +175 -0
  343. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +145 -0
  344. package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +43 -1
  345. package/src/grpc/proto/sui/rpc/v2/query_options.ts +132 -8
  346. package/src/grpc/proto/sui/rpc/v2/signature.ts +4 -4
  347. package/src/grpc/proto/sui/rpc/v2/signature_scheme.ts +4 -0
  348. package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +30 -0
  349. package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +16 -10
  350. package/src/grpc/proto/sui/rpc/v2/transaction.ts +6 -0
  351. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +5 -1
  352. package/src/grpc/pull-call.ts +54 -0
  353. package/src/grpc/stream/call.ts +317 -0
  354. package/src/grpc/stream/families.ts +228 -0
  355. package/src/grpc/stream/index.ts +182 -0
  356. package/src/grpc/stream/live.ts +33 -0
  357. package/src/grpc/stream/page.ts +161 -0
  358. package/src/grpc/stream-types.ts +33 -0
  359. package/src/grpc/transport.ts +116 -59
  360. package/src/jsonRpc/index.ts +60 -17
  361. package/src/jsonRpc/types.ts +421 -0
  362. package/src/multisig/publickey.ts +19 -7
  363. package/src/transactions/ObjectCache.ts +6 -6
  364. package/src/transactions/Transaction.ts +30 -6
  365. package/src/transactions/data/internal.ts +2 -0
  366. package/src/transactions/executor/serial.ts +2 -2
  367. package/src/transactions/index.ts +8 -1
  368. package/src/transactions/resolve.ts +6 -0
  369. package/src/transactions/restricted-move-calls.ts +87 -0
  370. package/src/transactions/serializer.ts +0 -70
  371. package/src/transactions/utils.ts +0 -37
  372. package/src/utils/abort.ts +101 -0
  373. package/src/verify/index.ts +1 -0
  374. package/src/verify/verify.ts +190 -62
  375. package/src/version.ts +1 -1
  376. package/src/zklogin/publickey.ts +18 -34
  377. package/dist/client/core-resolver.d.mts +0 -9
  378. package/dist/client/core-resolver.d.mts.map +0 -1
  379. package/dist/jsonRpc/client.d.mts +0 -507
  380. package/dist/jsonRpc/client.d.mts.map +0 -1
  381. package/dist/jsonRpc/client.mjs +0 -868
  382. package/dist/jsonRpc/client.mjs.map +0 -1
  383. package/dist/jsonRpc/core.d.mts +0 -168
  384. package/dist/jsonRpc/core.d.mts.map +0 -1
  385. package/dist/jsonRpc/core.mjs +0 -1054
  386. package/dist/jsonRpc/core.mjs.map +0 -1
  387. package/dist/jsonRpc/errors.d.mts +0 -27
  388. package/dist/jsonRpc/errors.d.mts.map +0 -1
  389. package/dist/jsonRpc/errors.mjs +0 -50
  390. package/dist/jsonRpc/errors.mjs.map +0 -1
  391. package/dist/jsonRpc/http-transport.d.mts +0 -62
  392. package/dist/jsonRpc/http-transport.d.mts.map +0 -1
  393. package/dist/jsonRpc/http-transport.mjs +0 -60
  394. package/dist/jsonRpc/http-transport.mjs.map +0 -1
  395. package/dist/jsonRpc/network.d.mts +0 -9
  396. package/dist/jsonRpc/network.d.mts.map +0 -1
  397. package/dist/jsonRpc/network.mjs +0 -18
  398. package/dist/jsonRpc/network.mjs.map +0 -1
  399. package/dist/jsonRpc/types/chain.d.mts +0 -169
  400. package/dist/jsonRpc/types/chain.d.mts.map +0 -1
  401. package/dist/jsonRpc/types/changes.d.mts +0 -48
  402. package/dist/jsonRpc/types/changes.d.mts.map +0 -1
  403. package/dist/jsonRpc/types/coins.d.mts +0 -15
  404. package/dist/jsonRpc/types/coins.d.mts.map +0 -1
  405. package/dist/jsonRpc/types/common.d.mts +0 -9
  406. package/dist/jsonRpc/types/common.d.mts.map +0 -1
  407. package/dist/jsonRpc/types/generated.d.mts +0 -1976
  408. package/dist/jsonRpc/types/generated.d.mts.map +0 -1
  409. package/dist/jsonRpc/types/index.d.mts +0 -6
  410. package/dist/jsonRpc/types/params.d.mts +0 -898
  411. package/dist/jsonRpc/types/params.d.mts.map +0 -1
  412. package/src/graphql/generated/tsconfig.tada.json +0 -11
  413. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -15
  414. package/src/jsonRpc/client.ts +0 -1252
  415. package/src/jsonRpc/core.ts +0 -1557
  416. package/src/jsonRpc/errors.ts +0 -57
  417. package/src/jsonRpc/http-transport.ts +0 -118
  418. package/src/jsonRpc/network.ts +0 -21
  419. package/src/jsonRpc/types/chain.ts +0 -190
  420. package/src/jsonRpc/types/changes.ts +0 -35
  421. package/src/jsonRpc/types/coins.ts +0 -14
  422. package/src/jsonRpc/types/common.ts +0 -8
  423. package/src/jsonRpc/types/generated.ts +0 -2165
  424. package/src/jsonRpc/types/index.ts +0 -9
  425. package/src/jsonRpc/types/params.ts +0 -908
@@ -1,23 +1,25 @@
1
1
  import { normalizeStructTag, normalizeSuiAddress } from "../utils/sui-types.mjs";
2
2
  import { bcs as suiBcs } from "../bcs/index.mjs";
3
+ import { ObjectError, SimulationError, TransactionError } from "../client/errors.mjs";
3
4
  import { raceSignal } from "../client/mvr.mjs";
5
+ import { SuiStreamError } from "../client/stream/errors.mjs";
6
+ import { resolveCheckpointRange, resolveEventFilter, resolvePagination, resolveTransactionFilter } from "../client/query-filters.mjs";
4
7
  import { CoreClient } from "../client/core.mjs";
5
8
  import { SUI_TYPE_ARG } from "../utils/constants.mjs";
6
- import { formatMoveAbortMessage, isMockedGasObjectId, transactionBytesHaveEmptyGasPayment } from "../client/utils.mjs";
7
- import { ObjectError, SimulationError, TransactionError } from "../client/errors.mjs";
9
+ import { decodeSignature, formatMoveAbortMessage, isMockedGasObjectId, resolveVerifySignatureOptions, transactionBytesHaveEmptyGasPayment } from "../client/utils.mjs";
8
10
  import { Value } from "./proto/google/protobuf/struct.mjs";
9
11
  import { Ability, FunctionDescriptor_Visibility, OpenSignatureBody_Type, OpenSignature_Reference } from "./proto/sui/rpc/v2/move_package.mjs";
10
- import { Owner_OwnerKind } from "./proto/sui/rpc/v2/owner.mjs";
11
- import { applyGrpcResolvedTransaction, grpcTransactionToTransactionData, transactionDataToGrpcTransaction, transactionToGrpcTransaction } from "../client/transaction-resolver.mjs";
12
+ import { applyGrpcResolvedTransaction, grpcTimestampToMilliseconds, mapOwner, transactionDataToGrpcTransaction, transactionToGrpcTransaction } from "../client/transaction-resolver.mjs";
13
+ import { grpcTransactionToLedgerTransactionData } from "../client/transaction-data.mjs";
12
14
  import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from "../client/address-balance-transaction-expiration.mjs";
13
- import { CommandArgumentError_CommandArgumentErrorKind } from "./proto/sui/rpc/v2/execution_status.mjs";
15
+ import { CommandArgumentError_CommandArgumentErrorKind, ExecutionError_ExecutionErrorKind, PackageUpgradeError_PackageUpgradeErrorKind, TypeArgumentError_TypeArgumentErrorKind } from "./proto/sui/rpc/v2/execution_status.mjs";
14
16
  import { ChangedObject_IdOperation, ChangedObject_InputObjectState, ChangedObject_OutputObjectState, UnchangedConsensusObject_UnchangedConsensusObjectKind } from "./proto/sui/rpc/v2/effects.mjs";
15
- import { resolveEventFilter, resolvePagination, resolveTransactionFilter, validateTransactionQuery } from "../client/query-filters.mjs";
16
17
  import { ExecutedTransaction } from "./proto/sui/rpc/v2/executed_transaction.mjs";
17
18
  import { SimulateTransactionRequest_TransactionChecks, SimulateTransactionResponse } from "./proto/sui/rpc/v2/transaction_execution_service.mjs";
18
19
  import { Ordering, QueryEndReason } from "./proto/sui/rpc/v2/query_options.mjs";
20
+ import { DynamicField_DynamicFieldKind } from "./proto/sui/rpc/v2/state_service.mjs";
19
21
  import { toGrpcEventFilter, toGrpcTransactionFilter } from "./filters.mjs";
20
- import { hasDecodedStatusMessage } from "./transport.mjs";
22
+ import { GrpcLedgerStreamAdapter } from "./stream/index.mjs";
21
23
  import { chunk, fromBase64, toBase64 } from "@mysten/utils";
22
24
  import { RpcError } from "@protobuf-ts/runtime-rpc";
23
25
  import { GrpcStatusCode } from "@protobuf-ts/grpcweb-transport";
@@ -29,14 +31,24 @@ function isNameServiceResolutionMiss(error) {
29
31
  if (typeof code !== "string" || typeof message !== "string") return false;
30
32
  if (code === GrpcStatusCode[GrpcStatusCode.NOT_FOUND]) return true;
31
33
  if (code !== GrpcStatusCode[GrpcStatusCode.RESOURCE_EXHAUSTED]) return false;
32
- if (message === "name has expired") return true;
33
- return !hasDecodedStatusMessage(error) && message === "name%20has%20expired";
34
+ return message === "name has expired" || message === "name%20has%20expired";
34
35
  }
35
36
  var GrpcCoreClient = class extends CoreClient {
36
37
  #client;
37
- constructor({ client, ...options }) {
38
+ #transport;
39
+ constructor({ client, transport, ...options }) {
38
40
  super(options);
39
41
  this.#client = client;
42
+ this.#transport = transport;
43
+ }
44
+ createLedgerStreamAdapter(request) {
45
+ const transport = this.#transport;
46
+ if (!transport) throw new SuiStreamError("InvalidOptions", "Ledger streams need a `transport` option");
47
+ return new GrpcLedgerStreamAdapter({
48
+ transport,
49
+ mvr: this.mvr,
50
+ chainIdentifier: async (signal) => (await this.getChainIdentifier({ signal })).chainIdentifier
51
+ }, request);
40
52
  }
41
53
  async getObjects(options) {
42
54
  const batches = chunk(options.objectIds, 50);
@@ -331,112 +343,134 @@ var GrpcCoreClient = class extends CoreClient {
331
343
  } };
332
344
  }
333
345
  async listDynamicFields(options) {
334
- return this.#client.listDynamicFields(options);
346
+ const includeValue = options.include?.value ?? false;
347
+ const paths = [
348
+ "field_id",
349
+ "name",
350
+ "value_type",
351
+ "kind",
352
+ "child_id"
353
+ ];
354
+ if (includeValue) paths.push("value", "child_object.contents");
355
+ const response = await this.#client.stateService.listDynamicFields({
356
+ parent: options.parentId,
357
+ pageToken: options.cursor ? fromBase64(options.cursor) : void 0,
358
+ pageSize: options.limit,
359
+ readMask: { paths }
360
+ }, { abort: options.signal });
361
+ return {
362
+ dynamicFields: response.response.dynamicFields.map((field) => {
363
+ const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
364
+ const nameType = field.name?.name;
365
+ const valueType = field.valueType;
366
+ const fieldType = isDynamicObject ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${nameType}>,0x2::object::ID>` : `0x2::dynamic_field::Field<${nameType},${valueType}>`;
367
+ let value;
368
+ if (includeValue) {
369
+ const valueBcs = isDynamicObject ? field.childObject?.contents?.value : field.value?.value;
370
+ if (valueBcs == null) throw new Error(`Missing value for dynamic field ${field.fieldId}`);
371
+ value = {
372
+ type: valueType,
373
+ bcs: valueBcs
374
+ };
375
+ }
376
+ return {
377
+ $kind: isDynamicObject ? "DynamicObject" : "DynamicField",
378
+ fieldId: field.fieldId,
379
+ type: normalizeStructTag(fieldType),
380
+ name: {
381
+ type: nameType,
382
+ bcs: field.name?.value
383
+ },
384
+ valueType,
385
+ childId: isDynamicObject ? field.childId : void 0,
386
+ value
387
+ };
388
+ }),
389
+ cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
390
+ hasNextPage: response.response.nextPageToken !== void 0
391
+ };
335
392
  }
336
393
  async listTransactions(options) {
337
394
  const paths = transactionReadMaskPaths(options.include);
338
- const filter = options.filter ? await resolveTransactionFilter(this.mvr, options.filter, options.signal) : void 0;
339
395
  const pagination = resolvePagination(options);
340
- validateTransactionQuery(filter, pagination);
341
- const call = this.#client.ledgerService.listTransactions({
396
+ const range = resolveCheckpointRange(options);
397
+ const filter = options.filter ? await resolveTransactionFilter(this.mvr, options.filter, options.signal) : void 0;
398
+ const { items, ...page } = await collectListPage(this.#client.ledgerService.listTransactions({
342
399
  readMask: { paths },
343
- filter: filter && toGrpcTransactionFilter(filter),
400
+ filter: toGrpcTransactionFilter(filter),
401
+ startCheckpoint: range.start,
402
+ endCheckpoint: range.end,
344
403
  options: toGrpcQueryOptions(pagination, pagination.limit + 1)
345
- }, { abort: options.signal });
346
- const transactions = [];
347
- let startCursor = null;
348
- let endCursor = null;
349
- let frontier = null;
350
- let end;
351
- let sawLookaheadItem = false;
352
- for await (const frame of call.responses) {
353
- if (frame.watermark?.cursor) frontier = toBase64(frame.watermark.cursor);
354
- if (frame.transaction) if (transactions.length >= pagination.limit) sawLookaheadItem = true;
355
- else {
356
- startCursor ??= frontier;
357
- endCursor = frontier;
358
- transactions.push(parseGrpcTransactionResponse(frame.transaction, { include: options.include }));
359
- }
360
- if (frame.end) end = frame.end;
361
- }
362
- const hasNextPage = sawLookaheadItem || end?.reason === QueryEndReason.SCAN_LIMIT || end?.reason === QueryEndReason.ITEM_LIMIT;
404
+ }, { abort: options.signal }).responses, pagination.limit, (frame) => frame.transaction, (transaction) => parseGrpcTransactionResponse(transaction, { include: options.include }));
363
405
  return {
364
- transactions,
365
- hasNextPage,
366
- startCursor,
367
- endCursor: sawLookaheadItem ? endCursor : hasNextPage ? frontier ?? endCursor : endCursor
406
+ transactions: items,
407
+ ...page
368
408
  };
369
409
  }
370
410
  async listEvents(options) {
371
411
  const pagination = resolvePagination(options);
372
- const call = this.#client.ledgerService.listEvents({
373
- readMask: { paths: [
374
- "package_id",
375
- "module",
376
- "sender",
377
- "event_type",
378
- "contents",
379
- "json",
380
- "checkpoint",
381
- "transaction_digest",
382
- "event_index"
383
- ] },
384
- filter: options.filter ? toGrpcEventFilter(await resolveEventFilter(this.mvr, options.filter, options.signal)) : void 0,
412
+ const range = resolveCheckpointRange(options);
413
+ const filter = options.filter ? await resolveEventFilter(this.mvr, options.filter, options.signal) : void 0;
414
+ const { items, ...page } = await collectListPage(this.#client.ledgerService.listEvents({
415
+ readMask: { paths: EVENT_READ_MASK_PATHS },
416
+ filter: toGrpcEventFilter(filter),
417
+ startCheckpoint: range.start,
418
+ endCheckpoint: range.end,
385
419
  options: toGrpcQueryOptions(pagination, pagination.limit + 1)
386
- }, { abort: options.signal });
387
- const events = [];
388
- let startCursor = null;
389
- let endCursor = null;
390
- let frontier = null;
391
- let end;
392
- let sawLookaheadItem = false;
393
- for await (const frame of call.responses) {
394
- if (frame.watermark?.cursor) frontier = toBase64(frame.watermark.cursor);
395
- if (frame.event) if (events.length >= pagination.limit) sawLookaheadItem = true;
396
- else {
397
- startCursor ??= frontier;
398
- endCursor = frontier;
399
- const event = frame.event;
400
- events.push({
401
- packageId: normalizeSuiAddress(event.packageId),
402
- module: event.module,
403
- sender: normalizeSuiAddress(event.sender),
404
- eventType: normalizeStructTag(event.eventType),
405
- bcs: event.contents?.value ?? new Uint8Array(),
406
- json: event.json ? Value.toJson(event.json) : null,
407
- checkpoint: event.checkpoint?.toString() ?? null,
408
- transactionDigest: event.transactionDigest,
409
- eventIndex: event.eventIndex
410
- });
411
- }
412
- if (frame.end) end = frame.end;
413
- }
414
- const hasNextPage = sawLookaheadItem || end?.reason === QueryEndReason.SCAN_LIMIT || end?.reason === QueryEndReason.ITEM_LIMIT;
420
+ }, { abort: options.signal }).responses, pagination.limit, (frame) => frame.event, (event) => parseGrpcEvent(event, "listEvents"));
415
421
  return {
416
- events,
417
- hasNextPage,
418
- startCursor,
419
- endCursor: sawLookaheadItem ? endCursor : hasNextPage ? frontier ?? endCursor : endCursor
422
+ events: items,
423
+ ...page
420
424
  };
421
425
  }
422
- async verifyZkLoginSignature(options) {
423
- const messageBytes = fromBase64(options.bytes);
424
- const messageValue = options.intentScope === "PersonalMessage" ? suiBcs.byteVector().serialize(messageBytes).toBytes() : messageBytes;
425
- const { response } = await this.#client.signatureVerificationService.verifySignature({
426
- message: {
427
- name: options.intentScope,
428
- value: messageValue
429
- },
430
- signature: {
431
- bcs: { value: fromBase64(options.signature) },
432
- signature: { oneofKind: void 0 }
433
- },
434
- address: options.address,
435
- jwks: []
436
- }, { abort: options.signal });
426
+ async listCheckpoints(options) {
427
+ const pagination = resolvePagination(options);
428
+ const range = resolveCheckpointRange(options);
429
+ const { items, ...page } = await collectListPage(this.#client.ledgerService.listCheckpoints({
430
+ readMask: { paths: CHECKPOINT_READ_MASK_PATHS },
431
+ startCheckpoint: range.start,
432
+ endCheckpoint: range.end,
433
+ options: toGrpcQueryOptions(pagination, pagination.limit + 1)
434
+ }, { abort: options.signal }).responses, pagination.limit, (frame) => frame.checkpoint, (checkpoint) => parseGrpcCheckpoint(checkpoint, "listCheckpoints"));
437
435
  return {
438
- success: response.isValid ?? false,
439
- errors: response.reason ? [response.reason] : []
436
+ checkpoints: items,
437
+ ...page
438
+ };
439
+ }
440
+ async verifySignature(options) {
441
+ const { intentScope, message, address, checkAddressAliases } = resolveVerifySignatureOptions(options);
442
+ const signature = decodeSignature(options.signature);
443
+ if (!signature) return {
444
+ valid: false,
445
+ reason: "Cannot parse signature"
446
+ };
447
+ let response;
448
+ try {
449
+ ({response} = await this.#client.signatureVerificationService.verifySignature({
450
+ message: {
451
+ name: intentScope,
452
+ value: intentScope === "PersonalMessage" ? suiBcs.byteVector().serialize(message).toBytes() : message
453
+ },
454
+ signature: {
455
+ bcs: { value: signature },
456
+ signature: { oneofKind: void 0 }
457
+ },
458
+ address,
459
+ checkAddressAliases,
460
+ jwks: []
461
+ }, { abort: options.signal }));
462
+ } catch (error) {
463
+ if (error instanceof RpcError && error.code === GrpcStatusCode[GrpcStatusCode.INVALID_ARGUMENT]) return {
464
+ valid: false,
465
+ reason: error.message
466
+ };
467
+ throw error;
468
+ }
469
+ if (typeof response.isValid !== "boolean") throw new Error("The node returned no signature verification verdict");
470
+ if (checkAddressAliases && response.addressAliasesChecked !== true) throw new Error("The node does not support checking address aliases; pass `checkAddressAliases: false` to verify the exact address only.");
471
+ return response.isValid ? { valid: true } : {
472
+ valid: false,
473
+ reason: response.reason ?? "Signature is not valid"
440
474
  };
441
475
  }
442
476
  async defaultNameServiceName(options) {
@@ -552,6 +586,88 @@ var GrpcCoreClient = class extends CoreClient {
552
586
  };
553
587
  }
554
588
  };
589
+ const CHECKPOINT_READ_MASK_PATHS = [
590
+ "sequence_number",
591
+ "digest",
592
+ "summary.epoch",
593
+ "summary.timestamp"
594
+ ];
595
+ const EVENT_READ_MASK_PATHS = [
596
+ "package_id",
597
+ "module",
598
+ "sender",
599
+ "event_type",
600
+ "contents",
601
+ "json",
602
+ "checkpoint",
603
+ "transaction_digest",
604
+ "event_index"
605
+ ];
606
+ /** `source` names the response in the error thrown when required fields are missing. */
607
+ function parseGrpcCheckpoint(checkpoint, source) {
608
+ const timestamp = checkpoint.summary?.timestamp;
609
+ if (checkpoint.sequenceNumber == null || !checkpoint.digest || checkpoint.summary?.epoch == null || !timestamp) throw new Error(`${source} response is missing expected checkpoint fields`);
610
+ return {
611
+ sequenceNumber: checkpoint.sequenceNumber.toString(),
612
+ digest: checkpoint.digest,
613
+ epoch: checkpoint.summary.epoch.toString(),
614
+ timestampMs: Number(grpcTimestampToMilliseconds(timestamp))
615
+ };
616
+ }
617
+ /** `source` names the response in the error thrown when required fields are missing. */
618
+ function parseGrpcEventFields(event, source) {
619
+ if (!event.packageId || !event.module || !event.sender || !event.eventType) throw new Error(`${source} response is missing expected event fields`);
620
+ return {
621
+ packageId: normalizeSuiAddress(event.packageId),
622
+ module: event.module,
623
+ sender: normalizeSuiAddress(event.sender),
624
+ eventType: normalizeStructTag(event.eventType),
625
+ bcs: event.contents?.value ?? new Uint8Array(),
626
+ json: event.json ? Value.toJson(event.json) : null
627
+ };
628
+ }
629
+ /** `source` names the response in the error thrown when required fields are missing. */
630
+ function parseGrpcEvent(event, source) {
631
+ if (!event.transactionDigest || event.eventIndex == null || event.checkpoint == null) throw new Error(`${source} response is missing expected event fields`);
632
+ return {
633
+ ...parseGrpcEventFields(event, source),
634
+ checkpoint: event.checkpoint.toString(),
635
+ transactionDigest: event.transactionDigest,
636
+ eventIndex: event.eventIndex
637
+ };
638
+ }
639
+ /**
640
+ * Collects one page from a streaming ledger query (listTransactions, listEvents,
641
+ * listCheckpoints) that was sent with a limit of `limit + 1`. The extra item is a lookahead:
642
+ * the server reports its item limit as reached without scanning past it, so an exact-limit
643
+ * final page is otherwise indistinguishable from one with more results.
644
+ */
645
+ async function collectListPage(responses, limit, pick, map) {
646
+ const items = [];
647
+ let startCursor = null;
648
+ let endCursor = null;
649
+ let frontier = null;
650
+ let end;
651
+ let sawLookaheadItem = false;
652
+ for await (const frame of responses) {
653
+ if (frame.watermark?.cursor) frontier = toBase64(frame.watermark.cursor);
654
+ const item = pick(frame);
655
+ if (item) if (items.length >= limit) sawLookaheadItem = true;
656
+ else {
657
+ startCursor ??= frontier;
658
+ endCursor = frontier;
659
+ items.push(map(item));
660
+ }
661
+ if (frame.end) end = frame.end;
662
+ }
663
+ const hasNextPage = sawLookaheadItem || end?.reason === QueryEndReason.SCAN_LIMIT || end?.reason === QueryEndReason.ITEM_LIMIT;
664
+ return {
665
+ items,
666
+ hasNextPage,
667
+ startCursor,
668
+ endCursor: sawLookaheadItem ? endCursor : hasNextPage ? frontier ?? endCursor : endCursor
669
+ };
670
+ }
555
671
  function toGrpcQueryOptions(pagination, limit) {
556
672
  return {
557
673
  limit,
@@ -560,16 +676,22 @@ function toGrpcQueryOptions(pagination, limit) {
560
676
  before: pagination.before ? fromBase64(pagination.before) : void 0
561
677
  };
562
678
  }
679
+ /**
680
+ * The read mask paths `parseGrpcTransactionResponse` needs for `include`, under `prefix` (such as
681
+ * `'transaction.'` for a simulation response).
682
+ */
563
683
  function transactionReadMaskPaths(include, prefix = "") {
564
684
  const paths = [
565
685
  "digest",
566
686
  "transaction.digest",
687
+ "transaction.sender",
567
688
  "signatures",
568
689
  "effects.status",
690
+ "effects.epoch",
569
691
  "timestamp",
570
692
  "checkpoint"
571
693
  ];
572
- if (include?.transaction) paths.push("transaction.sender", "transaction.gas_payment", "transaction.expiration", "transaction.kind");
694
+ if (include?.transaction) paths.push("transaction.gas_payment", "transaction.expiration", "transaction.kind");
573
695
  if (include?.bcs) paths.push("transaction.bcs");
574
696
  if (include?.balanceChanges) paths.push("balance_changes");
575
697
  if (include?.effects) paths.push("effects");
@@ -595,55 +717,23 @@ function mapDisplayProto(include, display) {
595
717
  errors: display.errors !== void 0 ? Value.toJson(display.errors) : null
596
718
  };
597
719
  }
598
- function mapOwner(owner) {
599
- if (!owner) return null;
600
- if (owner.kind === Owner_OwnerKind.IMMUTABLE) return {
601
- $kind: "Immutable",
602
- Immutable: true
603
- };
604
- if (owner.kind === Owner_OwnerKind.ADDRESS) return {
605
- AddressOwner: owner.address,
606
- $kind: "AddressOwner"
607
- };
608
- if (owner.kind === Owner_OwnerKind.OBJECT) return {
609
- $kind: "ObjectOwner",
610
- ObjectOwner: owner.address
611
- };
612
- if (owner.kind === Owner_OwnerKind.SHARED) return {
613
- $kind: "Shared",
614
- Shared: { initialSharedVersion: owner.version?.toString() }
615
- };
616
- if (owner.kind === Owner_OwnerKind.CONSENSUS_ADDRESS) return {
617
- $kind: "ConsensusAddressOwner",
618
- ConsensusAddressOwner: {
619
- startVersion: owner.version?.toString(),
620
- owner: owner.address
621
- }
622
- };
623
- throw new Error(`Unknown owner kind ${JSON.stringify(owner, (_k, v) => typeof v === "bigint" ? v.toString() : v)}`);
624
- }
625
720
  function parseGrpcExecutionError(error) {
626
721
  const message = error.description ?? "Unknown error";
627
722
  const command = error.command != null ? Number(error.command) : void 0;
628
723
  const details = error.errorDetails;
629
724
  switch (details?.oneofKind) {
630
725
  case "abort": {
631
- const abort = details.abort;
632
- const cleverError = abort.cleverError;
726
+ const moveAbort = parseMoveAbort(details.abort);
633
727
  return {
634
728
  $kind: "MoveAbort",
635
729
  message: formatMoveAbortMessage({
636
730
  command,
637
- location: abort.location,
638
- abortCode: String(abort.abortCode ?? 0n),
639
- cleverError: cleverError ? {
640
- lineNumber: cleverError.lineNumber != null ? Number(cleverError.lineNumber) : void 0,
641
- constantName: cleverError.constantName,
642
- value: cleverError.value?.oneofKind === "rendered" ? cleverError.value.rendered : void 0
643
- } : void 0
731
+ location: moveAbort.location,
732
+ abortCode: moveAbort.abortCode,
733
+ cleverError: moveAbort.cleverError
644
734
  }),
645
735
  command,
646
- MoveAbort: parseMoveAbort(abort)
736
+ MoveAbort: moveAbort
647
737
  };
648
738
  }
649
739
  case "sizeError": return {
@@ -651,7 +741,7 @@ function parseGrpcExecutionError(error) {
651
741
  message,
652
742
  command,
653
743
  SizeError: {
654
- name: mapErrorName(error.kind),
744
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
655
745
  size: Number(details.sizeError.size ?? 0n),
656
746
  maxSize: Number(details.sizeError.maxSize ?? 0n)
657
747
  }
@@ -662,7 +752,7 @@ function parseGrpcExecutionError(error) {
662
752
  command,
663
753
  CommandArgumentError: {
664
754
  argument: details.commandArgumentError.argument ?? 0,
665
- name: mapErrorName(details.commandArgumentError.kind)
755
+ name: mapErrorName(CommandArgumentError_CommandArgumentErrorKind, details.commandArgumentError.kind)
666
756
  }
667
757
  };
668
758
  case "typeArgumentError": return {
@@ -671,7 +761,7 @@ function parseGrpcExecutionError(error) {
671
761
  command,
672
762
  TypeArgumentError: {
673
763
  typeArgument: details.typeArgumentError.typeArgument ?? 0,
674
- name: mapErrorName(details.typeArgumentError.kind)
764
+ name: mapErrorName(TypeArgumentError_TypeArgumentErrorKind, details.typeArgumentError.kind)
675
765
  }
676
766
  };
677
767
  case "packageUpgradeError": return {
@@ -679,7 +769,7 @@ function parseGrpcExecutionError(error) {
679
769
  message,
680
770
  command,
681
771
  PackageUpgradeError: {
682
- name: mapErrorName(details.packageUpgradeError.kind),
772
+ name: mapErrorName(PackageUpgradeError_PackageUpgradeErrorKind, details.packageUpgradeError.kind),
683
773
  packageId: details.packageUpgradeError.packageId,
684
774
  digest: details.packageUpgradeError.digest
685
775
  }
@@ -698,7 +788,7 @@ function parseGrpcExecutionError(error) {
698
788
  message,
699
789
  command,
700
790
  CoinDenyListError: {
701
- name: mapErrorName(error.kind),
791
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
702
792
  coinType: details.coinDenyListError.coinType,
703
793
  address: details.coinDenyListError.address
704
794
  }
@@ -708,7 +798,7 @@ function parseGrpcExecutionError(error) {
708
798
  message,
709
799
  command,
710
800
  CongestedObjects: {
711
- name: mapErrorName(error.kind),
801
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
712
802
  objects: details.congestedObjects.objects
713
803
  }
714
804
  };
@@ -717,7 +807,7 @@ function parseGrpcExecutionError(error) {
717
807
  message,
718
808
  command,
719
809
  ObjectIdError: {
720
- name: mapErrorName(error.kind),
810
+ name: mapErrorName(ExecutionError_ExecutionErrorKind, error.kind),
721
811
  objectId: details.objectId
722
812
  }
723
813
  };
@@ -732,7 +822,7 @@ function parseGrpcExecutionError(error) {
732
822
  function parseMoveAbort(abort) {
733
823
  return {
734
824
  abortCode: String(abort.abortCode ?? 0n),
735
- location: { ...abort.location },
825
+ location: abort.location && parseMoveLocation(abort.location),
736
826
  cleverError: abort.cleverError ? {
737
827
  errorCode: abort.cleverError.errorCode != null ? Number(abort.cleverError.errorCode) : void 0,
738
828
  lineNumber: abort.cleverError.lineNumber != null ? Number(abort.cleverError.lineNumber) : void 0,
@@ -742,9 +832,19 @@ function parseMoveAbort(abort) {
742
832
  } : void 0
743
833
  };
744
834
  }
745
- function mapErrorName(kind) {
835
+ /** Without the function index, which GraphQL does not report. */
836
+ function parseMoveLocation(location) {
837
+ return {
838
+ package: location.package,
839
+ module: location.module,
840
+ functionName: location.functionName,
841
+ instruction: location.instruction
842
+ };
843
+ }
844
+ /** The PascalCase name of a protobuf enum value, from that enum's reverse mapping. */
845
+ function mapErrorName(names, kind) {
746
846
  if (kind == null) return "Unknown";
747
- const name = CommandArgumentError_CommandArgumentErrorKind[kind];
847
+ const name = names[kind];
748
848
  if (!name || name.endsWith("_UNKNOWN")) return "Unknown";
749
849
  return name.split("_").map((word) => word.charAt(0) + word.slice(1).toLowerCase()).join("");
750
850
  }
@@ -860,15 +960,7 @@ function parseGrpcTransactionResponse(transaction, options) {
860
960
  if (include?.transaction) {
861
961
  const tx = transaction.transaction;
862
962
  if (!tx) throw new Error("Transaction data is required but missing from gRPC response");
863
- const resolved = grpcTransactionToTransactionData(tx);
864
- transactionData = {
865
- gasData: resolved.gasData,
866
- sender: resolved.sender,
867
- expiration: resolved.expiration,
868
- commands: resolved.commands,
869
- inputs: resolved.inputs,
870
- version: resolved.version
871
- };
963
+ transactionData = grpcTransactionToLedgerTransactionData(tx);
872
964
  }
873
965
  const bcsBytes = include?.bcs ? transaction.transaction?.bcs?.value : void 0;
874
966
  const effects = include?.effects ? parseTransactionEffects({ effects: transaction.effects }) : void 0;
@@ -883,8 +975,11 @@ function parseGrpcTransactionResponse(transaction, options) {
883
975
  Unknown: null
884
976
  }
885
977
  };
978
+ const sender = transaction.transaction?.sender;
979
+ if (!sender) throw new Error("Transaction sender is missing from gRPC response; include `transaction.sender` in the read mask");
886
980
  const result = {
887
981
  digest: transaction.digest,
982
+ sender: normalizeSuiAddress(sender),
888
983
  epoch: transaction.effects?.epoch?.toString() ?? null,
889
984
  timestampMs: transaction.timestamp ? Number(transaction.timestamp.seconds) * 1e3 + Math.floor(transaction.timestamp.nanos / 1e6) : null,
890
985
  checkpoint: transaction.checkpoint?.toString() ?? null,
@@ -899,14 +994,7 @@ function parseGrpcTransactionResponse(transaction, options) {
899
994
  address: change.address,
900
995
  amount: change.amount
901
996
  })) ?? [] : void 0,
902
- events: include?.events ? transaction.events?.events.map((event) => ({
903
- packageId: normalizeSuiAddress(event.packageId),
904
- module: event.module,
905
- sender: normalizeSuiAddress(event.sender),
906
- eventType: event.eventType,
907
- bcs: event.contents?.value ?? new Uint8Array(),
908
- json: event.json ? Value.toJson(event.json) : null
909
- })) ?? [] : void 0
997
+ events: include?.events ? transaction.events?.events.map((event) => parseGrpcEventFields(event, "Transaction")) ?? [] : void 0
910
998
  };
911
999
  return status.success ? {
912
1000
  $kind: "Transaction",
@@ -977,5 +1065,5 @@ function parseNormalizedSuiMoveTypeBody(type) {
977
1065
  }
978
1066
 
979
1067
  //#endregion
980
- export { GrpcCoreClient, parseGrpcSimulateTransactionResponse, parseGrpcTransactionResponse };
1068
+ export { CHECKPOINT_READ_MASK_PATHS, EVENT_READ_MASK_PATHS, GrpcCoreClient, parseGrpcCheckpoint, parseGrpcEvent, parseGrpcSimulateTransactionResponse, parseGrpcTransactionResponse, transactionReadMaskPaths };
981
1069
  //# sourceMappingURL=core.mjs.map