@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,130 @@
1
+ /**
2
+ * The outcome taxonomy. Every failure of a submission is on exactly one axis:
3
+ *
4
+ * applied on chain; gas was charged ExecutionFailed
5
+ * not_applied provably never applied, never will NotApplied, JournalError
6
+ * (only raised before these bytes were ever sent)
7
+ * unknown may or may not have applied SubmissionUnknown,
8
+ * DigestMismatch, and anything outside this taxonomy
9
+ *
10
+ * Only `not_applied` is safe to retry by rebuilding. `unknown` carries the
11
+ * signed bytes: re-send them (`Lifecycle.resubmit`) or reconcile them later;
12
+ * identical bytes land at most once.
13
+ */
14
+ import * as Tx from "../Tx.ts"
15
+ import type { Effects } from "../Transactions.ts"
16
+ import * as Schema from "effect/Schema"
17
+ import { SignedTransaction } from "./SignedTransaction.ts"
18
+
19
+ /** The transaction reached the chain and Move aborted. Gas was charged. (Core's error, reused.) */
20
+ export const ExecutionFailed = Tx.ExecutionFailed
21
+ export type ExecutionFailed = Tx.ExecutionFailed
22
+
23
+ export const NotAppliedEvidence = Schema.Literals(["expired", "inputConsumed", "refused"])
24
+ export type NotAppliedEvidence = typeof NotAppliedEvidence.Type
25
+
26
+ /**
27
+ * The transaction did not apply, and the lifecycle will not send it again:
28
+ * - `expired`: its epoch window closed and it is absent, observed twice (around
29
+ * a recheck) by one `Evidence` backend whose history covers the window, with
30
+ * `Transactions` missing it too: it never applied and never will;
31
+ * - `inputConsumed`: another transaction consumed an object version these bytes
32
+ * pinned: it never applied and never will;
33
+ * - `refused`: the node refused the first send outright (`INVALID_ARGUMENT`),
34
+ * so nothing executed then. This is the node's verdict at that moment, not
35
+ * proof that the bytes can never land: some refusals are time-dependent
36
+ * (e.g. an unfunded address balance) and the node may still hold the bytes.
37
+ * It means this process will not send them again on its own
38
+ * (`Lifecycle.resubmit(..., { retryRefused: true })` does on request).
39
+ */
40
+ export class NotApplied extends Schema.TaggedError<NotApplied>()("NotApplied", {
41
+ digest: Schema.String,
42
+ evidence: NotAppliedEvidence,
43
+ message: Schema.optionalKey(Schema.String)
44
+ }) {}
45
+
46
+ /**
47
+ * The outcome is not known. `signed` (absent only when reconciling a bare
48
+ * digest) is what to re-send or reconcile later.
49
+ */
50
+ export class SubmissionUnknown extends Schema.TaggedError<SubmissionUnknown>()("SubmissionUnknown", {
51
+ digest: Schema.String,
52
+ signed: Schema.optionalKey(SignedTransaction),
53
+ reason: Schema.String
54
+ }) {
55
+ override get message(): string {
56
+ return `outcome of ${this.digest} unknown: ${this.reason}`
57
+ }
58
+ }
59
+
60
+ /**
61
+ * The journal could not be read or written. Raised only before bytes that were
62
+ * never sent go out (so `not_applied`): by `run` (bytes it signed just now) on
63
+ * any journal failure before the send, and by `submit` when the `Signed` write
64
+ * fails for bytes the journal has never seen. Once the bytes may have left — an
65
+ * earlier send, a re-send, `submit` unable to read the journal — a journal
66
+ * failure becomes `SubmissionUnknown` instead, and later writes are logged,
67
+ * never raised.
68
+ */
69
+ export class JournalError extends Schema.TaggedError<JournalError>()("JournalError", {
70
+ message: Schema.String
71
+ }) {}
72
+
73
+ /**
74
+ * A `SignedTransaction` whose `digest` is not the digest of its bytes: a
75
+ * corrupt or tampered record. Nothing was sent or concluded; what happened to
76
+ * either transaction is unknown.
77
+ */
78
+ export class DigestMismatch extends Schema.TaggedError<DigestMismatch>()("DigestMismatch", {
79
+ digest: Schema.String,
80
+ computed: Schema.String
81
+ }) {
82
+ override get message(): string {
83
+ return `digest ${this.digest} does not match the bytes (${this.computed})`
84
+ }
85
+ }
86
+
87
+ export type Outcome = "applied" | "not_applied" | "unknown"
88
+
89
+ /**
90
+ * Where a failure sits. Within the taxonomy: `ExecutionFailed` is `applied`,
91
+ * `NotApplied` and `JournalError` are `not_applied`, `SubmissionUnknown` and
92
+ * `DigestMismatch` are `unknown`.
93
+ *
94
+ * Every other value — a timeout around `run`, a raw `RpcError`, a defect — is
95
+ * `unknown`, because nothing says it happened before the bytes left. Pass
96
+ * `{ phase: "beforeSubmit" }` when you know it did: every error of
97
+ * `Lifecycle.run` outside the taxonomy (build, resolve, sign) is raised before
98
+ * submission, so `outcome(e, { phase: "beforeSubmit" })` is right for an error
99
+ * taken straight from `run`'s error channel, and wrong for one you added around it.
100
+ */
101
+ export const outcome = (error: unknown, options?: { readonly phase?: "beforeSubmit" }): Outcome => {
102
+ const tag = typeof error === "object" && error !== null ? (error as { readonly _tag?: unknown })._tag : undefined
103
+ switch (tag) {
104
+ case "ExecutionFailed":
105
+ return "applied"
106
+ case "NotApplied":
107
+ case "JournalError":
108
+ return "not_applied"
109
+ case "SubmissionUnknown":
110
+ case "DigestMismatch":
111
+ return "unknown"
112
+ default:
113
+ return options?.phase === "beforeSubmit" && typeof tag === "string" ? "not_applied" : "unknown"
114
+ }
115
+ }
116
+
117
+ /** Everything a submission can end in besides success. */
118
+ export type SubmitError = ExecutionFailed | NotApplied | SubmissionUnknown | JournalError | DigestMismatch
119
+
120
+ /** What one reconciled journal entry settled to. */
121
+ export type Reconciled =
122
+ | { readonly _tag: "Executed"; readonly digest: string; readonly effects: Effects }
123
+ | { readonly _tag: "ExecutionFailed"; readonly digest: string; readonly error: ExecutionFailed }
124
+ | { readonly _tag: "NotApplied"; readonly digest: string; readonly error: NotApplied }
125
+ | { readonly _tag: "SubmissionUnknown"; readonly digest: string; readonly error: SubmissionUnknown }
126
+ /**
127
+ * The journal entry could not be read (see `Journal.CorruptEntry`); `digest`
128
+ * is its key. Nothing was concluded or sent; `Journal.remove(digest)` drops it.
129
+ */
130
+ | { readonly _tag: "Corrupt"; readonly digest: string; readonly reason: string }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Per-address locks for `Lifecycle.run`.
3
+ *
4
+ * Two builds from one sender that overlap can resolve the same gas coin or
5
+ * owned object at the same version, and one of the two transactions then
6
+ * fails or equivocates. So `run` holds the sender's (and a distinct gas
7
+ * owner's) lock for every build, and keeps it through signing and submission
8
+ * when the built bytes pin a versioned object (owned or receiving input, any
9
+ * gas payment ref). Bytes that pin nothing release it after the build, so
10
+ * address-balance transactions from one sender are sent concurrently.
11
+ *
12
+ * A `Context.Reference` with an in-memory default (one semaphore per address,
13
+ * process-wide), so every `run` in the process shares it with no wiring.
14
+ * Provide `layerMemory` for an isolated set, or your own (e.g. a distributed
15
+ * lock) for several processes.
16
+ */
17
+ import * as Context from "effect/Context"
18
+ import * as Effect from "effect/Effect"
19
+ import * as Layer from "effect/Layer"
20
+ import * as Semaphore from "effect/Semaphore"
21
+
22
+ export interface SenderLockService {
23
+ /** Run `effect` holding the locks of every address (deduplicated, taken in ascending order). */
24
+ readonly withLocks: (
25
+ addresses: ReadonlyArray<string>
26
+ ) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
27
+ }
28
+
29
+ /**
30
+ * One semaphore per address, kept only while some fiber holds or waits for it
31
+ * (a count of users per address), so a long-lived process does not keep a
32
+ * lock for every sender it has ever seen.
33
+ */
34
+ export const makeMemory = (): SenderLockService & { readonly size: () => number } => {
35
+ const locks = new Map<string, { readonly semaphore: Semaphore.Semaphore; users: number }>()
36
+ const acquire = (address: string) =>
37
+ Effect.sync(() => {
38
+ let lock = locks.get(address)
39
+ if (lock === undefined) {
40
+ lock = { semaphore: Semaphore.makeUnsafe(1), users: 0 }
41
+ locks.set(address, lock)
42
+ }
43
+ lock.users++
44
+ return lock
45
+ })
46
+ const release = (address: string, lock: { users: number }) =>
47
+ Effect.sync(() => {
48
+ lock.users--
49
+ if (lock.users === 0 && locks.get(address) === lock) locks.delete(address)
50
+ })
51
+ const withLock = (address: string) => <A, E, R>(inner: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
52
+ Effect.acquireUseRelease(
53
+ acquire(address),
54
+ (lock) => lock.semaphore.withPermits(1)(inner),
55
+ (lock) => release(address, lock)
56
+ )
57
+ return {
58
+ withLocks: (addresses) => (effect) =>
59
+ // Ascending order, so two runs needing the same pair cannot deadlock.
60
+ [...new Set(addresses)].sort().reverse().reduce((inner, address) => withLock(address)(inner), effect),
61
+ size: () => locks.size
62
+ }
63
+ }
64
+
65
+ export const SenderLock = Context.Reference<SenderLockService>("@unconfirmed/effect-sui/lifecycle/SenderLock", {
66
+ defaultValue: makeMemory
67
+ })
68
+
69
+ /** A fresh, isolated set of in-memory locks. */
70
+ export const layerMemory: Layer.Layer<never> = Layer.sync(SenderLock, makeMemory)
71
+
72
+ /** No locking at all, for callers that serialise themselves. */
73
+ export const layerNone: Layer.Layer<never> = Layer.succeed(SenderLock, { withLocks: () => (effect) => effect })
@@ -0,0 +1,136 @@
1
+ /**
2
+ * A `SenderLock` over the Web Locks API (`navigator.locks`), so the tabs,
3
+ * iframes and workers of one origin serialise their submissions per sender,
4
+ * not only the fibers of one tab. `SenderLock.makeMemory` cannot see another
5
+ * tab: two tabs running for the same address could resolve the same gas coin
6
+ * or owned object and equivocate.
7
+ *
8
+ * - One exclusive lock per address, named `<prefix><address>` (default prefix
9
+ * {@link DEFAULT_PREFIX}), held for exactly the wrapped effect. Addresses are
10
+ * deduplicated and taken in ascending order, outermost first, as
11
+ * `SenderLock.makeMemory` does, so two runs needing the same pair cannot
12
+ * deadlock (in one tab or across tabs).
13
+ * - Interrupting the effect releases the lock: while waiting, the request's
14
+ * `AbortSignal` takes it out of the queue; once granted, the promise the
15
+ * lock callback returned is resolved. A grant that races the interruption
16
+ * is released at once. A tab that closes or crashes loses its locks (the
17
+ * browser releases them), so a dead tab never strands a sender.
18
+ * - Not reentrant (nor is the memory lock): don't nest `withLocks` for the
19
+ * same address in one fiber.
20
+ *
21
+ * **When Web Locks are missing** (`navigator.locks` is undefined outside a
22
+ * secure context, in old browsers, in Node/Bun; `query()` rejects in opaque
23
+ * origins), building `layer` fails with `SenderLockUnavailable`. It does not
24
+ * fall back to in-process locks on its own: a silent fallback would look the
25
+ * same as cross-tab locking and let two tabs equivocate, and the
26
+ * `SenderLockService` contract has no error channel to report it at run
27
+ * time. Opt in with `layerWith({ ifUnavailable: "memory" })` where one
28
+ * context per origin is guaranteed (server-side rendering, a single-tab
29
+ * kiosk), or provide `SenderLock.layerMemory` yourself. A lock request the
30
+ * browser rejects after the probe succeeded (a document that is no longer
31
+ * fully active) is a defect, for the same contract reason.
32
+ */
33
+ import * as Effect from "effect/Effect"
34
+ import * as Layer from "effect/Layer"
35
+ import * as Schema from "effect/Schema"
36
+ import { makeMemory, SenderLock, type SenderLockService } from "./SenderLock.ts"
37
+
38
+ export const DEFAULT_PREFIX = "@unconfirmed/effect-sui/lifecycle/sender/"
39
+
40
+ /** The Web Locks API is missing or unusable here; nothing was locked. */
41
+ export class SenderLockUnavailable extends Schema.TaggedError<SenderLockUnavailable>()("SenderLockUnavailable", {
42
+ message: Schema.String
43
+ }) {}
44
+
45
+ /** The subset of `LockManager` used here. */
46
+ export interface Locks {
47
+ readonly request: (name: string, options: LockOptions, callback: (lock: Lock | null) => Promise<void>) => Promise<void>
48
+ readonly query?: () => Promise<unknown>
49
+ }
50
+
51
+ export interface Options {
52
+ /** Lock-name prefix; the address is appended. Default {@link DEFAULT_PREFIX}. */
53
+ readonly prefix?: string
54
+ /** The `LockManager` to use instead of `navigator.locks` (tests). */
55
+ readonly locks?: Locks
56
+ /**
57
+ * What `layerWith` does without Web Locks: `"fail"` (default) fails with
58
+ * `SenderLockUnavailable`; `"memory"` falls back to `SenderLock.makeMemory`,
59
+ * which serialises only within this context.
60
+ */
61
+ readonly ifUnavailable?: "fail" | "memory"
62
+ }
63
+
64
+ /** Hold the exclusive lock `name` for `inner`. */
65
+ const withLock = (locks: Locks, name: string) => <A, E, R>(inner: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
66
+ Effect.uninterruptibleMask((restore) =>
67
+ Effect.flatMap(
68
+ restore(
69
+ Effect.callback<() => void>((resume, signal) => {
70
+ let release: (() => void) | undefined
71
+ locks.request(name, { mode: "exclusive", signal }, () =>
72
+ new Promise<void>((done) => {
73
+ let released = false
74
+ release = () => {
75
+ if (released) return
76
+ released = true
77
+ done()
78
+ }
79
+ // Interrupted between the grant and now: give it straight back.
80
+ if (signal.aborted) release()
81
+ else resume(Effect.succeed(release))
82
+ })).catch((cause: unknown) => {
83
+ if (signal.aborted) return // our own abort while queued
84
+ resume(Effect.die(cause))
85
+ })
86
+ return Effect.sync(() => release?.())
87
+ })
88
+ ),
89
+ (release) => Effect.ensuring(restore(inner), Effect.sync(release))
90
+ )
91
+ )
92
+
93
+ /** `SenderLockService` over `locks`. */
94
+ export const make = (locks: Locks, options?: { readonly prefix?: string }): SenderLockService => {
95
+ const prefix = options?.prefix ?? DEFAULT_PREFIX
96
+ return {
97
+ withLocks: (addresses) => (effect) =>
98
+ // Ascending order, outermost first, so two runs needing the same pair cannot deadlock.
99
+ [...new Set(addresses)].sort().reverse().reduce((inner, address) => withLock(locks, `${prefix}${address}`)(inner), effect)
100
+ }
101
+ }
102
+
103
+ const globalLocks = (): Locks | undefined => {
104
+ const locks = (globalThis as { navigator?: { locks?: Locks } }).navigator?.locks
105
+ return locks !== undefined && locks !== null && typeof locks.request === "function" ? locks : undefined
106
+ }
107
+
108
+ /** `SenderLock` over `navigator.locks` (or `options.locks`); see the module notes for `ifUnavailable`. */
109
+ export const layerWith = (options?: Options): Layer.Layer<never, SenderLockUnavailable> =>
110
+ Layer.effect(
111
+ SenderLock,
112
+ Effect.gen(function*() {
113
+ const locks = options?.locks ?? globalLocks()
114
+ const unavailable = (message: string) =>
115
+ options?.ifUnavailable === "memory"
116
+ ? Effect.as(Effect.logWarning(`${message}; falling back to in-process sender locks`), makeMemory())
117
+ : Effect.fail(new SenderLockUnavailable({ message }))
118
+ if (locks === undefined) {
119
+ return yield* unavailable("the Web Locks API (navigator.locks) is not available (it needs a secure context)")
120
+ }
121
+ if (typeof locks.query === "function") {
122
+ const query = locks.query.bind(locks)
123
+ const probe = yield* Effect.result(Effect.tryPromise(() => query()))
124
+ if (probe._tag === "Failure") {
125
+ const cause = probe.failure.cause
126
+ return yield* unavailable(
127
+ `the Web Locks API refused a query: ${cause instanceof Error ? `${cause.name}: ${cause.message}` : String(cause)}`
128
+ )
129
+ }
130
+ }
131
+ return make(locks, options?.prefix === undefined ? {} : { prefix: options.prefix })
132
+ })
133
+ )
134
+
135
+ /** `SenderLock` over `navigator.locks`; fails with `SenderLockUnavailable` without it. */
136
+ export const layer: Layer.Layer<never, SenderLockUnavailable> = layerWith()
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Signed bytes: the one representation of "a transaction that may be on the
3
+ * wire", shared by the journal, `SubmissionUnknown` and every lifecycle
4
+ * function. Everything else (sender, expiration, pinned objects) is read back
5
+ * out of the bytes, so what is reasoned about is what was signed.
6
+ */
7
+ import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
8
+ import * as Hash from "../Hash.ts"
9
+ import * as T from "../TransactionData.ts"
10
+ import * as Option from "effect/Option"
11
+ import * as Result from "effect/Result"
12
+ import * as Schema from "effect/Schema"
13
+
14
+ export const SignedTransaction = Schema.Struct({
15
+ /** `Hash.transactionDigest(bytes)`; identical bytes have one digest and execute at most once. */
16
+ digest: Schema.String,
17
+ bytes: Schema.Uint8ArrayFromBase64,
18
+ signatures: Schema.Array(Schema.Uint8ArrayFromBase64),
19
+ /**
20
+ * The chain id the bytes were built against, for the expiration variants that
21
+ * name none (`None`, `Epoch`). `ValidDuring` / `Validity` carry their own.
22
+ */
23
+ chain: Schema.optionalKey(Schema.String)
24
+ })
25
+ export type SignedTransaction = typeof SignedTransaction.Type
26
+
27
+ /** Bundle signed bytes; the digest is computed, never trusted from outside. */
28
+ export const make = (
29
+ bytes: Uint8Array,
30
+ signatures: ReadonlyArray<Uint8Array>,
31
+ options?: { readonly chain?: string }
32
+ ): SignedTransaction => ({
33
+ digest: Hash.transactionDigest(bytes),
34
+ bytes,
35
+ signatures,
36
+ ...(options?.chain !== undefined && { chain: options.chain })
37
+ })
38
+
39
+ const decodeData = T.decode
40
+
41
+ /** The transaction data inside the bytes, if they parse. */
42
+ export const dataOf = (signed: SignedTransaction): Option.Option<T.TransactionData> =>
43
+ Result.match(decodeData(signed.bytes), { onSuccess: Option.some, onFailure: () => Option.none() })
44
+
45
+ export const expirationOf = (signed: SignedTransaction): T.TransactionExpiration | undefined =>
46
+ Option.match(dataOf(signed), { onNone: () => undefined, onSome: (d) => d.expiration })
47
+
48
+ /** The last epoch the bytes may execute in, when the expiration says. */
49
+ export const maxEpochOf = (expiration: T.TransactionExpiration | undefined): bigint | undefined => {
50
+ switch (expiration?._tag) {
51
+ case "Epoch":
52
+ return expiration.value
53
+ case "ValidDuring":
54
+ case "Validity":
55
+ return Option.getOrUndefined(expiration.maxEpoch)
56
+ default:
57
+ return undefined
58
+ }
59
+ }
60
+
61
+ /** The first epoch the bytes may execute in (genesis when unbounded). */
62
+ export const minEpochOf = (expiration: T.TransactionExpiration | undefined): bigint | undefined =>
63
+ expiration?._tag === "ValidDuring" || expiration?._tag === "Validity"
64
+ ? Option.getOrUndefined(expiration.minEpoch)
65
+ : undefined
66
+
67
+ /** The chain the bytes belong to: the one the expiration names, else the recorded one. */
68
+ export const chainOf = (signed: SignedTransaction): string | undefined => {
69
+ const expiration = expirationOf(signed)
70
+ return expiration?._tag === "ValidDuring" || expiration?._tag === "Validity" ? expiration.chain : signed.chain
71
+ }
72
+
73
+ export interface PinnedRef {
74
+ readonly objectId: string
75
+ readonly version: bigint
76
+ }
77
+
78
+ const COIN_RESERVATION_MAGIC = 0xac
79
+ const COIN_RESERVATION_MAGIC_OFFSET = 12
80
+ const encodeDigest = Bcs.encodeSync(T.ObjectDigest)
81
+
82
+ /**
83
+ * A synthetic gas ref drawing on an address balance (version 0, a digest
84
+ * whose last 20 bytes are `0xac`). It names no object and pins nothing.
85
+ */
86
+ export const isCoinReservation = (ref: T.ObjectRef): boolean => {
87
+ if (ref.version !== 0n) return false
88
+ const bytes = encodeDigest(ref.digest)
89
+ const digest = bytes.subarray(bytes.length - 32)
90
+ return digest.subarray(COIN_RESERVATION_MAGIC_OFFSET).every((b) => b === COIN_RESERVATION_MAGIC)
91
+ }
92
+
93
+ /**
94
+ * The object versions whose consumption by another transaction proves these
95
+ * bytes can never execute: owned inputs and gas coins. `Receiving` inputs are
96
+ * left out — a transaction can still execute after its receiving object was
97
+ * received elsewhere (the receive fails, the transaction runs), so another
98
+ * transaction consuming one proves nothing about ours.
99
+ */
100
+ export const pinnedRefsOf = (signed: SignedTransaction): ReadonlyArray<PinnedRef> =>
101
+ Option.match(dataOf(signed), {
102
+ onNone: () => [],
103
+ onSome: (data) => {
104
+ const out: Array<PinnedRef> = []
105
+ for (const input of data.kind.inputs) {
106
+ if (input._tag !== "Object") continue
107
+ const arg = input.value
108
+ if (arg._tag === "ImmOrOwnedObject") {
109
+ out.push({ objectId: arg.objectId, version: arg.version })
110
+ }
111
+ }
112
+ for (const ref of data.gasData.payment) {
113
+ if (!isCoinReservation(ref)) out.push({ objectId: ref.objectId, version: ref.version })
114
+ }
115
+ return out
116
+ }
117
+ })
118
+
119
+ /**
120
+ * Whether two transactions from the same sender built concurrently could race
121
+ * over these bytes: any owned or receiving input, or any gas payment ref
122
+ * (coins, or a coin reservation). Bytes that pin none of these — address
123
+ * balance gas, pure / shared / withdrawal inputs — cannot.
124
+ */
125
+ export const pinsObjects = (data: T.TransactionData): boolean =>
126
+ data.gasData.payment.length > 0 ||
127
+ data.kind.inputs.some((i) => i._tag === "Object" && (i.value._tag === "ImmOrOwnedObject" || i.value._tag === "Receiving"))
128
+
129
+ /** `undefined` when the digest is the digest of the bytes, else the computed one. */
130
+ export const digestMismatch = (signed: SignedTransaction): string | undefined => {
131
+ const computed = Hash.transactionDigest(signed.bytes)
132
+ return computed === signed.digest ? undefined : computed
133
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The lifecycle's policies, as a `Context.Reference`: every default is in
3
+ * force with no setup, and any of them can be overridden for one fiber with
4
+ * `SubmitConfig.with({...})(effect)` or for a program with `layer({...})`.
5
+ */
6
+ import * as Context from "effect/Context"
7
+ import * as Duration from "effect/Duration"
8
+ import * as Effect from "effect/Effect"
9
+ import * as Layer from "effect/Layer"
10
+ import * as Schedule from "effect/Schedule"
11
+
12
+ export interface SubmitConfigService {
13
+ /** Delays between re-sends of the identical bytes after a retryable transport failure. */
14
+ readonly resubmit: Schedule.Schedule<unknown, unknown>
15
+ /** Total execute attempts, the first included. */
16
+ readonly resubmitAttempts: number
17
+ /** One execute with no answer within this is a retryable failure (the bytes may have landed). */
18
+ readonly executeTimeout: Duration.Duration
19
+ /** How long `reconcile` keeps asking for a digest the node does not (yet) serve. */
20
+ readonly lookupTimeout: Duration.Duration
21
+ /** Spacing of those lookups. */
22
+ readonly lookupInterval: Duration.Duration
23
+ /** The delay between the two observations the expiry rule needs. */
24
+ readonly reconcileRecheck: Duration.Duration
25
+ /**
26
+ * Whether a closed epoch window may be evidence at all. `"never"` is for a
27
+ * deployment behind a mixed-node load balancer, where even a repeated
28
+ * observation may be answered by two different nodes.
29
+ */
30
+ readonly expiryEvidence: "epochThenMiss" | "never"
31
+ /** After a successful execute, wait until reads see the transaction (never changes the outcome). */
32
+ readonly awaitVisibility: boolean
33
+ readonly visibilityTimeout: Duration.Duration
34
+ }
35
+
36
+ export type Overrides = {
37
+ readonly [K in keyof SubmitConfigService]?: SubmitConfigService[K] extends Duration.Duration ? Duration.Input
38
+ : SubmitConfigService[K]
39
+ }
40
+
41
+ export const defaults: SubmitConfigService = {
42
+ resubmit: Schedule.exponential("250 millis").pipe(
43
+ Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.min(duration, Duration.seconds(30)))),
44
+ Schedule.jittered
45
+ ),
46
+ resubmitAttempts: 5,
47
+ executeTimeout: Duration.seconds(60),
48
+ lookupTimeout: Duration.seconds(5),
49
+ lookupInterval: Duration.millis(500),
50
+ reconcileRecheck: Duration.seconds(2),
51
+ expiryEvidence: "epochThenMiss",
52
+ awaitVisibility: true,
53
+ visibilityTimeout: Duration.seconds(15)
54
+ }
55
+
56
+ export const SubmitConfig = Context.Reference<SubmitConfigService>("@unconfirmed/effect-sui/lifecycle/SubmitConfig", {
57
+ defaultValue: () => defaults
58
+ })
59
+
60
+ const merge = (base: SubmitConfigService, overrides: Overrides): SubmitConfigService => {
61
+ const out: Record<string, unknown> = { ...base }
62
+ for (const [key, value] of Object.entries(overrides)) {
63
+ if (value === undefined) continue
64
+ out[key] = Duration.isDuration((base as any)[key]) ? Duration.fromInputUnsafe(value as Duration.Input) : value
65
+ }
66
+ return out as unknown as SubmitConfigService
67
+ }
68
+
69
+ /** Overrides merged over the defaults. */
70
+ export const layer = (overrides: Overrides): Layer.Layer<never> => Layer.succeed(SubmitConfig, merge(defaults, overrides))
71
+
72
+ /** Overrides merged over the config in force, for one effect. */
73
+ export const with_ = (overrides: Overrides) => <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
74
+ Effect.flatMap(Effect.service(SubmitConfig), (config) =>
75
+ Effect.provideService(effect, SubmitConfig, merge(config, overrides)))
76
+
77
+ export { with_ as with }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@unconfirmed/effect-sui/lifecycle`: crash-safe submission for `@unconfirmed/effect-sui`.
3
+ */
4
+ export * as Evidence from "./Evidence.ts"
5
+ export * as Journal from "./Journal.ts"
6
+ export * as JournalEntry from "./JournalEntry.ts"
7
+ export * as JournalKeyValueStore from "./JournalKeyValueStore.ts"
8
+ export * as Lifecycle from "./Lifecycle.ts"
9
+ export * as Outcome from "./Outcome.ts"
10
+ export * as SenderLock from "./SenderLock.ts"
11
+ export * as SignedTransaction from "./SignedTransaction.ts"
12
+ export * as SubmitConfig from "./SubmitConfig.ts"