@unconfirmed/sui-effect 0.1.1 → 0.1.3

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 (74) hide show
  1. package/AGENTS.md +34 -11
  2. package/CHANGELOG.md +77 -0
  3. package/LLMS.md +630 -704
  4. package/README.md +175 -9
  5. package/dist/domain/bcs.d.ts.map +1 -1
  6. package/dist/domain/bcs.js +25 -9
  7. package/dist/domain/bcs.js.map +1 -1
  8. package/dist/domain/errors.d.ts +178 -40
  9. package/dist/domain/errors.d.ts.map +1 -1
  10. package/dist/domain/errors.js +271 -37
  11. package/dist/domain/errors.js.map +1 -1
  12. package/dist/domain/executed.d.ts +71 -2
  13. package/dist/domain/executed.d.ts.map +1 -1
  14. package/dist/domain/executed.js +210 -9
  15. package/dist/domain/executed.js.map +1 -1
  16. package/dist/domain/journal-entry.d.ts +37 -37
  17. package/dist/domain/journal-entry.js +1 -1
  18. package/dist/domain/schemas.d.ts +172 -65
  19. package/dist/domain/schemas.d.ts.map +1 -1
  20. package/dist/domain/schemas.js +131 -32
  21. package/dist/domain/schemas.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal.d.ts +1 -1
  27. package/dist/internal.d.ts.map +1 -1
  28. package/dist/internal.js +1 -1
  29. package/dist/internal.js.map +1 -1
  30. package/dist/script.d.ts +1 -1
  31. package/dist/script.d.ts.map +1 -1
  32. package/dist/script.js +1 -1
  33. package/dist/script.js.map +1 -1
  34. package/dist/services/Script.d.ts +42 -0
  35. package/dist/services/Script.d.ts.map +1 -1
  36. package/dist/services/Script.js +112 -77
  37. package/dist/services/Script.js.map +1 -1
  38. package/dist/services/Signer.d.ts +32 -7
  39. package/dist/services/Signer.d.ts.map +1 -1
  40. package/dist/services/Signer.js +69 -10
  41. package/dist/services/Signer.js.map +1 -1
  42. package/dist/services/SubmitConfig.d.ts +3 -22
  43. package/dist/services/SubmitConfig.d.ts.map +1 -1
  44. package/dist/services/SubmitConfig.js +54 -9
  45. package/dist/services/SubmitConfig.js.map +1 -1
  46. package/dist/services/Sui.d.ts +42 -1
  47. package/dist/services/Sui.d.ts.map +1 -1
  48. package/dist/services/Sui.js +46 -17
  49. package/dist/services/Sui.js.map +1 -1
  50. package/dist/services/SuiCore.d.ts.map +1 -1
  51. package/dist/services/SuiCore.js +47 -33
  52. package/dist/services/SuiCore.js.map +1 -1
  53. package/dist/services/SuiCoreFake.d.ts +47 -4
  54. package/dist/services/SuiCoreFake.d.ts.map +1 -1
  55. package/dist/services/SuiCoreFake.js +193 -22
  56. package/dist/services/SuiCoreFake.js.map +1 -1
  57. package/dist/services/Tx.d.ts +236 -402
  58. package/dist/services/Tx.d.ts.map +1 -1
  59. package/dist/services/Tx.js +205 -10
  60. package/dist/services/Tx.js.map +1 -1
  61. package/dist/testing.d.ts +1 -0
  62. package/dist/testing.d.ts.map +1 -1
  63. package/dist/testing.js +9 -0
  64. package/dist/testing.js.map +1 -1
  65. package/dist/tx.d.ts +1 -1
  66. package/dist/tx.d.ts.map +1 -1
  67. package/dist/tx.js +1 -1
  68. package/dist/tx.js.map +1 -1
  69. package/docs/extensions.md +608 -19
  70. package/examples/extension-template/src/Escrow.ts +1 -1
  71. package/examples/extension-template/src/errors.ts +29 -0
  72. package/examples/extension-template/src/schema.ts +8 -17
  73. package/examples/extension-template/test/escrow.test.ts +44 -0
  74. package/package.json +1 -1
@@ -1,15 +1,23 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
- import { Effect, Schema } from "effect";
2
+ import { Effect, type Option, Schema } from "effect";
3
3
  import { BuildError, ExecutionFailed, JournalError, NotApplied, PolicyDenied, SigningError, SimulationFailed, SubmissionUnknown, TransportError } from "../domain/errors.ts";
4
4
  import { Executed } from "../domain/executed.ts";
5
- import { Digest, SignedTransaction, SuiAddress } from "../domain/schemas.ts";
5
+ import { JournalEntry } from "../domain/journal-entry.ts";
6
+ import { Built, Digest, type Signature, SignedTransaction, SuiAddress } from "../domain/schemas.ts";
6
7
  import type { Signer } from "./Signer.ts";
7
8
  import type { Recipe } from "./Sui.ts";
8
9
  import { Sui } from "./Sui.ts";
9
10
  /** A transaction built into bytes, with the expiration the builder settled on. */
10
11
  export type { Built } from "../domain/schemas.ts";
