Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c330f18
feat: route splitting between express and fastify
zone117x Jul 29, 2024
93e9aae
feat: refactor `/extended/v1/tx/*` endpoints to fastify
zone117x Jul 30, 2024
3bf7800
feat: refactor `/extended/v1/stx_supply/*` endpoints to fastify
zone117x Jul 31, 2024
07df5d1
feat: refactor `/extended/v1/info/*` endpoints to fastify
zone117x Jul 31, 2024
802f298
feat: refactor `/extended/v1/tokens/*` endpoints to fastify
zone117x Jul 31, 2024
ec00767
feat: refactor `/extended/v1/tokens/*` endpoints to fastify
zone117x Jul 31, 2024
a38386e
feat: refactor `/extended/v1/contract/*` endpoints to fastify
zone117x Aug 1, 2024
c3cb5a1
feat: refactor `/extended/v1/fee_rate/*` endpoints to fastify
zone117x Aug 1, 2024
7687bca
feat: refactor `/extended/v1/microblock/*` endpoints to fastify
zone117x Aug 1, 2024
a6a2079
feat: refactor `/extended/v1/block/*` endpoints to fastify
zone117x Aug 1, 2024
bdeee2f
feat: refactor `/extended/v1/burnchain/*` endpoints to fastify
zone117x Aug 1, 2024
67eeb65
feat: refactor `/extended/v1/address/*` endpoints to fastify
zone117x Aug 1, 2024
6c1da94
feat: refactor `/extended/v1/search/*` endpoints to fastify
zone117x Aug 1, 2024
b8d0f62
feat: refactor `/extended/v1/pox*` endpoints to fastify
zone117x Aug 1, 2024
1121095
feat: refactor `/extended/v1/faucets/*` endpoints to fastify
zone117x Aug 2, 2024
fd68b75
feat: refactor `/extended/v1/debug/*` endpoints to fastify
zone117x Aug 2, 2024
e1c1714
feat: refactor `/extended/v2/blocks/*` and `/extended/v2/burn-blocks/…
zone117x Aug 2, 2024
41bb0e0
feat: refactor `/extended/v2/smart-contracts/*` endpoints to fastify
zone117x Aug 2, 2024
9220465
feat: refactor `/extended/v2/mempool/*` endpoints to fastify
zone117x Aug 2, 2024
40924ea
feat: refactor `/extended/v2/pox/*` endpoints to fastify
zone117x Aug 2, 2024
705a589
feat: refactor `/extended/v2/addresses/*` endpoints to fastify
zone117x Aug 2, 2024
5fd969d
feat: refactor `/v1/names/*` endpoints to fastify
zone117x Aug 5, 2024
d6dfbe4
feat: refactor `/v1/namespaces/*` endpoints to fastify
zone117x Aug 5, 2024
ddb09fe
feat: refactor `/v1/addresses/*` endpoints to fastify
zone117x Aug 5, 2024
2cbb658
feat: refactor `/v2/prices/*` endpoints to fastify
zone117x Aug 5, 2024
9c446fc
feat: refactor core-node RPC proxy (/v2/*) to fastify
zone117x Aug 5, 2024
15fb340
chore: remove dead code
zone117x Aug 5, 2024
9299727
feat: openAPI spec generation from fastify routes
zone117x Aug 5, 2024
e90b88c
chore: remove references to legacy generated types
zone117x Aug 5, 2024
5cef91c
docs: missing openapi tag on burn-blocks route
zone117x Aug 7, 2024
9e9a5b2
docs: update docs and client generation scripts
zone117x Aug 7, 2024
d98091e
fix: several query params should be optional
zone117x Aug 7, 2024
1aeefb6
fix: only use a GET route for extended status
zone117x Aug 7, 2024
3c27cb1
chore: simpify typing for TransactionSchema and MempoolTransactionSchema
zone117x Aug 7, 2024
a40c41d
feat: refactor client library
zone117x Aug 7, 2024
ab33e74
chore: remove dependencies on old generated types
zone117x Aug 7, 2024
2fa84ee
chore: isolate rosetta json schemas and delete the rest
zone117x Aug 7, 2024
121550c
chore: cleanup prometheus metrics
zone117x Aug 8, 2024
0dfe3e1
fix: misc tests
zone117x Aug 8, 2024
84ad016
test: misc rosetta fixes
zone117x Aug 8, 2024
994640f
fix: batch insert length assertion (#2042)
rafaelcr Aug 5, 2024
e24ad9b
test: misc bns test fixes
zone117x Aug 8, 2024
2cb85e8
test: misc pox fixes
zone117x Aug 8, 2024
e04d69a
ci: misc fixes
zone117x Aug 8, 2024
90661fc
chore: fix unused exports lint
zone117x Aug 8, 2024
94e8ffb
chore: simplify docs and client package.json scripts
zone117x Aug 12, 2024
b960a13
feat: refactor event-server from express to fastify
zone117x Aug 12, 2024
5e90a07
chore: expose more helper types in the client lib
zone117x Aug 13, 2024
8b8c585
ci: fix client npm lib building
zone117x Aug 13, 2024
d8b13e2
fix: openapi and client support for comma-separated query params
zone117x Aug 14, 2024
2bbcb29
chore: expose more helper types to client lib
zone117x Aug 14, 2024
918fb4a
ci: fix lint and tests
zone117x Aug 14, 2024
690081d
fix: ensure height-or-hash params are parsed correctly and have corre…
zone117x Aug 14, 2024
08f74e8
docs: client library migration guide
zone117x Aug 14, 2024
936c618
fix: tx event pagination limit
zone117x Aug 15, 2024
cb97800
docs: note RPC client library change
zone117x Aug 15, 2024
4bc8f77
Merge branch 'refactor/fastify-wip' into chore/v8.0.0-beta.1
zone117x Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions client/MIGRATION.md
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;
```
4 changes: 4 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

A JS Client for the Stacks Blockchain API

## Breaking changes from (<=7.x.x) → (8.x.x)

See [MIGRATION.md](./MIGRATION.md) for details.

## Features

This package provides the ability to:
Expand Down
14 changes: 7 additions & 7 deletions client/src/generated/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ export interface operations {
offset?: number;
/** @description Results per page */
limit?: number;
type?: (("coinbase" | "token_transfer" | "smart_contract" | "contract_call" | "poison_microblock" | "tenure_change") | string)[];
type?: ("coinbase" | "token_transfer" | "smart_contract" | "contract_call" | "poison_microblock" | "tenure_change")[];
/**
* @description Include data from unanchored (i.e. unconfirmed) microblocks
* @example true
Expand Down Expand Up @@ -3177,7 +3177,7 @@ export interface operations {
get_tx_list_details: {
parameters: {
query: {
tx_id: (string)[];
tx_id: string[];
/** @description Results per page */
event_limit?: number;
/** @description Result offset */
Expand Down Expand Up @@ -6496,7 +6496,7 @@ export interface operations {
*/
tx_id?: string;
address?: string;
type?: (("smart_contract_log" | "stx_lock" | "stx_asset" | "fungible_token_asset" | "non_fungible_token_asset") | string)[];
type?: ("smart_contract_log" | "stx_lock" | "stx_asset" | "fungible_token_asset" | "non_fungible_token_asset")[];
/** @description Result offset */
offset?: number;
/** @description Results per page */
Expand Down Expand Up @@ -27255,7 +27255,7 @@ export interface operations {
query?: never;
header?: never;
path: {
height_or_hash: "latest" | string;
height_or_hash: "latest" | string | number;
};
cookie?: never;
};
Expand Down Expand Up @@ -27321,7 +27321,7 @@ export interface operations {
};
header?: never;
path: {
height_or_hash: "latest" | string;
height_or_hash: "latest" | string | number;
};
cookie?: never;
};
Expand Down Expand Up @@ -28697,7 +28697,7 @@ export interface operations {
query?: never;
header?: never;
path: {
height_or_hash: "latest" | string;
height_or_hash: "latest" | string | number;
};
cookie?: never;
};
Expand Down Expand Up @@ -28739,7 +28739,7 @@ export interface operations {
};
header?: never;
path: {
height_or_hash: "latest" | string;
height_or_hash: "latest" | string | number;
};
cookie?: never;
};
Expand Down
1 change: 1 addition & 0 deletions client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './common';
export * from './socket-io';
export * from './ws';
export type * from './types';
export * from 'openapi-fetch';
31 changes: 21 additions & 10 deletions client/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import type { operations } from "./generated/schema";
import type { operations, paths } from './generated/schema';

