@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,550 @@
1
+ /**
2
+ * Wallet-standard Sui wallets as signers.
3
+ *
4
+ * const wallet = yield* Wallet.find("Sui Wallet")
5
+ * yield* Wallet.connect(wallet)
6
+ * const signer = yield* Wallet.signer(wallet, { chain: "sui:testnet" })
7
+ * yield* Tx.run(recipe, { signer }) // we resolve; the wallet signs; we execute its bytes
8
+ *
9
+ * A wallet never signs intent messages, so a wallet signer is a core
10
+ * `Signer.TransactionSigner`: `signTransaction(data)` hands the wallet our
11
+ * resolved transaction as Mysten transaction JSON (`sui:signTransaction`) and
12
+ * answers the bytes the wallet actually signed. The wallet may re-resolve and
13
+ * change them; `Tx.execute` submits exactly what it signed.
14
+ *
15
+ * Also: `signUnresolved` (the wallet resolves a Draft itself),
16
+ * `signAndExecuteTransaction` (the wallet submits) and `signPersonalMessage`.
17
+ *
18
+ * Failures are typed: a missing feature is `UnsupportedFeature`, a user
19
+ * rejection is `SigningError` with reason `"rejected"`, a connect refusal is
20
+ * `ConnectionError` with reason `"rejected"`. A failed
21
+ * `signAndExecuteTransaction` the wallet may have submitted is
22
+ * `ExecutionUnconfirmed`, never a signing failure.
23
+ *
24
+ * Only accounts on a `sui:` chain are used (multi-chain wallets also report
25
+ * EVM or Solana accounts).
26
+ */
27
+ import { base64 } from "@scure/base"
28
+ import { getWallets } from "@wallet-standard/app"
29
+ import type { IdentifierString, Wallet as StandardWallet, WalletAccount } from "@wallet-standard/base"
30
+ import * as Effect from "effect/Effect"
31
+ import * as Queue from "effect/Queue"
32
+ import * as Result from "effect/Result"
33
+ import type * as Scope from "effect/Scope"
34
+ import * as Schema from "effect/Schema"
35
+ import * as Stream from "effect/Stream"
36
+ import * as Address from "../Address.ts"
37
+ import * as Hash from "../Hash.ts"
38
+ import * as Signer from "../Signer.ts"
39
+ import type * as T from "../TransactionData.ts"
40
+ import * as TransactionJson from "../TransactionJson.ts"
41
+ import * as Features from "./Features.ts"
42
+
43
+ export type Wallet = StandardWallet
44
+
45
+ // -----------------------------------------------------------------------------
46
+ // Errors
47
+ // -----------------------------------------------------------------------------
48
+
49
+ export class WalletNotFound extends Schema.TaggedError<WalletNotFound>()("WalletNotFound", {
50
+ name: Schema.String
51
+ }) {
52
+ override get message(): string {
53
+ return `wallet ${this.name} not found`
54
+ }
55
+ }
56
+
57
+ /** The wallet doesn't implement a feature this operation needs. */
58
+ export class UnsupportedFeature extends Schema.TaggedError<UnsupportedFeature>()("UnsupportedFeature", {
59
+ wallet: Schema.String,
60
+ feature: Schema.String
61
+ }) {
62
+ override get message(): string {
63
+ return `${this.wallet} does not support ${this.feature}`
64
+ }
65
+ }
66
+
67
+ /** Neither the account nor the wallet lists this chain. */
68
+ export class UnsupportedChain extends Schema.TaggedError<UnsupportedChain>()("UnsupportedChain", {
69
+ wallet: Schema.String,
70
+ chain: Schema.String
71
+ }) {
72
+ override get message(): string {
73
+ return `${this.wallet} does not support ${this.chain}`
74
+ }
75
+ }
76
+
77
+ /** No such account is connected (connect first, or name an account the wallet authorized). */
78
+ export class AccountNotFound extends Schema.TaggedError<AccountNotFound>()("AccountNotFound", {
79
+ wallet: Schema.String,
80
+ address: Schema.optionalKey(Schema.String)
81
+ }) {
82
+ override get message(): string {
83
+ return this.address === undefined ? `no account connected to ${this.wallet}` : `account ${this.address} not connected to ${this.wallet}`
84
+ }
85
+ }
86
+
87
+ export class ConnectionError extends Schema.TaggedError<ConnectionError>()("ConnectionError", {
88
+ wallet: Schema.String,
89
+ reason: Schema.Literals(["rejected", "failed"]),
90
+ message: Schema.String
91
+ }) {}
92
+
93
+ /**
94
+ * `sui:signAndExecuteTransaction` failed or answered something that can't be
95
+ * trusted, after the wallet may have submitted: its promise rejected with
96
+ * anything but a coded user refusal (a timeout waiting for effects, an RPC
97
+ * error), or it returned missing or undecodable fields, or a digest that isn't
98
+ * the returned bytes'. The transaction may have executed: check `digest` (when
99
+ * the wallet reported one) on chain before retrying.
100
+ */
101
+ export class ExecutionUnconfirmed extends Schema.TaggedError<ExecutionUnconfirmed>()("ExecutionUnconfirmed", {
102
+ wallet: Schema.String,
103
+ digest: Schema.optionalKey(Schema.String),
104
+ message: Schema.String
105
+ }) {}
106
+
107
+ // -----------------------------------------------------------------------------
108
+ // Failure mapping
109
+ // -----------------------------------------------------------------------------
110
+
111
+ /** `WalletStandardError` `WALLET_STANDARD_ERROR__USER__REQUEST_REJECTED`. */
112
+ const USER_REJECTED = 4001000
113
+ /** EIP-1193 `userRejectedRequest`, which some wallets reuse. */
114
+ const EIP1193_REJECTED = 4001
115
+ /**
116
+ * A user's refusal in words, with the user as the one refusing: "User
117
+ * rejected the request", "The user denied the signature", "Rejected by (the)
118
+ * user", "User closed the modal". Validator and RPC failures that merely
119
+ * contain a refusal word ("Transaction rejected by validators", "Request
120
+ * denied: rate limit exceeded", "The user's gas coin was rejected") don't match.
121
+ */
122
+ const USER_WORDING =
123
+ /\buser (has )?(rejected|denied|declined|cancell?ed|closed|refused)\b|\b(rejected|denied|declined|cancell?ed|refused) by (the )?user\b/i
124
+ /** An error class named for the user's refusal (`UserRejectedRequestError`), not any "...RejectedError". */
125
+ const REJECTION_NAME = /user.?(reject|denied|declin|cancel|refus)/i
126
+
127
+ /** A coded refusal: wallet-standard 4001000 or EIP-1193 4001. */
128
+ const isCodedRejection = (e: unknown): boolean => {
129
+ if (typeof e !== "object" || e === null) return false
130
+ const x = e as { readonly code?: unknown; readonly context?: { readonly __code?: unknown } }
131
+ return x.context?.__code === USER_REJECTED || x.code === EIP1193_REJECTED || x.code === USER_REJECTED
132
+ }
133
+
134
+ /** A string property of an error-like value, read without throwing (getters, proxies). */
135
+ const field = (e: unknown, key: "name" | "message"): string | undefined => {
136
+ try {
137
+ const v = (e as Record<string, unknown>)[key]
138
+ return typeof v === "string" ? v : undefined
139
+ } catch {
140
+ return undefined
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Did the user refuse? A coded refusal (wallet-standard 4001000, EIP-1193
146
+ * 4001) first; then a refusal's name or wording with the user as its agent.
147
+ */
148
+ export const isRejection = (e: unknown): boolean => {
149
+ if (typeof e === "string") return USER_WORDING.test(e)
150
+ if (typeof e !== "object" || e === null) return false
151
+ if (isCodedRejection(e)) return true
152
+ return REJECTION_NAME.test(field(e, "name") ?? "") || USER_WORDING.test(field(e, "message") ?? "")
153
+ }
154
+
155
+ /** A failure as text. Total: a circular or `bigint`-holding value, or a cross-realm error, still describes. */
156
+ const describe = (e: unknown): string => {
157
+ if (typeof e === "string") return e
158
+ const message = typeof e === "object" && e !== null ? field(e, "message") : undefined
159
+ if (message !== undefined) return message
160
+ try {
161
+ const json = JSON.stringify(e)
162
+ if (json !== undefined && json !== "{}") return json
163
+ } catch {
164
+ // circular, or a bigint inside: fall through
165
+ }
166
+ try {
167
+ return String(e)
168
+ } catch {
169
+ return "unknown error"
170
+ }
171
+ }
172
+
173
+ const signingError = (wallet: Wallet, operation: string) => (e: unknown) =>
174
+ new Signer.SigningError({
175
+ reason: isRejection(e) ? "rejected" : "failed",
176
+ message: `${wallet.name} ${operation}: ${describe(e)}`
177
+ })
178
+
179
+ const decodeBase64 = (wallet: Wallet, what: string, s: unknown) =>
180
+ Effect.try({
181
+ try: () => {
182
+ if (typeof s !== "string") throw new Error("not a string")
183
+ return base64.decode(s)
184
+ },
185
+ catch: () => new Signer.SigningError({ reason: "failed", message: `${wallet.name} returned ${what} that is not base64` })
186
+ })
187
+
188
+ // -----------------------------------------------------------------------------
189
+ // Discovery
190
+ // -----------------------------------------------------------------------------
191
+
192
+ const features = (wallet: Wallet) => wallet.features as Features.SuiWalletFeatures
193
+
194
+ /** Lists a `sui:` chain. */
195
+ export const isSuiWallet = (wallet: Wallet): boolean => wallet.chains.some((c) => c.startsWith("sui:"))
196
+
197
+ /** Does the wallet implement `feature`? */
198
+ export const hasFeature = (wallet: Wallet, feature: IdentifierString): boolean => feature in wallet.features
199
+
200
+ /** The Sui wallets registered so far. */
201
+ export const wallets: Effect.Effect<ReadonlyArray<Wallet>> = Effect.sync(() => getWallets().get().filter(isSuiWallet))
202
+
203
+ /** A registered Sui wallet by name. */
204
+ export const find = (name: string): Effect.Effect<Wallet, WalletNotFound> =>
205
+ Effect.flatMap(wallets, (ws) => {
206
+ const w = ws.find((x) => x.name === name)
207
+ return w ? Effect.succeed(w) : Effect.fail(new WalletNotFound({ name }))
208
+ })
209
+
210
+ /** The Sui wallets now, then again whenever a wallet registers or unregisters. */
211
+ export const changes: Stream.Stream<ReadonlyArray<Wallet>> = Stream.callback<ReadonlyArray<Wallet>>((queue) =>
212
+ Effect.gen(function*() {
213
+ const api = getWallets()
214
+ const emit = () => Queue.offerUnsafe(queue, api.get().filter(isSuiWallet))
215
+ yield* Effect.acquireRelease(
216
+ Effect.sync(() => [api.on("register", emit), api.on("unregister", emit)]),
217
+ (offs) => Effect.sync(() => offs.forEach((off) => off()))
218
+ )
219
+ emit()
220
+ })
221
+ )
222
+
223
+ /** Register wallets (injected or in-process ones) for the life of the scope. */
224
+ export const register = (...ws: ReadonlyArray<Wallet>): Effect.Effect<void, never, Scope.Scope> =>
225
+ Effect.asVoid(Effect.acquireRelease(Effect.sync(() => getWallets().register(...ws)), (unregister) => Effect.sync(unregister)))
226
+
227
+ // -----------------------------------------------------------------------------
228
+ // Connection
229
+ // -----------------------------------------------------------------------------
230
+
231
+ export interface Account {
232
+ readonly address: Address.Address
233
+ /** As the wallet reports it (raw key bytes, no scheme flag). */
234
+ readonly publicKey: Uint8Array
235
+ readonly chains: ReadonlyArray<IdentifierString>
236
+ readonly label: string | undefined
237
+ /** The wallet-standard account, which every `sui:*` call names. */
238
+ readonly account: WalletAccount
239
+ }
240
+
241
+ const decodeAddress = Schema.decodeUnknownResult(Address.Strict)
242
+
243
+ /**
244
+ * A Sui account: it lists a `sui:` chain (or lists none, and then the wallet's
245
+ * chains apply) and has a full 32-byte address. A multi-chain wallet's EVM or
246
+ * Solana account is skipped, rather than padded into a "valid" Sui address.
247
+ */
248
+ const toAccount = (a: WalletAccount): Account | undefined => {
249
+ try {
250
+ const chains = Array.isArray(a.chains) ? a.chains : []
251
+ if (chains.length > 0 && !chains.some((c) => typeof c === "string" && c.startsWith("sui:"))) return undefined
252
+ const address = decodeAddress(a.address)
253
+ if (Result.isFailure(address)) return undefined
254
+ return { address: address.success, publicKey: new Uint8Array(a.publicKey), chains, label: a.label, account: a }
255
+ } catch {
256
+ return undefined
257
+ }
258
+ }
259
+
260
+ const toAccounts = (list: unknown): ReadonlyArray<Account> =>
261
+ Array.isArray(list) ? list.flatMap((a: WalletAccount) => toAccount(a) ?? []) : []
262
+
263
+ /** The Sui accounts the wallet has authorized (on a `sui:` chain, with a valid Sui address). */
264
+ export const accounts = (wallet: Wallet): ReadonlyArray<Account> => {
265
+ try {
266
+ return toAccounts(wallet.accounts)
267
+ } catch {
268
+ return []
269
+ }
270
+ }
271
+
272
+ /** `standard:connect`: ask for access; answer the authorized accounts. `silent` connects only if already authorized. */
273
+ export const connect = (
274
+ wallet: Wallet,
275
+ options?: { readonly silent?: boolean }
276
+ ): Effect.Effect<ReadonlyArray<Account>, UnsupportedFeature | ConnectionError> => {
277
+ const feature = features(wallet)[Features.StandardConnect]
278
+ if (!feature) return Effect.fail(new UnsupportedFeature({ wallet: wallet.name, feature: Features.StandardConnect }))
279
+ return Effect.tryPromise({
280
+ try: () => feature.connect(options?.silent !== undefined ? { silent: options.silent } : undefined),
281
+ catch: (e) =>
282
+ new ConnectionError({ wallet: wallet.name, reason: isRejection(e) ? "rejected" : "failed", message: describe(e) })
283
+ }).pipe(
284
+ Effect.flatMap((r) =>
285
+ typeof r === "object" && r !== null && Array.isArray(r.accounts)
286
+ ? Effect.succeed(toAccounts(r.accounts))
287
+ : Effect.fail(new ConnectionError({ wallet: wallet.name, reason: "failed", message: `${wallet.name} answered connect without accounts` }))
288
+ )
289
+ )
290
+ }
291
+
292
+ /** `standard:disconnect`, when the wallet has it (a no-op otherwise). */
293
+ export const disconnect = (wallet: Wallet): Effect.Effect<void, ConnectionError> => {
294
+ const feature = features(wallet)[Features.StandardDisconnect]
295
+ if (!feature) return Effect.void
296
+ return Effect.tryPromise({
297
+ try: () => feature.disconnect(),
298
+ catch: (e) => new ConnectionError({ wallet: wallet.name, reason: "failed", message: describe(e) })
299
+ })
300
+ }
301
+
302
+ /** The authorized accounts now, then whenever the wallet reports a change of accounts or chains (`standard:events`). */
303
+ export const accountChanges = (wallet: Wallet): Stream.Stream<ReadonlyArray<Account>, UnsupportedFeature> => {
304
+ const feature = features(wallet)[Features.StandardEvents]
305
+ if (!feature) return Stream.fail(new UnsupportedFeature({ wallet: wallet.name, feature: Features.StandardEvents }))
306
+ return Stream.callback<ReadonlyArray<Account>, UnsupportedFeature>((queue) =>
307
+ Effect.gen(function*() {
308
+ yield* Effect.acquireRelease(
309
+ Effect.sync(() =>
310
+ feature.on("change", (p) => {
311
+ if (p.accounts || p.chains) Queue.offerUnsafe(queue, accounts(wallet))
312
+ })
313
+ ),
314
+ (off) => Effect.sync(off)
315
+ )
316
+ Queue.offerUnsafe(queue, accounts(wallet))
317
+ })
318
+ )
319
+ }
320
+
321
+ // -----------------------------------------------------------------------------
322
+ // Signing
323
+ // -----------------------------------------------------------------------------
324
+
325
+ export interface Target {
326
+ readonly chain: Features.SuiChain
327
+ /** Which authorized account (default: the first on `chain`). */
328
+ readonly account?: Address.Address | string
329
+ }
330
+
331
+ /** The chains an account acts on: its own, or the wallet's when it lists none. */
332
+ const chainsOf = (wallet: Wallet, a: Account) => (a.chains.length > 0 ? a.chains : wallet.chains)
333
+
334
+ const pick = (wallet: Wallet, address: string | undefined, chain?: Features.SuiChain): Effect.Effect<Account, AccountNotFound> =>
335
+ Effect.suspend(() => {
336
+ let wanted: Address.Address | undefined
337
+ if (address !== undefined) {
338
+ try {
339
+ wanted = Address.normalize(address)
340
+ } catch {
341
+ return Effect.fail(new AccountNotFound({ wallet: wallet.name, address }))
342
+ }
343
+ }
344
+ const all = accounts(wallet)
345
+ const a = wanted !== undefined
346
+ ? all.find((x) => x.address === wanted)
347
+ : (chain !== undefined && all.find((x) => chainsOf(wallet, x).includes(chain))) || all[0]
348
+ return a ? Effect.succeed(a) : Effect.fail(new AccountNotFound({ wallet: wallet.name, ...(wanted && { address: wanted }) }))
349
+ })
350
+
351
+ /** Pick an authorized account that can act on `chain`. */
352
+ export const account = (wallet: Wallet, target: Target): Effect.Effect<Account, AccountNotFound | UnsupportedChain> =>
353
+ Effect.flatMap(pick(wallet, target.account, target.chain), (a) => {
354
+ return chainsOf(wallet, a).includes(target.chain)
355
+ ? Effect.succeed(a)
356
+ : Effect.fail(new UnsupportedChain({ wallet: wallet.name, chain: target.chain }))
357
+ })
358
+
359
+ /** What `sui:signTransaction` hands the wallet: Mysten's `toJSON()` contract. */
360
+ const transactionInput = (json: string): Features.TransactionInput => ({ toJSON: () => Promise.resolve(json) })
361
+
362
+ const withSender = (tx: T.TransactionData | TransactionJson.Unresolved, sender: Address.Address) =>
363
+ (tx as T.TransactionData)._tag === "V1" || (tx as TransactionJson.Unresolved).sender !== undefined
364
+ ? tx
365
+ : { ...(tx as TransactionJson.Unresolved), sender }
366
+
367
+ const signedOf = (wallet: Wallet, out: Features.SignedTransaction) =>
368
+ Effect.all({
369
+ bytes: decodeBase64(wallet, "transaction bytes", out?.bytes),
370
+ signature: decodeBase64(wallet, "a signature", out?.signature)
371
+ })
372
+
373
+ const callSignTransaction = (wallet: Wallet, a: Account, chain: Features.SuiChain, json: string) => {
374
+ const feature = features(wallet)[Features.SuiSignTransaction]
375
+ if (!feature) return Effect.fail(new UnsupportedFeature({ wallet: wallet.name, feature: Features.SuiSignTransaction }))
376
+ return Effect.tryPromise({
377
+ try: (signal) => feature.signTransaction({ transaction: transactionInput(json), account: a.account, chain, signal }),
378
+ catch: signingError(wallet, Features.SuiSignTransaction)
379
+ }).pipe(Effect.flatMap((out) => signedOf(wallet, out)))
380
+ }
381
+
382
+ /**
383
+ * `sui:signTransaction` over either form: resolved `TransactionData`, or an
384
+ * `Unresolved` draft the wallet resolves (sender defaults to the account).
385
+ * Answers the bytes the wallet signed, which may differ from what it was given.
386
+ */
387
+ export const signTransaction = (
388
+ wallet: Wallet,
389
+ target: Target,
390
+ tx: T.TransactionData | TransactionJson.Unresolved
391
+ ): Effect.Effect<
392
+ Signer.Signed,
393
+ Signer.SigningError | UnsupportedFeature | UnsupportedChain | AccountNotFound | TransactionJson.UnsupportedTransactionJson
394
+ > =>
395
+ Effect.gen(function*() {
396
+ const a = yield* account(wallet, target)
397
+ const json = yield* TransactionJson.encode(withSender(tx, a.address))
398
+ return yield* callSignTransaction(wallet, a, target.chain, json)
399
+ })
400
+
401
+ export interface Executed extends Signer.Signed {
402
+ readonly digest: string
403
+ /** BCS `TransactionEffects`, as the wallet returned them. */
404
+ readonly effects: Uint8Array
405
+ }
406
+
407
+ /**
408
+ * `sui:signAndExecuteTransaction`: the wallet signs and submits. The digest
409
+ * it reports must be the digest of the bytes it returns. For our `Effects`,
410
+ * follow with `Transactions.waitFor(digest)`.
411
+ */
412
+ export const signAndExecuteTransaction = (
413
+ wallet: Wallet,
414
+ target: Target,
415
+ tx: T.TransactionData | TransactionJson.Unresolved
416
+ ): Effect.Effect<
417
+ Executed,
418
+ | Signer.SigningError
419
+ | ExecutionUnconfirmed
420
+ | UnsupportedFeature
421
+ | UnsupportedChain
422
+ | AccountNotFound
423
+ | TransactionJson.UnsupportedTransactionJson
424
+ > =>
425
+ Effect.gen(function*() {
426
+ const feature = features(wallet)[Features.SuiSignAndExecuteTransaction]
427
+ if (!feature) return yield* new UnsupportedFeature({ wallet: wallet.name, feature: Features.SuiSignAndExecuteTransaction })
428
+ const a = yield* account(wallet, target)
429
+ const json = yield* TransactionJson.encode(withSender(tx, a.address))
430
+ const out = yield* Effect.tryPromise({
431
+ try: (signal) =>
432
+ feature.signAndExecuteTransaction({ transaction: transactionInput(json), account: a.account, chain: target.chain, signal }),
433
+ // Only a coded refusal proves nothing was submitted. Anything else (a timeout waiting for
434
+ // effects, an RPC error, a refusal in words only) may come after the wallet submitted.
435
+ catch: (e): Signer.SigningError | ExecutionUnconfirmed =>
436
+ isCodedRejection(e)
437
+ ? signingError(wallet, Features.SuiSignAndExecuteTransaction)(e)
438
+ : new ExecutionUnconfirmed({
439
+ wallet: wallet.name,
440
+ message: `${wallet.name} ${Features.SuiSignAndExecuteTransaction} failed, possibly after submitting: ${describe(e)}`
441
+ })
442
+ })
443
+ // From here the wallet has submitted: a bad answer is not a signing failure.
444
+ const reported = typeof out?.digest === "string" ? out.digest : undefined
445
+ const unconfirmed = (message: string) =>
446
+ new ExecutionUnconfirmed({ wallet: wallet.name, ...(reported !== undefined && { digest: reported }), message })
447
+ const signed = yield* Effect.mapError(signedOf(wallet, out), (e) => unconfirmed(e.message))
448
+ const effects = typeof out.effects !== "string"
449
+ ? yield* unconfirmed(`${wallet.name} returned no effects`)
450
+ : out.effects === ""
451
+ ? new Uint8Array()
452
+ : yield* Effect.mapError(decodeBase64(wallet, "effects", out.effects), (e) => unconfirmed(e.message))
453
+ const digest = Hash.transactionDigest(signed.bytes)
454
+ if (reported !== digest) {
455
+ return yield* unconfirmed(`${wallet.name} reported digest ${reported} for bytes whose digest is ${digest}`)
456
+ }
457
+ return { ...signed, digest, effects }
458
+ })
459
+
460
+ /** `sui:signPersonalMessage`. */
461
+ export const signPersonalMessage = (
462
+ wallet: Wallet,
463
+ target: { readonly account?: Address.Address | string; readonly chain?: Features.SuiChain },
464
+ message: Uint8Array
465
+ ): Effect.Effect<Signer.Signed, Signer.SigningError | UnsupportedFeature | UnsupportedChain | AccountNotFound> =>
466
+ Effect.gen(function*() {
467
+ const feature = features(wallet)[Features.SuiSignPersonalMessage]
468
+ if (!feature) return yield* new UnsupportedFeature({ wallet: wallet.name, feature: Features.SuiSignPersonalMessage })
469
+ const a = target.chain === undefined
470
+ ? yield* pick(wallet, target.account)
471
+ : yield* account(wallet, { ...target, chain: target.chain })
472
+ const out = yield* Effect.tryPromise({
473
+ try: () =>
474
+ feature.signPersonalMessage({ message, account: a.account, ...(target.chain !== undefined && { chain: target.chain }) }),
475
+ catch: signingError(wallet, Features.SuiSignPersonalMessage)
476
+ })
477
+ const signed = yield* signedOf(wallet, out)
478
+ if (signed.bytes.length !== message.length || !signed.bytes.every((b, i) => b === message[i])) {
479
+ return yield* new Signer.SigningError({ reason: "failed", message: `${wallet.name} signed a different message than the one requested` })
480
+ }
481
+ return signed
482
+ })
483
+
484
+ // -----------------------------------------------------------------------------
485
+ // The signer
486
+ // -----------------------------------------------------------------------------
487
+
488
+ /**
489
+ * One wallet account on one chain. A `Signer.TransactionSigner`, so `Tx.run`
490
+ * and `Tx.execute` take it like any signer.
491
+ */
492
+ export interface WalletSigner extends Signer.TransactionSigner {
493
+ readonly wallet: Wallet
494
+ readonly chain: Features.SuiChain
495
+ readonly account: Account
496
+ /** `sui:signTransaction` over our resolved transaction; answers what the wallet signed. */
497
+ readonly signTransaction: (data: T.TransactionData) => Effect.Effect<Signer.Signed, Signer.SigningError>
498
+ /** `sui:signTransaction` over a Draft the wallet resolves itself. */
499
+ readonly signUnresolved: (
500
+ tx: TransactionJson.Unresolved
501
+ ) => Effect.Effect<Signer.Signed, Signer.SigningError | TransactionJson.UnsupportedTransactionJson>
502
+ readonly signAndExecuteTransaction: (
503
+ tx: T.TransactionData | TransactionJson.Unresolved
504
+ ) => Effect.Effect<Executed, Signer.SigningError | ExecutionUnconfirmed | UnsupportedFeature | TransactionJson.UnsupportedTransactionJson>
505
+ readonly signPersonalMessage: (message: Uint8Array) => Effect.Effect<Signer.Signed, Signer.SigningError | UnsupportedFeature>
506
+ }
507
+
508
+ /** After the account was checked, a lookup failure means the wallet changed under us. */
509
+ const gone = (wallet: Wallet) => (e: AccountNotFound | UnsupportedChain) =>
510
+ Effect.fail(new Signer.SigningError({ reason: "unavailable", message: `${wallet.name}: ${e._tag} (the wallet's accounts changed)` }))
511
+
512
+ /**
513
+ * A signer for a connected wallet account on `chain`. Needs `sui:signTransaction`
514
+ * (`UnsupportedFeature` otherwise); wallets without it can still use
515
+ * `signAndExecuteTransaction` and `signPersonalMessage` directly.
516
+ */
517
+ export const signer = (
518
+ wallet: Wallet,
519
+ target: Target
520
+ ): Effect.Effect<WalletSigner, UnsupportedFeature | AccountNotFound | UnsupportedChain> =>
521
+ Effect.gen(function*() {
522
+ if (!hasFeature(wallet, Features.SuiSignTransaction)) {
523
+ return yield* new UnsupportedFeature({ wallet: wallet.name, feature: Features.SuiSignTransaction })
524
+ }
525
+ const a = yield* account(wallet, target)
526
+ const pinned: Target = { chain: target.chain, account: a.address }
527
+ const unavailable = (e: UnsupportedFeature) =>
528
+ Effect.fail(new Signer.SigningError({ reason: "unavailable", message: `${e.wallet} no longer offers ${e.feature}` }))
529
+ const sign = (tx: T.TransactionData | TransactionJson.Unresolved) =>
530
+ signTransaction(wallet, pinned, tx).pipe(
531
+ Effect.catchTags({ UnsupportedFeature: unavailable, AccountNotFound: gone(wallet), UnsupportedChain: gone(wallet) })
532
+ )
533
+ return {
534
+ address: a.address,
535
+ wallet,
536
+ chain: target.chain,
537
+ account: a,
538
+ signTransaction: (data) =>
539
+ sign(data).pipe(Effect.catchTag("UnsupportedTransactionJson", (e) => Effect.die(e))), // resolved data always encodes
540
+ signUnresolved: sign,
541
+ signAndExecuteTransaction: (tx) =>
542
+ signAndExecuteTransaction(wallet, pinned, tx).pipe(
543
+ Effect.catchTags({ AccountNotFound: gone(wallet), UnsupportedChain: gone(wallet) })
544
+ ),
545
+ signPersonalMessage: (message) =>
546
+ signPersonalMessage(wallet, pinned, message).pipe(
547
+ Effect.catchTags({ AccountNotFound: gone(wallet), UnsupportedChain: gone(wallet) })
548
+ )
549
+ } satisfies WalletSigner
550
+ })
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `@unconfirmed/effect-sui/wallet`: wallet-standard Sui wallets as signers.
3
+ */
4
+ export * as Features from "./Features.ts"
5
+ export * as Wallet from "./Wallet.ts"
6
+ export * as Connection from "./Connection.ts"
@@ -0,0 +1,130 @@
1
+ /**
2
+ * The address seed: `poseidon(hash(claimName), hash(claimValue), hash(aud), poseidon(salt))`.
3
+ * It is what the proof commits to and, with the issuer, what the address is
4
+ * derived from.
5
+ *
6
+ * With the default lengths this ships only the Poseidon arities the circuit
7
+ * uses (1, 2, 4, 5). Other lengths need other arities: pass
8
+ * `poseidon: Poseidon.hashUnsafe`, which loads all of them.
9
+ */
10
+ import * as Effect from "effect/Effect"
11
+ import { poseidon1 } from "poseidon-lite/poseidon1"
12
+ import { poseidon2 } from "poseidon-lite/poseidon2"
13
+ import { poseidon4 } from "poseidon-lite/poseidon4"
14
+ import { poseidon5 } from "poseidon-lite/poseidon5"
15
+ import { InvalidZkLoginInput, reasonOf } from "./Errors.ts"
16
+ import * as Core from "./internal/poseidon.ts"
17
+
18
+ export const MAX_KEY_CLAIM_NAME_LENGTH = 32
19
+ export const MAX_KEY_CLAIM_VALUE_LENGTH = 115
20
+ export const MAX_AUD_VALUE_LENGTH = 145
21
+ const PACK_WIDTH = 248
22
+
23
+ /**
24
+ * Poseidon over the arities the default lengths need: the salt (1), a 32-char
25
+ * claim name (2 chunks), a 115-char value (4), a 145-char `aud` (5), the seed (4).
26
+ */
27
+ const circuitPoseidon: Core.Hasher = Core.make({ 1: poseidon1, 2: poseidon2, 4: poseidon4, 5: poseidon5 })
28
+
29
+ /** Split into chunks of `size`; when uneven, the *first* chunk is the short one. */
30
+ const chunkFromEnd = <T>(array: ReadonlyArray<T>, size: number): Array<Array<T>> => {
31
+ const out: Array<Array<T>> = []
32
+ for (let end = array.length; end > 0; end -= size) out.unshift(array.slice(Math.max(0, end - size), end))
33
+ return out
34
+ }
35
+
36
+ const bytesBEToBigInt = (bytes: ReadonlyArray<number>): bigint =>
37
+ bytes.length === 0 ? 0n : BigInt("0x" + bytes.map((b) => b.toString(16).padStart(2, "0")).join(""))
38
+
39
+ /**
40
+ * @internal Each character is one byte, as in Sui's `hash_ascii_str_to_field`,
41
+ * which refuses a character wider than 8 bits. (`@mysten/sui` doesn't: a code
42
+ * unit above 0xFF prints as 3-4 hex digits and shifts every byte after it.)
43
+ */
44
+ export const hashASCIIStrToFieldUnsafe = (str: string, maxSize: number, poseidon: Core.Hasher = circuitPoseidon): bigint => {
45
+ if (str.length > maxSize) throw new Error(`String ${str} is longer than ${maxSize} chars`)
46
+ const padded = str.padEnd(maxSize, String.fromCharCode(0)).split("").map((c) => c.charCodeAt(0))
47
+ const wide = padded.findIndex((c) => c > 0xff)
48
+ if (wide !== -1) throw new Error(`character ${wide} (code ${padded[wide]}) does not fit in a byte`)
49
+ return poseidon(chunkFromEnd(padded, PACK_WIDTH / 8).map(bytesBEToBigInt))
50
+ }
51
+
52
+ /** Hash an ASCII string (zero-padded to `maxSize`) to a field element. */
53
+ export const hashASCIIStrToField = (
54
+ str: string,
55
+ maxSize: number,
56
+ options?: { readonly poseidon?: Core.Hasher }
57
+ ): Effect.Effect<bigint, InvalidZkLoginInput> =>
58
+ Effect.try({
59
+ try: () => hashASCIIStrToFieldUnsafe(str, maxSize, options?.poseidon),
60
+ catch: (e) => new InvalidZkLoginInput({ reason: reasonOf(e) })
61
+ })
62
+
63
+ /**
64
+ * The circuit hashes the raw JWT bytes of a claim. A claim whose decoded form
65
+ * reveals a JSON escape (`"`, `\`, a control character) or a non-ASCII
66
+ * character (raw UTF-8 or `\u` escaped in the token, while the hash here takes
67
+ * one byte per character) would derive an address the proof can't sign for.
68
+ * `@mysten/sui` derives one anyway; we refuse.
69
+ */
70
+ const assertCircuitSafe = (value: string, label: string) => {
71
+ for (let i = 0; i < value.length; i++) {
72
+ const c = value.charCodeAt(i)
73
+ if (c < 0x20 || c === 0x22 || c === 0x5c) {
74
+ throw new Error(
75
+ `zkLogin ${label} contains a JSON-escaped character (code ${c}); the circuit hashes raw JWT bytes, ` +
76
+ `so claim values with escapes are not supported`
77
+ )
78
+ }
79
+ if (c > 0x7f) {
80
+ throw new Error(
81
+ `zkLogin ${label} contains a non-ASCII character (code ${c}); the circuit hashes raw JWT bytes, ` +
82
+ `so the address can't be derived locally (use the prover's addressSeed with ZkLoginAddress.fromSeed)`
83
+ )
84
+ }
85
+ }
86
+ }
87
+
88
+ export interface AddressSeedOptions {
89
+ readonly maxNameLength?: number
90
+ readonly maxValueLength?: number
91
+ readonly maxAudLength?: number
92
+ /**
93
+ * The Poseidon hash to use. The default loads only the arities the default
94
+ * lengths need; pass `Poseidon.hashUnsafe` with lengths that need others.
95
+ */
96
+ readonly poseidon?: Core.Hasher
97
+ }
98
+
99
+ /** @internal */
100
+ export const genAddressSeedUnsafe = (
101
+ salt: string | bigint,
102
+ name: string,
103
+ value: string,
104
+ aud: string,
105
+ options?: AddressSeedOptions
106
+ ): bigint => {
107
+ assertCircuitSafe(name, "key claim name")
108
+ assertCircuitSafe(value, "key claim value")
109
+ assertCircuitSafe(aud, "aud")
110
+ const poseidon = options?.poseidon ?? circuitPoseidon
111
+ return poseidon([
112
+ hashASCIIStrToFieldUnsafe(name, options?.maxNameLength ?? MAX_KEY_CLAIM_NAME_LENGTH, poseidon),
113
+ hashASCIIStrToFieldUnsafe(value, options?.maxValueLength ?? MAX_KEY_CLAIM_VALUE_LENGTH, poseidon),
114
+ hashASCIIStrToFieldUnsafe(aud, options?.maxAudLength ?? MAX_AUD_VALUE_LENGTH, poseidon),
115
+ poseidon([BigInt(salt)])
116
+ ])
117
+ }
118
+
119
+ /** `genAddressSeed(salt, "sub", sub, aud)`. */
120
+ export const genAddressSeed = (
121
+ salt: string | bigint,
122
+ name: string,
123
+ value: string,
124
+ aud: string,
125
+ options?: AddressSeedOptions
126
+ ): Effect.Effect<bigint, InvalidZkLoginInput> =>
127
+ Effect.try({
128
+ try: () => genAddressSeedUnsafe(salt, name, value, aud, options),
129
+ catch: (e) => new InvalidZkLoginInput({ reason: reasonOf(e) })
130
+ })