@lifi/compose-spec 0.8.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,1180 +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
- ComposeManifestZod: () => ComposeManifestZod,
52
- ContinuationIntentSchema: () => ContinuationIntentSchema,
53
- ContinuationOutcomeSchema: () => ContinuationOutcomeSchema,
54
- EVMAddressString: () => EVMAddressString,
55
- EVM_NATIVE_SENTINEL: () => EVM_NATIVE_SENTINEL,
56
- Erc20BalanceDeltaGteSpecSchema: () => Erc20BalanceDeltaGteSpecSchema,
57
- Erc20BalanceGteSpecSchema: () => Erc20BalanceGteSpecSchema,
58
- FlowInputSchema: () => FlowInputSchema,
59
- FlowSchema: () => FlowSchema,
60
- GuardCompatibilityZod: () => GuardCompatibilityZod,
61
- GuardSelectorZod: () => GuardSelectorZod,
62
- HANDLE_UNITS: () => HANDLE_UNITS,
63
- HandleInputSchema: () => HandleInputSchema,
64
- HandlePortZod: () => HandlePortZod,
65
- HandleUnitsZod: () => HandleUnitsZod,
66
- HexStringSchema: () => HexStringSchema,
67
- InputPortZod: () => InputPortZod,
68
- IntegerString: () => IntegerString,
69
- LineageSchema: () => LineageSchema,
70
- LiteralBindingSchema: () => LiteralBindingSchema,
71
- ManifestGuardZod: () => ManifestGuardZod,
72
- ManifestMaterialiserZod: () => ManifestMaterialiserZod,
73
- ManifestOperationZod: () => ManifestOperationZod,
74
- ManifestPreconditionZod: () => ManifestPreconditionZod,
75
- NativeBalanceDeltaGteSpecSchema: () => NativeBalanceDeltaGteSpecSchema,
76
- NativeBalanceGteSpecSchema: () => NativeBalanceGteSpecSchema,
77
- OutputPortZod: () => OutputPortZod,
78
- PROVIDER_KIND: () => PROVIDER_KIND,
79
- Phase1ArtifactSchema: () => Phase1ArtifactSchema,
80
- RESERVED_REF_SCOPES: () => RESERVED_REF_SCOPES,
81
- RefSchema: () => RefSchema,
82
- ResourceInputSchema: () => ResourceInputSchema,
83
- ResourceOutputPortZod: () => ResourceOutputPortZod,
84
- ResourcePortZod: () => ResourcePortZod,
85
- ResourceSchema: () => ResourceSchema,
86
- SIMULATE_MAX_REQUIREMENTS: () => SIMULATE_MAX_REQUIREMENTS,
87
- SIMULATE_MAX_TRACKED_BALANCES: () => SIMULATE_MAX_TRACKED_BALANCES,
88
- STATIC_SOL_TYPES: () => STATIC_SOL_TYPES,
89
- SettlementZod: () => SettlementZod,
90
- SolTypeSchema: () => SolTypeSchema,
91
- StaticSolTypeZod: () => StaticSolTypeZod,
92
- TEMPO_CHAIN_ID: () => TEMPO_CHAIN_ID,
93
- TEMPO_NATIVE_ERC20: () => TEMPO_NATIVE_ERC20,
94
- UuidSchema: () => UuidSchema,
95
- VerificationDescriptorSchema: () => VerificationDescriptorSchema,
96
- VerificationDescriptorZod: () => VerificationDescriptorZod,
97
- canonicalAssertedPredicate: () => canonicalAssertedPredicate,
98
- canonicalNativeAddress: () => canonicalNativeAddress,
99
- checkCompatibility: () => checkCompatibility,
100
- copy: () => copy,
101
- erc20: () => erc20,
102
- erc20Allowance: () => erc20Allowance,
103
- erc20Balance: () => erc20Balance,
104
- erc20Resource: () => erc20Resource,
105
- erc20Token: () => erc20Token,
106
- expandOutputPorts: () => expandOutputPorts,
107
- familySize: () => familySize,
108
- flowInputMode: () => flowInputMode,
109
- flowInputResource: () => flowInputResource,
110
- flowInputType: () => flowInputType,
111
- foldChainCapabilities: () => foldChainCapabilities,
112
- foldMaterialiserMetadata: () => foldMaterialiserMetadata,
113
- foldRef: () => foldRef,
114
- foldResource: () => foldResource,
115
- getChainCapabilities: () => getChainCapabilities,
116
- handle: () => handle,
117
- hasErc20CanonicalNative: () => hasErc20CanonicalNative,
118
- instancePortName: () => instancePortName,
119
- isAsErc20Chain: () => isAsErc20Chain,
120
- isContextKey: () => isContextKey,
121
- isERC20Resource: () => isERC20Resource,
122
- isErc20AllowancePrecondition: () => isErc20AllowancePrecondition,
123
- isErc20BalancePrecondition: () => isErc20BalancePrecondition,
124
- isFutureResourceOutput: () => isFutureResourceOutput,
125
- isHandlePort: () => isHandlePort,
126
- isMaterialiserInput: () => isMaterialiserInput,
127
- isMsgValueNative: () => isMsgValueNative,
128
- isNativeAddressForChain: () => isNativeAddressForChain,
129
- isNativeBalancePrecondition: () => isNativeBalancePrecondition,
130
- isNativeResource: () => isNativeResource,
131
- isOutputFamily: () => isOutputFamily,
132
- isRef: () => isRef,
133
- isResourceInput: () => isResourceInput,
134
- isResourceOutputPort: () => isResourceOutputPort,
135
- isResourcePort: () => isResourcePort,
136
- isStaticSolType: () => isStaticSolType,
137
- linear: () => linear,
138
- native: () => native,
139
- nativeBalance: () => nativeBalance,
140
- nativeCheckPolicy: () => nativeCheckPolicy,
141
- nativeResource: () => nativeResource,
142
- normalizeNativeTokenAddress: () => normalizeNativeTokenAddress,
143
- normalizeResource: () => normalizeResource,
144
- opHandle: () => opHandle,
145
- parseRef: () => parseRef,
146
- parseVersion: () => parseVersion,
147
- providerKindByName: () => providerKindByName,
148
- providerKindNames: () => providerKindNames,
149
- readResource: () => readResource,
150
- ref: () => ref,
151
- refKey: () => refKey,
152
- resource: () => resource,
153
- resourceKey: () => resourceKey,
154
- resourceOutput: () => resourceOutput,
155
- resourceToken: () => resourceToken,
156
- resourcesEqual: () => resourcesEqual,
157
- settledOutcome: () => settledOutcome
158
- });
159
- module.exports = __toCommonJS(index_exports);
160
-
161
- // src/flowSchema.ts
162
- var import_effect = require("effect");
163
-
164
- // src/chainCapabilities.ts
165
- var EVM_NATIVE_SENTINEL = (
166
- // 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
167
- "0x0000000000000000000000000000000000000000"
168
- );
169
- var isNativeSentinel = (address) => address.toLowerCase() === EVM_NATIVE_SENTINEL.toLowerCase();
170
- var TEMPO_CHAIN_ID = 4217;
171
- var TEMPO_NATIVE_ERC20 = {
172
- token: "0x20C0000000000000000000000000000000000000",
173
- symbol: "pathUSD",
174
- 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
175
49
  };