11
- /** Signed bytes: everything `executeTransaction` needs, plus what `reconcile` needs. */
12
- export type Signed = SignedTransaction;
12
+ /**
13
+ * Signed bytes: everything `executeTransaction` needs, plus what `reconcile`
14
+ * needs.
15
+ *
16
+ * An interface rather than a type alias so the name survives into `.d.ts`,
17
+ * editor hover and `LLMS.md`; structurally it is {@link SignedTransaction}.
18
+ */
19
+ export interface Signed extends SignedTransaction {
20
+ }
13
21
  /** The schema of {@link Signed}. */
14
22
  export declare const Signed: Schema.Struct<{
15
23
  readonly digest: Schema.brand<Schema.String, "Digest">;
@@ -23,30 +31,30 @@ export declare const Signed: Schema.Struct<{
23
31
  readonly None: Schema.Literal<true>;
24
32
  }>, Schema.Struct<{
25
33
  readonly $kind: Schema.Literal<"Epoch">;
26
- readonly Epoch: Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>;
34
+ readonly Epoch: Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>;
27
35
  }>, Schema.Struct<{
28
36
  readonly $kind: Schema.Literal<"ValidDuring">;
29
37
  readonly ValidDuring: Schema.Struct<{
30
- readonly minEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
31
- readonly maxEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
32
- readonly minTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
33
- readonly maxTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
38
+ readonly minEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
39
+ readonly maxEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
40
+ readonly minTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
41
+ readonly maxTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
34
42
  readonly chain: Schema.String;
35
- readonly nonce: Schema.Number;
43
+ readonly nonce: Schema.Finite;
36
44
  }>;
37
45
  }>, Schema.Struct<{
38
46
  readonly $kind: Schema.Literal<"Validity">;
39
47
  readonly Validity: Schema.Struct<{
40
48
  readonly allowedProposers: Schema.NullOr<Schema.Struct<{
41
- readonly epoch: Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>;
42
- readonly proposers: Schema.$Array<Schema.Number>;
49
+ readonly epoch: Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>;
50
+ readonly proposers: Schema.$Array<Schema.Finite>;
43
51
  }>>;
44
- readonly minEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
45
- readonly maxEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
46
- readonly minTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
47
- readonly maxTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Number]>, never, never>>;
52
+ readonly minEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
53
+ readonly maxEpoch: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
54
+ readonly minTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
55
+ readonly maxTimestamp: Schema.NullOr<Schema.decodeTo<Schema.BigInt, Schema.Union<readonly [Schema.String, Schema.Finite]>, never, never>>;
48
56
  readonly chain: Schema.String;
49
- readonly nonce: Schema.Number;
57
+ readonly nonce: Schema.Finite;
50
58
  }>;
51
59
  }>]>>;
52
60
  readonly chain: Schema.optional<Schema.String>;
@@ -59,14 +67,49 @@ export type ReconcileInput = Digest | Signed | SubmissionUnknown;
59
67
  * An extension that wraps a submission spells its own errors plus this, rather
60
68
  * than repeating four tags that will grow with the taxonomy.
61
69
  */
62
- export type SubmitError = ExecutionFailed | NotApplied | SubmissionUnknown | JournalError;
70
+ export type SubmitError = ExecutionFailed | NotApplied | SubmissionUnknown | JournalError | TransportError;
63
71
  /**
64
72
  * Everything {@link run} can fail with, as one name: {@link SubmitError} plus
65
73
  * what building, preflighting and signing can produce.
66
74
  */
67
75
  export type RunError = BuildError | SimulationFailed | PolicyDenied | SigningError | SubmitError | TransportError;
