@lifi/compose-spec 0.2.0-staging.5 → 0.3.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 +448 -4
- package/dist/index.d.cts +1419 -115
- package/dist/index.d.ts +1419 -115
- package/dist/index.js +406 -4
- package/package.json +23 -3
- 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 +109 -17
- package/src/materialiserMetadata.ts +1 -1
- package/src/ref.ts +21 -21
- package/src/resource.ts +19 -9
- package/src/simulate.ts +183 -0
- 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,23 +62,36 @@ __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,
|
|
57
81
|
ResourceOutputPortZod: () => ResourceOutputPortZod,
|
|
58
82
|
ResourcePortZod: () => ResourcePortZod,
|
|
59
83
|
ResourceSchema: () => ResourceSchema,
|
|
84
|
+
SIMULATE_MAX_REQUIREMENTS: () => SIMULATE_MAX_REQUIREMENTS,
|
|
85
|
+
SIMULATE_MAX_TRACKED_BALANCES: () => SIMULATE_MAX_TRACKED_BALANCES,
|
|
60
86
|
STATIC_SOL_TYPES: () => STATIC_SOL_TYPES,
|
|
61
87
|
SolTypeSchema: () => SolTypeSchema,
|
|
62
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,
|
|
63
95
|
copy: () => copy,
|
|
64
96
|
erc20: () => erc20,
|
|
65
97
|
erc20Resource: () => erc20Resource,
|
|
@@ -70,12 +102,19 @@ __export(index_exports, {
|
|
|
70
102
|
foldMaterialiserMetadata: () => foldMaterialiserMetadata,
|
|
71
103
|
foldRef: () => foldRef,
|
|
72
104
|
foldResource: () => foldResource,
|
|
105
|
+
getChainCapabilities: () => getChainCapabilities,
|
|
73
106
|
handle: () => handle,
|
|
74
107
|
inputRef: () => inputRef,
|
|
108
|
+
isAsErc20Chain: () => isAsErc20Chain,
|
|
75
109
|
isContextKey: () => isContextKey,
|
|
110
|
+
isEQCheck: () => isEQCheck,
|
|
76
111
|
isERC20Resource: () => isERC20Resource,
|
|
112
|
+
isGTECheck: () => isGTECheck,
|
|
77
113
|
isHandlePort: () => isHandlePort,
|
|
114
|
+
isLTECheck: () => isLTECheck,
|
|
78
115
|
isMaterialiserInput: () => isMaterialiserInput,
|
|
116
|
+
isMsgValueNative: () => isMsgValueNative,
|
|
117
|
+
isNativeAddressForChain: () => isNativeAddressForChain,
|
|
79
118
|
isNativeResource: () => isNativeResource,
|
|
80
119
|
isRef: () => isRef,
|
|
81
120
|
isResourceInput: () => isResourceInput,
|
|
@@ -85,6 +124,8 @@ __export(index_exports, {
|
|
|
85
124
|
linear: () => linear,
|
|
86
125
|
native: () => native,
|
|
87
126
|
nativeResource: () => nativeResource,
|
|
127
|
+
normalizeNativeTokenAddress: () => normalizeNativeTokenAddress,
|
|
128
|
+
normalizeResource: () => normalizeResource,
|
|
88
129
|
opHandle: () => opHandle,
|
|
89
130
|
outputRef: () => outputRef,
|
|
90
131
|
parseRef: () => parseRef,
|
|
@@ -95,12 +136,61 @@ __export(index_exports, {
|
|
|
95
136
|
resource: () => resource,
|
|
96
137
|
resourceKey: () => resourceKey,
|
|
97
138
|
resourceOutput: () => resourceOutput,
|
|
139
|
+
resourceToken: () => resourceToken,
|
|
98
140
|
resourcesEqual: () => resourcesEqual
|
|
99
141
|
});
|
|
100
142
|
module.exports = __toCommonJS(index_exports);
|
|
101
143
|
|
|
102
144
|
// src/flowSchema.ts
|
|
103
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
|
|
104
194
|
var SolTypeSchema = import_effect.Schema.Literal(
|
|
105
195
|
"uint8",
|
|
106
196
|
"uint16",
|
|
@@ -117,8 +207,11 @@ var SolTypeSchema = import_effect.Schema.Literal(
|
|
|
117
207
|
"bytes32",
|
|
118
208
|
"string"
|
|
119
209
|
);
|
|
120
|
-
var ChainIdSchema = import_effect.Schema.Number.pipe(
|
|
121
|
-
|
|
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(
|
|
122
215
|
import_effect.Schema.Struct({ kind: import_effect.Schema.Literal("native"), chainId: ChainIdSchema }),
|
|
123
216
|
import_effect.Schema.Struct({
|
|
124
217
|
kind: import_effect.Schema.Literal("erc20"),
|
|
@@ -126,6 +219,15 @@ var ResourceSchema = import_effect.Schema.Union(
|
|
|
126
219
|
chainId: ChainIdSchema
|
|
127
220
|
})
|
|
128
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
|
+
);
|
|
129
231
|
var ResourceInputSchema = import_effect.Schema.Struct({
|
|
130
232
|
name: import_effect.Schema.String,
|
|
131
233
|
resource: ResourceSchema
|
|
@@ -177,9 +279,197 @@ var FlowSchema = import_effect.Schema.Struct({
|
|
|
177
279
|
chainId: ChainIdSchema,
|
|
178
280
|
inputs: import_effect.Schema.Array(FlowInputSchema),
|
|
179
281
|
nodes: import_effect.Schema.Array(CallSchema),
|
|
180
|
-
|
|
282
|
+
continuations: import_effect.Schema.optional(import_effect.Schema.Array(ContinuationSchema))
|
|
181
283
|
});
|
|
182
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
|
|
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);
|
|
472
|
+
|
|
183
473
|
// src/flow.ts
|
|
184
474
|
var isResourceInput = (input) => "resource" in input;
|
|
185
475
|
var flowInputType = (input) => isResourceInput(input) ? "uint256" : input.type;
|
|
@@ -212,6 +502,10 @@ var resourcesEqual = (a, b) => {
|
|
|
212
502
|
return false;
|
|
213
503
|
};
|
|
214
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
|
+
});
|
|
215
509
|
var resourceKey = (r) => foldResource(r, {
|
|
216
510
|
native: (chainId) => `native:${chainId}`,
|
|
217
511
|
erc20: (token, chainId) => `erc20:${token.toLowerCase()}:${chainId}`
|
|
@@ -247,7 +541,7 @@ var inputRef = (port) => ({ $ref: `input.${port}` });
|
|
|
247
541
|
var outputRef = (node, port) => ({
|
|
248
542
|
$ref: `${node}.${port}`
|
|
249
543
|
});
|
|
250
|
-
var optionalProp = (key, value) => value
|
|
544
|
+
var optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
|
|
251
545
|
var linear = (name, type) => ({ name, type, mode: "linear", availability: "now" });
|
|
252
546
|
var copy = (name, type) => ({ name, type, mode: "copy", availability: "now" });
|
|
253
547
|
var handle = (name, type) => ({ name, type });
|
|
@@ -315,6 +609,10 @@ var refKey = (ref) => foldRef(parseRef(ref), {
|
|
|
315
609
|
output: (node, port) => `output:${node}:${port}`
|
|
316
610
|
});
|
|
317
611
|
|
|
612
|
+
// src/simulate.ts
|
|
613
|
+
var SIMULATE_MAX_TRACKED_BALANCES = 40;
|
|
614
|
+
var SIMULATE_MAX_REQUIREMENTS = 40;
|
|
615
|
+
|
|
318
616
|
// src/materialiserMetadata.ts
|
|
319
617
|
var foldMaterialiserMetadata = (meta, cases) => {
|
|
320
618
|
if (meta.kind === "exact") return cases.exact(meta.amount);
|
|
@@ -324,6 +622,7 @@ var foldMaterialiserMetadata = (meta, cases) => {
|
|
|
324
622
|
|
|
325
623
|
// src/zodSchemas.ts
|
|
326
624
|
var import_zod = __toESM(require("zod"), 1);
|
|
625
|
+
var chainIdZod = import_zod.default.number().int().positive();
|
|
327
626
|
var SolTypeZod = import_zod.default.enum([
|
|
328
627
|
"uint8",
|
|
329
628
|
"uint16",
|
|
@@ -454,13 +753,135 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
454
753
|
materialisers: import_zod.default.array(ManifestMaterialiserZod),
|
|
455
754
|
preconditions: import_zod.default.array(ManifestPreconditionZod).optional()
|
|
456
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
|
+
});
|
|
457
859
|
// Annotate the CommonJS export names for ESM import in node:
|
|
458
860
|
0 && (module.exports = {
|
|
459
861
|
AppliedGuardSchema,
|
|
862
|
+
AssertedErc20BalanceGteSpecSchema,
|
|
863
|
+
AssertedNativeBalanceGteSpecSchema,
|
|
864
|
+
AssertedPredicateSchema,
|
|
865
|
+
AssertedPredicateZod,
|
|
866
|
+
AssertionOwnerSchema,
|
|
867
|
+
AssertionSpecSchema,
|
|
868
|
+
AssertionSpecZod,
|
|
460
869
|
BindValueSchema,
|
|
870
|
+
Bytes32HexSchema,
|
|
871
|
+
CONTINUATION_COMMITMENT_OP_ID,
|
|
872
|
+
CallCheckSpecSchema,
|
|
461
873
|
CallSchema,
|
|
874
|
+
CheckSchema,
|
|
875
|
+
CheckZod,
|
|
462
876
|
ComposeManifestZod,
|
|
877
|
+
ContinuationIntentSchema,
|
|
878
|
+
ContinuationOutcomeSchema,
|
|
879
|
+
ContinuationPlanSchema,
|
|
880
|
+
ContinuationPlanZod,
|
|
463
881
|
ContinuationSchema,
|
|
882
|
+
EVM_NATIVE_SENTINEL,
|
|
883
|
+
Erc20BalanceDeltaGteSpecSchema,
|
|
884
|
+
Erc20BalanceGteSpecSchema,
|
|
464
885
|
FlowInputSchema,
|
|
465
886
|
FlowSchema,
|
|
466
887
|
GuardCompatibilityZod,
|
|
@@ -469,23 +890,36 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
469
890
|
HandleInputSchema,
|
|
470
891
|
HandlePortZod,
|
|
471
892
|
HandleUnitsZod,
|
|
893
|
+
HexStringSchema,
|
|
472
894
|
InputPortZod,
|
|
473
895
|
LiteralBindingSchema,
|
|
474
896
|
ManifestGuardZod,
|
|
475
897
|
ManifestMaterialiserZod,
|
|
476
898
|
ManifestOperationZod,
|
|
477
899
|
ManifestPreconditionZod,
|
|
900
|
+
NativeBalanceDeltaGteSpecSchema,
|
|
901
|
+
NativeBalanceGteSpecSchema,
|
|
478
902
|
OutputPortZod,
|
|
479
903
|
PROVIDER_KIND,
|
|
904
|
+
Phase1ArtifactSchema,
|
|
905
|
+
Phase1ArtifactZod,
|
|
480
906
|
RESERVED_REF_SCOPES,
|
|
481
907
|
RefSchema,
|
|
482
908
|
ResourceInputSchema,
|
|
483
909
|
ResourceOutputPortZod,
|
|
484
910
|
ResourcePortZod,
|
|
485
911
|
ResourceSchema,
|
|
912
|
+
SIMULATE_MAX_REQUIREMENTS,
|
|
913
|
+
SIMULATE_MAX_TRACKED_BALANCES,
|
|
486
914
|
STATIC_SOL_TYPES,
|
|
487
915
|
SolTypeSchema,
|
|
488
916
|
StaticSolTypeZod,
|
|
917
|
+
TEMPO_CHAIN_ID,
|
|
918
|
+
TEMPO_NATIVE_ERC20,
|
|
919
|
+
VerificationDescriptorSchema,
|
|
920
|
+
VerificationDescriptorZod,
|
|
921
|
+
canonicalAssertedPredicate,
|
|
922
|
+
canonicalNativeAddress,
|
|
489
923
|
copy,
|
|
490
924
|
erc20,
|
|
491
925
|
erc20Resource,
|
|
@@ -496,12 +930,19 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
496
930
|
foldMaterialiserMetadata,
|
|
497
931
|
foldRef,
|
|
498
932
|
foldResource,
|
|
933
|
+
getChainCapabilities,
|
|
499
934
|
handle,
|
|
500
935
|
inputRef,
|
|
936
|
+
isAsErc20Chain,
|
|
501
937
|
isContextKey,
|
|
938
|
+
isEQCheck,
|
|
502
939
|
isERC20Resource,
|
|
940
|
+
isGTECheck,
|
|
503
941
|
isHandlePort,
|
|
942
|
+
isLTECheck,
|
|
504
943
|
isMaterialiserInput,
|
|
944
|
+
isMsgValueNative,
|
|
945
|
+
isNativeAddressForChain,
|
|
505
946
|
isNativeResource,
|
|
506
947
|
isRef,
|
|
507
948
|
isResourceInput,
|
|
@@ -511,6 +952,8 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
511
952
|
linear,
|
|
512
953
|
native,
|
|
513
954
|
nativeResource,
|
|
955
|
+
normalizeNativeTokenAddress,
|
|
956
|
+
normalizeResource,
|
|
514
957
|
opHandle,
|
|
515
958
|
outputRef,
|
|
516
959
|
parseRef,
|
|
@@ -521,5 +964,6 @@ var ComposeManifestZod = import_zod.default.object({
|
|
|
521
964
|
resource,
|
|
522
965
|
resourceKey,
|
|
523
966
|
resourceOutput,
|
|
967
|
+
resourceToken,
|
|
524
968
|
resourcesEqual
|
|
525
969
|
});
|