@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.cjs
CHANGED
|
@@ -31,10 +31,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AppliedGuardSchema: () => AppliedGuardSchema,
|
|
34
|
+
AssertedErc20BalanceGteSpecSchema: () => AssertedErc20BalanceGteSpecSchema,
|
|
35
|
+
AssertedNativeBalanceGteSpecSchema: () => AssertedNativeBalanceGteSpecSchema,
|
|
36
|
+
AssertedPredicateSchema: () => AssertedPredicateSchema,
|
|
37
|
+
AssertedPredicateZod: () => AssertedPredicateZod,
|
|
38
|
+
AssertionOwnerSchema: () => AssertionOwnerSchema,
|
|
39
|
+
AssertionSpecSchema: () => AssertionSpecSchema,
|
|
40
|
+
AssertionSpecZod: () => AssertionSpecZod,
|
|
34
41
|
BindValueSchema: () => BindValueSchema,
|
|
42
|
+
Bytes32HexSchema: () => Bytes32HexSchema,
|
|
43
|
+
CONTINUATION_COMMITMENT_OP_ID: () => CONTINUATION_COMMITMENT_OP_ID,
|
|
44
|
+
CallCheckSpecSchema: () => CallCheckSpecSchema,
|
|
35
45
|
CallSchema: () => CallSchema,
|
|
46
|
+
CheckSchema: () => CheckSchema,
|
|
47
|
+
CheckZod: () => CheckZod,
|
|
36
48
|
ComposeManifestZod: () => ComposeManifestZod,
|
|
49
|
+
ContinuationIntentSchema: () => ContinuationIntentSchema,
|
|
50
|
+
ContinuationOutcomeSchema: () => ContinuationOutcomeSchema,
|
|
51
|
+
ContinuationPlanSchema: () => ContinuationPlanSchema,
|
|
52
|
+
ContinuationPlanZod: () => ContinuationPlanZod,
|
|
37
53
|
ContinuationSchema: () => ContinuationSchema,
|
|
54
|
+
EVM_NATIVE_SENTINEL: () => EVM_NATIVE_SENTINEL,
|
|
55
|
+
Erc20BalanceDeltaGteSpecSchema: () => Erc20BalanceDeltaGteSpecSchema,
|
|
56
|
+
Erc20BalanceGteSpecSchema: () => Erc20BalanceGteSpecSchema,
|
|
38
57
|
FlowInputSchema: () => FlowInputSchema,
|
|
39
58
|
FlowSchema: () => FlowSchema,
|
|
40
59
|
GuardCompatibilityZod: () => GuardCompatibilityZod,
|
|
@@ -43,14 +62,19 @@ __export(index_exports, {
|
|
|
43
62
|
HandleInputSchema: () => HandleInputSchema,
|
|
44
63
|
HandlePortZod: () => HandlePortZod,
|
|
45
64
|
HandleUnitsZod: () => HandleUnitsZod,
|
|
65
|
+
HexStringSchema: () => HexStringSchema,
|
|
46
66
|
InputPortZod: () => InputPortZod,
|
|
47
67
|
LiteralBindingSchema: () => LiteralBindingSchema,
|
|
48
68
|
ManifestGuardZod: () => ManifestGuardZod,
|
|
49
69
|
ManifestMaterialiserZod: () => ManifestMaterialiserZod,
|
|
50
70
|
ManifestOperationZod: () => ManifestOperationZod,
|
|
51
71
|
ManifestPreconditionZod: () => ManifestPreconditionZod,
|
|
72
|
+
NativeBalanceDeltaGteSpecSchema: () => NativeBalanceDeltaGteSpecSchema,
|
|
73
|
+
NativeBalanceGteSpecSchema: () => NativeBalanceGteSpecSchema,
|
|
52
74
|
OutputPortZod: () => OutputPortZod,
|
|
53
75
|
PROVIDER_KIND: () => PROVIDER_KIND,
|
|
76
|
+
Phase1ArtifactSchema: () => Phase1ArtifactSchema,
|
|
77
|
+
Phase1ArtifactZod: () => Phase1ArtifactZod,
|
|
54
78
|
RESERVED_REF_SCOPES: () => RESERVED_REF_SCOPES,
|
|
55
79
|
RefSchema: () => RefSchema,
|
|
56
80
|
ResourceInputSchema: () => ResourceInputSchema,
|
|
@@ -62,6 +86,12 @@ __export(index_exports, {
|
|
|
62
86
|
STATIC_SOL_TYPES: () => STATIC_SOL_TYPES,
|
|
63
87
|
SolTypeSchema: () => SolTypeSchema,
|
|
64
88
|
StaticSolTypeZod: () => StaticSolTypeZod,
|
|
89
|
+
TEMPO_CHAIN_ID: () => TEMPO_CHAIN_ID,
|
|
90
|
+
TEMPO_NATIVE_ERC20: () => TEMPO_NATIVE_ERC20,
|
|
91
|
+
VerificationDescriptorSchema: () => VerificationDescriptorSchema,
|
|
92
|
+
VerificationDescriptorZod: () => VerificationDescriptorZod,
|
|
93
|
+
canonicalAssertedPredicate: () => canonicalAssertedPredicate,
|
|
94
|
+
canonicalNativeAddress: () => canonicalNativeAddress,
|
|
65
95
|
copy: () => copy,
|
|
66
96
|
erc20: () => erc20,
|
|
67
97
|
erc20Resource: () => erc20Resource,
|
|
@@ -72,12 +102,19 @@ __export(index_exports, {
|
|
|
72
102
|
foldMaterialiserMetadata: () => foldMaterialiserMetadata,
|
|
73
103
|
foldRef: () => foldRef,
|
|
74
104
|
foldResource: () => foldResource,
|
|
105
|
+
getChainCapabilities: () => getChainCapabilities,
|
|
75
106
|
handle: () => handle,
|
|
76
107
|
inputRef: () => inputRef,
|
|
108
|
+
isAsErc20Chain: () => isAsErc20Chain,
|
|
77
109
|
isContextKey: () => isContextKey,
|
|
110
|
+
isEQCheck: () => isEQCheck,
|
|
78
111
|
isERC20Resource: () => isERC20Resource,
|
|
112
|
+
isGTECheck: () => isGTECheck,
|
|
79
113
|
isHandlePort: () => isHandlePort,
|
|
114
|
+
isLTECheck: () => isLTECheck,
|
|
80
115
|
isMaterialiserInput: () => isMaterialiserInput,
|
|
116
|
+
isMsgValueNative: () => isMsgValueNative,
|
|
117
|
+
isNativeAddressForChain: () => isNativeAddressForChain,
|
|
81
118
|
isNativeResource: () => isNativeResource,
|
|
82
119
|
isRef: () => isRef,
|
|
83
120
|
isResourceInput: () => isResourceInput,
|
|
@@ -87,6 +124,8 @@ __export(index_exports, {
|
|
|
87
124
|
linear: () => linear,
|
|
88
125
|
native: () => native,
|
|
89
126
|
nativeResource: () => nativeResource,
|
|
127
|
+
normalizeNativeTokenAddress: () => normalizeNativeTokenAddress,
|
|
128
|
+
normalizeResource: () => normalizeResource,
|
|
90
129
|
opHandle: () => opHandle,
|
|
91
130
|
outputRef: () => outputRef,
|
|
92
131
|
parseRef: () => parseRef,
|
|
@@ -97,12 +136,61 @@ __export(index_exports, {
|
|
|
97
136
|
resource: () => resource,
|
|
98
137
|
resourceKey: () => resourceKey,
|
|
99
138
|
resourceOutput: () => resourceOutput,
|
|
139
|
+
resourceToken: () => resourceToken,
|
|
100
140
|
resourcesEqual: () => resourcesEqual
|
|
101
141
|
});
|
|
102
142
|
module.exports = __toCommonJS(index_exports);
|
|
103
143
|
|
|
104
144
|
// src/flowSchema.ts
|
|
105
145
|
var import_effect = require("effect");
|
|
146
|
+
|
|
147
|
+
// src/chainCapabilities.ts
|
|
148
|
+
var EVM_NATIVE_SENTINEL = (
|
|
149
|
+
// 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
|
|
150
|
+
"0x0000000000000000000000000000000000000000"
|
|
151
|
+
);
|
|
152
|
+
var isNativeSentinel = (address) => address.toLowerCase() === EVM_NATIVE_SENTINEL.toLowerCase();
|
|
153
|
+
var TEMPO_CHAIN_ID = 4217;
|
|
154
|
+
var TEMPO_NATIVE_ERC20 = {
|
|
155
|
+
token: "0x20C0000000000000000000000000000000000000",
|
|
156
|
+
symbol: "pathUSD",
|
|
157
|
+
decimals: 6
|
|
158
|
+
};
|
|
159
|
+
var REGISTRY = /* @__PURE__ */ new Map([
|
|
160
|
+
[
|
|
161
|
+
TEMPO_CHAIN_ID,
|
|
162
|
+
{
|
|
163
|
+
kind: "as-erc20",
|
|
164
|
+
chainId: TEMPO_CHAIN_ID,
|
|
165
|
+
nativeErc20: TEMPO_NATIVE_ERC20
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
]);
|
|
169
|
+
var getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? { kind: "evm-native", chainId };
|
|
170
|
+
var isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
|
|
171
|
+
var canonicalNativeAddress = (chainId) => {
|
|
172
|
+
const caps = getChainCapabilities(chainId);
|
|
173
|
+
return caps.kind === "as-erc20" ? caps.nativeErc20.token : EVM_NATIVE_SENTINEL;
|
|
174
|
+
};
|
|
175
|
+
var isNativeAddressForChain = (chainId, address) => {
|
|
176
|
+
const caps = getChainCapabilities(chainId);
|
|
177
|
+
const target = caps.kind === "as-erc20" ? caps.nativeErc20.token : EVM_NATIVE_SENTINEL;
|
|
178
|
+
return address.toLowerCase() === target.toLowerCase();
|
|
179
|
+
};
|
|
180
|
+
var isMsgValueNative = (chainId, address) => !isAsErc20Chain(chainId) && isNativeSentinel(address);
|
|
181
|
+
var normalizeResource = (r) => {
|
|
182
|
+
if (r.kind !== "native") return r;
|
|
183
|
+
const caps = getChainCapabilities(r.chainId);
|
|
184
|
+
if (caps.kind !== "as-erc20") return r;
|
|
185
|
+
return {
|
|
186
|
+
kind: "erc20",
|
|
187
|
+
chainId: r.chainId,
|
|
188
|
+
token: caps.nativeErc20.token
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
var normalizeNativeTokenAddress = (token, chainId) => isAsErc20Chain(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
|
|
192
|
+
|
|
193
|
+
// src/flowSchema.ts
|
|
106
194
|
var SolTypeSchema = import_effect.Schema.Literal(
|
|
107
195
|
"uint8",
|
|
108
196
|
"uint16",
|
|
@@ -119,8 +207,11 @@ var SolTypeSchema = import_effect.Schema.Literal(
|
|
|
119
207
|
"bytes32",
|
|
120
208
|
"string"
|
|
121
209
|
);
|
|
122
|
-
var ChainIdSchema = import_effect.Schema.Number.pipe(
|
|
123
|
-
|
|
210
|
+
var ChainIdSchema = import_effect.Schema.Number.pipe(
|
|
211
|
+
import_effect.Schema.int(),
|
|
212
|
+
import_effect.Schema.positive()
|
|
213
|
+
);
|
|
214
|
+
var RawResourceSchema = import_effect.Schema.Union(
|
|
124
215
|
import_effect.Schema.Struct({ kind: import_effect.Schema.Literal("native"), chainId: ChainIdSchema }),
|
|
125
216
|
import_effect.Schema.Struct({
|
|
126
217
|
kind: import_effect.Schema.Literal("erc20"),
|
|
@@ -128,6 +219,15 @@ var ResourceSchema = import_effect.Schema.Union(
|
|
|
128
219
|
chainId: ChainIdSchema
|
|
129
220
|
})
|
|
130
221
|
);
|
|
222
|
+
var ResourceSchema = import_effect.Schema.transform(
|
|
223
|
+
RawResourceSchema,
|
|
224
|
+
import_effect.Schema.typeSchema(RawResourceSchema),
|
|
225
|
+
{
|
|
226
|
+
strict: true,
|
|
227
|
+
decode: (raw) => normalizeResource(raw),
|
|
228
|
+
encode: (resource2) => resource2
|
|
229
|
+
}
|
|
230
|
+
);
|
|
131
231
|
var ResourceInputSchema = import_effect.Schema.Struct({
|
|
132
232
|
name: import_effect.Schema.String,
|
|
133
233
|
resource: ResourceSchema
|
|
@@ -179,8 +279,196 @@ var FlowSchema = import_effect.Schema.Struct({
|
|
|
179
279
|
chainId: ChainIdSchema,
|
|
180
280
|
inputs: import_effect.Schema.Array(FlowInputSchema),
|
|
181
281
|
nodes: import_effect.Schema.Array(CallSchema),
|
|
182
|
-
|
|
282
|
+
continuations: import_effect.Schema.optional(import_effect.Schema.Array(ContinuationSchema))
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// src/continuation.ts
|
|
286
|
+
var import_effect2 = require("effect");
|
|
287
|
+
var CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
|
|
288
|
+
var RawContinuationOutcomeSchema = import_effect2.Schema.Struct({
|
|
289
|
+
token: import_effect2.Schema.String,
|
|
290
|
+
minAmount: import_effect2.Schema.String,
|
|
291
|
+
destination: import_effect2.Schema.String,
|
|
292
|
+
chainId: ChainIdSchema
|
|
293
|
+
});
|
|
294
|
+
var ContinuationOutcomeSchema = import_effect2.Schema.transform(
|
|
295
|
+
RawContinuationOutcomeSchema,
|
|
296
|
+
import_effect2.Schema.typeSchema(RawContinuationOutcomeSchema),
|
|
297
|
+
{
|
|
298
|
+
strict: true,
|
|
299
|
+
decode: (raw) => ({
|
|
300
|
+
...raw,
|
|
301
|
+
token: normalizeNativeTokenAddress(raw.token, raw.chainId)
|
|
302
|
+
}),
|
|
303
|
+
encode: (outcome) => outcome
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
var ContinuationIntentSchema = import_effect2.Schema.Struct({
|
|
307
|
+
// `NonEmptyArray` enforces ≥1 outcome at the parse boundary, so downstream needs no guard.
|
|
308
|
+
outcomes: import_effect2.Schema.NonEmptyArray(ContinuationOutcomeSchema),
|
|
309
|
+
continuationFlow: import_effect2.Schema.optional(FlowSchema),
|
|
310
|
+
validity: import_effect2.Schema.Struct({ expiresAtMs: import_effect2.Schema.Number }),
|
|
311
|
+
perpetual: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
|
|
312
|
+
provider: import_effect2.Schema.optional(import_effect2.Schema.String)
|
|
313
|
+
});
|
|
314
|
+
var Phase1ArtifactSchema = import_effect2.Schema.Union(
|
|
315
|
+
import_effect2.Schema.Struct({
|
|
316
|
+
kind: import_effect2.Schema.Literal("transaction"),
|
|
317
|
+
transactionRequest: import_effect2.Schema.optional(
|
|
318
|
+
import_effect2.Schema.Struct({
|
|
319
|
+
to: import_effect2.Schema.String,
|
|
320
|
+
data: import_effect2.Schema.String,
|
|
321
|
+
value: import_effect2.Schema.String
|
|
322
|
+
})
|
|
323
|
+
)
|
|
324
|
+
}),
|
|
325
|
+
import_effect2.Schema.Struct({
|
|
326
|
+
kind: import_effect2.Schema.Literal("signables"),
|
|
327
|
+
typedData: import_effect2.Schema.Array(import_effect2.Schema.Unknown)
|
|
328
|
+
}),
|
|
329
|
+
import_effect2.Schema.Struct({ kind: import_effect2.Schema.Literal("none") })
|
|
330
|
+
);
|
|
331
|
+
var HexStringSchema = import_effect2.Schema.String.pipe(import_effect2.Schema.startsWith("0x"));
|
|
332
|
+
var AssertionOwnerSchema = import_effect2.Schema.Union(
|
|
333
|
+
HexStringSchema,
|
|
334
|
+
import_effect2.Schema.Literal("escrow", "delivery")
|
|
335
|
+
);
|
|
336
|
+
var Erc20BalanceGteSpecSchema = import_effect2.Schema.Struct({
|
|
337
|
+
kind: import_effect2.Schema.Literal("erc20BalanceGte"),
|
|
338
|
+
chainId: ChainIdSchema,
|
|
339
|
+
token: HexStringSchema,
|
|
340
|
+
owner: HexStringSchema,
|
|
341
|
+
minAmount: import_effect2.Schema.String
|
|
342
|
+
});
|
|
343
|
+
var NativeBalanceGteSpecSchema = import_effect2.Schema.Struct({
|
|
344
|
+
kind: import_effect2.Schema.Literal("nativeBalanceGte"),
|
|
345
|
+
chainId: ChainIdSchema,
|
|
346
|
+
owner: HexStringSchema,
|
|
347
|
+
minAmount: import_effect2.Schema.String
|
|
348
|
+
});
|
|
349
|
+
var CallCheckSpecSchema = import_effect2.Schema.Struct({
|
|
350
|
+
kind: import_effect2.Schema.Literal("call"),
|
|
351
|
+
chainId: ChainIdSchema,
|
|
352
|
+
to: HexStringSchema,
|
|
353
|
+
calldata: HexStringSchema,
|
|
354
|
+
comparator: import_effect2.Schema.Literal("gte", "eq", "lte"),
|
|
355
|
+
value: import_effect2.Schema.String
|
|
356
|
+
});
|
|
357
|
+
var asErc20BalanceGteCheck = (chainId, owner, minAmount) => ({
|
|
358
|
+
kind: "erc20BalanceGte",
|
|
359
|
+
chainId,
|
|
360
|
+
token: canonicalNativeAddress(chainId),
|
|
361
|
+
owner,
|
|
362
|
+
minAmount
|
|
363
|
+
});
|
|
364
|
+
var RawCheckSchema = import_effect2.Schema.Union(
|
|
365
|
+
Erc20BalanceGteSpecSchema,
|
|
366
|
+
NativeBalanceGteSpecSchema,
|
|
367
|
+
CallCheckSpecSchema
|
|
368
|
+
);
|
|
369
|
+
var CheckSchema = import_effect2.Schema.transform(
|
|
370
|
+
RawCheckSchema,
|
|
371
|
+
import_effect2.Schema.typeSchema(RawCheckSchema),
|
|
372
|
+
{
|
|
373
|
+
strict: true,
|
|
374
|
+
decode: (check) => check.kind === "nativeBalanceGte" && isAsErc20Chain(check.chainId) ? asErc20BalanceGteCheck(check.chainId, check.owner, check.minAmount) : check,
|
|
375
|
+
encode: (check) => check
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
var Erc20BalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
|
|
379
|
+
kind: import_effect2.Schema.Literal("erc20BalanceDeltaGte"),
|
|
380
|
+
chainId: ChainIdSchema,
|
|
381
|
+
token: HexStringSchema,
|
|
382
|
+
owner: AssertionOwnerSchema,
|
|
383
|
+
minDelta: import_effect2.Schema.String
|
|
183
384
|
});
|
|
385
|
+
var NativeBalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
|
|
386
|
+
kind: import_effect2.Schema.Literal("nativeBalanceDeltaGte"),
|
|
387
|
+
chainId: ChainIdSchema,
|
|
388
|
+
owner: AssertionOwnerSchema,
|
|
389
|
+
minDelta: import_effect2.Schema.String
|
|
390
|
+
});
|
|
391
|
+
var AssertionSpecSchema = import_effect2.Schema.Union(
|
|
392
|
+
Erc20BalanceGteSpecSchema,
|
|
393
|
+
NativeBalanceGteSpecSchema,
|
|
394
|
+
CallCheckSpecSchema,
|
|
395
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
396
|
+
NativeBalanceDeltaGteSpecSchema
|
|
397
|
+
);
|
|
398
|
+
var ContinuationPlanSchema = import_effect2.Schema.Struct({
|
|
399
|
+
chainId: ChainIdSchema,
|
|
400
|
+
nextFlow: FlowSchema,
|
|
401
|
+
check: CheckSchema,
|
|
402
|
+
validity: import_effect2.Schema.Struct({ expiresAtMs: import_effect2.Schema.Number }),
|
|
403
|
+
correlationId: import_effect2.Schema.optional(import_effect2.Schema.String)
|
|
404
|
+
});
|
|
405
|
+
var isGTECheck = (check) => check.kind === "call" && check.comparator === "gte";
|
|
406
|
+
var isLTECheck = (check) => check.kind === "call" && check.comparator === "lte";
|
|
407
|
+
var isEQCheck = (check) => check.kind === "call" && check.comparator === "eq";
|
|
408
|
+
|
|
409
|
+
// src/descriptor.ts
|
|
410
|
+
var import_effect3 = require("effect");
|
|
411
|
+
|
|
412
|
+
// src/hexPatterns.ts
|
|
413
|
+
var BYTES32_LOWER_HEX = /^0x[0-9a-f]{64}$/;
|
|
414
|
+
|
|
415
|
+
// src/descriptor.ts
|
|
416
|
+
var Bytes32HexSchema = import_effect3.Schema.String.pipe(
|
|
417
|
+
import_effect3.Schema.pattern(BYTES32_LOWER_HEX)
|
|
418
|
+
);
|
|
419
|
+
var AssertedErc20BalanceGteSpecSchema = import_effect3.Schema.Struct({
|
|
420
|
+
kind: import_effect3.Schema.Literal("erc20BalanceGte"),
|
|
421
|
+
chainId: ChainIdSchema,
|
|
422
|
+
token: HexStringSchema,
|
|
423
|
+
owner: AssertionOwnerSchema,
|
|
424
|
+
minAmount: import_effect3.Schema.String
|
|
425
|
+
});
|
|
426
|
+
var AssertedNativeBalanceGteSpecSchema = import_effect3.Schema.Struct({
|
|
427
|
+
kind: import_effect3.Schema.Literal("nativeBalanceGte"),
|
|
428
|
+
chainId: ChainIdSchema,
|
|
429
|
+
owner: AssertionOwnerSchema,
|
|
430
|
+
minAmount: import_effect3.Schema.String
|
|
431
|
+
});
|
|
432
|
+
var RawAssertedPredicateSchema = import_effect3.Schema.Union(
|
|
433
|
+
AssertedErc20BalanceGteSpecSchema,
|
|
434
|
+
AssertedNativeBalanceGteSpecSchema,
|
|
435
|
+
CallCheckSpecSchema,
|
|
436
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
437
|
+
NativeBalanceDeltaGteSpecSchema
|
|
438
|
+
);
|
|
439
|
+
var AssertedPredicateSchema = import_effect3.Schema.transform(
|
|
440
|
+
RawAssertedPredicateSchema,
|
|
441
|
+
import_effect3.Schema.typeSchema(RawAssertedPredicateSchema),
|
|
442
|
+
{
|
|
443
|
+
strict: true,
|
|
444
|
+
decode: (pred) => pred.kind === "nativeBalanceGte" && isAsErc20Chain(pred.chainId) ? asErc20BalanceGteCheck(pred.chainId, pred.owner, pred.minAmount) : pred,
|
|
445
|
+
encode: (pred) => pred
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
var VerificationDescriptorSchema = import_effect3.Schema.Struct({
|
|
449
|
+
validationProgramHash: Bytes32HexSchema,
|
|
450
|
+
// The C5 echo's second hash (verified continuations, plan GD-8): `keccak256`
|
|
451
|
+
// over the canonical params vector (`paramsHash`, GD-2 seam C1). Required and
|
|
452
|
+
// jointly necessary with `validationProgramHash` — the program hash is
|
|
453
|
+
// value-blind (it never binds the delivery address or amounts), so a descriptor
|
|
454
|
+
// that enforces only it is a fund-redirect hole. Empty params still yield a
|
|
455
|
+
// present `0x00…00`, so a real descriptor never omits it. Strict 32-byte
|
|
456
|
+
// lowercase hex, same rule as `validationProgramHash`.
|
|
457
|
+
paramsHash: Bytes32HexSchema,
|
|
458
|
+
assertedPredicate: import_effect3.Schema.Array(AssertedPredicateSchema)
|
|
459
|
+
});
|
|
460
|
+
var canonicalJson = (value) => {
|
|
461
|
+
if (Array.isArray(value)) {
|
|
462
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
463
|
+
}
|
|
464
|
+
if (value !== null && typeof value === "object") {
|
|
465
|
+
const record = value;
|
|
466
|
+
const entries = Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`);
|
|
467
|
+
return `{${entries.join(",")}}`;
|
|
468
|
+
}
|
|
469
|
+
return JSON.stringify(value);
|
|
470
|
+
};
|
|
471
|
+
var canonicalAssertedPredicate = (specs) => canonicalJson(specs);
|
|
184
472
|
|
|
185
473
|
// src/flow.ts
|
|
186
474
|
var isResourceInput = (input) => "resource" in input;
|
|
@@ -214,6 +502,10 @@ var resourcesEqual = (a, b) => {
|
|
|
214
502
|
return false;
|
|
215
503
|
};
|
|
216
504
|
var foldResource = (r, cases) => r.kind === "native" ? cases.native(r.chainId) : cases.erc20(r.token, r.chainId);
|
|
505
|
+
var resourceToken = (r) => foldResource(r, {
|
|
506
|
+
native: () => EVM_NATIVE_SENTINEL,
|
|
507
|
+
erc20: (token) => token
|
|
508
|
+
});
|
|
217
509
|
var resourceKey = (r) => foldResource(r, {
|
|
218
510
|
native: (chainId) => `native:${chainId}`,
|
|
219
511
|
erc20: (token, chainId) => `erc20:${token.toLowerCase()}:${chainId}`
|
|
@@ -249,7 +541,7 @@ var inputRef = (port) => ({ $ref: `input.${port}` });
|
|
|
249
541
|
var outputRef = (node, port) => ({
|
|
250
542
|
$ref: `${node}.${port}`
|
|
251
543
|
});
|
|
252
|
-
var optionalProp = (key, value) => value
|
|
544
|
+
var optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
|
|
253
545
|
var linear = (name, type) => ({ name, type, mode: "linear", availability: "now" });
|
|
254
546
|
var copy = (name, type) => ({ name, type, mode: "copy", availability: "now" });
|
|
255
547
|
var handle = (name, type) => ({ name, type });
|
|
@@ -330,6 +622,7 @@ var foldMaterialiserMetadata = (meta, cases) => {
|
|
|
330
622
|
|
|
331
623
|
// src/zodSchemas.ts
|
|
332
624
|
var import_zod = __toESM(require("zod"), 1);
|
|
625
|
+
var chainIdZod = import_zod.default.number().int().positive();
|
|
333
626
|
var SolTypeZod = import_zod.default.enum([
|
|
334
627
|
"uint8",
|
|
335
628
|
"uint16",
|
|
@@ -460,13 +753,135 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
460
753
|
materialisers: import_zod.default.array(ManifestMaterialiserZod),
|
|
461
754
|
preconditions: import_zod.default.array(ManifestPreconditionZod).optional()
|
|
462
755
|
});
|
|
756
|
+
var Phase1ArtifactZod = import_zod.default.discriminatedUnion("kind", [
|
|
757
|
+
import_zod.default.object({
|
|
758
|
+
kind: import_zod.default.literal("transaction"),
|
|
759
|
+
transactionRequest: import_zod.default.object({
|
|
760
|
+
to: import_zod.default.string(),
|
|
761
|
+
data: import_zod.default.string(),
|
|
762
|
+
value: import_zod.default.string()
|
|
763
|
+
}).optional()
|
|
764
|
+
}),
|
|
765
|
+
import_zod.default.object({
|
|
766
|
+
kind: import_zod.default.literal("signables"),
|
|
767
|
+
typedData: import_zod.default.array(import_zod.default.unknown())
|
|
768
|
+
}),
|
|
769
|
+
import_zod.default.object({
|
|
770
|
+
kind: import_zod.default.literal("none")
|
|
771
|
+
})
|
|
772
|
+
]);
|
|
773
|
+
var hexStringZod = import_zod.default.string().startsWith("0x");
|
|
774
|
+
var assertionOwnerZod = import_zod.default.union([
|
|
775
|
+
hexStringZod,
|
|
776
|
+
import_zod.default.enum(["escrow", "delivery"])
|
|
777
|
+
]);
|
|
778
|
+
var CheckZod = import_zod.default.discriminatedUnion("kind", [
|
|
779
|
+
import_zod.default.object({
|
|
780
|
+
kind: import_zod.default.literal("erc20BalanceGte"),
|
|
781
|
+
chainId: chainIdZod,
|
|
782
|
+
token: hexStringZod,
|
|
783
|
+
owner: hexStringZod,
|
|
784
|
+
minAmount: import_zod.default.string()
|
|
785
|
+
}),
|
|
786
|
+
import_zod.default.object({
|
|
787
|
+
kind: import_zod.default.literal("nativeBalanceGte"),
|
|
788
|
+
chainId: chainIdZod,
|
|
789
|
+
owner: hexStringZod,
|
|
790
|
+
minAmount: import_zod.default.string()
|
|
791
|
+
}),
|
|
792
|
+
import_zod.default.object({
|
|
793
|
+
kind: import_zod.default.literal("call"),
|
|
794
|
+
chainId: chainIdZod,
|
|
795
|
+
to: hexStringZod,
|
|
796
|
+
calldata: hexStringZod,
|
|
797
|
+
comparator: import_zod.default.enum(["gte", "eq", "lte"]),
|
|
798
|
+
value: import_zod.default.string()
|
|
799
|
+
})
|
|
800
|
+
]);
|
|
801
|
+
var AssertionSpecZod = import_zod.default.discriminatedUnion("kind", [
|
|
802
|
+
...CheckZod.options,
|
|
803
|
+
import_zod.default.object({
|
|
804
|
+
kind: import_zod.default.literal("erc20BalanceDeltaGte"),
|
|
805
|
+
chainId: import_zod.default.number().int().positive(),
|
|
806
|
+
token: hexStringZod,
|
|
807
|
+
owner: assertionOwnerZod,
|
|
808
|
+
minDelta: import_zod.default.string()
|
|
809
|
+
}),
|
|
810
|
+
import_zod.default.object({
|
|
811
|
+
kind: import_zod.default.literal("nativeBalanceDeltaGte"),
|
|
812
|
+
chainId: import_zod.default.number().int().positive(),
|
|
813
|
+
owner: assertionOwnerZod,
|
|
814
|
+
minDelta: import_zod.default.string()
|
|
815
|
+
})
|
|
816
|
+
]);
|
|
817
|
+
var assertionSpecOptionByKind = (kind) => {
|
|
818
|
+
const option = AssertionSpecZod.options.find(
|
|
819
|
+
(o) => o.shape.kind.value === kind
|
|
820
|
+
);
|
|
821
|
+
if (option === void 0) {
|
|
822
|
+
throw new Error(`AssertionSpecZod has no member with kind "${kind}"`);
|
|
823
|
+
}
|
|
824
|
+
return option;
|
|
825
|
+
};
|
|
826
|
+
var AssertedPredicateZod = import_zod.default.discriminatedUnion("kind", [
|
|
827
|
+
import_zod.default.object({
|
|
828
|
+
kind: import_zod.default.literal("erc20BalanceGte"),
|
|
829
|
+
chainId: import_zod.default.number().int().positive(),
|
|
830
|
+
token: hexStringZod,
|
|
831
|
+
owner: assertionOwnerZod,
|
|
832
|
+
minAmount: import_zod.default.string()
|
|
833
|
+
}),
|
|
834
|
+
import_zod.default.object({
|
|
835
|
+
kind: import_zod.default.literal("nativeBalanceGte"),
|
|
836
|
+
chainId: import_zod.default.number().int().positive(),
|
|
837
|
+
owner: assertionOwnerZod,
|
|
838
|
+
minAmount: import_zod.default.string()
|
|
839
|
+
}),
|
|
840
|
+
assertionSpecOptionByKind("call"),
|
|
841
|
+
assertionSpecOptionByKind("erc20BalanceDeltaGte"),
|
|
842
|
+
assertionSpecOptionByKind("nativeBalanceDeltaGte")
|
|
843
|
+
]);
|
|
844
|
+
var VerificationDescriptorZod = import_zod.default.object({
|
|
845
|
+
validationProgramHash: import_zod.default.string().regex(BYTES32_LOWER_HEX),
|
|
846
|
+
// The C5 echo's second hash (GD-8): the params-vector content hash
|
|
847
|
+
// (`paramsHash`, C1). Required and jointly necessary with the value-blind
|
|
848
|
+
// `validationProgramHash`.
|
|
849
|
+
paramsHash: import_zod.default.string().regex(BYTES32_LOWER_HEX),
|
|
850
|
+
assertedPredicate: import_zod.default.array(AssertedPredicateZod)
|
|
851
|
+
});
|
|
852
|
+
var ContinuationPlanZod = import_zod.default.object({
|
|
853
|
+
chainId: chainIdZod,
|
|
854
|
+
nextFlow: import_zod.default.unknown(),
|
|
855
|
+
check: CheckZod,
|
|
856
|
+
validity: import_zod.default.object({ expiresAtMs: import_zod.default.number() }),
|
|
857
|
+
correlationId: import_zod.default.string().optional()
|
|
858
|
+
});
|
|
463
859
|
// Annotate the CommonJS export names for ESM import in node:
|
|
464
860
|
0 && (module.exports = {
|
|
465
861
|
AppliedGuardSchema,
|
|
862
|
+
AssertedErc20BalanceGteSpecSchema,
|
|
863
|
+
AssertedNativeBalanceGteSpecSchema,
|
|
864
|
+
AssertedPredicateSchema,
|
|
865
|
+
AssertedPredicateZod,
|
|
866
|
+
AssertionOwnerSchema,
|
|
867
|
+
AssertionSpecSchema,
|
|
868
|
+
AssertionSpecZod,
|
|
466
869
|
BindValueSchema,
|
|
870
|
+
Bytes32HexSchema,
|
|
871
|
+
CONTINUATION_COMMITMENT_OP_ID,
|
|
872
|
+
CallCheckSpecSchema,
|
|
467
873
|
CallSchema,
|
|
874
|
+
CheckSchema,
|
|
875
|
+
CheckZod,
|
|
468
876
|
ComposeManifestZod,
|
|
877
|
+
ContinuationIntentSchema,
|
|
878
|
+
ContinuationOutcomeSchema,
|
|
879
|
+
ContinuationPlanSchema,
|
|
880
|
+
ContinuationPlanZod,
|
|
469
881
|
ContinuationSchema,
|
|
882
|
+
EVM_NATIVE_SENTINEL,
|
|
883
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
884
|
+
Erc20BalanceGteSpecSchema,
|
|
470
885
|
FlowInputSchema,
|
|
471
886
|
FlowSchema,
|
|
472
887
|
GuardCompatibilityZod,
|
|
@@ -475,14 +890,19 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
475
890
|
HandleInputSchema,
|
|
476
891
|
HandlePortZod,
|
|
477
892
|
HandleUnitsZod,
|
|
893
|
+
HexStringSchema,
|
|
478
894
|
InputPortZod,
|
|
479
895
|
LiteralBindingSchema,
|
|
480
896
|
ManifestGuardZod,
|
|
481
897
|
ManifestMaterialiserZod,
|
|
482
898
|
ManifestOperationZod,
|
|
483
899
|
ManifestPreconditionZod,
|
|
900
|
+
NativeBalanceDeltaGteSpecSchema,
|
|
901
|
+
NativeBalanceGteSpecSchema,
|
|
484
902
|
OutputPortZod,
|
|
485
903
|
PROVIDER_KIND,
|
|
904
|
+
Phase1ArtifactSchema,
|
|
905
|
+
Phase1ArtifactZod,
|
|
486
906
|
RESERVED_REF_SCOPES,
|
|
487
907
|
RefSchema,
|
|
488
908
|
ResourceInputSchema,
|
|
@@ -494,6 +914,12 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
494
914
|
STATIC_SOL_TYPES,
|
|
495
915
|
SolTypeSchema,
|
|
496
916
|
StaticSolTypeZod,
|
|
917
|
+
TEMPO_CHAIN_ID,
|
|
918
|
+
TEMPO_NATIVE_ERC20,
|
|
919
|
+
VerificationDescriptorSchema,
|
|
920
|
+
VerificationDescriptorZod,
|
|
921
|
+
canonicalAssertedPredicate,
|
|
922
|
+
canonicalNativeAddress,
|
|
497
923
|
copy,
|
|
498
924
|
erc20,
|
|
499
925
|
erc20Resource,
|
|
@@ -504,12 +930,19 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
504
930
|
foldMaterialiserMetadata,
|
|
505
931
|
foldRef,
|
|
506
932
|
foldResource,
|
|
933
|
+
getChainCapabilities,
|
|
507
934
|
handle,
|
|
508
935
|
inputRef,
|
|
936
|
+
isAsErc20Chain,
|
|
509
937
|
isContextKey,
|
|
938
|
+
isEQCheck,
|
|
510
939
|
isERC20Resource,
|
|
940
|
+
isGTECheck,
|
|
511
941
|
isHandlePort,
|
|
942
|
+
isLTECheck,
|
|
512
943
|
isMaterialiserInput,
|
|
944
|
+
isMsgValueNative,
|
|
945
|
+
isNativeAddressForChain,
|
|
513
946
|
isNativeResource,
|
|
514
947
|
isRef,
|
|
515
948
|
isResourceInput,
|
|
@@ -519,6 +952,8 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
519
952
|
linear,
|
|
520
953
|
native,
|
|
521
954
|
nativeResource,
|
|
955
|
+
normalizeNativeTokenAddress,
|
|
956
|
+
normalizeResource,
|
|
522
957
|
opHandle,
|
|
523
958
|
outputRef,
|
|
524
959
|
parseRef,
|
|
@@ -529,5 +964,6 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
529
964
|
resource,
|
|
530
965
|
resourceKey,
|
|
531
966
|
resourceOutput,
|
|
967
|
+
resourceToken,
|
|
532
968
|
resourcesEqual
|
|
533
969
|
});
|