@lifi/compose-spec 0.7.1 → 0.9.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 +1 -1
- package/dist/index.cjs +1018 -1144
- package/dist/index.d.cts +1693 -1996
- package/dist/index.d.ts +1693 -1996
- package/dist/index.js +926 -1032
- package/package.json +3 -3
- package/src/chainCapabilities.ts +3 -3
- package/src/compile.ts +4 -4
- package/src/continuation.ts +24 -80
- package/src/descriptor.ts +8 -8
- package/src/flowSchema.ts +6 -6
- package/src/index.ts +0 -11
- package/src/output.ts +7 -4
- package/src/zodSchemas.ts +17 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/compose-spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Public wire-format types and schemas for Compose flows",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "yarn check:types &&
|
|
32
|
+
"build": "yarn check:types && tsdown",
|
|
33
33
|
"check:types": "tsc --noEmit",
|
|
34
34
|
"clean": "rm -rf dist out",
|
|
35
35
|
"pack:local": "yarn build && mkdir -p out && yarn pack --out 'out/%s-%v.tgz'",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
55
55
|
"eslint-plugin-import": "^2.22.0",
|
|
56
56
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
57
|
-
"
|
|
57
|
+
"tsdown": "^0.23.0",
|
|
58
58
|
"typescript": "^6.0.3",
|
|
59
59
|
"vitest": "^3.2.4"
|
|
60
60
|
},
|
package/src/chainCapabilities.ts
CHANGED
|
@@ -190,9 +190,9 @@ export const foldChainCapabilities = <R>(
|
|
|
190
190
|
* check pass 1e12 too easily. The check must be authored as
|
|
191
191
|
* `erc20BalanceGte` of the facade; `reason` says so.
|
|
192
192
|
*
|
|
193
|
-
* Consumers (the `
|
|
194
|
-
*
|
|
195
|
-
*
|
|
193
|
+
* Consumers (the `AssertedPredicateSchema` decode and compose-core's derive
|
|
194
|
+
* backstop) are adapters over this result, so the unit rule lives in one place
|
|
195
|
+
* and the fold's exhaustiveness reaches every site.
|
|
196
196
|
*/
|
|
197
197
|
export type NativeCheckPolicy =
|
|
198
198
|
| { readonly kind: 'keep' }
|
package/src/compile.ts
CHANGED
|
@@ -187,10 +187,10 @@ export interface ComposeCompileSuccessData extends ComposeContinuationData {
|
|
|
187
187
|
readonly fill?: ComposeFill;
|
|
188
188
|
// The C4 verification echo, keyed by the flow node that carried the
|
|
189
189
|
// commitment (the `continuation.commitment` node on a settlement
|
|
190
|
-
// re-submission,
|
|
191
|
-
// verification). Present only when the compile
|
|
192
|
-
//
|
|
193
|
-
// committed
|
|
190
|
+
// re-submission, each committing `continuation.settle` node on
|
|
191
|
+
// authoring-time provider verification). Present only when the compile
|
|
192
|
+
// committed a validation program; one entry per committing node, so a
|
|
193
|
+
// fan-out across committed settles carries several.
|
|
194
194
|
readonly verificationByNode?: Record<string, VerificationDescriptor>;
|
|
195
195
|
}
|
|
196
196
|
|
package/src/continuation.ts
CHANGED
|
@@ -94,7 +94,9 @@ export const HexStringSchema = Schema.String.pipe(Schema.startsWith('0x'));
|
|
|
94
94
|
// the funding user, so the pair identifies that user's escrow on the chain,
|
|
95
95
|
// not one settlement.
|
|
96
96
|
// - `token` + `amount` — the funding asset (native → `EVM_NATIVE_SENTINEL`)
|
|
97
|
-
// and the raw amount the
|
|
97
|
+
// and the raw amount the escrow was sized from. The program transfers the
|
|
98
|
+
// amount realised at execution, which can differ when an upstream op
|
|
99
|
+
// supplies the funding.
|
|
98
100
|
// - `cap` — the committed funding allocation: the most a fill may spend from
|
|
99
101
|
// the escrow. A balance above it stays in the escrow.
|
|
100
102
|
// - `owner` — the account that controls the escrow and can sweep it.
|
|
@@ -140,10 +142,9 @@ export const Phase1ArtifactSchema = Schema.Union(
|
|
|
140
142
|
Schema.Struct({ kind: Schema.Literal('none') }),
|
|
141
143
|
);
|
|
142
144
|
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
// safely. Amounts are decimal strings on the wire because JSON has no bigint.
|
|
145
|
+
// The absolute assertion members of `AssertionSpec` below: each is a predicate
|
|
146
|
+
// over on-chain state that a derived validation program enforces. Amounts are
|
|
147
|
+
// decimal strings on the wire because JSON has no bigint.
|
|
147
148
|
//
|
|
148
149
|
// - `erc20BalanceGte` — `owner`'s balance of `token` on `chainId` is at least
|
|
149
150
|
// `minAmount`.
|
|
@@ -162,21 +163,18 @@ export const Phase1ArtifactSchema = Schema.Union(
|
|
|
162
163
|
// hex; the two symbolic owners `"escrow"` / `"delivery"` are resolved to
|
|
163
164
|
// validator-injected register handles at settlement time (see the
|
|
164
165
|
// verified-continuations derivation). This widening applies ONLY to the
|
|
165
|
-
// derivation-only delta members below — never to the
|
|
166
|
-
//
|
|
167
|
-
// has no injected slot, so a symbolic owner there cannot be resolved (it would
|
|
168
|
-
// throw at lowering); keeping `Check` owners hex-only rejects such a value
|
|
169
|
-
// cleanly at validation instead.
|
|
166
|
+
// derivation-only delta members below — never to the three absolute members,
|
|
167
|
+
// whose owner is always a concrete address once an invariant is captured.
|
|
170
168
|
export const AssertionOwnerSchema = Schema.Union(
|
|
171
169
|
EVMAddressString,
|
|
172
170
|
Schema.Literal('escrow', 'delivery'),
|
|
173
171
|
);
|
|
174
172
|
export type AssertionOwner = typeof AssertionOwnerSchema.Type;
|
|
175
173
|
|
|
176
|
-
// The three
|
|
177
|
-
//
|
|
178
|
-
// `owner` is hex-only: a captured invariant always resolves to a
|
|
179
|
-
// address
|
|
174
|
+
// The three absolute members are exported by name so `AssertionSpecSchema` and
|
|
175
|
+
// the descriptor's predicate union can reuse them without re-declaring their
|
|
176
|
+
// shape. Their `owner` is hex-only: a captured invariant always resolves to a
|
|
177
|
+
// concrete address.
|
|
180
178
|
export const Erc20BalanceGteSpecSchema = Schema.Struct({
|
|
181
179
|
kind: Schema.Literal('erc20BalanceGte'),
|
|
182
180
|
chainId: ChainIdSchema,
|
|
@@ -201,9 +199,9 @@ export const CallCheckSpecSchema = Schema.Struct({
|
|
|
201
199
|
value: IntegerString,
|
|
202
200
|
});
|
|
203
201
|
|
|
204
|
-
// The shape shared by the
|
|
205
|
-
// symbolic-owner variant. `owner` is `string` for both
|
|
206
|
-
// collapses to `string`).
|
|
202
|
+
// The shape shared by the hex-owner `nativeBalanceGte` spec and the
|
|
203
|
+
// descriptor's symbolic-owner variant. `owner` is `string` for both
|
|
204
|
+
// (`AssertionOwnerSchema.Type` collapses to `string`).
|
|
207
205
|
interface NativeBalanceGteLike {
|
|
208
206
|
readonly kind: 'nativeBalanceGte';
|
|
209
207
|
readonly chainId: number;
|
|
@@ -228,10 +226,9 @@ const asErc20BalanceGteCheck = (
|
|
|
228
226
|
// Decode adapter over `nativeCheckPolicy` (`chainCapabilities.ts` holds the
|
|
229
227
|
// unit reasoning): a `nativeBalanceGte` check is kept on an evm-native chain,
|
|
230
228
|
// rewritten to `erc20BalanceGte` of the stand-in ERC-20 on an `as-erc20`
|
|
231
|
-
// chain, and rejected on a `native-mirrored-erc20` chain.
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
// (authoring↔settlement hash parity).
|
|
229
|
+
// chain, and rejected on a `native-mirrored-erc20` chain. Used by the
|
|
230
|
+
// descriptor's `AssertedPredicateSchema` so the disclosed and the committed
|
|
231
|
+
// predicate derive the same program (authoring↔settlement hash parity).
|
|
235
232
|
export const decodeNativeBalanceGte = <C extends NativeBalanceGteLike>(
|
|
236
233
|
check: C,
|
|
237
234
|
ast: SchemaAST.AST,
|
|
@@ -250,40 +247,18 @@ export const decodeNativeBalanceGte = <C extends NativeBalanceGteLike>(
|
|
|
250
247
|
}
|
|
251
248
|
};
|
|
252
249
|
|
|
253
|
-
// The pre-transform union of the three named members.
|
|
254
|
-
const RawCheckSchema = Schema.Union(
|
|
255
|
-
Erc20BalanceGteSpecSchema,
|
|
256
|
-
NativeBalanceGteSpecSchema,
|
|
257
|
-
CallCheckSpecSchema,
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
// Only `nativeBalanceGte` is touched (via `decodeNativeBalanceGte`); every
|
|
261
|
-
// other member decodes unchanged. Encode is the identity.
|
|
262
|
-
export const CheckSchema = Schema.transformOrFail(
|
|
263
|
-
RawCheckSchema,
|
|
264
|
-
Schema.typeSchema(RawCheckSchema),
|
|
265
|
-
{
|
|
266
|
-
strict: true,
|
|
267
|
-
decode: (check, _options, ast) =>
|
|
268
|
-
check.kind === 'nativeBalanceGte'
|
|
269
|
-
? decodeNativeBalanceGte(check, ast)
|
|
270
|
-
: ParseResult.succeed(check),
|
|
271
|
-
encode: (check) => ParseResult.succeed(check),
|
|
272
|
-
},
|
|
273
|
-
);
|
|
274
|
-
|
|
275
250
|
// The derivation vocabulary (verified continuations, plan GD-1). An
|
|
276
251
|
// `AssertionSpec` is the structured, backend-neutral form of one invariant a
|
|
277
252
|
// derived validation program must enforce against the executor's re-quoted
|
|
278
|
-
// fill. It extends the three
|
|
279
|
-
// derivation-only members. Amounts stay decimal strings on the wire
|
|
280
|
-
// `Check`.
|
|
253
|
+
// fill. It extends the three absolute members above (reused verbatim) with two
|
|
254
|
+
// derivation-only members. Amounts stay decimal strings on the wire.
|
|
281
255
|
//
|
|
282
256
|
// - `erc20BalanceDeltaGte` / `nativeBalanceDeltaGte` — `owner`'s post-fill
|
|
283
257
|
// balance of `token` (native) on `chainId` must exceed its pre-fill balance
|
|
284
|
-
// by at least `minDelta`.
|
|
285
|
-
//
|
|
286
|
-
//
|
|
258
|
+
// by at least `minDelta`. The settlement validator already checks each
|
|
259
|
+
// committed outcome's floor itself, so the derivation lowers neither kind
|
|
260
|
+
// into a program and rejects them as an authored invariant; they stay in
|
|
261
|
+
// the vocabulary so a descriptor that carries one still decodes.
|
|
287
262
|
export const Erc20BalanceDeltaGteSpecSchema = Schema.Struct({
|
|
288
263
|
kind: Schema.Literal('erc20BalanceDeltaGte'),
|
|
289
264
|
chainId: ChainIdSchema,
|
|
@@ -307,27 +282,10 @@ export const AssertionSpecSchema = Schema.Union(
|
|
|
307
282
|
NativeBalanceDeltaGteSpecSchema,
|
|
308
283
|
);
|
|
309
284
|
|
|
310
|
-
// The continuation plan returned to the caller for a self-serve (manual-relay)
|
|
311
|
-
// settle node: the next Flow to run plus a readiness `check`. The caller polls
|
|
312
|
-
// the `check`, then re-submits `nextFlow` through the normal `/compose`
|
|
313
|
-
// pipeline once it passes. The `check` is also embedded into `nextFlow` as an
|
|
314
|
-
// on-chain assertion, so a premature re-submission reverts instead of executing
|
|
315
|
-
// on stale balances. `FlowSchema` lives in the same package, so importing it
|
|
316
|
-
// here keeps `compose-spec` dependency-free.
|
|
317
|
-
export const ContinuationPlanSchema = Schema.Struct({
|
|
318
|
-
chainId: ChainIdSchema,
|
|
319
|
-
nextFlow: FlowSchema,
|
|
320
|
-
check: CheckSchema,
|
|
321
|
-
validity: Schema.Struct({ expiresAtMs: EpochMsSchema }),
|
|
322
|
-
correlationId: Schema.optional(Schema.String),
|
|
323
|
-
});
|
|
324
|
-
|
|
325
285
|
export type ContinuationOutcome = typeof ContinuationOutcomeSchema.Type;
|
|
326
286
|
export type ContinuationIntent = typeof ContinuationIntentSchema.Type;
|
|
327
287
|
export type Phase1Artifact = typeof Phase1ArtifactSchema.Type;
|
|
328
|
-
export type Check = typeof CheckSchema.Type;
|
|
329
288
|
export type AssertionSpec = typeof AssertionSpecSchema.Type;
|
|
330
|
-
export type ContinuationPlan = typeof ContinuationPlanSchema.Type;
|
|
331
289
|
|
|
332
290
|
// The outcome a `continuation.settle` node's single `output` port stands for.
|
|
333
291
|
// The wire format admits several outcomes, but the op produces one resource,
|
|
@@ -338,17 +296,3 @@ export type ContinuationPlan = typeof ContinuationPlanSchema.Type;
|
|
|
338
296
|
export const settledOutcome = (
|
|
339
297
|
intent: ContinuationIntent,
|
|
340
298
|
): ContinuationOutcome => intent.outcomes[0];
|
|
341
|
-
|
|
342
|
-
// The comparison operator carried by a `call` check. Mirrors the inline
|
|
343
|
-
// `comparator` literal on the `call` member of `RawCheckSchema` above.
|
|
344
|
-
export type CheckComparator = 'gte' | 'eq' | 'lte';
|
|
345
|
-
|
|
346
|
-
// Comparator predicates for `call` checks, matching the package's `is*`
|
|
347
|
-
// convention (see `flow.ts`). Each is only true for a `call` check with the
|
|
348
|
-
// corresponding comparator; the other check kinds carry no comparator.
|
|
349
|
-
export const isGTECheck = (check: Check): boolean =>
|
|
350
|
-
check.kind === 'call' && check.comparator === 'gte';
|
|
351
|
-
export const isLTECheck = (check: Check): boolean =>
|
|
352
|
-
check.kind === 'call' && check.comparator === 'lte';
|
|
353
|
-
export const isEQCheck = (check: Check): boolean =>
|
|
354
|
-
check.kind === 'call' && check.comparator === 'eq';
|
package/src/descriptor.ts
CHANGED
|
@@ -29,8 +29,8 @@ import { BYTES32_LOWER_HEX } from './hexPatterns.js';
|
|
|
29
29
|
|
|
30
30
|
// `ChainIdSchema`, `EVMAddressString` and `IntegerString` (from
|
|
31
31
|
// `flowSchema.ts`) are reused directly, so the widened members below differ
|
|
32
|
-
// from their
|
|
33
|
-
// risk of a drifting re-declaration.
|
|
32
|
+
// from their `AssertionSpec` counterparts in exactly one field (`owner`) with
|
|
33
|
+
// no risk of a drifting re-declaration.
|
|
34
34
|
|
|
35
35
|
// The `validationProgramHash` (GD-2, seam C1): `keccak256` over the canonical
|
|
36
36
|
// program body. Strict 32-byte lowercase hex (`BYTES32_LOWER_HEX`) — see the
|
|
@@ -39,13 +39,13 @@ export const Bytes32HexSchema = Schema.String.pipe(
|
|
|
39
39
|
Schema.pattern(BYTES32_LOWER_HEX),
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
// The disclosure-path widening of the two balance-`Gte`
|
|
42
|
+
// The disclosure-path widening of the two balance-`Gte` assertion members: same
|
|
43
43
|
// fields as their `continuation.ts` counterparts, but `owner` accepts a symbolic
|
|
44
44
|
// `"escrow"`/`"delivery"` too. The derivation genuinely produces such values —
|
|
45
45
|
// a captured invariant can carry a symbolic owner, which `resolveOwner` maps to
|
|
46
46
|
// a validator-injected slot at settlement (see the `uc1` invariant). The
|
|
47
|
-
//
|
|
48
|
-
//
|
|
47
|
+
// `AssertionSpec` members stay hex-only, so this widening lives in the
|
|
48
|
+
// descriptor union only.
|
|
49
49
|
export const AssertedErc20BalanceGteSpecSchema = Schema.Struct({
|
|
50
50
|
kind: Schema.Literal('erc20BalanceGte'),
|
|
51
51
|
chainId: ChainIdSchema,
|
|
@@ -73,10 +73,10 @@ const RawAssertedPredicateSchema = Schema.Union(
|
|
|
73
73
|
NativeBalanceDeltaGteSpecSchema,
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
-
//
|
|
76
|
+
// `nativeBalanceGte` handling via `decodeNativeBalanceGte`, applied to the
|
|
77
77
|
// disclosed/committed predicate so settlement derives the identical program.
|
|
78
|
-
// Idempotent on
|
|
79
|
-
//
|
|
78
|
+
// Idempotent on already-normalized predicates; normalizes or refuses a
|
|
79
|
+
// hand-forged committed action that embeds a raw native check. The delta
|
|
80
80
|
// members are untouched — they derive from already-normalized outcomes.
|
|
81
81
|
export const AssertedPredicateSchema = Schema.transformOrFail(
|
|
82
82
|
RawAssertedPredicateSchema,
|
package/src/flowSchema.ts
CHANGED
|
@@ -162,7 +162,7 @@ export const AppliedGuardSchema = Schema.Struct(
|
|
|
162
162
|
// plain objects, and `__proto__` there sets the prototype instead of adding a
|
|
163
163
|
// key; the response serializer's `z.record` also drops a `__proto__` key. So
|
|
164
164
|
// the id can never round-trip, and the one flow schema rejects it for every
|
|
165
|
-
// flow it decodes, including an embedded
|
|
165
|
+
// flow it decodes, including an embedded `continuationFlow`.
|
|
166
166
|
const NodeIdSchema = Schema.String.pipe(
|
|
167
167
|
Schema.filter((id) => id !== '__proto__', {
|
|
168
168
|
message: () => 'node id "__proto__" is reserved; choose another node id',
|
|
@@ -190,9 +190,9 @@ export const UuidSchema = Schema.String.pipe(
|
|
|
190
190
|
);
|
|
191
191
|
|
|
192
192
|
// Journey lineage of a non-atomic flow (COM-1253). The server writes it into
|
|
193
|
-
// every flow it hands out for a later compile —
|
|
194
|
-
//
|
|
195
|
-
//
|
|
193
|
+
// every flow it hands out for a later compile — today an intent-factory
|
|
194
|
+
// committed action — so a journey's legs share one id without the caller
|
|
195
|
+
// carrying anything. A root flow has no `lineage`.
|
|
196
196
|
//
|
|
197
197
|
// It has no program semantics: nothing lowers it and nothing executes it. Only
|
|
198
198
|
// the compile pipeline (which turns it into the on-chain `ProgramExecution`
|
|
@@ -200,8 +200,8 @@ export const UuidSchema = Schema.String.pipe(
|
|
|
200
200
|
//
|
|
201
201
|
// Trust: a caller may hand-write or copy a stamp and the system accepts it.
|
|
202
202
|
// The link is server-asserted where the flow is committed (intent-factory
|
|
203
|
-
// registers the stamped blob) and telemetry-grade
|
|
204
|
-
//
|
|
203
|
+
// registers the stamped blob) and telemetry-grade on any flow the caller
|
|
204
|
+
// posts with a stamp it wrote itself.
|
|
205
205
|
export const LineageSchema = Schema.Struct({
|
|
206
206
|
journeyId: UuidSchema,
|
|
207
207
|
parentRequestId: UuidSchema,
|
package/src/index.ts
CHANGED
|
@@ -33,11 +33,8 @@ export type {
|
|
|
33
33
|
ContinuationOutcome,
|
|
34
34
|
ContinuationIntent,
|
|
35
35
|
Phase1Artifact,
|
|
36
|
-
Check,
|
|
37
|
-
CheckComparator,
|
|
38
36
|
AssertionOwner,
|
|
39
37
|
AssertionSpec,
|
|
40
|
-
ContinuationPlan,
|
|
41
38
|
} from './continuation.js';
|
|
42
39
|
export {
|
|
43
40
|
CONTINUATION_COMMITMENT_OP_ID,
|
|
@@ -45,7 +42,6 @@ export {
|
|
|
45
42
|
ContinuationOutcomeSchema,
|
|
46
43
|
ContinuationIntentSchema,
|
|
47
44
|
Phase1ArtifactSchema,
|
|
48
|
-
CheckSchema,
|
|
49
45
|
AssertionOwnerSchema,
|
|
50
46
|
Erc20BalanceGteSpecSchema,
|
|
51
47
|
NativeBalanceGteSpecSchema,
|
|
@@ -53,10 +49,6 @@ export {
|
|
|
53
49
|
Erc20BalanceDeltaGteSpecSchema,
|
|
54
50
|
NativeBalanceDeltaGteSpecSchema,
|
|
55
51
|
AssertionSpecSchema,
|
|
56
|
-
ContinuationPlanSchema,
|
|
57
|
-
isGTECheck,
|
|
58
|
-
isLTECheck,
|
|
59
|
-
isEQCheck,
|
|
60
52
|
settledOutcome,
|
|
61
53
|
} from './continuation.js';
|
|
62
54
|
|
|
@@ -306,11 +298,9 @@ export {
|
|
|
306
298
|
GuardSelectorZod,
|
|
307
299
|
GuardCompatibilityZod,
|
|
308
300
|
SettlementZod,
|
|
309
|
-
CheckZod,
|
|
310
301
|
AssertionSpecZod,
|
|
311
302
|
AssertedPredicateZod,
|
|
312
303
|
VerificationDescriptorZod,
|
|
313
|
-
ContinuationPlanZod,
|
|
314
304
|
} from './zodSchemas.js';
|
|
315
305
|
export type {
|
|
316
306
|
HandleUnits,
|
|
@@ -320,5 +310,4 @@ export type {
|
|
|
320
310
|
AssertionSpecWire,
|
|
321
311
|
AssertedPredicateWire,
|
|
322
312
|
VerificationDescriptorWire,
|
|
323
|
-
ContinuationPlanWire,
|
|
324
313
|
} from './zodSchemas.js';
|
package/src/output.ts
CHANGED
|
@@ -7,10 +7,13 @@ import type { Resource } from './resource.js';
|
|
|
7
7
|
// declares `omitIfZero` and the simulation measured it at zero. `estimate` is
|
|
8
8
|
// the measured value when the simulation observed the port, otherwise the
|
|
9
9
|
// prepared op's quote, otherwise absent. `minimum` is the enforced floor: the
|
|
10
|
-
// larger of a guard floor and an op floor when either exists
|
|
11
|
-
//
|
|
12
|
-
// `providesMinimum` (`declared`), else
|
|
13
|
-
//
|
|
10
|
+
// larger of a guard floor and an op floor when either exists, tagged `guard`
|
|
11
|
+
// only when the guard floor is strictly larger (`op` on a tie), else the
|
|
12
|
+
// estimate echoed when the port declares `providesMinimum` (`declared`), else
|
|
13
|
+
// absent. A port behind pure ops carries the floor those ops pass on from the
|
|
14
|
+
// enforced floors and declared input amounts upstream, tagged by the same
|
|
15
|
+
// rule. There is no zero placeholder; an absent `minimum` means no floor is
|
|
16
|
+
// known.
|
|
14
17
|
|
|
15
18
|
export type EstimateBasis = 'simulated' | 'quoted';
|
|
16
19
|
|
package/src/zodSchemas.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
DECIMAL_UINT,
|
|
6
6
|
EVM_ADDRESS_HEX,
|
|
7
7
|
HEX_BYTES,
|
|
8
|
-
MAX_DATE_MS,
|
|
9
8
|
MAX_UINT256,
|
|
10
9
|
} from './hexPatterns.js';
|
|
11
10
|
|
|
@@ -13,9 +12,9 @@ import {
|
|
|
13
12
|
// `flowSchema.ts`, single-sourced so the wire schemas stay consistent.
|
|
14
13
|
export const chainIdZod = z.number().int().positive();
|
|
15
14
|
|
|
16
|
-
// Zod mirrors of `EVMAddressString`, `HexBytesString
|
|
17
|
-
// `
|
|
18
|
-
//
|
|
15
|
+
// Zod mirrors of `EVMAddressString`, `HexBytesString` and `IntegerString` in
|
|
16
|
+
// `flowSchema.ts`, built from the same `hexPatterns.ts` constants.
|
|
17
|
+
// `continuationParity.spec.ts` holds the two sides in lockstep.
|
|
19
18
|
const evmAddressZod = z.string().regex(EVM_ADDRESS_HEX);
|
|
20
19
|
const hexBytesZod = z.string().regex(HEX_BYTES);
|
|
21
20
|
// One refinement, like `IntegerString`'s filter: Zod runs later checks after
|
|
@@ -26,7 +25,6 @@ const uintStringZod = z
|
|
|
26
25
|
.refine((value) => DECIMAL_UINT.test(value) && BigInt(value) <= MAX_UINT256, {
|
|
27
26
|
message: 'expected a uint256 decimal integer string',
|
|
28
27
|
});
|
|
29
|
-
const epochMsZod = z.number().int().min(-MAX_DATE_MS).max(MAX_DATE_MS);
|
|
30
28
|
|
|
31
29
|
const SolTypeZod = z.enum([
|
|
32
30
|
'uint8',
|
|
@@ -216,17 +214,17 @@ export const SettlementEscrowZod = z.object({
|
|
|
216
214
|
|
|
217
215
|
// Mirror of `AssertionOwnerSchema` (continuation.ts): a concrete address or
|
|
218
216
|
// one of the two symbolic owners resolved at settlement. Applies ONLY to the
|
|
219
|
-
// derivation-only delta members — the
|
|
220
|
-
// owners (see the note in continuation.ts).
|
|
217
|
+
// derivation-only delta members — the three absolute members keep
|
|
218
|
+
// address-only owners (see the note in continuation.ts).
|
|
221
219
|
const assertionOwnerZod = z.union([
|
|
222
220
|
evmAddressZod,
|
|
223
221
|
z.enum(['escrow', 'delivery']),
|
|
224
222
|
]);
|
|
225
223
|
|
|
226
|
-
// HTTP-layer mirror of `
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
export const
|
|
224
|
+
// HTTP-layer mirror of `AssertionSpecSchema` (continuation.ts): the three
|
|
225
|
+
// absolute members plus the two derivation-only members. Amounts are decimal
|
|
226
|
+
// strings on the wire.
|
|
227
|
+
export const AssertionSpecZod = z.discriminatedUnion('kind', [
|
|
230
228
|
z.object({
|
|
231
229
|
kind: z.literal('erc20BalanceGte'),
|
|
232
230
|
chainId: chainIdZod,
|
|
@@ -248,13 +246,6 @@ export const CheckZod = z.discriminatedUnion('kind', [
|
|
|
248
246
|
comparator: z.enum(['gte', 'eq', 'lte']),
|
|
249
247
|
value: uintStringZod,
|
|
250
248
|
}),
|
|
251
|
-
]);
|
|
252
|
-
|
|
253
|
-
// HTTP-layer mirror of `AssertionSpecSchema` (continuation.ts): the three
|
|
254
|
-
// `Check` members plus the two derivation-only members. Reuses `CheckZod`'s
|
|
255
|
-
// options so the shared members cannot drift from `Check`.
|
|
256
|
-
export const AssertionSpecZod = z.discriminatedUnion('kind', [
|
|
257
|
-
...CheckZod.options,
|
|
258
249
|
z.object({
|
|
259
250
|
kind: z.literal('erc20BalanceDeltaGte'),
|
|
260
251
|
chainId: z.number().int().positive(),
|
|
@@ -276,11 +267,11 @@ export type AssertionSpecWire = z.infer<typeof AssertionSpecZod>;
|
|
|
276
267
|
// (descriptor.ts, seam C4). It is the disclosure-path widening of
|
|
277
268
|
// `AssertionSpecZod`: the two balance-`Gte` members accept a symbolic owner
|
|
278
269
|
// (`assertionOwnerZod`) as well as hex, because the derivation resolves symbolic
|
|
279
|
-
// owners to validator-injected slots at settlement. The
|
|
280
|
-
// stay hex-only
|
|
281
|
-
// `call` member and the two derivation-only delta members are reused
|
|
282
|
-
// selecting them from `AssertionSpecZod.options` by their `kind`
|
|
283
|
-
// they cannot drift from the source union.
|
|
270
|
+
// owners to validator-injected slots at settlement. The `AssertionSpecZod`
|
|
271
|
+
// balance members stay hex-only; this widening is confined to the descriptor.
|
|
272
|
+
// The `call` member and the two derivation-only delta members are reused
|
|
273
|
+
// verbatim by selecting them from `AssertionSpecZod.options` by their `kind`
|
|
274
|
+
// literal, so they cannot drift from the source union.
|
|
284
275
|
const assertionSpecOptionByKind = (kind: string) => {
|
|
285
276
|
const option = AssertionSpecZod.options.find(
|
|
286
277
|
(o) => o.shape.kind.value === kind,
|
|
@@ -324,27 +315,12 @@ export type VerificationDescriptorWire = z.infer<
|
|
|
324
315
|
typeof VerificationDescriptorZod
|
|
325
316
|
>;
|
|
326
317
|
|
|
327
|
-
// HTTP-layer mirror of `ContinuationPlanSchema`. `nextFlow` is typed
|
|
328
|
-
// `z.unknown()` rather than mirroring the full Flow schema in Zod: the client
|
|
329
|
-
// treats it as an opaque, re-submittable document and POSTs it back to
|
|
330
|
-
// `/compose`, where the Effect `FlowSchema` validates it. The internal
|
|
331
|
-
// `ContinuationPlan` type keeps `nextFlow: Flow` precisely typed.
|
|
332
|
-
export const ContinuationPlanZod = z.object({
|
|
333
|
-
chainId: chainIdZod,
|
|
334
|
-
nextFlow: z.unknown(),
|
|
335
|
-
check: CheckZod,
|
|
336
|
-
validity: z.object({ expiresAtMs: epochMsZod }),
|
|
337
|
-
correlationId: z.string().optional(),
|
|
338
|
-
});
|
|
339
|
-
|
|
340
318
|
// What the response says about how one `continuation.settle` node settles.
|
|
341
|
-
// `escrow` is present when the provider registered an escrow;
|
|
342
|
-
//
|
|
343
|
-
//
|
|
344
|
-
// what to submit or sign lives in `actions`.
|
|
319
|
+
// `escrow` is present when the provider registered an escrow; a settle node
|
|
320
|
+
// that discloses none is an empty entry. Carries no calldata and no typed
|
|
321
|
+
// data: what to submit or sign lives in `actions`.
|
|
345
322
|
export const SettlementZod = z.object({
|
|
346
323
|
escrow: SettlementEscrowZod.optional(),
|
|
347
|
-
continuation: ContinuationPlanZod.optional(),
|
|
348
324
|
});
|
|
349
325
|
|
|
350
326
|
export type ResourcePort = z.infer<typeof ResourcePortZod>;
|
|
@@ -363,4 +339,3 @@ export type ManifestPrecondition = z.infer<typeof ManifestPreconditionZod>;
|
|
|
363
339
|
export type ComposeManifest = z.infer<typeof ComposeManifestZod>;
|
|
364
340
|
export type SettlementEscrowWire = z.infer<typeof SettlementEscrowZod>;
|
|
365
341
|
export type SettlementWire = z.infer<typeof SettlementZod>;
|
|
366
|
-
export type ContinuationPlanWire = z.infer<typeof ContinuationPlanZod>;
|