type Extract200Response<T> = T extends { 200: infer R } ? R : never;
type ExtractOperationResponse<T extends keyof operations> = Extract200Response<operations[T]['responses']> extends { content: { 'application/json': infer U } } ? U : never;
type PathResponse<T extends keyof paths> = paths[T]['get'] extends { responses: infer R } ? Extract200Response<R> extends { content: { 'application/json': infer U } } ? U : never : never;

export type OperationResponse = {
[K in keyof operations]: ExtractOperationResponse<K>;
} & {
[P in keyof paths]: PathResponse<P>;
};

export type Transaction = OperationResponse['get_transaction_list']['results'][number];
export type MempoolTransaction = OperationResponse['get_mempool_transaction_list']['results'][number];
export type Block = OperationResponse['get_block_by_height'];
export type Microblock = OperationResponse['get_microblock_by_hash'];
export type NakamotoBlock = OperationResponse['get_block'];
export type BurnBlock = OperationResponse['get_burn_blocks']['results'][number];
export type SmartContract = OperationResponse['get_contract_by_id'];
export type AddressTransactionWithTransfers = OperationResponse['get_account_transactions_with_transfers']['results'][number];
export type AddressStxBalanceResponse = OperationResponse['get_account_stx_balance'];

export type Transaction = operations['get_transaction_list']['responses']['200']['content']['application/json']['results'][number];
export type MempoolTransaction = operations['get_mempool_transaction_list']['responses']['200']['content']['application/json']['results'][number];
export type Block = operations['get_block_by_height']['responses']['200']['content']['application/json'];
export type Microblock = operations['get_microblock_by_hash']['responses']['200']['content']['application/json'];
export type NakamotoBlock = operations['get_block']['responses']['200']['content']['application/json'];
export type BurnBlock = operations['get_burn_blocks']['responses']['200']['content']['application/json']['results'][number];
export type SmartContract = operations['get_contract_by_id']['responses']['200']['content']['application/json'];
export type AddressTransactionWithTransfers = operations['get_account_transactions_with_transfers']['responses']['200']['content']['application/json']['results'][number];
export type AddressStxBalanceResponse = operations['get_account_stx_balance']['responses']['200']['content']['application/json'];
export type RpcAddressTxNotificationParams = AddressTransactionWithTransfers & {
address: string;
tx_id: string;
Expand Down
Loading