@lifi/compose-spec 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -30,6 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
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,
33
36
  AppliedGuardSchema: () => AppliedGuardSchema,
34
37
  AssertedErc20BalanceGteSpecSchema: () => AssertedErc20BalanceGteSpecSchema,
35
38
  AssertedNativeBalanceGteSpecSchema: () => AssertedNativeBalanceGteSpecSchema,
@@ -103,16 +106,19 @@ __export(index_exports, {
103
106
  flowInputMode: () => flowInputMode,
104
107
  flowInputResource: () => flowInputResource,
105
108
  flowInputType: () => flowInputType,
109
+ foldChainCapabilities: () => foldChainCapabilities,
106
110
  foldMaterialiserMetadata: () => foldMaterialiserMetadata,
107
111
  foldRef: () => foldRef,
108
112
  foldResource: () => foldResource,
109
113
  getChainCapabilities: () => getChainCapabilities,
110
114
  handle: () => handle,
115
+ hasErc20CanonicalNative: () => hasErc20CanonicalNative,
111
116
  isAsErc20Chain: () => isAsErc20Chain,
112
117
  isContextKey: () => isContextKey,
113
118
  isEQCheck: () => isEQCheck,
114
119
  isERC20Resource: () => isERC20Resource,
115
120
  isErc20AllowancePrecondition: () => isErc20AllowancePrecondition,
121
+ isErc20BalancePrecondition: () => isErc20BalancePrecondition,
116
122
  isFutureResourceOutput: () => isFutureResourceOutput,
117
123
  isGTECheck: () => isGTECheck,
118
124
  isHandlePort: () => isHandlePort,
@@ -130,6 +136,7 @@ __export(index_exports, {
130
136
  linear: () => linear,
131
137
  native: () => native,
132
138
  nativeBalance: () => nativeBalance,
139
+ nativeCheckPolicy: () => nativeCheckPolicy,
133
140
  nativeResource: () => nativeResource,
134
141
  normalizeNativeTokenAddress: () => normalizeNativeTokenAddress,
135
142
  normalizeResource: () => normalizeResource,
@@ -165,6 +172,13 @@ var TEMPO_NATIVE_ERC20 = {
165
172
  symbol: "pathUSD",
166
173
  decimals: 6
167
174
  };
175
+ var ARC_CHAIN_ID = 5042;
176
+ var ARC_NATIVE_ERC20 = {
177
+ token: "0x3600000000000000000000000000000000000000",
178
+ symbol: "USDC",
179
+ decimals: 6
180
+ };
181
+ var ARC_NATIVE_SCALE = 10n ** BigInt(18 - ARC_NATIVE_ERC20.decimals);
168
182
  var REGISTRY = /* @__PURE__ */ new Map([
169
183
  [
170
184
  TEMPO_CHAIN_ID,
@@ -173,31 +187,60 @@ var REGISTRY = /* @__PURE__ */ new Map([
173
187
  chainId: TEMPO_CHAIN_ID,
174
188
  nativeErc20: TEMPO_NATIVE_ERC20
175
189
  }
190
+ ],
191
+ [
192
+ ARC_CHAIN_ID,
193
+ {
194
+ kind: "native-mirrored-erc20",
195
+ chainId: ARC_CHAIN_ID,
196
+ nativeErc20: ARC_NATIVE_ERC20,
197
+ nativeScale: ARC_NATIVE_SCALE
198
+ }
176
199
  ]
177
200
  ]);
178
201
  var getChainCapabilities = (chainId) => REGISTRY.get(chainId) ?? { kind: "evm-native", chainId };
179
- var isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
180
- var canonicalNativeAddress = (chainId) => {
181
- const caps = getChainCapabilities(chainId);
182
- return caps.kind === "as-erc20" ? caps.nativeErc20.token : EVM_NATIVE_SENTINEL;
202
+ var foldChainCapabilities = (caps, cases) => {
203
+ switch (caps.kind) {
204
+ case "evm-native":
205
+ return cases.evmNative(caps.chainId);
206
+ case "as-erc20":
207
+ return cases.asErc20(caps.nativeErc20, caps.chainId);
208
+ case "native-mirrored-erc20":
209
+ return cases.nativeMirroredErc20(
210
+ caps.nativeErc20,
211
+ caps.nativeScale,
212
+ caps.chainId
213
+ );
214
+ }
183
215
  };
216
+ var nativeCheckPolicy = (chainId) => foldChainCapabilities(getChainCapabilities(chainId), {
217
+ evmNative: () => ({ kind: "keep" }),
218
+ asErc20: (nativeErc20) => ({ kind: "rewrite", token: nativeErc20.token }),
219
+ nativeMirroredErc20: (nativeErc20) => ({
220
+ kind: "reject",
221
+ 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}`
222
+ })
223
+ });
224
+ var isAsErc20Chain = (chainId) => getChainCapabilities(chainId).kind === "as-erc20";
225
+ var erc20CanonicalNative = (caps) => caps.kind === "as-erc20" || caps.kind === "native-mirrored-erc20" ? caps.nativeErc20 : void 0;
226
+ var hasErc20CanonicalNative = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId)) !== void 0;
227
+ var canonicalNativeAddress = (chainId) => erc20CanonicalNative(getChainCapabilities(chainId))?.token ?? EVM_NATIVE_SENTINEL;
184
228
  var isNativeAddressForChain = (chainId, address) => {
185
- const caps = getChainCapabilities(chainId);
186
- const target = caps.kind === "as-erc20" ? caps.nativeErc20.token : EVM_NATIVE_SENTINEL;
229
+ const target = canonicalNativeAddress(chainId);
187
230
  return address.toLowerCase() === target.toLowerCase();
188
231
  };
189
- var isMsgValueNative = (chainId, address) => !isAsErc20Chain(chainId) && isNativeSentinel(address);
232
+ var isMsgValueNative = (chainId, address) => !hasErc20CanonicalNative(chainId) && isNativeSentinel(address);
190
233
  var normalizeResource = (r) => {
191
234
  if (r.kind !== "native") return r;
192
- const caps = getChainCapabilities(r.chainId);
193
- if (caps.kind !== "as-erc20") return r;
235
+ const erc202 = erc20CanonicalNative(getChainCapabilities(r.chainId));
236
+ if (erc202 === void 0) return r;
194
237
  return {
195
238
  kind: "erc20",
196
239
  chainId: r.chainId,
197
- token: caps.nativeErc20.token
240
+ token: erc202.token
198
241
  };
199
242
  };
200
- var normalizeNativeTokenAddress = (token, chainId) => isAsErc20Chain(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
243
+ var normalizeNativeTokenAddress = (token, chainId) => hasErc20CanonicalNative(chainId) && isNativeSentinel(token) ? canonicalNativeAddress(chainId) : token;
201
244
 
202
245
  // src/flowSchema.ts
203
246
  var SolTypeSchema = import_effect.Schema.Literal(
@@ -363,25 +406,36 @@ var CallCheckSpecSchema = import_effect2.Schema.Struct({
363
406
  comparator: import_effect2.Schema.Literal("gte", "eq", "lte"),
364
407
  value: import_effect2.Schema.String
365
408
  });
366
- var asErc20BalanceGteCheck = (chainId, owner, minAmount) => ({
409
+ var asErc20BalanceGteCheck = (check, token) => ({
367
410
  kind: "erc20BalanceGte",
368
- chainId,
369
- token: canonicalNativeAddress(chainId),
370
- owner,
371
- minAmount
411
+ chainId: check.chainId,
412
+ token,
413
+ owner: check.owner,
414
+ minAmount: check.minAmount
372
415
  });
416
+ var decodeNativeBalanceGte = (check, ast) => {
417
+ const policy = nativeCheckPolicy(check.chainId);
418
+ switch (policy.kind) {
419
+ case "keep":
420
+ return import_effect2.ParseResult.succeed(check);
421
+ case "rewrite":
422
+ return import_effect2.ParseResult.succeed(asErc20BalanceGteCheck(check, policy.token));
423
+ case "reject":
424
+ return import_effect2.ParseResult.fail(new import_effect2.ParseResult.Type(ast, check, policy.reason));
425
+ }
426
+ };
373
427
  var RawCheckSchema = import_effect2.Schema.Union(
374
428
  Erc20BalanceGteSpecSchema,
375
429
  NativeBalanceGteSpecSchema,
376
430
  CallCheckSpecSchema
377
431
  );
378
- var CheckSchema = import_effect2.Schema.transform(
432
+ var CheckSchema = import_effect2.Schema.transformOrFail(
379
433
  RawCheckSchema,
380
434
  import_effect2.Schema.typeSchema(RawCheckSchema),
381
435
  {
382
436
  strict: true,
383
- decode: (check) => check.kind === "nativeBalanceGte" && isAsErc20Chain(check.chainId) ? asErc20BalanceGteCheck(check.chainId, check.owner, check.minAmount) : check,
384
- encode: (check) => check
437
+ decode: (check, _options, ast) => check.kind === "nativeBalanceGte" ? decodeNativeBalanceGte(check, ast) : import_effect2.ParseResult.succeed(check),
438
+ encode: (check) => import_effect2.ParseResult.succeed(check)
385
439
  }
386
440
  );
387
441
  var Erc20BalanceDeltaGteSpecSchema = import_effect2.Schema.Struct({
@@ -446,13 +500,13 @@ var RawAssertedPredicateSchema = import_effect3.Schema.Union(
446
500
  Erc20BalanceDeltaGteSpecSchema,
447
501
  NativeBalanceDeltaGteSpecSchema
448
502
  );
449
- var AssertedPredicateSchema = import_effect3.Schema.transform(
503
+ var AssertedPredicateSchema = import_effect3.Schema.transformOrFail(
450
504
  RawAssertedPredicateSchema,
451
505
  import_effect3.Schema.typeSchema(RawAssertedPredicateSchema),
452
506
  {
453
507
  strict: true,
454
- decode: (pred) => pred.kind === "nativeBalanceGte" && isAsErc20Chain(pred.chainId) ? asErc20BalanceGteCheck(pred.chainId, pred.owner, pred.minAmount) : pred,
455
- encode: (pred) => pred
508
+ decode: (pred, _options, ast) => pred.kind === "nativeBalanceGte" ? decodeNativeBalanceGte(pred, ast) : import_effect3.ParseResult.succeed(pred),
509
+ encode: (pred) => import_effect3.ParseResult.succeed(pred)
456
510
  }
457
511
  );
458
512
  var VerificationDescriptorSchema = import_effect3.Schema.Struct({
@@ -659,6 +713,7 @@ var refKey = (ref2) => foldRef(parseRef(ref2), {
659
713
  var erc20Balance = (config) => ({ type: "Erc20Balance", ...config });
660
714
  var nativeBalance = (config) => ({ type: "NativeBalance", ...config });
661
715
  var erc20Allowance = (config) => ({ type: "Erc20Allowance", ...config });
716
+ var isErc20BalancePrecondition = (p) => p.type === "Erc20Balance";
662
717
  var isErc20AllowancePrecondition = (p) => p.type === "Erc20Allowance";
663
718
  var isNativeBalancePrecondition = (p) => p.type === "NativeBalance";
664
719
 
@@ -934,6 +989,9 @@ var ContinuationPlanZod = import_zod.default.object({
934
989
  });
935
990
  // Annotate the CommonJS export names for ESM import in node:
936
991
  0 && (module.exports = {
992
+ ARC_CHAIN_ID,
993
+ ARC_NATIVE_ERC20,
994
+ ARC_NATIVE_SCALE,
937
995
  AppliedGuardSchema,
938
996
  AssertedErc20BalanceGteSpecSchema,
939
997
  AssertedNativeBalanceGteSpecSchema,
@@ -1007,16 +1065,19 @@ var ContinuationPlanZod = import_zod.default.object({
1007
1065
  flowInputMode,
1008
1066
  flowInputResource,
1009
1067
  flowInputType,
1068
+ foldChainCapabilities,
1010
1069
  foldMaterialiserMetadata,
1011
1070
  foldRef,
1012
1071
  foldResource,
1013
1072
  getChainCapabilities,
1014
1073
  handle,
1074
+ hasErc20CanonicalNative,
1015
1075
  isAsErc20Chain,
1016
1076
  isContextKey,
1017
1077
  isEQCheck,
1018
1078
  isERC20Resource,
1019
1079
  isErc20AllowancePrecondition,
1080
+ isErc20BalancePrecondition,
1020
1081
  isFutureResourceOutput,
1021
1082
  isGTECheck,
1022
1083
  isHandlePort,
@@ -1034,6 +1095,7 @@ var ContinuationPlanZod = import_zod.default.object({
1034
1095
  linear,
1035
1096
  native,
1036
1097
  nativeBalance,
1098
+ nativeCheckPolicy,
1037
1099
  nativeResource,
1038
1100
  normalizeNativeTokenAddress,
1039
1101
  normalizeResource,
package/dist/index.d.cts CHANGED
@@ -337,7 +337,7 @@ declare const CallCheckSpecSchema: Schema.Struct<{
337
337
  comparator: Schema.Literal<["gte", "eq", "lte"]>;
338
338
  value: typeof Schema.String;
339
339
  }>;
340
- declare const CheckSchema: Schema.transform<Schema.Union<[Schema.Struct<{
340
+ declare const CheckSchema: Schema.transformOrFail<Schema.Union<[Schema.Struct<{
341
341
  kind: Schema.Literal<["erc20BalanceGte"]>;
342
342
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
343
343
  token: Schema.filter<typeof Schema.String>;
@@ -391,7 +391,7 @@ declare const CheckSchema: Schema.transform<Schema.Union<[Schema.Struct<{
391
391
  readonly to: string;
392
392
  readonly calldata: string;
393
393
  readonly comparator: "gte" | "eq" | "lte";
394
- }, never>>;
394
+ }, never>, never>;
395
395
  declare const Erc20BalanceDeltaGteSpecSchema: Schema.Struct<{
396
396
  kind: Schema.Literal<["erc20BalanceDeltaGte"]>;
397
397
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
@@ -491,7 +491,7 @@ declare const ContinuationPlanSchema: Schema.Struct<{
491
491
  }]>>>;
492
492
  }>>;
493
493
  }>;
494
- check: Schema.transform<Schema.Union<[Schema.Struct<{
494
+ check: Schema.transformOrFail<Schema.Union<[Schema.Struct<{
495
495
  kind: Schema.Literal<["erc20BalanceGte"]>;
496
496
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
497
497
  token: Schema.filter<typeof Schema.String>;
@@ -545,7 +545,7 @@ declare const ContinuationPlanSchema: Schema.Struct<{
545
545
  readonly to: string;
546
546
  readonly calldata: string;
547
547
  readonly comparator: "gte" | "eq" | "lte";
548
- }, never>>;
548
+ }, never>, never>;
549
549
  validity: Schema.Struct<{
550
550
  expiresAtMs: typeof Schema.Number;
551
551
  }>;
@@ -577,7 +577,7 @@ declare const AssertedNativeBalanceGteSpecSchema: Schema.Struct<{
577
577
  owner: Schema.Union<[Schema.filter<typeof Schema.String>, Schema.Literal<["escrow", "delivery"]>]>;
578
578
  minAmount: typeof Schema.String;
579
579
  }>;
580
- declare const AssertedPredicateSchema: Schema.transform<Schema.Union<[Schema.Struct<{
580
+ declare const AssertedPredicateSchema: Schema.transformOrFail<Schema.Union<[Schema.Struct<{
581
581
  kind: Schema.Literal<["erc20BalanceGte"]>;
582
582
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
583
583
  token: Schema.filter<typeof Schema.String>;
@@ -664,11 +664,11 @@ declare const AssertedPredicateSchema: Schema.transform<Schema.Union<[Schema.Str
664
664
  readonly chainId: number;
665
665
  readonly minAmount: string;
666
666
  readonly owner: string;
667
- }, never>>;
667
+ }, never>, never>;
668
668
  declare const VerificationDescriptorSchema: Schema.Struct<{
669
669
  validationProgramHash: Schema.filter<typeof Schema.String>;
670
670
  paramsHash: Schema.filter<typeof Schema.String>;
671
- assertedPredicate: Schema.Array$<Schema.transform<Schema.Union<[Schema.Struct<{
671
+ assertedPredicate: Schema.Array$<Schema.transformOrFail<Schema.Union<[Schema.Struct<{
672
672
  kind: Schema.Literal<["erc20BalanceGte"]>;
673
673
  chainId: Schema.filter<Schema.filter<typeof Schema.Number>>;
674
674
  token: Schema.filter<typeof Schema.String>;
@@ -755,7 +755,7 @@ declare const VerificationDescriptorSchema: Schema.Struct<{
755
755
  readonly chainId: number;
756
756
  readonly minAmount: string;
757
757
  readonly owner: string;
758
- }, never>>>;
758
+ }, never>, never>>;
759
759
  }>;
760
760
  declare const canonicalAssertedPredicate: (specs: readonly AssertionSpec[]) => string;
761
761
  type VerificationDescriptor = typeof VerificationDescriptorSchema.Type;
@@ -2111,15 +2111,26 @@ declare const refKey: (ref: Ref) => string;
2111
2111
  * Per-chain native-asset semantics.
2112
2112
  *
2113
2113
  * Most EVM chains have an ETH-style native gas coin sent via `msg.value` (the
2114
- * `evm-native` policy). A small number — currently only Tempo — express their
2115
- * "native" coin as an ERC-20 token (the `as-erc20` policy). Code that needs to
2116
- * lower or simulate a `Resource` of kind `"native"` should consult
2117
- * `getChainCapabilities(chainId)` rather than hardcoding chain IDs.
2114
+ * `evm-native` policy). A small number express their "native" coin as an
2115
+ * ERC-20 token: on `as-erc20` chains (Tempo) no `msg.value` coin exists at
2116
+ * all, while on `native-mirrored-erc20` chains (Arc) a real `msg.value` coin
2117
+ * exists but is canonically routed through an ERC-20 facade that mirrors the
2118
+ * native balance (`balanceOf == native wei / nativeScale`, with no balance
2119
+ * storage of its own). Code that needs to lower or simulate a `Resource` of
2120
+ * kind `"native"` should consult `getChainCapabilities(chainId)` rather than
2121
+ * hardcoding chain IDs.
2118
2122
  *
2119
2123
  * The compose compiler uses this registry to transparently normalise native
2120
- * resources into ERC-20 resources on `as-erc20` chains at schema-decode time
2121
- * (see `normalizeResource` below and the `ResourceSchema` transform in
2122
- * `flowSchema.ts`).
2124
+ * resources into ERC-20 resources on both ERC-20-canonical kinds at
2125
+ * schema-decode time (see `normalizeResource` below and the `ResourceSchema`
2126
+ * transform in `flowSchema.ts`).
2127
+ *
2128
+ * The two ERC-20-canonical kinds behave identically at the resource level —
2129
+ * `hasErc20CanonicalNative` is the predicate for that shared behaviour. They
2130
+ * diverge only at the simulation layer: `as-erc20` balances live in ordinary
2131
+ * token storage, while `native-mirrored-erc20` balances have no storage slot
2132
+ * and are satisfied by a native balance override scaled by `nativeScale`
2133
+ * (see compose-core's `rewritePreconditions`).
2123
2134
  *
2124
2135
  * This union is the extension point for future native-asset policies. A chain
2125
2136
  * with no canonical native asset would get a `reject-native` arm, under which a
@@ -2133,6 +2144,12 @@ type ChainCapabilities = {
2133
2144
  readonly kind: 'as-erc20';
2134
2145
  readonly chainId: number;
2135
2146
  readonly nativeErc20: NativeErc20;
2147
+ } | {
2148
+ readonly kind: 'native-mirrored-erc20';
2149
+ readonly chainId: number;
2150
+ readonly nativeErc20: NativeErc20;
2151
+ /** Native wei per 1 unit of the facade ERC-20 (1e12 on Arc: 18-dec native, 6-dec USDC). */
2152
+ readonly nativeScale: bigint;
2136
2153
  };
2137
2154
  interface NativeErc20 {
2138
2155
  readonly token: `0x${string}`;
@@ -2151,21 +2168,93 @@ interface NativeErc20 {
2151
2168
  declare const EVM_NATIVE_SENTINEL: `0x${string}`;
2152
2169
  declare const TEMPO_CHAIN_ID = 4217;
2153
2170
  declare const TEMPO_NATIVE_ERC20: NativeErc20;
2171
+ declare const ARC_CHAIN_ID = 5042;
2172
+ /**
2173
+ * Arc's native gas coin is USDC (18-decimal wei at the EVM level). The USDC
2174
+ * ERC-20 at this address is a view over native balances: `balanceOf` returns
2175
+ * `native wei / 1e12` and has no balance storage slot; allowances live in
2176
+ * regular storage. The composer interacts with USDC exclusively through this
2177
+ * facade, never via `msg.value`.
2178
+ */
2179
+ declare const ARC_NATIVE_ERC20: NativeErc20;
2180
+ declare const ARC_NATIVE_SCALE: bigint;
2154
2181
  declare const getChainCapabilities: (chainId: number) => ChainCapabilities;
2182
+ /**
2183
+ * Structural fold over the `ChainCapabilities` union — the capabilities
2184
+ * counterpart of `foldResource`/`foldRef`. Dispatches on `kind` and hands each
2185
+ * case its narrowed fields, so consumers that must branch on the native-asset
2186
+ * policy (e.g. compose-core's `rewritePreconditions`) do so through one
2187
+ * combinator whose exhaustiveness the compiler enforces: adding a new arm to
2188
+ * the union above turns every `foldChainCapabilities` call into a type error
2189
+ * until it handles the new case.
2190
+ */
2191
+ declare const foldChainCapabilities: <R>(caps: ChainCapabilities, cases: {
2192
+ readonly evmNative: (chainId: number) => R;
2193
+ readonly asErc20: (nativeErc20: NativeErc20, chainId: number) => R;
2194
+ readonly nativeMirroredErc20: (nativeErc20: NativeErc20, nativeScale: bigint, chainId: number) => R;
2195
+ }) => R;
2196
+ /**
2197
+ * What a wire-level native-balance check (`nativeBalanceGte`) must become on
2198
+ * a chain, decided once here from the native-asset policy:
2199
+ *
2200
+ * - `keep` — `evm-native`: the native read is the right read.
2201
+ * - `rewrite` — `as-erc20` (Tempo): no `msg.value` coin exists, so the check
2202
+ * becomes an `erc20BalanceGte` of `token`, the stand-in ERC-20. Amounts were
2203
+ * always facade-denominated, so `minAmount` carries over verbatim.
2204
+ * - `reject` — `native-mirrored-erc20` (Arc): a native read returns real
2205
+ * 18-decimal wei, `nativeScale`× the facade's units, so no interpretation of
2206
+ * `minAmount` is safe — reusing it on a facade read is 1e12 too strict for a
2207
+ * wei-denominated check, keeping the native read lets a facade-denominated
2208
+ * check pass 1e12 too easily. The check must be authored as
2209
+ * `erc20BalanceGte` of the facade; `reason` says so.
2210
+ *
2211
+ * Consumers (the `CheckSchema` / `AssertedPredicateSchema` decodes and
2212
+ * compose-core's derive backstop) are adapters over this result, so the unit
2213
+ * rule lives in one place and the fold's exhaustiveness reaches every site.
2214
+ */
2215
+ type NativeCheckPolicy = {
2216
+ readonly kind: 'keep';
2217
+ } | {
2218
+ readonly kind: 'rewrite';
2219
+ readonly token: `0x${string}`;
2220
+ } | {
2221
+ readonly kind: 'reject';
2222
+ readonly reason: string;
2223
+ };
2224
+ declare const nativeCheckPolicy: (chainId: number) => NativeCheckPolicy;
2225
+ /**
2226
+ * Exact-kind check for `as-erc20` (currently Tempo only) — the rare case that
2227
+ * genuinely means "no `msg.value` coin exists on this chain". Most consumers
2228
+ * want `hasErc20CanonicalNative` instead, which also covers
2229
+ * `native-mirrored-erc20` chains (Arc), where the composer's ERC-20-only
2230
+ * policy applies even though `msg.value` works. Code that must treat the two
2231
+ * ERC-20-native kinds differently goes through `foldChainCapabilities` or
2232
+ * `nativeCheckPolicy`, never a second exact-kind predicate.
2233
+ */
2155
2234
  declare const isAsErc20Chain: (chainId: number) => boolean;
2235
+ /**
2236
+ * Whether the chain's canonical native asset is an ERC-20 — true for both
2237
+ * `as-erc20` chains (Tempo: no `msg.value` coin exists) and
2238
+ * `native-mirrored-erc20` chains (Arc: `msg.value` exists but is never used).
2239
+ * This is the predicate for the shared resource-level behaviour: native
2240
+ * resources are rewritten to the ERC-20, native routing edges are dropped, and
2241
+ * a surviving native resource is a compile error.
2242
+ */
2243
+ declare const hasErc20CanonicalNative: (chainId: number) => boolean;
2156
2244
  /**
2157
2245
  * The address that represents the chain's native asset.
2158
2246
  *
2159
- * On EVM-native chains this is the zero-address sentinel `0x0…0`. On
2160
- * `as-erc20` chains it is the chain's stand-in ERC-20 (e.g. PathUSD on Tempo).
2247
+ * On EVM-native chains this is the zero-address sentinel `0x0…0`. On chains
2248
+ * whose canonical native asset is an ERC-20 it is the chain's stand-in token
2249
+ * (PathUSD on Tempo, the USDC facade on Arc).
2161
2250
  */
2162
2251
  declare const canonicalNativeAddress: (chainId: number) => `0x${string}`;
2163
2252
  /**
2164
2253
  * Whether `address` represents the native asset of `chainId`.
2165
2254
  *
2166
2255
  * On EVM-native chains, this is the case-insensitive zero-address check. On
2167
- * `as-erc20` chains, the literal zero address returns `false` — only the
2168
- * chain's stand-in ERC-20 address matches.
2256
+ * chains whose canonical native asset is an ERC-20, the literal zero address
2257
+ * returns `false` — only the chain's stand-in ERC-20 address matches.
2169
2258
  */
2170
2259
  declare const isNativeAddressForChain: (chainId: number, address: string) => boolean;
2171
2260
  /**
@@ -2175,28 +2264,30 @@ declare const isNativeAddressForChain: (chainId: number, address: string) => boo
2175
2264
  * This is the single predicate that gates `msg.value` semantics — choosing a
2176
2265
  * `NativeBalance` over an `Erc20Balance` simulation requirement, and skipping
2177
2266
  * the ERC-20 approval a native input would otherwise need. It returns `false`
2178
- * for every address on an `as-erc20` chain (including the zero sentinel),
2179
- * because there the "native" coin is a real ERC-20 moved via `transferFrom`,
2180
- * never `msg.value`. Use this rather than re-deriving
2181
- * `!isAsErc20Chain(chainId) && address === EVM_NATIVE_SENTINEL` at call sites,
2182
- * and rather than `isNativeAddressForChain`, which returns `true` for the
2183
- * stand-in ERC-20 (PathUSD) on `as-erc20` chains and would wrongly route it to
2184
- * `msg.value`.
2267
+ * for every address on a chain whose canonical native asset is an ERC-20
2268
+ * (including the zero sentinel): on `as-erc20` chains the "native" coin is a
2269
+ * real ERC-20 moved via `transferFrom`, never `msg.value`, and on
2270
+ * `native-mirrored-erc20` chains `msg.value` works but the composer's policy
2271
+ * is to move the coin exclusively through the ERC-20 facade. Use this rather
2272
+ * than re-deriving the check at call sites, and rather than
2273
+ * `isNativeAddressForChain`, which returns `true` for the stand-in ERC-20
2274
+ * (PathUSD on Tempo) and would wrongly route it to `msg.value`.
2185
2275
  */
2186
2276
  declare const isMsgValueNative: (chainId: number, address: string) => boolean;
2187
2277
  /**
2188
2278
  * Rewrite a single `Resource` according to its chain's capabilities.
2189
2279
  *
2190
2280
  * On chains with the default `evm-native` policy, every resource is returned
2191
- * unchanged. On `as-erc20` chains (currently only Tempo, chainId 4217), a
2192
- * resource of kind `"native"` is rewritten into the equivalent ERC-20
2193
- * resource pointing at the chain's stand-in token (PathUSD for Tempo).
2281
+ * unchanged. On chains whose canonical native asset is an ERC-20 (`as-erc20`
2282
+ * Tempo, `native-mirrored-erc20` Arc), a resource of kind `"native"` is
2283
+ * rewritten into the equivalent ERC-20 resource pointing at the chain's
2284
+ * stand-in token (PathUSD on Tempo, the USDC facade on Arc).
2194
2285
  *
2195
2286
  * This is the rewrite primitive behind the `ResourceSchema` decode transform
2196
2287
  * (see `flowSchema.ts`), which is THE chokepoint: it runs every time a
2197
2288
  * `Resource` is parsed — flow inputs via `FlowSchema`, op configs via
2198
2289
  * `decodeConfig` — so every downstream pass (`normalizeFlow`, `resolve`,
2199
- * `lower`, `simulate`) sees only ERC-20 resources on `as-erc20` chains.
2290
+ * `lower`, `simulate`) sees only ERC-20 resources on those chains.
2200
2291
  *
2201
2292
  * The function preserves referential identity when nothing changes (returns the
2202
2293
  * input `r` unchanged on evm-native chains and for ERC-20 resources) and is
@@ -2206,8 +2297,8 @@ declare const normalizeResource: (r: Resource) => Resource;
2206
2297
  /**
2207
2298
  * Address-level counterpart of `normalizeResource` for wire fields that carry a
2208
2299
  * native asset as a bare token string (a continuation outcome's `token`). On
2209
- * `as-erc20` chains the native sentinel is rewritten to the chain's stand-in
2210
- * ERC-20; every other address passes through.
2300
+ * chains whose canonical native asset is an ERC-20, the native sentinel is
2301
+ * rewritten to the chain's stand-in ERC-20; every other address passes through.
2211
2302
  */
2212
2303
  declare const normalizeNativeTokenAddress: (token: string, chainId: number) => string;
2213
2304
 
@@ -2376,6 +2467,7 @@ type Erc20AllowancePrecondition = {
2376
2467
  declare const erc20Balance: (config: Omit<Erc20BalancePrecondition, "type">) => Erc20BalancePrecondition;
2377
2468
  declare const nativeBalance: (config: Omit<NativeBalancePrecondition, "type">) => NativeBalancePrecondition;
2378
2469
  declare const erc20Allowance: (config: Omit<Erc20AllowancePrecondition, "type">) => Erc20AllowancePrecondition;
2470
+ declare const isErc20BalancePrecondition: (p: Precondition) => p is Erc20BalancePrecondition;
2379
2471
  declare const isErc20AllowancePrecondition: (p: Precondition) => p is Erc20AllowancePrecondition;
2380
2472
  declare const isNativeBalancePrecondition: (p: Precondition) => p is NativeBalancePrecondition;
2381
2473
 
@@ -2604,4 +2696,4 @@ declare const foldMaterialiserMetadata: <R>(meta: MaterialiserMetadata, cases: {
2604
2696
  readonly runtime: () => R;
2605
2697
  }) => R;
2606
2698
 
2607
- export { type Amount, type AppliedGuard, AppliedGuardSchema, type ApprovalEntry, AssertedErc20BalanceGteSpecSchema, AssertedNativeBalanceGteSpecSchema, type AssertedPredicate, AssertedPredicateSchema, type AssertedPredicateWire, AssertedPredicateZod, type AssertionOwner, AssertionOwnerSchema, type AssertionSpec, AssertionSpecSchema, type AssertionSpecWire, AssertionSpecZod, type Availability, type BindValue, BindValueSchema, Bytes32HexSchema, COMPOSER_SDK_VERSION_HEADER, COMPOSE_VERSION_HEADER, CONTINUATION_COMMITMENT_OP_ID, type Call, CallCheckSpecSchema, CallSchema, type ChainCapabilities, type Check, type CheckComparator, CheckSchema, CheckZod, type ComposeAction, type ComposeCompilePartialData, type ComposeCompileRequest, type ComposeCompileResult, type ComposeCompileSuccessData, type ComposeError, type ComposeErrorKind, type ComposeFee, type ComposeFill, type ComposeManifest, ComposeManifestZod, type ComposeRouteErrorKind, type ComposeRouteRequest, type ComposeRun, type ComposeTransactionRequest, type ComposeUserProgramSimulation, type ComposeVersion, type ConsumedOutput, type ContextKey, type ContinuationIntent, ContinuationIntentSchema, type ContinuationOutcome, ContinuationOutcomeSchema, type ContinuationPlan, ContinuationPlanSchema, type ContinuationPlanWire, ContinuationPlanZod, type Delivery, EVM_NATIVE_SENTINEL, type Erc20AllowancePrecondition, type Erc20AllowanceRequirement, Erc20BalanceDeltaGteSpecSchema, Erc20BalanceGteSpecSchema, type Erc20BalancePrecondition, type Erc20BalanceRequirement, type Estimate, type EstimateBasis, type FailedPreparedOp, type FlashloanMaterialiserInput, type Flow, type FlowInput, FlowInputSchema, FlowSchema, type GenericComposeError, type GenericComposeErrorKind, type GuardCompatibility, GuardCompatibilityZod, type GuardSelector, GuardSelectorZod, HANDLE_UNITS, type HandleInput, HandleInputSchema, type HandlePort, HandlePortZod, type HandleUnits, HandleUnitsZod, HexStringSchema, InputPortZod, type InputSpec, type LiteralBinding, LiteralBindingSchema, type ManifestGuard, ManifestGuardZod, type ManifestMaterialiser, ManifestMaterialiserZod, type ManifestOperation, ManifestOperationZod, type ManifestPrecondition, ManifestPreconditionZod, type MaterialiserConfigOf, type MaterialiserInput, type MaterialiserInputBase, type MaterialiserInputOf, type MaterialiserMetadata, type MaterialiserResolution, type Minimum, type MinimumBasis, NativeBalanceDeltaGteSpecSchema, NativeBalanceGteSpecSchema, type NativeBalancePrecondition, type NativeBalanceRequirement, type NativeErc20, type OpInputPort, type OpOutputPort, type Output, type OutputAmount, OutputPortZod, type Outputs, PROVIDER_KIND, type ParsedRef, type Phase1Artifact, Phase1ArtifactSchema, type Phase1ArtifactWire, Phase1ArtifactZod, type Port, type Precondition, type PreconditionBase, type PreconditionConfigOf, type PreconditionOf, type PreparationComposeError, type PriceImpact, type ProviderKindName, RESERVED_REF_SCOPES, type Ref, type RefBuilder, type RefPath, RefSchema, type RefScope, type Resource, type ResourceInput, ResourceInputSchema, type ResourceOutputPort, ResourceOutputPortZod, type ResourcePort, ResourcePortZod, ResourceSchema, type RouteAmount, type RouteAmountAll, type RouteAmountExact, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, type SimulateBalanceEntry, type SimulateOkResult, type SimulateRequest, type SimulateResult, type SimulateRevertDecodeResult, type SimulateRevertResult, type SimulateSetupErrorResult, type SimulationPolicy, type SimulationRevert, type SimulationRevertComposeError, type SlotFinderRequirement, type SolType, SolTypeSchema, type SpendEntry, type StaticSolType, StaticSolTypeZod, type SweepTo, TEMPO_CHAIN_ID, TEMPO_NATIVE_ERC20, type TerminalOutput, type TrackedBalance, type VerificationDescriptor, VerificationDescriptorSchema, type VerificationDescriptorWire, VerificationDescriptorZod, type VersionCompatibility, canonicalAssertedPredicate, canonicalNativeAddress, checkCompatibility, copy, erc20, erc20Allowance, erc20Balance, erc20Resource, erc20Token, flowInputMode, flowInputResource, flowInputType, foldMaterialiserMetadata, foldRef, foldResource, getChainCapabilities, handle, isAsErc20Chain, isContextKey, isEQCheck, isERC20Resource, isErc20AllowancePrecondition, isFutureResourceOutput, isGTECheck, isHandlePort, isLTECheck, isMaterialiserInput, isMsgValueNative, isNativeAddressForChain, isNativeBalancePrecondition, isNativeResource, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeBalance, nativeResource, normalizeNativeTokenAddress, normalizeResource, opHandle, parseRef, parseVersion, providerKindByName, providerKindNames, readResource, ref, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual, settledOutcome };
2699
+ export { ARC_CHAIN_ID, ARC_NATIVE_ERC20, ARC_NATIVE_SCALE, type Amount, type AppliedGuard, AppliedGuardSchema, type ApprovalEntry, AssertedErc20BalanceGteSpecSchema, AssertedNativeBalanceGteSpecSchema, type AssertedPredicate, AssertedPredicateSchema, type AssertedPredicateWire, AssertedPredicateZod, type AssertionOwner, AssertionOwnerSchema, type AssertionSpec, AssertionSpecSchema, type AssertionSpecWire, AssertionSpecZod, type Availability, type BindValue, BindValueSchema, Bytes32HexSchema, COMPOSER_SDK_VERSION_HEADER, COMPOSE_VERSION_HEADER, CONTINUATION_COMMITMENT_OP_ID, type Call, CallCheckSpecSchema, CallSchema, type ChainCapabilities, type Check, type CheckComparator, CheckSchema, CheckZod, type ComposeAction, type ComposeCompilePartialData, type ComposeCompileRequest, type ComposeCompileResult, type ComposeCompileSuccessData, type ComposeError, type ComposeErrorKind, type ComposeFee, type ComposeFill, type ComposeManifest, ComposeManifestZod, type ComposeRouteErrorKind, type ComposeRouteRequest, type ComposeRun, type ComposeTransactionRequest, type ComposeUserProgramSimulation, type ComposeVersion, type ConsumedOutput, type ContextKey, type ContinuationIntent, ContinuationIntentSchema, type ContinuationOutcome, ContinuationOutcomeSchema, type ContinuationPlan, ContinuationPlanSchema, type ContinuationPlanWire, ContinuationPlanZod, type Delivery, EVM_NATIVE_SENTINEL, type Erc20AllowancePrecondition, type Erc20AllowanceRequirement, Erc20BalanceDeltaGteSpecSchema, Erc20BalanceGteSpecSchema, type Erc20BalancePrecondition, type Erc20BalanceRequirement, type Estimate, type EstimateBasis, type FailedPreparedOp, type FlashloanMaterialiserInput, type Flow, type FlowInput, FlowInputSchema, FlowSchema, type GenericComposeError, type GenericComposeErrorKind, type GuardCompatibility, GuardCompatibilityZod, type GuardSelector, GuardSelectorZod, HANDLE_UNITS, type HandleInput, HandleInputSchema, type HandlePort, HandlePortZod, type HandleUnits, HandleUnitsZod, HexStringSchema, InputPortZod, type InputSpec, type LiteralBinding, LiteralBindingSchema, type ManifestGuard, ManifestGuardZod, type ManifestMaterialiser, ManifestMaterialiserZod, type ManifestOperation, ManifestOperationZod, type ManifestPrecondition, ManifestPreconditionZod, type MaterialiserConfigOf, type MaterialiserInput, type MaterialiserInputBase, type MaterialiserInputOf, type MaterialiserMetadata, type MaterialiserResolution, type Minimum, type MinimumBasis, NativeBalanceDeltaGteSpecSchema, NativeBalanceGteSpecSchema, type NativeBalancePrecondition, type NativeBalanceRequirement, type NativeCheckPolicy, type NativeErc20, type OpInputPort, type OpOutputPort, type Output, type OutputAmount, OutputPortZod, type Outputs, PROVIDER_KIND, type ParsedRef, type Phase1Artifact, Phase1ArtifactSchema, type Phase1ArtifactWire, Phase1ArtifactZod, type Port, type Precondition, type PreconditionBase, type PreconditionConfigOf, type PreconditionOf, type PreparationComposeError, type PriceImpact, type ProviderKindName, RESERVED_REF_SCOPES, type Ref, type RefBuilder, type RefPath, RefSchema, type RefScope, type Resource, type ResourceInput, ResourceInputSchema, type ResourceOutputPort, ResourceOutputPortZod, type ResourcePort, ResourcePortZod, ResourceSchema, type RouteAmount, type RouteAmountAll, type RouteAmountExact, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, STATIC_SOL_TYPES, type SimulateBalanceEntry, type SimulateOkResult, type SimulateRequest, type SimulateResult, type SimulateRevertDecodeResult, type SimulateRevertResult, type SimulateSetupErrorResult, type SimulationPolicy, type SimulationRevert, type SimulationRevertComposeError, type SlotFinderRequirement, type SolType, SolTypeSchema, type SpendEntry, type StaticSolType, StaticSolTypeZod, type SweepTo, TEMPO_CHAIN_ID, TEMPO_NATIVE_ERC20, type TerminalOutput, type TrackedBalance, type VerificationDescriptor, VerificationDescriptorSchema, type VerificationDescriptorWire, VerificationDescriptorZod, type VersionCompatibility, canonicalAssertedPredicate, canonicalNativeAddress, checkCompatibility, copy, erc20, erc20Allowance, erc20Balance, erc20Resource, erc20Token, flowInputMode, flowInputResource, flowInputType, foldChainCapabilities, foldMaterialiserMetadata, foldRef, foldResource, getChainCapabilities, handle, hasErc20CanonicalNative, isAsErc20Chain, isContextKey, isEQCheck, isERC20Resource, isErc20AllowancePrecondition, isErc20BalancePrecondition, isFutureResourceOutput, isGTECheck, isHandlePort, isLTECheck, isMaterialiserInput, isMsgValueNative, isNativeAddressForChain, isNativeBalancePrecondition, isNativeResource, isRef, isResourceInput, isResourceOutputPort, isResourcePort, isStaticSolType, linear, native, nativeBalance, nativeCheckPolicy, nativeResource, normalizeNativeTokenAddress, normalizeResource, opHandle, parseRef, parseVersion, providerKindByName, providerKindNames, readResource, ref, refKey, resource, resourceKey, resourceOutput, resourceToken, resourcesEqual, settledOutcome };