68
- /** What one entry of `Tx.reconcileAll` settled to. */
69
- export type Reconciled = Executed | ExecutionFailed | NotApplied | SubmissionUnknown;
76
+ /**
77
+ * What one entry of `Tx.reconcileAll` settled to, as a tagged union.
78
+ *
79
+ * Every case carries **one** discriminator in the same place: `_tag` is
80
+ * `"Executed"`, `"ExecutionFailed"`, `"NotApplied"` or `"SubmissionUnknown"`,
81
+ * and the payload is `executed` for the first and `error` for the other three.
82
+ * Before 0.1.2 this was a bare union of an `Executed` (which has no `_tag`) and
83
+ * three errors (which do), so the only way to tell a success from a failure was
84
+ * `"_tag" in entry` — a shape nothing could `Schema.match` or serialize.
85
+ *
86
+ * @since 0.1.2
87
+ */
88
+ export declare const Reconciled: Schema.TaggedUnion<{
89
+ readonly ExecutionFailed: Schema.TaggedStruct<"ExecutionFailed", {
90
+ readonly error: typeof ExecutionFailed;
91
+ }>;
92
+ readonly SubmissionUnknown: Schema.TaggedStruct<"SubmissionUnknown", {
93
+ readonly error: typeof SubmissionUnknown;
94
+ }>;
95
+ readonly NotApplied: Schema.TaggedStruct<"NotApplied", {
96
+ readonly error: typeof NotApplied;
97
+ }>;
98
+ readonly Executed: Schema.TaggedStruct<"Executed", {
99
+ readonly executed: typeof Executed;
100
+ }>;
101
+ }>;
102
+ /** One settled entry of `Tx.reconcileAll`. @since 0.1.2 */
103
+ export type Reconciled = typeof Reconciled.Type;
104
+ /**
105
+ * The shape `Tx.reconcileAll` returned in 0.1.0 and 0.1.1: the four outcomes as
106
+ * a bare union, with the successful one carrying no discriminator at all.
107
+ *
108
+ * @deprecated Use {@link Reconciled}, whose cases all carry `_tag`. This name
109
+ * exists so a 0.1.1 consumer that spelled the old union in its own types still
110
+ * compiles.
111
+ */
112
+ export type ReconciledOutcome = Executed | ExecutionFailed | NotApplied | SubmissionUnknown;
70
113
  /**
71
114
  * Builds a transaction into signable bytes.
72
115
  *
@@ -105,44 +148,7 @@ export type Reconciled = Executed | ExecutionFailed | NotApplied | SubmissionUnk
105
148
  export declare const build: (input: Transaction | Recipe, opts: {
106
149
  readonly sender: SuiAddress;
107
150
  readonly gasOwner?: SuiAddress;
108
- }) => Effect.Effect<{
109
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
110
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
111
- readonly bytes: Uint8Array<ArrayBufferLike>;
112
- readonly chain?: string | undefined;
113
- readonly expiration?: {
114
- readonly $kind: "None";
115
- readonly None: true;
116
- } | {
117
- readonly $kind: "Epoch";
118
- readonly Epoch: bigint;
119
- } | {
120
- readonly $kind: "ValidDuring";
121
- readonly ValidDuring: {
122
- readonly minEpoch: bigint | null;
123
- readonly maxEpoch: bigint | null;
124
- readonly minTimestamp: bigint | null;
125
- readonly maxTimestamp: bigint | null;
126
- readonly chain: string;
127
- readonly nonce: number;
128
- };
129
- } | {
130
- readonly $kind: "Validity";
131
- readonly Validity: {
132
- readonly allowedProposers: {
133
- readonly epoch: bigint;
134
- readonly proposers: readonly number[];
135
- } | null;
136
- readonly minEpoch: bigint | null;
137
- readonly maxEpoch: bigint | null;
138
- readonly minTimestamp: bigint | null;
139
- readonly maxTimestamp: bigint | null;
140
- readonly chain: string;
141
- readonly nonce: number;
142
- };
143
- } | undefined;
144
- readonly gasOwner?: (string & import("effect/Brand").Brand<"SuiAddress">) | undefined;
145
- }, TransportError | SimulationFailed | BuildError, Sui>;
151
+ }) => Effect.Effect<Built, TransportError | SimulationFailed | BuildError, Sui>;
146
152
  /**
147
153
  * Signs built bytes.
148
154
  *
@@ -153,81 +159,7 @@ export declare const build: (input: Transaction | Recipe, opts: {
153
159
  *
154
160
  * Fails with: `SigningError`.
155
161
  */
156
- export declare const sign: (built: {
157
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
158
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
159
- readonly bytes: Uint8Array<ArrayBufferLike>;
160
- readonly chain?: string | undefined;
161
- readonly expiration?: {
162
- readonly $kind: "None";
163
- readonly None: true;
164
- } | {
165
- readonly $kind: "Epoch";
166
- readonly Epoch: bigint;
167
- } | {
168
- readonly $kind: "ValidDuring";
169
- readonly ValidDuring: {
170
- readonly minEpoch: bigint | null;
171
- readonly maxEpoch: bigint | null;
172
- readonly minTimestamp: bigint | null;
173
- readonly maxTimestamp: bigint | null;
174
- readonly chain: string;
175
- readonly nonce: number;
176
- };
177
- } | {
178
- readonly $kind: "Validity";
179
- readonly Validity: {
180
- readonly allowedProposers: {
181
- readonly epoch: bigint;
182
- readonly proposers: readonly number[];
183
- } | null;
184
- readonly minEpoch: bigint | null;
185
- readonly maxEpoch: bigint | null;
186
- readonly minTimestamp: bigint | null;
187
- readonly maxTimestamp: bigint | null;
188
- readonly chain: string;
189
- readonly nonce: number;
190
- };
191
- } | undefined;
192
- readonly gasOwner?: (string & import("effect/Brand").Brand<"SuiAddress">) | undefined;
193
- }, signer: Signer) => Effect.Effect<{
194
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
195
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
196
- readonly signatures: readonly (string & import("effect/Brand").Brand<"Signature">)[];
197
- readonly bytes: Uint8Array<ArrayBufferLike>;
198
- readonly chain?: string | undefined;
199
- readonly expiration?: {
200
- readonly $kind: "None";
201
- readonly None: true;
202
- } | {
203
- readonly $kind: "Epoch";
204
- readonly Epoch: bigint;
205
- } | {
206
- readonly $kind: "ValidDuring";
207
- readonly ValidDuring: {
208
- readonly minEpoch: bigint | null;
209
- readonly maxEpoch: bigint | null;
210
- readonly minTimestamp: bigint | null;
211
- readonly maxTimestamp: bigint | null;
212
- readonly chain: string;
213
- readonly nonce: number;
214
- };
215
- } | {
216
- readonly $kind: "Validity";
217
- readonly Validity: {
218
- readonly allowedProposers: {
219
- readonly epoch: bigint;
220
- readonly proposers: readonly number[];
221
- } | null;
222
- readonly minEpoch: bigint | null;
223
- readonly maxEpoch: bigint | null;
224
- readonly minTimestamp: bigint | null;
225
- readonly maxTimestamp: bigint | null;
226
- readonly chain: string;
227
- readonly nonce: number;
228
- };
229
- } | undefined;
230
- }, SigningError, never>;
162
+ export declare const sign: (built: Built, signer: Signer) => Effect.Effect<Signed, SigningError, never>;
231
163
  /**
232
164
  * Adds one more signature to already signed bytes, for a sponsored or
233
165
  * multi-party transaction. The bytes are untouched, so both parties sign
@@ -238,81 +170,7 @@ export declare const sign: (built: {
238
170
  *
239
171
  * Fails with: `SigningError`.
240
172
  */
