@lifi/compose-spec 0.9.0 → 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 CHANGED
@@ -268,7 +268,7 @@ const AppliedGuardSchema = effect.Schema.Struct({ kind: effect.Schema.String },
268
268
  key: effect.Schema.String,
269
269
  value: effect.Schema.Unknown
270
270
  });
271
- const NodeIdSchema = effect.Schema.String.pipe(effect.Schema.filter((id) => id !== "__proto__", { message: () => "node id \"__proto__\" is reserved; choose another node id" }));
271
+ const NodeIdSchema = effect.Schema.String.pipe(effect.Schema.filter((id) => id !== "__proto__", { message: () => "node id \"__proto__\" is reserved; choose another node id" }), effect.Schema.filter((id) => id.length > 0, { message: () => "node id must not be empty" }));
272
272
  const CallSchema = effect.Schema.Struct({
273
273
  id: NodeIdSchema,
274
274
  op: effect.Schema.String,
@@ -751,7 +751,7 @@ const checkCompatibility = (client, server, minimum = {
751
751
  const foldMaterialiserMetadata = (meta, cases) => {
752
752
  if (meta.kind === "exact") return cases.exact(meta.amount);
753
753
  if (meta.kind === "exact-native") return cases.exactNative(meta.amount);
754
- if (meta.kind === "capped") return cases.capped(meta.amount);
754
+ if (meta.kind === "capped") return cases.capped(meta.amount, meta.min);
755
755
  return cases.runtime();
756
756
  };
757
757
  //#endregion
package/dist/index.d.cts CHANGED
@@ -120,7 +120,7 @@ export declare const AppliedGuardSchema: Schema.TypeLiteral<{
120
120
  readonly value: typeof Schema.Unknown;
121
121
  }]>;
122
122
  export declare const CallSchema: Schema.Struct<{
123
- id: Schema.filter<typeof Schema.String>;
123
+ id: Schema.filter<Schema.filter<typeof Schema.String>>;
124
124
  op: typeof Schema.String;
125
125
  bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
126
126
  $ref: Schema.filter<typeof Schema.String>;
@@ -178,7 +178,7 @@ export declare const FlowSchema: Schema.Struct<{
178
178
  type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
179
179
  }>]>>;
180
180
  nodes: Schema.Array$<Schema.Struct<{
181
- id: Schema.filter<typeof Schema.String>;
181
+ id: Schema.filter<Schema.filter<typeof Schema.String>>;
182
182
  op: typeof Schema.String;
183
183
  bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
184
184
  $ref: Schema.filter<typeof Schema.String>;
@@ -283,7 +283,7 @@ export declare const ContinuationIntentSchema: Schema.Struct<{
283
283
  type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
284
284
  }>]>>;
285
285
  nodes: Schema.Array$<Schema.Struct<{
286
- id: Schema.filter<typeof Schema.String>;
286
+ id: Schema.filter<Schema.filter<typeof Schema.String>>;
287
287
  op: typeof Schema.String;
288
288
  bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
289
289
  $ref: Schema.filter<typeof Schema.String>;
@@ -2518,6 +2518,7 @@ type MaterialiserMetadata = {
2518
2518
  } | {
2519
2519
  readonly kind: 'capped';
2520
2520
  readonly amount: bigint;
2521
+ readonly min?: bigint;
2521
2522
  } | {
2522
2523
  readonly kind: 'runtime';
2523
2524
  };
@@ -2528,7 +2529,7 @@ interface MaterialiserResolution {
2528
2529
  export declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
2529
2530
  readonly exact: (amount: bigint) => R;
2530
2531
  readonly exactNative: (amount: bigint) => R;
2531
- readonly capped: (amount: bigint) => R;
2532
+ readonly capped: (amount: bigint, min: bigint | undefined) => R;
2532
2533
  readonly runtime: () => R;
2533
2534
  }) => R;
2534
2535
  //#endregion
package/dist/index.d.ts CHANGED
@@ -120,7 +120,7 @@ export declare const AppliedGuardSchema: Schema.TypeLiteral<{
120
120
  readonly value: typeof Schema.Unknown;
121
121
  }]>;
122
122
  export declare const CallSchema: Schema.Struct<{
123
- id: Schema.filter<typeof Schema.String>;
123
+ id: Schema.filter<Schema.filter<typeof Schema.String>>;
124
124
  op: typeof Schema.String;
125
125
  bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
126
126
  $ref: Schema.filter<typeof Schema.String>;
@@ -178,7 +178,7 @@ export declare const FlowSchema: Schema.Struct<{
178
178
  type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
179
179
  }>]>>;
180
180
  nodes: Schema.Array$<Schema.Struct<{
181
- id: Schema.filter<typeof Schema.String>;
181
+ id: Schema.filter<Schema.filter<typeof Schema.String>>;
182
182
  op: typeof Schema.String;
183
183
  bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
184
184
  $ref: Schema.filter<typeof Schema.String>;
@@ -283,7 +283,7 @@ export declare const ContinuationIntentSchema: Schema.Struct<{
283
283
  type: Schema.Literal<["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string"]>;
284
284
  }>]>>;
285
285
  nodes: Schema.Array$<Schema.Struct<{
286
- id: Schema.filter<typeof Schema.String>;
286
+ id: Schema.filter<Schema.filter<typeof Schema.String>>;
287
287
  op: typeof Schema.String;
288
288
  bind: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Struct<{
289
289
  $ref: Schema.filter<typeof Schema.String>;
@@ -2518,6 +2518,7 @@ type MaterialiserMetadata = {
2518
2518
  } | {
2519
2519
  readonly kind: 'capped';
2520
2520
  readonly amount: bigint;
2521
+ readonly min?: bigint;
2521
2522
  } | {
2522
2523
  readonly kind: 'runtime';
2523
2524
  };
@@ -2528,7 +2529,7 @@ interface MaterialiserResolution {
2528
2529
  export declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
2529
2530
  readonly exact: (amount: bigint) => R;
2530
2531
  readonly exactNative: (amount: bigint) => R;
2531
- readonly capped: (amount: bigint) => R;
2532
+ readonly capped: (amount: bigint, min: bigint | undefined) => R;
2532
2533
  readonly runtime: () => R;
2533
2534
  }) => R;
2534
2535
  //#endregion
package/dist/index.js CHANGED
@@ -244,7 +244,7 @@ const AppliedGuardSchema = Schema.Struct({ kind: Schema.String }, {
244
244
  key: Schema.String,
245
245
  value: Schema.Unknown
246
246
  });
247
- const NodeIdSchema = Schema.String.pipe(Schema.filter((id) => id !== "__proto__", { message: () => "node id \"__proto__\" is reserved; choose another node id" }));
247
+ const NodeIdSchema = Schema.String.pipe(Schema.filter((id) => id !== "__proto__", { message: () => "node id \"__proto__\" is reserved; choose another node id" }), Schema.filter((id) => id.length > 0, { message: () => "node id must not be empty" }));
248
248
  const CallSchema = Schema.Struct({
249
249
  id: NodeIdSchema,
250
250
  op: Schema.String,
@@ -727,7 +727,7 @@ const checkCompatibility = (client, server, minimum = {
727
727
  const foldMaterialiserMetadata = (meta, cases) => {
728
728
  if (meta.kind === "exact") return cases.exact(meta.amount);
729
729
  if (meta.kind === "exact-native") return cases.exactNative(meta.amount);
730
- if (meta.kind === "capped") return cases.capped(meta.amount);
730
+ if (meta.kind === "capped") return cases.capped(meta.amount, meta.min);
731
731
  return cases.runtime();
732
732
  };
733
733
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/compose-spec",
3
- "version": "0.9.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": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "effect": "^3.21.0",
44
- "zod": "^4.6.5"
44
+ "zod": "^4.6.6"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@eslint/compat": "^1.4.0",
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
- | { readonly kind: 'capped'; readonly amount: bigint }
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
  };