@mysten/sui 0.0.0-experimental-20240529040124

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 (609) hide show
  1. package/CHANGELOG.md +905 -0
  2. package/LICENSE +201 -0
  3. package/README.md +520 -0
  4. package/bcs/package.json +6 -0
  5. package/client/package.json +6 -0
  6. package/cryptography/package.json +6 -0
  7. package/dist/cjs/bcs/bcs.d.ts +2283 -0
  8. package/dist/cjs/bcs/bcs.js +306 -0
  9. package/dist/cjs/bcs/bcs.js.map +7 -0
  10. package/dist/cjs/bcs/effects.d.ts +793 -0
  11. package/dist/cjs/bcs/effects.js +203 -0
  12. package/dist/cjs/bcs/effects.js.map +7 -0
  13. package/dist/cjs/bcs/index.d.ts +3081 -0
  14. package/dist/cjs/bcs/index.js +73 -0
  15. package/dist/cjs/bcs/index.js.map +7 -0
  16. package/dist/cjs/bcs/type-tag-serializer.d.ts +6 -0
  17. package/dist/cjs/bcs/type-tag-serializer.js +113 -0
  18. package/dist/cjs/bcs/type-tag-serializer.js.map +7 -0
  19. package/dist/cjs/bcs/types.d.ts +114 -0
  20. package/dist/cjs/bcs/types.js +27 -0
  21. package/dist/cjs/bcs/types.js.map +7 -0
  22. package/dist/cjs/client/client.d.ts +229 -0
  23. package/dist/cjs/client/client.js +582 -0
  24. package/dist/cjs/client/client.js.map +7 -0
  25. package/dist/cjs/client/errors.d.ts +12 -0
  26. package/dist/cjs/client/errors.js +60 -0
  27. package/dist/cjs/client/errors.js.map +7 -0
  28. package/dist/cjs/client/http-transport.d.ts +40 -0
  29. package/dist/cjs/client/http-transport.js +125 -0
  30. package/dist/cjs/client/http-transport.js.map +7 -0
  31. package/dist/cjs/client/index.d.ts +5 -0
  32. package/dist/cjs/client/index.js +36 -0
  33. package/dist/cjs/client/index.js.map +7 -0
  34. package/dist/cjs/client/network.d.ts +1 -0
  35. package/dist/cjs/client/network.js +38 -0
  36. package/dist/cjs/client/network.js.map +7 -0
  37. package/dist/cjs/client/rpc-websocket-client.d.ts +49 -0
  38. package/dist/cjs/client/rpc-websocket-client.js +206 -0
  39. package/dist/cjs/client/rpc-websocket-client.js.map +7 -0
  40. package/dist/cjs/client/types/chain.d.ts +99 -0
  41. package/dist/cjs/client/types/chain.js +17 -0
  42. package/dist/cjs/client/types/chain.js.map +7 -0
  43. package/dist/cjs/client/types/changes.d.ts +19 -0
  44. package/dist/cjs/client/types/changes.js +17 -0
  45. package/dist/cjs/client/types/changes.js.map +7 -0
  46. package/dist/cjs/client/types/coins.d.ts +6 -0
  47. package/dist/cjs/client/types/coins.js +17 -0
  48. package/dist/cjs/client/types/coins.js.map +7 -0
  49. package/dist/cjs/client/types/common.d.ts +2 -0
  50. package/dist/cjs/client/types/common.js +17 -0
  51. package/dist/cjs/client/types/common.js.map +7 -0
  52. package/dist/cjs/client/types/generated.d.ts +1376 -0
  53. package/dist/cjs/client/types/generated.js +17 -0
  54. package/dist/cjs/client/types/generated.js.map +7 -0
  55. package/dist/cjs/client/types/index.d.ts +6 -0
  56. package/dist/cjs/client/types/index.js +24 -0
  57. package/dist/cjs/client/types/index.js.map +7 -0
  58. package/dist/cjs/client/types/params.d.ts +585 -0
  59. package/dist/cjs/client/types/params.js +17 -0
  60. package/dist/cjs/client/types/params.js.map +7 -0
  61. package/dist/cjs/cryptography/index.d.ts +7 -0
  62. package/dist/cjs/cryptography/index.js +47 -0
  63. package/dist/cjs/cryptography/index.js.map +7 -0
  64. package/dist/cjs/cryptography/intent.d.ts +6 -0
  65. package/dist/cjs/cryptography/intent.js +35 -0
  66. package/dist/cjs/cryptography/intent.js.map +7 -0
  67. package/dist/cjs/cryptography/keypair.d.ts +63 -0
  68. package/dist/cjs/cryptography/keypair.js +105 -0
  69. package/dist/cjs/cryptography/keypair.js.map +7 -0
  70. package/dist/cjs/cryptography/mnemonics.d.ts +27 -0
  71. package/dist/cjs/cryptography/mnemonics.js +47 -0
  72. package/dist/cjs/cryptography/mnemonics.js.map +7 -0
  73. package/dist/cjs/cryptography/publickey.d.ts +56 -0
  74. package/dist/cjs/cryptography/publickey.js +112 -0
  75. package/dist/cjs/cryptography/publickey.js.map +7 -0
  76. package/dist/cjs/cryptography/signature-scheme.d.ts +21 -0
  77. package/dist/cjs/cryptography/signature-scheme.js +45 -0
  78. package/dist/cjs/cryptography/signature-scheme.js.map +7 -0
  79. package/dist/cjs/cryptography/signature.d.ts +60 -0
  80. package/dist/cjs/cryptography/signature.js +75 -0
  81. package/dist/cjs/cryptography/signature.js.map +7 -0
  82. package/dist/cjs/faucet/faucet.d.ts +42 -0
  83. package/dist/cjs/faucet/faucet.js +103 -0
  84. package/dist/cjs/faucet/faucet.js.map +7 -0
  85. package/dist/cjs/faucet/index.d.ts +1 -0
  86. package/dist/cjs/faucet/index.js +29 -0
  87. package/dist/cjs/faucet/index.js.map +7 -0
  88. package/dist/cjs/graphql/client.d.ts +42 -0
  89. package/dist/cjs/graphql/client.js +93 -0
  90. package/dist/cjs/graphql/client.js.map +7 -0
  91. package/dist/cjs/graphql/generated/2024-01/tada-env.d.js +17 -0
  92. package/dist/cjs/graphql/generated/2024-01/tada-env.d.js.map +7 -0
  93. package/dist/cjs/graphql/generated/2024.1/tada-env.d.js +17 -0
  94. package/dist/cjs/graphql/generated/2024.1/tada-env.d.js.map +7 -0
  95. package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js +12 -0
  96. package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js.map +7 -0
  97. package/dist/cjs/graphql/generated/2024.4/tada-env.d.js +17 -0
  98. package/dist/cjs/graphql/generated/2024.4/tada-env.d.js.map +7 -0
  99. package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js +12 -0
  100. package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js.map +7 -0
  101. package/dist/cjs/graphql/index.d.ts +1 -0
  102. package/dist/cjs/graphql/index.js +26 -0
  103. package/dist/cjs/graphql/index.js.map +7 -0
  104. package/dist/cjs/graphql/schemas/2024.1/index.d.ts +8971 -0
  105. package/dist/cjs/graphql/schemas/2024.1/index.js +31 -0
  106. package/dist/cjs/graphql/schemas/2024.1/index.js.map +7 -0
  107. package/dist/cjs/graphql/schemas/2024.4/index.d.ts +8995 -0
  108. package/dist/cjs/graphql/schemas/2024.4/index.js +31 -0
  109. package/dist/cjs/graphql/schemas/2024.4/index.js.map +7 -0
  110. package/dist/cjs/graphql/types.d.ts +70 -0
  111. package/dist/cjs/graphql/types.js +17 -0
  112. package/dist/cjs/graphql/types.js.map +7 -0
  113. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +13 -0
  114. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +101 -0
  115. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js.map +7 -0
  116. package/dist/cjs/keypairs/ed25519/index.d.ts +2 -0
  117. package/dist/cjs/keypairs/ed25519/index.js +28 -0
  118. package/dist/cjs/keypairs/ed25519/index.js.map +7 -0
  119. package/dist/cjs/keypairs/ed25519/keypair.d.ts +74 -0
  120. package/dist/cjs/keypairs/ed25519/keypair.js +151 -0
  121. package/dist/cjs/keypairs/ed25519/keypair.js.map +7 -0
  122. package/dist/cjs/keypairs/ed25519/publickey.d.ts +30 -0
  123. package/dist/cjs/keypairs/ed25519/publickey.js +99 -0
  124. package/dist/cjs/keypairs/ed25519/publickey.js.map +7 -0
  125. package/dist/cjs/keypairs/secp256k1/index.d.ts +2 -0
  126. package/dist/cjs/keypairs/secp256k1/index.js +28 -0
  127. package/dist/cjs/keypairs/secp256k1/index.js.map +7 -0
  128. package/dist/cjs/keypairs/secp256k1/keypair.d.ts +73 -0
  129. package/dist/cjs/keypairs/secp256k1/keypair.js +143 -0
  130. package/dist/cjs/keypairs/secp256k1/keypair.js.map +7 -0
  131. package/dist/cjs/keypairs/secp256k1/publickey.d.ts +30 -0
  132. package/dist/cjs/keypairs/secp256k1/publickey.js +94 -0
  133. package/dist/cjs/keypairs/secp256k1/publickey.js.map +7 -0
  134. package/dist/cjs/keypairs/secp256r1/index.d.ts +2 -0
  135. package/dist/cjs/keypairs/secp256r1/index.js +28 -0
  136. package/dist/cjs/keypairs/secp256r1/index.js.map +7 -0
  137. package/dist/cjs/keypairs/secp256r1/keypair.d.ts +73 -0
  138. package/dist/cjs/keypairs/secp256r1/keypair.js +137 -0
  139. package/dist/cjs/keypairs/secp256r1/keypair.js.map +7 -0
  140. package/dist/cjs/keypairs/secp256r1/publickey.d.ts +30 -0
  141. package/dist/cjs/keypairs/secp256r1/publickey.js +94 -0
  142. package/dist/cjs/keypairs/secp256r1/publickey.js.map +7 -0
  143. package/dist/cjs/multisig/index.d.ts +2 -0
  144. package/dist/cjs/multisig/index.js +28 -0
  145. package/dist/cjs/multisig/index.js.map +7 -0
  146. package/dist/cjs/multisig/publickey.d.ts +110 -0
  147. package/dist/cjs/multisig/publickey.js +260 -0
  148. package/dist/cjs/multisig/publickey.js.map +7 -0
  149. package/dist/cjs/multisig/signer.d.ts +19 -0
  150. package/dist/cjs/multisig/signer.js +115 -0
  151. package/dist/cjs/multisig/signer.js.map +7 -0
  152. package/dist/cjs/package.json +5 -0
  153. package/dist/cjs/transactions/Commands.d.ts +110 -0
  154. package/dist/cjs/transactions/Commands.js +140 -0
  155. package/dist/cjs/transactions/Commands.js.map +7 -0
  156. package/dist/cjs/transactions/Inputs.d.ts +22 -0
  157. package/dist/cjs/transactions/Inputs.js +80 -0
  158. package/dist/cjs/transactions/Inputs.js.map +7 -0
  159. package/dist/cjs/transactions/ObjectCache.d.ts +85 -0
  160. package/dist/cjs/transactions/ObjectCache.js +246 -0
  161. package/dist/cjs/transactions/ObjectCache.js.map +7 -0
  162. package/dist/cjs/transactions/Transaction.d.ts +672 -0
  163. package/dist/cjs/transactions/Transaction.js +459 -0
  164. package/dist/cjs/transactions/Transaction.js.map +7 -0
  165. package/dist/cjs/transactions/TransactionData.d.ts +64 -0
  166. package/dist/cjs/transactions/TransactionData.js +249 -0
  167. package/dist/cjs/transactions/TransactionData.js.map +7 -0
  168. package/dist/cjs/transactions/__tests__/Transaction.test.d.ts +1 -0
  169. package/dist/cjs/transactions/__tests__/bcs.test.d.ts +1 -0
  170. package/dist/cjs/transactions/data/internal.d.ts +2689 -0
  171. package/dist/cjs/transactions/data/internal.js +210 -0
  172. package/dist/cjs/transactions/data/internal.js.map +7 -0
  173. package/dist/cjs/transactions/data/v1.d.ts +1839 -0
  174. package/dist/cjs/transactions/data/v1.js +440 -0
  175. package/dist/cjs/transactions/data/v1.js.map +7 -0
  176. package/dist/cjs/transactions/data/v2.d.ts +450 -0
  177. package/dist/cjs/transactions/data/v2.js +123 -0
  178. package/dist/cjs/transactions/data/v2.js.map +7 -0
  179. package/dist/cjs/transactions/executor/caching.d.ts +29 -0
  180. package/dist/cjs/transactions/executor/caching.js +109 -0
  181. package/dist/cjs/transactions/executor/caching.js.map +7 -0
  182. package/dist/cjs/transactions/executor/parallel.d.ts +22 -0
  183. package/dist/cjs/transactions/executor/parallel.js +316 -0
  184. package/dist/cjs/transactions/executor/parallel.js.map +7 -0
  185. package/dist/cjs/transactions/executor/queue.d.ts +11 -0
  186. package/dist/cjs/transactions/executor/queue.js +92 -0
  187. package/dist/cjs/transactions/executor/queue.js.map +7 -0
  188. package/dist/cjs/transactions/executor/serial.d.ts +27 -0
  189. package/dist/cjs/transactions/executor/serial.js +140 -0
  190. package/dist/cjs/transactions/executor/serial.js.map +7 -0
  191. package/dist/cjs/transactions/hash.d.ts +7 -0
  192. package/dist/cjs/transactions/hash.js +32 -0
  193. package/dist/cjs/transactions/hash.js.map +7 -0
  194. package/dist/cjs/transactions/index.d.ts +13 -0
  195. package/dist/cjs/transactions/index.js +47 -0
  196. package/dist/cjs/transactions/index.js.map +7 -0
  197. package/dist/cjs/transactions/intents/CoinWithBalance.d.ts +6 -0
  198. package/dist/cjs/transactions/intents/CoinWithBalance.js +168 -0
  199. package/dist/cjs/transactions/intents/CoinWithBalance.js.map +7 -0
  200. package/dist/cjs/transactions/json-rpc-resolver.d.ts +12 -0
  201. package/dist/cjs/transactions/json-rpc-resolver.js +353 -0
  202. package/dist/cjs/transactions/json-rpc-resolver.js.map +7 -0
  203. package/dist/cjs/transactions/pure.d.ts +185 -0
  204. package/dist/cjs/transactions/pure.js +41 -0
  205. package/dist/cjs/transactions/pure.js.map +7 -0
  206. package/dist/cjs/transactions/serializer.d.ts +7 -0
  207. package/dist/cjs/transactions/serializer.js +176 -0
  208. package/dist/cjs/transactions/serializer.js.map +7 -0
  209. package/dist/cjs/transactions/utils.d.ts +8 -0
  210. package/dist/cjs/transactions/utils.js +66 -0
  211. package/dist/cjs/transactions/utils.js.map +7 -0
  212. package/dist/cjs/utils/constants.d.ts +9 -0
  213. package/dist/cjs/utils/constants.js +42 -0
  214. package/dist/cjs/utils/constants.js.map +7 -0
  215. package/dist/cjs/utils/format.d.ts +2 -0
  216. package/dist/cjs/utils/format.js +36 -0
  217. package/dist/cjs/utils/format.js.map +7 -0
  218. package/dist/cjs/utils/index.d.ts +5 -0
  219. package/dist/cjs/utils/index.js +53 -0
  220. package/dist/cjs/utils/index.js.map +7 -0
  221. package/dist/cjs/utils/sui-types.d.ts +27 -0
  222. package/dist/cjs/utils/sui-types.js +90 -0
  223. package/dist/cjs/utils/sui-types.js.map +7 -0
  224. package/dist/cjs/utils/suins.d.ts +2 -0
  225. package/dist/cjs/utils/suins.js +57 -0
  226. package/dist/cjs/utils/suins.js.map +7 -0
  227. package/dist/cjs/verify/index.d.ts +1 -0
  228. package/dist/cjs/verify/index.js +29 -0
  229. package/dist/cjs/verify/index.js.map +7 -0
  230. package/dist/cjs/verify/verify.d.ts +11 -0
  231. package/dist/cjs/verify/verify.js +101 -0
  232. package/dist/cjs/verify/verify.js.map +7 -0
  233. package/dist/cjs/version.d.ts +2 -0
  234. package/dist/cjs/version.js +27 -0
  235. package/dist/cjs/version.js.map +7 -0
  236. package/dist/cjs/zklogin/address.d.ts +1 -0
  237. package/dist/cjs/zklogin/address.js +44 -0
  238. package/dist/cjs/zklogin/address.js.map +7 -0
  239. package/dist/cjs/zklogin/bcs.d.ts +46 -0
  240. package/dist/cjs/zklogin/bcs.js +42 -0
  241. package/dist/cjs/zklogin/bcs.js.map +7 -0
  242. package/dist/cjs/zklogin/index.d.ts +5 -0
  243. package/dist/cjs/zklogin/index.js +33 -0
  244. package/dist/cjs/zklogin/index.js.map +7 -0
  245. package/dist/cjs/zklogin/jwt-utils.d.ts +5 -0
  246. package/dist/cjs/zklogin/jwt-utils.js +102 -0
  247. package/dist/cjs/zklogin/jwt-utils.js.map +7 -0
  248. package/dist/cjs/zklogin/publickey.d.ts +69 -0
  249. package/dist/cjs/zklogin/publickey.js +197 -0
  250. package/dist/cjs/zklogin/publickey.js.map +7 -0
  251. package/dist/cjs/zklogin/signature.d.ts +23 -0
  252. package/dist/cjs/zklogin/signature.js +48 -0
  253. package/dist/cjs/zklogin/signature.js.map +7 -0
  254. package/dist/cjs/zklogin/utils.d.ts +2 -0
  255. package/dist/cjs/zklogin/utils.js +46 -0
  256. package/dist/cjs/zklogin/utils.js.map +7 -0
  257. package/dist/esm/bcs/bcs.d.ts +2283 -0
  258. package/dist/esm/bcs/bcs.js +286 -0
  259. package/dist/esm/bcs/bcs.js.map +7 -0
  260. package/dist/esm/bcs/effects.d.ts +793 -0
  261. package/dist/esm/bcs/effects.js +183 -0
  262. package/dist/esm/bcs/effects.js.map +7 -0
  263. package/dist/esm/bcs/index.d.ts +3081 -0
  264. package/dist/esm/bcs/index.js +83 -0
  265. package/dist/esm/bcs/index.js.map +7 -0
  266. package/dist/esm/bcs/type-tag-serializer.d.ts +6 -0
  267. package/dist/esm/bcs/type-tag-serializer.js +93 -0
  268. package/dist/esm/bcs/type-tag-serializer.js.map +7 -0
  269. package/dist/esm/bcs/types.d.ts +114 -0
  270. package/dist/esm/bcs/types.js +7 -0
  271. package/dist/esm/bcs/types.js.map +7 -0
  272. package/dist/esm/client/client.d.ts +229 -0
  273. package/dist/esm/client/client.js +568 -0
  274. package/dist/esm/client/client.js.map +7 -0
  275. package/dist/esm/client/errors.d.ts +12 -0
  276. package/dist/esm/client/errors.js +40 -0
  277. package/dist/esm/client/errors.js.map +7 -0
  278. package/dist/esm/client/http-transport.d.ts +40 -0
  279. package/dist/esm/client/http-transport.js +105 -0
  280. package/dist/esm/client/http-transport.js.map +7 -0
  281. package/dist/esm/client/index.d.ts +5 -0
  282. package/dist/esm/client/index.js +20 -0
  283. package/dist/esm/client/index.js.map +7 -0
  284. package/dist/esm/client/network.d.ts +1 -0
  285. package/dist/esm/client/network.js +18 -0
  286. package/dist/esm/client/network.js.map +7 -0
  287. package/dist/esm/client/rpc-websocket-client.d.ts +49 -0
  288. package/dist/esm/client/rpc-websocket-client.js +186 -0
  289. package/dist/esm/client/rpc-websocket-client.js.map +7 -0
  290. package/dist/esm/client/types/chain.d.ts +99 -0
  291. package/dist/esm/client/types/chain.js +1 -0
  292. package/dist/esm/client/types/chain.js.map +7 -0
  293. package/dist/esm/client/types/changes.d.ts +19 -0
  294. package/dist/esm/client/types/changes.js +1 -0
  295. package/dist/esm/client/types/changes.js.map +7 -0
  296. package/dist/esm/client/types/coins.d.ts +6 -0
  297. package/dist/esm/client/types/coins.js +1 -0
  298. package/dist/esm/client/types/coins.js.map +7 -0
  299. package/dist/esm/client/types/common.d.ts +2 -0
  300. package/dist/esm/client/types/common.js +1 -0
  301. package/dist/esm/client/types/common.js.map +7 -0
  302. package/dist/esm/client/types/generated.d.ts +1376 -0
  303. package/dist/esm/client/types/generated.js +1 -0
  304. package/dist/esm/client/types/generated.js.map +7 -0
  305. package/dist/esm/client/types/index.d.ts +6 -0
  306. package/dist/esm/client/types/index.js +7 -0
  307. package/dist/esm/client/types/index.js.map +7 -0
  308. package/dist/esm/client/types/params.d.ts +585 -0
  309. package/dist/esm/client/types/params.js +1 -0
  310. package/dist/esm/client/types/params.js.map +7 -0
  311. package/dist/esm/cryptography/index.d.ts +7 -0
  312. package/dist/esm/cryptography/index.js +47 -0
  313. package/dist/esm/cryptography/index.js.map +7 -0
  314. package/dist/esm/cryptography/intent.d.ts +6 -0
  315. package/dist/esm/cryptography/intent.js +15 -0
  316. package/dist/esm/cryptography/intent.js.map +7 -0
  317. package/dist/esm/cryptography/keypair.d.ts +63 -0
  318. package/dist/esm/cryptography/keypair.js +85 -0
  319. package/dist/esm/cryptography/keypair.js.map +7 -0
  320. package/dist/esm/cryptography/mnemonics.d.ts +27 -0
  321. package/dist/esm/cryptography/mnemonics.js +27 -0
  322. package/dist/esm/cryptography/mnemonics.js.map +7 -0
  323. package/dist/esm/cryptography/publickey.d.ts +56 -0
  324. package/dist/esm/cryptography/publickey.js +92 -0
  325. package/dist/esm/cryptography/publickey.js.map +7 -0
  326. package/dist/esm/cryptography/signature-scheme.d.ts +21 -0
  327. package/dist/esm/cryptography/signature-scheme.js +25 -0
  328. package/dist/esm/cryptography/signature-scheme.js.map +7 -0
  329. package/dist/esm/cryptography/signature.d.ts +60 -0
  330. package/dist/esm/cryptography/signature.js +59 -0
  331. package/dist/esm/cryptography/signature.js.map +7 -0
  332. package/dist/esm/faucet/faucet.d.ts +42 -0
  333. package/dist/esm/faucet/faucet.js +83 -0
  334. package/dist/esm/faucet/faucet.js.map +7 -0
  335. package/dist/esm/faucet/index.d.ts +1 -0
  336. package/dist/esm/faucet/index.js +15 -0
  337. package/dist/esm/faucet/index.js.map +7 -0
  338. package/dist/esm/graphql/client.d.ts +42 -0
  339. package/dist/esm/graphql/client.js +73 -0
  340. package/dist/esm/graphql/client.js.map +7 -0
  341. package/dist/esm/graphql/generated/2024-01/tada-env.d.js +1 -0
  342. package/dist/esm/graphql/generated/2024-01/tada-env.d.js.map +7 -0
  343. package/dist/esm/graphql/generated/2024.1/tada-env.d.js +1 -0
  344. package/dist/esm/graphql/generated/2024.1/tada-env.d.js.map +7 -0
  345. package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js +17 -0
  346. package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js.map +7 -0
  347. package/dist/esm/graphql/generated/2024.4/tada-env.d.js +1 -0
  348. package/dist/esm/graphql/generated/2024.4/tada-env.d.js.map +7 -0
  349. package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js +17 -0
  350. package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js.map +7 -0
  351. package/dist/esm/graphql/index.d.ts +1 -0
  352. package/dist/esm/graphql/index.js +9 -0
  353. package/dist/esm/graphql/index.js.map +7 -0
  354. package/dist/esm/graphql/schemas/2024.1/index.d.ts +8971 -0
  355. package/dist/esm/graphql/schemas/2024.1/index.js +10 -0
  356. package/dist/esm/graphql/schemas/2024.1/index.js.map +7 -0
  357. package/dist/esm/graphql/schemas/2024.4/index.d.ts +8995 -0
  358. package/dist/esm/graphql/schemas/2024.4/index.js +10 -0
  359. package/dist/esm/graphql/schemas/2024.4/index.js.map +7 -0
  360. package/dist/esm/graphql/types.d.ts +70 -0
  361. package/dist/esm/graphql/types.js +1 -0
  362. package/dist/esm/graphql/types.js.map +7 -0
  363. package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +13 -0
  364. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +71 -0
  365. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js.map +7 -0
  366. package/dist/esm/keypairs/ed25519/index.d.ts +2 -0
  367. package/dist/esm/keypairs/ed25519/index.js +11 -0
  368. package/dist/esm/keypairs/ed25519/index.js.map +7 -0
  369. package/dist/esm/keypairs/ed25519/keypair.d.ts +74 -0
  370. package/dist/esm/keypairs/ed25519/keypair.js +121 -0
  371. package/dist/esm/keypairs/ed25519/keypair.js.map +7 -0
  372. package/dist/esm/keypairs/ed25519/publickey.d.ts +30 -0
  373. package/dist/esm/keypairs/ed25519/publickey.js +69 -0
  374. package/dist/esm/keypairs/ed25519/publickey.js.map +7 -0
  375. package/dist/esm/keypairs/secp256k1/index.d.ts +2 -0
  376. package/dist/esm/keypairs/secp256k1/index.js +11 -0
  377. package/dist/esm/keypairs/secp256k1/index.js.map +7 -0
  378. package/dist/esm/keypairs/secp256k1/keypair.d.ts +73 -0
  379. package/dist/esm/keypairs/secp256k1/keypair.js +123 -0
  380. package/dist/esm/keypairs/secp256k1/keypair.js.map +7 -0
  381. package/dist/esm/keypairs/secp256k1/publickey.d.ts +30 -0
  382. package/dist/esm/keypairs/secp256k1/publickey.js +74 -0
  383. package/dist/esm/keypairs/secp256k1/publickey.js.map +7 -0
  384. package/dist/esm/keypairs/secp256r1/index.d.ts +2 -0
  385. package/dist/esm/keypairs/secp256r1/index.js +11 -0
  386. package/dist/esm/keypairs/secp256r1/index.js.map +7 -0
  387. package/dist/esm/keypairs/secp256r1/keypair.d.ts +73 -0
  388. package/dist/esm/keypairs/secp256r1/keypair.js +117 -0
  389. package/dist/esm/keypairs/secp256r1/keypair.js.map +7 -0
  390. package/dist/esm/keypairs/secp256r1/publickey.d.ts +30 -0
  391. package/dist/esm/keypairs/secp256r1/publickey.js +74 -0
  392. package/dist/esm/keypairs/secp256r1/publickey.js.map +7 -0
  393. package/dist/esm/multisig/index.d.ts +2 -0
  394. package/dist/esm/multisig/index.js +8 -0
  395. package/dist/esm/multisig/index.js.map +7 -0
  396. package/dist/esm/multisig/publickey.d.ts +110 -0
  397. package/dist/esm/multisig/publickey.js +243 -0
  398. package/dist/esm/multisig/publickey.js.map +7 -0
  399. package/dist/esm/multisig/signer.d.ts +19 -0
  400. package/dist/esm/multisig/signer.js +95 -0
  401. package/dist/esm/multisig/signer.js.map +7 -0
  402. package/dist/esm/package.json +5 -0
  403. package/dist/esm/transactions/Commands.d.ts +110 -0
  404. package/dist/esm/transactions/Commands.js +120 -0
  405. package/dist/esm/transactions/Commands.js.map +7 -0
  406. package/dist/esm/transactions/Inputs.d.ts +22 -0
  407. package/dist/esm/transactions/Inputs.js +60 -0
  408. package/dist/esm/transactions/Inputs.js.map +7 -0
  409. package/dist/esm/transactions/ObjectCache.d.ts +85 -0
  410. package/dist/esm/transactions/ObjectCache.js +226 -0
  411. package/dist/esm/transactions/ObjectCache.js.map +7 -0
  412. package/dist/esm/transactions/Transaction.d.ts +672 -0
  413. package/dist/esm/transactions/Transaction.js +439 -0
  414. package/dist/esm/transactions/Transaction.js.map +7 -0
  415. package/dist/esm/transactions/TransactionData.d.ts +64 -0
  416. package/dist/esm/transactions/TransactionData.js +229 -0
  417. package/dist/esm/transactions/TransactionData.js.map +7 -0
  418. package/dist/esm/transactions/__tests__/Transaction.test.d.ts +1 -0
  419. package/dist/esm/transactions/__tests__/bcs.test.d.ts +1 -0
  420. package/dist/esm/transactions/data/internal.d.ts +2689 -0
  421. package/dist/esm/transactions/data/internal.js +208 -0
  422. package/dist/esm/transactions/data/internal.js.map +7 -0
  423. package/dist/esm/transactions/data/v1.d.ts +1839 -0
  424. package/dist/esm/transactions/data/v1.js +437 -0
  425. package/dist/esm/transactions/data/v1.js.map +7 -0
  426. package/dist/esm/transactions/data/v2.d.ts +450 -0
  427. package/dist/esm/transactions/data/v2.js +118 -0
  428. package/dist/esm/transactions/data/v2.js.map +7 -0
  429. package/dist/esm/transactions/executor/caching.d.ts +29 -0
  430. package/dist/esm/transactions/executor/caching.js +89 -0
  431. package/dist/esm/transactions/executor/caching.js.map +7 -0
  432. package/dist/esm/transactions/executor/parallel.d.ts +22 -0
  433. package/dist/esm/transactions/executor/parallel.js +296 -0
  434. package/dist/esm/transactions/executor/parallel.js.map +7 -0
  435. package/dist/esm/transactions/executor/queue.d.ts +11 -0
  436. package/dist/esm/transactions/executor/queue.js +72 -0
  437. package/dist/esm/transactions/executor/queue.js.map +7 -0
  438. package/dist/esm/transactions/executor/serial.d.ts +27 -0
  439. package/dist/esm/transactions/executor/serial.js +120 -0
  440. package/dist/esm/transactions/executor/serial.js.map +7 -0
  441. package/dist/esm/transactions/hash.d.ts +7 -0
  442. package/dist/esm/transactions/hash.js +12 -0
  443. package/dist/esm/transactions/hash.js.map +7 -0
  444. package/dist/esm/transactions/index.d.ts +13 -0
  445. package/dist/esm/transactions/index.js +33 -0
  446. package/dist/esm/transactions/index.js.map +7 -0
  447. package/dist/esm/transactions/intents/CoinWithBalance.d.ts +6 -0
  448. package/dist/esm/transactions/intents/CoinWithBalance.js +148 -0
  449. package/dist/esm/transactions/intents/CoinWithBalance.js.map +7 -0
  450. package/dist/esm/transactions/json-rpc-resolver.d.ts +12 -0
  451. package/dist/esm/transactions/json-rpc-resolver.js +333 -0
  452. package/dist/esm/transactions/json-rpc-resolver.js.map +7 -0
  453. package/dist/esm/transactions/pure.d.ts +185 -0
  454. package/dist/esm/transactions/pure.js +21 -0
  455. package/dist/esm/transactions/pure.js.map +7 -0
  456. package/dist/esm/transactions/serializer.d.ts +7 -0
  457. package/dist/esm/transactions/serializer.js +156 -0
  458. package/dist/esm/transactions/serializer.js.map +7 -0
  459. package/dist/esm/transactions/utils.d.ts +8 -0
  460. package/dist/esm/transactions/utils.js +46 -0
  461. package/dist/esm/transactions/utils.js.map +7 -0
  462. package/dist/esm/utils/constants.d.ts +9 -0
  463. package/dist/esm/utils/constants.js +22 -0
  464. package/dist/esm/utils/constants.js.map +7 -0
  465. package/dist/esm/utils/format.d.ts +2 -0
  466. package/dist/esm/utils/format.js +16 -0
  467. package/dist/esm/utils/format.js.map +7 -0
  468. package/dist/esm/utils/index.d.ts +5 -0
  469. package/dist/esm/utils/index.js +52 -0
  470. package/dist/esm/utils/index.js.map +7 -0
  471. package/dist/esm/utils/sui-types.d.ts +27 -0
  472. package/dist/esm/utils/sui-types.js +70 -0
  473. package/dist/esm/utils/sui-types.js.map +7 -0
  474. package/dist/esm/utils/suins.d.ts +2 -0
  475. package/dist/esm/utils/suins.js +37 -0
  476. package/dist/esm/utils/suins.js.map +7 -0
  477. package/dist/esm/verify/index.d.ts +1 -0
  478. package/dist/esm/verify/index.js +15 -0
  479. package/dist/esm/verify/index.js.map +7 -0
  480. package/dist/esm/verify/verify.d.ts +11 -0
  481. package/dist/esm/verify/verify.js +81 -0
  482. package/dist/esm/verify/verify.js.map +7 -0
  483. package/dist/esm/version.d.ts +2 -0
  484. package/dist/esm/version.js +7 -0
  485. package/dist/esm/version.js.map +7 -0
  486. package/dist/esm/zklogin/address.d.ts +1 -0
  487. package/dist/esm/zklogin/address.js +24 -0
  488. package/dist/esm/zklogin/address.js.map +7 -0
  489. package/dist/esm/zklogin/bcs.d.ts +46 -0
  490. package/dist/esm/zklogin/bcs.js +22 -0
  491. package/dist/esm/zklogin/bcs.js.map +7 -0
  492. package/dist/esm/zklogin/index.d.ts +5 -0
  493. package/dist/esm/zklogin/index.js +13 -0
  494. package/dist/esm/zklogin/index.js.map +7 -0
  495. package/dist/esm/zklogin/jwt-utils.d.ts +5 -0
  496. package/dist/esm/zklogin/jwt-utils.js +82 -0
  497. package/dist/esm/zklogin/jwt-utils.js.map +7 -0
  498. package/dist/esm/zklogin/publickey.d.ts +69 -0
  499. package/dist/esm/zklogin/publickey.js +177 -0
  500. package/dist/esm/zklogin/publickey.js.map +7 -0
  501. package/dist/esm/zklogin/signature.d.ts +23 -0
  502. package/dist/esm/zklogin/signature.js +28 -0
  503. package/dist/esm/zklogin/signature.js.map +7 -0
  504. package/dist/esm/zklogin/utils.d.ts +2 -0
  505. package/dist/esm/zklogin/utils.js +26 -0
  506. package/dist/esm/zklogin/utils.js.map +7 -0
  507. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  508. package/dist/tsconfig.tsbuildinfo +1 -0
  509. package/faucet/package.json +6 -0
  510. package/graphql/package.json +6 -0
  511. package/graphql/schemas/2024.1/package.json +6 -0
  512. package/graphql/schemas/2024.4/package.json +6 -0
  513. package/keypairs/ed25519/package.json +6 -0
  514. package/keypairs/secp256k1/package.json +6 -0
  515. package/keypairs/secp256r1/package.json +6 -0
  516. package/multisig/package.json +6 -0
  517. package/package.json +160 -0
  518. package/src/bcs/bcs.ts +300 -0
  519. package/src/bcs/effects.ts +200 -0
  520. package/src/bcs/index.ts +87 -0
  521. package/src/bcs/type-tag-serializer.ts +106 -0
  522. package/src/bcs/types.ts +113 -0
  523. package/src/client/client.ts +814 -0
  524. package/src/client/errors.ts +45 -0
  525. package/src/client/http-transport.ts +130 -0
  526. package/src/client/index.ts +21 -0
  527. package/src/client/network.ts +17 -0
  528. package/src/client/rpc-websocket-client.ts +234 -0
  529. package/src/client/types/chain.ts +122 -0
  530. package/src/client/types/changes.ts +11 -0
  531. package/src/client/types/coins.ts +9 -0
  532. package/src/client/types/common.ts +5 -0
  533. package/src/client/types/generated.ts +1508 -0
  534. package/src/client/types/index.ts +9 -0
  535. package/src/client/types/params.ts +584 -0
  536. package/src/cryptography/index.ts +36 -0
  537. package/src/cryptography/intent.ts +22 -0
  538. package/src/cryptography/keypair.ts +130 -0
  539. package/src/cryptography/mnemonics.ts +49 -0
  540. package/src/cryptography/publickey.ts +133 -0
  541. package/src/cryptography/signature-scheme.ts +28 -0
  542. package/src/cryptography/signature.ts +86 -0
  543. package/src/faucet/faucet.ts +130 -0
  544. package/src/faucet/index.ts +10 -0
  545. package/src/graphql/client.ts +110 -0
  546. package/src/graphql/generated/2024-01/tada-env.d.ts +202 -0
  547. package/src/graphql/generated/2024.1/schema.graphql +4168 -0
  548. package/src/graphql/generated/2024.1/tada-env.d.ts +201 -0
  549. package/src/graphql/generated/2024.1/tsconfig.tada.json +11 -0
  550. package/src/graphql/generated/2024.4/schema.graphql +4183 -0
  551. package/src/graphql/generated/2024.4/tada-env.d.ts +202 -0
  552. package/src/graphql/generated/2024.4/tsconfig.tada.json +11 -0
  553. package/src/graphql/index.ts +12 -0
  554. package/src/graphql/schemas/2024.1/index.ts +17 -0
  555. package/src/graphql/schemas/2024.4/index.ts +17 -0
  556. package/src/graphql/types.ts +86 -0
  557. package/src/keypairs/ed25519/ed25519-hd-key.ts +93 -0
  558. package/src/keypairs/ed25519/index.ts +9 -0
  559. package/src/keypairs/ed25519/keypair.ts +151 -0
  560. package/src/keypairs/ed25519/publickey.ts +86 -0
  561. package/src/keypairs/secp256k1/index.ts +9 -0
  562. package/src/keypairs/secp256k1/keypair.ts +151 -0
  563. package/src/keypairs/secp256k1/publickey.ts +91 -0
  564. package/src/keypairs/secp256r1/index.ts +9 -0
  565. package/src/keypairs/secp256r1/keypair.ts +147 -0
  566. package/src/keypairs/secp256r1/publickey.ts +91 -0
  567. package/src/multisig/index.ts +5 -0
  568. package/src/multisig/publickey.ts +356 -0
  569. package/src/multisig/signer.ts +92 -0
  570. package/src/transactions/Commands.ts +178 -0
  571. package/src/transactions/Inputs.ts +68 -0
  572. package/src/transactions/ObjectCache.ts +296 -0
  573. package/src/transactions/Transaction.ts +553 -0
  574. package/src/transactions/TransactionData.ts +296 -0
  575. package/src/transactions/__tests__/Transaction.test.ts +184 -0
  576. package/src/transactions/__tests__/bcs.test.ts +205 -0
  577. package/src/transactions/data/internal.ts +321 -0
  578. package/src/transactions/data/v1.ts +501 -0
  579. package/src/transactions/data/v2.ts +146 -0
  580. package/src/transactions/executor/caching.ts +94 -0
  581. package/src/transactions/executor/parallel.ts +335 -0
  582. package/src/transactions/executor/queue.ts +65 -0
  583. package/src/transactions/executor/serial.ts +131 -0
  584. package/src/transactions/hash.ts +20 -0
  585. package/src/transactions/index.ts +41 -0
  586. package/src/transactions/intents/CoinWithBalance.ts +204 -0
  587. package/src/transactions/json-rpc-resolver.ts +482 -0
  588. package/src/transactions/pure.ts +32 -0
  589. package/src/transactions/serializer.ts +205 -0
  590. package/src/transactions/utils.ts +66 -0
  591. package/src/utils/constants.ts +15 -0
  592. package/src/utils/format.ts +19 -0
  593. package/src/utils/index.ts +29 -0
  594. package/src/utils/sui-types.ts +110 -0
  595. package/src/utils/suins.ts +43 -0
  596. package/src/verify/index.ts +11 -0
  597. package/src/verify/verify.ts +111 -0
  598. package/src/version.ts +7 -0
  599. package/src/zklogin/address.ts +27 -0
  600. package/src/zklogin/bcs.ts +26 -0
  601. package/src/zklogin/index.ts +8 -0
  602. package/src/zklogin/jwt-utils.ts +113 -0
  603. package/src/zklogin/publickey.ts +190 -0
  604. package/src/zklogin/signature.ts +37 -0
  605. package/src/zklogin/utils.ts +33 -0
  606. package/transactions/package.json +6 -0
  607. package/utils/package.json +6 -0
  608. package/verify/package.json +6 -0
  609. package/zklogin/package.json +6 -0