176
- var ARC_CHAIN_ID = 5042;
177
- var ARC_NATIVE_ERC20 = {
178
- token: "0x3600000000000000000000000000000000000000",
179
- symbol: "USDC",
180
- 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
181
62
  };
182
- var ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
183
- var REGISTRY = /* @__PURE__ */ new Map([
184
- [
185
- TEMPO_CHAIN_ID,
186
- {
187
- kind: "as-erc20",
188
- chainId: TEMPO_CHAIN_ID,
189
- nativeErc20: TEMPO_NATIVE_ERC20
190
- }
191
- ],
192
- [
193
- ARC_CHAIN_ID,
194
- {
195
- kind: "native-mirrored-erc20",
196
- chainId: ARC_CHAIN_ID,
197
- nativeErc20: ARC_NATIVE_ERC20,
198
- nativeScale: ARC_NATIVE_SCALE
199
- }
200
- ]
201
- ]);
202
- var getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? { kind: "evm-native", chainId };
203
- var foldChainCapabilities = (caps, cases) => {
204
- switch (caps.kind) {
205
- case "evm-native":
206
- return cases.evmNative(caps.chainId);
207
- case "as-erc20":
208
- return cases.asErc20(caps.nativeErc20, caps.chainId);
209
- case "native-mirrored-erc20":
210
- return cases.nativeMirroredErc20(
211
- caps.nativeErc20,
212
- caps.nativeScale,
213
- caps.chainId
214
- );
215
- }
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
216
77
  };
