Repository navigation
Conversation
GET /tokens/{symbolOrAddress} sat beside DELETE /tokens/{address}, and
GET /pools/{tradingPair} beside DELETE /pools/{address}: the same path
shape, with the id meaning something else per verb. A consumer that reads
the route table structurally - a generated client, a drift check - saw
one resource where there were two.
Both pairs now share a name and a meaning. DELETE /tokens/{symbolOrAddress}
resolves a symbol the way GET does and removes the token it names.
/pools/{tradingPairOrAddress}: GET and DELETE take a pool address, or a
trading pair with type (and connector to narrow it); a DELETE by pair
removes the pool only when exactly one matches and otherwise names the
candidates, so a pair that spans fee tiers or connectors never deletes
one at random. type is therefore optional on the query and required only
when the path names a pair. No path changes; a client sending an address
today sends the same request.
openapi.json regenerated.
Fixes hummingbot#689.
|
…r is exactly two segments
GET resolves a symbol before an address, the right order for a read; a
delete must never remove a token whose symbol happens to equal the
address that was named, so DELETE /tokens/{symbolOrAddress} matches the
address first. And a three-segment id is not the pair of its first two:
both pool routes require exactly BASE-QUOTE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting this PR, please make sure:
A description of the changes proposed in the pull request:
Fixes #689, taking option 1 from the issue: one parameter name per path, with the parameter genuinely meaning the same thing under both verbs.
/tokens/{}GET {symbolOrAddress}·DELETE {address}GETandDELETE {symbolOrAddress}/pools/{}GET {tradingPair}·DELETE {address}GETandDELETE {tradingPairOrAddress}DELETE /tokens/{symbolOrAddress}resolves the id against the token list and removes the token it names; an unknown symbol or address is a 404 before anything is touched. One deliberate difference fromGET: the address is matched before the symbol.GETtries the symbol first, the right order for a read, but a delete must never remove a token whose symbol happens to equal the address that was named (symbols are only required to be non-empty). The message names both symbol and address of what was removed.BASE-QUOTE; a three-segment id is not the pair of its first two and is refused rather than truncated.GET /pools/{tradingPairOrAddress}tries the id as a pool address first (getPoolByAddress, notypeneeded) and otherwise as a trading pair withtype(andconnectorto narrow it), exactly as before.typebecomes optional onGetPoolRequestSchemaand is required by the handler only when the path names a pair.DELETE /pools/{tradingPairOrAddress}takes an address as today, or a pair: a pair can name several pools (fee tiers, connectors), and a delete must name one, so it removes the pool only when exactly one matches and otherwise answers 400 listing the candidates by connector and address. Nothing is ever deleted at random.No path changes: a client that sends an address today sends the same request and gets the same answer.
operation-ids.tsand the committedopenapi.jsonare updated (pnpm generate:openapi), so thetest/specchecks that pin the route table pass against the new names.Tests performed by the developer:
test/tokens/tokens.routes.test.ts: a token removed by address, by symbol, by address when another token's symbol equals that address (the named one goes, not the impostor), and a 404 for an unknown id withremoveTokennever called.test/pools/pools.routes.test.ts:GETby address withouttype;GETby pair withouttypeis a 400 naming the missing field;DELETEby pair with one match removes that address; with two matches answers 400 naming both and removes nothing; by pair withouttypeis a 400;SOL-USDC-EXTRAis a 404 with nothing listed or removed; the existing address cases unchanged.test/spec,test/pools,test/tokens: 306 passed.pnpm typecheck, eslint and prettier clean on the changed files.Tips for QA testing:
DELETE /tokens/USDC?chainNetwork=ethereum-mainnetnow removes USDC (was a 404: "Token with address USDC not found").GET /pools/<address>?chainNetwork=solana-mainnet-betareturns that pool withouttype.DELETE /pools/SOL-USDC?chainNetwork=solana-mainnet-beta&type=clmmremoves the one SOL-USDC CLMM pool, or lists the candidates when there are several. The generated spec shows one parameter per path under/tokens/{symbolOrAddress}and/pools/{tradingPairOrAddress}.