241
- export declare const cosign: (signed: {
242
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
243
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
244
- readonly signatures: readonly (string & import("effect/Brand").Brand<"Signature">)[];
245
- readonly bytes: Uint8Array<ArrayBufferLike>;
246
- readonly chain?: string | undefined;
247
- readonly expiration?: {
248
- readonly $kind: "None";
249
- readonly None: true;
250
- } | {
251
- readonly $kind: "Epoch";
252
- readonly Epoch: bigint;
253
- } | {
254
- readonly $kind: "ValidDuring";
255
- readonly ValidDuring: {
256
- readonly minEpoch: bigint | null;
257
- readonly maxEpoch: bigint | null;
258
- readonly minTimestamp: bigint | null;
259
- readonly maxTimestamp: bigint | null;
260
- readonly chain: string;
261
- readonly nonce: number;
262
- };
263
- } | {
264
- readonly $kind: "Validity";
265
- readonly Validity: {
266
- readonly allowedProposers: {
267
- readonly epoch: bigint;
268
- readonly proposers: readonly number[];
269
- } | null;
270
- readonly minEpoch: bigint | null;
271
- readonly maxEpoch: bigint | null;
272
- readonly minTimestamp: bigint | null;
273
- readonly maxTimestamp: bigint | null;
274
- readonly chain: string;
275
- readonly nonce: number;
276
- };
277
- } | undefined;
278
- }, signer: Signer) => Effect.Effect<{
279
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
280
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
281
- readonly signatures: readonly (string & import("effect/Brand").Brand<"Signature">)[];
282
- readonly bytes: Uint8Array<ArrayBufferLike>;
283
- readonly chain?: string | undefined;
284
- readonly expiration?: {
285
- readonly $kind: "None";
286
- readonly None: true;
287
- } | {
288
- readonly $kind: "Epoch";
289
- readonly Epoch: bigint;
290
- } | {
291
- readonly $kind: "ValidDuring";
292
- readonly ValidDuring: {
293
- readonly minEpoch: bigint | null;
294
- readonly maxEpoch: bigint | null;
295
- readonly minTimestamp: bigint | null;
296
- readonly maxTimestamp: bigint | null;
297
- readonly chain: string;
298
- readonly nonce: number;
299
- };
300
- } | {
301
- readonly $kind: "Validity";
302
- readonly Validity: {
303
- readonly allowedProposers: {
304
- readonly epoch: bigint;
305
- readonly proposers: readonly number[];
306
- } | null;
307
- readonly minEpoch: bigint | null;
308
- readonly maxEpoch: bigint | null;
309
- readonly minTimestamp: bigint | null;
310
- readonly maxTimestamp: bigint | null;
311
- readonly chain: string;
312
- readonly nonce: number;
313
- };
314
- } | undefined;
315
- }, SigningError, never>;
173
+ export declare const cosign: (signed: Signed, signer: Signer) => Effect.Effect<Signed, SigningError, never>;
316
174
  /**
317
175
  * Turns a recipe into a sponsored one: the sender owns the transaction, the
318
176
  * gas owner pays, and gas comes from the sponsor's address balance rather than
@@ -337,9 +195,16 @@ export declare const sponsored: (opts: {
337
195
  * `Tx.reconcile`, which either finds the transaction, proves it never applied,
338
196
  * or says it does not know.
339
197
  *
340
- * `TransportError` never escapes: once bytes may have been sent, "the network
341
- * was unreachable" is not an answer a caller can act on, so it becomes
342
- * `SubmissionUnknown` carrying the signed bytes.
198
+ * `TransportError` almost never escapes: once bytes may have been sent, "the
199
+ * network was unreachable" is not an answer a caller can act on, so it becomes
200
+ * `SubmissionUnknown` carrying the signed bytes. **The one exception is a node
201
+ * that refused the request outright** — gRPC `INVALID_ARGUMENT`, which is what
202
+ * a validator answers for malformed bytes or for a sponsored transaction
203
+ * carrying one signature. That answer came from the node, it is final, and
204
+ * nothing was executed, so it is reported as the `TransportError` it is rather
205
+ * than reconciled: a reconcile would go on to ask "is this digest on chain?",
206
+ * a question about a transaction that was never sent, and a lagging or scripted
207
+ * node can answer it yes.
343
208
  *
344
209
  * `JournalError` can only come from the `Signed` write, before anything has
345
210
  * been sent. Once the network has answered, a journal write that fails is
@@ -350,9 +215,60 @@ export declare const sponsored: (opts: {
350
215
  * Fails with: `ExecutionFailed` (applied on chain and failed; gas was charged),
351
216
  * `NotApplied` (provably never applied), `SubmissionUnknown` (the outcome is
352
217
  * not known and the bytes are in the error), `JournalError` (only before the
353
- * first send).
218
+ * first send), `TransportError` (only `INVALID_ARGUMENT`: the node refused the
219
+ * submission and nothing was executed).
354
220
  */
