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