@@ -0,0 +1,553 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { SerializedBcs } from '@mysten/bcs';
5
+ import { fromB64, isSerializedBcs } from '@mysten/bcs';
6
+ import type { Input } from 'valibot';
7
+ import { is, parse } from 'valibot';
8
+
9
+ import type { SuiClient } from '../client/index.js';
10
+ import type { SignatureWithBytes, Signer } from '../cryptography/index.js';
11
+ import { normalizeSuiAddress } from '../utils/sui-types.js';
12
+ import type { TransactionArgument } from './Commands.js';
13
+ import { Commands } from './Commands.js';
14
+ import type { CallArg, Command } from './data/internal.js';
15
+ import { Argument, NormalizedCallArg, ObjectRef, TransactionExpiration } from './data/internal.js';
16
+ import { serializeV1TransactionData } from './data/v1.js';
17
+ import { SerializedTransactionDataV2 } from './data/v2.js';
18
+ import { Inputs } from './Inputs.js';
19
+ import type {
20
+ BuildTransactionOptions,
21
+ SerializeTransactionOptions,
22
+ TransactionPlugin,
23
+ } from './json-rpc-resolver.js';
24
+ import { resolveTransactionData } from './json-rpc-resolver.js';
25
+ import { createPure } from './pure.js';
26
+ import { TransactionDataBuilder } from './TransactionData.js';
27
+ import { getIdFromCallArg } from './utils.js';
28
+
29
+ export type TransactionObjectArgument =
30
+ | Exclude<Input<typeof Argument>, { Input: unknown; type?: 'pure' }>
31
+ | ((tx: Transaction) => Exclude<Input<typeof Argument>, { Input: unknown; type?: 'pure' }>);
32
+
33
+ export type TransactionResult = Extract<Argument, { Result: unknown }> &
34
+ Extract<Argument, { NestedResult: unknown }>[];
35
+
36
+ function createTransactionResult(index: number) {
37
+ const baseResult = { $kind: 'Result' as const, Result: index };
38
+
39
+ const nestedResults: {
40
+ $kind: 'NestedResult';
41
+ NestedResult: [number, number];
42
+ }[] = [];
43
+ const nestedResultFor = (
44
+ resultIndex: number,
45
+ ): {
46
+ $kind: 'NestedResult';
47
+ NestedResult: [number, number];
48
+ } =>
49
+ (nestedResults[resultIndex] ??= {
50
+ $kind: 'NestedResult' as const,
51
+ NestedResult: [index, resultIndex],
52
+ });
53
+
54
+ return new Proxy(baseResult, {
55
+ set() {
56
+ throw new Error(
57
+ 'The transaction result is a proxy, and does not support setting properties directly',
58
+ );
59
+ },
60
+ // TODO: Instead of making this return a concrete argument, we should ideally
61
+ // make it reference-based (so that this gets resolved at build-time), which
62
+ // allows re-ordering transactions.
63
+ get(target, property) {
64
+ // This allows this transaction argument to be used in the singular form:
65
+ if (property in target) {
66
+ return Reflect.get(target, property);
67
+ }
68
+
69
+ // Support destructuring:
70
+ if (property === Symbol.iterator) {
71
+ return function* () {
72
+ let i = 0;
73
+ while (true) {
74
+ yield nestedResultFor(i);
75
+ i++;
76
+ }
77
+ };
78
+ }
79
+
80
+ if (typeof property === 'symbol') return;
81
+
82
+ const resultIndex = parseInt(property, 10);
83
+ if (Number.isNaN(resultIndex) || resultIndex < 0) return;
84
+ return nestedResultFor(resultIndex);
85
+ },
86
+ }) as TransactionResult;
87
+ }
88
+
89
+ const TRANSACTION_BRAND = Symbol.for('@mysten/transaction');
90
+
91
+ interface SignOptions extends BuildTransactionOptions {
92
+ signer: Signer;
93
+ }
94
+
95
+ export function isTransaction(obj: unknown): obj is Transaction {
96
+ return !!obj && typeof obj === 'object' && (obj as any)[TRANSACTION_BRAND] === true;
97
+ }
98
+
99
+ export type TransactionObjectInput = string | CallArg | TransactionObjectArgument;
100
+
101
+ /**
102
+ * Transaction Builder
103
+ */
104
+ export class Transaction {
105
+ #serializationPlugins: TransactionPlugin[] = [];
106
+ #buildPlugins: TransactionPlugin[] = [];
107
+ #intentResolvers = new Map<string, TransactionPlugin>();
108
+
109
+ /**
110
+ * Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.
111
+ * Supports either a byte array, or base64-encoded bytes.
112
+ */
113
+ static fromKind(serialized: string | Uint8Array) {
114
+ const tx = new Transaction();
115
+
116
+ tx.#data = TransactionDataBuilder.fromKindBytes(
117
+ typeof serialized === 'string' ? fromB64(serialized) : serialized,
118
+ );
119
+
120
+ return tx;
121
+ }
122
+
123
+ /**
124
+ * Converts from a serialized transaction format to a `Transaction` class.
125
+ * There are two supported serialized formats:
126
+ * - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.
127
+ * - A byte array (or base64-encoded bytes) containing BCS transaction data.
128
+ */
129
+ static from(transaction: string | Uint8Array | Transaction) {
130
+ const newTransaction = new Transaction();
131
+
132
+ if (isTransaction(transaction)) {
133
+ newTransaction.#data = new TransactionDataBuilder(transaction.getData());
134
+ } else if (typeof transaction !== 'string' || !transaction.startsWith('{')) {
135
+ newTransaction.#data = TransactionDataBuilder.fromBytes(
136
+ typeof transaction === 'string' ? fromB64(transaction) : transaction,
137
+ );
138
+ } else {
139
+ newTransaction.#data = TransactionDataBuilder.restore(JSON.parse(transaction));
140
+ }
141
+
142
+ return newTransaction;
143
+ }
144
+
145
+ addSerializationPlugin(step: TransactionPlugin) {
146
+ this.#serializationPlugins.push(step);
147
+ }
148
+
149
+ addBuildPlugin(step: TransactionPlugin) {
150
+ this.#buildPlugins.push(step);
151
+ }
152
+
153
+ addIntentResolver(intent: string, resolver: TransactionPlugin) {
154
+ if (this.#intentResolvers.has(intent) && this.#intentResolvers.get(intent) !== resolver) {
155
+ throw new Error(`Intent resolver for ${intent} already exists`);
156
+ }
157
+
158
+ this.#intentResolvers.set(intent, resolver);
159
+ }
160
+
161
+ setSender(sender: string) {
162
+ this.#data.sender = sender;
163
+ }
164
+ /**
165
+ * Sets the sender only if it has not already been set.
166
+ * This is useful for sponsored transaction flows where the sender may not be the same as the signer address.
167
+ */
168
+ setSenderIfNotSet(sender: string) {
169
+ if (!this.#data.sender) {
170
+ this.#data.sender = sender;
171
+ }
172
+ }
173
+ setExpiration(expiration?: Input<typeof TransactionExpiration> | null) {
174
+ this.#data.expiration = expiration ? parse(TransactionExpiration, expiration) : null;
175
+ }
176
+ setGasPrice(price: number | bigint) {
177
+ this.#data.gasConfig.price = String(price);
178
+ }
179
+ setGasBudget(budget: number | bigint) {
180
+ this.#data.gasConfig.budget = String(budget);
181
+ }
182
+ setGasOwner(owner: string) {
183
+ this.#data.gasConfig.owner = owner;
184
+ }
185
+ setGasPayment(payments: ObjectRef[]) {
186
+ this.#data.gasConfig.payment = payments.map((payment) => parse(ObjectRef, payment));
187
+ }
188
+
189
+ #data: TransactionDataBuilder;
190
+
191
+ /** @deprecated Use `getData()` instead. */
192
+ get blockData() {
193
+ return serializeV1TransactionData(this.#data.snapshot());
194
+ }
195
+
196
+ /** Get a snapshot of the transaction data, in JSON form: */
197
+ getData() {
198
+ return this.#data.snapshot();
199
+ }
200
+
201
+ // Used to brand transaction classes so that they can be identified, even between multiple copies
202
+ // of the builder.
203
+ get [TRANSACTION_BRAND]() {
204
+ return true;
205
+ }
206
+
207
+ // Temporary workaround for the wallet interface accidentally serializing transactions via postMessage
208
+ get pure(): ReturnType<typeof createPure> {
209
+ Object.defineProperty(this, 'pure', {
210
+ enumerable: false,
211
+ value: createPure((value): Argument => {
212
+ if (isSerializedBcs(value)) {
213
+ return this.#data.addInput('pure', {
214
+ $kind: 'Pure',
215
+ Pure: {
216
+ bytes: value.toBase64(),
217
+ },
218
+ });
219
+ }
220
+
221
+ // TODO: we can also do some deduplication here
222
+ return this.#data.addInput(
223
+ 'pure',
224
+ is(NormalizedCallArg, value)
225
+ ? parse(NormalizedCallArg, value)
226
+ : value instanceof Uint8Array
227
+ ? Inputs.Pure(value)
228
+ : { $kind: 'UnresolvedPure', UnresolvedPure: { value } },
229
+ );
230
+ }),
231
+ });
232
+
233
+ return this.pure;
234
+ }
235
+
236
+ constructor() {
237
+ this.#data = new TransactionDataBuilder();
238
+ }
239
+
240
+ /** Returns an argument for the gas coin, to be used in a transaction. */
241
+ get gas() {
242
+ return { $kind: 'GasCoin' as const, GasCoin: true as const };
243
+ }
244
+
245
+ /**
246
+ * Add a new object input to the transaction.
247
+ */
248
+ object(value: TransactionObjectInput): { $kind: 'Input'; Input: number; type?: 'object' } {
249
+ if (typeof value === 'function') {
250
+ return this.object(value(this));
251
+ }
252
+
253
+ if (typeof value === 'object' && is(Argument, value)) {
254
+ return value as { $kind: 'Input'; Input: number; type?: 'object' };
255
+ }
256
+
257
+ const id = getIdFromCallArg(value);
258
+
259
+ const inserted = this.#data.inputs.find((i) => id === getIdFromCallArg(i));
260
+
261
+ // Upgrade shared object inputs to mutable if needed:
262
+ if (inserted?.Object?.SharedObject && typeof value === 'object' && value.Object?.SharedObject) {
263
+ inserted.Object.SharedObject.mutable =
264
+ inserted.Object.SharedObject.mutable || value.Object.SharedObject.mutable;
265
+ }
266
+
267
+ return inserted
268
+ ? { $kind: 'Input', Input: this.#data.inputs.indexOf(inserted), type: 'object' }
269
+ : this.#data.addInput(
270
+ 'object',
271
+ typeof value === 'string'
272
+ ? {
273
+ $kind: 'UnresolvedObject',
274
+ UnresolvedObject: { objectId: normalizeSuiAddress(value) },
275
+ }
276
+ : value,
277
+ );
278
+ }
279
+
280
+ /**
281
+ * Add a new object input to the transaction using the fully-resolved object reference.
282
+ * If you only have an object ID, use `builder.object(id)` instead.
283
+ */
284
+ objectRef(...args: Parameters<(typeof Inputs)['ObjectRef']>) {
285
+ return this.object(Inputs.ObjectRef(...args));
286
+ }
287
+
288
+ /**
289
+ * Add a new receiving input to the transaction using the fully-resolved object reference.
290
+ * If you only have an object ID, use `builder.object(id)` instead.
291
+ */
292
+ receivingRef(...args: Parameters<(typeof Inputs)['ReceivingRef']>) {
293
+ return this.object(Inputs.ReceivingRef(...args));
294
+ }
295
+
296
+ /**
297
+ * Add a new shared object input to the transaction using the fully-resolved shared object reference.
298
+ * If you only have an object ID, use `builder.object(id)` instead.
299
+ */
300
+ sharedObjectRef(...args: Parameters<(typeof Inputs)['SharedObjectRef']>) {
301
+ return this.object(Inputs.SharedObjectRef(...args));
302
+ }
303
+
304
+ /** Add a transaction to the transaction */
305
+ add(command: Command | ((tx: Transaction) => TransactionResult)): TransactionResult {
306
+ if (typeof command === 'function') {
307
+ return command(this);
308
+ }
309
+
310
+ const index = this.#data.commands.push(command);
311
+ return createTransactionResult(index - 1);
312
+ }
313
+
314
+ #normalizeTransactionArgument(arg: TransactionArgument | SerializedBcs<any>) {
315
+ if (isSerializedBcs(arg)) {
316
+ return this.pure(arg);
317
+ }
318
+
319
+ return this.#resolveArgument(arg as TransactionArgument);
320
+ }
321
+
322
+ #resolveArgument(arg: TransactionArgument): Argument {
323
+ if (typeof arg === 'function') {
324
+ return parse(Argument, arg(this));
325
+ }
326
+
327
+ return parse(Argument, arg);
328
+ }
329
+
330
+ // Method shorthands:
331
+
332
+ splitCoins(
333
+ coin: TransactionObjectArgument | string,
334
+ amounts: (TransactionArgument | SerializedBcs<any> | number | string | bigint)[],
335
+ ) {
336
+ return this.add(
337
+ Commands.SplitCoins(
338
+ typeof coin === 'string' ? this.object(coin) : this.#resolveArgument(coin),
339
+ amounts.map((amount) =>
340
+ typeof amount === 'number' || typeof amount === 'bigint' || typeof amount === 'string'
341
+ ? this.pure.u64(amount)
342
+ : this.#normalizeTransactionArgument(amount),
343
+ ),
344
+ ),
345
+ );
346
+ }
347
+ mergeCoins(
348
+ destination: TransactionObjectArgument | string,
349
+ sources: (TransactionObjectArgument | string)[],
350
+ ) {
351
+ return this.add(
352
+ Commands.MergeCoins(
353
+ this.object(destination),
354
+ sources.map((src) => this.object(src)),
355
+ ),
356
+ );
357
+ }
358
+ publish({ modules, dependencies }: { modules: number[][] | string[]; dependencies: string[] }) {
359
+ return this.add(
360
+ Commands.Publish({
361
+ modules,
362
+ dependencies,
363
+ }),
364
+ );
365
+ }
366
+ upgrade({
367
+ modules,
368
+ dependencies,
369
+ package: packageId,
370
+ ticket,
371
+ }: {
372
+ modules: number[][] | string[];
373
+ dependencies: string[];
374
+ package: string;
375
+ ticket: TransactionObjectArgument | string;
376
+ }) {
377
+ return this.add(
378
+ Commands.Upgrade({
379
+ modules,
380
+ dependencies,
381
+ package: packageId,
382
+ ticket: this.object(ticket),
383
+ }),
384
+ );
385
+ }
386
+ moveCall({
387
+ arguments: args,
388
+ ...input
389
+ }:
390
+ | {
391
+ package: string;
392
+ module: string;
393
+ function: string;
394
+ arguments?: (TransactionArgument | SerializedBcs<any>)[];
395
+ typeArguments?: string[];
396
+ }
397
+ | {
398
+ target: string;
399
+ arguments?: (TransactionArgument | SerializedBcs<any>)[];
400
+ typeArguments?: string[];
401
+ }) {
402
+ return this.add(
403
+ Commands.MoveCall({
404
+ ...input,
405
+ arguments: args?.map((arg) => this.#normalizeTransactionArgument(arg)),
406
+ } as Parameters<typeof Commands.MoveCall>[0]),
407
+ );
408
+ }
409
+ transferObjects(
410
+ objects: (TransactionObjectArgument | string)[],
411
+ address: TransactionArgument | SerializedBcs<any> | string,
412
+ ) {
413
+ return this.add(
414
+ Commands.TransferObjects(
415
+ objects.map((obj) => this.object(obj)),
416
+ typeof address === 'string'
417
+ ? this.pure.address(address)
418
+ : this.#normalizeTransactionArgument(address),
419
+ ),
420
+ );
421
+ }
422
+ makeMoveVec({
423
+ type,
424
+ elements,
425
+ }: {
426
+ elements: (TransactionObjectArgument | string)[];
427
+ type?: string;
428
+ }) {
429
+ return this.add(
430
+ Commands.MakeMoveVec({
431
+ type,
432
+ elements: elements.map((obj) => this.object(obj)),
433
+ }),
434
+ );
435
+ }
436
+
437
+ /**
438
+ * @deprecated Use toJSON instead.
439
+ * For synchronous serialization, you can use `getData()`
440
+ * */
441
+ serialize() {
442
+ return JSON.stringify(serializeV1TransactionData(this.#data.snapshot()));
443
+ }
444
+
445
+ async toJSON(options: SerializeTransactionOptions = {}): Promise<string> {
446
+ await this.prepareForSerialization(options);
447
+ return JSON.stringify(
448
+ parse(SerializedTransactionDataV2, this.#data.snapshot()),
449
+ (_key, value) => (typeof value === 'bigint' ? value.toString() : value),
450
+ 2,
451
+ );
452
+ }
453
+
454
+ /** Build the transaction to BCS bytes, and sign it with the provided keypair. */
455
+ async sign(options: SignOptions): Promise<SignatureWithBytes> {
456
+ const { signer, ...buildOptions } = options;
457
+ const bytes = await this.build(buildOptions);
458
+ return signer.signTransaction(bytes);
459
+ }
460
+
461
+ /** Build the transaction to BCS bytes. */
462
+ async build(options: BuildTransactionOptions = {}): Promise<Uint8Array> {
463
+ await this.prepareForSerialization(options);
464
+ await this.#prepareBuild(options);
465
+ return this.#data.build({
466
+ onlyTransactionKind: options.onlyTransactionKind,
467
+ });
468
+ }
469
+
470
+ /** Derive transaction digest */
471
+ async getDigest(
472
+ options: {
473
+ client?: SuiClient;
474
+ } = {},
475
+ ): Promise<string> {
476
+ await this.#prepareBuild(options);
477
+ return this.#data.getDigest();
478
+ }
479
+
480
+ /**
481
+ * Prepare the transaction by validating the transaction data and resolving all inputs
482
+ * so that it can be built into bytes.
483
+ */
484
+ async #prepareBuild(options: BuildTransactionOptions) {
485
+ if (!options.onlyTransactionKind && !this.#data.sender) {
486
+ throw new Error('Missing transaction sender');
487
+ }
488
+
489
+ await this.#runPlugins([...this.#buildPlugins, resolveTransactionData], options);
490
+ }
491
+
492
+ async #runPlugins(plugins: TransactionPlugin[], options: SerializeTransactionOptions) {
493
+ const createNext = (i: number) => {
494
+ if (i >= plugins.length) {
495
+ return () => {};
496
+ }
497
+ const plugin = plugins[i];
498
+
499
+ return async () => {
500
+ const next = createNext(i + 1);
501
+ let calledNext = false;
502
+ let nextResolved = false;
503
+
504
+ await plugin(this.#data, options, async () => {
505
+ if (calledNext) {
506
+ throw new Error(`next() was call multiple times in TransactionPlugin ${i}`);
507
+ }
508
+
509
+ calledNext = true;
510
+
511
+ await next();
512
+
513
+ nextResolved = true;
514
+ });
515
+
516
+ if (!calledNext) {
517
+ throw new Error(`next() was not called in TransactionPlugin ${i}`);
518
+ }
519
+
520
+ if (!nextResolved) {
521
+ throw new Error(`next() was not awaited in TransactionPlugin ${i}`);
522
+ }
523
+ };
524
+ };
525
+
526
+ await createNext(0)();
527
+ }
528
+
529
+ async prepareForSerialization(options: SerializeTransactionOptions) {
530
+ const intents = new Set<string>();
531
+ for (const command of this.#data.commands) {
532
+ if (command.$Intent && options.supportedIntents) {
533
+ intents.add(command.$Intent.name);
534
+ }
535
+ }
536
+
537
+ const steps = [...this.#serializationPlugins];
538
+
539
+ for (const intent of intents) {
540
+ if (options.supportedIntents?.includes(intent)) {
541
+ continue;
542
+ }
543
+
544
+ if (!this.#intentResolvers.has(intent)) {
545
+ throw new Error(`Missing intent resolver for ${intent}`);
546
+ }
547
+
548
+ steps.push(this.#intentResolvers.get(intent)!);
549
+ }
550
+
551
+ await this.#runPlugins(steps, options);
552
+ }
553
+ }