@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,666 @@
1
+ import { Chain } from "../Chain.js";
2
+ import { Objects } from "../Objects.js";
3
+ import * as Resolve from "../Resolve.js";
4
+ import { RpcError } from "../RpcError.js";
5
+ import * as Signer from "../Signer.js";
6
+ import * as T from "../TransactionData.js";
7
+ import { Transactions } from "../Transactions.js";
8
+ import * as Tx from "../Tx.js";
9
+ import * as Clock from "effect/Clock";
10
+ import * as DateTime from "effect/DateTime";
11
+ import * as Duration from "effect/Duration";
12
+ import * as Effect from "effect/Effect";
13
+ import * as Option from "effect/Option";
14
+ import * as Result from "effect/Result";
15
+ import { Evidence } from "./Evidence.js";
16
+ import { Journal } from "./Journal.js";
17
+ import { SenderLock } from "./SenderLock.js";
18
+ import { includeOf, isUnresolved, JournalEntry } from "./JournalEntry.js";
19
+ import { DigestMismatch, ExecutionFailed, NotApplied, SubmissionUnknown } from "./Outcome.js";
20
+ import * as Signed from "./SignedTransaction.js";
21
+ import { SubmitConfig } from "./SubmitConfig.js";
22
+ const withInclude = (include) => include && { include };
23
+ // -----------------------------------------------------------------------------
24
+ // Small helpers
25
+ // -----------------------------------------------------------------------------
26
+ /** One line for a failure, never bytes. */
27
+ export const describe = (error) => {
28
+ if (typeof error !== "object" || error === null)
29
+ return String(error);
30
+ const e = error;
31
+ const tag = typeof e._tag === "string" ? e._tag : "Error";
32
+ if (tag === "RpcError")
33
+ return `RpcError ${String(e.code)} from ${String(e.method)}: ${String(e.message)}`;
34
+ const detail = e.message ?? e.reason ?? e.description ?? e.evidence;
35
+ return typeof detail === "string" && detail.length > 0 ? `${tag}: ${detail}` : tag;
36
+ };
37
+ const isRetryable = (e) => e.retryable;
38
+ const executionFailed = (effects) => effects.status._tag === "Failure"
39
+ ? new ExecutionFailed({ digest: effects.digest, ...Resolve.failureFields(effects.status) })
40
+ : undefined;
41
+ /** One `Transactions.get`, with "not found" as `None`. */
42
+ const lookupOnce = (digest, include) => Effect.flatMap(Effect.service(Transactions), (t) => t.get(digest, withInclude(include))).pipe(Effect.map(Option.some), Effect.catchTag("TransactionNotFound", () => Effect.succeedNone));
43
+ /**
44
+ * Ask for `digest` every `interval` until it is served or `timeout` passes.
45
+ * `None` means every lookup missed; a transport failure that lasted to the
46
+ * deadline (or was not retryable) is returned as the failure, because it is
47
+ * not a miss. `include` adds those parts to the effects.
48
+ */
49
+ export const awaitTransaction = Effect.fnUntraced(function* (digest, options) {
50
+ const interval = Duration.toMillis(options.interval);
51
+ const deadline = (yield* Clock.currentTimeMillis) + Duration.toMillis(options.timeout);
52
+ while (true) {
53
+ const result = yield* Effect.result(lookupOnce(digest, options.include));
54
+ if (result._tag === "Success" && Option.isSome(result.success))
55
+ return result.success;
56
+ if (result._tag === "Failure" && !isRetryable(result.failure))
57
+ return yield* result.failure;
58
+ if ((yield* Clock.currentTimeMillis) + interval > deadline) {
59
+ return result._tag === "Failure" ? yield* result.failure : Option.none();
60
+ }
61
+ yield* Effect.sleep(interval);
62
+ }
63
+ });
64
+ // -----------------------------------------------------------------------------
65
+ // Journal bookkeeping
66
+ // -----------------------------------------------------------------------------
67
+ const entry = {
68
+ signed: (signed, include) => Effect.map(DateTime.now, (at) => JournalEntry.cases.Signed.make({ digest: signed.digest, signed, ...withInclude(include), at })),
69
+ executed: (digest, include) => Effect.map(DateTime.now, (at) => JournalEntry.cases.Executed.make({ digest, ...withInclude(include), at })),
70
+ failed: (error) => Effect.map(DateTime.now, (at) => JournalEntry.cases.Failed.make({ digest: error.digest, description: error.description, at })),
71
+ notApplied: (error) => Effect.map(DateTime.now, (at) => JournalEntry.cases.NotApplied.make({ digest: error.digest, evidence: error.evidence, at })),
72
+ /** `firstAt`: when the bytes were first journalled, kept across rewrites. */
73
+ unknown: (signed, include, lastError, attempts, firstAt) => Effect.map(DateTime.now, (now) => JournalEntry.cases.Unknown.make({
74
+ digest: signed.digest,
75
+ signed,
76
+ ...withInclude(include),
77
+ lastError,
78
+ attempts,
79
+ at: firstAt ?? now
80
+ }))
81
+ };
82
+ /** Write an entry after the network answered: a failure is logged, never returned. */
83
+ const journalSettled = (e) => Effect.flatMap(Effect.service(Journal), (j) => j.put(e)).pipe(Effect.catchTag("JournalError", (error) => Effect.logError("the journal could not record a settled transaction; the outcome stands", error)), Effect.annotateLogs({ digest: e.digest, entry: e._tag }));
84
+ const terminalEntry = (result, digest, include) => result._tag === "Success"
85
+ ? Option.some(entry.executed(digest, include))
86
+ : result.failure._tag === "ExecutionFailed"
87
+ ? Option.some(entry.failed(result.failure))
88
+ : result.failure._tag === "NotApplied"
89
+ ? Option.some(entry.notApplied(result.failure))
90
+ : Option.none();
91
+ /**
92
+ * What the pinned objects prove. A version that has not moved proves nothing.
93
+ * One that moved is read for *who* moved it: this digest (applied), or another
94
+ * transaction whose effects took exactly the pinned version as input
95
+ * (`inputConsumed`). Anything else is inconclusive; every ref is tried.
96
+ */
97
+ /**
98
+ * The version of `objectId` that transaction `by` took as input, from its own
99
+ * effects (a failed transaction consumed its inputs too). None when the node
100
+ * does not serve it, answers for another digest, or the object was not an input.
101
+ */
102
+ const consumedVersion = (by, objectId) => Effect.map(lookupOnce(by), (found) => Option.flatMap(found, (effects) => effects.digest !== by
103
+ ? Option.none()
104
+ : Option.fromNullishOr(effects.changedObjects.find((c) => c.objectId === objectId)?.inputVersion)));
105
+ const inputEvidence = Effect.fnUntraced(function* (digest, signed) {
106
+ const objects = yield* Objects;
107
+ let inconclusive;
108
+ const remember = (objectId, reason) => {
109
+ inconclusive ??= { _tag: "Unreadable", objectId, reason };
110
+ };
111
+ const refs = Signed.pinnedRefsOf(signed);
112
+ // All pinned objects at once, so a batching `Objects` sends one request.
113
+ const lives = yield* Effect.forEach(refs, (pinned) => objects.get(pinned.objectId).pipe(Effect.map(Option.some), Effect.catchTag("ObjectNotFound", () => Effect.succeedNone)), { concurrency: "unbounded" });
114
+ for (const [i, pinned] of refs.entries()) {
115
+ const objectId = pinned.objectId;
116
+ const live = lives[i];
117
+ if (Option.isNone(live)) {
118
+ remember(objectId, "it is gone, and a deleted object names no transaction");
119
+ continue;
120
+ }
121
+ if (live.value.version <= pinned.version)
122
+ continue;
123
+ const by = Option.fromNullishOr(live.value.previousTransaction);
124
+ if (Option.isNone(by)) {
125
+ remember(objectId, "the node does not say which transaction last mutated it");
126
+ continue;
127
+ }
128
+ if (by.value === digest)
129
+ return { _tag: "AppliedByUs", objectId };
130
+ const consumed = yield* consumedVersion(by.value, objectId);
131
+ if (Option.isNone(consumed)) {
132
+ remember(objectId, `the node does not say which version transaction ${by.value} consumed`);
133
+ continue;
134
+ }
135
+ if (consumed.value === pinned.version)
136
+ return { _tag: "ConsumedByOther", objectId, by: by.value };
137
+ remember(objectId, `transaction ${by.value} consumed version ${consumed.value}, not the pinned ${pinned.version}, and the state in between is not served`);
138
+ }
139
+ return inconclusive ?? { _tag: "NoEvidence" };
140
+ });
141
+ /** Whether the epoch window is observably closed right now. */
142
+ const expiryClosed = Effect.fnUntraced(function* (signed) {
143
+ const last = Signed.maxEpochOf(Signed.expirationOf(signed));
144
+ if (last === undefined)
145
+ return false;
146
+ const info = yield* Effect.flatMap(Effect.service(Chain), (c) => c.info);
147
+ return info.epoch > last;
148
+ });
149
+ /**
150
+ * One observation from one backend (`Evidence.observe`): its epoch, whether it
151
+ * serves the digest and its history, read consistently. Nothing from `Chain`
152
+ * or `Transactions` is joined into it.
153
+ */
154
+ const observeRound = Effect.fnUntraced(function* (digest, signed) {
155
+ const expiration = Signed.expirationOf(signed);
156
+ const last = Signed.maxEpochOf(expiration);
157
+ if (last === undefined)
158
+ return { _tag: "Open" };
159
+ const evidence = yield* Evidence;
160
+ const seen = yield* evidence.observe(digest, Signed.minEpochOf(expiration) ?? 0n);
161
+ if (Option.isNone(seen))
162
+ return { _tag: "Unobservable" };
163
+ if (seen.value.found)
164
+ return { _tag: "Found" };
165
+ if (seen.value.epoch <= last)
166
+ return { _tag: "Open" };
167
+ return { _tag: "Absent", gap: seen.value.gap };
168
+ });
169
+ const UNOBSERVABLE = "no Evidence service is provided, so the expiry rule is off (see Evidence)";
170
+ const FOUND_ELSEWHERE = "the Evidence backend serves this transaction but Transactions does not yet";
171
+ const OPEN_ELSEWHERE = "the Evidence backend has not yet reached the end of its window";
172
+ /** The reconcile rules, before read failures become `SubmissionUnknown`. */
173
+ const recover = Effect.fnUntraced(function* (config, digest, signed, include) {
174
+ const unknown = (reason) => new SubmissionUnknown({ digest, ...(signed && { signed }), reason });
175
+ const settle = (effects) => {
176
+ if (effects.digest !== digest) {
177
+ return Effect.fail(unknown(`the node answered for transaction ${effects.digest}, not ${digest}`));
178
+ }
179
+ const failed = executionFailed(effects);
180
+ return failed ? Effect.fail(failed) : Effect.succeed(effects);
181
+ };
182
+ if (signed !== undefined) {
183
+ const chain = Signed.chainOf(signed);
184
+ const info = yield* Effect.flatMap(Effect.service(Chain), (c) => c.info);
185
+ if (chain !== undefined && chain !== info.chainId) {
186
+ return yield* unknown(`these bytes were built for chain ${chain}, this node is on ${info.chainId}; nothing it says is evidence`);
187
+ }
188
+ }
189
+ const first = yield* awaitTransaction(digest, { timeout: config.lookupTimeout, interval: config.lookupInterval, ...withInclude(include) });
190
+ if (Option.isSome(first))
191
+ return yield* settle(first.value);
192
+ if (signed === undefined)
193
+ return yield* unknown("the node does not know this digest and the signed bytes are not available");
194
+ // Ordered and repeated: closed, missing, (recheck) closed, missing. Each
195
+ // round needs both a `Transactions` miss and one `Evidence` backend that is
196
+ // past the window and does not serve the digest, so a lagging index on one
197
+ // side cannot turn a late landing into `expired`.
198
+ let expired = Option.none();
199
+ // Why a closed window settled nothing, when it did not.
200
+ let why;
201
+ const round = Effect.fnUntraced(function* () {
202
+ const missed = yield* lookupOnce(digest, include);
203
+ if (Option.isSome(missed))
204
+ return { _tag: "Settled", effects: missed.value };
205
+ const seen = yield* observeRound(digest, signed);
206
+ if (seen._tag === "Found") {
207
+ const again = yield* lookupOnce(digest, include);
208
+ if (Option.isSome(again))
209
+ return { _tag: "Settled", effects: again.value };
210
+ }
211
+ return seen;
212
+ });
213
+ if (config.expiryEvidence === "epochThenMiss" && (yield* expiryClosed(signed))) {
214
+ const first = yield* round();
215
+ if (first._tag === "Settled")
216
+ return yield* settle(first.effects);
217
+ if (first._tag === "Absent") {
218
+ yield* Effect.sleep(config.reconcileRecheck);
219
+ if (yield* expiryClosed(signed)) {
220
+ const second = yield* round();
221
+ if (second._tag === "Settled")
222
+ return yield* settle(second.effects);
223
+ if (second._tag === "Absent")
224
+ expired = Option.some(second.gap);
225
+ else
226
+ why = second._tag === "Found" ? FOUND_ELSEWHERE : second._tag === "Open" ? OPEN_ELSEWHERE : UNOBSERVABLE;
227
+ }
228
+ }
229
+ else {
230
+ why = first._tag === "Found" ? FOUND_ELSEWHERE : first._tag === "Open" ? OPEN_ELSEWHERE : UNOBSERVABLE;
231
+ }
232
+ }
233
+ // Positive evidence vetoes "expired", so the objects are read first.
234
+ const evidence = yield* inputEvidence(digest, signed);
235
+ if (evidence._tag === "AppliedByUs") {
236
+ const again = yield* lookupOnce(digest, include);
237
+ if (Option.isSome(again))
238
+ return yield* settle(again.value);
239
+ return yield* unknown(`object ${evidence.objectId} names this transaction as its last mutation, so it applied, but the node does not serve it` +
240
+ (Option.isSome(expired) ? " (its window has closed; do not re-send it)" : ""));
241
+ }
242
+ if (Option.isSome(expired)) {
243
+ if (Option.isNone(expired.value))
244
+ return yield* new NotApplied({ digest, evidence: "expired" });
245
+ why = expired.value.value;
246
+ }
247
+ const pruned = why;
248
+ switch (evidence._tag) {
249
+ case "ConsumedByOther":
250
+ return yield* new NotApplied({
251
+ digest,
252
+ evidence: "inputConsumed",
253
+ message: `object ${evidence.objectId} at the pinned version was consumed by ${evidence.by}`
254
+ });
255
+ case "Unreadable":
256
+ return yield* unknown(`object ${evidence.objectId} has moved on or is gone, and ${evidence.reason}, so nothing is proven` +
257
+ (pruned === undefined ? "" : `; ${pruned}`));
258
+ case "NoEvidence":
259
+ return yield* unknown(pruned === undefined
260
+ ? "the node does not know this digest and nothing proves it cannot land"
261
+ : `the validity window has closed, but ${pruned}`);
262
+ }
263
+ });
264
+ const reconcileUnjournaled = (digest, signed, include) => Effect.flatMap(Effect.service(SubmitConfig), (config) => recover(config, digest, signed, include)).pipe(Effect.catchTag("RpcError", (error) => Effect.fail(new SubmissionUnknown({ digest, ...(signed && { signed }), reason: describe(error) }))));
265
+ /** The journal's entry for a digest; a read failure is logged and reads as none. */
266
+ const heldEntry = (digest) => Effect.flatMap(Effect.service(Journal), (j) => j.get(digest)).pipe(Effect.catchTag("JournalError", (error) => Effect.as(Effect.logError("the journal could not be read; the outcome stands", error), Option.none())));
267
+ /** The `include` asked for, else the one the journal recorded for the digest. */
268
+ const includeFor = (digest, given) => given !== undefined
269
+ ? Effect.succeed(given)
270
+ : Effect.map(heldEntry(digest), (held) => Option.isSome(held) ? includeOf(held.value) : undefined);
271
+ /**
272
+ * A settled journal entry wins over a weaker conclusion. The chain finding the
273
+ * transaction always stands (it is positive evidence), but a journal that
274
+ * recorded `Executed` / `Failed` is never contradicted by `NotApplied` or
275
+ * `SubmissionUnknown` from a lagging node, and a recorded `NotApplied` is never
276
+ * weakened to `SubmissionUnknown`.
277
+ */
278
+ const honourJournal = (held, digest, signed, result) => {
279
+ if (Option.isNone(held) || result._tag === "Success" || result.failure._tag === "ExecutionFailed")
280
+ return result;
281
+ const recorded = held.value;
282
+ switch (recorded._tag) {
283
+ case "Executed":
284
+ return Result.fail(new SubmissionUnknown({
285
+ digest,
286
+ ...(signed && { signed }),
287
+ reason: `the journal records this transaction as executed, but the node does not serve it (${describe(result.failure)}); do not re-send it`
288
+ }));
289
+ case "Failed":
290
+ return Result.fail(new ExecutionFailed({ digest, description: recorded.description }));
291
+ case "NotApplied":
292
+ return result.failure._tag === "NotApplied"
293
+ ? result
294
+ : Result.fail(new NotApplied({ digest, evidence: recorded.evidence }));
295
+ default:
296
+ return result;
297
+ }
298
+ };
299
+ /** Write an unresolved entry unless the journal (as just read: `held`) holds a settled one. Write failures are logged. */
300
+ const journalUnresolved = (held, e) => Option.isSome(held) && !isUnresolved(held.value) ? Effect.void : journalSettled(e);
301
+ const verified = (signed) => {
302
+ const computed = Signed.digestMismatch(signed);
303
+ return computed === undefined
304
+ ? Effect.succeed(signed)
305
+ : Effect.fail(new DigestMismatch({ digest: signed.digest, computed }));
306
+ };
307
+ /** A bare digest uses the signed bytes of the journal's unresolved entry for it, when they check out. */
308
+ const journalledBytes = (digest) => Effect.map(heldEntry(digest), (held) => {
309
+ const signed = Option.isSome(held) && isUnresolved(held.value) ? held.value.signed : undefined;
310
+ return {
311
+ digest,
312
+ signed: signed !== undefined && signed.digest === digest && Signed.digestMismatch(signed) === undefined ? signed : undefined
313
+ };
314
+ });
315
+ const inputOf = (input) => typeof input === "string"
316
+ ? journalledBytes(input)
317
+ : input instanceof SubmissionUnknown
318
+ ? input.signed === undefined
319
+ ? journalledBytes(input.digest)
320
+ : Effect.flatMap(verified(input.signed), (signed) => signed.digest === input.digest
321
+ ? Effect.succeed({ digest: input.digest, signed })
322
+ : Effect.fail(new DigestMismatch({ digest: input.digest, computed: signed.digest })))
323
+ : Effect.map(verified(input), (signed) => ({ digest: signed.digest, signed }));
324
+ /**
325
+ * Decide what happened to a transaction. Found is `Executed` / `ExecutionFailed`;
326
+ * not found is `NotApplied` only on evidence, otherwise `SubmissionUnknown`.
327
+ * A bare digest uses the signed bytes the journal holds for it (an unresolved
328
+ * entry); without them it can never be proven absent. A settled journal entry is never
329
+ * contradicted by a weaker answer; a terminal answer settles an unresolved one.
330
+ * Signed bytes whose digest does not match fail with `DigestMismatch`.
331
+ * `include` adds those parts to the effects; without it, the `include` the
332
+ * journal recorded for the submission is used.
333
+ */
334
+ export const reconcile = Effect.fn("Lifecycle.reconcile")(function* (input, options) {
335
+ const { digest, signed } = yield* inputOf(input);
336
+ const include = yield* includeFor(digest, options?.include);
337
+ const result = yield* Effect.uninterruptibleMask((restore) => Effect.flatMap(restore(Effect.result(reconcileUnjournaled(digest, signed, include))), (raw) => Effect.gen(function* () {
338
+ const held = yield* heldEntry(digest);
339
+ const result = honourJournal(held, digest, signed, raw);
340
+ const make = terminalEntry(result, digest, include);
341
+ if (Option.isSome(make) && Option.isSome(held) && isUnresolved(held.value)) {
342
+ yield* journalSettled(yield* make.value);
343
+ }
344
+ return result;
345
+ })));
346
+ return yield* Effect.fromResult(result);
347
+ });
348
+ /** Reconcile (with optional rechecks while unknown) and journal the answer. Never fails. */
349
+ const settle = Effect.fnUntraced(function* (signed, attempts, lastError, rechecks, include) {
350
+ const config = yield* SubmitConfig;
351
+ const answer = Effect.gen(function* () {
352
+ let result = yield* Effect.result(reconcileUnjournaled(signed.digest, signed, include));
353
+ for (let round = 0; round < rechecks; round++) {
354
+ if (result._tag !== "Failure" || result.failure._tag !== "SubmissionUnknown")
355
+ break;
356
+ yield* Effect.sleep(config.reconcileRecheck);
357
+ result = yield* Effect.result(reconcileUnjournaled(signed.digest, signed, include));
358
+ }
359
+ return result;
360
+ });
361
+ return yield* Effect.uninterruptibleMask((restore) => Effect.flatMap(restore(answer), (raw) => Effect.gen(function* () {
362
+ const held = yield* heldEntry(signed.digest);
363
+ const result = honourJournal(held, signed.digest, signed, raw);
364
+ const make = terminalEntry(result, signed.digest, include);
365
+ if (Option.isSome(make)) {
366
+ yield* journalSettled(yield* make.value);
367
+ }
368
+ else {
369
+ // Keep when the bytes were first journalled, and the send error that
370
+ // made them unknown when this round has no new one (reconcileAll).
371
+ const previous = Option.isSome(held) && isUnresolved(held.value) ? held.value : undefined;
372
+ yield* journalUnresolved(held, yield* entry.unknown(signed, include, lastError ?? (previous?._tag === "Unknown"
373
+ ? previous.lastError
374
+ : result._tag === "Failure" ? describe(result.failure) : "unknown"), attempts, previous?.at));
375
+ }
376
+ return result;
377
+ })));
378
+ });
379
+ // -----------------------------------------------------------------------------
380
+ // Submit
381
+ // -----------------------------------------------------------------------------
382
+ const LOCK_CONFLICT = /already locked by a different transaction|rejected as invalid by more than 1\/3 of validators/i;
383
+ const LOCK_CONFLICT_RECHECKS = 3;
384
+ /** Wait until reads see an executed transaction. Never fails and never changes the outcome. */
385
+ const awaitVisible = (config, digest) => config.awaitVisibility
386
+ ? awaitTransaction(digest, { timeout: config.visibilityTimeout, interval: config.lookupInterval }).pipe(Effect.flatMap((found) => Option.isSome(found)
387
+ ? Effect.void
388
+ : Effect.logDebug("executed but not visible within visibilityTimeout; the outcome stands")), Effect.catch((error) => Effect.logDebug(`executed, but waiting for visibility failed: ${describe(error)}`)), Effect.annotateLogs({ digest }), Effect.withSpan("Lifecycle.awaitVisible"))
389
+ : Effect.void;
390
+ /**
391
+ * The `Signed` write before a send. Never over a settled entry (unless asked).
392
+ * On bytes that were never sent a failure is an honest `JournalError`; on
393
+ * bytes that may already have gone out (`resent`) it is `SubmissionUnknown`.
394
+ */
395
+ const journalBeforeSend = (signed, resent, how) => Effect.gen(function* () {
396
+ const journal = yield* Journal;
397
+ // The caller usually just read the entry; read it here only when it did not.
398
+ const held = how.held ?? (yield* journal.get(signed.digest));
399
+ if (Option.isSome(held) && !isUnresolved(held.value) && !how.overwriteSettled)
400
+ return;
401
+ yield* journal.put(yield* entry.signed(signed, how.include));
402
+ }).pipe(Effect.catchTag("JournalError", (error) => resent
403
+ ? Effect.fail(new SubmissionUnknown({
404
+ digest: signed.digest,
405
+ signed,
406
+ reason: `these bytes may already be on chain and the journal could not record the re-send (${error.message}); nothing was re-sent`
407
+ }))
408
+ : Effect.fail(error)));
409
+ const send = Effect.fnUntraced(function* (signed, resent, how = {}) {
410
+ const config = yield* SubmitConfig;
411
+ const transactions = yield* Transactions;
412
+ if (!resent) {
413
+ // Bytes for another chain are never sent (a re-send checks this too):
414
+ // the node would refuse them, and that refusal would be recorded as proof.
415
+ const chain = Signed.chainOf(signed);
416
+ const info = yield* Effect.result(Effect.flatMap(Effect.service(Chain), (c) => c.info));
417
+ if (chain !== undefined && info._tag === "Success" && chain !== info.success.chainId) {
418
+ return yield* new SubmissionUnknown({
419
+ digest: signed.digest,
420
+ signed,
421
+ reason: `these bytes were built for chain ${chain}, this node is on ${info.success.chainId}; nothing was sent`
422
+ });
423
+ }
424
+ }
425
+ yield* journalBeforeSend(signed, resent, how);
426
+ let attempts = 0;
427
+ const once = Effect.suspend(() => {
428
+ attempts += 1;
429
+ return transactions.execute(signed.bytes, signed.signatures, withInclude(how.include)).pipe(Effect.timeoutOrElse({
430
+ duration: config.executeTimeout,
431
+ orElse: () => Effect.fail(new RpcError({
432
+ method: "ExecuteTransaction",
433
+ code: "DEADLINE_EXCEEDED",
434
+ message: `no answer within executeTimeout (${Duration.format(config.executeTimeout)})`
435
+ }))
436
+ }));
437
+ });
438
+ // The attempts are interruptible; from the answer to its journal record, nothing is.
439
+ const result = yield* Effect.uninterruptibleMask((restore) => restore(once.pipe(Effect.retry({
440
+ schedule: config.resubmit,
441
+ times: Math.max(config.resubmitAttempts - 1, 0),
442
+ while: (e) => e._tag === "RpcError" && isRetryable(e)
443
+ }))).pipe(Effect.result, Effect.tap((answered) => {
444
+ if (answered._tag !== "Success" || answered.success.digest !== signed.digest)
445
+ return Effect.void;
446
+ const failed = executionFailed(answered.success);
447
+ return Effect.flatMap(failed ? entry.failed(failed) : entry.executed(signed.digest, how.include), journalSettled);
448
+ })));
449
+ if (result._tag === "Success") {
450
+ const effects = result.success;
451
+ if (effects.digest !== signed.digest) {
452
+ return yield* reconcileSigned(signed, `the node answered for transaction ${effects.digest}`, attempts, 0, how.include);
453
+ }
454
+ const failed = executionFailed(effects);
455
+ if (failed)
456
+ return yield* failed;
457
+ yield* awaitVisible(config, signed.digest);
458
+ return effects;
459
+ }
460
+ const failure = result.failure;
461
+ // Accepted, but the answer can't be read as effects: it may have executed.
462
+ if (failure._tag === "ExecutedEffectsIncomplete")
463
+ return yield* reconcileSigned(signed, failure.message, attempts, 0, how.include);
464
+ // A lock held by another transaction, whatever the code: the bytes reached
465
+ // validators, so it reconciles (with rechecks while the winner becomes readable).
466
+ if (LOCK_CONFLICT.test(failure.message)) {
467
+ return yield* reconcileSigned(signed, describe(failure), attempts, LOCK_CONFLICT_RECHECKS, how.include);
468
+ }
469
+ // Refused outright on the first send of bytes never sent before: nothing executed.
470
+ if (!resent && attempts === 1 && failure.code === "INVALID_ARGUMENT") {
471
+ const refused = new NotApplied({ digest: signed.digest, evidence: "refused", message: failure.message });
472
+ yield* Effect.flatMap(entry.notApplied(refused), journalSettled);
473
+ return yield* refused;
474
+ }
475
+ return yield* reconcileSigned(signed, describe(failure), attempts, 0, how.include);
476
+ });
477
+ const reconcileSigned = Effect.fnUntraced(function* (signed, lastSend, attempts, rechecks, include) {
478
+ const settled = yield* settle(signed, attempts, lastSend, rechecks, include);
479
+ if (settled._tag === "Success")
480
+ return settled.success;
481
+ const failure = settled.failure;
482
+ if (failure._tag !== "SubmissionUnknown")
483
+ return yield* failure;
484
+ return yield* new SubmissionUnknown({
485
+ digest: failure.digest,
486
+ signed,
487
+ reason: `${failure.reason}; the last send failed with ${lastSend}`
488
+ });
489
+ });
490
+ const sendConsultingJournal = Effect.fnUntraced(function* (signed, mode, options) {
491
+ const held = yield* Effect.flatMap(Effect.service(Journal), (j) => j.get(signed.digest)).pipe(Effect.catchTag("JournalError", (error) => mode === "fresh" ? Effect.fail(error) : Effect.fail(new SubmissionUnknown({
492
+ digest: signed.digest,
493
+ signed,
494
+ reason: `the journal could not be read (${error.message}); nothing was sent, but these bytes may have been sent before`
495
+ }))));
496
+ // Asked for now, else what the earlier send of these bytes asked for.
497
+ const include = options?.include ?? (Option.isSome(held) ? includeOf(held.value) : undefined);
498
+ if (Option.isSome(held)) {
499
+ switch (held.value._tag) {
500
+ case "Executed":
501
+ case "Failed":
502
+ return yield* reconcile(signed, withInclude(include));
503
+ case "NotApplied":
504
+ if (mode === "resend" && options?.retryRefused === true && held.value.evidence === "refused") {
505
+ return yield* resend(signed, { held, overwriteSettled: true, include });
506
+ }
507
+ return yield* new NotApplied({ digest: signed.digest, evidence: held.value.evidence });
508
+ default:
509
+ return yield* resend(signed, { held, include });
510
+ }
511
+ }
512
+ return yield* (mode === "resend" ? resend(signed, { held, include }) : send(signed, false, { held, include }));
513
+ });
514
+ /**
515
+ * Send signed bytes and find out what happened. Re-sends only the identical
516
+ * bytes; ends in `Executed`, `ExecutionFailed`, `NotApplied` (proven, or
517
+ * `refused` on the first send of bytes the journal has never seen) or
518
+ * `SubmissionUnknown`. Bytes the journal already holds are treated as a
519
+ * re-send (see `resubmit`); bytes built for another chain than the node's are
520
+ * not sent (`SubmissionUnknown`). `JournalError` only from the `Signed` write
521
+ * before bytes the journal has never seen (a journal that cannot be read is
522
+ * `SubmissionUnknown`: the bytes may have been sent before); `DigestMismatch`
523
+ * if the digest is not the bytes'. `include` (`["events", "balanceChanges"]`)
524
+ * adds those to the effects, and is journalled with the bytes so a later
525
+ * reconcile (`reconcileAll` after a crash) reads them too.
526
+ */
527
+ export const submit = Effect.fn("Lifecycle.submit")(function* (input, options) {
528
+ const signed = yield* verified(input);
529
+ yield* Effect.annotateCurrentSpan({ "sui.digest": signed.digest });
530
+ return yield* sendConsultingJournal(signed, "submit", options);
531
+ });
532
+ /** `submit` for bytes signed just now by `run`: a journal read failure before the send is `JournalError`. */
533
+ const submitFresh = (signed, include) => Effect.flatMap(verified(signed), (s) => sendConsultingJournal(s, "fresh", withInclude(include))).pipe(Effect.withSpan("Lifecycle.submit"));
534
+ /**
535
+ * Re-send the identical bytes. Refuses when the journal already says
536
+ * `NotApplied` (unless `retryRefused` and the evidence is `refused`);
537
+ * reconciles instead (journal winning) when the journal says it executed, the
538
+ * bytes name another chain, or their window has closed. Bytes not given
539
+ * (a `SubmissionUnknown` without them) are taken from the journal, as is
540
+ * `include` when not given. Never raises `JournalError`: the bytes may
541
+ * already be out.
542
+ */
543
+ export const resubmit = Effect.fn("Lifecycle.resubmit")(function* (input, options) {
544
+ const { digest, signed } = yield* inputOf(input);
545
+ if (signed === undefined)
546
+ return yield* reconcile(digest, withInclude(options?.include));
547
+ return yield* sendConsultingJournal(signed, "resend", options);
548
+ });
549
+ const resend = Effect.fnUntraced(function* (signed, how = {}) {
550
+ const info = yield* Effect.result(Effect.flatMap(Effect.service(Chain), (c) => c.info));
551
+ const chain = Signed.chainOf(signed);
552
+ const otherChain = chain !== undefined && info._tag === "Success" && chain !== info.success.chainId;
553
+ const closed = otherChain || (yield* Effect.orElseSucceed(expiryClosed(signed), () => false));
554
+ if (closed) {
555
+ const settled = yield* settle(signed, 1, undefined, 0, how.include);
556
+ return settled._tag === "Success" ? settled.success : yield* settled.failure;
557
+ }
558
+ // `resent: true` turns a journal failure into SubmissionUnknown, never JournalError.
559
+ return yield* send(signed, true, how);
560
+ });
561
+ /**
562
+ * Settle every unresolved journal entry: the startup call after a crash. Each
563
+ * entry gets `reconcile`'s rules (with one lookup, not `lookupTimeout` of
564
+ * polling: entries left over from a crash are old) and the journal is updated,
565
+ * `concurrency` entries at a time; with `{ resubmit: true }` an entry still
566
+ * unknown is re-sent as identical bytes. Entries the journal cannot read are
567
+ * reported as `Corrupt` (drop them with `Journal.remove`), never a failure of
568
+ * the whole call. Fails only when the journal cannot be listed.
569
+ */
570
+ export const reconcileAll = Effect.fn("Lifecycle.reconcileAll")(function* (options) {
571
+ const journal = yield* Journal;
572
+ const config = yield* SubmitConfig;
573
+ const once = { ...config, lookupTimeout: Duration.zero };
574
+ const { entries, corrupt } = yield* journal.listUnresolved;
575
+ const corruptResults = corrupt.map((c) => ({ _tag: "Corrupt", digest: c.key, reason: c.reason }));
576
+ const settled = yield* Effect.forEach(entries, (e) => Effect.gen(function* () {
577
+ const computed = Signed.digestMismatch(e.signed);
578
+ if (computed !== undefined || e.signed.digest !== e.digest) {
579
+ return { _tag: "Corrupt", digest: e.digest, reason: `its bytes have digest ${computed ?? e.signed.digest}, not ${e.digest}` };
580
+ }
581
+ let result = yield* settle(e.signed, e._tag === "Unknown" ? e.attempts : 1, undefined, 0, e.include);
582
+ if (options?.resubmit === true && result._tag === "Failure" && result.failure._tag === "SubmissionUnknown") {
583
+ const sent = yield* Effect.result(resend(e.signed, { include: e.include }));
584
+ result = sent;
585
+ }
586
+ return toReconciled(e.digest, result);
587
+ }).pipe(Effect.provideService(SubmitConfig, once)), { concurrency: options?.concurrency ?? 8 });
588
+ return [...corruptResults, ...settled];
589
+ });
590
+ const toReconciled = (digest, result) => {
591
+ if (result._tag === "Success")
592
+ return { _tag: "Executed", digest, effects: result.success };
593
+ const error = result.failure;
594
+ switch (error._tag) {
595
+ case "ExecutionFailed":
596
+ return { _tag: "ExecutionFailed", digest, error };
597
+ case "NotApplied":
598
+ return { _tag: "NotApplied", digest, error };
599
+ case "SubmissionUnknown":
600
+ return { _tag: "SubmissionUnknown", digest, error };
601
+ case "DigestMismatch":
602
+ return { _tag: "SubmissionUnknown", digest, error: new SubmissionUnknown({ digest, reason: describe(error) }) };
603
+ }
604
+ };
605
+ // -----------------------------------------------------------------------------
606
+ // Sign and run
607
+ // -----------------------------------------------------------------------------
608
+ /**
609
+ * Sign transaction data (or its bytes) with every signer, concurrently.
610
+ * `chain` is recorded for expirations that name none. A signer that is
611
+ * neither the sender nor the gas owner is `Tx.SignerMismatch` before anyone
612
+ * signs, as in `Tx.execute` (an alias signs through `AddressAlias.signer`);
613
+ * bytes that do not parse as `TransactionData` are signed unchecked.
614
+ */
615
+ export const sign = Effect.fn("Lifecycle.sign")(function* (data, signers, options) {
616
+ const bytes = data instanceof Uint8Array ? data : T.encode(data);
617
+ const all = Array.isArray(signers) ? signers : [signers];
618
+ const parsed = data instanceof Uint8Array ? Result.getOrUndefined(T.decode(data)) : data;
619
+ if (parsed !== undefined)
620
+ yield* refuseMismatch(all, parsed.sender, parsed.gasData.owner);
621
+ const signatures = yield* Effect.forEach(all, (s) => Effect.map(Signer.signTransaction(s, bytes), (x) => x.signature), { concurrency: "unbounded" });
622
+ return Signed.make(bytes, signatures, options);
623
+ });
624
+ /** The first signer that is neither `sender` nor `gasOwner`, as `Tx.SignerMismatch`. */
625
+ const refuseMismatch = (signers, sender, gasOwner) => {
626
+ for (const s of signers) {
627
+ const refused = Tx.signerMismatch(s.address, sender, gasOwner);
628
+ if (refused)
629
+ return Effect.fail(refused);
630
+ }
631
+ return Effect.void;
632
+ };
633
+ /**
634
+ * Build (core `Tx.build`), sign, journal, submit. Unless given, the expiration
635
+ * is `ValidDuring` this epoch and the next, so the expiry rule can settle the
636
+ * bytes even when they pin nothing. `include` (`["events", "balanceChanges"]`)
637
+ * adds those to the effects (see `submit`).
638
+ *
639
+ * A signer (or cosigner) that is neither the sender nor the gas owner is
640
+ * `Tx.SignerMismatch` before any network call, as in `Tx.run`.
641
+ *
642
+ * Holds the `SenderLock` of the sender (and a distinct gas owner) for the
643
+ * build, and through signing and submission when the bytes pin a versioned
644
+ * object or gas payment; bytes that pin nothing are signed and sent after the
645
+ * lock is released.
646
+ */
647
+ export const run = (recipe, options) => Effect.gen(function* () {
648
+ const { signer, cosigners, sender: given, include, ...resolve } = options;
649
+ const sender = given ?? signer.address;
650
+ const signers = [signer, ...(cosigners ?? [])];
651
+ yield* refuseMismatch(signers, sender, resolve.gasOwner ?? sender);
652
+ const info = yield* Effect.flatMap(Effect.service(Chain), (c) => c.info);
653
+ const lock = yield* SenderLock;
654
+ const locked = yield* lock.withLocks([sender, ...(resolve.gasOwner ? [resolve.gasOwner] : [])])(Effect.gen(function* () {
655
+ const expiration = options.expiration ?? (yield* Resolve.validDuring());
656
+ const data = yield* Tx.build(recipe, { ...resolve, expiration, sender });
657
+ if (!Signed.pinsObjects(data))
658
+ return { _tag: "Unpinned", data };
659
+ const signed = yield* sign(data, signers, { chain: info.chainId });
660
+ return { _tag: "Done", effects: yield* submitFresh(signed, include) };
661
+ }));
662
+ if (locked._tag === "Done")
663
+ return locked.effects;
664
+ return yield* submitFresh(yield* sign(locked.data, signers, { chain: info.chainId }), include);
665
+ }).pipe(Effect.withSpan("Lifecycle.run"));
666
+ //# sourceMappingURL=Lifecycle.js.map