@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/README.md +1 -1
- package/dist/index.cjs +89 -41
- package/dist/index.d.cts +266 -70
- package/dist/index.d.ts +266 -70
- package/dist/index.js +82 -38
- package/package.json +6 -13
- package/src/compile.ts +87 -21
- package/src/constructors.ts +106 -53
- package/src/continuation.ts +9 -9
- package/src/flow.ts +15 -1
- package/src/flowSchema.ts +0 -7
- package/src/index.ts +32 -6
- package/src/preconditions.ts +51 -0
- package/src/ref.ts +34 -1
- package/src/resource.ts +6 -1
- package/src/route.ts +139 -0
- package/src/simulate.ts +14 -23
- package/src/zodSchemas.ts +5 -13
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
export
|
|
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
|
|
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
|
|
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
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
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
|
-
|
|
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'),
|