355
221
  export declare const submit: (signed: Signed) => Effect.Effect<Executed, SubmitError, Sui>;
222
+ /**
223
+ * What a third party answers when it has submitted your bytes.
224
+ *
225
+ * Three shapes are understood, in this order: an SDK `TransactionResult` (the
226
+ * service ran `executeTransaction` and passed the whole thing on), a reduced
227
+ * execute envelope (anything with a `digest` or an `effects`, decoded through
228
+ * {@link Executed.fromPartial}), and a bare digest string. Anything else — a
229
+ * `void`, an acknowledgement with no digest — means "ask the chain", and
230
+ * `submitVia` reconciles by the digest it already has, which is the digest of
231
+ * the bytes it handed over.
232
+ *
233
+ * @since 0.1.2
234
+ */
235
+ export type SubmitViaReply = unknown;
236
+ /** Everything {@link submitVia} can fail with, before the sender's own errors. */
237
+ export type SubmitViaError = ExecutionFailed | NotApplied | SubmissionUnknown | JournalError;
238
+ /**
239
+ * Submits through **someone else** — a relay, a sponsorship service, a backend
240
+ * that holds the only key allowed to talk to the node — and keeps the journal
241
+ * and the evidence rules that `Tx.submit` would have kept.
242
+ *
243
+ * The bytes never reach `executeTransaction` here; `send` does whatever the
244
+ * service needs (an HTTP POST, a queue, another process) and answers with
245
+ * whatever the service returns. What this owns is everything around it:
246
+ *
247
+ * - a `Signed` journal entry is written **before** `send` is called, so a crash
248
+ * between here and the service leaves the same record a direct submit leaves;
249
+ * - `send` is called **once**. A third party's submit is not known to be
250
+ * idempotent and re-sending is not this function's decision;
251
+ * - the reply is turned into an `Executed` when it carries one (see
252
+ * {@link SubmitViaReply}), and otherwise the chain is asked — by the digest
253
+ * of the bytes that were handed over, which a co-signature does not change;
254
+ * - a failure from `send` is **ambiguous** unless it says otherwise, so it ends
255
+ * in `Tx.reconcile` with the full evidence rules: the ordered expiry check,
256
+ * the chain-identity guard, the versioned consumer check. A sender error that
257
+ * **declares** `outcome: "not_applied"` on the instance — a 400 from the
258
+ * service, a refusal before anything went out — is taken at its word and
259
+ * fails straight through without spending a reconcile. A `TransportError` is
260
+ * not that: the taxonomy calls it `not_applied`, but a transport failure
261
+ * *talking to the relay* is exactly the ambiguous case, so it reconciles;
262
+ * - every terminal answer is journalled, exactly as `Tx.submit` journals it.
263
+ *
264
+ * Fails with: `ExecutionFailed`, `NotApplied`, `SubmissionUnknown` (carrying
265
+ * the signed bytes, with the sender's failure as its `cause`), `JournalError`
266
+ * (only from the write before `send`), and `E` — whatever `send` fails with —
267
+ * when that error declares `outcome: "not_applied"`.
268
+ *
269
+ * @since 0.1.2
270
+ */
271
+ export declare const submitVia: <E, R>(signed: Signed, send: (bytes: Uint8Array, signatures: ReadonlyArray<Signature>) => Effect.Effect<SubmitViaReply, E, R>) => Effect.Effect<Executed, SubmitViaError | E, Sui | R>;
356
272
  /**
357
273
  * Finds out what happened to a transaction that was sent but never answered
358
274
  * for.
@@ -438,6 +354,14 @@ export declare const reconcile: (input: ReconcileInput) => Effect.Effect<Execute
438
354
  * explicit lifecycle (`Tx.build`, `Tx.sign`, `Tx.cosign`, `Tx.submit`) when the
439
355
  * two parties cannot both sign in one process.
440
356
  *
357
+ * **`onSigned` is the hook between signing and sending.** A program with its
358
+ * own record to keep — a batch row, an outbox, an idempotency key — has to
359
+ * write the digest before the first send, and that used to mean giving up
360
+ * `Tx.run` and reassembling `withSenderLock(build → sign → record → submit)` by
361
+ * hand. Pass `onSigned` instead: it runs inside the sender lock, after the last
362
+ * signature and before `Tx.submit`'s first `executeTransaction`, and failing it
363
+ * fails the run with nothing sent.
364
+ *
441
365
  * Fails with: `BuildError`, `SimulationFailed`, `PolicyDenied`, `SigningError`,
442
366
  * `ExecutionFailed`, `NotApplied`, `SubmissionUnknown`, `JournalError`,
443
367
  * `TransportError` (from the build reads; once bytes are sent, transport
@@ -451,11 +375,58 @@ export declare const run: (recipe: Transaction | Recipe, opts: {
451
375
  * the bytes name a gas owner that is not the sender.
452
376
  */
