@unconfirmed/effect-sui 0.0.0-stage → 0.1.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 (573) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/Address.d.ts +18 -0
  4. package/dist/Address.d.ts.map +1 -0
  5. package/dist/Address.js +33 -0
  6. package/dist/Address.js.map +1 -0
  7. package/dist/AddressAlias.d.ts +107 -0
  8. package/dist/AddressAlias.d.ts.map +1 -0
  9. package/dist/AddressAlias.js +104 -0
  10. package/dist/AddressAlias.js.map +1 -0
  11. package/dist/Bip32.d.ts +6 -0
  12. package/dist/Bip32.d.ts.map +1 -0
  13. package/dist/Bip32.js +34 -0
  14. package/dist/Bip32.js.map +1 -0
  15. package/dist/Chain.d.ts +23 -0
  16. package/dist/Chain.d.ts.map +1 -0
  17. package/dist/Chain.js +7 -0
  18. package/dist/Chain.js.map +1 -0
  19. package/dist/CheckpointData.d.ts +74 -0
  20. package/dist/CheckpointData.d.ts.map +1 -0
  21. package/dist/CheckpointData.js +48 -0
  22. package/dist/CheckpointData.js.map +1 -0
  23. package/dist/Checkpoints.d.ts +23 -0
  24. package/dist/Checkpoints.d.ts.map +1 -0
  25. package/dist/Checkpoints.js +7 -0
  26. package/dist/Checkpoints.js.map +1 -0
  27. package/dist/CoinReservation.d.ts +18 -0
  28. package/dist/CoinReservation.d.ts.map +1 -0
  29. package/dist/CoinReservation.js +58 -0
  30. package/dist/CoinReservation.js.map +1 -0
  31. package/dist/Coins.d.ts +42 -0
  32. package/dist/Coins.d.ts.map +1 -0
  33. package/dist/Coins.js +49 -0
  34. package/dist/Coins.js.map +1 -0
  35. package/dist/DynamicFields.d.ts +115 -0
  36. package/dist/DynamicFields.d.ts.map +1 -0
  37. package/dist/DynamicFields.js +101 -0
  38. package/dist/DynamicFields.js.map +1 -0
  39. package/dist/Ecdsa.d.ts +39 -0
  40. package/dist/Ecdsa.d.ts.map +1 -0
  41. package/dist/Ecdsa.js +76 -0
  42. package/dist/Ecdsa.js.map +1 -0
  43. package/dist/Ed25519.d.ts +22 -0
  44. package/dist/Ed25519.d.ts.map +1 -0
  45. package/dist/Ed25519.js +77 -0
  46. package/dist/Ed25519.js.map +1 -0
  47. package/dist/Events.d.ts +105 -0
  48. package/dist/Events.d.ts.map +1 -0
  49. package/dist/Events.js +51 -0
  50. package/dist/Events.js.map +1 -0
  51. package/dist/Hash.d.ts +16 -0
  52. package/dist/Hash.d.ts.map +1 -0
  53. package/dist/Hash.js +32 -0
  54. package/dist/Hash.js.map +1 -0
  55. package/dist/MlDsa65.d.ts +17 -0
  56. package/dist/MlDsa65.d.ts.map +1 -0
  57. package/dist/MlDsa65.js +84 -0
  58. package/dist/MlDsa65.js.map +1 -0
  59. package/dist/Mnemonic.d.ts +20 -0
  60. package/dist/Mnemonic.d.ts.map +1 -0
  61. package/dist/Mnemonic.js +71 -0
  62. package/dist/Mnemonic.js.map +1 -0
  63. package/dist/Move.d.ts +261 -0
  64. package/dist/Move.d.ts.map +1 -0
  65. package/dist/Move.js +232 -0
  66. package/dist/Move.js.map +1 -0
  67. package/dist/MultiSig.d.ts +106 -0
  68. package/dist/MultiSig.d.ts.map +1 -0
  69. package/dist/MultiSig.js +254 -0
  70. package/dist/MultiSig.js.map +1 -0
  71. package/dist/Objects.d.ts +95 -0
  72. package/dist/Objects.d.ts.map +1 -0
  73. package/dist/Objects.js +57 -0
  74. package/dist/Objects.js.map +1 -0
  75. package/dist/Packages.d.ts +49 -0
  76. package/dist/Packages.d.ts.map +1 -0
  77. package/dist/Packages.js +16 -0
  78. package/dist/Packages.js.map +1 -0
  79. package/dist/Passkey.d.ts +11 -0
  80. package/dist/Passkey.d.ts.map +1 -0
  81. package/dist/Passkey.js +11 -0
  82. package/dist/Passkey.js.map +1 -0
  83. package/dist/PrivateKey.d.ts +39 -0
  84. package/dist/PrivateKey.d.ts.map +1 -0
  85. package/dist/PrivateKey.js +118 -0
  86. package/dist/PrivateKey.js.map +1 -0
  87. package/dist/Ptb.d.ts +413 -0
  88. package/dist/Ptb.d.ts.map +1 -0
  89. package/dist/Ptb.js +338 -0
  90. package/dist/Ptb.js.map +1 -0
  91. package/dist/Resolve.d.ts +502 -0
  92. package/dist/Resolve.d.ts.map +1 -0
  93. package/dist/Resolve.js +1188 -0
  94. package/dist/Resolve.js.map +1 -0
  95. package/dist/RpcError.d.ts +19 -0
  96. package/dist/RpcError.d.ts.map +1 -0
  97. package/dist/RpcError.js +37 -0
  98. package/dist/RpcError.js.map +1 -0
  99. package/dist/Secp256k1.d.ts +11 -0
  100. package/dist/Secp256k1.d.ts.map +1 -0
  101. package/dist/Secp256k1.js +23 -0
  102. package/dist/Secp256k1.js.map +1 -0
  103. package/dist/Secp256r1.d.ts +11 -0
  104. package/dist/Secp256r1.d.ts.map +1 -0
  105. package/dist/Secp256r1.js +23 -0
  106. package/dist/Secp256r1.js.map +1 -0
  107. package/dist/SignatureScheme.d.ts +103 -0
  108. package/dist/SignatureScheme.d.ts.map +1 -0
  109. package/dist/SignatureScheme.js +93 -0
  110. package/dist/SignatureScheme.js.map +1 -0
  111. package/dist/Signer.d.ts +54 -0
  112. package/dist/Signer.d.ts.map +1 -0
  113. package/dist/Signer.js +31 -0
  114. package/dist/Signer.js.map +1 -0
  115. package/dist/Testing.d.ts +171 -0
  116. package/dist/Testing.d.ts.map +1 -0
  117. package/dist/Testing.js +531 -0
  118. package/dist/Testing.js.map +1 -0
  119. package/dist/TransactionData.d.ts +3218 -0
  120. package/dist/TransactionData.d.ts.map +1 -0
  121. package/dist/TransactionData.js +105 -0
  122. package/dist/TransactionData.js.map +1 -0
  123. package/dist/TransactionJson.d.ts +1544 -0
  124. package/dist/TransactionJson.d.ts.map +1 -0
  125. package/dist/TransactionJson.js +926 -0
  126. package/dist/TransactionJson.js.map +1 -0
  127. package/dist/Transactions.d.ts +181 -0
  128. package/dist/Transactions.d.ts.map +1 -0
  129. package/dist/Transactions.js +49 -0
  130. package/dist/Transactions.js.map +1 -0
  131. package/dist/Tx.d.ts +1419 -0
  132. package/dist/Tx.d.ts.map +1 -0
  133. package/dist/Tx.js +266 -0
  134. package/dist/Tx.js.map +1 -0
  135. package/dist/TypeTag.d.ts +42 -0
  136. package/dist/TypeTag.d.ts.map +1 -0
  137. package/dist/TypeTag.js +110 -0
  138. package/dist/TypeTag.js.map +1 -0
  139. package/dist/Verify.d.ts +23 -0
  140. package/dist/Verify.d.ts.map +1 -0
  141. package/dist/Verify.js +29 -0
  142. package/dist/Verify.js.map +1 -0
  143. package/dist/enoki/EnokiClient.d.ts +184 -0
  144. package/dist/enoki/EnokiClient.d.ts.map +1 -0
  145. package/dist/enoki/EnokiClient.js +105 -0
  146. package/dist/enoki/EnokiClient.js.map +1 -0
  147. package/dist/enoki/EnokiHttp.d.ts +33 -0
  148. package/dist/enoki/EnokiHttp.d.ts.map +1 -0
  149. package/dist/enoki/EnokiHttp.js +160 -0
  150. package/dist/enoki/EnokiHttp.js.map +1 -0
  151. package/dist/enoki/Sponsor.d.ts +119 -0
  152. package/dist/enoki/Sponsor.d.ts.map +1 -0
  153. package/dist/enoki/Sponsor.js +170 -0
  154. package/dist/enoki/Sponsor.js.map +1 -0
  155. package/dist/enoki/ZkLoginFlow.d.ts +84 -0
  156. package/dist/enoki/ZkLoginFlow.d.ts.map +1 -0
  157. package/dist/enoki/ZkLoginFlow.js +138 -0
  158. package/dist/enoki/ZkLoginFlow.js.map +1 -0
  159. package/dist/enoki/index.d.ts +9 -0
  160. package/dist/enoki/index.d.ts.map +1 -0
  161. package/dist/enoki/index.js +9 -0
  162. package/dist/enoki/index.js.map +1 -0
  163. package/dist/graphql/ChainGraphQL.d.ts +35 -0
  164. package/dist/graphql/ChainGraphQL.d.ts.map +1 -0
  165. package/dist/graphql/ChainGraphQL.js +62 -0
  166. package/dist/graphql/ChainGraphQL.js.map +1 -0
  167. package/dist/graphql/CheckpointDataGraphQL.d.ts +785 -0
  168. package/dist/graphql/CheckpointDataGraphQL.d.ts.map +1 -0
  169. package/dist/graphql/CheckpointDataGraphQL.js +157 -0
  170. package/dist/graphql/CheckpointDataGraphQL.js.map +1 -0
  171. package/dist/graphql/CheckpointsGraphQL.d.ts +91 -0
  172. package/dist/graphql/CheckpointsGraphQL.d.ts.map +1 -0
  173. package/dist/graphql/CheckpointsGraphQL.js +80 -0
  174. package/dist/graphql/CheckpointsGraphQL.js.map +1 -0
  175. package/dist/graphql/CoinsGraphQL.d.ts +81 -0
  176. package/dist/graphql/CoinsGraphQL.d.ts.map +1 -0
  177. package/dist/graphql/CoinsGraphQL.js +63 -0
  178. package/dist/graphql/CoinsGraphQL.js.map +1 -0
  179. package/dist/graphql/DynamicFieldsGraphQL.d.ts +94 -0
  180. package/dist/graphql/DynamicFieldsGraphQL.d.ts.map +1 -0
  181. package/dist/graphql/DynamicFieldsGraphQL.js +126 -0
  182. package/dist/graphql/DynamicFieldsGraphQL.js.map +1 -0
  183. package/dist/graphql/EventsGraphQL.d.ts +266 -0
  184. package/dist/graphql/EventsGraphQL.d.ts.map +1 -0
  185. package/dist/graphql/EventsGraphQL.js +249 -0
  186. package/dist/graphql/EventsGraphQL.js.map +1 -0
  187. package/dist/graphql/ObjectsGraphQL.d.ts +130 -0
  188. package/dist/graphql/ObjectsGraphQL.d.ts.map +1 -0
  189. package/dist/graphql/ObjectsGraphQL.js +79 -0
  190. package/dist/graphql/ObjectsGraphQL.js.map +1 -0
  191. package/dist/graphql/PackagesGraphQL.d.ts +82 -0
  192. package/dist/graphql/PackagesGraphQL.d.ts.map +1 -0
  193. package/dist/graphql/PackagesGraphQL.js +145 -0
  194. package/dist/graphql/PackagesGraphQL.js.map +1 -0
  195. package/dist/graphql/SuiGraphQL.d.ts +37 -0
  196. package/dist/graphql/SuiGraphQL.d.ts.map +1 -0
  197. package/dist/graphql/SuiGraphQL.js +47 -0
  198. package/dist/graphql/SuiGraphQL.js.map +1 -0
  199. package/dist/graphql/TransactionsGraphQL.d.ts +1309 -0
  200. package/dist/graphql/TransactionsGraphQL.d.ts.map +1 -0
  201. package/dist/graphql/TransactionsGraphQL.js +206 -0
  202. package/dist/graphql/TransactionsGraphQL.js.map +1 -0
  203. package/dist/graphql/convert.d.ts +505 -0
  204. package/dist/graphql/convert.d.ts.map +1 -0
  205. package/dist/graphql/convert.js +384 -0
  206. package/dist/graphql/convert.js.map +1 -0
  207. package/dist/graphql/index.d.ts +41 -0
  208. package/dist/graphql/index.d.ts.map +1 -0
  209. package/dist/graphql/index.js +20 -0
  210. package/dist/graphql/index.js.map +1 -0
  211. package/dist/graphql/merge.d.ts +8 -0
  212. package/dist/graphql/merge.d.ts.map +1 -0
  213. package/dist/graphql/merge.js +55 -0
  214. package/dist/graphql/merge.js.map +1 -0
  215. package/dist/graphql/paging.d.ts +219 -0
  216. package/dist/graphql/paging.d.ts.map +1 -0
  217. package/dist/graphql/paging.js +74 -0
  218. package/dist/graphql/paging.js.map +1 -0
  219. package/dist/graphql/subscription.d.ts +27 -0
  220. package/dist/graphql/subscription.d.ts.map +1 -0
  221. package/dist/graphql/subscription.js +47 -0
  222. package/dist/graphql/subscription.js.map +1 -0
  223. package/dist/graphql/tip.d.ts +31 -0
  224. package/dist/graphql/tip.d.ts.map +1 -0
  225. package/dist/graphql/tip.js +29 -0
  226. package/dist/graphql/tip.js.map +1 -0
  227. package/dist/grpc/ChainGrpc.d.ts +11 -0
  228. package/dist/grpc/ChainGrpc.d.ts.map +1 -0
  229. package/dist/grpc/ChainGrpc.js +40 -0
  230. package/dist/grpc/ChainGrpc.js.map +1 -0
  231. package/dist/grpc/CheckpointDataGrpc.d.ts +6 -0
  232. package/dist/grpc/CheckpointDataGrpc.d.ts.map +1 -0
  233. package/dist/grpc/CheckpointDataGrpc.js +27 -0
  234. package/dist/grpc/CheckpointDataGrpc.js.map +1 -0
  235. package/dist/grpc/CheckpointsGrpc.d.ts +6 -0
  236. package/dist/grpc/CheckpointsGrpc.d.ts.map +1 -0
  237. package/dist/grpc/CheckpointsGrpc.js +25 -0
  238. package/dist/grpc/CheckpointsGrpc.js.map +1 -0
  239. package/dist/grpc/CoinsGrpc.d.ts +7 -0
  240. package/dist/grpc/CoinsGrpc.d.ts.map +1 -0
  241. package/dist/grpc/CoinsGrpc.js +34 -0
  242. package/dist/grpc/CoinsGrpc.js.map +1 -0
  243. package/dist/grpc/DynamicFieldsGrpc.d.ts +11 -0
  244. package/dist/grpc/DynamicFieldsGrpc.d.ts.map +1 -0
  245. package/dist/grpc/DynamicFieldsGrpc.js +91 -0
  246. package/dist/grpc/DynamicFieldsGrpc.js.map +1 -0
  247. package/dist/grpc/EventsGrpc.d.ts +13 -0
  248. package/dist/grpc/EventsGrpc.d.ts.map +1 -0
  249. package/dist/grpc/EventsGrpc.js +88 -0
  250. package/dist/grpc/EventsGrpc.js.map +1 -0
  251. package/dist/grpc/GrpcWeb.d.ts +71 -0
  252. package/dist/grpc/GrpcWeb.d.ts.map +1 -0
  253. package/dist/grpc/GrpcWeb.js +243 -0
  254. package/dist/grpc/GrpcWeb.js.map +1 -0
  255. package/dist/grpc/ObjectsGrpc.d.ts +10 -0
  256. package/dist/grpc/ObjectsGrpc.d.ts.map +1 -0
  257. package/dist/grpc/ObjectsGrpc.js +72 -0
  258. package/dist/grpc/ObjectsGrpc.js.map +1 -0
  259. package/dist/grpc/PackagesGrpc.d.ts +9 -0
  260. package/dist/grpc/PackagesGrpc.d.ts.map +1 -0
  261. package/dist/grpc/PackagesGrpc.js +78 -0
  262. package/dist/grpc/PackagesGrpc.js.map +1 -0
  263. package/dist/grpc/Rpc.d.ts +46 -0
  264. package/dist/grpc/Rpc.d.ts.map +1 -0
  265. package/dist/grpc/Rpc.js +111 -0
  266. package/dist/grpc/Rpc.js.map +1 -0
  267. package/dist/grpc/TransactionsGrpc.d.ts +6 -0
  268. package/dist/grpc/TransactionsGrpc.d.ts.map +1 -0
  269. package/dist/grpc/TransactionsGrpc.js +56 -0
  270. package/dist/grpc/TransactionsGrpc.js.map +1 -0
  271. package/dist/grpc/cache.d.ts +7 -0
  272. package/dist/grpc/cache.d.ts.map +1 -0
  273. package/dist/grpc/cache.js +55 -0
  274. package/dist/grpc/cache.js.map +1 -0
  275. package/dist/grpc/convert.d.ts +43 -0
  276. package/dist/grpc/convert.d.ts.map +1 -0
  277. package/dist/grpc/convert.js +198 -0
  278. package/dist/grpc/convert.js.map +1 -0
  279. package/dist/grpc/generated/lean.d.ts +36 -0
  280. package/dist/grpc/generated/lean.d.ts.map +1 -0
  281. package/dist/grpc/generated/lean.js +205 -0
  282. package/dist/grpc/generated/lean.js.map +1 -0
  283. package/dist/grpc/generated/proto.d.ts +2000 -0
  284. package/dist/grpc/generated/proto.d.ts.map +1 -0
  285. package/dist/grpc/generated/proto.js +356 -0
  286. package/dist/grpc/generated/proto.js.map +1 -0
  287. package/dist/grpc/generated/rpc.d.ts +62 -0
  288. package/dist/grpc/generated/rpc.d.ts.map +1 -0
  289. package/dist/grpc/generated/rpc.js +324 -0
  290. package/dist/grpc/generated/rpc.js.map +1 -0
  291. package/dist/grpc/index.d.ts +58 -0
  292. package/dist/grpc/index.d.ts.map +1 -0
  293. package/dist/grpc/index.js +43 -0
  294. package/dist/grpc/index.js.map +1 -0
  295. package/dist/grpc/scan.d.ts +79 -0
  296. package/dist/grpc/scan.d.ts.map +1 -0
  297. package/dist/grpc/scan.js +126 -0
  298. package/dist/grpc/scan.js.map +1 -0
  299. package/dist/grpc/transaction.d.ts +9 -0
  300. package/dist/grpc/transaction.d.ts.map +1 -0
  301. package/dist/grpc/transaction.js +168 -0
  302. package/dist/grpc/transaction.js.map +1 -0
  303. package/dist/index.d.ts +36 -0
  304. package/dist/index.d.ts.map +1 -0
  305. package/dist/index.js +36 -0
  306. package/dist/index.js.map +1 -0
  307. package/dist/internal/allowances.d.ts +18 -0
  308. package/dist/internal/allowances.d.ts.map +1 -0
  309. package/dist/internal/allowances.js +194 -0
  310. package/dist/internal/allowances.js.map +1 -0
  311. package/dist/internal/mnemonic.d.ts +53 -0
  312. package/dist/internal/mnemonic.d.ts.map +1 -0
  313. package/dist/internal/mnemonic.js +66 -0
  314. package/dist/internal/mnemonic.js.map +1 -0
  315. package/dist/internal/passkey/BrowserProvider.d.ts +10 -0
  316. package/dist/internal/passkey/BrowserProvider.d.ts.map +1 -0
  317. package/dist/internal/passkey/BrowserProvider.js +101 -0
  318. package/dist/internal/passkey/BrowserProvider.js.map +1 -0
  319. package/dist/internal/passkey/Passkey.d.ts +104 -0
  320. package/dist/internal/passkey/Passkey.d.ts.map +1 -0
  321. package/dist/internal/passkey/Passkey.js +333 -0
  322. package/dist/internal/passkey/Passkey.js.map +1 -0
  323. package/dist/internal/passkey/SoftwareProvider.d.ts +23 -0
  324. package/dist/internal/passkey/SoftwareProvider.d.ts.map +1 -0
  325. package/dist/internal/passkey/SoftwareProvider.js +61 -0
  326. package/dist/internal/passkey/SoftwareProvider.js.map +1 -0
  327. package/dist/lifecycle/Evidence.d.ts +62 -0
  328. package/dist/lifecycle/Evidence.d.ts.map +1 -0
  329. package/dist/lifecycle/Evidence.js +30 -0
  330. package/dist/lifecycle/Evidence.js.map +1 -0
  331. package/dist/lifecycle/EvidenceGraphQL.d.ts +59 -0
  332. package/dist/lifecycle/EvidenceGraphQL.d.ts.map +1 -0
  333. package/dist/lifecycle/EvidenceGraphQL.js +53 -0
  334. package/dist/lifecycle/EvidenceGraphQL.js.map +1 -0
  335. package/dist/lifecycle/EvidenceGrpc.d.ts +4 -0
  336. package/dist/lifecycle/EvidenceGrpc.d.ts.map +1 -0
  337. package/dist/lifecycle/EvidenceGrpc.js +37 -0
  338. package/dist/lifecycle/EvidenceGrpc.js.map +1 -0
  339. package/dist/lifecycle/Journal.d.ts +69 -0
  340. package/dist/lifecycle/Journal.d.ts.map +1 -0
  341. package/dist/lifecycle/Journal.js +70 -0
  342. package/dist/lifecycle/Journal.js.map +1 -0
  343. package/dist/lifecycle/JournalEntry.d.ts +67 -0
  344. package/dist/lifecycle/JournalEntry.d.ts.map +1 -0
  345. package/dist/lifecycle/JournalEntry.js +45 -0
  346. package/dist/lifecycle/JournalEntry.js.map +1 -0
  347. package/dist/lifecycle/JournalKeyValueStore.d.ts +30 -0
  348. package/dist/lifecycle/JournalKeyValueStore.d.ts.map +1 -0
  349. package/dist/lifecycle/JournalKeyValueStore.js +217 -0
  350. package/dist/lifecycle/JournalKeyValueStore.js.map +1 -0
  351. package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts +54 -0
  352. package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts.map +1 -0
  353. package/dist/lifecycle/KeyValueStoreIndexedDb.js +321 -0
  354. package/dist/lifecycle/KeyValueStoreIndexedDb.js.map +1 -0
  355. package/dist/lifecycle/KeyValueStoreOpfs.d.ts +65 -0
  356. package/dist/lifecycle/KeyValueStoreOpfs.d.ts.map +1 -0
  357. package/dist/lifecycle/KeyValueStoreOpfs.js +207 -0
  358. package/dist/lifecycle/KeyValueStoreOpfs.js.map +1 -0
  359. package/dist/lifecycle/Lifecycle.d.ts +416 -0
  360. package/dist/lifecycle/Lifecycle.d.ts.map +1 -0
  361. package/dist/lifecycle/Lifecycle.js +666 -0
  362. package/dist/lifecycle/Lifecycle.js.map +1 -0
  363. package/dist/lifecycle/Outcome.d.ts +132 -0
  364. package/dist/lifecycle/Outcome.d.ts.map +1 -0
  365. package/dist/lifecycle/Outcome.js +106 -0
  366. package/dist/lifecycle/Outcome.js.map +1 -0
  367. package/dist/lifecycle/SenderLock.d.ts +37 -0
  368. package/dist/lifecycle/SenderLock.d.ts.map +1 -0
  369. package/dist/lifecycle/SenderLock.js +57 -0
  370. package/dist/lifecycle/SenderLock.js.map +1 -0
  371. package/dist/lifecycle/SenderLockWebLocks.d.ts +37 -0
  372. package/dist/lifecycle/SenderLockWebLocks.d.ts.map +1 -0
  373. package/dist/lifecycle/SenderLockWebLocks.js +100 -0
  374. package/dist/lifecycle/SenderLockWebLocks.js.map +1 -0
  375. package/dist/lifecycle/SignedTransaction.d.ts +55 -0
  376. package/dist/lifecycle/SignedTransaction.d.ts.map +1 -0
  377. package/dist/lifecycle/SignedTransaction.js +109 -0
  378. package/dist/lifecycle/SignedTransaction.js.map +1 -0
  379. package/dist/lifecycle/SubmitConfig.d.ts +44 -0
  380. package/dist/lifecycle/SubmitConfig.d.ts.map +1 -0
  381. package/dist/lifecycle/SubmitConfig.js +39 -0
  382. package/dist/lifecycle/SubmitConfig.js.map +1 -0
  383. package/dist/lifecycle/index.d.ts +13 -0
  384. package/dist/lifecycle/index.d.ts.map +1 -0
  385. package/dist/lifecycle/index.js +13 -0
  386. package/dist/lifecycle/index.js.map +1 -0
  387. package/dist/wallet/Connection.d.ts +119 -0
  388. package/dist/wallet/Connection.d.ts.map +1 -0
  389. package/dist/wallet/Connection.js +197 -0
  390. package/dist/wallet/Connection.js.map +1 -0
  391. package/dist/wallet/Features.d.ts +91 -0
  392. package/dist/wallet/Features.d.ts.map +1 -0
  393. package/dist/wallet/Features.js +14 -0
  394. package/dist/wallet/Features.js.map +1 -0
  395. package/dist/wallet/Wallet.d.ts +151 -0
  396. package/dist/wallet/Wallet.d.ts.map +1 -0
  397. package/dist/wallet/Wallet.js +399 -0
  398. package/dist/wallet/Wallet.js.map +1 -0
  399. package/dist/wallet/index.d.ts +7 -0
  400. package/dist/wallet/index.d.ts.map +1 -0
  401. package/dist/wallet/index.js +7 -0
  402. package/dist/wallet/index.js.map +1 -0
  403. package/dist/zklogin/AddressSeed.d.ts +40 -0
  404. package/dist/zklogin/AddressSeed.d.ts.map +1 -0
  405. package/dist/zklogin/AddressSeed.js +91 -0
  406. package/dist/zklogin/AddressSeed.js.map +1 -0
  407. package/dist/zklogin/Errors.d.ts +24 -0
  408. package/dist/zklogin/Errors.d.ts.map +1 -0
  409. package/dist/zklogin/Errors.js +25 -0
  410. package/dist/zklogin/Errors.js.map +1 -0
  411. package/dist/zklogin/Jwt.d.ts +51 -0
  412. package/dist/zklogin/Jwt.d.ts.map +1 -0
  413. package/dist/zklogin/Jwt.js +159 -0
  414. package/dist/zklogin/Jwt.js.map +1 -0
  415. package/dist/zklogin/Nonce.d.ts +9 -0
  416. package/dist/zklogin/Nonce.d.ts.map +1 -0
  417. package/dist/zklogin/Nonce.js +34 -0
  418. package/dist/zklogin/Nonce.js.map +1 -0
  419. package/dist/zklogin/Poseidon.d.ts +24 -0
  420. package/dist/zklogin/Poseidon.d.ts.map +1 -0
  421. package/dist/zklogin/Poseidon.js +54 -0
  422. package/dist/zklogin/Poseidon.js.map +1 -0
  423. package/dist/zklogin/PublicIdentifier.d.ts +49 -0
  424. package/dist/zklogin/PublicIdentifier.d.ts.map +1 -0
  425. package/dist/zklogin/PublicIdentifier.js +90 -0
  426. package/dist/zklogin/PublicIdentifier.js.map +1 -0
  427. package/dist/zklogin/Signature.d.ts +55 -0
  428. package/dist/zklogin/Signature.d.ts.map +1 -0
  429. package/dist/zklogin/Signature.js +70 -0
  430. package/dist/zklogin/Signature.js.map +1 -0
  431. package/dist/zklogin/ZkLogin.d.ts +41 -0
  432. package/dist/zklogin/ZkLogin.d.ts.map +1 -0
  433. package/dist/zklogin/ZkLogin.js +87 -0
  434. package/dist/zklogin/ZkLogin.js.map +1 -0
  435. package/dist/zklogin/ZkLoginAddress.d.ts +30 -0
  436. package/dist/zklogin/ZkLoginAddress.d.ts.map +1 -0
  437. package/dist/zklogin/ZkLoginAddress.js +31 -0
  438. package/dist/zklogin/ZkLoginAddress.js.map +1 -0
  439. package/dist/zklogin/ZkLoginVerifier.d.ts +37 -0
  440. package/dist/zklogin/ZkLoginVerifier.d.ts.map +1 -0
  441. package/dist/zklogin/ZkLoginVerifier.js +4 -0
  442. package/dist/zklogin/ZkLoginVerifier.js.map +1 -0
  443. package/dist/zklogin/ZkLoginVerifierGrpc.d.ts +12 -0
  444. package/dist/zklogin/ZkLoginVerifierGrpc.d.ts.map +1 -0
  445. package/dist/zklogin/ZkLoginVerifierGrpc.js +53 -0
  446. package/dist/zklogin/ZkLoginVerifierGrpc.js.map +1 -0
  447. package/dist/zklogin/index.d.ts +17 -0
  448. package/dist/zklogin/index.d.ts.map +1 -0
  449. package/dist/zklogin/index.js +17 -0
  450. package/dist/zklogin/index.js.map +1 -0
  451. package/dist/zklogin/internal/parse.d.ts +9 -0
  452. package/dist/zklogin/internal/parse.d.ts.map +1 -0
  453. package/dist/zklogin/internal/parse.js +33 -0
  454. package/dist/zklogin/internal/parse.js.map +1 -0
  455. package/dist/zklogin/internal/poseidon.d.ts +21 -0
  456. package/dist/zklogin/internal/poseidon.d.ts.map +1 -0
  457. package/dist/zklogin/internal/poseidon.js +40 -0
  458. package/dist/zklogin/internal/poseidon.js.map +1 -0
  459. package/package.json +69 -4
  460. package/src/Address.ts +45 -0
  461. package/src/AddressAlias.ts +160 -0
  462. package/src/Bip32.ts +37 -0
  463. package/src/Chain.ts +21 -0
  464. package/src/CheckpointData.ts +106 -0
  465. package/src/Checkpoints.ts +18 -0
  466. package/src/CoinReservation.ts +65 -0
  467. package/src/Coins.ts +86 -0
  468. package/src/DynamicFields.ts +179 -0
  469. package/src/Ecdsa.ts +103 -0
  470. package/src/Ed25519.ts +84 -0
  471. package/src/Events.ts +133 -0
  472. package/src/Hash.ts +39 -0
  473. package/src/MlDsa65.ts +92 -0
  474. package/src/Mnemonic.ts +109 -0
  475. package/src/Move.ts +440 -0
  476. package/src/MultiSig.ts +320 -0
  477. package/src/Objects.ts +112 -0
  478. package/src/Packages.ts +52 -0
  479. package/src/Passkey.ts +10 -0
  480. package/src/PrivateKey.ts +138 -0
  481. package/src/Ptb.ts +579 -0
  482. package/src/Resolve.ts +1367 -0
  483. package/src/RpcError.ts +41 -0
  484. package/src/Secp256k1.ts +29 -0
  485. package/src/Secp256r1.ts +29 -0
  486. package/src/SignatureScheme.ts +166 -0
  487. package/src/Signer.ts +62 -0
  488. package/src/Testing.ts +830 -0
  489. package/src/TransactionData.ts +134 -0
  490. package/src/TransactionJson.ts +1002 -0
  491. package/src/Transactions.ts +211 -0
  492. package/src/Tx.ts +367 -0
  493. package/src/TypeTag.ts +123 -0
  494. package/src/Verify.ts +42 -0
  495. package/src/enoki/EnokiClient.ts +204 -0
  496. package/src/enoki/EnokiHttp.ts +222 -0
  497. package/src/enoki/Sponsor.ts +280 -0
  498. package/src/enoki/ZkLoginFlow.ts +176 -0
  499. package/src/enoki/index.ts +8 -0
  500. package/src/graphql/ChainGraphQL.ts +76 -0
  501. package/src/graphql/CheckpointDataGraphQL.ts +191 -0
  502. package/src/graphql/CheckpointsGraphQL.ts +96 -0
  503. package/src/graphql/CoinsGraphQL.ts +85 -0
  504. package/src/graphql/DynamicFieldsGraphQL.ts +167 -0
  505. package/src/graphql/EventsGraphQL.ts +301 -0
  506. package/src/graphql/ObjectsGraphQL.ts +112 -0
  507. package/src/graphql/PackagesGraphQL.ts +173 -0
  508. package/src/graphql/SuiGraphQL.ts +77 -0
  509. package/src/graphql/TransactionsGraphQL.ts +292 -0
  510. package/src/graphql/convert.ts +450 -0
  511. package/src/graphql/index.ts +74 -0
  512. package/src/graphql/merge.ts +62 -0
  513. package/src/graphql/paging.ts +110 -0
  514. package/src/graphql/subscription.ts +58 -0
  515. package/src/graphql/tip.ts +38 -0
  516. package/src/grpc/ChainGrpc.ts +51 -0
  517. package/src/grpc/CheckpointDataGrpc.ts +47 -0
  518. package/src/grpc/CheckpointsGrpc.ts +37 -0
  519. package/src/grpc/CoinsGrpc.ts +50 -0
  520. package/src/grpc/DynamicFieldsGrpc.ts +128 -0
  521. package/src/grpc/EventsGrpc.ts +101 -0
  522. package/src/grpc/GrpcWeb.ts +343 -0
  523. package/src/grpc/ObjectsGrpc.ts +95 -0
  524. package/src/grpc/PackagesGrpc.ts +98 -0
  525. package/src/grpc/Rpc.ts +156 -0
  526. package/src/grpc/TransactionsGrpc.ts +88 -0
  527. package/src/grpc/cache.ts +68 -0
  528. package/src/grpc/convert.ts +227 -0
  529. package/src/grpc/generated/lean.ts +276 -0
  530. package/src/grpc/generated/proto.ts +2130 -0
  531. package/src/grpc/generated/rpc.ts +417 -0
  532. package/src/grpc/index.ts +97 -0
  533. package/src/grpc/scan.ts +183 -0
  534. package/src/grpc/transaction.ts +182 -0
  535. package/src/index.ts +35 -0
  536. package/src/internal/allowances.ts +238 -0
  537. package/src/internal/mnemonic.ts +99 -0
  538. package/src/internal/passkey/BrowserProvider.ts +131 -0
  539. package/src/internal/passkey/Passkey.ts +408 -0
  540. package/src/internal/passkey/SoftwareProvider.ts +90 -0
  541. package/src/lifecycle/Evidence.ts +85 -0
  542. package/src/lifecycle/EvidenceGraphQL.ts +67 -0
  543. package/src/lifecycle/EvidenceGrpc.ts +47 -0
  544. package/src/lifecycle/Journal.ts +117 -0
  545. package/src/lifecycle/JournalEntry.ts +68 -0
  546. package/src/lifecycle/JournalKeyValueStore.ts +276 -0
  547. package/src/lifecycle/KeyValueStoreIndexedDb.ts +361 -0
  548. package/src/lifecycle/KeyValueStoreOpfs.ts +230 -0
  549. package/src/lifecycle/Lifecycle.ts +990 -0
  550. package/src/lifecycle/Outcome.ts +130 -0
  551. package/src/lifecycle/SenderLock.ts +73 -0
  552. package/src/lifecycle/SenderLockWebLocks.ts +136 -0
  553. package/src/lifecycle/SignedTransaction.ts +133 -0
  554. package/src/lifecycle/SubmitConfig.ts +77 -0
  555. package/src/lifecycle/index.ts +12 -0
  556. package/src/wallet/Connection.ts +323 -0
  557. package/src/wallet/Features.ts +114 -0
  558. package/src/wallet/Wallet.ts +550 -0
  559. package/src/wallet/index.ts +6 -0
  560. package/src/zklogin/AddressSeed.ts +130 -0
  561. package/src/zklogin/Errors.ts +27 -0
  562. package/src/zklogin/Jwt.ts +186 -0
  563. package/src/zklogin/Nonce.ts +46 -0
  564. package/src/zklogin/Poseidon.ts +62 -0
  565. package/src/zklogin/PublicIdentifier.ts +111 -0
  566. package/src/zklogin/Signature.ts +88 -0
  567. package/src/zklogin/ZkLogin.ts +145 -0
  568. package/src/zklogin/ZkLoginAddress.ts +72 -0
  569. package/src/zklogin/ZkLoginVerifier.ts +37 -0
  570. package/src/zklogin/ZkLoginVerifierGrpc.ts +66 -0
  571. package/src/zklogin/index.ts +16 -0
  572. package/src/zklogin/internal/parse.ts +30 -0
  573. package/src/zklogin/internal/poseidon.ts +47 -0
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Multisig for `@unconfirmed/effect-sui`.
3
+ *
4
+ * Composes with every other scheme instead of knowing about them:
5
+ * - `scheme` verifies each member through the registry it is handed, so a
6
+ * 2-of-3 of Ed25519 + passkey + Ledger verifies exactly when those schemes
7
+ * are installed, and is a typed `UnsupportedScheme` otherwise.
8
+ * - `signer` combines any `Signer`s (in-memory, hardware, remote, wallet) into
9
+ * one `Signer`, which then works anywhere a `Signer` does (`Tx.run`, ...).
10
+ *
11
+ * const pk = yield* MultiSig.publicKey({ members: [{ publicKey: a.publicKey, weight: 1 }, ...], threshold: 2 })
12
+ * const signer = yield* MultiSig.signer(pk, [a, b])
13
+ */
14
+ import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
15
+ import * as Address from "./Address.ts"
16
+ import * as Hash from "./Hash.ts"
17
+ import * as SignatureScheme from "./SignatureScheme.ts"
18
+ import * as Signer from "./Signer.ts"
19
+ import * as Effect from "effect/Effect"
20
+ import * as Result from "effect/Result"
21
+ import * as Schema from "effect/Schema"
22
+ import * as Bytes from "@unconfirmed/effect-bcs/Bytes"
23
+
24
+ export const FLAG = 0x03
25
+ const MAX_MEMBERS = 10
26
+
27
+ // -----------------------------------------------------------------------------
28
+ // BCS (variant order is Sui's: validators hash it)
29
+ // -----------------------------------------------------------------------------
30
+
31
+ /** Member schemes by flag, in the `PublicKey` / `CompressedSignature` enum order. */
32
+ const VARIANTS = [
33
+ { flag: 0x00, name: "ED25519", pk: Bcs.bytes(32), pkLength: 32, sig: Bcs.bytes(64), sigLength: 64 },
34
+ { flag: 0x01, name: "Secp256k1", pk: Bcs.bytes(33), pkLength: 33, sig: Bcs.bytes(64), sigLength: 64 },
35
+ { flag: 0x02, name: "Secp256r1", pk: Bcs.bytes(33), pkLength: 33, sig: Bcs.bytes(64), sigLength: 64 },
36
+ { flag: 0x05, name: "ZkLogin", pk: Bcs.byteVector, pkLength: undefined, sig: Bcs.byteVector, sigLength: undefined },
37
+ { flag: 0x06, name: "Passkey", pk: Bcs.bytes(33), pkLength: 33, sig: Bcs.byteVector, sigLength: undefined },
38
+ { flag: 0x07, name: "MLDSA65", pk: Bcs.bytes(1952), pkLength: 1952, sig: Bcs.bytes(3309), sigLength: 3309 }
39
+ ] as const
40
+
41
+ const byFlag = new Map<number, (typeof VARIANTS)[number]>(VARIANTS.map((v) => [v.flag, v]))
42
+ const byName = new Map<string, (typeof VARIANTS)[number]>(VARIANTS.map((v) => [v.name, v]))
43
+
44
+ const PublicKeyBcs = Bcs.enum(Object.fromEntries(VARIANTS.map((v) => [v.name, v.pk])) as Record<string, Schema.Top>)
45
+ const CompressedSignatureBcs = Bcs.enum(
46
+ Object.fromEntries(VARIANTS.map((v) => [v.name, v.sig])) as Record<string, Schema.Top>
47
+ )
48
+
49
+ export const MultiSigPublicKeyBcs = Bcs.struct({
50
+ pkMap: Bcs.vector(Bcs.struct({ pubKey: PublicKeyBcs, weight: Bcs.u8 })),
51
+ threshold: Bcs.u16
52
+ })
53
+
54
+ export const MultiSigBcs = Bcs.struct({
55
+ sigs: Bcs.vector(CompressedSignatureBcs),
56
+ bitmap: Bcs.u16,
57
+ multisigPk: MultiSigPublicKeyBcs
58
+ })
59
+
60
+ // -----------------------------------------------------------------------------
61
+ // Public key
62
+ // -----------------------------------------------------------------------------
63
+
64
+ export interface Member {
65
+ readonly publicKey: SignatureScheme.PublicKey
66
+ readonly weight: number
67
+ }
68
+
69
+ /** A member set and threshold, as given to `publicKey`. */
70
+ export interface MultiSigPublicKeyInput {
71
+ readonly members: ReadonlyArray<Member>
72
+ readonly threshold: number
73
+ }
74
+
75
+ declare const Validated: unique symbol
76
+
77
+ /**
78
+ * A member set and threshold that `publicKey` validated. Only a validated key
79
+ * has an `address`: an invalid one (a member key of the wrong length, say)
80
+ * would name an address no encodable multisig hashes to.
81
+ */
82
+ export interface MultiSigPublicKey extends MultiSigPublicKeyInput {
83
+ readonly [Validated]: true
84
+ }
85
+
86
+ export class InvalidMultiSig extends Schema.TaggedError<InvalidMultiSig>()("InvalidMultiSig", {
87
+ reason: Schema.String
88
+ }) {
89
+ override get message(): string {
90
+ return this.reason
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Why a member's key bytes can't be what its flag says, or `undefined`. A
96
+ * zkLogin identifier is `len(iss) || iss || seed` with a 1 to 32-byte seed
97
+ * (32 padded, shorter for legacy accounts).
98
+ */
99
+ const keyProblem = (v: (typeof VARIANTS)[number], bytes: Uint8Array): string | undefined => {
100
+ if (v.pkLength !== undefined) {
101
+ return bytes.length === v.pkLength ? undefined : `${v.name} key must be ${v.pkLength} bytes, got ${bytes.length}`
102
+ }
103
+ const issLength = bytes[0]
104
+ if (issLength === undefined || issLength === 0) return "zkLogin identifier has no issuer"
105
+ const seed = bytes.length - 1 - issLength
106
+ return seed >= 1 && seed <= 32 ? undefined : "zkLogin identifier must be len(iss) || iss || a 1 to 32-byte seed"
107
+ }
108
+
109
+ /** Validate a member set and threshold, synchronously: a `Result` instead of an `Effect`. */
110
+ export const publicKeyResult = (input: MultiSigPublicKeyInput): Result.Result<MultiSigPublicKey, InvalidMultiSig> => {
111
+ const fail = (reason: string) => Result.fail(new InvalidMultiSig({ reason }))
112
+ const { members, threshold } = input
113
+ if (members.length === 0 || members.length > MAX_MEMBERS) return fail(`1 to ${MAX_MEMBERS} members, got ${members.length}`)
114
+ if (!Number.isInteger(threshold) || threshold < 1 || threshold > 0xffff) return fail(`invalid threshold ${threshold}`)
115
+ let total = 0
116
+ for (const [i, m] of members.entries()) {
117
+ const variant = byFlag.get(m.publicKey.flag)
118
+ if (!variant) return fail(`member ${i}: flag ${m.publicKey.flag} cannot be a multisig member`)
119
+ const problem = keyProblem(variant, m.publicKey.bytes)
120
+ if (problem) return fail(`member ${i}: ${problem}`)
121
+ if (!Number.isInteger(m.weight) || m.weight < 1 || m.weight > 255) return fail(`member ${i}: invalid weight ${m.weight}`)
122
+ if (members.slice(0, i).some((o) => o.publicKey.flag === m.publicKey.flag && Bytes.equal(o.publicKey.bytes, m.publicKey.bytes))) {
123
+ return fail(`member ${i}: duplicate public key`)
124
+ }
125
+ total += m.weight
126
+ }
127
+ if (threshold > total) return fail(`threshold ${threshold} exceeds total weight ${total}`)
128
+ return Result.succeed(input as MultiSigPublicKey)
129
+ }
130
+
131
+ /** Validate a member set and threshold. */
132
+ export const publicKey = (input: MultiSigPublicKeyInput): Effect.Effect<MultiSigPublicKey, InvalidMultiSig> =>
133
+ Effect.fromResult(publicKeyResult(input))
134
+
135
+ const toBcs = (pk: MultiSigPublicKey): typeof MultiSigPublicKeyBcs.Type => ({
136
+ pkMap: pk.members.map((m) => ({ pubKey: { _tag: byFlag.get(m.publicKey.flag)!.name, value: m.publicKey.bytes } as any, weight: m.weight })),
137
+ threshold: pk.threshold
138
+ })
139
+
140
+ const fromBcs = (b: typeof MultiSigPublicKeyBcs.Type): MultiSigPublicKeyInput => ({
141
+ members: b.pkMap.map((m) => {
142
+ const pub = m.pubKey as unknown as { _tag: string; value: Uint8Array }
143
+ return { publicKey: { flag: byName.get(pub._tag)!.flag, bytes: pub.value }, weight: m.weight }
144
+ }),
145
+ threshold: b.threshold
146
+ })
147
+
148
+ /** `blake2b256(0x03 || threshold:u16le || (flag || pk || weight)*)`. */
149
+ export const address = (pk: MultiSigPublicKey): Address.Address => addressOf(pk)
150
+
151
+ const addressOf = (pk: MultiSigPublicKeyInput): Address.Address => {
152
+ const parts: Array<number> = [FLAG, pk.threshold & 0xff, pk.threshold >> 8]
153
+ for (const m of pk.members) parts.push(...SignatureScheme.toSuiBytes(m.publicKey), m.weight)
154
+ return Address.fromBytes(Hash.blake2b256(Uint8Array.from(parts)))
155
+ }
156
+
157
+ /** The multisig as a `PublicKey` (flag 0x03, BCS `MultiSigPublicKey`). */
158
+ export const toPublicKey = (pk: MultiSigPublicKey): SignatureScheme.PublicKey => ({
159
+ flag: FLAG,
160
+ bytes: Bcs.encodeSync(MultiSigPublicKeyBcs)(toBcs(pk))
161
+ })
162
+
163
+ // -----------------------------------------------------------------------------
164
+ // Verification
165
+ // -----------------------------------------------------------------------------
166
+
167
+ const indices = (bitmap: number) => Array.from({ length: 16 }, (_, i) => i).filter((i) => (bitmap & (1 << i)) !== 0)
168
+
169
+ const invalid = (reason: string) => new SignatureScheme.InvalidSignature({ scheme: "MultiSig", reason })
170
+
171
+ export const scheme: SignatureScheme.SignatureScheme = {
172
+ name: "MultiSig",
173
+ flag: FLAG,
174
+ // Throws on bytes that aren't a BCS `MultiSigPublicKey`: the core's `address` hook can't fail (review SIGN-15).
175
+ // The registry only asks for keys a verification answered, which always decode.
176
+ address: (bytes) => addressOf(fromBcs(Bcs.decodeSync(MultiSigPublicKeyBcs)(bytes))),
177
+ verify: (body, intentMessage, registry) =>
178
+ Effect.gen(function*() {
179
+ const parsed = Bcs.decode(MultiSigBcs)(body)
180
+ if (Result.isFailure(parsed)) return yield* invalid(`malformed: ${parsed.failure.message}`)
181
+ const { sigs, bitmap, multisigPk } = parsed.success
182
+ const pk = fromBcs(multisigPk)
183
+ // Validators reject what `publicKey` rejects (threshold 0, zero weights, duplicates, > 10 members).
184
+ const valid = publicKeyResult(pk)
185
+ if (Result.isFailure(valid)) return yield* invalid(`invalid multisig public key: ${valid.failure.reason}`)
186
+ const signers = indices(bitmap)
187
+ // Stricter than validators on purpose. Sui's `verify_claims` zips signatures with bitmap indices
188
+ // (`zip_debug_eq`: a fatal error in debug builds, a silent truncation in release), and `@mysten/sui`
189
+ // takes the i-th set bit per signature, so both accept extra bits. A bitmap naming members that
190
+ // didn't sign is never produced by `combine` / `signer` (ours, Sui's or Mysten's); we refuse it.
191
+ if (signers.length !== sigs.length) return yield* invalid("bitmap does not match the signature count")
192
+ let weight = 0
193
+ for (const [i, memberIndex] of signers.entries()) {
194
+ const member = pk.members[memberIndex]
195
+ if (!member) return yield* invalid(`bitmap names member ${memberIndex}, which does not exist`)
196
+ const memberScheme = yield* registry.get(member.publicKey.flag)
197
+ if (!memberScheme.verifyMember) return yield* invalid(`${memberScheme.name} cannot verify as a multisig member`)
198
+ const sig = (sigs[i] as unknown as { value: Uint8Array }).value
199
+ yield* memberScheme.verifyMember(member.publicKey.bytes, sig, intentMessage, registry)
200
+ weight += member.weight
201
+ }
202
+ if (weight < pk.threshold) return yield* invalid(`weight ${weight} is below threshold ${pk.threshold}`)
203
+ return { flag: FLAG, bytes: Bcs.encodeSync(MultiSigPublicKeyBcs)(multisigPk) }
204
+ })
205
+ }
206
+
207
+ // -----------------------------------------------------------------------------
208
+ // Signing
209
+ // -----------------------------------------------------------------------------
210
+
211
+ /**
212
+ * A member's serialized signature (`flag || body`) reduced to the compressed
213
+ * form multisig stores: the bare signature for fixed-size schemes, and the
214
+ * whole serialized signature, flag included, for zkLogin and passkey (as Sui
215
+ * and `@mysten/sui` do).
216
+ */
217
+ const compress = (serialized: Uint8Array): Effect.Effect<{ flag: number; signature: Uint8Array }, InvalidMultiSig> => {
218
+ const flag = serialized[0]
219
+ const v = flag === undefined ? undefined : byFlag.get(flag)
220
+ if (flag === undefined || !v) return Effect.fail(new InvalidMultiSig({ reason: `flag ${flag} cannot be a multisig member` }))
221
+ return Effect.succeed({ flag, signature: v.sigLength === undefined ? serialized.slice() : serialized.slice(1, 1 + v.sigLength) })
222
+ }
223
+
224
+ const assemble = (pk: MultiSigPublicKey, parts: ReadonlyArray<{ index: number; flag: number; signature: Uint8Array }>) => {
225
+ const sorted = [...parts].sort((a, b) => a.index - b.index)
226
+ const body = Bcs.encodeSync(MultiSigBcs)({
227
+ sigs: sorted.map((p) => ({ _tag: byFlag.get(p.flag)!.name, value: p.signature }) as any),
228
+ bitmap: sorted.reduce((b, p) => b | (1 << p.index), 0),
229
+ multisigPk: toBcs(pk)
230
+ })
231
+ const out = new Uint8Array(1 + body.length)
232
+ out[0] = FLAG
233
+ out.set(body, 1)
234
+ return out
235
+ }
236
+
237
+ /** A partial signature for `combine`, optionally naming the member that made it. */
238
+ export type PartialSignature =
239
+ | Uint8Array
240
+ | { readonly signature: Uint8Array; readonly publicKey: SignatureScheme.PublicKey }
241
+
242
+ /**
243
+ * Combine signatures that members produced separately (multi-party flows).
244
+ * A bare single-key signature (Ed25519, Secp256k1/r1, ML-DSA-65) is matched by
245
+ * the public key it embeds. zkLogin and passkey signatures don't carry a key in
246
+ * that form, so pass them as `{ signature, publicKey }` naming their member.
247
+ */
248
+ export const combine = (
249
+ pk: MultiSigPublicKey,
250
+ signatures: ReadonlyArray<PartialSignature>
251
+ ): Effect.Effect<Uint8Array, InvalidMultiSig> =>
252
+ Effect.flatMap(publicKey(pk), (pk) => combineValid(pk, signatures))
253
+
254
+ const combineValid = (pk: MultiSigPublicKey, signatures: ReadonlyArray<PartialSignature>) =>
255
+ Effect.forEach(signatures, (entry) =>
256
+ Effect.gen(function*() {
257
+ const serialized = entry instanceof Uint8Array ? entry : entry.signature
258
+ const { flag, signature } = yield* compress(serialized)
259
+ let claimed: SignatureScheme.PublicKey
260
+ if (entry instanceof Uint8Array) {
261
+ if (byFlag.get(flag)!.sigLength === undefined) {
262
+ return yield* new InvalidMultiSig({ reason: `a ${byFlag.get(flag)!.name} signature must name its member: pass { signature, publicKey }` })
263
+ }
264
+ claimed = { flag, bytes: serialized.subarray(1 + signature.length) }
265
+ } else {
266
+ claimed = entry.publicKey
267
+ if (claimed.flag !== flag) return yield* new InvalidMultiSig({ reason: "signature scheme does not match the named member" })
268
+ }
269
+ const index = pk.members.findIndex((m) => m.publicKey.flag === flag && Bytes.equal(m.publicKey.bytes, claimed.bytes))
270
+ if (index < 0) return yield* new InvalidMultiSig({ reason: "signature from a key that is not a member" })
271
+ return { index, flag, signature }
272
+ })).pipe(
273
+ Effect.flatMap((parts) => {
274
+ if (new Set(parts.map((p) => p.index)).size !== parts.length) {
275
+ return Effect.fail(new InvalidMultiSig({ reason: "two signatures from the same member" }))
276
+ }
277
+ // Below the threshold the result could never verify: refuse it here, as `signer` does.
278
+ const weight = parts.reduce((w, p) => w + pk.members[p.index]!.weight, 0)
279
+ return weight < pk.threshold
280
+ ? Effect.fail(new InvalidMultiSig({ reason: `signatures' weight ${weight} is below threshold ${pk.threshold}` }))
281
+ : Effect.succeed(assemble(pk, parts))
282
+ })
283
+ )
284
+
285
+ /** One `Signer` from member signers. They sign concurrently. */
286
+ export const signer = (
287
+ pk: MultiSigPublicKey,
288
+ signers: ReadonlyArray<Signer.Signer>
289
+ ): Effect.Effect<Signer.Signer, InvalidMultiSig> =>
290
+ // Re-validated: the brand is only a type, and a forged key would make the BCS encoding throw.
291
+ Effect.flatMap(publicKey(pk), (valid) => signerUnsuspended(valid, signers))
292
+
293
+ const signerUnsuspended = (
294
+ pk: MultiSigPublicKey,
295
+ signers: ReadonlyArray<Signer.Signer>
296
+ ): Effect.Effect<Signer.Signer, InvalidMultiSig> => {
297
+ const members = signers.map((s) =>
298
+ pk.members.findIndex((m) => m.publicKey.flag === s.publicKey.flag && Bytes.equal(m.publicKey.bytes, s.publicKey.bytes))
299
+ )
300
+ if (members.some((i) => i < 0)) return Effect.fail(new InvalidMultiSig({ reason: "a signer is not a member" }))
301
+ if (new Set(members).size !== members.length) return Effect.fail(new InvalidMultiSig({ reason: "duplicate signer" }))
302
+ const weight = members.reduce((w, i) => w + pk.members[i]!.weight, 0)
303
+ if (weight < pk.threshold) {
304
+ return Effect.fail(new InvalidMultiSig({ reason: `signers' weight ${weight} is below threshold ${pk.threshold}` }))
305
+ }
306
+ return Effect.succeed({
307
+ address: address(pk),
308
+ publicKey: toPublicKey(pk),
309
+ sign: (intentMessage) =>
310
+ Effect.forEach(signers, (s, i) =>
311
+ s.sign(intentMessage).pipe(
312
+ Effect.flatMap((serialized) =>
313
+ compress(serialized).pipe(
314
+ Effect.mapError((e) => new Signer.SigningError({ reason: "failed", message: e.reason }))
315
+ )
316
+ ),
317
+ Effect.map((c) => ({ index: members[i]!, ...c }))
318
+ ), { concurrency: "unbounded" }).pipe(Effect.map((parts) => assemble(pk, parts)))
319
+ })
320
+ }
package/src/Objects.ts ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Reading objects. `get` is batched and deduplicated by every implementation,
3
+ * so call it freely and concurrently.
4
+ */
5
+ import * as Context from "effect/Context"
6
+ import * as Effect from "effect/Effect"
7
+ import * as Result from "effect/Result"
8
+ import * as Schema from "effect/Schema"
9
+ import * as Stream from "effect/Stream"
10
+ import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
11
+ import type { Address } from "./Address.ts"
12
+ import type { RpcError } from "./RpcError.ts"
13
+ import type { ObjectDigest, ObjectRef } from "./TransactionData.ts"
14
+ import * as TypeTag from "./TypeTag.ts"
15
+
16
+ export type Owner =
17
+ | { readonly _tag: "AddressOwner"; readonly address: Address }
18
+ | { readonly _tag: "ObjectOwner"; readonly address: Address }
19
+ | { readonly _tag: "Shared"; readonly initialSharedVersion: bigint }
20
+ | { readonly _tag: "Immutable" }
21
+ | { readonly _tag: "ConsensusAddressOwner"; readonly startVersion: bigint; readonly address: Address }
22
+ /** An owner kind newer than this SDK (the transport's raw kind number). */
23
+ | { readonly _tag: "Unknown"; readonly kind: number }
24
+
25
+ export interface SuiObject {
26
+ readonly objectId: Address
27
+ readonly version: bigint
28
+ readonly digest: ObjectDigest
29
+ readonly owner: Owner
30
+ /** The full type, `0x2::coin::Coin<0x2::sui::SUI>` (or `package`). */
31
+ readonly type: string
32
+ /** The Move struct's BCS bytes. Empty for packages. */
33
+ readonly contents: Uint8Array
34
+ /** The digest of the transaction that last wrote this version; `undefined` when the transport doesn't report it. */
35
+ readonly previousTransaction: string | undefined
36
+ }
37
+
38
+ export const refOf = (o: SuiObject): ObjectRef => ({ objectId: o.objectId, version: o.version, digest: o.digest })
39
+
40
+ export class ObjectNotFound extends /* @__PURE__ */ Schema.TaggedError<ObjectNotFound>()("ObjectNotFound", {
41
+ objectId: Schema.String
42
+ }) {
43
+ override get message(): string {
44
+ return `object ${this.objectId} not found`
45
+ }
46
+ }
47
+
48
+ export class ObjectDecodeError extends /* @__PURE__ */ Schema.TaggedError<ObjectDecodeError>()("ObjectDecodeError", {
49
+ objectId: Schema.String,
50
+ type: Schema.String,
51
+ issue: Schema.String
52
+ }) {
53
+ override get message(): string {
54
+ return `cannot decode object ${this.objectId} as ${this.type}: ${this.issue}`
55
+ }
56
+ }
57
+
58
+ /** Decode an object's contents with a BCS schema. */
59
+ export const decode = <T, E>(schema: Schema.Codec<T, E>) => {
60
+ const run = Bcs.decode(schema)
61
+ return (o: SuiObject): Effect.Effect<T, ObjectDecodeError> =>
62
+ Result.match(run(o.contents), {
63
+ onSuccess: Effect.succeed,
64
+ onFailure: (e) => Effect.fail(new ObjectDecodeError({ objectId: o.objectId, type: o.type, issue: e.message }))
65
+ })
66
+ }
67
+
68
+ export interface ListOwnedOptions {
69
+ /** A struct type filter; a type without type arguments matches every instantiation. */
70
+ readonly type?: string
71
+ readonly pageSize?: number
72
+ }
73
+
74
+ export class Objects extends /* @__PURE__ */ Context.Service<Objects, {
75
+ readonly get: (objectId: Address) => Effect.Effect<SuiObject, ObjectNotFound | RpcError>
76
+ readonly listOwned: (owner: Address, options?: ListOwnedOptions) => Stream.Stream<SuiObject, RpcError>
77
+ }>()("@unconfirmed/effect-sui/Objects") {}
78
+
79
+ /** The object's type is not the one asked for. */
80
+ export class ObjectTypeMismatch extends /* @__PURE__ */ Schema.TaggedError<ObjectTypeMismatch>()("ObjectTypeMismatch", {
81
+ objectId: Schema.String,
82
+ expected: Schema.String,
83
+ actual: Schema.String
84
+ }) {
85
+ override get message(): string {
86
+ return `object ${this.objectId} is a ${this.actual}, not a ${this.expected}`
87
+ }
88
+ }
89
+
90
+ export interface GetAsOptions {
91
+ /**
92
+ * The object's expected type, checked before decoding. A struct type without
93
+ * type arguments (`0x2::coin::Coin`) matches every instantiation; with them,
94
+ * only that one. Addresses may be short (`0x2`). Without it, the contents are
95
+ * decoded whatever the type: a schema that happens to parse other bytes
96
+ * decodes them, so give it unless the object id is trusted.
97
+ */
98
+ readonly type?: string
99
+ }
100
+
101
+ /** Fetch, check the type (`options.type`) and decode in one step. */
102
+ export const getAs = <T, E>(objectId: Address, schema: Schema.Codec<T, E>, options?: GetAsOptions) => {
103
+ const d = decode(schema)
104
+ const expected = options?.type
105
+ return Effect.flatMap(Effect.service(Objects), (o) =>
106
+ Effect.flatMap(o.get(objectId), (object): Effect.Effect<T, ObjectDecodeError | ObjectTypeMismatch> =>
107
+ expected === undefined || TypeTag.matchesPath(expected, object.type)
108
+ ? d(object)
109
+ : Effect.fail(
110
+ new ObjectTypeMismatch({ objectId: object.objectId, expected: TypeTag.normalizePath(expected), actual: object.type })
111
+ )))
112
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Move package metadata. Packages are immutable, so implementations cache.
3
+ */
4
+ import * as Context from "effect/Context"
5
+ import type * as Effect from "effect/Effect"
6
+ import * as Schema from "effect/Schema"
7
+ import type { Address } from "./Address.ts"
8
+ import type { RpcError } from "./RpcError.ts"
9
+
10
+ export type Reference = "Immutable" | "Mutable" | "Value"
11
+
12
+ export interface Parameter {
13
+ readonly reference: Reference
14
+ /** For datatypes, the type name without type arguments (`0x…2::tx_context::TxContext`). */
15
+ readonly typeName: string | undefined
16
+ /**
17
+ * For a generic datatype, its type arguments as type strings
18
+ * (`Coin<0x…::wal::WAL>` gives `["0x…::wal::WAL"]`). Absent when the
19
+ * datatype has none, or when an argument is a function type parameter.
20
+ */
21
+ readonly typeArguments?: ReadonlyArray<string>
22
+ }
23
+
24
+ export interface MoveFunction {
25
+ readonly isEntry: boolean
26
+ readonly parameters: ReadonlyArray<Parameter>
27
+ }
28
+
29
+ export interface FunctionTarget {
30
+ readonly package: Address
31
+ readonly module: string
32
+ readonly function: string
33
+ }
34
+
35
+ /** No object at the id. (An object that isn't a package is `RpcError` `INVALID_ARGUMENT`.) */
36
+ export class PackageNotFound extends /* @__PURE__ */ Schema.TaggedError<PackageNotFound>()("PackageNotFound", {
37
+ packageId: Schema.String
38
+ }) {
39
+ override get message(): string {
40
+ return `package ${this.packageId} not found`
41
+ }
42
+ }
43
+
44
+ export class Packages extends /* @__PURE__ */ Context.Service<Packages, {
45
+ readonly getFunction: (target: FunctionTarget) => Effect.Effect<MoveFunction, RpcError>
46
+ /**
47
+ * The package's stored modules: name -> compiled module bytes.
48
+ * Read from the object, so it works when the publish transaction is pruned.
49
+ * Not cached (a package can be hundreds of KB).
50
+ */
51
+ readonly getModules: (packageId: Address) => Effect.Effect<ReadonlyMap<string, Uint8Array>, PackageNotFound | RpcError>
52
+ }>()("@unconfirmed/effect-sui/Packages") {}
package/src/Passkey.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Passkeys for `@unconfirmed/effect-sui`.
3
+ *
4
+ * import * as Passkey from "@unconfirmed/effect-sui/Passkey"
5
+ * SignatureSchemes.layer(Ed25519.scheme, Passkey.scheme)
6
+ * const signer = yield* Passkey.create(Passkey.browserProvider("My app"))
7
+ */
8
+ export * from "./internal/passkey/BrowserProvider.ts"
9
+ export * from "./internal/passkey/Passkey.ts"
10
+ export * from "./internal/passkey/SoftwareProvider.ts"
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Private keys as the Sui CLI and wallets exchange them.
3
+ *
4
+ * - `suiprivkey1…`: bech32 of `flag || 32-byte secret`, what `sui keytool
5
+ * export` prints and wallets import.
6
+ * - `sui.keystore`: the CLI's key file, a JSON array of base64 `flag || secret`.
7
+ *
8
+ * The core can't build a signer for a scheme it doesn't ship (secp256k1/r1 and
9
+ * ML-DSA-65 are plugins), so decoding answers bytes and the scheme package
10
+ * makes the signer:
11
+ *
12
+ * const { flag, secretKey } = yield* PrivateKey.decode(s)
13
+ * const signer = yield* Secp256k1.fromSecretKey(secretKey)
14
+ *
15
+ * // or insist on one scheme:
16
+ * const signer = yield* Ed25519.fromSecretKey((yield* PrivateKey.decode(s, Ed25519.FLAG)).secretKey)
17
+ *
18
+ * // and back:
19
+ * const secretKey = yield* Ed25519.generateSecretKey
20
+ * const exported = yield* PrivateKey.encode({ flag: Ed25519.FLAG, secretKey })
21
+ */
22
+ import { base64, bech32 } from "@scure/base"
23
+ import * as Effect from "effect/Effect"
24
+ import { InvalidKey } from "./Signer.ts"
25
+
26
+ export const PREFIX = "suiprivkey"
27
+ export const SECRET_KEY_SIZE = 32
28
+
29
+ /** The schemes that have exportable private keys, by the flag Sui gives them. */
30
+ export const Scheme = {
31
+ ED25519: 0x00,
32
+ Secp256k1: 0x01,
33
+ Secp256r1: 0x02,
34
+ MLDSA65: 0x07
35
+ } as const
36
+ export type Scheme = keyof typeof Scheme
37
+
38
+ const NAMES: Record<number, Scheme> = { 0x00: "ED25519", 0x01: "Secp256k1", 0x02: "Secp256r1", 0x07: "MLDSA65" }
39
+
40
+ /**
41
+ * A decoded key: the scheme's flag and name, and its 32-byte secret (the
42
+ * Ed25519 seed, the secp scalar, the ML-DSA-65 keygen seed).
43
+ */
44
+ export interface PrivateKey {
45
+ readonly flag: number
46
+ readonly scheme: Scheme
47
+ readonly secretKey: Uint8Array
48
+ }
49
+
50
+ const flagHex = (flag: number) => `0x${flag.toString(16).padStart(2, "0")}`
51
+
52
+ /** `flag || secret`, validated. */
53
+ const parse = (format: string, raw: Uint8Array, expected: number | undefined): Effect.Effect<PrivateKey, InvalidKey> => {
54
+ const flag = raw[0]
55
+ const fail = (scheme: string, reason: string) => Effect.fail(new InvalidKey({ scheme, reason }))
56
+ if (flag === undefined) return fail(format, "empty key")
57
+ const scheme = NAMES[flag]
58
+ if (!scheme) return fail(format, `flag ${flagHex(flag)} is not a scheme with private keys`)
59
+ if (expected !== undefined && flag !== expected) {
60
+ return fail(NAMES[expected] ?? format, `expected a ${NAMES[expected] ?? flagHex(expected)} key, got ${scheme}`)
61
+ }
62
+ if (raw.length !== 1 + SECRET_KEY_SIZE) return fail(scheme, `expected a ${SECRET_KEY_SIZE}-byte secret, got ${raw.length - 1} bytes`)
63
+ return Effect.succeed({ flag, scheme, secretKey: raw.slice(1) })
64
+ }
65
+
66
+ const serialize = (key: { readonly flag: number; readonly secretKey: Uint8Array }): Effect.Effect<Uint8Array, InvalidKey> => {
67
+ const scheme = NAMES[key.flag]
68
+ if (!scheme) return Effect.fail(new InvalidKey({ scheme: PREFIX, reason: `flag ${flagHex(key.flag)} is not a scheme with private keys` }))
69
+ if (key.secretKey.length !== SECRET_KEY_SIZE) {
70
+ return Effect.fail(new InvalidKey({ scheme, reason: `expected a ${SECRET_KEY_SIZE}-byte secret, got ${key.secretKey.length} bytes` }))
71
+ }
72
+ const out = new Uint8Array(1 + SECRET_KEY_SIZE)
73
+ out[0] = key.flag
74
+ out.set(key.secretKey, 1)
75
+ return Effect.succeed(out)
76
+ }
77
+
78
+ // -----------------------------------------------------------------------------
79
+ // suiprivkey
80
+ // -----------------------------------------------------------------------------
81
+
82
+ /**
83
+ * Decode a `suiprivkey1…` string. With `expectedFlag`, a key of another scheme
84
+ * is an `InvalidKey` too.
85
+ */
86
+ export const decode = (encoded: string, expectedFlag?: number): Effect.Effect<PrivateKey, InvalidKey> =>
87
+ Effect.suspend(() => {
88
+ let decoded: { prefix: string; words: Array<number> }
89
+ let raw: Uint8Array
90
+ try {
91
+ decoded = bech32.decode(encoded.trim())
92
+ raw = bech32.fromWords(decoded.words)
93
+ } catch (e) {
94
+ return Effect.fail(new InvalidKey({ scheme: PREFIX, reason: "not a valid bech32 string (bad checksum, prefix or characters)" }))
95
+ }
96
+ if (decoded.prefix !== PREFIX) {
97
+ return Effect.fail(new InvalidKey({ scheme: PREFIX, reason: `expected prefix "${PREFIX}", got "${decoded.prefix}"` }))
98
+ }
99
+ return parse(PREFIX, raw, expectedFlag)
100
+ })
101
+
102
+ /** Encode a secret as `suiprivkey1…`. */
103
+ export const encode = (key: { readonly flag: number; readonly secretKey: Uint8Array }): Effect.Effect<string, InvalidKey> =>
104
+ Effect.map(serialize(key), (raw) => bech32.encode(PREFIX, bech32.toWords(raw)))
105
+
106
+ // -----------------------------------------------------------------------------
107
+ // sui.keystore
108
+ // -----------------------------------------------------------------------------
109
+
110
+ const KEYSTORE = "sui.keystore"
111
+
112
+ /** Parse the contents of a Sui CLI `sui.keystore` file (a JSON array of base64 `flag || secret`). */
113
+ export const decodeKeystore = (json: string): Effect.Effect<ReadonlyArray<PrivateKey>, InvalidKey> =>
114
+ Effect.suspend(() => {
115
+ let entries: unknown
116
+ try {
117
+ entries = JSON.parse(json)
118
+ } catch (e) {
119
+ return Effect.fail(new InvalidKey({ scheme: KEYSTORE, reason: "not JSON" }))
120
+ }
121
+ if (!Array.isArray(entries)) return Effect.fail(new InvalidKey({ scheme: KEYSTORE, reason: "expected a JSON array" }))
122
+ return Effect.forEach(entries, (entry: unknown, i) => {
123
+ if (typeof entry !== "string") return Effect.fail(new InvalidKey({ scheme: KEYSTORE, reason: `entry ${i}: expected a base64 string` }))
124
+ let raw: Uint8Array
125
+ try {
126
+ raw = base64.decode(entry)
127
+ } catch {
128
+ return Effect.fail(new InvalidKey({ scheme: KEYSTORE, reason: `entry ${i}: not base64` }))
129
+ }
130
+ return Effect.mapError(parse(KEYSTORE, raw, undefined), (e) => new InvalidKey({ scheme: e.scheme, reason: `entry ${i}: ${e.reason}` }))
131
+ })
132
+ })
133
+
134
+ /** Serialize keys as a `sui.keystore` file the Sui CLI reads. */
135
+ export const encodeKeystore = (
136
+ keys: ReadonlyArray<{ readonly flag: number; readonly secretKey: Uint8Array }>
137
+ ): Effect.Effect<string, InvalidKey> =>
138
+ Effect.map(Effect.forEach(keys, serialize), (raws) => JSON.stringify(raws.map((r) => base64.encode(r)), null, 2))