-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pagination and query param parsing bugs
* feat: route splitting between express and fastify * feat: refactor `/extended/v1/tx/*` endpoints to fastify * feat: refactor `/extended/v1/stx_supply/*` endpoints to fastify * feat: refactor `/extended/v1/info/*` endpoints to fastify * feat: refactor `/extended/v1/tokens/*` endpoints to fastify * feat: refactor `/extended/v1/tokens/*` endpoints to fastify * feat: refactor `/extended/v1/contract/*` endpoints to fastify * feat: refactor `/extended/v1/fee_rate/*` endpoints to fastify * feat: refactor `/extended/v1/microblock/*` endpoints to fastify * feat: refactor `/extended/v1/block/*` endpoints to fastify * feat: refactor `/extended/v1/burnchain/*` endpoints to fastify * feat: refactor `/extended/v1/address/*` endpoints to fastify * feat: refactor `/extended/v1/search/*` endpoints to fastify * feat: refactor `/extended/v1/pox*` endpoints to fastify * feat: refactor `/extended/v1/faucets/*` endpoints to fastify * feat: refactor `/extended/v1/debug/*` endpoints to fastify * feat: refactor `/extended/v2/blocks/*` and `/extended/v2/burn-blocks/*` endpoints to fastify * feat: refactor `/extended/v2/smart-contracts/*` endpoints to fastify * feat: refactor `/extended/v2/mempool/*` endpoints to fastify * feat: refactor `/extended/v2/pox/*` endpoints to fastify * feat: refactor `/extended/v2/addresses/*` endpoints to fastify * feat: refactor `/v1/names/*` endpoints to fastify * feat: refactor `/v1/namespaces/*` endpoints to fastify * feat: refactor `/v1/addresses/*` endpoints to fastify * feat: refactor `/v2/prices/*` endpoints to fastify * feat: refactor core-node RPC proxy (/v2/*) to fastify * chore: remove dead code * feat: openAPI spec generation from fastify routes * chore: remove references to legacy generated types * docs: missing openapi tag on burn-blocks route * docs: update docs and client generation scripts * fix: several query params should be optional * fix: only use a GET route for extended status * chore: simpify typing for TransactionSchema and MempoolTransactionSchema * feat: refactor client library * chore: remove dependencies on old generated types * chore: isolate rosetta json schemas and delete the rest * chore: cleanup prometheus metrics * fix: misc tests * test: misc rosetta fixes * fix: batch insert length assertion (#2042) * fix: batch insert length assertion * build: upgrade docker-compose * build: use docker compose * test: misc bns test fixes * test: misc pox fixes * ci: misc fixes * chore: fix unused exports lint * chore: simplify docs and client package.json scripts * feat: refactor event-server from express to fastify * chore: expose more helper types in the client lib * ci: fix client npm lib building * fix: openapi and client support for comma-separated query params * chore: expose more helper types to client lib * ci: fix lint and tests * fix: ensure height-or-hash params are parsed correctly and have correct openapi and client types * docs: client library migration guide * fix: tx event pagination limit * docs: note RPC client library change --------- Co-authored-by: Rafael Cárdenas <rafael@rafaelcr.com>
- Loading branch information
Showing
19 changed files
with
421 additions
and
313 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
## @stacks/blockchain-api-client (<=7.x.x) → (8.x.x) | ||
|
||
## Breaking Changes | ||
|
||
This library is now generated with [openapi-typescript](https://openapi-ts.dev/openapi-fetch/) rather than [swagger-codegen](https://github.com/swagger-api/swagger-codegen). Several types which previously presented as the `any` type are now fixed, and the `@stacks/stacks-blockchain-api-types` package is no longer needed. | ||
|
||
|
||
This repo no longer includes a schema for the Stacks Blockchain RPC interface. An alternative client library for the RPC interface can be found at https://github.com/hirosystems/stacks.js/pull/1737. | ||
|
||
#### Configuration & Middleware | ||
|
||
```ts | ||
// old: | ||
import { TransactionsApi, Configuration } from '@stacks/blockchain-api-client'; | ||
const client = new TransactionsApi(new Configuration({ | ||
basePath: 'https://api.mainnet.hiro.so', | ||
middleware: [{ | ||
pre({url, init}) { | ||
init.headers = new Headers(init.headers); | ||
init.headers.set('x-custom-header', 'custom-value'); | ||
return Promise.resolve({ url, init }); | ||
} | ||
}] | ||
})); | ||
|
||
|
||
// new: | ||
import { createClient } from '@stacks/blockchain-api-client'; | ||
const client = createClient({ | ||
baseUrl: 'https://api.mainnet.hiro.so' | ||
}); | ||
client.use({ | ||
onRequest({request}) { | ||
request.headers.set('x-custom-header', 'custom-value'); | ||
return request; | ||
} | ||
}); | ||
``` | ||
|
||
#### Performing Requests | ||
|
||
```ts | ||
// old: | ||
const blockTxs = await client.getTransactionsByBlock({ | ||
heightOrHash: 2000, | ||
limit: 20, | ||
offset: 100 | ||
}); | ||
console.log('Block transactions:', blockTxs); | ||
|
||
// new: | ||
const { data: blockTxs } = await client.GET('/extended/v2/blocks/{height_or_hash}/transactions', { | ||
params: { | ||
path: { height_or_hash: 2000 }, | ||
query: { limit: 20, offset: 100 }, | ||
} | ||
}); | ||
console.log('Block transactions:', blockTxs); | ||
``` | ||
|
||
#### Referencing Types | ||
|
||
```ts | ||
// old: | ||
import { MempoolTransactionStatsResponse } from '@stacks/blockchain-api-client'; | ||
let response: MempoolTransactionStatsResponse; | ||
response = await client.getMempoolTransactionStats(); | ||
|
||
// new: | ||
import { OperationResponse } from '@stacks/blockchain-api-client'; | ||
let response: OperationResponse['/extended/v1/tx/mempool/stats']; | ||
response = (await client.GET('/extended/v1/tx/mempool/stats')).data; | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.