453
377
  readonly sponsor?: Signer;
378
+ /**
379
+ * Called with the signed bytes **after every signature is on them and
380
+ * before the first `executeTransaction`**, which is the one moment a
381
+ * consumer's own record has to be written: the digest is final from here
382
+ * on, and anything that happens next may have reached the network.
383
+ *
384
+ * `Tx.submit` already writes its `Signed` journal entry at this point; this
385
+ * is for the record the journal does not hold — a domain row joining the
386
+ * digest to a batch, an outbox, a log line an operator greps. It runs
387
+ * inside the sender lock, so it is ordered with the submission it belongs
388
+ * to.
389
+ *
390
+ * Failing it fails the run **before anything is sent**, which is why its
391
+ * error is a `JournalError`: that is the taxonomy's "the record could not
392
+ * be written and nothing has gone out yet", it is already in `Tx.run`'s
393
+ * union, and it is `not_applied`, so the documented retry idiom is correct.
394
+ * Map your own persistence failure into it
395
+ * (`Effect.mapError((cause) => new JournalError({ cause }))`).
396
+ *
397
+ * @since 0.1.2
398
+ */
399
+ readonly onSigned?: (signed: Signed) => Effect.Effect<void, JournalError>;
454
400
  }) => Effect.Effect<Executed, TransportError | SimulationFailed | ExecutionFailed | SubmissionUnknown | NotApplied | SigningError | BuildError | PolicyDenied | JournalError, Sui>;
401
+ /**
402
+ * What the journal recorded for one digest, if anything.
403
+ *
404
+ * `Tx.reconcileAll` returns **only the entries that were still unresolved**,
405
+ * because those are the ones it had work to do about; a transaction that had
406
+ * already settled — executed, failed, or proven never applied — is not in its
407
+ * answer and never will be. This is how to ask about one of those: the entry is
408
+ * `Executed`, `Failed` or `NotApplied` for a settled digest, `Signed` or
409
+ * `Unknown` for one still in flight, and `None` for a digest this journal has
410
+ * never seen (including every digest at all, when the journal is the in-memory
411
+ * default and the process restarted).
412
+ *
413
+ * It is exactly `(yield* Journal).get(digest)`, named so that the recovery path
414
+ * does not have to reach for the reference.
415
+ *
416
+ * Fails with: `JournalError`.
417
+ *
418
+ * @since 0.1.2
419
+ */
420
+ export declare const recorded: (digest: Digest) => Effect.Effect<Option.Option<JournalEntry>, JournalError, never>;
455
421
  /**
456
422
  * Settles every unresolved entry in the journal: the explicit startup call a
457
423
  * long-lived application makes after building a durable `Journal`.
458
424
  *
425
+ * **Only unresolved entries come back.** `Signed` and `Unknown` are the tags
426
+ * that still need an answer; a digest that already settled is not in the
427
+ * journal's unresolved index and is not in this array. Ask about one of those
428
+ * with {@link recorded}.
429
+ *
459
430
  * Nothing here fails per entry: each one settles to an `Executed`, an
460
431
  * `ExecutionFailed`, a `NotApplied` or a `SubmissionUnknown`, in the order the
461
432
  * journal listed them, and the journal is updated to match. Every settled entry
@@ -471,7 +442,19 @@ export declare const run: (recipe: Transaction | Recipe, opts: {
471
442
  *
472
443
  * Fails with: `JournalError`, `TransportError`.
473
444
  */
