@degenerate/generic 0.4.0 → 0.6.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/dist/_settings/cryptography-settings.d.ts +5 -1
- package/dist/_settings/cryptography-settings.d.ts.map +1 -1
- package/dist/_settings/cryptography-settings.js +5 -1
- package/dist/crypto/index.d.ts +5 -9
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +7 -9
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts +22 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.js +65 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts +11 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.js +15 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts +16 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/create-ed25519-signature.js +26 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts +25 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts.map +1 -0
- package/dist/crypto/signature/ed25519-primitives.js +65 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts +13 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/verify-ed25519-signature.js +31 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/settlement/settlement-errors.d.ts +74 -0
- package/dist/errors/settlement/settlement-errors.d.ts.map +1 -0
- package/dist/errors/settlement/settlement-errors.js +93 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +5 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
- package/dist/models/settlement/settlement-models.d.ts +221 -0
- package/dist/models/settlement/settlement-models.d.ts.map +1 -0
- package/dist/models/settlement/settlement-models.js +152 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts +3 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.d.ts +179 -3
- package/dist/models/shareblock/shareblock-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.js +95 -3
- package/package.json +3 -4
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +0 -12
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +0 -54
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +0 -50
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +0 -51
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +0 -10
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +0 -51
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +0 -11
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/generate-key-pair.js +0 -49
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +0 -15
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +0 -21
- package/dist/crypto/signature/create-crypto-signature.d.ts +0 -20
- package/dist/crypto/signature/create-crypto-signature.d.ts.map +0 -1
- package/dist/crypto/signature/create-crypto-signature.js +0 -26
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.js +0 -61
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-hash.js +0 -58
|
@@ -34,6 +34,7 @@ export declare const ISAFETransactionShareDataDataSchema: z.ZodObject<{
|
|
|
34
34
|
Funding: "Funding";
|
|
35
35
|
Distribution: "Distribution";
|
|
36
36
|
GraceRepayment: "GraceRepayment";
|
|
37
|
+
Settlement: "Settlement";
|
|
37
38
|
}>;
|
|
38
39
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
39
40
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -93,6 +94,7 @@ export declare const ISAFETransactionShareDataSchema: z.ZodObject<{
|
|
|
93
94
|
Funding: "Funding";
|
|
94
95
|
Distribution: "Distribution";
|
|
95
96
|
GraceRepayment: "GraceRepayment";
|
|
97
|
+
Settlement: "Settlement";
|
|
96
98
|
}>;
|
|
97
99
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
98
100
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -151,6 +153,7 @@ export declare const ISAFETransactionShareDataAddSchema: z.ZodObject<{
|
|
|
151
153
|
Funding: "Funding";
|
|
152
154
|
Distribution: "Distribution";
|
|
153
155
|
GraceRepayment: "GraceRepayment";
|
|
156
|
+
Settlement: "Settlement";
|
|
154
157
|
}>;
|
|
155
158
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
156
159
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -208,6 +211,7 @@ export declare const ISAFETransactionShareDataUpdateSchema: z.ZodObject<{
|
|
|
208
211
|
Funding: "Funding";
|
|
209
212
|
Distribution: "Distribution";
|
|
210
213
|
GraceRepayment: "GraceRepayment";
|
|
214
|
+
Settlement: "Settlement";
|
|
211
215
|
}>;
|
|
212
216
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
213
217
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -265,6 +269,7 @@ export declare const ISAFETransactionShareDataDeleteSchema: z.ZodObject<{
|
|
|
265
269
|
Funding: "Funding";
|
|
266
270
|
Distribution: "Distribution";
|
|
267
271
|
GraceRepayment: "GraceRepayment";
|
|
272
|
+
Settlement: "Settlement";
|
|
268
273
|
}>;
|
|
269
274
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
270
275
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedata-transactions-models.d.ts","sourceRoot":"","sources":["../../../../src/models/safe/transactions/sharedata-transactions-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AASpC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mCAAmC
|
|
1
|
+
{"version":3,"file":"sharedata-transactions-models.d.ts","sourceRoot":"","sources":["../../../../src/models/safe/transactions/sharedata-transactions-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AASpC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAIxF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Two-phase-commit phase of a settlement, journaled on the coordinator's
|
|
4
|
+
* state. The legal transition graph (enforced by `buildSettlementPhaseRule`):
|
|
5
|
+
*
|
|
6
|
+
* PREPARING ──▶ COMMITTING ──▶ COMMITTED (terminal)
|
|
7
|
+
* │
|
|
8
|
+
* └────────▶ ABORTING ──▶ ABORTED (terminal)
|
|
9
|
+
*
|
|
10
|
+
* `COMMITTING` is the point of no return: once reached, every leg was already
|
|
11
|
+
* reserved, so the settlement can only roll forward. Failures before that
|
|
12
|
+
* point route to `ABORTING`. Terminals are sinks.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SettlementPhaseSchema: z.ZodEnum<{
|
|
15
|
+
PREPARING: "PREPARING";
|
|
16
|
+
COMMITTING: "COMMITTING";
|
|
17
|
+
ABORTING: "ABORTING";
|
|
18
|
+
COMMITTED: "COMMITTED";
|
|
19
|
+
ABORTED: "ABORTED";
|
|
20
|
+
}>;
|
|
21
|
+
export type SettlementPhase = z.infer<typeof SettlementPhaseSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Per-leg status as tracked by the coordinator (a superset of the member
|
|
24
|
+
* block's `ReservationStatus`):
|
|
25
|
+
*
|
|
26
|
+
* - `planned` — in the plan, not yet reserved on its block.
|
|
27
|
+
* - `reserved` — successfully held on its block (PREPARE done for this leg).
|
|
28
|
+
* - `committed` — finalized on its block.
|
|
29
|
+
* - `released` — unwound on its block (abort path).
|
|
30
|
+
* - `failed` — its reserve threw (drift/overdraw); triggers settlement
|
|
31
|
+
* abort.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SettlementLegStatusSchema: z.ZodEnum<{
|
|
34
|
+
reserved: "reserved";
|
|
35
|
+
committed: "committed";
|
|
36
|
+
released: "released";
|
|
37
|
+
planned: "planned";
|
|
38
|
+
failed: "failed";
|
|
39
|
+
}>;
|
|
40
|
+
export type SettlementLegStatus = z.infer<typeof SettlementLegStatusSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* One leg of a settlement plan as recorded on the coordinator. A transfer is a
|
|
43
|
+
* `debit` leg (source) + a `credit` leg (destination) of equal `amountCents`.
|
|
44
|
+
* `againstHash` pins the leg to the target block's current-state hash at plan
|
|
45
|
+
* time (D5): if the block advanced, the reserve fails and the settlement
|
|
46
|
+
* aborts. `currency` is not carried per-leg — a settlement is single-currency
|
|
47
|
+
* (see the coordinator's `currency`).
|
|
48
|
+
*/
|
|
49
|
+
export declare const ISettlementLegSchema: z.ZodObject<{
|
|
50
|
+
blockId: z.ZodString;
|
|
51
|
+
direction: z.ZodEnum<{
|
|
52
|
+
debit: "debit";
|
|
53
|
+
credit: "credit";
|
|
54
|
+
}>;
|
|
55
|
+
amountCents: z.ZodNumber;
|
|
56
|
+
againstHash: z.ZodString;
|
|
57
|
+
status: z.ZodEnum<{
|
|
58
|
+
reserved: "reserved";
|
|
59
|
+
committed: "committed";
|
|
60
|
+
released: "released";
|
|
61
|
+
planned: "planned";
|
|
62
|
+
failed: "failed";
|
|
63
|
+
}>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type ISettlementLeg = z.infer<typeof ISettlementLegSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* The coordinator ShareBlock's state. A Settlement block is not a money-
|
|
68
|
+
* holding block — its inherited `balance` stays at zero and `participants` is
|
|
69
|
+
* empty; its real payload is the plan (`legs`), the 2PC `phase`, and the
|
|
70
|
+
* timestamps. The block's append-only transaction history is the durable
|
|
71
|
+
* journal that crash-recovery re-drives.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ISettlementShareBlockStateSchema: z.ZodObject<{
|
|
74
|
+
balance: z.ZodNumber;
|
|
75
|
+
isOpen: z.ZodBoolean;
|
|
76
|
+
participants: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
77
|
+
userId: z.ZodString;
|
|
78
|
+
role: z.ZodEnum<{
|
|
79
|
+
Borrower: "Borrower";
|
|
80
|
+
Lender: "Lender";
|
|
81
|
+
Platform: "Platform";
|
|
82
|
+
Recipient: "Recipient";
|
|
83
|
+
}>;
|
|
84
|
+
committedAmount: z.ZodNumber;
|
|
85
|
+
settledAmount: z.ZodNumber;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
reservations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
88
|
+
settlementId: z.ZodString;
|
|
89
|
+
direction: z.ZodEnum<{
|
|
90
|
+
debit: "debit";
|
|
91
|
+
credit: "credit";
|
|
92
|
+
}>;
|
|
93
|
+
amountCents: z.ZodNumber;
|
|
94
|
+
currency: z.ZodString;
|
|
95
|
+
againstHash: z.ZodString;
|
|
96
|
+
status: z.ZodEnum<{
|
|
97
|
+
reserved: "reserved";
|
|
98
|
+
committed: "committed";
|
|
99
|
+
released: "released";
|
|
100
|
+
}>;
|
|
101
|
+
}, z.core.$strip>>>;
|
|
102
|
+
blockType: z.ZodLiteral<"Settlement">;
|
|
103
|
+
settlementId: z.ZodString;
|
|
104
|
+
currency: z.ZodString;
|
|
105
|
+
phase: z.ZodEnum<{
|
|
106
|
+
PREPARING: "PREPARING";
|
|
107
|
+
COMMITTING: "COMMITTING";
|
|
108
|
+
ABORTING: "ABORTING";
|
|
109
|
+
COMMITTED: "COMMITTED";
|
|
110
|
+
ABORTED: "ABORTED";
|
|
111
|
+
}>;
|
|
112
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
113
|
+
blockId: z.ZodString;
|
|
114
|
+
direction: z.ZodEnum<{
|
|
115
|
+
debit: "debit";
|
|
116
|
+
credit: "credit";
|
|
117
|
+
}>;
|
|
118
|
+
amountCents: z.ZodNumber;
|
|
119
|
+
againstHash: z.ZodString;
|
|
120
|
+
status: z.ZodEnum<{
|
|
121
|
+
reserved: "reserved";
|
|
122
|
+
committed: "committed";
|
|
123
|
+
released: "released";
|
|
124
|
+
planned: "planned";
|
|
125
|
+
failed: "failed";
|
|
126
|
+
}>;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
openedAtMs: z.ZodNumber;
|
|
129
|
+
terminalAtMs: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export type ISettlementShareBlockState = z.infer<typeof ISettlementShareBlockStateSchema>;
|
|
132
|
+
/**
|
|
133
|
+
* Input for the coordinator `openSettlement` function — establishes the plan
|
|
134
|
+
* as the first journaled transaction (phase `PREPARING`, every leg `planned`).
|
|
135
|
+
*/
|
|
136
|
+
export declare const ISettlementOpenInputSchema: z.ZodObject<{
|
|
137
|
+
userId: z.ZodString;
|
|
138
|
+
settlementId: z.ZodString;
|
|
139
|
+
currency: z.ZodString;
|
|
140
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
141
|
+
blockId: z.ZodString;
|
|
142
|
+
direction: z.ZodEnum<{
|
|
143
|
+
debit: "debit";
|
|
144
|
+
credit: "credit";
|
|
145
|
+
}>;
|
|
146
|
+
amountCents: z.ZodNumber;
|
|
147
|
+
againstHash: z.ZodString;
|
|
148
|
+
status: z.ZodEnum<{
|
|
149
|
+
reserved: "reserved";
|
|
150
|
+
committed: "committed";
|
|
151
|
+
released: "released";
|
|
152
|
+
planned: "planned";
|
|
153
|
+
failed: "failed";
|
|
154
|
+
}>;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
openedAtMs: z.ZodNumber;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
export type ISettlementOpenInput = z.infer<typeof ISettlementOpenInputSchema>;
|
|
159
|
+
/**
|
|
160
|
+
* Input for `markLegReserved` — advances one leg `planned → reserved` once its
|
|
161
|
+
* block-side reserve succeeds. Legs are addressed by `blockId`.
|
|
162
|
+
*/
|
|
163
|
+
export declare const ISettlementMarkLegReservedInputSchema: z.ZodObject<{
|
|
164
|
+
userId: z.ZodString;
|
|
165
|
+
blockId: z.ZodString;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export type ISettlementMarkLegReservedInput = z.infer<typeof ISettlementMarkLegReservedInputSchema>;
|
|
168
|
+
/**
|
|
169
|
+
* Input for `beginCommit` — the commit point: phase `PREPARING → COMMITTING`.
|
|
170
|
+
* Valid only when every leg is `reserved`.
|
|
171
|
+
*/
|
|
172
|
+
export declare const ISettlementBeginCommitInputSchema: z.ZodObject<{
|
|
173
|
+
userId: z.ZodString;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export type ISettlementBeginCommitInput = z.infer<typeof ISettlementBeginCommitInputSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* Input for `markLegCommitted` — advances one leg `reserved → committed` after
|
|
178
|
+
* its block-side commit lands.
|
|
179
|
+
*/
|
|
180
|
+
export declare const ISettlementMarkLegCommittedInputSchema: z.ZodObject<{
|
|
181
|
+
userId: z.ZodString;
|
|
182
|
+
blockId: z.ZodString;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export type ISettlementMarkLegCommittedInput = z.infer<typeof ISettlementMarkLegCommittedInputSchema>;
|
|
185
|
+
/**
|
|
186
|
+
* Input for `finishCommit` — phase `COMMITTING → COMMITTED` (terminal) once
|
|
187
|
+
* every leg is committed. Stamps `terminalAtMs`.
|
|
188
|
+
*/
|
|
189
|
+
export declare const ISettlementFinishCommitInputSchema: z.ZodObject<{
|
|
190
|
+
userId: z.ZodString;
|
|
191
|
+
terminalAtMs: z.ZodNumber;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
export type ISettlementFinishCommitInput = z.infer<typeof ISettlementFinishCommitInputSchema>;
|
|
194
|
+
/**
|
|
195
|
+
* Input for `beginAbort` — phase `PREPARING → ABORTING` when a leg fails to
|
|
196
|
+
* reserve before the commit point. `reason` is optional audit context.
|
|
197
|
+
*/
|
|
198
|
+
export declare const ISettlementBeginAbortInputSchema: z.ZodObject<{
|
|
199
|
+
userId: z.ZodString;
|
|
200
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export type ISettlementBeginAbortInput = z.infer<typeof ISettlementBeginAbortInputSchema>;
|
|
203
|
+
/**
|
|
204
|
+
* Input for `markLegReleased` — advances a `reserved` leg to `released` after
|
|
205
|
+
* its block-side release unwinds the hold (abort path).
|
|
206
|
+
*/
|
|
207
|
+
export declare const ISettlementMarkLegReleasedInputSchema: z.ZodObject<{
|
|
208
|
+
userId: z.ZodString;
|
|
209
|
+
blockId: z.ZodString;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
export type ISettlementMarkLegReleasedInput = z.infer<typeof ISettlementMarkLegReleasedInputSchema>;
|
|
212
|
+
/**
|
|
213
|
+
* Input for `finishAbort` — phase `ABORTING → ABORTED` (terminal) once every
|
|
214
|
+
* reserved leg is released. Stamps `terminalAtMs`.
|
|
215
|
+
*/
|
|
216
|
+
export declare const ISettlementFinishAbortInputSchema: z.ZodObject<{
|
|
217
|
+
userId: z.ZodString;
|
|
218
|
+
terminalAtMs: z.ZodNumber;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
export type ISettlementFinishAbortInput = z.infer<typeof ISettlementFinishAbortInputSchema>;
|
|
221
|
+
//# sourceMappingURL=settlement-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement-models.d.ts","sourceRoot":"","sources":["../../../src/models/settlement/settlement-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AASpB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB;;;;;;EAMhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB;;;;;;EAMpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAM5E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;iBAM/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAM1F;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;iBAMrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,qCAAqC;;;iBAGhD,CAAC;AACH,MAAM,MAAM,+BAA+B,GACvC,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;iBAE5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GACnC,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sCAAsC;;;iBAGjD,CAAC;AACH,MAAM,MAAM,gCAAgC,GACxC,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,kCAAkC;;;iBAG7C,CAAC;AACH,MAAM,MAAM,4BAA4B,GACpC,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAClC,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,qCAAqC;;;iBAGhD,CAAC;AACH,MAAM,MAAM,+BAA+B,GACvC,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;;iBAG5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GACnC,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ISettlementFinishAbortInputSchema = exports.ISettlementMarkLegReleasedInputSchema = exports.ISettlementBeginAbortInputSchema = exports.ISettlementFinishCommitInputSchema = exports.ISettlementMarkLegCommittedInputSchema = exports.ISettlementBeginCommitInputSchema = exports.ISettlementMarkLegReservedInputSchema = exports.ISettlementOpenInputSchema = exports.ISettlementShareBlockStateSchema = exports.ISettlementLegSchema = exports.SettlementLegStatusSchema = exports.SettlementPhaseSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const shareblock_models_1 = require("../shareblock/shareblock-models");
|
|
9
|
+
//#region Phase + leg status
|
|
10
|
+
/**
|
|
11
|
+
* Two-phase-commit phase of a settlement, journaled on the coordinator's
|
|
12
|
+
* state. The legal transition graph (enforced by `buildSettlementPhaseRule`):
|
|
13
|
+
*
|
|
14
|
+
* PREPARING ──▶ COMMITTING ──▶ COMMITTED (terminal)
|
|
15
|
+
* │
|
|
16
|
+
* └────────▶ ABORTING ──▶ ABORTED (terminal)
|
|
17
|
+
*
|
|
18
|
+
* `COMMITTING` is the point of no return: once reached, every leg was already
|
|
19
|
+
* reserved, so the settlement can only roll forward. Failures before that
|
|
20
|
+
* point route to `ABORTING`. Terminals are sinks.
|
|
21
|
+
*/
|
|
22
|
+
exports.SettlementPhaseSchema = zod_1.default.enum([
|
|
23
|
+
'PREPARING',
|
|
24
|
+
'COMMITTING',
|
|
25
|
+
'ABORTING',
|
|
26
|
+
'COMMITTED',
|
|
27
|
+
'ABORTED',
|
|
28
|
+
]);
|
|
29
|
+
/**
|
|
30
|
+
* Per-leg status as tracked by the coordinator (a superset of the member
|
|
31
|
+
* block's `ReservationStatus`):
|
|
32
|
+
*
|
|
33
|
+
* - `planned` — in the plan, not yet reserved on its block.
|
|
34
|
+
* - `reserved` — successfully held on its block (PREPARE done for this leg).
|
|
35
|
+
* - `committed` — finalized on its block.
|
|
36
|
+
* - `released` — unwound on its block (abort path).
|
|
37
|
+
* - `failed` — its reserve threw (drift/overdraw); triggers settlement
|
|
38
|
+
* abort.
|
|
39
|
+
*/
|
|
40
|
+
exports.SettlementLegStatusSchema = zod_1.default.enum([
|
|
41
|
+
'planned',
|
|
42
|
+
'reserved',
|
|
43
|
+
'committed',
|
|
44
|
+
'released',
|
|
45
|
+
'failed',
|
|
46
|
+
]);
|
|
47
|
+
//#endregion Phase + leg status
|
|
48
|
+
//#region Leg + coordinator state
|
|
49
|
+
/**
|
|
50
|
+
* One leg of a settlement plan as recorded on the coordinator. A transfer is a
|
|
51
|
+
* `debit` leg (source) + a `credit` leg (destination) of equal `amountCents`.
|
|
52
|
+
* `againstHash` pins the leg to the target block's current-state hash at plan
|
|
53
|
+
* time (D5): if the block advanced, the reserve fails and the settlement
|
|
54
|
+
* aborts. `currency` is not carried per-leg — a settlement is single-currency
|
|
55
|
+
* (see the coordinator's `currency`).
|
|
56
|
+
*/
|
|
57
|
+
exports.ISettlementLegSchema = zod_1.default.object({
|
|
58
|
+
blockId: zod_1.default.string(),
|
|
59
|
+
direction: shareblock_models_1.SettlementLegDirectionSchema,
|
|
60
|
+
amountCents: zod_1.default.number().int().positive(),
|
|
61
|
+
againstHash: zod_1.default.string(),
|
|
62
|
+
status: exports.SettlementLegStatusSchema,
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* The coordinator ShareBlock's state. A Settlement block is not a money-
|
|
66
|
+
* holding block — its inherited `balance` stays at zero and `participants` is
|
|
67
|
+
* empty; its real payload is the plan (`legs`), the 2PC `phase`, and the
|
|
68
|
+
* timestamps. The block's append-only transaction history is the durable
|
|
69
|
+
* journal that crash-recovery re-drives.
|
|
70
|
+
*/
|
|
71
|
+
exports.ISettlementShareBlockStateSchema = shareblock_models_1.IShareBlockStateSchema.extend({
|
|
72
|
+
blockType: zod_1.default.literal(shareblock_models_1.ShareBlockTypeSchema.enum.Settlement),
|
|
73
|
+
settlementId: zod_1.default.string(),
|
|
74
|
+
// Opaque currency code; equality-checked against member legs, never
|
|
75
|
+
// converted. Loosened from the base `min(3).max(3)` per the settlement
|
|
76
|
+
// design (one settlement = one currency).
|
|
77
|
+
currency: zod_1.default.string(),
|
|
78
|
+
phase: exports.SettlementPhaseSchema,
|
|
79
|
+
legs: zod_1.default.array(exports.ISettlementLegSchema),
|
|
80
|
+
openedAtMs: zod_1.default.number().int().nonnegative(),
|
|
81
|
+
/** Stamped when the block reaches a terminal phase (COMMITTED/ABORTED). */
|
|
82
|
+
terminalAtMs: zod_1.default.number().int().nonnegative().optional(),
|
|
83
|
+
});
|
|
84
|
+
//#endregion Leg + coordinator state
|
|
85
|
+
//#region Coordinator function inputs
|
|
86
|
+
/**
|
|
87
|
+
* Input for the coordinator `openSettlement` function — establishes the plan
|
|
88
|
+
* as the first journaled transaction (phase `PREPARING`, every leg `planned`).
|
|
89
|
+
*/
|
|
90
|
+
exports.ISettlementOpenInputSchema = zod_1.default.object({
|
|
91
|
+
userId: zod_1.default.string(),
|
|
92
|
+
settlementId: zod_1.default.string(),
|
|
93
|
+
currency: zod_1.default.string(),
|
|
94
|
+
legs: zod_1.default.array(exports.ISettlementLegSchema),
|
|
95
|
+
openedAtMs: zod_1.default.number().int().nonnegative(),
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Input for `markLegReserved` — advances one leg `planned → reserved` once its
|
|
99
|
+
* block-side reserve succeeds. Legs are addressed by `blockId`.
|
|
100
|
+
*/
|
|
101
|
+
exports.ISettlementMarkLegReservedInputSchema = zod_1.default.object({
|
|
102
|
+
userId: zod_1.default.string(),
|
|
103
|
+
blockId: zod_1.default.string(),
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Input for `beginCommit` — the commit point: phase `PREPARING → COMMITTING`.
|
|
107
|
+
* Valid only when every leg is `reserved`.
|
|
108
|
+
*/
|
|
109
|
+
exports.ISettlementBeginCommitInputSchema = zod_1.default.object({
|
|
110
|
+
userId: zod_1.default.string(),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Input for `markLegCommitted` — advances one leg `reserved → committed` after
|
|
114
|
+
* its block-side commit lands.
|
|
115
|
+
*/
|
|
116
|
+
exports.ISettlementMarkLegCommittedInputSchema = zod_1.default.object({
|
|
117
|
+
userId: zod_1.default.string(),
|
|
118
|
+
blockId: zod_1.default.string(),
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Input for `finishCommit` — phase `COMMITTING → COMMITTED` (terminal) once
|
|
122
|
+
* every leg is committed. Stamps `terminalAtMs`.
|
|
123
|
+
*/
|
|
124
|
+
exports.ISettlementFinishCommitInputSchema = zod_1.default.object({
|
|
125
|
+
userId: zod_1.default.string(),
|
|
126
|
+
terminalAtMs: zod_1.default.number().int().nonnegative(),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Input for `beginAbort` — phase `PREPARING → ABORTING` when a leg fails to
|
|
130
|
+
* reserve before the commit point. `reason` is optional audit context.
|
|
131
|
+
*/
|
|
132
|
+
exports.ISettlementBeginAbortInputSchema = zod_1.default.object({
|
|
133
|
+
userId: zod_1.default.string(),
|
|
134
|
+
reason: zod_1.default.string().optional(),
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Input for `markLegReleased` — advances a `reserved` leg to `released` after
|
|
138
|
+
* its block-side release unwinds the hold (abort path).
|
|
139
|
+
*/
|
|
140
|
+
exports.ISettlementMarkLegReleasedInputSchema = zod_1.default.object({
|
|
141
|
+
userId: zod_1.default.string(),
|
|
142
|
+
blockId: zod_1.default.string(),
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* Input for `finishAbort` — phase `ABORTING → ABORTED` (terminal) once every
|
|
146
|
+
* reserved leg is released. Stamps `terminalAtMs`.
|
|
147
|
+
*/
|
|
148
|
+
exports.ISettlementFinishAbortInputSchema = zod_1.default.object({
|
|
149
|
+
userId: zod_1.default.string(),
|
|
150
|
+
terminalAtMs: zod_1.default.number().int().nonnegative(),
|
|
151
|
+
});
|
|
152
|
+
//#endregion Coordinator function inputs
|
|
@@ -26,6 +26,7 @@ export declare const PersistedCreationConfigSchema: z.ZodObject<{
|
|
|
26
26
|
Funding: "Funding";
|
|
27
27
|
Distribution: "Distribution";
|
|
28
28
|
GraceRepayment: "GraceRepayment";
|
|
29
|
+
Settlement: "Settlement";
|
|
29
30
|
}>;
|
|
30
31
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
31
32
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -98,6 +99,7 @@ export declare const PersistedShareDataSchema: z.ZodObject<{
|
|
|
98
99
|
Funding: "Funding";
|
|
99
100
|
Distribution: "Distribution";
|
|
100
101
|
GraceRepayment: "GraceRepayment";
|
|
102
|
+
Settlement: "Settlement";
|
|
101
103
|
}>;
|
|
102
104
|
signingCurve: z.ZodEnum<{
|
|
103
105
|
ed25519: EllipticalCurvesSigning.Curve25519;
|
|
@@ -117,6 +119,7 @@ export declare const PersistedShareDataSchema: z.ZodObject<{
|
|
|
117
119
|
Funding: "Funding";
|
|
118
120
|
Distribution: "Distribution";
|
|
119
121
|
GraceRepayment: "GraceRepayment";
|
|
122
|
+
Settlement: "Settlement";
|
|
120
123
|
}>;
|
|
121
124
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
122
125
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-data-persistence-models.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data-persistence-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAEH,cAAc,EAEjB,MAAM,iCAAiC,CAAC;AAmBzC;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;EAGtC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B
|
|
1
|
+
{"version":3,"file":"share-data-persistence-models.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data-persistence-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAEH,cAAc,EAEjB,MAAM,iCAAiC,CAAC;AAmBzC;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;EAGtC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACpC,SAAS,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,uBAAuB,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;iBAOrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,sDAAsD;AACtD,eAAO,MAAM,mCAAmC,EAAG,CAAU,CAAC"}
|