@eco-foundation/api-schemas 0.4.0 → 0.6.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 +274 -13
- package/dist/fixtures/index.js +0 -4
- package/dist/fixtures/index.js.map +1 -1
- package/dist/fixtures/v1/tokens-list.response.default.json +1 -1
- package/dist/generated/build-digest.json +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/v1/endpoints/chains.d.ts +7 -0
- package/dist/v1/endpoints/chains.js +5 -1
- package/dist/v1/endpoints/chains.js.map +1 -1
- package/dist/v1/endpoints/deposit-addresses.js +1 -1
- package/dist/v1/endpoints/deposit-addresses.js.map +1 -1
- package/dist/v1/endpoints/quotes.d.ts +2 -1
- package/dist/v1/endpoints/quotes.js +33 -6
- package/dist/v1/endpoints/quotes.js.map +1 -1
- package/dist/v1/endpoints/registry.d.ts +110 -21
- package/dist/v1/endpoints/registry.js +2 -2
- package/dist/v1/endpoints/registry.js.map +1 -1
- package/dist/v1/endpoints/status.d.ts +211 -26
- package/dist/v1/endpoints/status.js +39 -7
- package/dist/v1/endpoints/status.js.map +1 -1
- package/dist/v1/endpoints/submit.d.ts +2 -91
- package/dist/v1/endpoints/submit.js +1 -37
- package/dist/v1/endpoints/submit.js.map +1 -1
- package/dist/v1/endpoints/tokens.d.ts +7 -0
- package/dist/v1/endpoints/tokens.js +5 -1
- package/dist/v1/endpoints/tokens.js.map +1 -1
- package/dist/v1/enums.d.ts +2 -1
- package/dist/v1/enums.js +1 -1
- package/dist/v1/enums.js.map +1 -1
- package/dist/v1/errors/catalog.d.ts +7 -0
- package/dist/v1/errors/catalog.js +2 -1
- package/dist/v1/errors/catalog.js.map +1 -1
- package/dist/v1/errors/problem.d.ts +10 -0
- package/dist/v1/errors/problem.js +20 -10
- package/dist/v1/errors/problem.js.map +1 -1
- package/dist/v1/primitives.d.ts +7 -1
- package/dist/v1/primitives.js +14 -1
- package/dist/v1/primitives.js.map +1 -1
- package/dist/v1/types.d.ts +35 -1
- package/errors/catalog.lock.json +5 -0
- package/openapi/v1.json +601 -594
- package/package.json +20 -15
- package/dist/fixtures/v1/intents-submit-permit2.request.quote-target.json +0 -25
- package/dist/fixtures/v1/intents-submit-permit3.request.quote-target.json +0 -27
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ Zod-first schemas, error catalog, golden fixtures, and generated OpenAPI 3.1 for
|
|
|
4
4
|
API. The Zod schemas are the source of truth; everything else (OpenAPI, fixtures, plain types)
|
|
5
5
|
is generated from or gated against them.
|
|
6
6
|
|
|
7
|
-
Today the package covers **
|
|
8
|
-
legacy references), and **
|
|
7
|
+
Today the package covers **11 endpoints across 10 paths**, **38 error codes** (51 namespaced
|
|
8
|
+
legacy references), and **17 golden fixtures**.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -14,13 +14,13 @@ While the package is 0.x, pin the patch range or the exact version:
|
|
|
14
14
|
```json
|
|
15
15
|
{
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@eco-foundation/api-schemas": "~0.
|
|
17
|
+
"@eco-foundation/api-schemas": "~0.6.0"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
**Never write `^0`.** npm resolves `^0.x` as `>=0.0.0 <1.0.0`, so it silently accepts every
|
|
23
|
-
future breaking `0.y` — it is not a pin at all. Use `~0.
|
|
23
|
+
future breaking `0.y` — it is not a pin at all. Use `~0.6.0` or the exact `0.6.0`.
|
|
24
24
|
|
|
25
25
|
A matching version string is not evidence of a matching artifact: also compare
|
|
26
26
|
`V1_SCHEMA_DIGEST` (see [Invariants](#invariants-enforced-in-ci)). Two builds both called
|
|
@@ -30,6 +30,230 @@ A matching version string is not evidence of a matching artifact: also compare
|
|
|
30
30
|
zod-bearing entry point. Which case you are in is decided entirely by your imports; see
|
|
31
31
|
[Consumers](#consumers).
|
|
32
32
|
|
|
33
|
+
## Migrating 0.5.0 -> 0.6.0
|
|
34
|
+
|
|
35
|
+
**BREAKING under 0.x semver** (breaking bumps the minor while the major is 0). Five items REJECT
|
|
36
|
+
a request `0.5.0` accepted or remove something `0.5.0` published; four are additive. Every
|
|
37
|
+
breaking item is listed here — if you send anything named below, read its entry before bumping.
|
|
38
|
+
|
|
39
|
+
**`V1_SCHEMA_DIGEST` MOVES.** Both digest inputs changed (`errors/catalog.lock.json` gained one
|
|
40
|
+
code; `openapi/v1.json` lost two operations, gained two parameters and several descriptions), so
|
|
41
|
+
the value is now `a6724fa4dd585e77aebe680655ac10fe5a2f4b70537930a0b4dee2612afb7c8e` — was
|
|
42
|
+
`1d8e88e957795b23e1317dc1e3783fd64bf79b756e3f28bd40e02b047542d790` on `0.4.0`, `0.4.1` and
|
|
43
|
+
`0.5.0`. Every consumer running `assertNoSkew` must move to the new value **in the same
|
|
44
|
+
rollout**. Unlike `0.5.0`, this time the skew check DOES see the difference, so a mixed fleet
|
|
45
|
+
fails it by design rather than silently validating two ways.
|
|
46
|
+
|
|
47
|
+
**THE FIVE BREAKING ITEMS FIRST.**
|
|
48
|
+
|
|
49
|
+
**1. `slippage` now rejects `0` and anything below `0.0001`, and the rejection is named.**
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// 0.5.0: parses (and then fails downstream). 0.6.0: 400, code slippage-out-of-bounds, path ['slippage'].
|
|
53
|
+
{ ..., slippage: 0 }
|
|
54
|
+
{ ..., slippage: 0.00005 }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The range is `0.0001`-`1` (`SLIPPAGE_MIN`/`SLIPPAGE_MAX`, both exported), a DECIMAL FRACTION of
|
|
58
|
+
the destination amount: `0.005` is 0.5%. No solver can express a tolerance below one basis
|
|
59
|
+
point, so a `0` could only ever be rejected downstream, silently clamped, or silently replaced
|
|
60
|
+
by a default; refusing it at the edge with a named code is the honest one. Zero tolerance is
|
|
61
|
+
meaningless on a swap route and ignored on a non-swap route, so nothing is lost.
|
|
62
|
+
|
|
63
|
+
**The code changes for EVERY out-of-range value, not only the new floor.** `0.5.0` enforced the
|
|
64
|
+
bound with a built-in `.min()/.max()`, which zod reports as `too_small`/`too_big` — and
|
|
65
|
+
`v1ErrorCodeFromIssues` maps only a `custom` issue carrying `v1IssueParams`, so the catalog's
|
|
66
|
+
`slippage-out-of-bounds` was promised and unreachable: `50` rendered as the generic
|
|
67
|
+
`invalid-request` with `legacyCode: eco-quotes:1003`. It now renders as
|
|
68
|
+
`slippage-out-of-bounds` (status 400 unchanged, `detail` text unchanged, no `legacyCode`
|
|
69
|
+
because that code has none). An integrator branching on `code === 'invalid-request'` for a
|
|
70
|
+
bad slippage, or reading `legacyCode` there, sees the change. The catalog TITLE names the
|
|
71
|
+
floor now; code, status and `legacyCodes` are untouched.
|
|
72
|
+
|
|
73
|
+
The published document also carries the units for the first time: both `slippage` fields have a
|
|
74
|
+
`description`, and the request field keeps `minimum`/`maximum` (via `.meta()`, since the bound
|
|
75
|
+
itself lives in a refinement that `z.toJSONSchema` drops). The response `slippage` is documented
|
|
76
|
+
as the tolerance ACTUALLY bound into `destination.minAmountOut` — when a request omits
|
|
77
|
+
`slippage`, that is the default the solver applied, not the omission.
|
|
78
|
+
|
|
79
|
+
**2. A zero `amount` is rejected on the quote request.**
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// 0.5.0: parses, reaches a solver, comes back as a 502. 0.6.0: 400, path ['source','amount'].
|
|
83
|
+
{ ..., source: { chainId: 8453, token: '0x…', amount: '0' } }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`source.amount` and `destination.amount` are `PositiveUintString` (new primitive: `UintString`
|
|
87
|
+
with `'0'` excluded, message `must be greater than 0`). Every other `UintString` field is
|
|
88
|
+
unchanged — a zero `value` on a destination call or a zero fee is still legal. The bound reaches
|
|
89
|
+
the OpenAPI document as a `description` only; a string has no `minimum`.
|
|
90
|
+
|
|
91
|
+
**3. `options.maxCallDataSize` is gone.**
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// 0.5.0: parses. 0.6.0: 400, unrecognized_keys at path ['options'].
|
|
95
|
+
{ ..., options: { maxCallDataSize: 1000 } }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
It was published with no description and read by no service, so a caller sending it was handed
|
|
99
|
+
a 200 for a bound nobody enforced. The strict `options` object now names the key in a 400, the
|
|
100
|
+
same disposition `allowHighSlippage` has had since `0.3.0`. The zod-free `V1QuoteRequest` alias
|
|
101
|
+
drops the member too. A caller that needs a calldata cap needs one that is defined and enforced,
|
|
102
|
+
which is a different change.
|
|
103
|
+
|
|
104
|
+
**4. `POST /v1/intents/submit/permit2` and `/permit3` are WITHDRAWN.**
|
|
105
|
+
|
|
106
|
+
Neither lane can complete, and this is why. The signed Permit2 `spender` and every Permit3 leg
|
|
107
|
+
`account` must be the intent VAULT (`Portal.fundFor` pulls the funds through
|
|
108
|
+
`IPermit.transferFrom(funder, vault)`), and the vault is derived from the route salt the router
|
|
109
|
+
dispatches — a value the signer cannot know before signing until quoted-salt dispatch and vault
|
|
110
|
+
binding exist. On top of that the published bodies omitted material the solver requires (permit2
|
|
111
|
+
`chainId`; permit3 `permitContract`, `timestamp`, `merkleRoot`, per-leg `account` /
|
|
112
|
+
`modeOrExpiration`), so the first refusal was a 401 on every request. Advertising a lane whose
|
|
113
|
+
every body ends in a 4xx is a false promise. The lanes return as a follow-on once quoted-salt
|
|
114
|
+
dispatch and vault binding land; `erc-3009` is the quote-target intents standard until then.
|
|
115
|
+
|
|
116
|
+
What moved, concretely:
|
|
117
|
+
|
|
118
|
+
- `STANDARDS_BY_TARGET.quote` is `['erc-3009']`. `depositAddress` is unchanged.
|
|
119
|
+
- The two registry entries, the two operations in `openapi/v1.json`, and the two golden fixtures
|
|
120
|
+
are gone (11 endpoints over 10 paths; 17 fixtures). A router that dispatches from
|
|
121
|
+
`V1_SUBMIT_SCHEMAS_BY_SERVICE.intents` answers `invalid-parameter` on those routes by
|
|
122
|
+
construction.
|
|
123
|
+
- **Five exports are deleted:** `Permit3AllowanceSchema`, `Permit3PayloadSchema`,
|
|
124
|
+
`Permit3SubmitSchema`, `Permit2PermitSingleSchema`, `Permit2SubmitSchema`. No endpoint accepts
|
|
125
|
+
those bodies, so there is nothing for them to validate.
|
|
126
|
+
- **`V1_SUBMIT_SCHEMAS` is keyed by the new `LaneStandard` type** (`'erc-3009' | 'erc-2612'` —
|
|
127
|
+
the standards that have a lane), not by `SubmitStandard`. `V1_SUBMIT_SCHEMAS[standard]` with
|
|
128
|
+
a `SubmitStandard`-typed index no longer compiles; narrow to `LaneStandard` first. That is the
|
|
129
|
+
intended signal — the alternative was an `undefined` a dispatcher trips over at runtime.
|
|
130
|
+
- **`SUBMIT_STANDARDS` and `SubmitStandard` KEEP all four spellings.** That enum is also the
|
|
131
|
+
discovery vocabulary a token advertises under `supports`, and narrowing it would make a
|
|
132
|
+
consumer hard-fail on a token list from a server still spelling `permit3`. The vocabulary is
|
|
133
|
+
what a token MAY advertise; the matrix is what has a lane. The tokens fixture advertises
|
|
134
|
+
`quote: ['erc-3009']`.
|
|
135
|
+
|
|
136
|
+
**5. Consumer-side only, but read it: the lock gained a 502.** `V1ProblemSchema` cross-checks a
|
|
137
|
+
KNOWN code's `status`/`type` against the catalog. `solver-error` (below) is now known, so a body
|
|
138
|
+
carrying that spelling with a contradicting status or type stops parsing where `0.5.0` tolerated
|
|
139
|
+
it as "a newer server". An exhaustive `switch` over `V1ErrorCode` will not compile until it
|
|
140
|
+
handles it.
|
|
141
|
+
|
|
142
|
+
**THE FOUR ADDITIVE ITEMS.**
|
|
143
|
+
|
|
144
|
+
**Added — `solver-error` (502): an upstream solver rejected or failed the quote request.**
|
|
145
|
+
`solver-timeout` was the only 502, so a router had to label a solver answering 400 in six
|
|
146
|
+
milliseconds with a title that says "timed out". `solver-error` is the code for every upstream
|
|
147
|
+
failure that is NOT a deadline expiry — a solver 4xx/5xx, a network error, an unparseable body.
|
|
148
|
+
It is 502 rather than 4xx/422 on purpose: the gateway built the RFQ, so a solver rejection is a
|
|
149
|
+
gateway/contract fault, never the caller's, and a 422 mapping would hide a contract bug as "no
|
|
150
|
+
route". `legacyCodes` is EMPTY by construction: `eco-quotes:1025` (Failed) is the ref that would
|
|
151
|
+
belong here, but it was published on `solver-timeout` and the lock is append-only, so it stays
|
|
152
|
+
there. Branch on `code`, not on `status`, to tell the two 502s apart.
|
|
153
|
+
|
|
154
|
+
**Added — `?chainId=` on `GET /v1/chains` and `GET /v1/tokens`.** OPTIONAL on both (the
|
|
155
|
+
unfiltered document is unchanged and stays legal), a single value only. A malformed value —
|
|
156
|
+
`abc`, `0`, `-1`, `1.5`, or a repeated `?chainId=1&chainId=8453` — is a 400 at the field; a
|
|
157
|
+
syntactically valid chain id that matches nothing is a 200 with `chains: []` /
|
|
158
|
+
`tokens: [], nextCursor: null`, never a 404. New exports: `CHAINS_LIST_QUERY_SHAPE` /
|
|
159
|
+
`ChainsListQuerySchema`, `TOKENS_LIST_QUERY_SHAPE` / `TokensListQuerySchema`, and `ChainIdParam`
|
|
160
|
+
(the coercing query-string twin of the body `ChainId`, which all three `chainId` query params —
|
|
161
|
+
these two and the deposit-address lookup's — now wrap, so the accepted set cannot differ between
|
|
162
|
+
endpoints publishing the same parameter name). Query-side only: never coerce a chain id in a
|
|
163
|
+
JSON body.
|
|
164
|
+
|
|
165
|
+
**Added — `renderIssuesAsProblemParts(issues, opts?) -> { code, detail?, errors? }`, THE one
|
|
166
|
+
sanctioned path from a `ZodError` to a problem body.** Two services rendered the same validation
|
|
167
|
+
failure with a cap of 4 and a cap of 10, a `(+N more issues)` suffix and an `N issues, first M:`
|
|
168
|
+
prefix, a bare root message and a `(root)` placeholder, and only one of them emitted `errors[]`.
|
|
169
|
+
This function is the single set of conventions: cap `MAX_DETAIL_ISSUES` (8, now exported) for
|
|
170
|
+
both `detail` and `errors`; overflow is ONE trailing `(+N more issues)`; a root-level issue is
|
|
171
|
+
its bare message; `errors` carries bare dotted fields and is omitted when nothing survives.
|
|
172
|
+
Absent keys are absent, so the result spreads straight into `problem(code, rest)` or your own
|
|
173
|
+
builder. `problemFromZodError` is built on it and a test pins that the two produce byte-identical
|
|
174
|
+
bodies. A service with its own problem type should route every `ZodError` through here and
|
|
175
|
+
delete its local cap and overflow constants.
|
|
176
|
+
|
|
177
|
+
**Added — execution detail on a status entry.** `StatusEntrySchema` and `statusEntrySchemaFor`
|
|
178
|
+
gain three OPTIONAL members: `sourceTx` and `destinationTx` as
|
|
179
|
+
`{ chainId, txHash, token, amount }`, and `steps[]` as
|
|
180
|
+
`{ type: 'SWAP' | 'BRIDGE', status, from, to, transactions: { created?, fulfilled?, refunded? } }`
|
|
181
|
+
with `{ token, amount, chainId }` legs and `{ chainId, txHash }` transaction refs. The shape
|
|
182
|
+
mirrors the solver's step facts verbatim; the step `type` is the producer's vocabulary (not the
|
|
183
|
+
quote-response `StepKind`) and the step `status` is the producer's raw per-step state beneath the
|
|
184
|
+
C1 entry-level vocabulary, deliberately unmapped. **Absent means unknown; `null` is rejected** —
|
|
185
|
+
a null would read as "known to be none" on a lane whose upstream simply has no token/amount.
|
|
186
|
+
Today the quote-status lane can populate them; the general intent-status lane omits them.
|
|
187
|
+
`chainId` is a JSON number (the solver spells it as a string; the producer converts), amounts
|
|
188
|
+
are uint strings, `token` is a bare string because the native asset may be a sentinel. New
|
|
189
|
+
schema exports `StatusTxRefSchema`, `StatusTokenAmountSchema`, `StatusTxDetailSchema`,
|
|
190
|
+
`StatusStepSchema`, `StatusStepType` / `STATUS_STEP_TYPES`; new zod-free aliases `V1StatusTxRef`,
|
|
191
|
+
`V1StatusTokenAmount`, `V1StatusTxDetail`, `V1StatusStep`, `V1StatusStepType`.
|
|
192
|
+
|
|
193
|
+
## Migrating 0.4.1 -> 0.5.0
|
|
194
|
+
|
|
195
|
+
**BREAKING under 0.x semver** (breaking bumps the minor while the major is 0): this release
|
|
196
|
+
REJECTS a request body `0.4.1` accepted. Nothing else moved — no code, status, `legacyCodes`
|
|
197
|
+
mapping, or response shape changed.
|
|
198
|
+
|
|
199
|
+
**`V1_SCHEMA_DIGEST` DOES NOT MOVE, and that is the caveat to read before rolling out.** The new
|
|
200
|
+
rule is a `superRefine`, and `z.toJSONSchema` drops refinements, so neither digest input changed:
|
|
201
|
+
`openapi/v1.json` is byte-identical and `assertNoSkew` cannot see the difference. A fleet running
|
|
202
|
+
`0.4.1` and `0.5.0` side by side therefore passes the skew check while VALIDATING DIFFERENTLY —
|
|
203
|
+
the same body is a 400 on one instance and a 200 on another. Roll every consumer together, or
|
|
204
|
+
accept that inconsistency knowingly.
|
|
205
|
+
|
|
206
|
+
**Rejected — a `funder` that cannot share a chain with `source.token`.**
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
// 0.4.1: parses. 0.5.0: 400, path ['funder'].
|
|
210
|
+
{ source: { chainId: 1399811149, token: '<a Solana mint>' }, funder: '0x3333…3333' }
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Both fields live on the SOURCE chain, so an EVM funder beside a Solana source token describes no
|
|
214
|
+
chain that exists. It used to parse, get quoted, and then fail wherever a service classified the
|
|
215
|
+
funder against the source VM — and a service that read a malformed funder as ITS OWN material
|
|
216
|
+
answered `500 internal-error` for a field the caller sent.
|
|
217
|
+
|
|
218
|
+
**What this rule deliberately does NOT do: bind `funder` to `source.chainId`.** That needs a
|
|
219
|
+
chain-ID-to-VM table, and this package holds none by design — `ChainId` is any positive integer,
|
|
220
|
+
and `ADDRESS_BY_CHAIN_TYPE` exists for the caller that already knows the chain type. A table here
|
|
221
|
+
would make every published version an allow-list of chains: a newly launched SVM chain would be
|
|
222
|
+
misclassified by every consumer still on an older pin, and its valid base58 funder rejected, so
|
|
223
|
+
this package would have to be re-released and rolled out before a chain could launch. Comparing
|
|
224
|
+
two addresses from the same request needs no table and cannot go stale.
|
|
225
|
+
|
|
226
|
+
So the check is a NECESSARY condition, not a sufficient one, in two specific ways:
|
|
227
|
+
|
|
228
|
+
- **Two EVM addresses agree with each other whatever `chainId` says**, including a Solana chain id.
|
|
229
|
+
A green parse is not evidence the funder is right for the chain.
|
|
230
|
+
- **SVM and TVM are not separated.** A Tron base58check address also satisfies `SvmAddress`'s
|
|
231
|
+
32-44 character range (see the `AnyAddress` docblock), so shape cannot decide between them and
|
|
232
|
+
the rule lets that pair through rather than guessing.
|
|
233
|
+
|
|
234
|
+
A service that knows the chain's VM must still check each address against it. Two new exports help:
|
|
235
|
+
`addressFamilies(value)` returns every family a value is consistent with, and
|
|
236
|
+
`addressFamiliesCanAgree(a, b)` is the pairwise predicate the refinement uses.
|
|
237
|
+
|
|
238
|
+
## Migrating 0.4.0 -> 0.4.1
|
|
239
|
+
|
|
240
|
+
Purely additive; no schema, wire, or digest change. `V1_SCHEMA_DIGEST` is UNCHANGED, so this is
|
|
241
|
+
not a coordinated-rollout release — a fleet may run 0.4.0 and 0.4.1 side by side.
|
|
242
|
+
|
|
243
|
+
**Added — the two conformance skip reasons are exported constants.**
|
|
244
|
+
`SIDE_EFFECT_SKIP_REASON` and `DRAFT_SKIP_REASON` are now named exports of the `./testing`
|
|
245
|
+
subpath. They were previously inline literals in this package's own spec, which meant a consumer
|
|
246
|
+
pinning them had to copy the strings and had no way to notice a rewording — the published tarball
|
|
247
|
+
ships `dist/`, never the sources those literals lived in. Import them instead of copying:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
import { DRAFT_SKIP_REASON, SIDE_EFFECT_SKIP_REASON } from '@eco-foundation/api-schemas/testing';
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
This is also the first release cut from `eco/eco-api-schemas`, the package's own repository. It
|
|
254
|
+
previously shipped from a pnpm workspace inside `eco-incorp/router`; nothing about the published
|
|
255
|
+
artifact's contents or layout changed with the move.
|
|
256
|
+
|
|
33
257
|
## Migrating 0.3.1 -> 0.4.0
|
|
34
258
|
|
|
35
259
|
`0.3.1` was never published, so **`0.4.0` is the upgrade from `0.3.0`** and carries `0.3.1`'s
|
|
@@ -135,6 +359,13 @@ Tron-source funding quote. Do not read the SVM lane as a precedent that a `tvm`
|
|
|
135
359
|
behind it: adding one would be a breaking wire change with its own migration note, and nothing
|
|
136
360
|
here commits `/v1` to that surface.
|
|
137
361
|
|
|
362
|
+
**Added — `./package.json` is an exported subpath.**
|
|
363
|
+
`require('@eco-foundation/api-schemas/package.json')` previously threw
|
|
364
|
+
`ERR_PACKAGE_PATH_NOT_EXPORTED`, which broke tooling that reads a dependency's manifest for
|
|
365
|
+
its version. Nothing else changes; it is purely additive. (`prepack` now also rebuilds
|
|
366
|
+
`dist/` on a manual `npm pack`/`npm publish`, which affects publishing rather than
|
|
367
|
+
consuming.)
|
|
368
|
+
|
|
138
369
|
**Added — the `errors` problem extension (per-field caller faults).**
|
|
139
370
|
|
|
140
371
|
```json
|
|
@@ -150,8 +381,13 @@ here commits `/v1` to that surface.
|
|
|
150
381
|
|
|
151
382
|
`errors` is **OPTIONAL**: an `invalid-request` for a body that is not JSON at all has no
|
|
152
383
|
field to name, so absence is legal and means exactly that. `field` names the offending
|
|
153
|
-
input in YOUR terms — the path into what you sent
|
|
154
|
-
|
|
384
|
+
input in YOUR terms — the path into what you sent, with **no `body.`/`query.` prefix**:
|
|
385
|
+
`source.chainId`, `funder`, `limit`. `detail` obeys the same free-text policy as the
|
|
386
|
+
problem's own `detail`.
|
|
387
|
+
|
|
388
|
+
Because there is no prefix, `field` alone does not say whether the value came from the body
|
|
389
|
+
or the query string. Every /v1 endpoint takes its parameters in exactly one of the two, so
|
|
390
|
+
**key on the route plus `field`**, not on `field` alone.
|
|
155
391
|
|
|
156
392
|
**`errors` is NOT `solverErrors`.** They sit adjacent and answer different questions:
|
|
157
393
|
`errors` is your own fault (a field you sent, and naming it is how you fix it);
|
|
@@ -456,7 +692,7 @@ Zod-major compatibility is the reason there are two interfaces, not one:
|
|
|
456
692
|
|
|
457
693
|
There are two fixture locations and they serve different jobs — do not conflate them:
|
|
458
694
|
|
|
459
|
-
- **`src/fixtures/v1/`** — the
|
|
695
|
+
- **`src/fixtures/v1/`** — the 17 golden request/response payloads, one per endpoint variant,
|
|
460
696
|
consumed through **`loadV1Fixtures()`** rather than by file path. Each entry carries its
|
|
461
697
|
endpoint id, direction, variant, and the C12 replay metadata (`method`, `path`,
|
|
462
698
|
`expectedStatus`, `sideEffect`, optional `stability` and `headers`), so a live-replay harness
|
|
@@ -519,10 +755,10 @@ which needs no server.
|
|
|
519
755
|
build → lint:check → test → catalog:check → openapi:check → digest:check
|
|
520
756
|
```
|
|
521
757
|
|
|
522
|
-
Both `.github/workflows/ci.yml` (every PR) and `.github/workflows/publish
|
|
758
|
+
Both `.github/workflows/ci.yml` (every PR) and `.github/workflows/publish.yml`
|
|
523
759
|
(every release tag) run exactly that one command.
|
|
524
760
|
|
|
525
|
-
**The `verify`-before-`
|
|
761
|
+
**The `verify`-before-`stage` step in the release workflow is load-bearing — do not
|
|
526
762
|
streamline it away.** `build` uses `tsconfig.build.json`, which excludes `src/**/*.spec.ts`, so
|
|
527
763
|
the compile-time gates that live in spec files — most importantly the `v1/types` parity gate —
|
|
528
764
|
cannot fail `build`. They fail `test`. Publishing without running `verify` would therefore ship
|
|
@@ -546,12 +782,37 @@ Two `catalog:check` outcomes are NOT failures and must not be confused with each
|
|
|
546
782
|
|
|
547
783
|
## Publishing
|
|
548
784
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
785
|
+
Publishing is **two steps, and CI only does the first one.**
|
|
786
|
+
|
|
787
|
+
**1. Tag `v<version>`** (must equal `package.json` version). The `Stage release` workflow
|
|
788
|
+
verifies and then runs `npm stage publish`, which uploads the tarball to npm in a pending state.
|
|
789
|
+
It fails with `::error::tag version <x> != package version <y>` if the two drift, so a stale tag
|
|
790
|
+
can never stage a mismatched artifact. It needs the `NPM_TOKEN` repo secret: a granular token
|
|
791
|
+
scoped to `@eco-foundation` with **"Read and write (stage only)"** rights.
|
|
792
|
+
|
|
793
|
+
**A green run means the version is QUEUED, not released.** Nobody can install it yet.
|
|
794
|
+
|
|
795
|
+
**2. A maintainer promotes it**, which costs a 2FA challenge:
|
|
796
|
+
|
|
797
|
+
```
|
|
798
|
+
npm stage list @eco-foundation/api-schemas
|
|
799
|
+
npm stage approve <stage-id> # or: npm stage reject <stage-id>
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
The queue is also visible on npmjs.com, and the workflow's run summary repeats these commands.
|
|
803
|
+
|
|
804
|
+
Why the split: npm removes direct publish from granular access tokens in **January 2027**, and
|
|
805
|
+
an approval cannot be satisfied by any CI credential — token or OIDC — by design. A stolen
|
|
806
|
+
runner token can queue a release; it can never ship one. `npm stage approve` needs npm ≥
|
|
807
|
+
`11.15.0` locally, same as CI.
|
|
808
|
+
|
|
809
|
+
Two staging rules worth knowing before you tag. The dist-tag is **immutable once staged** — it
|
|
810
|
+
cannot be changed on the way to approval, only rejected and re-staged — and a version that is
|
|
811
|
+
already staged cannot be staged again, so a re-tag of a queued version fails until the queued
|
|
812
|
+
one is approved or rejected.
|
|
552
813
|
|
|
553
814
|
Semver: breaking schema change = major, additive = minor; consumers pin minor. **While the
|
|
554
|
-
package is 0.x, "pin minor" means `~0.
|
|
815
|
+
package is 0.x, "pin minor" means `~0.6.0` or the exact `0.6.0` — never `^0`** (see
|
|
555
816
|
[Install](#install)). Consumers additionally compare `V1_SCHEMA_DIGEST`: a matching version
|
|
556
817
|
string is not evidence of a matching artifact. `/v1/routes` is draft-tagged and exempt until its
|
|
557
818
|
stability flips.
|
package/dist/fixtures/index.js
CHANGED
|
@@ -15,8 +15,6 @@ const intents_status_response_intent_filled_json_1 = __importDefault(require("./
|
|
|
15
15
|
const intents_status_response_unknown_json_1 = __importDefault(require("./v1/intents-status.response.unknown.json"));
|
|
16
16
|
const intents_status_response_wallet_page_json_1 = __importDefault(require("./v1/intents-status.response.wallet-page.json"));
|
|
17
17
|
const intents_submit_erc_3009_response_job_json_1 = __importDefault(require("./v1/intents-submit-erc-3009.response.job.json"));
|
|
18
|
-
const intents_submit_permit2_request_quote_target_json_1 = __importDefault(require("./v1/intents-submit-permit2.request.quote-target.json"));
|
|
19
|
-
const intents_submit_permit3_request_quote_target_json_1 = __importDefault(require("./v1/intents-submit-permit3.request.quote-target.json"));
|
|
20
18
|
const quotes_create_request_public_swap_json_1 = __importDefault(require("./v1/quotes-create.request.public-swap.json"));
|
|
21
19
|
const quotes_create_response_all_quotes_json_1 = __importDefault(require("./v1/quotes-create.response.all-quotes.json"));
|
|
22
20
|
const quotes_create_response_private_swap_json_1 = __importDefault(require("./v1/quotes-create.response.private-swap.json"));
|
|
@@ -29,8 +27,6 @@ const FIXTURE_BINDINGS = [
|
|
|
29
27
|
bind('quotes.create', 'response', 'public-swap', quotes_create_response_public_swap_json_1.default),
|
|
30
28
|
bind('quotes.create', 'response', 'private-swap', quotes_create_response_private_swap_json_1.default),
|
|
31
29
|
bind('quotes.create', 'response', 'all-quotes', quotes_create_response_all_quotes_json_1.default),
|
|
32
|
-
bind('intents.submit.permit3', 'request', 'quote-target', intents_submit_permit3_request_quote_target_json_1.default),
|
|
33
|
-
bind('intents.submit.permit2', 'request', 'quote-target', intents_submit_permit2_request_quote_target_json_1.default),
|
|
34
30
|
bind('intents.submit.erc-3009', 'response', 'job', intents_submit_erc_3009_response_job_json_1.default),
|
|
35
31
|
bind('deposit-addresses.submit.erc-3009', 'request', 'deposit-address-target', deposit_addresses_submit_erc_3009_request_deposit_address_target_json_1.default),
|
|
36
32
|
bind('deposit-addresses.submit.erc-2612', 'request', 'deposit-address-target', deposit_addresses_submit_erc_2612_request_deposit_address_target_json_1.default),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":";;;;;;AACA,+GAAgE;AAChE,mJAAuF;AACvF,qJAAyF;AACzF,yIAA2E;AAC3E,uLAAsG;AACtG,uLAAsG;AACtG,qIAA8E;AAC9E,iIAA2E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a,GAAI,IAAI,CAAC,SAAoC,IAAI,QAAQ,CAAC;IAC7E,IAAI,aAAa,KAAK,iBAAiB,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,mDAAmD;YACjD,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,iBAAiB;YAC9E,GAAG,iBAAiB,eAAe,aAAa,EAAE,CACrD,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QACjF,MAAM,IAAI,KAAK,CACb,kDAAkD;YAChD,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAClE,CAAC;IACJ,CAAC;IACD,OAAO,IAA4B,CAAC;AACtC,CAAC;AAEY,QAAA,WAAW,GAAyB,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { generateOpenApiDocument, STABLE_TAG } from './openapi';
|
|
|
3
3
|
export type { V1Fixture } from './testing';
|
|
4
4
|
export { assertMatchesV1Schema, loadV1Fixtures } from './testing';
|
|
5
5
|
export * as v1 from './v1';
|
|
6
|
-
export type { LegacyCodeRef, V1Chain, V1ChainType, V1DepositAddress, V1DepositAddressChainStatus, V1DepositAddressCreateRequest, V1DepositAddressCreateResponse, V1DepositAddressKind, V1DestinationCall, V1ErrorCode, V1ErrorDefinition, V1Execution, V1Fee, V1FeeKind, V1FeeToken, V1FundingTransaction, V1GaslessJob, V1GaslessJobStatus, V1GaslessSubState, V1GaslessSubStatus, V1Guarantee, V1IntentCall, V1IntentReward, V1IntentRoute, V1IntentTokenAmount, V1ProblemBody, V1QuoteCore, V1QuoteRequest, V1QuoteResponse, V1RankedQuoteEntry, V1RelatedIntent, V1RelatedIntentRole, V1SolverIdentity, V1StatusEntry, V1StatusType, V1Step, V1StepKind, V1StepLeg, V1SvmAccountMeta, V1SvmInstruction, V1SwapType, V1TokenEntry, V1Visibility, } from './v1/types';
|
|
6
|
+
export type { LegacyCodeRef, V1Chain, V1ChainType, V1DepositAddress, V1DepositAddressChainStatus, V1DepositAddressCreateRequest, V1DepositAddressCreateResponse, V1DepositAddressKind, V1DestinationCall, V1ErrorCode, V1ErrorDefinition, V1Execution, V1Fee, V1FeeKind, V1FeeToken, V1FundingTransaction, V1GaslessJob, V1GaslessJobStatus, V1GaslessSubState, V1GaslessSubStatus, V1Guarantee, V1IntentCall, V1IntentReward, V1IntentRoute, V1IntentTokenAmount, V1ProblemBody, V1QuoteCore, V1QuoteRequest, V1QuoteResponse, V1RankedQuoteEntry, V1RelatedIntent, V1RelatedIntentRole, V1SolverIdentity, V1StatusEntry, V1StatusStep, V1StatusStepType, V1StatusTokenAmount, V1StatusTxDetail, V1StatusTxRef, V1StatusType, V1Step, V1StepKind, V1StepLeg, V1SvmAccountMeta, V1SvmInstruction, V1SwapType, V1TokenEntry, V1Visibility, } from './v1/types';
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -5,3 +5,5 @@ export declare function assertMatchesV1Schema(endpointId: V1EndpointId, payload:
|
|
|
5
5
|
direction?: 'request' | 'response';
|
|
6
6
|
}): void;
|
|
7
7
|
export declare function loadV1Fixtures(): readonly V1Fixture[];
|
|
8
|
+
export declare const SIDE_EFFECT_SKIP_REASON = "sideEffect fixture \u2014 covered by flow E2Es";
|
|
9
|
+
export declare const DRAFT_SKIP_REASON = "draft endpoint (x-stability: draft) \u2014 not served at launch";
|
package/dist/testing/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DRAFT_SKIP_REASON = exports.SIDE_EFFECT_SKIP_REASON = void 0;
|
|
3
4
|
exports.assertMatchesV1Schema = assertMatchesV1Schema;
|
|
4
5
|
exports.loadV1Fixtures = loadV1Fixtures;
|
|
5
6
|
const zod_1 = require("zod");
|
|
@@ -24,4 +25,6 @@ function assertMatchesV1Schema(endpointId, payload, opts = {}) {
|
|
|
24
25
|
function loadV1Fixtures() {
|
|
25
26
|
return fixtures_1.V1_FIXTURES;
|
|
26
27
|
}
|
|
28
|
+
exports.SIDE_EFFECT_SKIP_REASON = 'sideEffect fixture — covered by flow E2Es';
|
|
29
|
+
exports.DRAFT_SKIP_REASON = 'draft endpoint (x-stability: draft) — not served at launch';
|
|
27
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";;;AA0BA,sDAqBC;AAED,wCAEC;AAnDD,6BAAwB;AAExB,0CAAqD;AACrD,uDAA4F;AAY5F,MAAM,WAAW,GAA+C,uBAAY,CAAC;AAW7E,SAAgB,qBAAqB,CACnC,UAAwB,EACxB,OAAgB,EAChB,OAA+C,EAAE;IAEjD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC;IAC/C,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,4BAA4B,MAAM,CAAC,UAAU,CAAC,iBAAiB,SAAS,KAAK;YAC3E,cAAc,MAAM,CAAC,IAAI,CAAC,uBAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvD,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAA0B,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC3F,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,WAAW,SAAS,SAAS,CAAC,CAAC;IACzE,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,0BAA0B,UAAU,IAAI,SAAS,aAAa,OAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC9F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAgB,cAAc;IAC5B,OAAO,sBAAW,CAAC;AACrB,CAAC;AASY,QAAA,uBAAuB,GAAG,2CAA2C,CAAC;AACtE,QAAA,iBAAiB,GAAG,4DAA4D,CAAC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const CHAINS_LIST_QUERY_SHAPE: {
|
|
3
|
+
chainId: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
4
|
+
};
|
|
5
|
+
export declare const ChainsListQuerySchema: z.ZodObject<{
|
|
6
|
+
chainId: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type ChainsListQuery = z.infer<typeof ChainsListQuerySchema>;
|
|
2
9
|
export declare const ChainContractsSchema: z.ZodObject<{
|
|
3
10
|
portal: z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodString]>, z.ZodString]>;
|
|
4
11
|
executor: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodString]>, z.ZodString]>>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChainsResponseSchema = exports.V1LimitsSchema = exports.ChainSchema = exports.ChainContractsSchema = void 0;
|
|
3
|
+
exports.ChainsResponseSchema = exports.V1LimitsSchema = exports.ChainSchema = exports.ChainContractsSchema = exports.ChainsListQuerySchema = exports.CHAINS_LIST_QUERY_SHAPE = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const enums_1 = require("../enums");
|
|
6
6
|
const primitives_1 = require("../primitives");
|
|
7
7
|
const status_1 = require("./status");
|
|
8
|
+
exports.CHAINS_LIST_QUERY_SHAPE = {
|
|
9
|
+
chainId: primitives_1.ChainIdParam.optional(),
|
|
10
|
+
};
|
|
11
|
+
exports.ChainsListQuerySchema = zod_1.z.object(exports.CHAINS_LIST_QUERY_SHAPE);
|
|
8
12
|
exports.ChainContractsSchema = zod_1.z.looseObject({
|
|
9
13
|
portal: primitives_1.AnyAddress,
|
|
10
14
|
executor: primitives_1.AnyAddress.nullable(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../../src/v1/endpoints/chains.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,oCAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../../src/v1/endpoints/chains.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,oCAAiE;AACjE,8CAAkE;AAClE,qCAA8C;AAejC,QAAA,uBAAuB,GAAG;IACrC,OAAO,EAAE,yBAAY,CAAC,QAAQ,EAAE;CACjC,CAAC;AAEW,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC;AAM1D,QAAA,oBAAoB,GAAG,OAAC,CAAC,WAAW,CAAC;IAChD,MAAM,EAAE,uBAAU;IAMlB,QAAQ,EAAE,uBAAU,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAEU,QAAA,WAAW,GAAG,OAAC,CAAC,WAAW,CAAC;IACvC,OAAO,EAAE,oBAAO;IAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IASvB,WAAW,EAAE,uBAAU;IAEvB,IAAI,EAAE,iBAAS;IACf,QAAQ,EAAE,qBAAa;IAEvB,MAAM,EAAE,mBAAW;IACnB,SAAS,EAAE,4BAAoB;CAChC,CAAC,CAAC;AAwCU,QAAA,cAAc,GAAG,OAAC,CAAC,WAAW,CAAC;IAC1C,MAAM,EAAE,2BAAkB;CAC3B,CAAC,CAAC;AAGU,QAAA,oBAAoB,GAAG,OAAC,CAAC,WAAW,CAAC;IAChD,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,mBAAW,CAAC;IAC5B,MAAM,EAAE,sBAAc,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC"}
|
|
@@ -80,7 +80,7 @@ exports.DEPOSIT_ADDRESS_LOOKUP_QUERY_SHAPE = {
|
|
|
80
80
|
depositAddress: primitives_1.EvmAddress.optional(),
|
|
81
81
|
depositor: primitives_1.EvmAddress.optional(),
|
|
82
82
|
destinationAddress: primitives_1.AnyAddress.optional(),
|
|
83
|
-
chainId:
|
|
83
|
+
chainId: primitives_1.ChainIdParam.optional(),
|
|
84
84
|
kind: exports.DepositAddressKind.optional(),
|
|
85
85
|
...status_1.PagingFields,
|
|
86
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit-addresses.js","sourceRoot":"","sources":["../../../src/v1/endpoints/deposit-addresses.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"deposit-addresses.js","sourceRoot":"","sources":["../../../src/v1/endpoints/deposit-addresses.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,8CAQuB;AACvB,qCAAiE;AAepD,QAAA,qBAAqB,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,eAAe,CAAU,CAAC;AACxE,QAAA,kBAAkB,GAAG,OAAC,CAAC,IAAI,CAAC,6BAAqB,CAAC,CAAC;AAkBnD,QAAA,iCAAiC,GAAG,OAAC,CAAC,kBAA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,GAAG;IAChD,cAAc,EAAE,uBAAU,CAAC,QAAQ,EAAE;IACrC,SAAS,EAAE,uBAAU,CAAC,QAAQ,EAAE;IAChC,kBAAkB,EAAE,uBAAU,CAAC,QAAQ,EAAE;IAGzC,OAAO,EAAE,yBAAY,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,0BAAkB,CAAC,QAAQ,EAAE;IACnC,GAAG,qBAAY;CAChB,CAAC;AAEW,QAAA,+BAA+B,GAAG,OAAC;KAC7C,MAAM,CAAC,0CAAkC,CAAC;KAC1C,WAAW,CAAC,IAAA,gCAAuB,EAAC,8BAA8B,CAAC,CAAC,CAAC;AAE3D,QAAA,kCAAkC,GAAG,OAAC,CAAC,WAAW,CAAC;IAC9D,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC;CACvC,CAAC,CAAC"}
|
|
@@ -6,6 +6,8 @@ export declare const DestinationCallSchema: z.ZodObject<{
|
|
|
6
6
|
tokenOut: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodString]>, z.ZodString]>>;
|
|
7
7
|
gasLimit: z.ZodOptional<z.ZodString>;
|
|
8
8
|
}, z.core.$strict>;
|
|
9
|
+
export declare const SLIPPAGE_MIN = 0.0001;
|
|
10
|
+
export declare const SLIPPAGE_MAX = 1;
|
|
9
11
|
export declare const QuoteRequestSchema: z.ZodObject<{
|
|
10
12
|
swapType: z.ZodEnum<{
|
|
11
13
|
custom: "custom";
|
|
@@ -40,7 +42,6 @@ export declare const QuoteRequestSchema: z.ZodObject<{
|
|
|
40
42
|
public: "public";
|
|
41
43
|
private: "private";
|
|
42
44
|
}>>;
|
|
43
|
-
maxCallDataSize: z.ZodOptional<z.ZodNumber>;
|
|
44
45
|
allQuotes: z.ZodOptional<z.ZodBoolean>;
|
|
45
46
|
}, z.core.$strict>>;
|
|
46
47
|
}, z.core.$strict>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QUOTE_SIGNATURE_TYPES = exports.QuoteResponseSchema = exports.RankedQuoteEntrySchema = exports.QuoteCoreSchema = exports.ExecutionSchema = exports.IntentRewardSchema = exports.IntentRouteSchema = exports.IntentCallSchema = exports.IntentTokenAmountSchema = exports.FundingTransactionSchema = exports.SvmTransactionSchema = exports.SvmInstructionSchema = exports.SvmAccountMetaSchema = exports.EvmTransactionSchema = exports.SolverIdentitySchema = exports.RelatedIntentSchema = exports.StepSchema = exports.StepLegSchema = exports.FeeSchema = exports.FeeTokenSchema = exports.QuoteRequestSchema = exports.DestinationCallSchema = void 0;
|
|
3
|
+
exports.QUOTE_SIGNATURE_TYPES = exports.QuoteResponseSchema = exports.RankedQuoteEntrySchema = exports.QuoteCoreSchema = exports.ExecutionSchema = exports.IntentRewardSchema = exports.IntentRouteSchema = exports.IntentCallSchema = exports.IntentTokenAmountSchema = exports.FundingTransactionSchema = exports.SvmTransactionSchema = exports.SvmInstructionSchema = exports.SvmAccountMetaSchema = exports.EvmTransactionSchema = exports.SolverIdentitySchema = exports.RelatedIntentSchema = exports.StepSchema = exports.StepLegSchema = exports.FeeSchema = exports.FeeTokenSchema = exports.QuoteRequestSchema = exports.SLIPPAGE_MAX = exports.SLIPPAGE_MIN = exports.DestinationCallSchema = void 0;
|
|
4
4
|
exports.quoteSignaturePayload = quoteSignaturePayload;
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const enums_1 = require("../enums");
|
|
7
7
|
const catalog_1 = require("../errors/catalog");
|
|
8
|
+
const problem_1 = require("../errors/problem");
|
|
8
9
|
const primitives_1 = require("../primitives");
|
|
9
10
|
exports.DestinationCallSchema = zod_1.z.strictObject({
|
|
10
11
|
target: primitives_1.AnyAddress,
|
|
@@ -16,32 +17,48 @@ exports.DestinationCallSchema = zod_1.z.strictObject({
|
|
|
16
17
|
const QuoteRequestOptionsSchema = zod_1.z.strictObject({
|
|
17
18
|
deadlineSec: zod_1.z.number().int().positive().optional(),
|
|
18
19
|
visibility: enums_1.Visibility.optional(),
|
|
19
|
-
maxCallDataSize: zod_1.z.number().int().positive().optional(),
|
|
20
20
|
allQuotes: zod_1.z.boolean().optional(),
|
|
21
21
|
});
|
|
22
|
+
exports.SLIPPAGE_MIN = 0.0001;
|
|
23
|
+
exports.SLIPPAGE_MAX = 1;
|
|
22
24
|
const SLIPPAGE_RANGE_MESSAGE = `${(0, catalog_1.getErrorDefinition)('slippage-out-of-bounds').title} (error code: slippage-out-of-bounds)`;
|
|
25
|
+
const SLIPPAGE_DESCRIPTION = 'Decimal fraction of the destination amount: 0.005 = 0.5%. Range 0.0001-1; a percent-style ' +
|
|
26
|
+
'0.5 would mean 50%.';
|
|
23
27
|
exports.QuoteRequestSchema = zod_1.z
|
|
24
28
|
.strictObject({
|
|
25
29
|
swapType: enums_1.SwapType,
|
|
26
30
|
source: zod_1.z.strictObject({
|
|
27
31
|
chainId: primitives_1.ChainId,
|
|
28
32
|
token: primitives_1.AnyAddress,
|
|
29
|
-
amount: primitives_1.
|
|
33
|
+
amount: primitives_1.PositiveUintString.optional(),
|
|
30
34
|
}),
|
|
31
35
|
destination: zod_1.z.strictObject({
|
|
32
36
|
chainId: primitives_1.ChainId,
|
|
33
37
|
token: primitives_1.AnyAddress,
|
|
34
|
-
amount: primitives_1.
|
|
38
|
+
amount: primitives_1.PositiveUintString.optional(),
|
|
35
39
|
recipient: primitives_1.AnyAddress.optional(),
|
|
36
40
|
calls: zod_1.z.array(exports.DestinationCallSchema).optional(),
|
|
37
41
|
}),
|
|
38
42
|
funder: primitives_1.AnyAddress,
|
|
39
43
|
refundRecipient: primitives_1.AnyAddress.optional(),
|
|
40
|
-
slippage: zod_1.z
|
|
44
|
+
slippage: zod_1.z
|
|
45
|
+
.number()
|
|
46
|
+
.describe(SLIPPAGE_DESCRIPTION)
|
|
47
|
+
.meta({ minimum: exports.SLIPPAGE_MIN, maximum: exports.SLIPPAGE_MAX })
|
|
48
|
+
.optional(),
|
|
41
49
|
dappId: primitives_1.DappId.optional(),
|
|
42
50
|
options: QuoteRequestOptionsSchema.optional(),
|
|
43
51
|
})
|
|
44
52
|
.superRefine((req, ctx) => {
|
|
53
|
+
if (req.slippage !== undefined &&
|
|
54
|
+
(req.slippage < exports.SLIPPAGE_MIN || req.slippage > exports.SLIPPAGE_MAX)) {
|
|
55
|
+
ctx.addIssue({
|
|
56
|
+
code: 'custom',
|
|
57
|
+
path: ['slippage'],
|
|
58
|
+
params: (0, problem_1.v1IssueParams)('slippage-out-of-bounds'),
|
|
59
|
+
message: SLIPPAGE_RANGE_MESSAGE,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
45
62
|
const hasCalls = (req.destination.calls?.length ?? 0) > 0;
|
|
46
63
|
if (req.swapType === 'custom' && !hasCalls) {
|
|
47
64
|
ctx.addIssue({
|
|
@@ -80,6 +97,13 @@ exports.QuoteRequestSchema = zod_1.z
|
|
|
80
97
|
message: `${req.swapType} requires source.amount`,
|
|
81
98
|
});
|
|
82
99
|
}
|
|
100
|
+
if (!(0, primitives_1.addressFamiliesCanAgree)(req.funder, req.source.token)) {
|
|
101
|
+
ctx.addIssue({
|
|
102
|
+
code: 'custom',
|
|
103
|
+
path: ['funder'],
|
|
104
|
+
message: 'funder is not from the same address family as source.token',
|
|
105
|
+
});
|
|
106
|
+
}
|
|
83
107
|
});
|
|
84
108
|
exports.FeeTokenSchema = zod_1.z.looseObject({
|
|
85
109
|
chainId: primitives_1.ChainId,
|
|
@@ -197,7 +221,10 @@ exports.QuoteCoreSchema = zod_1.z.looseObject({
|
|
|
197
221
|
symbol: zod_1.z.string().nullable(),
|
|
198
222
|
decimals: zod_1.z.number().int().nullable(),
|
|
199
223
|
}),
|
|
200
|
-
slippage: zod_1.z
|
|
224
|
+
slippage: zod_1.z
|
|
225
|
+
.number()
|
|
226
|
+
.min(0)
|
|
227
|
+
.describe('Tolerance actually bound into destination.minAmountOut, as a decimal fraction'),
|
|
201
228
|
fees: zod_1.z.array(exports.FeeSchema),
|
|
202
229
|
steps: zod_1.z.array(exports.StepSchema),
|
|
203
230
|
relatedIntents: zod_1.z.array(exports.RelatedIntentSchema),
|