217
- var nativeCheckPolicy = (chainId) => foldChainCapabilities(getChainCapabilities(chainId), {
218
- evmNative: () => ({ kind: "keep" }),
219
- asErc20: (nativeErc20) => ({ kind: "rewrite", token: nativeErc20.token }),
220
- nativeMirroredErc20: (nativeErc20) => ({
221
- kind: "reject",
222
- 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}`
223
- })
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
+ })
224
104
  });
225
- var isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
226
- var erc20CanonicalNative = (caps) => caps.kind === "as-erc20" || caps.kind === "native-mirrored-erc20" ? caps.nativeErc20 : void 0;
227
- var hasErc20CanonicalNative = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId)) !== void 0;
228
- var canonicalNativeAddress = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId))?.token ?? EVM_NATIVE_SENTINEL;
229
- var isNativeAddressForChain = (chainId, address) => {
230
- const target = canonicalNativeAddress(chainId);
231
- 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();
232
149
  };
233
- var isMsgValueNative = (chainId, address) => !hasErc20CanonicalNative(chainId) && isNativeSentinel(address);
234
- var normalizeResource = (r) => {
235
- if (r.kind !== "native") return r;
236
- const erc202 = erc20CanonicalNative(getChainCapabilities(r.chainId));
237
- if (erc202 === void 0) return r;
238
- return {
239
- kind: "erc20",
240
- chainId: r.chainId,
241
- token: erc202.token
242
- };
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
+ };
243
195
  };
244
- var normalizeNativeTokenAddress = (token, chainId) => hasErc20CanonicalNative(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
245
-
246
- // src/hexPatterns.ts
247
- var BYTES32_LOWER_HEX = /^0x[0-9a-f]{64}$/;
248
- var EVM_ADDRESS_HEX = /^0x[0-9a-fA-F]{40}$/;
249
- var HEX_BYTES = /^0x(?:[0-9a-fA-F]{2})*$/;
250
- var DECIMAL_UINT = /^[0-9]+$/;
251
- var MAX_UINT256 = 2n ** 256n - 1n;
252
- var MAX_DATE_MS = 864e13;
253
-
254
- // src/flowSchema.ts
255
- var SolTypeSchema = import_effect.Schema.Literal(
256
- "uint8",
257
- "uint16",
258
- "uint32",
259
- "uint64",
260
- "uint128",
261
- "uint256",
262
- "int128",
263
- "int256",
264
- "address",
265
- "bool",
266
- "bytes",
267
- "bytes4",
268
- "bytes32",
269
- "string"
270
- );
271
- var ChainIdSchema = import_effect.Schema.Number.pipe(
272
- import_effect.Schema.int(),
273
- import_effect.Schema.positive()
274
- );
275
- var EVMAddressString = import_effect.Schema.String.pipe(
276
- import_effect.Schema.pattern(EVM_ADDRESS_HEX, {
277
- message: () => "expected a 0x-prefixed 20-byte EVM address"
278
- })
279
- ).annotations({
280
- 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
281
251
  });
282
- var HexBytesString = import_effect.Schema.String.pipe(
283
- import_effect.Schema.pattern(HEX_BYTES, {
284
- message: () => "expected 0x-prefixed hex of whole bytes"
285
- })
286
- ).annotations({
287
- 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
288
255
  });
289
- var EpochMsSchema = import_effect.Schema.Number.pipe(
290
- import_effect.Schema.int(),
291
- import_effect.Schema.between(-MAX_DATE_MS, MAX_DATE_MS)
292
- );
293
- var IntegerString = import_effect.Schema.String.pipe(
294
- // Both checks live in one filter so the uint256-bound test only ever runs
295
- // `BigInt` on a string the digit check already accepted — order-independent
296
- // and never throws on malformed input.
297
- import_effect.Schema.filter((value) => {
298
- if (!DECIMAL_UINT.test(value)) {
299
- return "amount must be a decimal integer string";
300
- }
301
- if (BigInt(value) > MAX_UINT256) {
302
- return "amount must not exceed uint256 max";
303
- }
304
- return void 0;
305
- })
306
- );
307
- var RawResourceSchema = import_effect.Schema.Union(
308
- import_effect.Schema.Struct({ kind: import_effect.Schema.Literal("native"), chainId: ChainIdSchema }),
309
- import_effect.Schema.Struct({
310
- kind: import_effect.Schema.Literal("erc20"),
311
- token: EVMAddressString,
312
- chainId: ChainIdSchema
313
- })
314
- );
315
- var ResourceSchema = import_effect.Schema.transform(
316
- RawResourceSchema,
317
- import_effect.Schema.typeSchema(RawResourceSchema),
318
- {
319
- strict: true,
320
- decode: (raw) => normalizeResource(raw),
321
- encode: (resource2) => resource2
322
- }
323
- );
324
- var ResourceInputSchema = import_effect.Schema.Struct({
325
- name: import_effect.Schema.String,
326
- resource: ResourceSchema
256
+ const HandleInputSchema = effect.Schema.Struct({
257
+ name: effect.Schema.String,
258
+ type: SolTypeSchema
327
259
  });
328
- var HandleInputSchema = import_effect.Schema.Struct({
329
- name: import_effect.Schema.String,
330
- 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
331
265
  });
332
- var FlowInputSchema = import_effect.Schema.Union(
333
- ResourceInputSchema,
334
- HandleInputSchema
335
- );
336
- var RefSchema = import_effect.Schema.Struct({
337
- $ref: import_effect.Schema.String.pipe(
338
- import_effect.Schema.filter((s) => s.indexOf(".") > 0, {
339
- message: () => '$ref must be a dotpath like "input.name" or "nodeId.port"'
340
- })
341
- )
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
342
270
  });
343
- var LiteralBindingSchema = import_effect.Schema.Struct({
344
- kind: SolTypeSchema,
345
- 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))
346
284
  });
347
- var BindValueSchema = import_effect.Schema.Union(RefSchema, LiteralBindingSchema);
348
- var AppliedGuardSchema = import_effect.Schema.Struct(
349
- { kind: import_effect.Schema.String },
350
- { key: import_effect.Schema.String, value: import_effect.Schema.Unknown }
351
- );
352
- var NodeIdSchema = import_effect.Schema.String.pipe(
353
- import_effect.Schema.filter((id) => id !== "__proto__", {
354
- message: () => 'node id "__proto__" is reserved; choose another node id'
355
- })
356
- );
357
- var CallSchema = import_effect.Schema.Struct({
358
- id: NodeIdSchema,
359
- op: import_effect.Schema.String,
360
- bind: import_effect.Schema.optionalWith(
361
- import_effect.Schema.Record({ key: import_effect.Schema.String, value: BindValueSchema }),
362
- { default: () => ({}) }
363
- ),
364
- config: import_effect.Schema.optionalWith(
365
- import_effect.Schema.Record({ key: import_effect.Schema.String, value: import_effect.Schema.Unknown }),
366
- { default: () => ({}) }
367
- ),
368
- 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
369
289
  });
370
- var UuidSchema = import_effect.Schema.String.pipe(
371
- import_effect.Schema.pattern(/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/)
372
- );
373
- var LineageSchema = import_effect.Schema.Struct({
374
- journeyId: UuidSchema,
375
- 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)
376
297
  });
377
- var FlowSchema = import_effect.Schema.Struct({
378
- version: import_effect.Schema.Literal(1),
379
- id: import_effect.Schema.String,
380
- chainId: ChainIdSchema,
381
- inputs: import_effect.Schema.Array(FlowInputSchema),
382
- nodes: import_effect.Schema.Array(CallSchema),
383
- 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
384
306
  });
385
-
386
- // src/continuation.ts
387
- var import_effect2 = require("effect");
388
- var CONTINUATION_COMMITMENT_OP_ID = "continuation.commitment";
389
- var RawContinuationOutcomeSchema = import_effect2.Schema.Struct({
390
- token: EVMAddressString,
391
- minAmount: IntegerString,
392
- destination: EVMAddressString,
393
- 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
394
314
  });
395
- var ContinuationOutcomeSchema = import_effect2.Schema.transform(
396
- RawContinuationOutcomeSchema,
397
- import_effect2.Schema.typeSchema(RawContinuationOutcomeSchema),
398
- {
399
- strict: true,
400
- decode: (raw) => ({
401
- ...raw,
402
- token: normalizeNativeTokenAddress(raw.token, raw.chainId)
403
- }),
404
- encode: (outcome) => outcome
405
- }
406
- );
407
- var ContinuationIntentSchema = import_effect2.Schema.Struct({
408
- // `NonEmptyArray` enforces ≥1 outcome at the parse boundary, so downstream needs no guard.
409
- outcomes: import_effect2.Schema.NonEmptyArray(ContinuationOutcomeSchema),
410
- continuationFlow: import_effect2.Schema.optional(FlowSchema),
411
- validity: import_effect2.Schema.Struct({ expiresAtMs: EpochMsSchema }),
412
- perpetual: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
413
- provider: import_effect2.Schema.optional(import_effect2.Schema.String),
414
- // Funding-path mode. The HTTP wire contract is documented by
415
- // `ComposeActionsSchema` in `@lifi/api-schemas`.
416
- 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"))
417
322
  });
418
- var HexStringSchema = import_effect2.Schema.String.pipe(import_effect2.Schema.startsWith("0x"));
419
- var Phase1EscrowSchema = import_effect2.Schema.Struct({
420
- chainId: ChainIdSchema,
421
- address: HexStringSchema,
422
- token: HexStringSchema,
423
- amount: import_effect2.Schema.String,
424
- cap: import_effect2.Schema.String,
425
- owner: HexStringSchema,
426
- refund: HexStringSchema,
427
- 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())
428
333
  });
429
- var Phase1ArtifactSchema = import_effect2.Schema.Union(
430
- import_effect2.Schema.Struct({
431
- kind: import_effect2.Schema.Literal("transaction"),
432
- funding: import_effect2.Schema.Literal("inline", "external"),
433
- transactionRequest: import_effect2.Schema.optional(
434
- import_effect2.Schema.Struct({
435
- to: import_effect2.Schema.String,
436
- data: import_effect2.Schema.String,
437
- value: import_effect2.Schema.String,
438
- chainId: import_effect2.Schema.Number
439
- })
440
- ),
441
- escrow: import_effect2.Schema.optional(Phase1EscrowSchema)
442
- }),
443
- import_effect2.Schema.Struct({
444
- kind: import_effect2.Schema.Literal("signables"),
445
- typedData: import_effect2.Schema.Array(import_effect2.Schema.Unknown)
446
- }),
447
- import_effect2.Schema.Struct({ kind: import_effect2.Schema.Literal("none") })
448
- );
449
- var AssertionOwnerSchema = import_effect2.Schema.Union(
450
- EVMAddressString,
451
- import_effect2.Schema.Literal("escrow", "delivery")
452
- );
453
- var Erc20BalanceGteSpecSchema = import_effect2.Schema.Struct({
454
- kind: import_effect2.Schema.Literal("erc20BalanceGte"),
455
- chainId: ChainIdSchema,
456
- token: EVMAddressString,
457
- owner: EVMAddressString,
458
- 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
459
355
  });
460
- var NativeBalanceGteSpecSchema = import_effect2.Schema.Struct({
461
- kind: import_effect2.Schema.Literal("nativeBalanceGte"),
462
- chainId: ChainIdSchema,
463
- owner: EVMAddressString,
464
- minAmount: IntegerString
356
+ const NativeBalanceGteSpecSchema = effect.Schema.Struct({
357
+ kind: effect.Schema.Literal("nativeBalanceGte"),
358
+ chainId: ChainIdSchema,
359
+ owner: EVMAddressString,
360
+ minAmount: IntegerString
465
361
  });
466
- var CallCheckSpecSchema = import_effect2.Schema.Struct({
467
- kind: import_effect2.Schema.Literal("call"),
468
- chainId: ChainIdSchema,
469
- to: EVMAddressString,
470
- calldata: HexBytesString,
471
- comparator: import_effect2.Schema.Literal("gte", "eq", "lte"),
472
- 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
473
369
  });
474
- var asErc20BalanceGteCheck = (check, token) => ({
475
- kind: "erc20BalanceGte",
476
- chainId: check.chainId,
477
- token,
478
- owner: check.owner,
479
- 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
480
376
  });
481
- var decodeNativeBalanceGte = (check, ast) => {
482
- const policy = nativeCheckPolicy(check.chainId);
483
- switch (policy.kind) {
484
- case "keep":
485
- return import_effect2.ParseResult.succeed(check);
486
- case "rewrite":
487
- return import_effect2.ParseResult.succeed(asErc20BalanceGteCheck(check, policy.token));
488
- case "reject":
489
- return import_effect2.ParseResult.fail(new import_effect2.ParseResult.Type(ast, check, policy.reason));
490
- }
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
+ }
491
384
  };
492
- var Erc20BalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
493
- kind: import_effect2.Schema.Literal("erc20BalanceDeltaGte"),
494
- chainId: ChainIdSchema,
495
- token: EVMAddressString,
496
- owner: AssertionOwnerSchema,
497
- 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
391
+ });
392
+ const NativeBalanceDeltaGteSpecSchema = effect.Schema.Struct({
393
+ kind: effect.Schema.Literal("nativeBalanceDeltaGte"),
394
+ chainId: ChainIdSchema,
395
+ owner: AssertionOwnerSchema,
396
+ minDelta: IntegerString
498
397
  });
499
- var NativeBalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
500
- kind: import_effect2.Schema.Literal("nativeBalanceDeltaGte"),
501
- chainId: ChainIdSchema,
502
- owner: AssertionOwnerSchema,
503
- minDelta: IntegerString
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
504
409
  });
505
- var AssertionSpecSchema = import_effect2.Schema.Union(
506
- Erc20BalanceGteSpecSchema,
507
- NativeBalanceGteSpecSchema,
508
- CallCheckSpecSchema,
509
- Erc20BalanceDeltaGteSpecSchema,
510
- NativeBalanceDeltaGteSpecSchema
511
- );
512
- var settledOutcome = (intent) => intent.outcomes[0];
513
-
514
- // src/descriptor.ts
515
- var import_effect3 = require("effect");
516
- var Bytes32HexSchema = import_effect3.Schema.String.pipe(
517
- import_effect3.Schema.pattern(BYTES32_LOWER_HEX)
518
- );
519
- var AssertedErc20BalanceGteSpecSchema = import_effect3.Schema.Struct({
520
- kind: import_effect3.Schema.Literal("erc20BalanceGte"),
521
- chainId: ChainIdSchema,
522
- token: EVMAddressString,
523
- owner: AssertionOwnerSchema,
524
- minAmount: IntegerString
410
+ const AssertedNativeBalanceGteSpecSchema = effect.Schema.Struct({
411
+ kind: effect.Schema.Literal("nativeBalanceGte"),
412
+ chainId: ChainIdSchema,
413
+ owner: AssertionOwnerSchema,
414
+ minAmount: IntegerString
525
415
  });
526
- var AssertedNativeBalanceGteSpecSchema = import_effect3.Schema.Struct({
527
- kind: import_effect3.Schema.Literal("nativeBalanceGte"),
528
- chainId: ChainIdSchema,
529
- owner: AssertionOwnerSchema,
530
- 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)
531
421
  });
532
- var RawAssertedPredicateSchema = import_effect3.Schema.Union(
533
- AssertedErc20BalanceGteSpecSchema,
534
- AssertedNativeBalanceGteSpecSchema,
535
- CallCheckSpecSchema,
536
- Erc20BalanceDeltaGteSpecSchema,
537
- NativeBalanceDeltaGteSpecSchema
538
- );
539
- var AssertedPredicateSchema = import_effect3.Schema.transformOrFail(
540
- RawAssertedPredicateSchema,
541
- import_effect3.Schema.typeSchema(RawAssertedPredicateSchema),
542
- {
543
- strict: true,
544
- decode: (pred, _options, ast) => pred.kind === "nativeBalanceGte" ? decodeNativeBalanceGte(pred, ast) : import_effect3.ParseResult.succeed(pred),
545
- encode: (pred) => import_effect3.ParseResult.succeed(pred)
546
- }
547
- );
548
- var VerificationDescriptorSchema = import_effect3.Schema.Struct({
549
- validationProgramHash: Bytes32HexSchema,
550
- // The C5 echo's second hash (verified continuations, plan GD-8): `keccak256`
551
- // over the canonical params vector (`paramsHash`, GD-2 seam C1). Required and
552
- // jointly necessary with `validationProgramHash` — the program hash is
553
- // value-blind (it never binds the delivery address or amounts), so a descriptor
554
- // that enforces only it is a fund-redirect hole. Empty params still yield a
555
- // present `0x00…00`, so a real descriptor never omits it. Strict 32-byte
556
- // lowercase hex, same rule as `validationProgramHash`.
557
- paramsHash: Bytes32HexSchema,
558
- assertedPredicate: import_effect3.Schema.Array(AssertedPredicateSchema)
422
+ const VerificationDescriptorSchema = effect.Schema.Struct({
423
+ validationProgramHash: Bytes32HexSchema,
424
+ paramsHash: Bytes32HexSchema,
425
+ assertedPredicate: effect.Schema.Array(AssertedPredicateSchema)
559
426
  });
560
- var canonicalJson = (value) => {
561
- if (Array.isArray(value)) {
562
- return `[${value.map(canonicalJson).join(",")}]`;
563
- }
564
- if (value !== null && typeof value === "object") {
565
- const record = value;
566
- const entries = Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`);
567
- return `{${entries.join(",")}}`;
568
- }
569
- 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);
570
434
  };