474
- export declare const reconcileAll: () => Effect.Effect<readonly Reconciled[], TransportError | JournalError, Sui>;
445
+ export declare const reconcileAll: () => Effect.Effect<readonly ({
446
+ readonly _tag: "ExecutionFailed";
447
+ readonly error: ExecutionFailed;
448
+ } | {
449
+ readonly _tag: "SubmissionUnknown";
450
+ readonly error: SubmissionUnknown;
451
+ } | {
452
+ readonly _tag: "NotApplied";
453
+ readonly error: NotApplied;
454
+ } | {
455
+ readonly _tag: "Executed";
456
+ readonly executed: Executed;
457
+ })[], TransportError | JournalError, Sui>;
475
458
  /**
476
459
  * The lifecycle, namespaced the way the spec spells it: `Tx.build`, `Tx.sign`,
477
460
  * `Tx.cosign`, `Tx.sponsored`, `Tx.submit`, `Tx.reconcile`, `Tx.run`,
@@ -481,200 +464,17 @@ export declare const Tx: {
481
464
  readonly build: (input: Transaction | Recipe, opts: {
482
465
  readonly sender: SuiAddress;
483
466
  readonly gasOwner?: SuiAddress;
484
- }) => Effect.Effect<{
485
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
486
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
487
- readonly bytes: Uint8Array<ArrayBufferLike>;
488
- readonly chain?: string | undefined;
489
- readonly expiration?: {
490
- readonly $kind: "None";
491
- readonly None: true;
492
- } | {
493
- readonly $kind: "Epoch";
494
- readonly Epoch: bigint;
495
- } | {
496
- readonly $kind: "ValidDuring";
497
- readonly ValidDuring: {
498
- readonly minEpoch: bigint | null;
499
- readonly maxEpoch: bigint | null;
500
- readonly minTimestamp: bigint | null;
501
- readonly maxTimestamp: bigint | null;
502
- readonly chain: string;
503
- readonly nonce: number;
504
- };
505
- } | {
506
- readonly $kind: "Validity";
507
- readonly Validity: {
508
- readonly allowedProposers: {
509
- readonly epoch: bigint;
510
- readonly proposers: readonly number[];
511
- } | null;
512
- readonly minEpoch: bigint | null;
513
- readonly maxEpoch: bigint | null;
514
- readonly minTimestamp: bigint | null;
515
- readonly maxTimestamp: bigint | null;
516
- readonly chain: string;
517
- readonly nonce: number;
518
- };
519
- } | undefined;
520
- readonly gasOwner?: (string & import("effect/Brand").Brand<"SuiAddress">) | undefined;
521
- }, TransportError | SimulationFailed | BuildError, Sui>;
522
- readonly sign: (built: {
523
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
524
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
525
- readonly bytes: Uint8Array<ArrayBufferLike>;
526
- readonly chain?: string | undefined;
527
- readonly expiration?: {
528
- readonly $kind: "None";
529
- readonly None: true;
530
- } | {
531
- readonly $kind: "Epoch";
532
- readonly Epoch: bigint;
533
- } | {
534
- readonly $kind: "ValidDuring";
535
- readonly ValidDuring: {
536
- readonly minEpoch: bigint | null;
537
- readonly maxEpoch: bigint | null;
538
- readonly minTimestamp: bigint | null;
539
- readonly maxTimestamp: bigint | null;
540
- readonly chain: string;
541
- readonly nonce: number;
542
- };
543
- } | {
544
- readonly $kind: "Validity";
545
- readonly Validity: {
546
- readonly allowedProposers: {
547
- readonly epoch: bigint;
548
- readonly proposers: readonly number[];
549
- } | null;
550
- readonly minEpoch: bigint | null;
551
- readonly maxEpoch: bigint | null;
552
- readonly minTimestamp: bigint | null;
553
- readonly maxTimestamp: bigint | null;
554
- readonly chain: string;
555
- readonly nonce: number;
556
- };
557
- } | undefined;
558
- readonly gasOwner?: (string & import("effect/Brand").Brand<"SuiAddress">) | undefined;
559
- }, signer: Signer) => Effect.Effect<{
560
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
561
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
562
- readonly signatures: readonly (string & import("effect/Brand").Brand<"Signature">)[];
563
- readonly bytes: Uint8Array<ArrayBufferLike>;
564
- readonly chain?: string | undefined;
565
- readonly expiration?: {
566
- readonly $kind: "None";
567
- readonly None: true;
568
- } | {
569
- readonly $kind: "Epoch";
570
- readonly Epoch: bigint;
571
- } | {
572
- readonly $kind: "ValidDuring";
573
- readonly ValidDuring: {
574
- readonly minEpoch: bigint | null;
575
- readonly maxEpoch: bigint | null;
576
- readonly minTimestamp: bigint | null;
577
- readonly maxTimestamp: bigint | null;
578
- readonly chain: string;
579
- readonly nonce: number;
580
- };
581
- } | {
582
- readonly $kind: "Validity";
583
- readonly Validity: {
584
- readonly allowedProposers: {
585
- readonly epoch: bigint;
586
- readonly proposers: readonly number[];
587
- } | null;
588
- readonly minEpoch: bigint | null;
589
- readonly maxEpoch: bigint | null;
590
- readonly minTimestamp: bigint | null;
591
- readonly maxTimestamp: bigint | null;
592
- readonly chain: string;
593
- readonly nonce: number;
594
- };
595
- } | undefined;
596
- }, SigningError, never>;
597
- readonly cosign: (signed: {
598
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
599
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
600
- readonly signatures: readonly (string & import("effect/Brand").Brand<"Signature">)[];
601
- readonly bytes: Uint8Array<ArrayBufferLike>;
602
- readonly chain?: string | undefined;
603
- readonly expiration?: {
604
- readonly $kind: "None";
605
- readonly None: true;
606
- } | {
607
- readonly $kind: "Epoch";
608
- readonly Epoch: bigint;
609
- } | {
610
- readonly $kind: "ValidDuring";
611
- readonly ValidDuring: {
612
- readonly minEpoch: bigint | null;
613
- readonly maxEpoch: bigint | null;
614
- readonly minTimestamp: bigint | null;
615
- readonly maxTimestamp: bigint | null;
616
- readonly chain: string;
617
- readonly nonce: number;
618
- };
619
- } | {
620
- readonly $kind: "Validity";
621
- readonly Validity: {
622
- readonly allowedProposers: {
623
- readonly epoch: bigint;
624
- readonly proposers: readonly number[];
625
- } | null;
626
- readonly minEpoch: bigint | null;
627
- readonly maxEpoch: bigint | null;
628
- readonly minTimestamp: bigint | null;
629
- readonly maxTimestamp: bigint | null;
630
- readonly chain: string;
631
- readonly nonce: number;
632
- };
633
- } | undefined;
634
- }, signer: Signer) => Effect.Effect<{
635
- readonly digest: string & import("effect/Brand").Brand<"Digest">;
636
- readonly sender: string & import("effect/Brand").Brand<"SuiAddress">;
637
- readonly signatures: readonly (string & import("effect/Brand").Brand<"Signature">)[];
638
- readonly bytes: Uint8Array<ArrayBufferLike>;
639
- readonly chain?: string | undefined;
640
- readonly expiration?: {
641
- readonly $kind: "None";
642
- readonly None: true;
643
- } | {
644
- readonly $kind: "Epoch";
645
- readonly Epoch: bigint;
646
- } | {
647
- readonly $kind: "ValidDuring";
648
- readonly ValidDuring: {
649
- readonly minEpoch: bigint | null;
650
- readonly maxEpoch: bigint | null;
651
- readonly minTimestamp: bigint | null;
652
- readonly maxTimestamp: bigint | null;
653
- readonly chain: string;
654
- readonly nonce: number;
655
- };
656
- } | {
657
- readonly $kind: "Validity";
658
- readonly Validity: {
659
- readonly allowedProposers: {
660
- readonly epoch: bigint;
661
- readonly proposers: readonly number[];
662
- } | null;
663
- readonly minEpoch: bigint | null;
664
- readonly maxEpoch: bigint | null;
665
- readonly minTimestamp: bigint | null;
666
- readonly maxTimestamp: bigint | null;
667
- readonly chain: string;
668
- readonly nonce: number;
669
- };
670
- } | undefined;
671
- }, SigningError, never>;
467
+ }) => Effect.Effect<Built, TransportError | SimulationFailed | BuildError, Sui>;
468
+ readonly sign: (built: Built, signer: Signer) => Effect.Effect<Signed, SigningError, never>;
469
+ readonly cosign: (signed: Signed, signer: Signer) => Effect.Effect<Signed, SigningError, never>;
672
470
  readonly sponsored: (opts: {
673
471
  readonly sender: SuiAddress;
674
472
  readonly gasOwner: SuiAddress;
675
473
  }) => (recipe: Recipe) => Recipe;
676
474
  readonly submit: (signed: Signed) => Effect.Effect<Executed, SubmitError, Sui>;
475
+ readonly submitVia: <E, R>(signed: Signed, send: (bytes: Uint8Array, signatures: ReadonlyArray<Signature>) => Effect.Effect<SubmitViaReply, E, R>) => Effect.Effect<Executed, SubmitViaError | E, Sui | R>;
677
476
  readonly reconcile: (input: ReconcileInput) => Effect.Effect<Executed, TransportError | ExecutionFailed | SubmissionUnknown | NotApplied, Sui>;
477
+ readonly recorded: (digest: Digest) => Effect.Effect<Option.Option<JournalEntry>, JournalError, never>;
678
478
  readonly run: (recipe: Transaction | Recipe, opts: {
679
479
  readonly signer: Signer;
680
480
  readonly gasOwner?: SuiAddress;
@@ -683,7 +483,41 @@ export declare const Tx: {
683
483
  * the bytes name a gas owner that is not the sender.
684
484
  */
