@lifi/compose-spec 0.7.1 → 0.9.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 CHANGED
@@ -1,1230 +1,1104 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
9
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
19
18
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- ARC_CHAIN_ID: () => ARC_CHAIN_ID,
34
- ARC_NATIVE_ERC20: () => ARC_NATIVE_ERC20,
35
- ARC_NATIVE_SCALE: () => ARC_NATIVE_SCALE,
36
- AppliedGuardSchema: () => AppliedGuardSchema,
37
- AssertedErc20BalanceGteSpecSchema: () => AssertedErc20BalanceGteSpecSchema,
38
- AssertedNativeBalanceGteSpecSchema: () => AssertedNativeBalanceGteSpecSchema,
39
- AssertedPredicateSchema: () => AssertedPredicateSchema,
40
- AssertedPredicateZod: () => AssertedPredicateZod,
41
- AssertionOwnerSchema: () => AssertionOwnerSchema,
42
- AssertionSpecSchema: () => AssertionSpecSchema,
43
- AssertionSpecZod: () => AssertionSpecZod,
44
- BindValueSchema: () => BindValueSchema,
45
- Bytes32HexSchema: () => Bytes32HexSchema,
46
- COMPOSER_SDK_VERSION_HEADER: () => COMPOSER_SDK_VERSION_HEADER,
47
- COMPOSE_VERSION_HEADER: () => COMPOSE_VERSION_HEADER,
48
- CONTINUATION_COMMITMENT_OP_ID: () => CONTINUATION_COMMITMENT_OP_ID,
49
- CallCheckSpecSchema: () => CallCheckSpecSchema,
50
- CallSchema: () => CallSchema,
51
- CheckSchema: () => CheckSchema,
52
- CheckZod: () => CheckZod,
53
- ComposeManifestZod: () => ComposeManifestZod,
54
- ContinuationIntentSchema: () => ContinuationIntentSchema,
55
- ContinuationOutcomeSchema: () => ContinuationOutcomeSchema,
56
- ContinuationPlanSchema: () => ContinuationPlanSchema,
57
- ContinuationPlanZod: () => ContinuationPlanZod,
58
- EVMAddressString: () => EVMAddressString,
59
- EVM_NATIVE_SENTINEL: () => EVM_NATIVE_SENTINEL,
60
- Erc20BalanceDeltaGteSpecSchema: () => Erc20BalanceDeltaGteSpecSchema,
61
- Erc20BalanceGteSpecSchema: () => Erc20BalanceGteSpecSchema,
62
- FlowInputSchema: () => FlowInputSchema,
63
- FlowSchema: () => FlowSchema,
64
- GuardCompatibilityZod: () => GuardCompatibilityZod,
65
- GuardSelectorZod: () => GuardSelectorZod,
66
- HANDLE_UNITS: () => HANDLE_UNITS,
67
- HandleInputSchema: () => HandleInputSchema,
68
- HandlePortZod: () => HandlePortZod,
69
- HandleUnitsZod: () => HandleUnitsZod,
70
- HexStringSchema: () => HexStringSchema,
71
- InputPortZod: () => InputPortZod,
72
- IntegerString: () => IntegerString,
73
- LineageSchema: () => LineageSchema,
74
- LiteralBindingSchema: () => LiteralBindingSchema,
75
- ManifestGuardZod: () => ManifestGuardZod,
76
- ManifestMaterialiserZod: () => ManifestMaterialiserZod,
77
- ManifestOperationZod: () => ManifestOperationZod,
78
- ManifestPreconditionZod: () => ManifestPreconditionZod,
79
- NativeBalanceDeltaGteSpecSchema: () => NativeBalanceDeltaGteSpecSchema,
80
- NativeBalanceGteSpecSchema: () => NativeBalanceGteSpecSchema,
81
- OutputPortZod: () => OutputPortZod,
82
- PROVIDER_KIND: () => PROVIDER_KIND,
83
- Phase1ArtifactSchema: () => Phase1ArtifactSchema,
84
- RESERVED_REF_SCOPES: () => RESERVED_REF_SCOPES,
85
- RefSchema: () => RefSchema,
86
- ResourceInputSchema: () => ResourceInputSchema,
87
- ResourceOutputPortZod: () => ResourceOutputPortZod,
88
- ResourcePortZod: () => ResourcePortZod,
89
- ResourceSchema: () => ResourceSchema,
90
- SIMULATE_MAX_REQUIREMENTS: () => SIMULATE_MAX_REQUIREMENTS,
91
- SIMULATE_MAX_TRACKED_BALANCES: () => SIMULATE_MAX_TRACKED_BALANCES,
92
- STATIC_SOL_TYPES: () => STATIC_SOL_TYPES,
93
- SettlementZod: () => SettlementZod,
94
- SolTypeSchema: () => SolTypeSchema,
95
- StaticSolTypeZod: () => StaticSolTypeZod,
96
- TEMPO_CHAIN_ID: () => TEMPO_CHAIN_ID,
97
- TEMPO_NATIVE_ERC20: () => TEMPO_NATIVE_ERC20,
98
- UuidSchema: () => UuidSchema,
99
- VerificationDescriptorSchema: () => VerificationDescriptorSchema,
100
- VerificationDescriptorZod: () => VerificationDescriptorZod,
101
- canonicalAssertedPredicate: () => canonicalAssertedPredicate,
102
- canonicalNativeAddress: () => canonicalNativeAddress,
103
- checkCompatibility: () => checkCompatibility,
104
- copy: () => copy,
105
- erc20: () => erc20,
106
- erc20Allowance: () => erc20Allowance,
107
- erc20Balance: () => erc20Balance,
108
- erc20Resource: () => erc20Resource,
109
- erc20Token: () => erc20Token,
110
- expandOutputPorts: () => expandOutputPorts,
111
- familySize: () => familySize,
112
- flowInputMode: () => flowInputMode,
113
- flowInputResource: () => flowInputResource,
114
- flowInputType: () => flowInputType,
115
- foldChainCapabilities: () => foldChainCapabilities,
116
- foldMaterialiserMetadata: () => foldMaterialiserMetadata,
117
- foldRef: () => foldRef,
118
- foldResource: () => foldResource,
119
- getChainCapabilities: () => getChainCapabilities,
120
- handle: () => handle,
121
- hasErc20CanonicalNative: () => hasErc20CanonicalNative,
122
- instancePortName: () => instancePortName,
123
- isAsErc20Chain: () => isAsErc20Chain,
124
- isContextKey: () => isContextKey,
125
- isEQCheck: () => isEQCheck,
126
- isERC20Resource: () => isERC20Resource,
127
- isErc20AllowancePrecondition: () => isErc20AllowancePrecondition,
128
- isErc20BalancePrecondition: () => isErc20BalancePrecondition,
129
- isFutureResourceOutput: () => isFutureResourceOutput,
130
- isGTECheck: () => isGTECheck,
131
- isHandlePort: () => isHandlePort,
132
- isLTECheck: () => isLTECheck,
133
- isMaterialiserInput: () => isMaterialiserInput,
134
- isMsgValueNative: () => isMsgValueNative,
135
- isNativeAddressForChain: () => isNativeAddressForChain,
136
- isNativeBalancePrecondition: () => isNativeBalancePrecondition,
137
- isNativeResource: () => isNativeResource,
138
- isOutputFamily: () => isOutputFamily,
139
- isRef: () => isRef,
140
- isResourceInput: () => isResourceInput,
141
- isResourceOutputPort: () => isResourceOutputPort,
142
- isResourcePort: () => isResourcePort,
143
- isStaticSolType: () => isStaticSolType,
144
- linear: () => linear,
145
- native: () => native,
146
- nativeBalance: () => nativeBalance,
147
- nativeCheckPolicy: () => nativeCheckPolicy,
148
- nativeResource: () => nativeResource,
149
- normalizeNativeTokenAddress: () => normalizeNativeTokenAddress,
150
- normalizeResource: () => normalizeResource,
151
- opHandle: () => opHandle,
152
- parseRef: () => parseRef,
153
- parseVersion: () => parseVersion,
154
- providerKindByName: () => providerKindByName,
155
- providerKindNames: () => providerKindNames,
156
- readResource: () => readResource,
157
- ref: () => ref,
158
- refKey: () => refKey,
159
- resource: () => resource,
160
- resourceKey: () => resourceKey,
161
- resourceOutput: () => resourceOutput,
162
- resourceToken: () => resourceToken,
163
- resourcesEqual: () => resourcesEqual,
164
- settledOutcome: () => settledOutcome
165
- });
166
- module.exports = __toCommonJS(index_exports);
167
-
168
- // src/flowSchema.ts
169
- var import_effect = require("effect");
170
-
171
- // src/chainCapabilities.ts
172
- var EVM_NATIVE_SENTINEL = (
173
- // 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
174
- "0x0000000000000000000000000000000000000000"
175
- );
176
- var isNativeSentinel = (address) => address.toLowerCase() === EVM_NATIVE_SENTINEL.toLowerCase();
177
- var TEMPO_CHAIN_ID = 4217;
178
- var TEMPO_NATIVE_ERC20 = {
179
- token: "0x20C0000000000000000000000000000000000000",
180
- symbol: "pathUSD",
181
- decimals: 6
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let effect = require("effect");
25
+ let zod = require("zod");
26
+ zod = __toESM(zod, 1);
27
+ //#region src/chainCapabilities.ts
28
+ /**
29
+ * The zero-address sentinel that represents the native gas coin on
30
+ * EVM-native chains. Exported so tests and call-sites can reference it
31
+ * by name rather than inlining 40 zeros.
32
+ *
33
+ * Inlined as a literal rather than imported from `@lifi/utils`: `compose-spec`
34
+ * is the wire-format leaf package and carries no `@lifi/*` dependencies
35
+ * (enforced by `scripts/check-compose-boundaries.mjs`).
36
+ */
37
+ const EVM_NATIVE_SENTINEL = "0x0000000000000000000000000000000000000000";
38
+ /**
39
+ * Whether `address` is the EVM-native zero-address sentinel, compared
40
+ * case-insensitively. Module-local: the two call-sites below share this exact
41
+ * comparison; it is not part of the package's public surface.
42
+ */
43
+ const isNativeSentinel = (address) => address.toLowerCase() === EVM_NATIVE_SENTINEL.toLowerCase();
44
+ const TEMPO_CHAIN_ID = 4217;
45
+ const TEMPO_NATIVE_ERC20 = {
46
+ token: "0x20C0000000000000000000000000000000000000",
47
+ symbol: "pathUSD",
48
+ decimals: 6
182
49
  };
183
- var ARC_CHAIN_ID = 5042;
184
- var ARC_NATIVE_ERC20 = {
185
- token: "0x3600000000000000000000000000000000000000",
186
- symbol: "USDC",
187
- decimals: 6
50
+ const ARC_CHAIN_ID = 5042;
51
+ /**
52
+ * Arc's native gas coin is USDC (18-decimal wei at the EVM level). The USDC
53
+ * ERC-20 at this address is a view over native balances: `balanceOf` returns
54
+ * `native wei / 1e12` and has no balance storage slot; allowances live in
55
+ * regular storage. The composer interacts with USDC exclusively through this
56
+ * facade, never via `msg.value`.
57
+ */
58
+ const ARC_NATIVE_ERC20 = {
59
+ token: "0x3600000000000000000000000000000000000000",
60
+ symbol: "USDC",
61
+ decimals: 6
188
62
  };
189
- var ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
190
- var REGISTRY = /* @__PURE__ */ new Map([
191
- [
192
- TEMPO_CHAIN_ID,
193
- {
194
- kind: "as-erc20",
195
- chainId: TEMPO_CHAIN_ID,
196
- nativeErc20: TEMPO_NATIVE_ERC20
197
- }
198
- ],
199
- [
200
- ARC_CHAIN_ID,
201
- {
202
- kind: "native-mirrored-erc20",
203
- chainId: ARC_CHAIN_ID,
204
- nativeErc20: ARC_NATIVE_ERC20,
205
- nativeScale: ARC_NATIVE_SCALE
206
- }
207
- ]
208
- ]);
209
- var getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? { kind: "evm-native", chainId };
210
- var foldChainCapabilities = (caps, cases) => {
211
- switch (caps.kind) {
212
- case "evm-native":
213
- return cases.evmNative(caps.chainId);
214
- case "as-erc20":
215
- return cases.asErc20(caps.nativeErc20, caps.chainId);
216
- case "native-mirrored-erc20":
217
- return cases.nativeMirroredErc20(
218
- caps.nativeErc20,
219
- caps.nativeScale,
220
- caps.chainId
221
- );
222
- }
63
+ const ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
64
+ const REGISTRY = /* @__PURE__ */ new Map([[TEMPO_CHAIN_ID, {
65
+ kind: "as-erc20",
66
+ chainId: TEMPO_CHAIN_ID,
67
+ nativeErc20: TEMPO_NATIVE_ERC20
68
+ }], [ARC_CHAIN_ID, {
69
+ kind: "native-mirrored-erc20",
70
+ chainId: ARC_CHAIN_ID,
71
+ nativeErc20: ARC_NATIVE_ERC20,
72
+ nativeScale: ARC_NATIVE_SCALE
73
+ }]]);
74
+ const getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? {
75
+ kind: "evm-native",
76
+ chainId
223
77
  };
224
- var nativeCheckPolicy = (chainId) => foldChainCapabilities(getChainCapabilities(chainId), {
225
- evmNative: () => ({ kind: "keep" }),
226
- asErc20: (nativeErc20) => ({ kind: "rewrite", token: nativeErc20.token }),
227
- nativeMirroredErc20: (nativeErc20) => ({
228
- kind: "reject",
229
- reason: `nativeBalanceGte is not accepted on chain ${chainId}: its canonical native asset is an ERC-20 facade whose units differ from native wei \u2014 author the check as erc20BalanceGte of ${nativeErc20.token}`
230
- })
78
+ /**
79
+ * Structural fold over the `ChainCapabilities` union — the capabilities
80
+ * counterpart of `foldResource`/`foldRef`. Dispatches on `kind` and hands each
81
+ * case its narrowed fields, so consumers that must branch on the native-asset
82
+ * policy (e.g. compose-core's `rewritePreconditions`) do so through one
83
+ * combinator whose exhaustiveness the compiler enforces: adding a new arm to
84
+ * the union above turns every `foldChainCapabilities` call into a type error
85
+ * until it handles the new case.
86
+ */
87
+ const foldChainCapabilities = (caps, cases) => {
88
+ switch (caps.kind) {
89
+ case "evm-native": return cases.evmNative(caps.chainId);
90
+ case "as-erc20": return cases.asErc20(caps.nativeErc20, caps.chainId);
91
+ case "native-mirrored-erc20": return cases.nativeMirroredErc20(caps.nativeErc20, caps.nativeScale, caps.chainId);
92
+ }
93
+ };
94
+ const nativeCheckPolicy = (chainId) => foldChainCapabilities(getChainCapabilities(chainId), {
95
+ evmNative: () => ({ kind: "keep" }),
96
+ asErc20: (nativeErc20) => ({
97
+ kind: "rewrite",
98
+ token: nativeErc20.token
99
+ }),
100
+ nativeMirroredErc20: (nativeErc20) => ({
101
+ kind: "reject",
102
+ reason: `nativeBalanceGte is not accepted on chain ${chainId}: its canonical native asset is an ERC-20 facade whose units differ from native wei — author the check as erc20BalanceGte of ${nativeErc20.token}`
103
+ })
231
104
  });
232
- var isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
233
- var erc20CanonicalNative = (caps) => caps.kind === "as-erc20" || caps.kind === "native-mirrored-erc20" ? caps.nativeErc20 : void 0;
234
- var hasErc20CanonicalNative = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId)) !== void 0;
235
- var canonicalNativeAddress = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId))?.token ?? EVM_NATIVE_SENTINEL;
236
- var isNativeAddressForChain = (chainId, address) => {
237
- const target = canonicalNativeAddress(chainId);
238
- return address.toLowerCase() === target.toLowerCase();
105
+ /**
106
+ * Exact-kind check for `as-erc20` (currently Tempo only) — the rare case that
107
+ * genuinely means "no `msg.value` coin exists on this chain". Most consumers
108
+ * want `hasErc20CanonicalNative` instead, which also covers
109
+ * `native-mirrored-erc20` chains (Arc), where the composer's ERC-20-only
110
+ * policy applies even though `msg.value` works. Code that must treat the two
111
+ * ERC-20-native kinds differently goes through `foldChainCapabilities` or
112
+ * `nativeCheckPolicy`, never a second exact-kind predicate.
113
+ */
114
+ const isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
115
+ /**
116
+ * The chain's stand-in native ERC-20 when its canonical native asset is an
117
+ * ERC-20 (`as-erc20` and `native-mirrored-erc20`), `undefined` on plain
118
+ * `evm-native` chains. Module-local narrowing helper behind the exported
119
+ * predicates and rewrites below.
120
+ */
121
+ const erc20CanonicalNative = (caps) => caps.kind === "as-erc20" || caps.kind === "native-mirrored-erc20" ? caps.nativeErc20 : void 0;
122
+ /**
123
+ * Whether the chain's canonical native asset is an ERC-20 — true for both
124
+ * `as-erc20` chains (Tempo: no `msg.value` coin exists) and
125
+ * `native-mirrored-erc20` chains (Arc: `msg.value` exists but is never used).
126
+ * This is the predicate for the shared resource-level behaviour: native
127
+ * resources are rewritten to the ERC-20, native routing edges are dropped, and
128
+ * a surviving native resource is a compile error.
129
+ */
130
+ const hasErc20CanonicalNative = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId)) !== void 0;
131
+ /**
132
+ * The address that represents the chain's native asset.
133
+ *
134
+ * On EVM-native chains this is the zero-address sentinel `0x0…0`. On chains
135
+ * whose canonical native asset is an ERC-20 it is the chain's stand-in token
136
+ * (PathUSD on Tempo, the USDC facade on Arc).
137
+ */
138
+ const canonicalNativeAddress = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId))?.token ?? "0x0000000000000000000000000000000000000000";
139
+ /**
140
+ * Whether `address` represents the native asset of `chainId`.
141
+ *
142
+ * On EVM-native chains, this is the case-insensitive zero-address check. On
143
+ * chains whose canonical native asset is an ERC-20, the literal zero address
144
+ * returns `false` — only the chain's stand-in ERC-20 address matches.
145
+ */
146
+ const isNativeAddressForChain = (chainId, address) => {
147
+ const target = canonicalNativeAddress(chainId);
148
+ return address.toLowerCase() === target.toLowerCase();
239
149
  };