571
- var canonicalAssertedPredicate = (specs) => canonicalJson(specs);
572
-
573
- // src/flow.ts
574
- var isResourceInput = (input) => "resource" in input;
575
- var flowInputType = (input) => isResourceInput(input) ? "uint256" : input.type;
576
- var flowInputMode = (input) => isResourceInput(input) ? "linear" : "copy";
577
- var flowInputResource = (input) => isResourceInput(input) ? input.resource : void 0;
578
- var isResourcePort = (port) => port.kind === "resource";
579
- var isHandlePort = (port) => port.kind === "handle";
580
- var isResourceOutputPort = (port) => port.kind === "resource_output";
581
- var isFutureResourceOutput = (port) => isResourceOutputPort(port) && port.availability === "future";
582
- var isMaterialiserInput = (s) => typeof s === "object" && s !== null && "kind" in s;
583
-
584
- // src/resource.ts
585
- var erc20Resource = (token, chainId) => ({
586
- kind: "erc20",
587
- token,
588
- 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
589
453
  });
590
- var nativeResource = (chainId) => ({
591
- kind: "native",
592
- chainId
454
+ const nativeResource = (chainId) => ({
455
+ kind: "native",
456
+ chainId
593
457
  });
594
- var isERC20Resource = (r) => r.kind === "erc20";
595
- var isNativeResource = (r) => r.kind === "native";
596
- var resourcesEqual = (a, b) => {
597
- if (isNativeResource(a) && isNativeResource(b)) {
598
- return a.chainId === b.chainId;
599
- }
600
- if (isERC20Resource(a) && isERC20Resource(b)) {
601
- return a.chainId === b.chainId && a.token.toLowerCase() === b.token.toLowerCase();
602
- }
603
- 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;
604
464
  };
605
- var foldResource = (r, cases) => r.kind === "native" ? cases.native(r.chainId) : cases.erc20(r.token, r.chainId);
606
- var resourceToken = (r) => foldResource(r, {
607
- native: () => EVM_NATIVE_SENTINEL,
608
- 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
609
469
  });
610
- var resourceKey = (r) => foldResource(r, {
611
- native: (chainId) => `native:${chainId}`,
612
- 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}`
613
473
  });
614
- var erc20Token = (r) => {
615
- if (r.kind !== "erc20")
616
- throw new Error(`Expected erc20 resource, got ${r.kind}`);
617
- 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;
618
477
  };
619
-
620
- // src/flashloan.ts
621
- var PROVIDER_KIND = {
622
- AAVE_V3: 0,
623
- ERC3156: 1,
624
- BALANCER_V2: 2,
625
- 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
626
485
  };
627
- var providerKindNames = [
628
- "aave-v3",
629
- "erc3156",
630
- "balancer-v2",
631
- "morpho-blue"
486
+ const providerKindNames = [
487
+ "aave-v3",
488
+ "erc3156",
489
+ "balancer-v2",
490
+ "morpho-blue"
632
491
  ];
633
- var providerKindByName = {
634
- "aave-v3": PROVIDER_KIND.AAVE_V3,
635
- erc3156: PROVIDER_KIND.ERC3156,
636
- "balancer-v2": PROVIDER_KIND.BALANCER_V2,
637
- "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
638
497
  };
639
-
640
- // src/constructors.ts
641
- var optionalProp = (key, value) => value !== void 0 && value !== null ? { [key]: value } : {};
642
- var linear = (name, type) => ({
643
- name,
644
- type,
645
- mode: "linear",
646
- 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"
647
507
  });
648
- var copy = (name, type) => ({
649
- name,
650
- type,
651
- mode: "copy",
652
- availability: "now"
508
+ const copy = (name, type) => ({
509
+ name,
510
+ type,
511
+ mode: "copy",
512
+ availability: "now"
653
513
  });
654
- var handle = (name, type) => ({ name, type });
655
- var native = (name, chainId) => ({
656
- name,
657
- resource: nativeResource(chainId)
514
+ const handle = (name, type) => ({
515
+ name,
516
+ type
658
517
  });
659
- var erc20 = (name, token, chainId) => ({
660
- name,
661
- resource: erc20Resource(token, chainId)
518
+ const native = (name, chainId) => ({
519
+ name,
520
+ resource: nativeResource(chainId)
662
521
  });
663
- var resource = (name, accepts, options) => ({
664
- kind: "resource",
665
- name,
666
- accepts,
667
- mode: "linear",
668
- ...optionalProp("optional", options?.optional)
522
+ const erc20 = (name, token, chainId) => ({
523
+ name,
524
+ resource: erc20Resource(token, chainId)
669
525
  });
670
- var readResource = (name, accepts) => ({
671
- kind: "resource",
672
- name,
673
- accepts,
674
- mode: "copy"
526
+ const resource = (name, accepts, options) => ({
527
+ kind: "resource",
528
+ name,
529
+ accepts,
530
+ mode: "linear",
531
+ ...optionalProp("optional", options?.optional)
675
532
  });
676
- var opHandle = (name, type, options) => ({
677
- kind: "handle",
678
- name,
679
- type,
680
- mode: "copy",
681
- ...optionalProp("expose", options?.expose),
682
- ...optionalProp("units", options?.units),
683
- ...optionalProp("optional", options?.optional)
533
+ const readResource = (name, accepts) => ({
534
+ kind: "resource",
535
+ name,
536
+ accepts,
537
+ mode: "copy"
684
538
  });
685
- var resourceOutput = (name, options) => {
686
- const raw = options;
687
- const opts = typeof raw === "string" ? { availability: raw } : raw;
688
- return {
689
- kind: "resource_output",
690
- name,
691
- mode: "linear",
692
- ...optionalProp("availability", opts?.availability),
693
- ...optionalProp("providesMinimum", opts?.providesMinimum),
694
- ...optionalProp("omitIfZero", opts?.omitIfZero),
695
- ...optionalProp("deliveryAddressInput", opts?.deliveryAddressInput),
696
- ...optionalProp("countFrom", opts?.countFrom)
697
- };
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)
547
+ });
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
+ };
698
561
  };
699
-
700
- // src/outputFamilies.ts
701
- var isOutputFamily = (port) => port.kind === "resource_output" && port.countFrom !== void 0;
702
- var instancePortName = (family, index) => `${family}.${index}`;
703
- var familySize = (family, config) => {
704
- const source = config[family.countFrom];
705
- if (Array.isArray(source)) return source.length;
706
- if (Number.isSafeInteger(source) && source >= 0) {
707
- return source;
708
- }
709
- throw new Error(
710
- `Output family '${family.name}' counts from config '${family.countFrom}', which is neither an array nor a non-negative integer`
711
- );
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`);
712
571
  };
713
- var expandFamily = (port, config) => {
714
- const { countFrom: _countFrom, ...instance } = port;
715
- return Array.from({ length: familySize(port, config) }, (_, index) => ({
716
- ...instance,
717
- name: instancePortName(port.name, index)
718
- }));
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
+ }));
719
578
  };
