@lifi/compose-spec 0.2.0 → 0.4.0-staging.1
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 +440 -4
- package/dist/index.d.cts +1259 -121
- package/dist/index.d.ts +1259 -121
- package/dist/index.js +400 -4
- package/package.json +22 -2
- package/src/chainCapabilities.ts +174 -0
- package/src/compile.ts +44 -11
- package/src/constructors.ts +55 -53
- package/src/continuation.ts +278 -0
- package/src/descriptor.ts +151 -0
- package/src/flashloan.ts +8 -8
- package/src/flow.ts +46 -46
- package/src/flowSchema.ts +61 -27
- package/src/hexPatterns.ts +16 -0
- package/src/index.ts +92 -19
- package/src/materialiserMetadata.ts +1 -1
- package/src/ref.ts +21 -21
- package/src/resource.ts +19 -9
- package/src/simulate.ts +7 -9
- package/src/zodSchemas.ts +208 -48
package/dist/index.js
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
// src/flowSchema.ts
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
// src/chainCapabilities.ts
|
|
5
|
+
var EVM_NATIVE_SENTINEL = (
|
|
6
|
+
// eslint-disable-next-line @lifi/prefer-utils-constants -- compose-spec is the wire-format leaf and must not import @lifi/utils (enforced by scripts/check-compose-boundaries.mjs); the literal is intentional here
|
|
7
|
+
"0x0000000000000000000000000000000000000000"
|
|
8
|
+
);
|
|
9
|
+
var isNativeSentinel = (address) => address.toLowerCase() === EVM_NATIVE_SENTINEL.toLowerCase();
|
|
10
|
+
var TEMPO_CHAIN_ID = 4217;
|
|
11
|
+
var TEMPO_NATIVE_ERC20 = {
|
|
12
|
+
token: "0x20C0000000000000000000000000000000000000",
|
|
13
|
+
symbol: "pathUSD",
|
|
14
|
+
decimals: 6
|
|
15
|
+
};
|
|
16
|
+
var REGISTRY = /* @__PURE__ */ new Map([
|
|
17
|
+
[
|
|
18
|
+
TEMPO_CHAIN_ID,
|
|
19
|
+
{
|
|
20
|
+
kind: "as-erc20",
|
|
21
|
+
chainId: TEMPO_CHAIN_ID,
|
|
22
|
+
nativeErc20: TEMPO_NATIVE_ERC20
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
]);
|
|
26
|
+
var getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? { kind: "evm-native", chainId };
|
|
27
|
+
var isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
|
|
28
|
+
var canonicalNativeAddress = (chainId) => {
|
|
29
|
+
const caps = getChainCapabilities(chainId);
|
|
30
|
+
return caps.kind === "as-erc20" ? caps.nativeErc20.token : EVM_NATIVE_SENTINEL;
|
|
31
|
+
};
|
|
32
|
+
var isNativeAddressForChain = (chainId, address) => {
|
|
33
|
+
const caps = getChainCapabilities(chainId);
|
|
34
|
+
const target = caps.kind === "as-erc20" ? caps.nativeErc20.token : EVM_NATIVE_SENTINEL;
|
|
35
|
+
return address.toLowerCase() === target.toLowerCase();
|
|
36
|
+
};
|
|
37
|
+
var isMsgValueNative = (chainId, address) => !isAsErc20Chain(chainId) && isNativeSentinel(address);
|
|
38
|
+
var normalizeResource = (r) => {
|
|
39
|
+
if (r.kind !== "native") return r;
|
|
40
|
+
const caps = getChainCapabilities(r.chainId);
|
|
41
|
+
if (caps.kind !== "as-erc20") return r;
|
|
42
|
+
return {
|
|
43
|
+
kind: "erc20",
|
|
44
|
+
chainId: r.chainId,
|
|
45
|
+
token: caps.nativeErc20.token
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
var normalizeNativeTokenAddress = (token, chainId) => isAsErc20Chain(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
|
|
49
|
+
|
|
50
|
+
// src/flowSchema.ts
|
|
3
51
|
var SolTypeSchema = Schema.Literal(
|
|
4
52
|
"uint8",
|
|
5
53
|
"uint16",
|
|
@@ -16,8 +64,11 @@ var SolTypeSchema = Schema.Literal(
|
|
|
16
64
|
"bytes32",
|
|
17
65
|
"string"
|
|
18
66
|
);
|
|
19
|
-
var ChainIdSchema = Schema.Number.pipe(
|
|
20
|
-
|
|
67
|
+
var ChainIdSchema = Schema.Number.pipe(
|
|
68
|
+
Schema.int(),
|
|
69
|
+
Schema.positive()
|
|
70
|
+
);
|
|
71
|
+
var RawResourceSchema = Schema.Union(
|
|
21
72
|
Schema.Struct({ kind: Schema.Literal("native"), chainId: ChainIdSchema }),
|
|
22
73
|
Schema.Struct({
|
|
23
74
|
kind: Schema.Literal("erc20"),
|
|
@@ -25,6 +76,15 @@ var ResourceSchema = Schema.Union(
|
|
|
25
76
|
chainId: ChainIdSchema
|
|
26
77
|
})
|
|
27
78
|
);
|
|
79
|
+
var ResourceSchema = Schema.transform(
|
|
80
|
+
RawResourceSchema,
|
|
81
|
+
Schema.typeSchema(RawResourceSchema),
|
|
82
|
+
{
|
|
83
|
+
strict: true,
|
|
84
|
+
decode: (raw) => normalizeResource(raw),
|
|
85
|
+
encode: (resource2) => resource2
|
|
86
|
+
}
|
|
87
|
+
);
|
|
28
88
|
var ResourceInputSchema = Schema.Struct({
|
|
29
89
|
name: Schema.String,
|
|
30
90
|
resource: ResourceSchema
|
|
@@ -76,8 +136,196 @@ var FlowSchema = Schema.Struct({
|
|
|
76
136
|
chainId: ChainIdSchema,
|
|
77
137
|
inputs: Schema.Array(FlowInputSchema),
|
|
78
138
|
nodes: Schema.Array(CallSchema),
|
|
79
|
-
|
|
139
|
+
continuations: Schema.optional(Schema.Array(ContinuationSchema))
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// src/continuation.ts
|
|
143
|
+
import { Schema as Schema2 } from "effect";
|
|
144
|
+
var CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
|
|
145
|
+
var RawContinuationOutcomeSchema = Schema2.Struct({
|
|
146
|
+
token: Schema2.String,
|
|
147
|
+
minAmount: Schema2.String,
|
|
148
|
+
destination: Schema2.String,
|
|
149
|
+
chainId: ChainIdSchema
|
|
150
|
+
});
|
|
151
|
+
var ContinuationOutcomeSchema = Schema2.transform(
|
|
152
|
+
RawContinuationOutcomeSchema,
|
|
153
|
+
Schema2.typeSchema(RawContinuationOutcomeSchema),
|
|
154
|
+
{
|
|
155
|
+
strict: true,
|
|
156
|
+
decode: (raw) => ({
|
|
157
|
+
...raw,
|
|
158
|
+
token: normalizeNativeTokenAddress(raw.token, raw.chainId)
|
|
159
|
+
}),
|
|
160
|
+
encode: (outcome) => outcome
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
var ContinuationIntentSchema = Schema2.Struct({
|
|
164
|
+
// `NonEmptyArray` enforces ≥1 outcome at the parse boundary, so downstream needs no guard.
|
|
165
|
+
outcomes: Schema2.NonEmptyArray(ContinuationOutcomeSchema),
|
|
166
|
+
continuationFlow: Schema2.optional(FlowSchema),
|
|
167
|
+
validity: Schema2.Struct({ expiresAtMs: Schema2.Number }),
|
|
168
|
+
perpetual: Schema2.optional(Schema2.Boolean),
|
|
169
|
+
provider: Schema2.optional(Schema2.String)
|
|
170
|
+
});
|
|
171
|
+
var Phase1ArtifactSchema = Schema2.Union(
|
|
172
|
+
Schema2.Struct({
|
|
173
|
+
kind: Schema2.Literal("transaction"),
|
|
174
|
+
transactionRequest: Schema2.optional(
|
|
175
|
+
Schema2.Struct({
|
|
176
|
+
to: Schema2.String,
|
|
177
|
+
data: Schema2.String,
|
|
178
|
+
value: Schema2.String
|
|
179
|
+
})
|
|
180
|
+
)
|
|
181
|
+
}),
|
|
182
|
+
Schema2.Struct({
|
|
183
|
+
kind: Schema2.Literal("signables"),
|
|
184
|
+
typedData: Schema2.Array(Schema2.Unknown)
|
|
185
|
+
}),
|
|
186
|
+
Schema2.Struct({ kind: Schema2.Literal("none") })
|
|
187
|
+
);
|
|
188
|
+
var HexStringSchema = Schema2.String.pipe(Schema2.startsWith("0x"));
|
|
189
|
+
var AssertionOwnerSchema = Schema2.Union(
|
|
190
|
+
HexStringSchema,
|
|
191
|
+
Schema2.Literal("escrow", "delivery")
|
|
192
|
+
);
|
|
193
|
+
var Erc20BalanceGteSpecSchema = Schema2.Struct({
|
|
194
|
+
kind: Schema2.Literal("erc20BalanceGte"),
|
|
195
|
+
chainId: ChainIdSchema,
|
|
196
|
+
token: HexStringSchema,
|
|
197
|
+
owner: HexStringSchema,
|
|
198
|
+
minAmount: Schema2.String
|
|
199
|
+
});
|
|
200
|
+
var NativeBalanceGteSpecSchema = Schema2.Struct({
|
|
201
|
+
kind: Schema2.Literal("nativeBalanceGte"),
|
|
202
|
+
chainId: ChainIdSchema,
|
|
203
|
+
owner: HexStringSchema,
|
|
204
|
+
minAmount: Schema2.String
|
|
205
|
+
});
|
|
206
|
+
var CallCheckSpecSchema = Schema2.Struct({
|
|
207
|
+
kind: Schema2.Literal("call"),
|
|
208
|
+
chainId: ChainIdSchema,
|
|
209
|
+
to: HexStringSchema,
|
|
210
|
+
calldata: HexStringSchema,
|
|
211
|
+
comparator: Schema2.Literal("gte", "eq", "lte"),
|
|
212
|
+
value: Schema2.String
|
|
213
|
+
});
|
|
214
|
+
var asErc20BalanceGteCheck = (chainId, owner, minAmount) => ({
|
|
215
|
+
kind: "erc20BalanceGte",
|
|
216
|
+
chainId,
|
|
217
|
+
token: canonicalNativeAddress(chainId),
|
|
218
|
+
owner,
|
|
219
|
+
minAmount
|
|
220
|
+
});
|
|
221
|
+
var RawCheckSchema = Schema2.Union(
|
|
222
|
+
Erc20BalanceGteSpecSchema,
|
|
223
|
+
NativeBalanceGteSpecSchema,
|
|
224
|
+
CallCheckSpecSchema
|
|
225
|
+
);
|
|
226
|
+
var CheckSchema = Schema2.transform(
|
|
227
|
+
RawCheckSchema,
|
|
228
|
+
Schema2.typeSchema(RawCheckSchema),
|
|
229
|
+
{
|
|
230
|
+
strict: true,
|
|
231
|
+
decode: (check) => check.kind === "nativeBalanceGte" && isAsErc20Chain(check.chainId) ? asErc20BalanceGteCheck(check.chainId, check.owner, check.minAmount) : check,
|
|
232
|
+
encode: (check) => check
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
var Erc20BalanceDeltaGteSpecSchema = Schema2.Struct({
|
|
236
|
+
kind: Schema2.Literal("erc20BalanceDeltaGte"),
|
|
237
|
+
chainId: ChainIdSchema,
|
|
238
|
+
token: HexStringSchema,
|
|
239
|
+
owner: AssertionOwnerSchema,
|
|
240
|
+
minDelta: Schema2.String
|
|
80
241
|
});
|
|
242
|
+
var NativeBalanceDeltaGteSpecSchema = Schema2.Struct({
|
|
243
|
+
kind: Schema2.Literal("nativeBalanceDeltaGte"),
|
|
244
|
+
chainId: ChainIdSchema,
|
|
245
|
+
owner: AssertionOwnerSchema,
|
|
246
|
+
minDelta: Schema2.String
|
|
247
|
+
});
|
|
248
|
+
var AssertionSpecSchema = Schema2.Union(
|
|
249
|
+
Erc20BalanceGteSpecSchema,
|
|
250
|
+
NativeBalanceGteSpecSchema,
|
|
251
|
+
CallCheckSpecSchema,
|
|
252
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
253
|
+
NativeBalanceDeltaGteSpecSchema
|
|
254
|
+
);
|
|
255
|
+
var ContinuationPlanSchema = Schema2.Struct({
|
|
256
|
+
chainId: ChainIdSchema,
|
|
257
|
+
nextFlow: FlowSchema,
|
|
258
|
+
check: CheckSchema,
|
|
259
|
+
validity: Schema2.Struct({ expiresAtMs: Schema2.Number }),
|
|
260
|
+
correlationId: Schema2.optional(Schema2.String)
|
|
261
|
+
});
|
|
262
|
+
var isGTECheck = (check) => check.kind === "call" && check.comparator === "gte";
|
|
263
|
+
var isLTECheck = (check) => check.kind === "call" && check.comparator === "lte";
|
|
264
|
+
var isEQCheck = (check) => check.kind === "call" && check.comparator === "eq";
|
|
265
|
+
|
|
266
|
+
// src/descriptor.ts
|
|
267
|
+
import { Schema as Schema3 } from "effect";
|
|
268
|
+
|
|
269
|
+
// src/hexPatterns.ts
|
|
270
|
+
var BYTES32_LOWER_HEX = /^0x[0-9a-f]{64}$/;
|
|
271
|
+
|
|
272
|
+
// src/descriptor.ts
|
|
273
|
+
var Bytes32HexSchema = Schema3.String.pipe(
|
|
274
|
+
Schema3.pattern(BYTES32_LOWER_HEX)
|
|
275
|
+
);
|
|
276
|
+
var AssertedErc20BalanceGteSpecSchema = Schema3.Struct({
|
|
277
|
+
kind: Schema3.Literal("erc20BalanceGte"),
|
|
278
|
+
chainId: ChainIdSchema,
|
|
279
|
+
token: HexStringSchema,
|
|
280
|
+
owner: AssertionOwnerSchema,
|
|
281
|
+
minAmount: Schema3.String
|
|
282
|
+
});
|
|
283
|
+
var AssertedNativeBalanceGteSpecSchema = Schema3.Struct({
|
|
284
|
+
kind: Schema3.Literal("nativeBalanceGte"),
|
|
285
|
+
chainId: ChainIdSchema,
|
|
286
|
+
owner: AssertionOwnerSchema,
|
|
287
|
+
minAmount: Schema3.String
|
|
288
|
+
});
|
|
289
|
+
var RawAssertedPredicateSchema = Schema3.Union(
|
|
290
|
+
AssertedErc20BalanceGteSpecSchema,
|
|
291
|
+
AssertedNativeBalanceGteSpecSchema,
|
|
292
|
+
CallCheckSpecSchema,
|
|
293
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
294
|
+
NativeBalanceDeltaGteSpecSchema
|
|
295
|
+
);
|
|
296
|
+
var AssertedPredicateSchema = Schema3.transform(
|
|
297
|
+
RawAssertedPredicateSchema,
|
|
298
|
+
Schema3.typeSchema(RawAssertedPredicateSchema),
|
|
299
|
+
{
|
|
300
|
+
strict: true,
|
|
301
|
+
decode: (pred) => pred.kind === "nativeBalanceGte" && isAsErc20Chain(pred.chainId) ? asErc20BalanceGteCheck(pred.chainId, pred.owner, pred.minAmount) : pred,
|
|
302
|
+
encode: (pred) => pred
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
var VerificationDescriptorSchema = Schema3.Struct({
|
|
306
|
+
validationProgramHash: Bytes32HexSchema,
|
|
307
|
+
// The C5 echo's second hash (verified continuations, plan GD-8): `keccak256`
|
|
308
|
+
// over the canonical params vector (`paramsHash`, GD-2 seam C1). Required and
|
|
309
|
+
// jointly necessary with `validationProgramHash` — the program hash is
|
|
310
|
+
// value-blind (it never binds the delivery address or amounts), so a descriptor
|
|
311
|
+
// that enforces only it is a fund-redirect hole. Empty params still yield a
|
|
312
|
+
// present `0x00…00`, so a real descriptor never omits it. Strict 32-byte
|
|
313
|
+
// lowercase hex, same rule as `validationProgramHash`.
|
|
314
|
+
paramsHash: Bytes32HexSchema,
|
|
315
|
+
assertedPredicate: Schema3.Array(AssertedPredicateSchema)
|
|
316
|
+
});
|
|
317
|
+
var canonicalJson = (value) => {
|
|
318
|
+
if (Array.isArray(value)) {
|
|
319
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
320
|
+
}
|
|
321
|
+
if (value !== null && typeof value === "object") {
|
|
322
|
+
const record = value;
|
|
323
|
+
const entries = Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`);
|
|
324
|
+
return `{${entries.join(",")}}`;
|
|
325
|
+
}
|
|
326
|
+
return JSON.stringify(value);
|
|
327
|
+
};
|
|
328
|
+
var canonicalAssertedPredicate = (specs) => canonicalJson(specs);
|
|
81
329
|
|
|
82
330
|
// src/flow.ts
|
|
83
331
|
var isResourceInput = (input) => "resource" in input;
|
|
@@ -111,6 +359,10 @@ var resourcesEqual = (a, b) => {
|
|
|
111
359
|
return false;
|
|
112
360
|
};
|
|
113
361
|
var foldResource = (r, cases) => r.kind === "native" ? cases.native(r.chainId) : cases.erc20(r.token, r.chainId);
|
|
362
|
+
var resourceToken = (r) => foldResource(r, {
|
|
363
|
+
native: () => EVM_NATIVE_SENTINEL,
|
|
364
|
+
erc20: (token) => token
|
|
365
|
+
});
|
|
114
366
|
var resourceKey = (r) => foldResource(r, {
|
|
115
367
|
native: (chainId) => `native:${chainId}`,
|
|
116
368
|
erc20: (token, chainId) => `erc20:${token.toLowerCase()}:${chainId}`
|
|
@@ -146,7 +398,7 @@ var inputRef = (port) => ({ $ref: `input.${port}` });
|
|
|
146
398
|
var outputRef = (node, port) => ({
|
|
147
399
|
$ref: `${node}.${port}`
|
|
148
400
|
});
|
|
149
|
-
var optionalProp = (key, value) => value
|
|
401
|
+
var optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
|
|
150
402
|
var linear = (name, type) => ({ name, type, mode: "linear", availability: "now" });
|
|
151
403
|
var copy = (name, type) => ({ name, type, mode: "copy", availability: "now" });
|
|
152
404
|
var handle = (name, type) => ({ name, type });
|
|
@@ -227,6 +479,7 @@ var foldMaterialiserMetadata = (meta, cases) => {
|
|
|
227
479
|
|
|
228
480
|
// src/zodSchemas.ts
|
|
229
481
|
import z from "zod";
|
|
482
|
+
var chainIdZod = z.number().int().positive();
|
|
230
483
|
var SolTypeZod = z.enum([
|
|
231
484
|
"uint8",
|
|
232
485
|
"uint16",
|
|
@@ -357,12 +610,134 @@ var ComposeManifestZod = z.object({
|
|
|
357
610
|
materialisers: z.array(ManifestMaterialiserZod),
|
|
358
611
|
preconditions: z.array(ManifestPreconditionZod).optional()
|
|
359
612
|
});
|
|
613
|
+
var Phase1ArtifactZod = z.discriminatedUnion("kind", [
|
|
614
|
+
z.object({
|
|
615
|
+
kind: z.literal("transaction"),
|
|
616
|
+
transactionRequest: z.object({
|
|
617
|
+
to: z.string(),
|
|
618
|
+
data: z.string(),
|
|
619
|
+
value: z.string()
|
|
620
|
+
}).optional()
|
|
621
|
+
}),
|
|
622
|
+
z.object({
|
|
623
|
+
kind: z.literal("signables"),
|
|
624
|
+
typedData: z.array(z.unknown())
|
|
625
|
+
}),
|
|
626
|
+
z.object({
|
|
627
|
+
kind: z.literal("none")
|
|
628
|
+
})
|
|
629
|
+
]);
|
|
630
|
+
var hexStringZod = z.string().startsWith("0x");
|
|
631
|
+
var assertionOwnerZod = z.union([
|
|
632
|
+
hexStringZod,
|
|
633
|
+
z.enum(["escrow", "delivery"])
|
|
634
|
+
]);
|
|
635
|
+
var CheckZod = z.discriminatedUnion("kind", [
|
|
636
|
+
z.object({
|
|
637
|
+
kind: z.literal("erc20BalanceGte"),
|
|
638
|
+
chainId: chainIdZod,
|
|
639
|
+
token: hexStringZod,
|
|
640
|
+
owner: hexStringZod,
|
|
641
|
+
minAmount: z.string()
|
|
642
|
+
}),
|
|
643
|
+
z.object({
|
|
644
|
+
kind: z.literal("nativeBalanceGte"),
|
|
645
|
+
chainId: chainIdZod,
|
|
646
|
+
owner: hexStringZod,
|
|
647
|
+
minAmount: z.string()
|
|
648
|
+
}),
|
|
649
|
+
z.object({
|
|
650
|
+
kind: z.literal("call"),
|
|
651
|
+
chainId: chainIdZod,
|
|
652
|
+
to: hexStringZod,
|
|
653
|
+
calldata: hexStringZod,
|
|
654
|
+
comparator: z.enum(["gte", "eq", "lte"]),
|
|
655
|
+
value: z.string()
|
|
656
|
+
})
|
|
657
|
+
]);
|
|
658
|
+
var AssertionSpecZod = z.discriminatedUnion("kind", [
|
|
659
|
+
...CheckZod.options,
|
|
660
|
+
z.object({
|
|
661
|
+
kind: z.literal("erc20BalanceDeltaGte"),
|
|
662
|
+
chainId: z.number().int().positive(),
|
|
663
|
+
token: hexStringZod,
|
|
664
|
+
owner: assertionOwnerZod,
|
|
665
|
+
minDelta: z.string()
|
|
666
|
+
}),
|
|
667
|
+
z.object({
|
|
668
|
+
kind: z.literal("nativeBalanceDeltaGte"),
|
|
669
|
+
chainId: z.number().int().positive(),
|
|
670
|
+
owner: assertionOwnerZod,
|
|
671
|
+
minDelta: z.string()
|
|
672
|
+
})
|
|
673
|
+
]);
|
|
674
|
+
var assertionSpecOptionByKind = (kind) => {
|
|
675
|
+
const option = AssertionSpecZod.options.find(
|
|
676
|
+
(o) => o.shape.kind.value === kind
|
|
677
|
+
);
|
|
678
|
+
if (option === void 0) {
|
|
679
|
+
throw new Error(`AssertionSpecZod has no member with kind "${kind}"`);
|
|
680
|
+
}
|
|
681
|
+
return option;
|
|
682
|
+
};
|
|
683
|
+
var AssertedPredicateZod = z.discriminatedUnion("kind", [
|
|
684
|
+
z.object({
|
|
685
|
+
kind: z.literal("erc20BalanceGte"),
|
|
686
|
+
chainId: z.number().int().positive(),
|
|
687
|
+
token: hexStringZod,
|
|
688
|
+
owner: assertionOwnerZod,
|
|
689
|
+
minAmount: z.string()
|
|
690
|
+
}),
|
|
691
|
+
z.object({
|
|
692
|
+
kind: z.literal("nativeBalanceGte"),
|
|
693
|
+
chainId: z.number().int().positive(),
|
|
694
|
+
owner: assertionOwnerZod,
|
|
695
|
+
minAmount: z.string()
|
|
696
|
+
}),
|
|
697
|
+
assertionSpecOptionByKind("call"),
|
|
698
|
+
assertionSpecOptionByKind("erc20BalanceDeltaGte"),
|
|
699
|
+
assertionSpecOptionByKind("nativeBalanceDeltaGte")
|
|
700
|
+
]);
|
|
701
|
+
var VerificationDescriptorZod = z.object({
|
|
702
|
+
validationProgramHash: z.string().regex(BYTES32_LOWER_HEX),
|
|
703
|
+
// The C5 echo's second hash (GD-8): the params-vector content hash
|
|
704
|
+
// (`paramsHash`, C1). Required and jointly necessary with the value-blind
|
|
705
|
+
// `validationProgramHash`.
|
|
706
|
+
paramsHash: z.string().regex(BYTES32_LOWER_HEX),
|
|
707
|
+
assertedPredicate: z.array(AssertedPredicateZod)
|
|
708
|
+
});
|
|
709
|
+
var ContinuationPlanZod = z.object({
|
|
710
|
+
chainId: chainIdZod,
|
|
711
|
+
nextFlow: z.unknown(),
|
|
712
|
+
check: CheckZod,
|
|
713
|
+
validity: z.object({ expiresAtMs: z.number() }),
|
|
714
|
+
correlationId: z.string().optional()
|
|
715
|
+
});
|
|
360
716
|
export {
|
|
361
717
|
AppliedGuardSchema,
|
|
718
|
+
AssertedErc20BalanceGteSpecSchema,
|
|
719
|
+
AssertedNativeBalanceGteSpecSchema,
|
|
720
|
+
AssertedPredicateSchema,
|
|
721
|
+
AssertedPredicateZod,
|
|
722
|
+
AssertionOwnerSchema,
|
|
723
|
+
AssertionSpecSchema,
|
|
724
|
+
AssertionSpecZod,
|
|
362
725
|
BindValueSchema,
|
|
726
|
+
Bytes32HexSchema,
|
|
727
|
+
CONTINUATION_COMMITMENT_OP_ID,
|
|
728
|
+
CallCheckSpecSchema,
|
|
363
729
|
CallSchema,
|
|
730
|
+
CheckSchema,
|
|
731
|
+
CheckZod,
|
|
364
732
|
ComposeManifestZod,
|
|
733
|
+
ContinuationIntentSchema,
|
|
734
|
+
ContinuationOutcomeSchema,
|
|
735
|
+
ContinuationPlanSchema,
|
|
736
|
+
ContinuationPlanZod,
|
|
365
737
|
ContinuationSchema,
|
|
738
|
+
EVM_NATIVE_SENTINEL,
|
|
739
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
740
|
+
Erc20BalanceGteSpecSchema,
|
|
366
741
|
FlowInputSchema,
|
|
367
742
|
FlowSchema,
|
|
368
743
|
GuardCompatibilityZod,
|
|
@@ -371,14 +746,19 @@ export {
|
|
|
371
746
|
HandleInputSchema,
|
|
372
747
|
HandlePortZod,
|
|
373
748
|
HandleUnitsZod,
|
|
749
|
+
HexStringSchema,
|
|
374
750
|
InputPortZod,
|
|
375
751
|
LiteralBindingSchema,
|
|
376
752
|
ManifestGuardZod,
|
|
377
753
|
ManifestMaterialiserZod,
|
|
378
754
|
ManifestOperationZod,
|
|
379
755
|
ManifestPreconditionZod,
|
|
756
|
+
NativeBalanceDeltaGteSpecSchema,
|
|
757
|
+
NativeBalanceGteSpecSchema,
|
|
380
758
|
OutputPortZod,
|
|
381
759
|
PROVIDER_KIND,
|
|
760
|
+
Phase1ArtifactSchema,
|
|
761
|
+
Phase1ArtifactZod,
|
|
382
762
|
RESERVED_REF_SCOPES,
|
|
383
763
|
RefSchema,
|
|
384
764
|
ResourceInputSchema,
|
|
@@ -390,6 +770,12 @@ export {
|
|
|
390
770
|
STATIC_SOL_TYPES,
|
|
391
771
|
SolTypeSchema,
|
|
392
772
|
StaticSolTypeZod,
|
|
773
|
+
TEMPO_CHAIN_ID,
|
|
774
|
+
TEMPO_NATIVE_ERC20,
|
|
775
|
+
VerificationDescriptorSchema,
|
|
776
|
+
VerificationDescriptorZod,
|
|
777
|
+
canonicalAssertedPredicate,
|
|
778
|
+
canonicalNativeAddress,
|
|
393
779
|
copy,
|
|
394
780
|
erc20,
|
|
395
781
|
erc20Resource,
|
|
@@ -400,12 +786,19 @@ export {
|
|
|
400
786
|
foldMaterialiserMetadata,
|
|
401
787
|
foldRef,
|
|
402
788
|
foldResource,
|
|
789
|
+
getChainCapabilities,
|
|
403
790
|
handle,
|
|
404
791
|
inputRef,
|
|
792
|
+
isAsErc20Chain,
|
|
405
793
|
isContextKey,
|
|
794
|
+
isEQCheck,
|
|
406
795
|
isERC20Resource,
|
|
796
|
+
isGTECheck,
|
|
407
797
|
isHandlePort,
|
|
798
|
+
isLTECheck,
|
|
408
799
|
isMaterialiserInput,
|
|
800
|
+
isMsgValueNative,
|
|
801
|
+
isNativeAddressForChain,
|
|
409
802
|
isNativeResource,
|
|
410
803
|
isRef,
|
|
411
804
|
isResourceInput,
|
|
@@ -415,6 +808,8 @@ export {
|
|
|
415
808
|
linear,
|
|
416
809
|
native,
|
|
417
810
|
nativeResource,
|
|
811
|
+
normalizeNativeTokenAddress,
|
|
812
|
+
normalizeResource,
|
|
418
813
|
opHandle,
|
|
419
814
|
outputRef,
|
|
420
815
|
parseRef,
|
|
@@ -425,5 +820,6 @@ export {
|
|
|
425
820
|
resource,
|
|
426
821
|
resourceKey,
|
|
427
822
|
resourceOutput,
|
|
823
|
+
resourceToken,
|
|
428
824
|
resourcesEqual
|
|
429
825
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/compose-spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-staging.1",
|
|
4
4
|
"description": "Public wire-format types and schemas for Compose flows",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -28,18 +28,38 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
+
"prettier": {
|
|
32
|
+
"singleQuote": true
|
|
33
|
+
},
|
|
31
34
|
"scripts": {
|
|
32
35
|
"build": "yarn check:types && tsup",
|
|
33
36
|
"check:types": "tsc --noEmit",
|
|
34
37
|
"clean": "rm -rf dist out",
|
|
35
38
|
"pack:local": "yarn build && mkdir -p out && yarn pack --out 'out/%s-%v.tgz'",
|
|
36
|
-
"test": "vitest run --config vitest.config.ts"
|
|
39
|
+
"test": "vitest run --config vitest.config.ts",
|
|
40
|
+
"fix": "run-s fix:lint fix:prettier",
|
|
41
|
+
"fix:lint": "eslint src --fix",
|
|
42
|
+
"fix:prettier": "prettier \"src/**/*.ts\" --write",
|
|
43
|
+
"lint": "eslint src",
|
|
44
|
+
"test:lint": "eslint src",
|
|
45
|
+
"test:prettier": "prettier \"src/**/*.ts\" --list-different"
|
|
37
46
|
},
|
|
38
47
|
"dependencies": {
|
|
39
48
|
"effect": "^3.21.0",
|
|
40
49
|
"zod": "^4.1.11"
|
|
41
50
|
},
|
|
42
51
|
"devDependencies": {
|
|
52
|
+
"@eslint/compat": "^1.4.0",
|
|
53
|
+
"@lifi/eslint-plugin": "workspace:^",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.44.1",
|
|
55
|
+
"@typescript-eslint/parser": "^8.44.1",
|
|
56
|
+
"eslint": "^9.36.0",
|
|
57
|
+
"eslint-config-prettier": "^9.0.0",
|
|
58
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
59
|
+
"eslint-plugin-import": "^2.22.0",
|
|
60
|
+
"eslint-plugin-require-extensions": "^0.1.3",
|
|
61
|
+
"npm-run-all": "^4.1.5",
|
|
62
|
+
"prettier": "^3.9.4",
|
|
43
63
|
"tsup": "^8.5.1",
|
|
44
64
|
"typescript": "^5.9.2",
|
|
45
65
|
"vitest": "^3.2.4"
|