@lifi/compose-spec 0.8.1 → 0.10.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/index.cjs +1019 -1095
- package/dist/index.d.cts +1666 -1701
- package/dist/index.d.ts +1666 -1701
- package/dist/index.js +926 -989
- package/package.json +4 -4
- package/src/continuation.ts +4 -3
- package/src/flowSchema.ts +8 -0
- package/src/materialiserMetadata.ts +5 -4
- package/src/output.ts +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/compose-spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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'",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"effect": "^3.21.0",
|
|
44
|
-
"zod": "^4.6.
|
|
44
|
+
"zod": "^4.6.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@eslint/compat": "^1.4.0",
|
|
@@ -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/continuation.ts
CHANGED
|
@@ -255,9 +255,10 @@ export const decodeNativeBalanceGte = <C extends NativeBalanceGteLike>(
|
|
|
255
255
|
//
|
|
256
256
|
// - `erc20BalanceDeltaGte` / `nativeBalanceDeltaGte` — `owner`'s post-fill
|
|
257
257
|
// balance of `token` (native) on `chainId` must exceed its pre-fill balance
|
|
258
|
-
// by at least `minDelta`.
|
|
259
|
-
//
|
|
260
|
-
//
|
|
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.
|
|
261
262
|
export const Erc20BalanceDeltaGteSpecSchema = Schema.Struct({
|
|
262
263
|
kind: Schema.Literal('erc20BalanceDeltaGte'),
|
|
263
264
|
chainId: ChainIdSchema,
|
package/src/flowSchema.ts
CHANGED
|
@@ -163,10 +163,18 @@ export const AppliedGuardSchema = Schema.Struct(
|
|
|
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
165
|
// flow it decodes, including an embedded `continuationFlow`.
|
|
166
|
+
//
|
|
167
|
+
// The empty id is rejected for the same reason: it names a node that no `$ref`
|
|
168
|
+
// can address (`node.` + `.` + port is unparseable) and that the compile
|
|
169
|
+
// response cannot carry — `fill.spends[].nodeId` is a non-empty string — so a
|
|
170
|
+
// settle node with an empty id failed response serialisation with a 500.
|
|
166
171
|
const NodeIdSchema = Schema.String.pipe(
|
|
167
172
|
Schema.filter((id) => id !== '__proto__', {
|
|
168
173
|
message: () => 'node id "__proto__" is reserved; choose another node id',
|
|
169
174
|
}),
|
|
175
|
+
Schema.filter((id) => id.length > 0, {
|
|
176
|
+
message: () => 'node id must not be empty',
|
|
177
|
+
}),
|
|
170
178
|
);
|
|
171
179
|
|
|
172
180
|
export const CallSchema = Schema.Struct({
|
|
@@ -5,8 +5,9 @@ export type MaterialiserMetadata =
|
|
|
5
5
|
| { readonly kind: 'exact-native'; readonly amount: bigint }
|
|
6
6
|
// The program pulls at most `amount` and consumes the measured result;
|
|
7
7
|
// `amount` is what an authoriser signs and what a spend report states, not
|
|
8
|
-
// what was deposited.
|
|
9
|
-
|
|
8
|
+
// what was deposited. `min`, when present, is a floor the program asserts
|
|
9
|
+
// on-chain right after the pull, so the deposit never lands below it.
|
|
10
|
+
| { readonly kind: 'capped'; readonly amount: bigint; readonly min?: bigint }
|
|
10
11
|
| { readonly kind: 'runtime' };
|
|
11
12
|
|
|
12
13
|
export interface MaterialiserResolution {
|
|
@@ -19,12 +20,12 @@ export const foldMaterialiserMetadata = <R>(
|
|
|
19
20
|
cases: {
|
|
20
21
|
readonly exact: (amount: bigint) => R;
|
|
21
22
|
readonly exactNative: (amount: bigint) => R;
|
|
22
|
-
readonly capped: (amount: bigint) => R;
|
|
23
|
+
readonly capped: (amount: bigint, min: bigint | undefined) => R;
|
|
23
24
|
readonly runtime: () => R;
|
|
24
25
|
},
|
|
25
26
|
): R => {
|
|
26
27
|
if (meta.kind === 'exact') return cases.exact(meta.amount);
|
|
27
28
|
if (meta.kind === 'exact-native') return cases.exactNative(meta.amount);
|
|
28
|
-
if (meta.kind === 'capped') return cases.capped(meta.amount);
|
|
29
|
+
if (meta.kind === 'capped') return cases.capped(meta.amount, meta.min);
|
|
29
30
|
return cases.runtime();
|
|
30
31
|
};
|
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
|
|