685
485
  readonly sponsor?: Signer;
486
+ /**
487
+ * Called with the signed bytes **after every signature is on them and
488
+ * before the first `executeTransaction`**, which is the one moment a
489
+ * consumer's own record has to be written: the digest is final from here
490
+ * on, and anything that happens next may have reached the network.
491
+ *
492
+ * `Tx.submit` already writes its `Signed` journal entry at this point; this
493
+ * is for the record the journal does not hold — a domain row joining the
494
+ * digest to a batch, an outbox, a log line an operator greps. It runs
495
+ * inside the sender lock, so it is ordered with the submission it belongs
496
+ * to.
497
+ *
498
+ * Failing it fails the run **before anything is sent**, which is why its
499
+ * error is a `JournalError`: that is the taxonomy's "the record could not
500
+ * be written and nothing has gone out yet", it is already in `Tx.run`'s
501
+ * union, and it is `not_applied`, so the documented retry idiom is correct.
502
+ * Map your own persistence failure into it
503
+ * (`Effect.mapError((cause) => new JournalError({ cause }))`).
504
+ *
505
+ * @since 0.1.2
506
+ */
507
+ readonly onSigned?: (signed: Signed) => Effect.Effect<void, JournalError>;
686
508
  }) => Effect.Effect<Executed, TransportError | SimulationFailed | ExecutionFailed | SubmissionUnknown | NotApplied | SigningError | BuildError | PolicyDenied | JournalError, Sui>;
687
- readonly reconcileAll: () => Effect.Effect<readonly Reconciled[], TransportError | JournalError, Sui>;
509
+ readonly reconcileAll: () => Effect.Effect<readonly ({
510
+ readonly _tag: "ExecutionFailed";
511
+ readonly error: ExecutionFailed;
512
+ } | {
513
+ readonly _tag: "SubmissionUnknown";
514
+ readonly error: SubmissionUnknown;
515
+ } | {
516
+ readonly _tag: "NotApplied";
517
+ readonly error: NotApplied;
518
+ } | {
519
+ readonly _tag: "Executed";
520
+ readonly executed: Executed;
521
+ })[], TransportError | JournalError, Sui>;
688
522
  };
689
523
  //# sourceMappingURL=Tx.d.ts.map