@lifi/compose-spec 0.4.0 → 0.5.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/src/simulate.ts CHANGED
@@ -16,6 +16,12 @@
16
16
  * Mirrors the hand-authored style of `src/compile.ts`.
17
17
  */
18
18
 
19
+ import type {
20
+ Erc20AllowancePrecondition,
21
+ Erc20BalancePrecondition,
22
+ NativeBalancePrecondition,
23
+ } from './preconditions.js';
24
+
19
25
  /**
20
26
  * Maximum number of watched `(token, owner)` pairs accepted by `POST /simulate`.
21
27
  *
@@ -47,33 +53,18 @@ export interface TrackedBalance {
47
53
  readonly owner: string;
48
54
  }
49
55
 
50
- /**
51
- * Funding instruction: seed an ERC-20 balance on a wallet before simulation.
52
- * Amounts accept `bigint | string` — the SDK serialises `bigint` to a decimal
53
- * string; the string side covers values already stringified.
54
- */
55
- export interface Erc20BalanceRequirement {
56
- readonly type: 'Erc20Balance';
57
- readonly wallet: string;
58
- readonly token: string;
59
- readonly balance: bigint | string;
60
- }
56
+ // The funding instructions are the precondition shapes themselves: what the
57
+ // simulator seeds is exactly what a compile declared. See `preconditions.ts`
58
+ // for the canonical definitions and constructors.
59
+
60
+ /** Funding instruction: seed an ERC-20 balance on a wallet before simulation. */
61
+ export type Erc20BalanceRequirement = Erc20BalancePrecondition;
61
62
 
62
63
  /** Funding instruction: seed a native balance on a wallet before simulation. */
63
- export interface NativeBalanceRequirement {
64
- readonly type: 'NativeBalance';
65
- readonly wallet: string;
66
- readonly balance: bigint | string;
67
- }
64
+ export type NativeBalanceRequirement = NativeBalancePrecondition;
68
65
 
69
66
  /** Funding instruction: seed an ERC-20 allowance before simulation. */
70
- export interface Erc20AllowanceRequirement {
71
- readonly type: 'Erc20Allowance';
72
- readonly owner: string;
73
- readonly spender: string;
74
- readonly token: string;
75
- readonly allowance: bigint | string;
76
- }
67
+ export type Erc20AllowanceRequirement = Erc20AllowancePrecondition;
77
68
 
78
69
  /**
79
70
  * The funding-instruction union applied before a simulation. Three variants,
package/src/zodSchemas.ts CHANGED
@@ -70,6 +70,7 @@ export const HandlePortZod = z.object({
70
70
  mode: z.enum(['linear', 'copy']),
71
71
  expose: z.boolean().optional(),
72
72
  units: HandleUnitsZod.optional(),
73
+ optional: z.boolean().optional(),
73
74
  });
74
75
 
75
76
  export const InputPortZod = z.discriminatedUnion('kind', [
@@ -164,22 +165,13 @@ export const ComposeManifestZod = z.object({
164
165
  preconditions: z.array(ManifestPreconditionZod).optional(),
165
166
  });
166
167
 
167
- // HTTP-layer mirror of `Phase1ArtifactSchema` (the Effect schema in
168
- // `continuation.ts`). The Effect schema validates the Flow; this Zod schema
169
- // validates the `/compose` response. `transaction` carries an optional
170
- // `transactionRequest` only if a venue later needs it; for v1 it is just
171
- // `{ kind: "transaction" }` and the client funds via the existing
172
- // response-level `transactionRequest`.
168
+ // Metadata-only HTTP projection of `Phase1ArtifactSchema`. The authoritative
169
+ // funding and action contract lives on `ComposeActionsSchema` in
170
+ // `@lifi/api-schemas`.
173
171
  export const Phase1ArtifactZod = z.discriminatedUnion('kind', [
174
172
  z.object({
175
173
  kind: z.literal('transaction'),
176
- transactionRequest: z
177
- .object({
178
- to: z.string(),
179
- data: z.string(),
180
- value: z.string(),
181
- })
182
- .optional(),
174
+ funding: z.enum(['inline', 'external']),
183
175
  }),
184
176
  z.object({
185
177
  kind: z.literal('signables'),