@midnightntwrk/wallet-sdk-capabilities 4.0.0-rc.1 → 4.0.0
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.
- package/README.md +10 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/liveness/livenessReads.js +11 -10
- package/dist/liveness/livenessService.js +4 -5
- package/dist/proving/index.d.ts +1 -0
- package/dist/proving/index.js +1 -0
- package/dist/proving/provingService.d.ts +16 -49
- package/dist/proving/provingService.js +1 -89
- package/dist/proving/v8ProvingService.d.ts +34 -7
- package/dist/proving/v8ProvingService.js +36 -6
- package/dist/proving/v9ProvingService.d.ts +108 -0
- package/dist/proving/v9ProvingService.js +146 -0
- package/dist/proving/versionedProving.d.ts +22 -4
- package/dist/proving/versionedProving.js +28 -2
- package/dist/signatures/v8Signatures.d.ts +1 -1
- package/dist/simulation/index.d.ts +4 -6
- package/dist/simulation/index.js +4 -7
- package/dist/simulation/v8/Simulator.d.ts +1 -3
- package/dist/simulation/v8/Simulator.js +1 -3
- package/dist/simulation/v8/SimulatorState.d.ts +1 -10
- package/dist/simulation/v8/SimulatorState.js +1 -9
- package/dist/simulation/v8/index.d.ts +1 -1
- package/dist/simulation/v8/index.js +1 -1
- package/dist/simulation/v9/Simulator.d.ts +0 -2
- package/dist/simulation/v9/Simulator.js +0 -2
- package/dist/simulation/v9/SimulatorState.d.ts +0 -9
- package/dist/simulation/v9/SimulatorState.js +0 -8
- package/dist/simulation/v9/index.d.ts +1 -1
- package/dist/simulation/v9/index.js +1 -1
- package/dist/submission/submissionService.d.ts +57 -9
- package/dist/submission/submissionService.js +61 -15
- package/dist/transactionLifecycle/SnapshotFormat.d.ts +51 -0
- package/dist/transactionLifecycle/SnapshotFormat.js +120 -0
- package/dist/transactionLifecycle/index.d.ts +4 -0
- package/dist/{pendingTransactions → transactionLifecycle}/index.js +4 -2
- package/dist/transactionLifecycle/lifecycle.d.ts +402 -0
- package/dist/transactionLifecycle/lifecycle.js +407 -0
- package/dist/transactionLifecycle/lifecycleService.d.ts +448 -0
- package/dist/transactionLifecycle/lifecycleService.js +350 -0
- package/dist/transactionLifecycle/transactionTraits.d.ts +106 -0
- package/dist/transactionLifecycle/transactionTraits.js +53 -0
- package/dist/validation/blockData.d.ts +23 -4
- package/dist/validation/blockData.js +34 -10
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/promiseBoundary.d.ts +10 -0
- package/dist/validation/promiseBoundary.js +30 -0
- package/dist/validation/v8ValidationService.d.ts +6 -5
- package/dist/validation/v8ValidationService.js +11 -4
- package/dist/validation/v9ValidationService.d.ts +30 -0
- package/dist/validation/v9ValidationService.js +61 -0
- package/dist/validation/validationService.d.ts +54 -32
- package/dist/validation/validationService.js +29 -49
- package/dist/validation/versionedValidation.d.ts +5 -3
- package/dist/validation/versionedValidation.js +5 -3
- package/package.json +12 -12
- package/dist/pendingTransactions/index.d.ts +0 -2
- package/dist/pendingTransactions/pendingTransactions.d.ts +0 -266
- package/dist/pendingTransactions/pendingTransactions.js +0 -302
- package/dist/pendingTransactions/pendingTransactionsService.d.ts +0 -108
- package/dist/pendingTransactions/pendingTransactionsService.js +0 -186
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One record per transaction, from the moment it is balanced to the moment nothing can change its outcome.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The states, what moves a record between them and what each stores are decided in ADR 0011. Every transition here is
|
|
6
|
+
* total: an event that does not apply to a record leaves it as it was, so a final state never moves, save that a
|
|
7
|
+
* reported inclusion overrules an end the wallet only inferred. No transition frees a coin; each wallet's own sweep
|
|
8
|
+
* does.
|
|
9
|
+
*/
|
|
10
|
+
import { ProtocolVersion, SnapshotFormat } from '@midnightntwrk/wallet-sdk-abstractions';
|
|
11
|
+
import { Data, DateTime, Either, Option, ParseResult } from 'effect';
|
|
12
|
+
import { type FailedTransactionResult, type Inputs, type VersionedTransactionTrait } from './transactionTraits.js';
|
|
13
|
+
export type { Inputs } from './transactionTraits.js';
|
|
14
|
+
/** Why a submitted transaction will never be included: the chain refused it, or its TTL passed while it waited. */
|
|
15
|
+
export type RejectedVerdict = FailedTransactionResult | Readonly<{
|
|
16
|
+
status: 'TTL_PASSED';
|
|
17
|
+
}>;
|
|
18
|
+
/** Where a transaction is in its lifecycle. */
|
|
19
|
+
export type LifecycleState = Data.TaggedEnum<{
|
|
20
|
+
Balanced: Record<never, never>;
|
|
21
|
+
Finalized: Record<never, never>;
|
|
22
|
+
Submitted: Record<never, never>;
|
|
23
|
+
Confirmed: Record<never, never>;
|
|
24
|
+
Rejected: {
|
|
25
|
+
readonly verdict: RejectedVerdict;
|
|
26
|
+
};
|
|
27
|
+
Orphaned: {
|
|
28
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
29
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
30
|
+
};
|
|
31
|
+
Expired: Record<never, never>;
|
|
32
|
+
Reverted: Record<never, never>;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const LifecycleState: {
|
|
35
|
+
readonly Submitted: Data.Case.Constructor<{
|
|
36
|
+
readonly _tag: "Submitted";
|
|
37
|
+
}, "_tag">;
|
|
38
|
+
readonly Expired: Data.Case.Constructor<{
|
|
39
|
+
readonly _tag: "Expired";
|
|
40
|
+
}, "_tag">;
|
|
41
|
+
readonly Balanced: Data.Case.Constructor<{
|
|
42
|
+
readonly _tag: "Balanced";
|
|
43
|
+
}, "_tag">;
|
|
44
|
+
readonly Finalized: Data.Case.Constructor<{
|
|
45
|
+
readonly _tag: "Finalized";
|
|
46
|
+
}, "_tag">;
|
|
47
|
+
readonly Confirmed: Data.Case.Constructor<{
|
|
48
|
+
readonly _tag: "Confirmed";
|
|
49
|
+
}, "_tag">;
|
|
50
|
+
readonly Rejected: Data.Case.Constructor<{
|
|
51
|
+
readonly _tag: "Rejected";
|
|
52
|
+
readonly verdict: RejectedVerdict;
|
|
53
|
+
}, "_tag">;
|
|
54
|
+
readonly Orphaned: Data.Case.Constructor<{
|
|
55
|
+
readonly _tag: "Orphaned";
|
|
56
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
57
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
58
|
+
}, "_tag">;
|
|
59
|
+
readonly Reverted: Data.Case.Constructor<{
|
|
60
|
+
readonly _tag: "Reverted";
|
|
61
|
+
}, "_tag">;
|
|
62
|
+
readonly $is: <Tag extends "Submitted" | "Expired" | "Balanced" | "Finalized" | "Confirmed" | "Rejected" | "Orphaned" | "Reverted">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
63
|
+
readonly _tag: "Submitted";
|
|
64
|
+
}, {
|
|
65
|
+
readonly _tag: Tag;
|
|
66
|
+
}> | Extract<{
|
|
67
|
+
readonly _tag: "Expired";
|
|
68
|
+
}, {
|
|
69
|
+
readonly _tag: Tag;
|
|
70
|
+
}> | Extract<{
|
|
71
|
+
readonly _tag: "Balanced";
|
|
72
|
+
}, {
|
|
73
|
+
readonly _tag: Tag;
|
|
74
|
+
}> | Extract<{
|
|
75
|
+
readonly _tag: "Finalized";
|
|
76
|
+
}, {
|
|
77
|
+
readonly _tag: Tag;
|
|
78
|
+
}> | Extract<{
|
|
79
|
+
readonly _tag: "Confirmed";
|
|
80
|
+
}, {
|
|
81
|
+
readonly _tag: Tag;
|
|
82
|
+
}> | Extract<{
|
|
83
|
+
readonly _tag: "Rejected";
|
|
84
|
+
readonly verdict: RejectedVerdict;
|
|
85
|
+
}, {
|
|
86
|
+
readonly _tag: Tag;
|
|
87
|
+
}> | Extract<{
|
|
88
|
+
readonly _tag: "Orphaned";
|
|
89
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
90
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
91
|
+
}, {
|
|
92
|
+
readonly _tag: Tag;
|
|
93
|
+
}> | Extract<{
|
|
94
|
+
readonly _tag: "Reverted";
|
|
95
|
+
}, {
|
|
96
|
+
readonly _tag: Tag;
|
|
97
|
+
}>;
|
|
98
|
+
readonly $match: {
|
|
99
|
+
<const Cases extends {
|
|
100
|
+
readonly Submitted: (args: {
|
|
101
|
+
readonly _tag: "Submitted";
|
|
102
|
+
}) => any;
|
|
103
|
+
readonly Expired: (args: {
|
|
104
|
+
readonly _tag: "Expired";
|
|
105
|
+
}) => any;
|
|
106
|
+
readonly Balanced: (args: {
|
|
107
|
+
readonly _tag: "Balanced";
|
|
108
|
+
}) => any;
|
|
109
|
+
readonly Finalized: (args: {
|
|
110
|
+
readonly _tag: "Finalized";
|
|
111
|
+
}) => any;
|
|
112
|
+
readonly Confirmed: (args: {
|
|
113
|
+
readonly _tag: "Confirmed";
|
|
114
|
+
}) => any;
|
|
115
|
+
readonly Rejected: (args: {
|
|
116
|
+
readonly _tag: "Rejected";
|
|
117
|
+
readonly verdict: RejectedVerdict;
|
|
118
|
+
}) => any;
|
|
119
|
+
readonly Orphaned: (args: {
|
|
120
|
+
readonly _tag: "Orphaned";
|
|
121
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
122
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
123
|
+
}) => any;
|
|
124
|
+
readonly Reverted: (args: {
|
|
125
|
+
readonly _tag: "Reverted";
|
|
126
|
+
}) => any;
|
|
127
|
+
}>(cases: Cases & { [K in Exclude<keyof Cases, "Submitted" | "Expired" | "Balanced" | "Finalized" | "Confirmed" | "Rejected" | "Orphaned" | "Reverted">]: never; }): (value: {
|
|
128
|
+
readonly _tag: "Submitted";
|
|
129
|
+
} | {
|
|
130
|
+
readonly _tag: "Expired";
|
|
131
|
+
} | {
|
|
132
|
+
readonly _tag: "Balanced";
|
|
133
|
+
} | {
|
|
134
|
+
readonly _tag: "Finalized";
|
|
135
|
+
} | {
|
|
136
|
+
readonly _tag: "Confirmed";
|
|
137
|
+
} | {
|
|
138
|
+
readonly _tag: "Rejected";
|
|
139
|
+
readonly verdict: RejectedVerdict;
|
|
140
|
+
} | {
|
|
141
|
+
readonly _tag: "Orphaned";
|
|
142
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
143
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
144
|
+
} | {
|
|
145
|
+
readonly _tag: "Reverted";
|
|
146
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Submitted" | "Expired" | "Balanced" | "Finalized" | "Confirmed" | "Rejected" | "Orphaned" | "Reverted"]>>;
|
|
147
|
+
<const Cases extends {
|
|
148
|
+
readonly Submitted: (args: {
|
|
149
|
+
readonly _tag: "Submitted";
|
|
150
|
+
}) => any;
|
|
151
|
+
readonly Expired: (args: {
|
|
152
|
+
readonly _tag: "Expired";
|
|
153
|
+
}) => any;
|
|
154
|
+
readonly Balanced: (args: {
|
|
155
|
+
readonly _tag: "Balanced";
|
|
156
|
+
}) => any;
|
|
157
|
+
readonly Finalized: (args: {
|
|
158
|
+
readonly _tag: "Finalized";
|
|
159
|
+
}) => any;
|
|
160
|
+
readonly Confirmed: (args: {
|
|
161
|
+
readonly _tag: "Confirmed";
|
|
162
|
+
}) => any;
|
|
163
|
+
readonly Rejected: (args: {
|
|
164
|
+
readonly _tag: "Rejected";
|
|
165
|
+
readonly verdict: RejectedVerdict;
|
|
166
|
+
}) => any;
|
|
167
|
+
readonly Orphaned: (args: {
|
|
168
|
+
readonly _tag: "Orphaned";
|
|
169
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
170
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
171
|
+
}) => any;
|
|
172
|
+
readonly Reverted: (args: {
|
|
173
|
+
readonly _tag: "Reverted";
|
|
174
|
+
}) => any;
|
|
175
|
+
}>(value: {
|
|
176
|
+
readonly _tag: "Submitted";
|
|
177
|
+
} | {
|
|
178
|
+
readonly _tag: "Expired";
|
|
179
|
+
} | {
|
|
180
|
+
readonly _tag: "Balanced";
|
|
181
|
+
} | {
|
|
182
|
+
readonly _tag: "Finalized";
|
|
183
|
+
} | {
|
|
184
|
+
readonly _tag: "Confirmed";
|
|
185
|
+
} | {
|
|
186
|
+
readonly _tag: "Rejected";
|
|
187
|
+
readonly verdict: RejectedVerdict;
|
|
188
|
+
} | {
|
|
189
|
+
readonly _tag: "Orphaned";
|
|
190
|
+
readonly authoredFor: ProtocolVersion.ProtocolVersion;
|
|
191
|
+
readonly chainNow: ProtocolVersion.ProtocolVersion;
|
|
192
|
+
} | {
|
|
193
|
+
readonly _tag: "Reverted";
|
|
194
|
+
}, cases: Cases & { [K in Exclude<keyof Cases, "Submitted" | "Expired" | "Balanced" | "Finalized" | "Confirmed" | "Rejected" | "Orphaned" | "Reverted">]: never; }): import("effect/Unify").Unify<ReturnType<Cases["Submitted" | "Expired" | "Balanced" | "Finalized" | "Confirmed" | "Rejected" | "Orphaned" | "Reverted"]>>;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
/** The record of one transaction. */
|
|
198
|
+
export type LifecycleRecord<TTransaction> = Readonly<{
|
|
199
|
+
/** What ties the record to the transaction at every state: proving and binding leave identifiers unchanged. */
|
|
200
|
+
identifiers: readonly string[];
|
|
201
|
+
/** The values the ledger stamps on the coins the transaction creates. */
|
|
202
|
+
intentHashes: readonly string[];
|
|
203
|
+
inputs: Inputs;
|
|
204
|
+
/** From this instant the ledger rejects the transaction. */
|
|
205
|
+
ttl: Date;
|
|
206
|
+
/**
|
|
207
|
+
* The version the transaction's bytes were built for; `none` for a record that never held its transaction, or one
|
|
208
|
+
* stored before transactions were stamped, which is read with the oldest trait and never orphaned.
|
|
209
|
+
*/
|
|
210
|
+
protocolVersion: Option.Option<ProtocolVersion.ProtocolVersion>;
|
|
211
|
+
/** The transaction in the form for its state; `none` only for a record that never held its transaction. */
|
|
212
|
+
tx: Option.Option<TTransaction>;
|
|
213
|
+
/** When the record began, whichever state it began in. */
|
|
214
|
+
createdAt: DateTime.Utc;
|
|
215
|
+
/** When the transaction was submitted, kept through its verdict; `none` while it never was. */
|
|
216
|
+
submittedAt: Option.Option<DateTime.Utc>;
|
|
217
|
+
state: LifecycleState;
|
|
218
|
+
}>;
|
|
219
|
+
/** Every transaction's record. */
|
|
220
|
+
export type TransactionLifecycle<TTransaction> = Readonly<{
|
|
221
|
+
records: ReadonlyArray<LifecycleRecord<TTransaction>>;
|
|
222
|
+
/**
|
|
223
|
+
* The top-level members of the stored payload this build does not declare, exactly as they were read, written back so
|
|
224
|
+
* a later release that wrote them still finds them. Absent when the payload carried none.
|
|
225
|
+
*/
|
|
226
|
+
unknownFields?: SnapshotFormat.UnknownFields;
|
|
227
|
+
}>;
|
|
228
|
+
/** What the facade knows about a transaction when it moves it into a state. */
|
|
229
|
+
export type TransactionFacts<TTransaction> = Readonly<{
|
|
230
|
+
tx: TTransaction;
|
|
231
|
+
identifiers: readonly string[];
|
|
232
|
+
intentHashes: readonly string[];
|
|
233
|
+
inputs: Inputs;
|
|
234
|
+
ttl: Date;
|
|
235
|
+
protocolVersion: ProtocolVersion.ProtocolVersion;
|
|
236
|
+
}>;
|
|
237
|
+
/** No transaction recorded. */
|
|
238
|
+
export declare const empty: <TTransaction>() => TransactionLifecycle<TTransaction>;
|
|
239
|
+
/**
|
|
240
|
+
* Whether a record can still leave its state: balanced, finalized or submitted.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* const open = state.records.filter(isLive);
|
|
244
|
+
*
|
|
245
|
+
* @param record The record.
|
|
246
|
+
* @returns `true` while some event can still move it.
|
|
247
|
+
*/
|
|
248
|
+
export declare const isLive: <TTransaction>(record: LifecycleRecord<TTransaction>) => boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Records a transaction as balanced, replacing a balanced record of the same spend: balancing it again begins it anew.
|
|
251
|
+
* So does balancing a spend whose record ended without its coins being spent on chain; a confirmed spend stays as it
|
|
252
|
+
* is, and so does one already finalized or submitted.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* const held = balanced(state, { tx: erased, identifiers, intentHashes, inputs, ttl, protocolVersion }, now);
|
|
256
|
+
*
|
|
257
|
+
* @param state The records.
|
|
258
|
+
* @param facts The balanced transaction, with its proofs erased.
|
|
259
|
+
* @param now When it was balanced.
|
|
260
|
+
* @returns The records with the transaction balanced, or unchanged when the spend has already moved past balancing.
|
|
261
|
+
*/
|
|
262
|
+
export declare const balanced: <TTransaction>(state: TransactionLifecycle<TTransaction>, facts: TransactionFacts<TTransaction>, now: DateTime.Utc) => TransactionLifecycle<TTransaction>;
|
|
263
|
+
/**
|
|
264
|
+
* Records a transaction as finalized, from balanced or from nothing. Every record the finalized transaction covers is
|
|
265
|
+
* folded into one, because merging the parts of a recipe makes one transaction.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* const proven = finalized(
|
|
269
|
+
* state,
|
|
270
|
+
* { tx: finalizedTx, identifiers, intentHashes, inputs, ttl, protocolVersion },
|
|
271
|
+
* now,
|
|
272
|
+
* );
|
|
273
|
+
*
|
|
274
|
+
* @param state The records.
|
|
275
|
+
* @param facts The finalized transaction.
|
|
276
|
+
* @param now When it was finalized.
|
|
277
|
+
* @returns The records with the transaction finalized, or unchanged when the spend has already been submitted.
|
|
278
|
+
*/
|
|
279
|
+
export declare const finalized: <TTransaction>(state: TransactionLifecycle<TTransaction>, facts: TransactionFacts<TTransaction>, now: DateTime.Utc) => TransactionLifecycle<TTransaction>;
|
|
280
|
+
/**
|
|
281
|
+
* Records a transaction as submitted, from balanced, finalized, reverted or nothing: a transaction proven outside the
|
|
282
|
+
* facade arrives still balanced, and an adopted one arrives unrecorded. A reverted one is sent again after a submission
|
|
283
|
+
* that threw: once it is sent it is in flight, whatever the wallet concluded before.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* const sent = submitted(state, { tx: finalizedTx, identifiers, intentHashes, inputs, ttl, protocolVersion }, now);
|
|
287
|
+
*
|
|
288
|
+
* @param state The records.
|
|
289
|
+
* @param facts The submitted transaction.
|
|
290
|
+
* @param now When it was submitted.
|
|
291
|
+
* @returns The records with the transaction submitted, or unchanged when it already was.
|
|
292
|
+
*/
|
|
293
|
+
export declare const submitted: <TTransaction>(state: TransactionLifecycle<TTransaction>, facts: TransactionFacts<TTransaction>, now: DateTime.Utc) => TransactionLifecycle<TTransaction>;
|
|
294
|
+
/**
|
|
295
|
+
* Records that a transaction was included, whichever live state its record is in: inclusion is a fact, and nothing
|
|
296
|
+
* overrules it afterwards.
|
|
297
|
+
*
|
|
298
|
+
* It also overrules an end the wallet only inferred (expired, rejected at its TTL, orphaned, reverted): a block's time
|
|
299
|
+
* is within the transaction's TTL, so an inclusion reported after such an end happened before it.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* const included = confirmed(state, [...tx.identifiers()]);
|
|
303
|
+
*
|
|
304
|
+
* @param state The records.
|
|
305
|
+
* @param identifiers The included transaction's identifiers.
|
|
306
|
+
* @returns The records with the transaction confirmed; a record whose end the chain reported is left as it was.
|
|
307
|
+
*/
|
|
308
|
+
export declare const confirmed: <TTransaction>(state: TransactionLifecycle<TTransaction>, identifiers: readonly string[]) => TransactionLifecycle<TTransaction>;
|
|
309
|
+
/**
|
|
310
|
+
* Records that the chain refused a finalized or submitted transaction. A finalized one counts too, because another
|
|
311
|
+
* party may have submitted it, as in a swap, and the chain's answer about it is a fact. A balanced one is left as it
|
|
312
|
+
* was: it is not yet proven, so no chain can have been asked to include it.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* const refused = rejected(state, [...tx.identifiers()], { status: 'FAILURE', segments });
|
|
316
|
+
*
|
|
317
|
+
* @param state The records.
|
|
318
|
+
* @param identifiers The refused transaction's identifiers.
|
|
319
|
+
* @param verdict What the chain reported.
|
|
320
|
+
* @returns The records with the transaction rejected.
|
|
321
|
+
*/
|
|
322
|
+
export declare const rejected: <TTransaction>(state: TransactionLifecycle<TTransaction>, identifiers: readonly string[], verdict: FailedTransactionResult) => TransactionLifecycle<TTransaction>;
|
|
323
|
+
/**
|
|
324
|
+
* Gives up on every live transaction built for an epoch the chain has left. A record whose version was never known is
|
|
325
|
+
* left as it was: that is no evidence it was left behind.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* const stranded = orphanBeyond(state, traits, chainNow);
|
|
329
|
+
*
|
|
330
|
+
* @param state The records.
|
|
331
|
+
* @param epochs The protocol version epochs, as the registry of traits keys them.
|
|
332
|
+
* @param chainNow The version the chain has reached.
|
|
333
|
+
* @returns The records with every stranded transaction orphaned.
|
|
334
|
+
*/
|
|
335
|
+
export declare const orphanBeyond: <TTransaction, TEpoch>(state: TransactionLifecycle<TTransaction>, epochs: ProtocolVersion.Registry<TEpoch>, chainNow: ProtocolVersion.ProtocolVersion) => TransactionLifecycle<TTransaction>;
|
|
336
|
+
/**
|
|
337
|
+
* Records that a transaction was reverted, so no chain will be asked to include it.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* const abandoned = reverted(state, [...tx.identifiers()]);
|
|
341
|
+
*
|
|
342
|
+
* @param state The records.
|
|
343
|
+
* @param identifiers The reverted transaction's identifiers.
|
|
344
|
+
* @returns The records with the transaction reverted; a final record is left as it was.
|
|
345
|
+
*/
|
|
346
|
+
export declare const reverted: <TTransaction>(state: TransactionLifecycle<TTransaction>, identifiers: readonly string[]) => TransactionLifecycle<TTransaction>;
|
|
347
|
+
/**
|
|
348
|
+
* Ends every live record whose TTL `now` has passed: one never submitted expires, and a submitted one is rejected.
|
|
349
|
+
*
|
|
350
|
+
* @param state The records.
|
|
351
|
+
* @param now The instant to expire against.
|
|
352
|
+
* @returns The records with every passed TTL acted on, or the same state when none has passed.
|
|
353
|
+
*/
|
|
354
|
+
export declare const expire: <TTransaction>(state: TransactionLifecycle<TTransaction>, now: DateTime.Utc) => TransactionLifecycle<TTransaction>;
|
|
355
|
+
/**
|
|
356
|
+
* Drops every final record whose TTL `now` has passed.
|
|
357
|
+
*
|
|
358
|
+
* @param state The records.
|
|
359
|
+
* @param now The instant to drop against.
|
|
360
|
+
* @returns The records without them, or the same state when none is due.
|
|
361
|
+
*/
|
|
362
|
+
export declare const dropFinished: <TTransaction>(state: TransactionLifecycle<TTransaction>, now: DateTime.Utc) => TransactionLifecycle<TTransaction>;
|
|
363
|
+
/**
|
|
364
|
+
* The unshielded coin ids some live transaction still accounts for.
|
|
365
|
+
*
|
|
366
|
+
* A final record accounts for none: a confirmed transaction's coins are spent on chain, and every other final state's
|
|
367
|
+
* coins are free. Read from the inputs each record keeps, so a record that never held its transaction still counts.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* const spokenFor = coveredUnshieldedIds(lifecycle);
|
|
371
|
+
*
|
|
372
|
+
* @param state The records.
|
|
373
|
+
* @returns Every such coin id, without repeats.
|
|
374
|
+
*/
|
|
375
|
+
export declare const coveredUnshieldedIds: <TTransaction>(state: TransactionLifecycle<TTransaction>) => readonly string[];
|
|
376
|
+
/**
|
|
377
|
+
* Writes the records in the current stored format, with every top-level member a payload it was read from carried but
|
|
378
|
+
* this build does not declare.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* const stored = serialize(lifecycle, traits);
|
|
382
|
+
*
|
|
383
|
+
* @param state The records.
|
|
384
|
+
* @param traits The traits each record's transaction is written with, chosen by the version it was built for.
|
|
385
|
+
* @returns The records as a JSON string.
|
|
386
|
+
*/
|
|
387
|
+
export declare const serialize: <TTransaction>(state: TransactionLifecycle<TTransaction>, traits: VersionedTransactionTrait<TTransaction>) => string;
|
|
388
|
+
/**
|
|
389
|
+
* Reads records stored in any format version this build knows, upgrading an older one on the way.
|
|
390
|
+
*
|
|
391
|
+
* @remarks
|
|
392
|
+
* A record that holds its transaction but lacks a fact reads it off the transaction, with the trait registered for the
|
|
393
|
+
* version the record was stamped with, or the oldest trait when it carries no stamp. A version this build does not
|
|
394
|
+
* know is refused, never read as the current one.
|
|
395
|
+
* @example
|
|
396
|
+
* const lifecycle = deserialize(stored, traits);
|
|
397
|
+
*
|
|
398
|
+
* @param serialized The stored JSON string.
|
|
399
|
+
* @param traits The traits each record's transaction is read with, chosen by the version it was stamped with.
|
|
400
|
+
* @returns The records, or why the payload could not be read.
|
|
401
|
+
*/
|
|
402
|
+
export declare const deserialize: <TTransaction>(serialized: string, traits: VersionedTransactionTrait<TTransaction>) => Either.Either<TransactionLifecycle<TTransaction>, ParseResult.ParseError>;
|