720
- var expandOutputPorts = (declared, config) => declared.some(isOutputFamily) ? declared.flatMap(
721
- (port) => isOutputFamily(port) ? expandFamily(port, config) : [port]
722
- ) : declared;
723
-
724
- // src/ref.ts
725
- var isContextKey = (key) => key === "sender" || key === "executionAddress";
726
- var RESERVED_REF_SCOPES = /* @__PURE__ */ new Set([
727
- "input",
728
- "context",
729
- "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"
730
593
  ]);
731
- var isRef = (v) => typeof v === "object" && v !== null && "$ref" in v && typeof v.$ref === "string";
732
- var parseRef = (ref2) => {
733
- const dot = ref2.$ref.indexOf(".");
734
- if (dot === -1)
735
- throw new Error(`Invalid ref: "${ref2.$ref}" (must contain a dot)`);
736
- const prefix = ref2.$ref.slice(0, dot);
737
- const suffix = ref2.$ref.slice(dot + 1);
738
- if (prefix === "input") return { scope: "input", port: suffix };
739
- if (prefix === "context") {
740
- if (!isContextKey(suffix))
741
- throw new Error(`Unknown context key: "${suffix}"`);
742
- return { scope: "context", key: suffix };
743
- }
744
- 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
+ };
745
616
  };