240
- var isMsgValueNative = (chainId, address) => !hasErc20CanonicalNative(chainId) && isNativeSentinel(address);
241
- var normalizeResource = (r) => {
242
- if (r.kind !== "native") return r;
243
- const erc202 = erc20CanonicalNative(getChainCapabilities(r.chainId));
244
- if (erc202 === void 0) return r;
245
- return {
246
- kind: "erc20",
247
- chainId: r.chainId,
248
- token: erc202.token
249
- };
150
+ /**
151
+ * Whether `address` on `chainId` is the genuine `msg.value`-style native coin:
152
+ * an `evm-native` chain's zero-address sentinel.
153
+ *
154
+ * This is the single predicate that gates `msg.value` semantics — choosing a
155
+ * `NativeBalance` over an `Erc20Balance` simulation requirement, and skipping
156
+ * the ERC-20 approval a native input would otherwise need. It returns `false`
157
+ * for every address on a chain whose canonical native asset is an ERC-20
158
+ * (including the zero sentinel): on `as-erc20` chains the "native" coin is a
159
+ * real ERC-20 moved via `transferFrom`, never `msg.value`, and on
160
+ * `native-mirrored-erc20` chains `msg.value` works but the composer's policy
161
+ * is to move the coin exclusively through the ERC-20 facade. Use this rather
162
+ * than re-deriving the check at call sites, and rather than
163
+ * `isNativeAddressForChain`, which returns `true` for the stand-in ERC-20
164
+ * (PathUSD on Tempo) and would wrongly route it to `msg.value`.
165
+ */
166
+ const isMsgValueNative = (chainId, address) => !hasErc20CanonicalNative(chainId) && isNativeSentinel(address);
167
+ /**
168
+ * Rewrite a single `Resource` according to its chain's capabilities.
169
+ *
170
+ * On chains with the default `evm-native` policy, every resource is returned
171
+ * unchanged. On chains whose canonical native asset is an ERC-20 (`as-erc20`
172
+ * Tempo, `native-mirrored-erc20` Arc), a resource of kind `"native"` is
173
+ * rewritten into the equivalent ERC-20 resource pointing at the chain's
174
+ * stand-in token (PathUSD on Tempo, the USDC facade on Arc).
175
+ *
176
+ * This is the rewrite primitive behind the `ResourceSchema` decode transform
177
+ * (see `flowSchema.ts`), which is THE chokepoint: it runs every time a
178
+ * `Resource` is parsed — flow inputs via `FlowSchema`, op configs via
179
+ * `decodeConfig` — so every downstream pass (`normalizeFlow`, `resolve`,
180
+ * `lower`, `simulate`) sees only ERC-20 resources on those chains.
181
+ *
182
+ * The function preserves referential identity when nothing changes (returns the
183
+ * input `r` unchanged on evm-native chains and for ERC-20 resources) and is
184
+ * idempotent: running it on an already-rewritten resource is a no-op.
185
+ */
186
+ const normalizeResource = (r) => {
187
+ if (r.kind !== "native") return r;
188
+ const erc20 = erc20CanonicalNative(getChainCapabilities(r.chainId));
189
+ if (erc20 === void 0) return r;
190
+ return {
191
+ kind: "erc20",
192
+ chainId: r.chainId,
193
+ token: erc20.token
194
+ };
250
195
  };
251
- var normalizeNativeTokenAddress = (token, chainId) => hasErc20CanonicalNative(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
252
-
253
- // src/hexPatterns.ts
254
- var BYTES32_LOWER_HEX = /^0x[0-9a-f]{64}$/;
255
- var EVM_ADDRESS_HEX = /^0x[0-9a-fA-F]{40}$/;
256
- var HEX_BYTES = /^0x(?:[0-9a-fA-F]{2})*$/;
257
- var DECIMAL_UINT = /^[0-9]+$/;
258
- var MAX_UINT256 = 2n ** 256n - 1n;
259
- var MAX_DATE_MS = 864e13;
260
-
261
- // src/flowSchema.ts
262
- var SolTypeSchema = import_effect.Schema.Literal(
263
- "uint8",
264
- "uint16",
265
- "uint32",
266
- "uint64",
267
- "uint128",
268
- "uint256",
269
- "int128",
270
- "int256",
271
- "address",
272
- "bool",
273
- "bytes",
274
- "bytes4",
275
- "bytes32",
276
- "string"
277
- );
278
- var ChainIdSchema = import_effect.Schema.Number.pipe(
279
- import_effect.Schema.int(),
280
- import_effect.Schema.positive()
281
- );
282
- var EVMAddressString = import_effect.Schema.String.pipe(
283
- import_effect.Schema.pattern(EVM_ADDRESS_HEX, {
284
- message: () => "expected a 0x-prefixed 20-byte EVM address"
285
- })
286
- ).annotations({
287
- description: "EVM address: 0x followed by 40 hex characters"
196
+ /**
197
+ * Address-level counterpart of `normalizeResource` for wire fields that carry a
198
+ * native asset as a bare token string (a continuation outcome's `token`). On
199
+ * chains whose canonical native asset is an ERC-20, the native sentinel is
200
+ * rewritten to the chain's stand-in ERC-20; every other address passes through.
201
+ */
202
+ const normalizeNativeTokenAddress = (token, chainId) => hasErc20CanonicalNative(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
203
+ //#endregion
204
+ //#region src/hexPatterns.ts
205
+ const BYTES32_LOWER_HEX = /^0x[0-9a-f]{64}$/;
206
+ const EVM_ADDRESS_HEX = /^0x[0-9a-fA-F]{40}$/;
207
+ const HEX_BYTES = /^0x(?:[0-9a-fA-F]{2})*$/;
208
+ const DECIMAL_UINT = /^[0-9]+$/;
209
+ const MAX_UINT256 = 2n ** 256n - 1n;
210
+ const MAX_DATE_MS = 864e13;
211
+ //#endregion
212
+ //#region src/flowSchema.ts
213
+ const SolTypeSchema = effect.Schema.Literal("uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int128", "int256", "address", "bool", "bytes", "bytes4", "bytes32", "string");
214
+ const ChainIdSchema = effect.Schema.Number.pipe(effect.Schema.int(), effect.Schema.positive());
215
+ const EVMAddressString = effect.Schema.String.pipe(effect.Schema.pattern(EVM_ADDRESS_HEX, { message: () => "expected a 0x-prefixed 20-byte EVM address" })).annotations({ description: "EVM address: 0x followed by 40 hex characters" });
216
+ const HexBytesString = effect.Schema.String.pipe(effect.Schema.pattern(HEX_BYTES, { message: () => "expected 0x-prefixed hex of whole bytes" })).annotations({ description: "Hex bytes: 0x followed by an even number of hex characters" });
217
+ const EpochMsSchema = effect.Schema.Number.pipe(effect.Schema.int(), effect.Schema.between(-864e13, MAX_DATE_MS));
218
+ const IntegerString = effect.Schema.String.pipe(effect.Schema.filter((value) => {
219
+ if (!DECIMAL_UINT.test(value)) return "amount must be a decimal integer string";
220
+ if (BigInt(value) > MAX_UINT256) return "amount must not exceed uint256 max";
221
+ }));
222
+ const RawResourceSchema = effect.Schema.Union(effect.Schema.Struct({
223
+ kind: effect.Schema.Literal("native"),
224
+ chainId: ChainIdSchema
225
+ }), effect.Schema.Struct({
226
+ kind: effect.Schema.Literal("erc20"),
227
+ token: EVMAddressString,
228
+ chainId: ChainIdSchema
229
+ }));
230
+ /**
231
+ * THE chain-capabilities chokepoint.
232
+ *
233
+ * `ResourceSchema` is a decode transform: it parses the plain `native | erc20`
234
+ * wire union (`RawResourceSchema`) and then runs `normalizeResource`, so on
235
+ * `as-erc20` chains (e.g. Tempo) a `{ kind: "native", chainId }` resource is
236
+ * rewritten to its ERC-20 form (PathUSD) before any application code sees it.
237
+ * Because every Resource-bearing schema embeds this one — `FlowSchema` for flow
238
+ * inputs, op `configSchema`s for op configs — making the schema itself
239
+ * chain-aware covers every parsed entry point in one place.
240
+ *
241
+ * The `encode` direction is the identity: the ERC-20 form is itself valid wire
242
+ * format, and the rewrite is deliberately not reversible (we never want to
243
+ * re-introduce a `native` resource when serialising). `JSONSchema.make` derives
244
+ * the published wire format from the encoded (`from`) side, so the manifest
245
+ * keeps advertising the plain union with both arms.
246
+ */
247
+ const ResourceSchema = effect.Schema.transform(RawResourceSchema, effect.Schema.typeSchema(RawResourceSchema), {
248
+ strict: true,
249
+ decode: (raw) => normalizeResource(raw),
250
+ encode: (resource) => resource
288
251
  });
289
- var HexBytesString = import_effect.Schema.String.pipe(
290
- import_effect.Schema.pattern(HEX_BYTES, {
291
- message: () => "expected 0x-prefixed hex of whole bytes"
292
- })
293
- ).annotations({
294
- description: "Hex bytes: 0x followed by an even number of hex characters"
252
+ const ResourceInputSchema = effect.Schema.Struct({
253
+ name: effect.Schema.String,
254
+ resource: ResourceSchema
295
255
  });
296
- var EpochMsSchema = import_effect.Schema.Number.pipe(
297
- import_effect.Schema.int(),
298
- import_effect.Schema.between(-MAX_DATE_MS, MAX_DATE_MS)
299
- );
300
- var IntegerString = import_effect.Schema.String.pipe(
301
- // Both checks live in one filter so the uint256-bound test only ever runs
302
- // `BigInt` on a string the digit check already accepted — order-independent
303
- // and never throws on malformed input.
304
- import_effect.Schema.filter((value) => {
305
- if (!DECIMAL_UINT.test(value)) {
306
- return "amount must be a decimal integer string";
307
- }
308
- if (BigInt(value) > MAX_UINT256) {
309
- return "amount must not exceed uint256 max";
310
- }
311
- return void 0;
312
- })
313
- );
314
- var RawResourceSchema = import_effect.Schema.Union(
315
- import_effect.Schema.Struct({ kind: import_effect.Schema.Literal("native"), chainId: ChainIdSchema }),
316
- import_effect.Schema.Struct({
317
- kind: import_effect.Schema.Literal("erc20"),
318
- token: EVMAddressString,
319
- chainId: ChainIdSchema
320
- })
321
- );
322
- var ResourceSchema = import_effect.Schema.transform(
323
- RawResourceSchema,
324
- import_effect.Schema.typeSchema(RawResourceSchema),
325
- {
326
- strict: true,
327
- decode: (raw) => normalizeResource(raw),
328
- encode: (resource2) => resource2
329
- }
330
- );
331
- var ResourceInputSchema = import_effect.Schema.Struct({
332
- name: import_effect.Schema.String,
333
- resource: ResourceSchema
256
+ const HandleInputSchema = effect.Schema.Struct({
257
+ name: effect.Schema.String,
258
+ type: SolTypeSchema
334
259
  });
335
- var HandleInputSchema = import_effect.Schema.Struct({
336
- name: import_effect.Schema.String,
337
- type: SolTypeSchema
260
+ const FlowInputSchema = effect.Schema.Union(ResourceInputSchema, HandleInputSchema);
261
+ const RefSchema = effect.Schema.Struct({ $ref: effect.Schema.String.pipe(effect.Schema.filter((s) => s.indexOf(".") > 0, { message: () => "$ref must be a dotpath like \"input.name\" or \"nodeId.port\"" })) });
262
+ const LiteralBindingSchema = effect.Schema.Struct({
263
+ kind: SolTypeSchema,
264
+ value: effect.Schema.String
338
265
  });
339
- var FlowInputSchema = import_effect.Schema.Union(
340
- ResourceInputSchema,
341
- HandleInputSchema
342
- );
343
- var RefSchema = import_effect.Schema.Struct({
344
- $ref: import_effect.Schema.String.pipe(
345
- import_effect.Schema.filter((s) => s.indexOf(".") > 0, {
346
- message: () => '$ref must be a dotpath like "input.name" or "nodeId.port"'
347
- })
348
- )
266
+ const BindValueSchema = effect.Schema.Union(RefSchema, LiteralBindingSchema);
267
+ const AppliedGuardSchema = effect.Schema.Struct({ kind: effect.Schema.String }, {
268
+ key: effect.Schema.String,
269
+ value: effect.Schema.Unknown
349
270
  });
350
- var LiteralBindingSchema = import_effect.Schema.Struct({
351
- kind: SolTypeSchema,
352
- value: import_effect.Schema.String
271
+ const NodeIdSchema = effect.Schema.String.pipe(effect.Schema.filter((id) => id !== "__proto__", { message: () => "node id \"__proto__\" is reserved; choose another node id" }));
272
+ const CallSchema = effect.Schema.Struct({
273
+ id: NodeIdSchema,
274
+ op: effect.Schema.String,
275
+ bind: effect.Schema.optionalWith(effect.Schema.Record({
276
+ key: effect.Schema.String,
277
+ value: BindValueSchema
278
+ }), { default: () => ({}) }),
279
+ config: effect.Schema.optionalWith(effect.Schema.Record({
280
+ key: effect.Schema.String,
281
+ value: effect.Schema.Unknown
282
+ }), { default: () => ({}) }),
283
+ guards: effect.Schema.optional(effect.Schema.Array(AppliedGuardSchema))
353
284
  });
354
- var BindValueSchema = import_effect.Schema.Union(RefSchema, LiteralBindingSchema);
355
- var AppliedGuardSchema = import_effect.Schema.Struct(
356
- { kind: import_effect.Schema.String },
357
- { key: import_effect.Schema.String, value: import_effect.Schema.Unknown }
358
- );
359
- var NodeIdSchema = import_effect.Schema.String.pipe(
360
- import_effect.Schema.filter((id) => id !== "__proto__", {
361
- message: () => 'node id "__proto__" is reserved; choose another node id'
362
- })
363
- );
364
- var CallSchema = import_effect.Schema.Struct({
365
- id: NodeIdSchema,
366
- op: import_effect.Schema.String,
367
- bind: import_effect.Schema.optionalWith(
368
- import_effect.Schema.Record({ key: import_effect.Schema.String, value: BindValueSchema }),
369
- { default: () => ({}) }
370
- ),
371
- config: import_effect.Schema.optionalWith(
372
- import_effect.Schema.Record({ key: import_effect.Schema.String, value: import_effect.Schema.Unknown }),
373
- { default: () => ({}) }
374
- ),
375
- guards: import_effect.Schema.optional(import_effect.Schema.Array(AppliedGuardSchema))
285
+ const UuidSchema = effect.Schema.String.pipe(effect.Schema.pattern(/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/));
286
+ const LineageSchema = effect.Schema.Struct({
287
+ journeyId: UuidSchema,
288
+ parentRequestId: UuidSchema
376
289
  });
377
- var UuidSchema = import_effect.Schema.String.pipe(
378
- import_effect.Schema.pattern(/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/)
379
- );
380
- var LineageSchema = import_effect.Schema.Struct({
381
- journeyId: UuidSchema,
382
- parentRequestId: UuidSchema
290
+ const FlowSchema = effect.Schema.Struct({
291
+ version: effect.Schema.Literal(1),
292
+ id: effect.Schema.String,
293
+ chainId: ChainIdSchema,
294
+ inputs: effect.Schema.Array(FlowInputSchema),
295
+ nodes: effect.Schema.Array(CallSchema),
296
+ lineage: effect.Schema.optional(LineageSchema)
383
297
  });
384
- var FlowSchema = import_effect.Schema.Struct({
385
- version: import_effect.Schema.Literal(1),
386
- id: import_effect.Schema.String,
387
- chainId: ChainIdSchema,
388
- inputs: import_effect.Schema.Array(FlowInputSchema),
389
- nodes: import_effect.Schema.Array(CallSchema),
390
- lineage: import_effect.Schema.optional(LineageSchema)
298
+ //#endregion
299
+ //#region src/continuation.ts
300
+ const CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
301
+ const RawContinuationOutcomeSchema = effect.Schema.Struct({
302
+ token: EVMAddressString,
303
+ minAmount: IntegerString,
304
+ destination: EVMAddressString,
305
+ chainId: ChainIdSchema
391
306
  });
392
-
393
- // src/continuation.ts
394
- var import_effect2 = require("effect");
395
- var CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
396
- var RawContinuationOutcomeSchema = import_effect2.Schema.Struct({
397
- token: EVMAddressString,
398
- minAmount: IntegerString,
399
- destination: EVMAddressString,
400
- chainId: ChainIdSchema
307
+ const ContinuationOutcomeSchema = effect.Schema.transform(RawContinuationOutcomeSchema, effect.Schema.typeSchema(RawContinuationOutcomeSchema), {
308
+ strict: true,
309
+ decode: (raw) => ({
310
+ ...raw,
311
+ token: normalizeNativeTokenAddress(raw.token, raw.chainId)
312
+ }),
313
+ encode: (outcome) => outcome
401
314
  });
402
- var ContinuationOutcomeSchema = import_effect2.Schema.transform(
403
- RawContinuationOutcomeSchema,
404
- import_effect2.Schema.typeSchema(RawContinuationOutcomeSchema),
405
- {
406
- strict: true,
407
- decode: (raw) => ({
408
- ...raw,
409
- token: normalizeNativeTokenAddress(raw.token, raw.chainId)
410
- }),
411
- encode: (outcome) => outcome
412
- }
413
- );
414
- var ContinuationIntentSchema = import_effect2.Schema.Struct({
415
- // `NonEmptyArray` enforces ≥1 outcome at the parse boundary, so downstream needs no guard.
416
- outcomes: import_effect2.Schema.NonEmptyArray(ContinuationOutcomeSchema),
417
- continuationFlow: import_effect2.Schema.optional(FlowSchema),
418
- validity: import_effect2.Schema.Struct({ expiresAtMs: EpochMsSchema }),
419
- perpetual: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
420
- provider: import_effect2.Schema.optional(import_effect2.Schema.String),
421
- // Funding-path mode. The HTTP wire contract is documented by
422
- // `ComposeActionsSchema` in `@lifi/api-schemas`.
423
- funding: import_effect2.Schema.optional(import_effect2.Schema.Literal("inline", "external"))
315
+ const ContinuationIntentSchema = effect.Schema.Struct({
316
+ outcomes: effect.Schema.NonEmptyArray(ContinuationOutcomeSchema),
317
+ continuationFlow: effect.Schema.optional(FlowSchema),
318
+ validity: effect.Schema.Struct({ expiresAtMs: EpochMsSchema }),
319
+ perpetual: effect.Schema.optional(effect.Schema.Boolean),
320
+ provider: effect.Schema.optional(effect.Schema.String),
321
+ funding: effect.Schema.optional(effect.Schema.Literal("inline", "external"))
424
322
  });
425
- var HexStringSchema = import_effect2.Schema.String.pipe(import_effect2.Schema.startsWith("0x"));
426
- var Phase1EscrowSchema = import_effect2.Schema.Struct({
427
- chainId: ChainIdSchema,
428
- address: HexStringSchema,
429
- token: HexStringSchema,
430
- amount: import_effect2.Schema.String,
431
- cap: import_effect2.Schema.String,
432
- owner: HexStringSchema,
433
- refund: HexStringSchema,
434
- expiresAtMs: import_effect2.Schema.Number.pipe(import_effect2.Schema.int(), import_effect2.Schema.positive())
323
+ const HexStringSchema = effect.Schema.String.pipe(effect.Schema.startsWith("0x"));
324
+ const Phase1EscrowSchema = effect.Schema.Struct({
325
+ chainId: ChainIdSchema,
326
+ address: HexStringSchema,
327
+ token: HexStringSchema,
328
+ amount: effect.Schema.String,
329
+ cap: effect.Schema.String,
330
+ owner: HexStringSchema,
331
+ refund: HexStringSchema,
332
+ expiresAtMs: effect.Schema.Number.pipe(effect.Schema.int(), effect.Schema.positive())
435
333
  });
436
- var Phase1ArtifactSchema = import_effect2.Schema.Union(
437
- import_effect2.Schema.Struct({
438
- kind: import_effect2.Schema.Literal("transaction"),
439
- funding: import_effect2.Schema.Literal("inline", "external"),
440
- transactionRequest: import_effect2.Schema.optional(
441
- import_effect2.Schema.Struct({
442
- to: import_effect2.Schema.String,
443
- data: import_effect2.Schema.String,
444
- value: import_effect2.Schema.String,
445
- chainId: import_effect2.Schema.Number
446
- })
447
- ),
448
- escrow: import_effect2.Schema.optional(Phase1EscrowSchema)
449
- }),
450
- import_effect2.Schema.Struct({
451
- kind: import_effect2.Schema.Literal("signables"),
452
- typedData: import_effect2.Schema.Array(import_effect2.Schema.Unknown)
453
- }),
454
- import_effect2.Schema.Struct({ kind: import_effect2.Schema.Literal("none") })
455
- );
456
- var AssertionOwnerSchema = import_effect2.Schema.Union(
457
- EVMAddressString,
458
- import_effect2.Schema.Literal("escrow", "delivery")
459
- );
460
- var Erc20BalanceGteSpecSchema = import_effect2.Schema.Struct({
461
- kind: import_effect2.Schema.Literal("erc20BalanceGte"),
462
- chainId: ChainIdSchema,
463
- token: EVMAddressString,
464
- owner: EVMAddressString,
465
- minAmount: IntegerString
334
+ const Phase1ArtifactSchema = effect.Schema.Union(effect.Schema.Struct({
335
+ kind: effect.Schema.Literal("transaction"),
336
+ funding: effect.Schema.Literal("inline", "external"),
337
+ transactionRequest: effect.Schema.optional(effect.Schema.Struct({
338
+ to: effect.Schema.String,
339
+ data: effect.Schema.String,
340
+ value: effect.Schema.String,
341
+ chainId: effect.Schema.Number
342
+ })),
343
+ escrow: effect.Schema.optional(Phase1EscrowSchema)
344
+ }), effect.Schema.Struct({
345
+ kind: effect.Schema.Literal("signables"),
346
+ typedData: effect.Schema.Array(effect.Schema.Unknown)
347
+ }), effect.Schema.Struct({ kind: effect.Schema.Literal("none") }));
348
+ const AssertionOwnerSchema = effect.Schema.Union(EVMAddressString, effect.Schema.Literal("escrow", "delivery"));
349
+ const Erc20BalanceGteSpecSchema = effect.Schema.Struct({
350
+ kind: effect.Schema.Literal("erc20BalanceGte"),
351
+ chainId: ChainIdSchema,
352
+ token: EVMAddressString,
353
+ owner: EVMAddressString,
354
+ minAmount: IntegerString
466
355
  });
467
- var NativeBalanceGteSpecSchema = import_effect2.Schema.Struct({
468
- kind: import_effect2.Schema.Literal("nativeBalanceGte"),
469
- chainId: ChainIdSchema,
470
- owner: EVMAddressString,
471
- minAmount: IntegerString
356
+ const NativeBalanceGteSpecSchema = effect.Schema.Struct({
357
+ kind: effect.Schema.Literal("nativeBalanceGte"),
358
+ chainId: ChainIdSchema,
359
+ owner: EVMAddressString,
360
+ minAmount: IntegerString
472
361
  });
473
- var CallCheckSpecSchema = import_effect2.Schema.Struct({
474
- kind: import_effect2.Schema.Literal("call"),
475
- chainId: ChainIdSchema,
476
- to: EVMAddressString,
477
- calldata: HexBytesString,
478
- comparator: import_effect2.Schema.Literal("gte", "eq", "lte"),
479
- value: IntegerString
362
+ const CallCheckSpecSchema = effect.Schema.Struct({
363
+ kind: effect.Schema.Literal("call"),
364
+ chainId: ChainIdSchema,
365
+ to: EVMAddressString,
366
+ calldata: HexBytesString,
367
+ comparator: effect.Schema.Literal("gte", "eq", "lte"),
368
+ value: IntegerString
480
369
  });
481
- var asErc20BalanceGteCheck = (check, token) => ({
482
- kind: "erc20BalanceGte",
483
- chainId: check.chainId,
484
- token,
485
- owner: check.owner,
486
- minAmount: check.minAmount
370
+ const asErc20BalanceGteCheck = (check, token) => ({
371
+ kind: "erc20BalanceGte",
372
+ chainId: check.chainId,
373
+ token,
374
+ owner: check.owner,
375
+ minAmount: check.minAmount
487
376
  });
488
- var decodeNativeBalanceGte = (check, ast) => {
489
- const policy = nativeCheckPolicy(check.chainId);
490
- switch (policy.kind) {
491
- case "keep":
492
- return import_effect2.ParseResult.succeed(check);
493
- case "rewrite":
494
- return import_effect2.ParseResult.succeed(asErc20BalanceGteCheck(check, policy.token));
495
- case "reject":
496
- return import_effect2.ParseResult.fail(new import_effect2.ParseResult.Type(ast, check, policy.reason));
497
- }
377
+ const decodeNativeBalanceGte = (check, ast) => {
378
+ const policy = nativeCheckPolicy(check.chainId);
379
+ switch (policy.kind) {
380
+ case "keep": return effect.ParseResult.succeed(check);
381
+ case "rewrite": return effect.ParseResult.succeed(asErc20BalanceGteCheck(check, policy.token));
382
+ case "reject": return effect.ParseResult.fail(new effect.ParseResult.Type(ast, check, policy.reason));
383
+ }
498
384
  };
499
- var RawCheckSchema = import_effect2.Schema.Union(
500
- Erc20BalanceGteSpecSchema,
501
- NativeBalanceGteSpecSchema,
502
- CallCheckSpecSchema
503
- );
504
- var CheckSchema = import_effect2.Schema.transformOrFail(
505
- RawCheckSchema,
506
- import_effect2.Schema.typeSchema(RawCheckSchema),
507
- {
508
- strict: true,
509
- decode: (check, _options, ast) => check.kind === "nativeBalanceGte" ? decodeNativeBalanceGte(check, ast) : import_effect2.ParseResult.succeed(check),
510
- encode: (check) => import_effect2.ParseResult.succeed(check)
511
- }
512
- );
513
- var Erc20BalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
514
- kind: import_effect2.Schema.Literal("erc20BalanceDeltaGte"),
515
- chainId: ChainIdSchema,
516
- token: EVMAddressString,
517
- owner: AssertionOwnerSchema,
518
- minDelta: IntegerString
385
+ const Erc20BalanceDeltaGteSpecSchema = effect.Schema.Struct({
386
+ kind: effect.Schema.Literal("erc20BalanceDeltaGte"),
387
+ chainId: ChainIdSchema,
388
+ token: EVMAddressString,
389
+ owner: AssertionOwnerSchema,
390
+ minDelta: IntegerString
519
391
  });
520
- var NativeBalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
521
- kind: import_effect2.Schema.Literal("nativeBalanceDeltaGte"),
522
- chainId: ChainIdSchema,
523
- owner: AssertionOwnerSchema,
524
- minDelta: IntegerString
392
+ const NativeBalanceDeltaGteSpecSchema = effect.Schema.Struct({
393
+ kind: effect.Schema.Literal("nativeBalanceDeltaGte"),
394
+ chainId: ChainIdSchema,
395
+ owner: AssertionOwnerSchema,
396
+ minDelta: IntegerString
525
397
  });
526
- var AssertionSpecSchema = import_effect2.Schema.Union(
527
- Erc20BalanceGteSpecSchema,
528
- NativeBalanceGteSpecSchema,
529
- CallCheckSpecSchema,
530
- Erc20BalanceDeltaGteSpecSchema,
531
- NativeBalanceDeltaGteSpecSchema
532
- );
533
- var ContinuationPlanSchema = import_effect2.Schema.Struct({
534
- chainId: ChainIdSchema,
535
- nextFlow: FlowSchema,
536
- check: CheckSchema,
537
- validity: import_effect2.Schema.Struct({ expiresAtMs: EpochMsSchema }),
538
- correlationId: import_effect2.Schema.optional(import_effect2.Schema.String)
398
+ const AssertionSpecSchema = effect.Schema.Union(Erc20BalanceGteSpecSchema, NativeBalanceGteSpecSchema, CallCheckSpecSchema, Erc20BalanceDeltaGteSpecSchema, NativeBalanceDeltaGteSpecSchema);
399
+ const settledOutcome = (intent) => intent.outcomes[0];
400
+ //#endregion
401
+ //#region src/descriptor.ts
402
+ const Bytes32HexSchema = effect.Schema.String.pipe(effect.Schema.pattern(BYTES32_LOWER_HEX));
403
+ const AssertedErc20BalanceGteSpecSchema = effect.Schema.Struct({
404
+ kind: effect.Schema.Literal("erc20BalanceGte"),
405
+ chainId: ChainIdSchema,
406
+ token: EVMAddressString,
407
+ owner: AssertionOwnerSchema,
408
+ minAmount: IntegerString
539
409
  });
540
- var settledOutcome = (intent) => intent.outcomes[0];
541
- var isGTECheck = (check) => check.kind === "call" && check.comparator === "gte";
542
- var isLTECheck = (check) => check.kind === "call" && check.comparator === "lte";
543
- var isEQCheck = (check) => check.kind === "call" && check.comparator === "eq";
544
-
545
- // src/descriptor.ts
546
- var import_effect3 = require("effect");
547
- var Bytes32HexSchema = import_effect3.Schema.String.pipe(
548
- import_effect3.Schema.pattern(BYTES32_LOWER_HEX)
549
- );
550
- var AssertedErc20BalanceGteSpecSchema = import_effect3.Schema.Struct({
551
- kind: import_effect3.Schema.Literal("erc20BalanceGte"),
552
- chainId: ChainIdSchema,
553
- token: EVMAddressString,
554
- owner: AssertionOwnerSchema,
555
- minAmount: IntegerString
410
+ const AssertedNativeBalanceGteSpecSchema = effect.Schema.Struct({
411
+ kind: effect.Schema.Literal("nativeBalanceGte"),
412
+ chainId: ChainIdSchema,
413
+ owner: AssertionOwnerSchema,
414
+ minAmount: IntegerString
556
415
  });
557
- var AssertedNativeBalanceGteSpecSchema = import_effect3.Schema.Struct({
558
- kind: import_effect3.Schema.Literal("nativeBalanceGte"),
559
- chainId: ChainIdSchema,
560
- owner: AssertionOwnerSchema,
561
- minAmount: IntegerString
416
+ const RawAssertedPredicateSchema = effect.Schema.Union(AssertedErc20BalanceGteSpecSchema, AssertedNativeBalanceGteSpecSchema, CallCheckSpecSchema, Erc20BalanceDeltaGteSpecSchema, NativeBalanceDeltaGteSpecSchema);
417
+ const AssertedPredicateSchema = effect.Schema.transformOrFail(RawAssertedPredicateSchema, effect.Schema.typeSchema(RawAssertedPredicateSchema), {
418
+ strict: true,
419
+ decode: (pred, _options, ast) => pred.kind === "nativeBalanceGte" ? decodeNativeBalanceGte(pred, ast) : effect.ParseResult.succeed(pred),
420
+ encode: (pred) => effect.ParseResult.succeed(pred)
562
421
  });
563
- var RawAssertedPredicateSchema = import_effect3.Schema.Union(
564
- AssertedErc20BalanceGteSpecSchema,
565
- AssertedNativeBalanceGteSpecSchema,
566
- CallCheckSpecSchema,
567
- Erc20BalanceDeltaGteSpecSchema,
568
- NativeBalanceDeltaGteSpecSchema
569
- );
570
- var AssertedPredicateSchema = import_effect3.Schema.transformOrFail(
571
- RawAssertedPredicateSchema,
572
- import_effect3.Schema.typeSchema(RawAssertedPredicateSchema),
573
- {
574
- strict: true,
575
- decode: (pred, _options, ast) => pred.kind === "nativeBalanceGte" ? decodeNativeBalanceGte(pred, ast) : import_effect3.ParseResult.succeed(pred),
576
- encode: (pred) => import_effect3.ParseResult.succeed(pred)
577
- }
578
- );
579
- var VerificationDescriptorSchema = import_effect3.Schema.Struct({
580
- validationProgramHash: Bytes32HexSchema,
581
- // The C5 echo's second hash (verified continuations, plan GD-8): `keccak256`
582
- // over the canonical params vector (`paramsHash`, GD-2 seam C1). Required and
583
- // jointly necessary with `validationProgramHash` — the program hash is
584
- // value-blind (it never binds the delivery address or amounts), so a descriptor
585
- // that enforces only it is a fund-redirect hole. Empty params still yield a
586
- // present `0x00…00`, so a real descriptor never omits it. Strict 32-byte
587
- // lowercase hex, same rule as `validationProgramHash`.
588
- paramsHash: Bytes32HexSchema,
589
- assertedPredicate: import_effect3.Schema.Array(AssertedPredicateSchema)
422
+ const VerificationDescriptorSchema = effect.Schema.Struct({
423
+ validationProgramHash: Bytes32HexSchema,
424
+ paramsHash: Bytes32HexSchema,
425
+ assertedPredicate: effect.Schema.Array(AssertedPredicateSchema)
590
426
  });
591
- var canonicalJson = (value) => {
592
- if (Array.isArray(value)) {
593
- return `[${value.map(canonicalJson).join(",")}]`;
594
- }
595
- if (value !== null && typeof value === "object") {
596
- const record = value;
597
- const entries = Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`);
598
- return `{${entries.join(",")}}`;
599
- }
600
- return JSON.stringify(value);
427
+ const canonicalJson = (value) => {
428
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
429
+ if (value !== null && typeof value === "object") {
430
+ const record = value;
431
+ return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
432
+ }
433
+ return JSON.stringify(value);
601
434
  };
602
- var canonicalAssertedPredicate = (specs) => canonicalJson(specs);
603
-
604
- // src/flow.ts
605
- var isResourceInput = (input) => "resource" in input;
606
- var flowInputType = (input) => isResourceInput(input) ? "uint256" : input.type;
607
- var flowInputMode = (input) => isResourceInput(input) ? "linear" : "copy";
608
- var flowInputResource = (input) => isResourceInput(input) ? input.resource : void 0;
609
- var isResourcePort = (port) => port.kind === "resource";
610
- var isHandlePort = (port) => port.kind === "handle";
611
- var isResourceOutputPort = (port) => port.kind === "resource_output";
612
- var isFutureResourceOutput = (port) => isResourceOutputPort(port) && port.availability === "future";
613
- var isMaterialiserInput = (s) => typeof s === "object" && s !== null && "kind" in s;
614
-
615
- // src/resource.ts
616
- var erc20Resource = (token, chainId) => ({
617
- kind: "erc20",
618
- token,
619
- chainId
435
+ const canonicalAssertedPredicate = (specs) => canonicalJson(specs);
436
+ //#endregion
437
+ //#region src/flow.ts
438
+ const isResourceInput = (input) => "resource" in input;
439
+ const flowInputType = (input) => isResourceInput(input) ? "uint256" : input.type;
440
+ const flowInputMode = (input) => isResourceInput(input) ? "linear" : "copy";
441
+ const flowInputResource = (input) => isResourceInput(input) ? input.resource : void 0;
442
+ const isResourcePort = (port) => port.kind === "resource";
443
+ const isHandlePort = (port) => port.kind === "handle";
444
+ const isResourceOutputPort = (port) => port.kind === "resource_output";
445
+ const isFutureResourceOutput = (port) => isResourceOutputPort(port) && port.availability === "future";
446
+ const isMaterialiserInput = (s) => typeof s === "object" && s !== null && "kind" in s;
447
+ //#endregion
448
+ //#region src/resource.ts
449
+ const erc20Resource = (token, chainId) => ({
450
+ kind: "erc20",
451
+ token,
452
+ chainId
620
453
  });
621
- var nativeResource = (chainId) => ({
622
- kind: "native",
623
- chainId
454
+ const nativeResource = (chainId) => ({
455
+ kind: "native",
456
+ chainId
624
457
  });
625
- var isERC20Resource = (r) => r.kind === "erc20";
626
- var isNativeResource = (r) => r.kind === "native";
627
- var resourcesEqual = (a, b) => {
628
- if (isNativeResource(a) && isNativeResource(b)) {
629
- return a.chainId === b.chainId;
630
- }
631
- if (isERC20Resource(a) && isERC20Resource(b)) {
632
- return a.chainId === b.chainId && a.token.toLowerCase() === b.token.toLowerCase();
633
- }
634
- return false;
458
+ const isERC20Resource = (r) => r.kind === "erc20";
459
+ const isNativeResource = (r) => r.kind === "native";
460
+ const resourcesEqual = (a, b) => {
461
+ if (isNativeResource(a) && isNativeResource(b)) return a.chainId === b.chainId;
462
+ if (isERC20Resource(a) && isERC20Resource(b)) return a.chainId === b.chainId && a.token.toLowerCase() === b.token.toLowerCase();
463
+ return false;
635
464
  };
636
- var foldResource = (r, cases) => r.kind === "native" ? cases.native(r.chainId) : cases.erc20(r.token, r.chainId);
637
- var resourceToken = (r) => foldResource(r, {
638
- native: () => EVM_NATIVE_SENTINEL,
639
- erc20: (token) => token
465
+ const foldResource = (r, cases) => r.kind === "native" ? cases.native(r.chainId) : cases.erc20(r.token, r.chainId);
466
+ const resourceToken = (r) => foldResource(r, {
467
+ native: () => EVM_NATIVE_SENTINEL,
468
+ erc20: (token) => token
640
469
  });
641
- var resourceKey = (r) => foldResource(r, {
642
- native: (chainId) => `native:${chainId}`,
643
- erc20: (token, chainId) => `erc20:${token.toLowerCase()}:${chainId}`
470
+ const resourceKey = (r) => foldResource(r, {
471
+ native: (chainId) => `native:${chainId}`,
472
+ erc20: (token, chainId) => `erc20:${token.toLowerCase()}:${chainId}`
644
473
  });
645
- var erc20Token = (r) => {
646
- if (r.kind !== "erc20")
647
- throw new Error(`Expected erc20 resource, got ${r.kind}`);
648
- return r.token;
474
+ const erc20Token = (r) => {
475
+ if (r.kind !== "erc20") throw new Error(`Expected erc20 resource, got ${r.kind}`);
476
+ return r.token;
649
477
  };
650
-
651
- // src/flashloan.ts
652
- var PROVIDER_KIND = {
653
- AAVE_V3: 0,
654
- ERC3156: 1,
655
- BALANCER_V2: 2,
656
- MORPHO_BLUE: 3
478
+ //#endregion
479
+ //#region src/flashloan.ts
480
+ const PROVIDER_KIND = {
481
+ AAVE_V3: 0,
482
+ ERC3156: 1,
483
+ BALANCER_V2: 2,
484
+ MORPHO_BLUE: 3
657
485
  };
658
- var providerKindNames = [
659
- "aave-v3",
660
- "erc3156",
661
- "balancer-v2",
662
- "morpho-blue"
486
+ const providerKindNames = [
487
+ "aave-v3",
488
+ "erc3156",
489
+ "balancer-v2",
490
+ "morpho-blue"
663
491
  ];
664
- var providerKindByName = {
665
- "aave-v3": PROVIDER_KIND.AAVE_V3,
666
- erc3156: PROVIDER_KIND.ERC3156,
667
- "balancer-v2": PROVIDER_KIND.BALANCER_V2,
668
- "morpho-blue": PROVIDER_KIND.MORPHO_BLUE
492
+ const providerKindByName = {
493
+ "aave-v3": PROVIDER_KIND.AAVE_V3,
494
+ erc3156: PROVIDER_KIND.ERC3156,
495
+ "balancer-v2": PROVIDER_KIND.BALANCER_V2,
496
+ "morpho-blue": PROVIDER_KIND.MORPHO_BLUE
669
497
  };
670
-
671
- // src/constructors.ts
672
- var optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
673
- var linear = (name, type) => ({
674
- name,
675
- type,
676
- mode: "linear",
677
- availability: "now"
498
+ //#endregion
499
+ //#region src/constructors.ts
500
+ /** Returns `{ [key]: value }` when `value` is not nullish, else `{}`. */
501
+ const optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
502
+ const linear = (name, type) => ({
503
+ name,
504
+ type,
505
+ mode: "linear",
506
+ availability: "now"
507
+ });
508
+ const copy = (name, type) => ({
509
+ name,
510
+ type,
511
+ mode: "copy",
512
+ availability: "now"
678
513
  });
679
- var copy = (name, type) => ({
680
- name,
681
- type,
682
- mode: "copy",
683
- availability: "now"
514
+ const handle = (name, type) => ({
515
+ name,
516
+ type
684
517
  });
685
- var handle = (name, type) => ({ name, type });
686
- var native = (name, chainId) => ({
687
- name,
688
- resource: nativeResource(chainId)
518
+ const native = (name, chainId) => ({
519
+ name,
520
+ resource: nativeResource(chainId)
689
521
  });
690
- var erc20 = (name, token, chainId) => ({
691
- name,
692
- resource: erc20Resource(token, chainId)
522
+ const erc20 = (name, token, chainId) => ({
523
+ name,
524
+ resource: erc20Resource(token, chainId)
693
525
  });
694
- var resource = (name, accepts, options) => ({
695
- kind: "resource",
696
- name,
697
- accepts,
698
- mode: "linear",
699
- ...optionalProp("optional", options?.optional)
526
+ const resource = (name, accepts, options) => ({
527
+ kind: "resource",
528
+ name,
529
+ accepts,
530
+ mode: "linear",
531
+ ...optionalProp("optional", options?.optional)
700
532
  });
701
- var readResource = (name, accepts) => ({
702
- kind: "resource",
703
- name,
704
- accepts,
705
- mode: "copy"
533
+ const readResource = (name, accepts) => ({
534
+ kind: "resource",
535
+ name,
536
+ accepts,
537
+ mode: "copy"
706
538
  });
707
- var opHandle = (name, type, options) => ({
708
- kind: "handle",
709
- name,
710
- type,
711
- mode: "copy",
712
- ...optionalProp("expose", options?.expose),
713
- ...optionalProp("units", options?.units),
714
- ...optionalProp("optional", options?.optional)
539
+ const opHandle = (name, type, options) => ({
540
+ kind: "handle",
541
+ name,
542
+ type,
543
+ mode: "copy",
544
+ ...optionalProp("expose", options?.expose),
545
+ ...optionalProp("units", options?.units),
546
+ ...optionalProp("optional", options?.optional)
715
547
  });
716
- var resourceOutput = (name, options) => {
717
- const raw = options;
718
- const opts = typeof raw === "string" ? { availability: raw } : raw;
719
- return {
720
- kind: "resource_output",
721
- name,
722
- mode: "linear",
723
- ...optionalProp("availability", opts?.availability),
724
- ...optionalProp("providesMinimum", opts?.providesMinimum),
725
- ...optionalProp("omitIfZero", opts?.omitIfZero),
726
- ...optionalProp("deliveryAddressInput", opts?.deliveryAddressInput),
727
- ...optionalProp("countFrom", opts?.countFrom)
728
- };
548
+ const resourceOutput = (name, options) => {
549
+ const raw = options;
550
+ const opts = typeof raw === "string" ? { availability: raw } : raw;
551
+ return {
552
+ kind: "resource_output",
553
+ name,
554
+ mode: "linear",
555
+ ...optionalProp("availability", opts?.availability),
556
+ ...optionalProp("providesMinimum", opts?.providesMinimum),
557
+ ...optionalProp("omitIfZero", opts?.omitIfZero),
558
+ ...optionalProp("deliveryAddressInput", opts?.deliveryAddressInput),
559
+ ...optionalProp("countFrom", opts?.countFrom)
560
+ };
729
561
  };
730
-
731
- // src/outputFamilies.ts
732
- var isOutputFamily = (port) => port.kind === "resource_output" && port.countFrom !== void 0;
733
- var instancePortName = (family, index) => `${family}.${index}`;
734
- var familySize = (family, config) => {
735
- const source = config[family.countFrom];
736
- if (Array.isArray(source)) return source.length;
737
- if (Number.isSafeInteger(source) && source >= 0) {
738
- return source;
739
- }
740
- throw new Error(
741
- `Output family '${family.name}' counts from config '${family.countFrom}', which is neither an array nor a non-negative integer`
742
- );
562
+ //#endregion
563
+ //#region src/outputFamilies.ts
564
+ const isOutputFamily = (port) => port.kind === "resource_output" && port.countFrom !== void 0;
565
+ const instancePortName = (family, index) => `${family}.${index}`;
566
+ const familySize = (family, config) => {
567
+ const source = config[family.countFrom];
568
+ if (Array.isArray(source)) return source.length;
569
+ if (Number.isSafeInteger(source) && source >= 0) return source;
570
+ throw new Error(`Output family '${family.name}' counts from config '${family.countFrom}', which is neither an array nor a non-negative integer`);
743
571
  };
744
- var expandFamily = (port, config) => {
745
- const { countFrom: _countFrom, ...instance } = port;
746
- return Array.from({ length: familySize(port, config) }, (_, index) => ({
747
- ...instance,
748
- name: instancePortName(port.name, index)
749
- }));
572
+ const expandFamily = (port, config) => {
573
+ const { countFrom: _countFrom, ...instance } = port;
574
+ return Array.from({ length: familySize(port, config) }, (_, index) => ({
575
+ ...instance,
576
+ name: instancePortName(port.name, index)
577
+ }));
750
578
  };
751
- var expandOutputPorts = (declared, config) => declared.some(isOutputFamily) ? declared.flatMap(
752
- (port) => isOutputFamily(port) ? expandFamily(port, config) : [port]
753
- ) : declared;
754
-
755
- // src/ref.ts
756
- var isContextKey = (key) => key === "sender" || key === "executionAddress";
757
- var RESERVED_REF_SCOPES = /* @__PURE__ */ new Set([
758
- "input",
759
- "context",
760
- "literal"
579
+ const expandOutputPorts = (declared, config) => declared.some(isOutputFamily) ? declared.flatMap((port) => isOutputFamily(port) ? expandFamily(port, config) : [port]) : declared;
580
+ //#endregion
581
+ //#region src/ref.ts
582
+ const isContextKey = (key) => key === "sender" || key === "executionAddress";
583
+ /**
584
+ * Ref prefixes that parseRef intercepts before the fallback `output` scope.
585
+ * A node whose id matches one of these would produce ambiguous refs
586
+ * (e.g. `context.sender` could be a context ref or node-output ref).
587
+ * Validation must reject these as node ids.
588
+ */
589
+ const RESERVED_REF_SCOPES = /* @__PURE__ */ new Set([
590
+ "input",
591
+ "context",
592
+ "literal"
761
593
  ]);
762
- var isRef = (v) => typeof v === "object" && v !== null && "$ref" in v && typeof v.$ref === "string";
763
- var parseRef = (ref2) => {
764
- const dot = ref2.$ref.indexOf(".");
765
- if (dot === -1)
766
- throw new Error(`Invalid ref: "${ref2.$ref}" (must contain a dot)`);
767
- const prefix = ref2.$ref.slice(0, dot);
768
- const suffix = ref2.$ref.slice(dot + 1);
769
- if (prefix === "input") return { scope: "input", port: suffix };
770
- if (prefix === "context") {
771
- if (!isContextKey(suffix))
772
- throw new Error(`Unknown context key: "${suffix}"`);
773
- return { scope: "context", key: suffix };
774
- }
775
- return { scope: "output", node: prefix, port: suffix };
594
+ const isRef = (v) => typeof v === "object" && v !== null && "$ref" in v && typeof v.$ref === "string";
595
+ const parseRef = (ref) => {
596
+ const dot = ref.$ref.indexOf(".");
597
+ if (dot === -1) throw new Error(`Invalid ref: "${ref.$ref}" (must contain a dot)`);
598
+ const prefix = ref.$ref.slice(0, dot);
599
+ const suffix = ref.$ref.slice(dot + 1);
600
+ if (prefix === "input") return {
601
+ scope: "input",
602
+ port: suffix
603
+ };
604
+ if (prefix === "context") {
605
+ if (!isContextKey(suffix)) throw new Error(`Unknown context key: "${suffix}"`);
606
+ return {
607
+ scope: "context",
608
+ key: suffix
609
+ };
610
+ }
611
+ return {
612
+ scope: "output",
613
+ node: prefix,
614
+ port: suffix
615
+ };
776
616
  };
777
- var buildRef = (path) => {
778
- if (path.indexOf(".") < 1)
779
- throw new Error(
780
- `Invalid ref: "${path}" (must be a dotpath like "input.name" or "nodeId.port")`
781
- );
782
- const built = { $ref: path };
783
- parseRef(built);
784
- return built;
617
+ const buildRef = (path) => {
618
+ if (path.indexOf(".") < 1) throw new Error(`Invalid ref: "${path}" (must be a dotpath like "input.name" or "nodeId.port")`);
619
+ const built = { $ref: path };
620
+ parseRef(built);
621
+ return built;
785
622
  };
786
- var ref = Object.assign(buildRef, {
787
- input: (port) => buildRef(`input.${port}`),
788
- context: {
789
- sender: buildRef("context.sender"),
790
- executionAddress: buildRef("context.executionAddress")
791
- }
623
+ const ref = Object.assign(buildRef, {
624
+ input: (port) => buildRef(`input.${port}`),
625
+ context: {
626
+ sender: buildRef("context.sender"),
627
+ executionAddress: buildRef("context.executionAddress")
628
+ }
792
629
  });
793
- var foldRef = (ref2, cases) => {
794
- if (ref2.scope === "input") return cases.input(ref2.port);
795
- if (ref2.scope === "context") return cases.context(ref2.key);
796
- return cases.output(ref2.node, ref2.port);
630
+ const foldRef = (ref, cases) => {
631
+ if (ref.scope === "input") return cases.input(ref.port);
632
+ if (ref.scope === "context") return cases.context(ref.key);
633
+ return cases.output(ref.node, ref.port);
797
634
  };
798
- var refKey = (ref2) => foldRef(parseRef(ref2), {
799
- input: (port) => `input:${port}`,
800
- context: (key) => `context:${key}`,
801
- output: (node, port) => `output:${node}:${port}`
635
+ const refKey = (ref) => foldRef(parseRef(ref), {
636
+ input: (port) => `input:${port}`,
637
+ context: (key) => `context:${key}`,
638
+ output: (node, port) => `output:${node}:${port}`
802
639
  });
803
-
804
- // src/preconditions.ts
805
- var erc20Balance = (config) => ({ type: "Erc20Balance", ...config });
806
- var nativeBalance = (config) => ({ type: "NativeBalance", ...config });
807
- var erc20Allowance = (config) => ({ type: "Erc20Allowance", ...config });
808
- var isErc20BalancePrecondition = (p) => p.type === "Erc20Balance";
809
- var isErc20AllowancePrecondition = (p) => p.type === "Erc20Allowance";
810
- var isNativeBalancePrecondition = (p) => p.type === "NativeBalance";
811
-
812
- // src/simulate.ts
813
- var SIMULATE_MAX_TRACKED_BALANCES = 40;
814
- var SIMULATE_MAX_REQUIREMENTS = 40;
815
-
816
- // src/headers.ts
817
- var COMPOSER_SDK_VERSION_HEADER = "x-lifi-composer-sdk";
818
- var COMPOSE_VERSION_HEADER = "x-lifi-composer-version";
819
-
820
- // src/version.ts
821
- var SEMANTIC_VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
822
- var parseVersion = (version) => {
823
- const match = SEMANTIC_VERSION_PATTERN.exec(version);
824
- if (!match) return void 0;
825
- const major = Number(match[1]);
826
- const minor = Number(match[2]);
827
- const patch = Number(match[3]);
828
- if (![major, minor, patch].every(Number.isSafeInteger)) return void 0;
829
- return { major, minor, patch };
640
+ //#endregion
641
+ //#region src/preconditions.ts
642
+ const erc20Balance = (config) => ({
643
+ type: "Erc20Balance",
644
+ ...config
645
+ });
646
+ const nativeBalance = (config) => ({
647
+ type: "NativeBalance",
648
+ ...config
649
+ });
650
+ const erc20Allowance = (config) => ({
651
+ type: "Erc20Allowance",
652
+ ...config
653
+ });
654
+ const isErc20BalancePrecondition = (p) => p.type === "Erc20Balance";
655
+ const isErc20AllowancePrecondition = (p) => p.type === "Erc20Allowance";
656
+ const isNativeBalancePrecondition = (p) => p.type === "NativeBalance";
657
+ //#endregion
658
+ //#region src/simulate.ts
659
+ /**
660
+ * Maximum number of watched `(token, owner)` pairs accepted by `POST /simulate`.
661
+ *
662
+ * The limit comes from the VM's hard register budget (~123 usable registers,
663
+ * checked on the final ISA layout). Each pair costs two result registers — a
664
+ * before-read and an after-read — that are both live at the closing abi-encode,
665
+ * so the compiler cannot coalesce them; that `2 × N` is the cost that scales.
666
+ * Token and owner address literals do not scale it, since constant-propagation
667
+ * merges identical-valued literals into one register. The cap leaves headroom
668
+ * for the inner-call / gas-measurement / abi-encode scaffolding.
669
+ */
670
+ const SIMULATE_MAX_TRACKED_BALANCES = 40;
671
+ /**
672
+ * Maximum number of funding `requirements` accepted by `POST /simulate`.
673
+ *
674
+ * Each requirement triggers a slot-discovery cycle (access-list probe + sentinel
675
+ * verification + RPC round trips) in slot-finder, so an unbounded array lets a
676
+ * single request amplify into arbitrary upstream RPC work. Bounded here at the
677
+ * trust boundary and re-enforced server-side in `rawSimulation.ts`.
678
+ */
679
+ const SIMULATE_MAX_REQUIREMENTS = 40;
680
+ //#endregion
681
+ //#region src/headers.ts
682
+ /**
683
+ * HTTP header names on the compose wire.
684
+ *
685
+ * Both the SDK (which sends the request header) and the backend (which reads it
686
+ * and answers with the response header) are part of the same handshake, so the
687
+ * names belong to the wire format rather than to either side of it.
688
+ */
689
+ /** Compose contract version the client was built against. Sent on every request. */
690
+ const COMPOSER_SDK_VERSION_HEADER = "x-lifi-composer-sdk";
691
+ /** Compose contract version the backend serves. Returned on every compose response. */
692
+ const COMPOSE_VERSION_HEADER = "x-lifi-composer-version";
693
+ //#endregion
694
+ //#region src/version.ts
695
+ const SEMANTIC_VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
696
+ /**
697
+ * Parses the numeric triple of a semantic version. Prerelease and build
698
+ * suffixes are accepted and ignored: `0.5.1-staging.3` compares as `0.5.1`.
699
+ * Returns `undefined` for anything that is not a complete semver string,
700
+ * including the `dev` sentinel the SDK sends when it runs unbundled.
701
+ */
702
+ const parseVersion = (version) => {
703
+ const match = SEMANTIC_VERSION_PATTERN.exec(version);
704
+ if (!match) return void 0;
705
+ const major = Number(match[1]);
706
+ const minor = Number(match[2]);
707
+ const patch = Number(match[3]);
708
+ if (![
709
+ major,
710
+ minor,
711
+ patch
712
+ ].every(Number.isSafeInteger)) return void 0;
713
+ return {
714
+ major,
715
+ minor,
716
+ patch
717
+ };
830
718
  };
831
- var compareVersions = (a, b) => a.major !== b.major ? a.major - b.major : a.minor !== b.minor ? a.minor - b.minor : a.patch - b.patch;
832
- var checkCompatibility = (client, server, minimum = {
833
- major: server.major,
834
- minor: server.minor,
835
- patch: 0
719
+ const compareVersions = (a, b) => a.major !== b.major ? a.major - b.major : a.minor !== b.minor ? a.minor - b.minor : a.patch - b.patch;
720
+ /**
721
+ * Decides whether a client built against `client` may talk to a server that
722
+ * serves `server` and accepts clients down to `minimum`.
723
+ *
724
+ * - A client ahead of the server in any component is `server_outdated`. Even
725
+ * a patch-ahead client may send a field the server has never seen, and the
726
+ * guarantee must not depend on every server schema staying strict. This is
727
+ * the rollout window between an npm publish and the prod image bump.
728
+ * - A client below `minimum` is `sdk_outdated`: the server no longer serves
729
+ * the contract that client speaks.
730
+ * - Anything in between is compatible. Patch releases only add, so a client
731
+ * at or behind the server's patch never emits anything the server lacks;
732
+ * a client on an older minor is served because the server still emits the
733
+ * shapes that minor reads.
734
+ *
735
+ * `minimum` defaults to the server's own `major.minor.0`, which makes every
736
+ * minor bump a hard cutover. The backend passes its explicit floor so a minor
737
+ * bump can ship with the previous line still accepted; the SDK passes no floor
738
+ * because the server, not the client, decides how far back it serves.
739
+ */
740
+ const checkCompatibility = (client, server, minimum = {
741
+ major: server.major,
742
+ minor: server.minor,
743
+ patch: 0
836
744
  }) => {
837
- if (compareVersions(client, server) > 0) return "server_outdated";
838
- if (compareVersions(client, minimum) < 0) return "sdk_outdated";
839
- return "compatible";
745
+ if (compareVersions(client, server) > 0) return "server_outdated";
746
+ if (compareVersions(client, minimum) < 0) return "sdk_outdated";
747
+ return "compatible";
840
748
  };
841
-
842
- // src/materialiserMetadata.ts
843
- var foldMaterialiserMetadata = (meta, cases) => {
844
- if (meta.kind === "exact") return cases.exact(meta.amount);
845
- if (meta.kind === "exact-native") return cases.exactNative(meta.amount);
846
- if (meta.kind === "capped") return cases.capped(meta.amount);
847
- return cases.runtime();
749
+ //#endregion
750
+ //#region src/materialiserMetadata.ts
751
+ const foldMaterialiserMetadata = (meta, cases) => {
752
+ if (meta.kind === "exact") return cases.exact(meta.amount);
753
+ if (meta.kind === "exact-native") return cases.exactNative(meta.amount);
754
+ if (meta.kind === "capped") return cases.capped(meta.amount);
755
+ return cases.runtime();
848
756
  };
849
-
850
- // src/zodSchemas.ts
851
- var import_zod = __toESM(require("zod"), 1);
852
- var chainIdZod = import_zod.default.number().int().positive();
853
- var evmAddressZod = import_zod.default.string().regex(EVM_ADDRESS_HEX);
854
- var hexBytesZod = import_zod.default.string().regex(HEX_BYTES);
855
- var uintStringZod = import_zod.default.string().refine((value) => DECIMAL_UINT.test(value) && BigInt(value) <= MAX_UINT256, {
856
- message: "expected a uint256 decimal integer string"
857
- });
858
- var epochMsZod = import_zod.default.number().int().min(-MAX_DATE_MS).max(MAX_DATE_MS);
859
- var SolTypeZod = import_zod.default.enum([
860
- "uint8",
861
- "uint16",
862
- "uint32",
863
- "uint64",
864
- "uint128",
865
- "uint256",
866
- "int128",
867
- "int256",
868
- "address",
869
- "bool",
870
- "bytes",
871
- "bytes4",
872
- "bytes32",
873
- "string"
757
+ //#endregion
758
+ //#region src/zodSchemas.ts
759
+ const chainIdZod = zod.default.number().int().positive();
760
+ const evmAddressZod = zod.default.string().regex(EVM_ADDRESS_HEX);
761
+ const hexBytesZod = zod.default.string().regex(HEX_BYTES);
762
+ const uintStringZod = zod.default.string().refine((value) => DECIMAL_UINT.test(value) && BigInt(value) <= MAX_UINT256, { message: "expected a uint256 decimal integer string" });
763
+ const SolTypeZod = zod.default.enum([
764
+ "uint8",
765
+ "uint16",
766
+ "uint32",
767
+ "uint64",
768
+ "uint128",
769
+ "uint256",
770
+ "int128",
771
+ "int256",
772
+ "address",
773
+ "bool",
774
+ "bytes",
775
+ "bytes4",
776
+ "bytes32",
777
+ "string"
874
778
  ]);
875
- var ResourcePortZod = import_zod.default.object({
876
- kind: import_zod.default.literal("resource"),
877
- name: import_zod.default.string(),
878
- accepts: import_zod.default.enum(["erc20", "native", "any"]),
879
- mode: import_zod.default.enum(["linear", "copy"]),
880
- optional: import_zod.default.boolean().optional()
779
+ const ResourcePortZod = zod.default.object({
780
+ kind: zod.default.literal("resource"),
781
+ name: zod.default.string(),
782
+ accepts: zod.default.enum([
783
+ "erc20",
784
+ "native",
785
+ "any"
786
+ ]),
787
+ mode: zod.default.enum(["linear", "copy"]),
788
+ optional: zod.default.boolean().optional()
881
789
  });
882
- var HANDLE_UNITS = [
883
- "raw",
884
- "wad",
885
- "ray",
886
- "bps",
887
- "token-decimals"
790
+ const HANDLE_UNITS = [
791
+ "raw",
792
+ "wad",
793
+ "ray",
794
+ "bps",
795
+ "token-decimals"
888
796
  ];
889
- var STATIC_SOL_TYPES = [
890
- "uint256",
891
- "uint128",
892
- "uint64",
893
- "uint32",
894
- "uint16",
895
- "uint8",
896
- "address",
897
- "bool",
898
- "bytes32"
797
+ const STATIC_SOL_TYPES = [
798
+ "uint256",
799
+ "uint128",
800
+ "uint64",
801
+ "uint32",
802
+ "uint16",
803
+ "uint8",
804
+ "address",
805
+ "bool",
806
+ "bytes32"
899
807
  ];
900
- var HandleUnitsZod = import_zod.default.enum(HANDLE_UNITS);
901
- var StaticSolTypeZod = import_zod.default.enum(STATIC_SOL_TYPES);
902
- var STATIC_SOL_TYPE_SET = new Set(STATIC_SOL_TYPES);
903
- var isStaticSolType = (value) => STATIC_SOL_TYPE_SET.has(value);
904
- var HandlePortZod = import_zod.default.object({
905
- kind: import_zod.default.literal("handle"),
906
- name: import_zod.default.string(),
907
- type: SolTypeZod,
908
- mode: import_zod.default.enum(["linear", "copy"]),
909
- expose: import_zod.default.boolean().optional(),
910
- units: HandleUnitsZod.optional(),
911
- optional: import_zod.default.boolean().optional()
912
- });
913
- var InputPortZod = import_zod.default.discriminatedUnion("kind", [
914
- ResourcePortZod,
915
- HandlePortZod
916
- ]);
917
- var ResourceOutputPortZod = import_zod.default.object({
918
- kind: import_zod.default.literal("resource_output"),
919
- name: import_zod.default.string(),
920
- mode: import_zod.default.enum(["linear", "copy"]),
921
- availability: import_zod.default.enum(["now", "future"]).optional(),
922
- providesMinimum: import_zod.default.boolean().optional(),
923
- omitIfZero: import_zod.default.boolean().optional(),
924
- deliveryAddressInput: import_zod.default.string().optional(),
925
- // Declares an output *family*: the port expands, when a call's config is
926
- // bound, into one instance per element of the config array named here, or
927
- // into as many instances as the non-negative integer named here. Instances
928
- // are ordinary ports named `<name>.<index>`; see
929
- // `outputFamilies.ts:expandOutputPorts`.
930
- countFrom: import_zod.default.string().optional()
931
- });
932
- var OutputPortZod = import_zod.default.discriminatedUnion("kind", [
933
- ResourceOutputPortZod,
934
- HandlePortZod
935
- ]);
936
- var ManifestOperationZod = import_zod.default.object({
937
- id: import_zod.default.string(),
938
- description: import_zod.default.string().optional(),
939
- inputs: import_zod.default.array(InputPortZod),
940
- outputs: import_zod.default.array(OutputPortZod),
941
- configSchema: import_zod.default.unknown().optional()
808
+ const HandleUnitsZod = zod.default.enum(HANDLE_UNITS);
809
+ const StaticSolTypeZod = zod.default.enum(STATIC_SOL_TYPES);
810
+ const STATIC_SOL_TYPE_SET = new Set(STATIC_SOL_TYPES);
811
+ const isStaticSolType = (value) => STATIC_SOL_TYPE_SET.has(value);
812
+ const HandlePortZod = zod.default.object({
813
+ kind: zod.default.literal("handle"),
814
+ name: zod.default.string(),
815
+ type: SolTypeZod,
816
+ mode: zod.default.enum(["linear", "copy"]),
817
+ expose: zod.default.boolean().optional(),
818
+ units: HandleUnitsZod.optional(),
819
+ optional: zod.default.boolean().optional()
942
820
  });
943
- var PortKindEnum = import_zod.default.enum(["resource", "resource_output", "handle"]);
944
- var SelectorMatchZod = import_zod.default.object({
945
- kind: import_zod.default.union([PortKindEnum, import_zod.default.array(PortKindEnum)]),
946
- mode: import_zod.default.enum(["linear", "copy"]).optional(),
947
- type: import_zod.default.enum(["erc20", "native", "any"]).optional()
821
+ const InputPortZod = zod.default.discriminatedUnion("kind", [ResourcePortZod, HandlePortZod]);
822
+ const ResourceOutputPortZod = zod.default.object({
823
+ kind: zod.default.literal("resource_output"),
824
+ name: zod.default.string(),
825
+ mode: zod.default.enum(["linear", "copy"]),
826
+ availability: zod.default.enum(["now", "future"]).optional(),
827
+ providesMinimum: zod.default.boolean().optional(),
828
+ omitIfZero: zod.default.boolean().optional(),
829
+ deliveryAddressInput: zod.default.string().optional(),
830
+ countFrom: zod.default.string().optional()
948
831
  });
949
- var ConfigSelectionZod = import_zod.default.object({
950
- kind: import_zod.default.literal("config"),
951
- configKey: import_zod.default.string(),
952
- cardinality: import_zod.default.enum(["one", "many"])
832
+ const OutputPortZod = zod.default.discriminatedUnion("kind", [ResourceOutputPortZod, HandlePortZod]);
833
+ const ManifestOperationZod = zod.default.object({
834
+ id: zod.default.string(),
835
+ description: zod.default.string().optional(),
836
+ inputs: zod.default.array(InputPortZod),
837
+ outputs: zod.default.array(OutputPortZod),
838
+ configSchema: zod.default.unknown().optional()
953
839
  });
954
- var AllMatchingSelectionZod = import_zod.default.object({
955
- kind: import_zod.default.literal("all_matching")
956
- });
957
- var SelectorSelectionZod = import_zod.default.discriminatedUnion("kind", [
958
- ConfigSelectionZod,
959
- AllMatchingSelectionZod
840
+ const PortKindEnum = zod.default.enum([
841
+ "resource",
842
+ "resource_output",
843
+ "handle"
960
844
  ]);
961
- var GuardSelectorZod = import_zod.default.object({
962
- binding: import_zod.default.string(),
963
- source: import_zod.default.enum(["inputs", "outputs"]),
964
- match: SelectorMatchZod,
965
- selection: SelectorSelectionZod
845
+ const SelectorMatchZod = zod.default.object({
846
+ kind: zod.default.union([PortKindEnum, zod.default.array(PortKindEnum)]),
847
+ mode: zod.default.enum(["linear", "copy"]).optional(),
848
+ type: zod.default.enum([
849
+ "erc20",
850
+ "native",
851
+ "any"
852
+ ]).optional()
966
853
  });
967
- var GuardCompatibilityZod = import_zod.default.object({
968
- selectors: import_zod.default.array(GuardSelectorZod)
854
+ const ConfigSelectionZod = zod.default.object({
855
+ kind: zod.default.literal("config"),
856
+ configKey: zod.default.string(),
857
+ cardinality: zod.default.enum(["one", "many"])
969
858
  });
970
- var ManifestGuardZod = import_zod.default.object({
971
- kind: import_zod.default.string(),
972
- description: import_zod.default.string().optional(),
973
- configSchema: import_zod.default.unknown().optional(),
974
- compatibility: GuardCompatibilityZod.optional()
859
+ const AllMatchingSelectionZod = zod.default.object({ kind: zod.default.literal("all_matching") });
860
+ const SelectorSelectionZod = zod.default.discriminatedUnion("kind", [ConfigSelectionZod, AllMatchingSelectionZod]);
861
+ const GuardSelectorZod = zod.default.object({
862
+ binding: zod.default.string(),
863
+ source: zod.default.enum(["inputs", "outputs"]),
864
+ match: SelectorMatchZod,
865
+ selection: SelectorSelectionZod
975
866
  });
976
- var ManifestMaterialiserZod = import_zod.default.object({
977
- kind: import_zod.default.string(),
978
- description: import_zod.default.string().optional(),
979
- accepts: import_zod.default.enum(["resource", "handle", "any"]),
980
- configSchema: import_zod.default.unknown().optional()
867
+ const GuardCompatibilityZod = zod.default.object({ selectors: zod.default.array(GuardSelectorZod) });
868
+ const ManifestGuardZod = zod.default.object({
869
+ kind: zod.default.string(),
870
+ description: zod.default.string().optional(),
871
+ configSchema: zod.default.unknown().optional(),
872
+ compatibility: GuardCompatibilityZod.optional()
981
873
  });
982
- var ManifestPreconditionZod = import_zod.default.object({
983
- type: import_zod.default.string(),
984
- description: import_zod.default.string().optional(),
985
- configSchema: import_zod.default.unknown().optional()
874
+ const ManifestMaterialiserZod = zod.default.object({
875
+ kind: zod.default.string(),
876
+ description: zod.default.string().optional(),
877
+ accepts: zod.default.enum([
878
+ "resource",
879
+ "handle",
880
+ "any"
881
+ ]),
882
+ configSchema: zod.default.unknown().optional()
986
883
  });
987
- var ComposeManifestZod = import_zod.default.object({
988
- manifestVersion: import_zod.default.number(),
989
- manifestHash: import_zod.default.string(),
990
- flowSchema: import_zod.default.object({}).passthrough(),
991
- operations: import_zod.default.array(ManifestOperationZod),
992
- guards: import_zod.default.array(ManifestGuardZod),
993
- materialisers: import_zod.default.array(ManifestMaterialiserZod),
994
- preconditions: import_zod.default.array(ManifestPreconditionZod).optional()
884
+ const ManifestPreconditionZod = zod.default.object({
885
+ type: zod.default.string(),
886
+ description: zod.default.string().optional(),
887
+ configSchema: zod.default.unknown().optional()
995
888
  });
996
- var hexStringZod = import_zod.default.string().startsWith("0x");
997
- var SettlementEscrowZod = import_zod.default.object({
998
- chainId: chainIdZod,
999
- address: hexStringZod,
1000
- token: hexStringZod,
1001
- amount: import_zod.default.string(),
1002
- cap: import_zod.default.string(),
1003
- owner: hexStringZod,
1004
- refund: hexStringZod,
1005
- expiresAtMs: import_zod.default.number().int().positive()
889
+ const ComposeManifestZod = zod.default.object({
890
+ manifestVersion: zod.default.number(),
891
+ manifestHash: zod.default.string(),
892
+ flowSchema: zod.default.object({}).passthrough(),
893
+ operations: zod.default.array(ManifestOperationZod),
894
+ guards: zod.default.array(ManifestGuardZod),
895
+ materialisers: zod.default.array(ManifestMaterialiserZod),
896
+ preconditions: zod.default.array(ManifestPreconditionZod).optional()
1006
897
  });
1007
- var assertionOwnerZod = import_zod.default.union([
1008
- evmAddressZod,
1009
- import_zod.default.enum(["escrow", "delivery"])
1010
- ]);
1011
- var CheckZod = import_zod.default.discriminatedUnion("kind", [
1012
- import_zod.default.object({
1013
- kind: import_zod.default.literal("erc20BalanceGte"),
1014
- chainId: chainIdZod,
1015
- token: evmAddressZod,
1016
- owner: evmAddressZod,
1017
- minAmount: uintStringZod
1018
- }),
1019
- import_zod.default.object({
1020
- kind: import_zod.default.literal("nativeBalanceGte"),
1021
- chainId: chainIdZod,
1022
- owner: evmAddressZod,
1023
- minAmount: uintStringZod
1024
- }),
1025
- import_zod.default.object({
1026
- kind: import_zod.default.literal("call"),
1027
- chainId: chainIdZod,
1028
- to: evmAddressZod,
1029
- calldata: hexBytesZod,
1030
- comparator: import_zod.default.enum(["gte", "eq", "lte"]),
1031
- value: uintStringZod
1032
- })
1033
- ]);
1034
- var AssertionSpecZod = import_zod.default.discriminatedUnion("kind", [
1035
- ...CheckZod.options,
1036
- import_zod.default.object({
1037
- kind: import_zod.default.literal("erc20BalanceDeltaGte"),
1038
- chainId: import_zod.default.number().int().positive(),
1039
- token: evmAddressZod,
1040
- owner: assertionOwnerZod,
1041
- minDelta: uintStringZod
1042
- }),
1043
- import_zod.default.object({
1044
- kind: import_zod.default.literal("nativeBalanceDeltaGte"),
1045
- chainId: import_zod.default.number().int().positive(),
1046
- owner: assertionOwnerZod,
1047
- minDelta: uintStringZod
1048
- })
898
+ const hexStringZod = zod.default.string().startsWith("0x");
899
+ const SettlementEscrowZod = zod.default.object({
900
+ chainId: chainIdZod,
901
+ address: hexStringZod,
902
+ token: hexStringZod,
903
+ amount: zod.default.string(),
904
+ cap: zod.default.string(),
905
+ owner: hexStringZod,
906
+ refund: hexStringZod,
907
+ expiresAtMs: zod.default.number().int().positive()
908
+ });
909
+ const assertionOwnerZod = zod.default.union([evmAddressZod, zod.default.enum(["escrow", "delivery"])]);
910
+ const AssertionSpecZod = zod.default.discriminatedUnion("kind", [
911
+ zod.default.object({
912
+ kind: zod.default.literal("erc20BalanceGte"),
913
+ chainId: chainIdZod,
914
+ token: evmAddressZod,
915
+ owner: evmAddressZod,
916
+ minAmount: uintStringZod
917
+ }),
918
+ zod.default.object({
919
+ kind: zod.default.literal("nativeBalanceGte"),
920
+ chainId: chainIdZod,
921
+ owner: evmAddressZod,
922
+ minAmount: uintStringZod
923
+ }),
924
+ zod.default.object({
925
+ kind: zod.default.literal("call"),
926
+ chainId: chainIdZod,
927
+ to: evmAddressZod,
928
+ calldata: hexBytesZod,
929
+ comparator: zod.default.enum([
930
+ "gte",
931
+ "eq",
932
+ "lte"
933
+ ]),
934
+ value: uintStringZod
935
+ }),
936
+ zod.default.object({
937
+ kind: zod.default.literal("erc20BalanceDeltaGte"),
938
+ chainId: zod.default.number().int().positive(),
939
+ token: evmAddressZod,
940
+ owner: assertionOwnerZod,
941
+ minDelta: uintStringZod
942
+ }),
943
+ zod.default.object({
944
+ kind: zod.default.literal("nativeBalanceDeltaGte"),
945
+ chainId: zod.default.number().int().positive(),
946
+ owner: assertionOwnerZod,
947
+ minDelta: uintStringZod
948
+ })
1049
949
  ]);
1050
- var assertionSpecOptionByKind = (kind) => {
1051
- const option = AssertionSpecZod.options.find(
1052
- (o) => o.shape.kind.value === kind
1053
- );
1054
- if (option === void 0) {
1055
- throw new Error(`AssertionSpecZod has no member with kind "${kind}"`);
1056
- }
1057
- return option;
950
+ const assertionSpecOptionByKind = (kind) => {
951
+ const option = AssertionSpecZod.options.find((o) => o.shape.kind.value === kind);
952
+ if (option === void 0) throw new Error(`AssertionSpecZod has no member with kind "${kind}"`);
953
+ return option;
1058
954
  };
1059
- var AssertedPredicateZod = import_zod.default.discriminatedUnion("kind", [
1060
- import_zod.default.object({
1061
- kind: import_zod.default.literal("erc20BalanceGte"),
1062
- chainId: import_zod.default.number().int().positive(),
1063
- token: evmAddressZod,
1064
- owner: assertionOwnerZod,
1065
- minAmount: uintStringZod
1066
- }),
1067
- import_zod.default.object({
1068
- kind: import_zod.default.literal("nativeBalanceGte"),
1069
- chainId: import_zod.default.number().int().positive(),
1070
- owner: assertionOwnerZod,
1071
- minAmount: uintStringZod
1072
- }),
1073
- assertionSpecOptionByKind("call"),
1074
- assertionSpecOptionByKind("erc20BalanceDeltaGte"),
1075
- assertionSpecOptionByKind("nativeBalanceDeltaGte")
955
+ const AssertedPredicateZod = zod.default.discriminatedUnion("kind", [
956
+ zod.default.object({
957
+ kind: zod.default.literal("erc20BalanceGte"),
958
+ chainId: zod.default.number().int().positive(),
959
+ token: evmAddressZod,
960
+ owner: assertionOwnerZod,
961
+ minAmount: uintStringZod
962
+ }),
963
+ zod.default.object({
964
+ kind: zod.default.literal("nativeBalanceGte"),
965
+ chainId: zod.default.number().int().positive(),
966
+ owner: assertionOwnerZod,
967
+ minAmount: uintStringZod
968
+ }),
969
+ assertionSpecOptionByKind("call"),
970
+ assertionSpecOptionByKind("erc20BalanceDeltaGte"),
971
+ assertionSpecOptionByKind("nativeBalanceDeltaGte")
1076
972
  ]);
1077
- var VerificationDescriptorZod = import_zod.default.object({
1078
- validationProgramHash: import_zod.default.string().regex(BYTES32_LOWER_HEX),
1079
- // The C5 echo's second hash (GD-8): the params-vector content hash
1080
- // (`paramsHash`, C1). Required and jointly necessary with the value-blind
1081
- // `validationProgramHash`.
1082
- paramsHash: import_zod.default.string().regex(BYTES32_LOWER_HEX),
1083
- assertedPredicate: import_zod.default.array(AssertedPredicateZod)
1084
- });
1085
- var ContinuationPlanZod = import_zod.default.object({
1086
- chainId: chainIdZod,
1087
- nextFlow: import_zod.default.unknown(),
1088
- check: CheckZod,
1089
- validity: import_zod.default.object({ expiresAtMs: epochMsZod }),
1090
- correlationId: import_zod.default.string().optional()
1091
- });
1092
- var SettlementZod = import_zod.default.object({
1093
- escrow: SettlementEscrowZod.optional(),
1094
- continuation: ContinuationPlanZod.optional()
1095
- });
1096
- // Annotate the CommonJS export names for ESM import in node:
1097
- 0 && (module.exports = {
1098
- ARC_CHAIN_ID,
1099
- ARC_NATIVE_ERC20,
1100
- ARC_NATIVE_SCALE,
1101
- AppliedGuardSchema,
1102
- AssertedErc20BalanceGteSpecSchema,
1103
- AssertedNativeBalanceGteSpecSchema,
1104
- AssertedPredicateSchema,
1105
- AssertedPredicateZod,
1106
- AssertionOwnerSchema,
1107
- AssertionSpecSchema,
1108
- AssertionSpecZod,
1109
- BindValueSchema,
1110
- Bytes32HexSchema,
1111
- COMPOSER_SDK_VERSION_HEADER,
1112
- COMPOSE_VERSION_HEADER,
1113
- CONTINUATION_COMMITMENT_OP_ID,
1114
- CallCheckSpecSchema,
1115
- CallSchema,
1116
- CheckSchema,
1117
- CheckZod,
1118
- ComposeManifestZod,
1119
- ContinuationIntentSchema,
1120
- ContinuationOutcomeSchema,
1121
- ContinuationPlanSchema,
1122
- ContinuationPlanZod,
1123
- EVMAddressString,
1124
- EVM_NATIVE_SENTINEL,
1125
- Erc20BalanceDeltaGteSpecSchema,
1126
- Erc20BalanceGteSpecSchema,
1127
- FlowInputSchema,
1128
- FlowSchema,
1129
- GuardCompatibilityZod,
1130
- GuardSelectorZod,
1131
- HANDLE_UNITS,
1132
- HandleInputSchema,
1133
- HandlePortZod,
1134
- HandleUnitsZod,
1135
- HexStringSchema,
1136
- InputPortZod,
1137
- IntegerString,
1138
- LineageSchema,
1139
- LiteralBindingSchema,
1140
- ManifestGuardZod,
1141
- ManifestMaterialiserZod,
1142
- ManifestOperationZod,
1143
- ManifestPreconditionZod,
1144
- NativeBalanceDeltaGteSpecSchema,
1145
- NativeBalanceGteSpecSchema,
1146
- OutputPortZod,
1147
- PROVIDER_KIND,
1148
- Phase1ArtifactSchema,
1149
- RESERVED_REF_SCOPES,
1150
- RefSchema,
1151
- ResourceInputSchema,
1152
- ResourceOutputPortZod,
1153
- ResourcePortZod,
1154
- ResourceSchema,
1155
- SIMULATE_MAX_REQUIREMENTS,
1156
- SIMULATE_MAX_TRACKED_BALANCES,
1157
- STATIC_SOL_TYPES,
1158
- SettlementZod,
1159
- SolTypeSchema,
1160
- StaticSolTypeZod,
1161
- TEMPO_CHAIN_ID,
1162
- TEMPO_NATIVE_ERC20,
1163
- UuidSchema,
1164
- VerificationDescriptorSchema,
1165
- VerificationDescriptorZod,
1166
- canonicalAssertedPredicate,
1167
- canonicalNativeAddress,
1168
- checkCompatibility,
1169
- copy,
1170
- erc20,
1171
- erc20Allowance,
1172
- erc20Balance,
1173
- erc20Resource,
1174
- erc20Token,
1175
- expandOutputPorts,
1176
- familySize,
1177
- flowInputMode,
1178
- flowInputResource,
1179
- flowInputType,
1180
- foldChainCapabilities,
1181
- foldMaterialiserMetadata,
1182
- foldRef,
1183
- foldResource,
1184
- getChainCapabilities,
1185
- handle,
1186
- hasErc20CanonicalNative,
1187
- instancePortName,
1188
- isAsErc20Chain,
1189
- isContextKey,
1190
- isEQCheck,
1191
- isERC20Resource,
1192
- isErc20AllowancePrecondition,
1193
- isErc20BalancePrecondition,
1194
- isFutureResourceOutput,
1195
- isGTECheck,
1196
- isHandlePort,
1197
- isLTECheck,
1198
- isMaterialiserInput,
1199
- isMsgValueNative,
1200
- isNativeAddressForChain,
1201
- isNativeBalancePrecondition,
1202
- isNativeResource,
1203
- isOutputFamily,
1204
- isRef,
1205
- isResourceInput,
1206
- isResourceOutputPort,
1207
- isResourcePort,
1208
- isStaticSolType,
1209
- linear,
1210
- native,
1211
- nativeBalance,
1212
- nativeCheckPolicy,
1213
- nativeResource,
1214
- normalizeNativeTokenAddress,
1215
- normalizeResource,
1216
- opHandle,
1217
- parseRef,
1218
- parseVersion,
1219
- providerKindByName,
1220
- providerKindNames,
1221
- readResource,
1222
- ref,
1223
- refKey,
1224
- resource,
1225
- resourceKey,
1226
- resourceOutput,
1227
- resourceToken,
1228
- resourcesEqual,
1229
- settledOutcome
973
+ const VerificationDescriptorZod = zod.default.object({
974
+ validationProgramHash: zod.default.string().regex(BYTES32_LOWER_HEX),
975
+ paramsHash: zod.default.string().regex(BYTES32_LOWER_HEX),
976
+ assertedPredicate: zod.default.array(AssertedPredicateZod)
1230
977
  });
978
+ const SettlementZod = zod.default.object({ escrow: SettlementEscrowZod.optional() });
979
+ //#endregion
980
+ exports.ARC_CHAIN_ID = ARC_CHAIN_ID;
981
+ exports.ARC_NATIVE_ERC20 = ARC_NATIVE_ERC20;
982
+ exports.ARC_NATIVE_SCALE = ARC_NATIVE_SCALE;
983
+ exports.AppliedGuardSchema = AppliedGuardSchema;
984
+ exports.AssertedErc20BalanceGteSpecSchema = AssertedErc20BalanceGteSpecSchema;
985
+ exports.AssertedNativeBalanceGteSpecSchema = AssertedNativeBalanceGteSpecSchema;
986
+ exports.AssertedPredicateSchema = AssertedPredicateSchema;
987
+ exports.AssertedPredicateZod = AssertedPredicateZod;
988
+ exports.AssertionOwnerSchema = AssertionOwnerSchema;
989
+ exports.AssertionSpecSchema = AssertionSpecSchema;
990
+ exports.AssertionSpecZod = AssertionSpecZod;
991
+ exports.BindValueSchema = BindValueSchema;
992
+ exports.Bytes32HexSchema = Bytes32HexSchema;
993
+ exports.COMPOSER_SDK_VERSION_HEADER = COMPOSER_SDK_VERSION_HEADER;
994
+ exports.COMPOSE_VERSION_HEADER = COMPOSE_VERSION_HEADER;
995
+ exports.CONTINUATION_COMMITMENT_OP_ID = CONTINUATION_COMMITMENT_OP_ID;
996
+ exports.CallCheckSpecSchema = CallCheckSpecSchema;
997
+ exports.CallSchema = CallSchema;
998
+ exports.ComposeManifestZod = ComposeManifestZod;
999
+ exports.ContinuationIntentSchema = ContinuationIntentSchema;
1000
+ exports.ContinuationOutcomeSchema = ContinuationOutcomeSchema;
1001
+ exports.EVMAddressString = EVMAddressString;
1002
+ exports.EVM_NATIVE_SENTINEL = EVM_NATIVE_SENTINEL;
1003
+ exports.Erc20BalanceDeltaGteSpecSchema = Erc20BalanceDeltaGteSpecSchema;
1004
+ exports.Erc20BalanceGteSpecSchema = Erc20BalanceGteSpecSchema;
1005
+ exports.FlowInputSchema = FlowInputSchema;
1006
+ exports.FlowSchema = FlowSchema;
1007
+ exports.GuardCompatibilityZod = GuardCompatibilityZod;
1008
+ exports.GuardSelectorZod = GuardSelectorZod;
1009
+ exports.HANDLE_UNITS = HANDLE_UNITS;
1010
+ exports.HandleInputSchema = HandleInputSchema;
1011
+ exports.HandlePortZod = HandlePortZod;
1012
+ exports.HandleUnitsZod = HandleUnitsZod;
1013
+ exports.HexStringSchema = HexStringSchema;
1014
+ exports.InputPortZod = InputPortZod;
1015
+ exports.IntegerString = IntegerString;
1016
+ exports.LineageSchema = LineageSchema;
1017
+ exports.LiteralBindingSchema = LiteralBindingSchema;
1018
+ exports.ManifestGuardZod = ManifestGuardZod;
1019
+ exports.ManifestMaterialiserZod = ManifestMaterialiserZod;
1020
+ exports.ManifestOperationZod = ManifestOperationZod;
1021
+ exports.ManifestPreconditionZod = ManifestPreconditionZod;
1022
+ exports.NativeBalanceDeltaGteSpecSchema = NativeBalanceDeltaGteSpecSchema;
1023
+ exports.NativeBalanceGteSpecSchema = NativeBalanceGteSpecSchema;
1024
+ exports.OutputPortZod = OutputPortZod;
1025
+ exports.PROVIDER_KIND = PROVIDER_KIND;
1026
+ exports.Phase1ArtifactSchema = Phase1ArtifactSchema;
1027
+ exports.RESERVED_REF_SCOPES = RESERVED_REF_SCOPES;
1028
+ exports.RefSchema = RefSchema;
1029
+ exports.ResourceInputSchema = ResourceInputSchema;
1030
+ exports.ResourceOutputPortZod = ResourceOutputPortZod;
1031
+ exports.ResourcePortZod = ResourcePortZod;
1032
+ exports.ResourceSchema = ResourceSchema;
1033
+ exports.SIMULATE_MAX_REQUIREMENTS = SIMULATE_MAX_REQUIREMENTS;
1034
+ exports.SIMULATE_MAX_TRACKED_BALANCES = SIMULATE_MAX_TRACKED_BALANCES;
1035
+ exports.STATIC_SOL_TYPES = STATIC_SOL_TYPES;
1036
+ exports.SettlementZod = SettlementZod;
1037
+ exports.SolTypeSchema = SolTypeSchema;
1038
+ exports.StaticSolTypeZod = StaticSolTypeZod;
1039
+ exports.TEMPO_CHAIN_ID = TEMPO_CHAIN_ID;
1040
+ exports.TEMPO_NATIVE_ERC20 = TEMPO_NATIVE_ERC20;
1041
+ exports.UuidSchema = UuidSchema;
1042
+ exports.VerificationDescriptorSchema = VerificationDescriptorSchema;
1043
+ exports.VerificationDescriptorZod = VerificationDescriptorZod;
1044
+ exports.canonicalAssertedPredicate = canonicalAssertedPredicate;
1045
+ exports.canonicalNativeAddress = canonicalNativeAddress;
1046
+ exports.checkCompatibility = checkCompatibility;
1047
+ exports.copy = copy;
1048
+ exports.erc20 = erc20;
1049
+ exports.erc20Allowance = erc20Allowance;
1050
+ exports.erc20Balance = erc20Balance;
1051
+ exports.erc20Resource = erc20Resource;
1052
+ exports.erc20Token = erc20Token;
1053
+ exports.expandOutputPorts = expandOutputPorts;
1054
+ exports.familySize = familySize;
1055
+ exports.flowInputMode = flowInputMode;
1056
+ exports.flowInputResource = flowInputResource;
1057
+ exports.flowInputType = flowInputType;
1058
+ exports.foldChainCapabilities = foldChainCapabilities;
1059
+ exports.foldMaterialiserMetadata = foldMaterialiserMetadata;
1060
+ exports.foldRef = foldRef;
1061
+ exports.foldResource = foldResource;
1062
+ exports.getChainCapabilities = getChainCapabilities;
1063
+ exports.handle = handle;
1064
+ exports.hasErc20CanonicalNative = hasErc20CanonicalNative;
1065
+ exports.instancePortName = instancePortName;
1066
+ exports.isAsErc20Chain = isAsErc20Chain;
1067
+ exports.isContextKey = isContextKey;
1068
+ exports.isERC20Resource = isERC20Resource;
1069
+ exports.isErc20AllowancePrecondition = isErc20AllowancePrecondition;
1070
+ exports.isErc20BalancePrecondition = isErc20BalancePrecondition;
1071
+ exports.isFutureResourceOutput = isFutureResourceOutput;
1072
+ exports.isHandlePort = isHandlePort;
1073
+ exports.isMaterialiserInput = isMaterialiserInput;
1074
+ exports.isMsgValueNative = isMsgValueNative;
1075
+ exports.isNativeAddressForChain = isNativeAddressForChain;
1076
+ exports.isNativeBalancePrecondition = isNativeBalancePrecondition;
1077
+ exports.isNativeResource = isNativeResource;
1078
+ exports.isOutputFamily = isOutputFamily;
1079
+ exports.isRef = isRef;
1080
+ exports.isResourceInput = isResourceInput;
1081
+ exports.isResourceOutputPort = isResourceOutputPort;
1082
+ exports.isResourcePort = isResourcePort;
1083
+ exports.isStaticSolType = isStaticSolType;
1084
+ exports.linear = linear;
1085
+ exports.native = native;
1086
+ exports.nativeBalance = nativeBalance;
1087
+ exports.nativeCheckPolicy = nativeCheckPolicy;
1088
+ exports.nativeResource = nativeResource;
1089
+ exports.normalizeNativeTokenAddress = normalizeNativeTokenAddress;
1090
+ exports.normalizeResource = normalizeResource;
1091
+ exports.opHandle = opHandle;
1092
+ exports.parseRef = parseRef;
1093
+ exports.parseVersion = parseVersion;
1094
+ exports.providerKindByName = providerKindByName;
1095
+ exports.providerKindNames = providerKindNames;
1096
+ exports.readResource = readResource;
1097
+ exports.ref = ref;
1098
+ exports.refKey = refKey;
1099
+ exports.resource = resource;
1100
+ exports.resourceKey = resourceKey;
1101
+ exports.resourceOutput = resourceOutput;
1102
+ exports.resourceToken = resourceToken;
1103
+ exports.resourcesEqual = resourcesEqual;
1104
+ exports.settledOutcome = settledOutcome;