mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-06-15 00:49:53 +08:00
* chore: function structures * chore: return accepted and streamed microblocks on socket.io block updates * chore: move ws-rpc and socket-io to ws/ directory * feat: add individual tx updates to socket.io * fix: use updated microblock txs query function * chore: add new schemas for block, microblock, mempool rpcs * feat: handle new block, microblock, mempool websocket updates * fix: socket.io type imports * chore: add test for websocket mempool update * chore: add test for block updates * chore: add microblock update test * chore: remove additional properties from rpc schemas * chore: add client support for new websocket events
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import type {
|
|
AddressStxBalanceResponse,
|
|
AddressTransactionWithTransfers,
|
|
Block,
|
|
Microblock,
|
|
Transaction,
|
|
MempoolTransaction
|
|
} from '..';
|
|
|
|
export type AddressTransactionTopic = `address-transaction:${string}`;
|
|
export type AddressStxBalanceTopic = `address-stx-balance:${string}`;
|
|
export type TransactionTopic = `transaction:${string}`;
|
|
export type Topic =
|
|
| 'block'
|
|
| 'microblock'
|
|
| 'mempool'
|
|
| AddressTransactionTopic
|
|
| AddressStxBalanceTopic
|
|
| TransactionTopic;
|
|
|
|
export interface ClientToServerMessages {
|
|
subscribe: (topic: Topic | Topic[], callback: (error: string | null) => void) => void;
|
|
unsubscribe: (...topic: Topic[]) => void;
|
|
}
|
|
|
|
export interface ServerToClientMessages {
|
|
block: (block: Block) => void;
|
|
microblock: (microblock: Microblock) => void;
|
|
mempool: (transaction: MempoolTransaction) => void;
|
|
transaction: (transaction: Transaction | MempoolTransaction) => void;
|
|
|
|
// @ts-ignore scheduled for support in TS v4.3 https://github.com/microsoft/TypeScript/pull/26797
|
|
[key: AddressTransactionTopic]: (address: string, stxBalance: AddressTransactionWithTransfers) => void;
|
|
'address-transaction': (address: string, tx: AddressTransactionWithTransfers) => void;
|
|
|
|
// @ts-ignore scheduled for support in TS v4.3 https://github.com/microsoft/TypeScript/pull/26797
|
|
[key: AddressStxBalanceTopic]: (address: string, stxBalance: AddressStxBalanceResponse) => void;
|
|
'address-stx-balance': (address: string, stxBalance: AddressStxBalanceResponse) => void;
|
|
}
|