746
- var buildRef = (path) => {
747
- if (path.indexOf(".") < 1)
748
- throw new Error(
749
- `Invalid ref: "${path}" (must be a dotpath like "input.name" or "nodeId.port")`
750
- );
751
- const built = { $ref: path };
752
- parseRef(built);
753
- 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;
754
622
  };
755
- var ref = Object.assign(buildRef, {
756
- input: (port) => buildRef(`input.${port}`),
757
- context: {
758
- sender: buildRef("context.sender"),
759
- executionAddress: buildRef("context.executionAddress")
760
- }
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
+ }
761
629
  });
762
- var foldRef = (ref2, cases) => {
763
- if (ref2.scope === "input") return cases.input(ref2.port);
764
- if (ref2.scope === "context") return cases.context(ref2.key);
765
- 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);
766
634
  };
767
- var refKey = (ref2) => foldRef(parseRef(ref2), {
768
- input: (port) => `input:${port}`,
769
- context: (key) => `context:${key}`,
770
- 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}`
639
+ });
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
771
649
  });
772
-
773
- // src/preconditions.ts
774
- var erc20Balance = (config) => ({ type: "Erc20Balance", ...config });
775
- var nativeBalance = (config) => ({ type: "NativeBalance", ...config });
776
- var erc20Allowance = (config) => ({ type: "Erc20Allowance", ...config });
777
- var isErc20BalancePrecondition = (p) => p.type === "Erc20Balance";
778
- var isErc20AllowancePrecondition = (p) => p.type === "Erc20Allowance";
779
- var isNativeBalancePrecondition = (p) => p.type === "NativeBalance";
780
-
781
- // src/simulate.ts
782
- var SIMULATE_MAX_TRACKED_BALANCES = 40;
783
- var SIMULATE_MAX_REQUIREMENTS = 40;
784
-
785
- // src/headers.ts
786
- var COMPOSER_SDK_VERSION_HEADER = "x-lifi-composer-sdk";
787
- var COMPOSE_VERSION_HEADER = "x-lifi-composer-version";
788
-
789
- // src/version.ts
790
- 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-]+)*)?$/;
791
- var parseVersion = (version) => {
792
- const match = SEMANTIC_VERSION_PATTERN.exec(version);
793
- if (!match) return void 0;
794
- const major = Number(match[1]);
795
- const minor = Number(match[2]);
796
- const patch = Number(match[3]);
797
- if (![major, minor, patch].every(Number.isSafeInteger)) return void 0;
798
- return { major, minor, patch };
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
+ };
799
718
  };
800
- var compareVersions = (a, b) => a.major !== b.major ? a.major - b.major : a.minor !== b.minor ? a.minor - b.minor : a.patch - b.patch;
801
- var checkCompatibility = (client, server, minimum = {
802
- major: server.major,
803
- minor: server.minor,
804
- 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
805
744
  }) => {
806
- if (compareVersions(client, server) > 0) return "server_outdated";
807
- if (compareVersions(client, minimum) < 0) return "sdk_outdated";
808
- return "compatible";
745
+ if (compareVersions(client, server) > 0) return "server_outdated";
746
+ if (compareVersions(client, minimum) < 0) return "sdk_outdated";
747
+ return "compatible";
809
748
  };
810
-
811
- // src/materialiserMetadata.ts
812
- var foldMaterialiserMetadata = (meta, cases) => {
813
- if (meta.kind === "exact") return cases.exact(meta.amount);
814
- if (meta.kind === "exact-native") return cases.exactNative(meta.amount);
815
- if (meta.kind === "capped") return cases.capped(meta.amount);
816
- 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();
817
756
  };
818
-
819
- // src/zodSchemas.ts
820
- var import_zod = __toESM(require("zod"), 1);
821
- var chainIdZod = import_zod.default.number().int().positive();
822
- var evmAddressZod = import_zod.default.string().regex(EVM_ADDRESS_HEX);
823
- var hexBytesZod = import_zod.default.string().regex(HEX_BYTES);
824
- var uintStringZod = import_zod.default.string().refine((value) => DECIMAL_UINT.test(value) && BigInt(value) <= MAX_UINT256, {
825
- message: "expected a uint256 decimal integer string"
826
- });
827
- var SolTypeZod = import_zod.default.enum([
828
- "uint8",
829
- "uint16",
830
- "uint32",
831
- "uint64",
832
- "uint128",
833
- "uint256",
834
- "int128",
835
- "int256",
836
- "address",
837
- "bool",
838
- "bytes",
839
- "bytes4",
840
- "bytes32",
841
- "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"
842
778
  ]);
843
- var ResourcePortZod = import_zod.default.object({
844
- kind: import_zod.default.literal("resource"),
845
- name: import_zod.default.string(),
846
- accepts: import_zod.default.enum(["erc20", "native", "any"]),
847
- mode: import_zod.default.enum(["linear", "copy"]),
848
- 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()
849
789
  });
850
- var HANDLE_UNITS = [
851
- "raw",
852
- "wad",
853
- "ray",
854
- "bps",
855
- "token-decimals"
790
+ const HANDLE_UNITS = [
791
+ "raw",
792
+ "wad",
793
+ "ray",
794
+ "bps",
795
+ "token-decimals"
856
796
  ];
857
- var STATIC_SOL_TYPES = [
858
- "uint256",
859
- "uint128",
860
- "uint64",
861
- "uint32",
862
- "uint16",
863
- "uint8",
864
- "address",
865
- "bool",
866
- "bytes32"
797
+ const STATIC_SOL_TYPES = [
798
+ "uint256",
799
+ "uint128",
800
+ "uint64",
801
+ "uint32",
802
+ "uint16",
803
+ "uint8",
804
+ "address",
805
+ "bool",
806
+ "bytes32"
867
807
  ];
868
- var HandleUnitsZod = import_zod.default.enum(HANDLE_UNITS);
869
- var StaticSolTypeZod = import_zod.default.enum(STATIC_SOL_TYPES);
870
- var STATIC_SOL_TYPE_SET = new Set(STATIC_SOL_TYPES);
871
- var isStaticSolType = (value) => STATIC_SOL_TYPE_SET.has(value);
872
- var HandlePortZod = import_zod.default.object({
873
- kind: import_zod.default.literal("handle"),
874
- name: import_zod.default.string(),
875
- type: SolTypeZod,
876
- mode: import_zod.default.enum(["linear", "copy"]),
877
- expose: import_zod.default.boolean().optional(),
878
- units: HandleUnitsZod.optional(),
879
- optional: import_zod.default.boolean().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()
880
820
  });
881
- var InputPortZod = import_zod.default.discriminatedUnion("kind", [
882
- ResourcePortZod,
883
- HandlePortZod
884
- ]);
885
- var ResourceOutputPortZod = import_zod.default.object({
886
- kind: import_zod.default.literal("resource_output"),
887
- name: import_zod.default.string(),
888
- mode: import_zod.default.enum(["linear", "copy"]),
889
- availability: import_zod.default.enum(["now", "future"]).optional(),
890
- providesMinimum: import_zod.default.boolean().optional(),
891
- omitIfZero: import_zod.default.boolean().optional(),
892
- deliveryAddressInput: import_zod.default.string().optional(),
893
- // Declares an output *family*: the port expands, when a call's config is
894
- // bound, into one instance per element of the config array named here, or
895
- // into as many instances as the non-negative integer named here. Instances
896
- // are ordinary ports named `<name>.<index>`; see
897
- // `outputFamilies.ts:expandOutputPorts`.
898
- countFrom: import_zod.default.string().optional()
899
- });
900
- var OutputPortZod = import_zod.default.discriminatedUnion("kind", [
901
- ResourceOutputPortZod,
902
- HandlePortZod
903
- ]);
904
- var ManifestOperationZod = import_zod.default.object({
905
- id: import_zod.default.string(),
906
- description: import_zod.default.string().optional(),
907
- inputs: import_zod.default.array(InputPortZod),
908
- outputs: import_zod.default.array(OutputPortZod),
909
- configSchema: import_zod.default.unknown().optional()
910
- });
911
- var PortKindEnum = import_zod.default.enum(["resource", "resource_output", "handle"]);
912
- var SelectorMatchZod = import_zod.default.object({
913
- kind: import_zod.default.union([PortKindEnum, import_zod.default.array(PortKindEnum)]),
914
- mode: import_zod.default.enum(["linear", "copy"]).optional(),
915
- type: import_zod.default.enum(["erc20", "native", "any"]).optional()
916
- });
917
- var ConfigSelectionZod = import_zod.default.object({
918
- kind: import_zod.default.literal("config"),
919
- configKey: import_zod.default.string(),
920
- cardinality: import_zod.default.enum(["one", "many"])
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()
921
831
  });
922
- var AllMatchingSelectionZod = import_zod.default.object({
923
- kind: import_zod.default.literal("all_matching")
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()
924
839
  });
925
- var SelectorSelectionZod = import_zod.default.discriminatedUnion("kind", [
926
- ConfigSelectionZod,
927
- AllMatchingSelectionZod
840
+ const PortKindEnum = zod.default.enum([
841
+ "resource",
842
+ "resource_output",
843
+ "handle"
928
844
  ]);
929
- var GuardSelectorZod = import_zod.default.object({
930
- binding: import_zod.default.string(),
931
- source: import_zod.default.enum(["inputs", "outputs"]),
932
- match: SelectorMatchZod,
933
- 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()
934
853
  });
935
- var GuardCompatibilityZod = import_zod.default.object({
936
- 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"])
937
858
  });
938
- var ManifestGuardZod = import_zod.default.object({
939
- kind: import_zod.default.string(),
940
- description: import_zod.default.string().optional(),
941
- configSchema: import_zod.default.unknown().optional(),
942
- 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
943
866
  });
944
- var ManifestMaterialiserZod = import_zod.default.object({
945
- kind: import_zod.default.string(),
946
- description: import_zod.default.string().optional(),
947
- accepts: import_zod.default.enum(["resource", "handle", "any"]),
948
- 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()
949
873
  });
950
- var ManifestPreconditionZod = import_zod.default.object({
951
- type: import_zod.default.string(),
952
- description: import_zod.default.string().optional(),
953
- 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()
954
883
  });
955
- var ComposeManifestZod = import_zod.default.object({
956
- manifestVersion: import_zod.default.number(),
957
- manifestHash: import_zod.default.string(),
958
- flowSchema: import_zod.default.object({}).passthrough(),
959
- operations: import_zod.default.array(ManifestOperationZod),
960
- guards: import_zod.default.array(ManifestGuardZod),
961
- materialisers: import_zod.default.array(ManifestMaterialiserZod),
962
- 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()
963
888
  });
964
- var hexStringZod = import_zod.default.string().startsWith("0x");
965
- var SettlementEscrowZod = import_zod.default.object({
966
- chainId: chainIdZod,
967
- address: hexStringZod,
968
- token: hexStringZod,
969
- amount: import_zod.default.string(),
970
- cap: import_zod.default.string(),
971
- owner: hexStringZod,
972
- refund: hexStringZod,
973
- 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()
974
897
  });
975
- var assertionOwnerZod = import_zod.default.union([
976
- evmAddressZod,
977
- import_zod.default.enum(["escrow", "delivery"])
978
- ]);
979
- var AssertionSpecZod = import_zod.default.discriminatedUnion("kind", [
980
- import_zod.default.object({
981
- kind: import_zod.default.literal("erc20BalanceGte"),
982
- chainId: chainIdZod,
983
- token: evmAddressZod,
984
- owner: evmAddressZod,
985
- minAmount: uintStringZod
986
- }),
987
- import_zod.default.object({
988
- kind: import_zod.default.literal("nativeBalanceGte"),
989
- chainId: chainIdZod,
990
- owner: evmAddressZod,
991
- minAmount: uintStringZod
992
- }),
993
- import_zod.default.object({
994
- kind: import_zod.default.literal("call"),
995
- chainId: chainIdZod,
996
- to: evmAddressZod,
997
- calldata: hexBytesZod,
998
- comparator: import_zod.default.enum(["gte", "eq", "lte"]),
999
- value: uintStringZod
1000
- }),
1001
- import_zod.default.object({
1002
- kind: import_zod.default.literal("erc20BalanceDeltaGte"),
1003
- chainId: import_zod.default.number().int().positive(),
1004
- token: evmAddressZod,
1005
- owner: assertionOwnerZod,
1006
- minDelta: uintStringZod
1007
- }),
1008
- import_zod.default.object({
1009
- kind: import_zod.default.literal("nativeBalanceDeltaGte"),
1010
- chainId: import_zod.default.number().int().positive(),
1011
- owner: assertionOwnerZod,
1012
- minDelta: uintStringZod
1013
- })
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
+ })
1014
949
  ]);
1015
- var assertionSpecOptionByKind = (kind) => {
1016
- const option = AssertionSpecZod.options.find(
1017
- (o) => o.shape.kind.value === kind
1018
- );
1019
- if (option === void 0) {
1020
- throw new Error(`AssertionSpecZod has no member with kind "${kind}"`);
1021
- }
1022
- 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;
1023
954
  };
1024
- var AssertedPredicateZod = import_zod.default.discriminatedUnion("kind", [
1025
- import_zod.default.object({
1026
- kind: import_zod.default.literal("erc20BalanceGte"),
1027
- chainId: import_zod.default.number().int().positive(),
1028
- token: evmAddressZod,
1029
- owner: assertionOwnerZod,
1030
- minAmount: uintStringZod
1031
- }),
1032
- import_zod.default.object({
1033
- kind: import_zod.default.literal("nativeBalanceGte"),
1034
- chainId: import_zod.default.number().int().positive(),
1035
- owner: assertionOwnerZod,
1036
- minAmount: uintStringZod
1037
- }),
1038
- assertionSpecOptionByKind("call"),
1039
- assertionSpecOptionByKind("erc20BalanceDeltaGte"),
1040
- 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")
1041
972
  ]);
1042
- var VerificationDescriptorZod = import_zod.default.object({
1043
- validationProgramHash: import_zod.default.string().regex(BYTES32_LOWER_HEX),
1044
- // The C5 echo's second hash (GD-8): the params-vector content hash
1045
- // (`paramsHash`, C1). Required and jointly necessary with the value-blind
1046
- // `validationProgramHash`.
1047
- paramsHash: import_zod.default.string().regex(BYTES32_LOWER_HEX),
1048
- assertedPredicate: import_zod.default.array(AssertedPredicateZod)
1049
- });
1050
- var SettlementZod = import_zod.default.object({
1051
- escrow: SettlementEscrowZod.optional()
1052
- });
1053
- // Annotate the CommonJS export names for ESM import in node:
1054
- 0 && (module.exports = {
1055
- ARC_CHAIN_ID,
1056
- ARC_NATIVE_ERC20,
1057
- ARC_NATIVE_SCALE,
1058
- AppliedGuardSchema,
1059
- AssertedErc20BalanceGteSpecSchema,
1060
- AssertedNativeBalanceGteSpecSchema,
1061
- AssertedPredicateSchema,
1062
- AssertedPredicateZod,
1063
- AssertionOwnerSchema,
1064
- AssertionSpecSchema,
1065
- AssertionSpecZod,
1066
- BindValueSchema,
1067
- Bytes32HexSchema,
1068
- COMPOSER_SDK_VERSION_HEADER,
1069
- COMPOSE_VERSION_HEADER,
1070
- CONTINUATION_COMMITMENT_OP_ID,
1071
- CallCheckSpecSchema,
1072
- CallSchema,
1073
- ComposeManifestZod,
1074
- ContinuationIntentSchema,
1075
- ContinuationOutcomeSchema,
1076
- EVMAddressString,
1077
- EVM_NATIVE_SENTINEL,
1078
- Erc20BalanceDeltaGteSpecSchema,
1079
- Erc20BalanceGteSpecSchema,
1080
- FlowInputSchema,
1081
- FlowSchema,
1082
- GuardCompatibilityZod,
1083
- GuardSelectorZod,
1084
- HANDLE_UNITS,
1085
- HandleInputSchema,
1086
- HandlePortZod,
1087
- HandleUnitsZod,
1088
- HexStringSchema,
1089
- InputPortZod,
1090
- IntegerString,
1091
- LineageSchema,
1092
- LiteralBindingSchema,
1093
- ManifestGuardZod,
1094
- ManifestMaterialiserZod,
1095
- ManifestOperationZod,
1096
- ManifestPreconditionZod,
1097
- NativeBalanceDeltaGteSpecSchema,
1098
- NativeBalanceGteSpecSchema,
1099
- OutputPortZod,
1100
- PROVIDER_KIND,
1101
- Phase1ArtifactSchema,
1102
- RESERVED_REF_SCOPES,
1103
- RefSchema,
1104
- ResourceInputSchema,
1105
- ResourceOutputPortZod,
1106
- ResourcePortZod,
1107
- ResourceSchema,
1108
- SIMULATE_MAX_REQUIREMENTS,
1109
- SIMULATE_MAX_TRACKED_BALANCES,
1110
- STATIC_SOL_TYPES,
1111
- SettlementZod,
1112
- SolTypeSchema,
1113
- StaticSolTypeZod,
1114
- TEMPO_CHAIN_ID,
1115
- TEMPO_NATIVE_ERC20,
1116
- UuidSchema,
1117
- VerificationDescriptorSchema,
1118
- VerificationDescriptorZod,
1119
- canonicalAssertedPredicate,
1120
- canonicalNativeAddress,
1121
- checkCompatibility,
1122
- copy,
1123
- erc20,
1124
- erc20Allowance,
1125
- erc20Balance,
1126
- erc20Resource,
1127
- erc20Token,
1128
- expandOutputPorts,
1129
- familySize,
1130
- flowInputMode,
1131
- flowInputResource,
1132
- flowInputType,
1133
- foldChainCapabilities,
1134
- foldMaterialiserMetadata,
1135
- foldRef,
1136
- foldResource,
1137
- getChainCapabilities,
1138
- handle,
1139
- hasErc20CanonicalNative,
1140
- instancePortName,
1141
- isAsErc20Chain,
1142
- isContextKey,
1143
- isERC20Resource,
1144
- isErc20AllowancePrecondition,
1145
- isErc20BalancePrecondition,
1146
- isFutureResourceOutput,
1147
- isHandlePort,
1148
- isMaterialiserInput,
1149
- isMsgValueNative,
1150
- isNativeAddressForChain,
1151
- isNativeBalancePrecondition,
1152
- isNativeResource,
1153
- isOutputFamily,
1154
- isRef,
1155
- isResourceInput,
1156
- isResourceOutputPort,
1157
- isResourcePort,
1158
- isStaticSolType,
1159
- linear,
1160
- native,
1161
- nativeBalance,
1162
- nativeCheckPolicy,
1163
- nativeResource,
1164
- normalizeNativeTokenAddress,
1165
- normalizeResource,
1166
- opHandle,
1167
- parseRef,
1168
- parseVersion,
1169
- providerKindByName,
1170
- providerKindNames,
1171
- readResource,
1172
- ref,
1173
- refKey,
1174
- resource,
1175
- resourceKey,
1176
- resourceOutput,
1177
- resourceToken,
1178
- resourcesEqual,
1179
- 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)
1180
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;