@stacks/blockchain-api-client 8.0.3 → 8.1.0-beta.2

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/lib/types.d.ts ADDED
@@ -0,0 +1,119 @@
1
+ import type { operations, paths } from './generated/schema';
2
+
3
+ type Extract200Response<T> = T extends { 200: infer R } ? R : never;
4
+ type ExtractOperationResponse<T extends keyof operations> = Extract200Response<operations[T]['responses']> extends { content: { 'application/json': infer U } } ? U : never;
5
+ type PathResponse<T extends keyof paths> = paths[T]['get'] extends { responses: infer R } ? Extract200Response<R> extends { content: { 'application/json': infer U } } ? U : never : never;
6
+
7
+ export type OperationResponse = {
8
+ [K in keyof operations]: ExtractOperationResponse<K>;
9
+ } & {
10
+ [P in keyof paths]: PathResponse<P>;
11
+ };
12
+
13
+ export type Transaction = OperationResponse['get_transaction_list']['results'][number];
14
+ export type MempoolTransaction = OperationResponse['get_mempool_transaction_list']['results'][number];
15
+ export type Block = OperationResponse['get_block_by_height'];
16
+ export type Microblock = OperationResponse['get_microblock_by_hash'];
17
+ export type NakamotoBlock = OperationResponse['get_block'];
18
+ export type BurnBlock = OperationResponse['get_burn_blocks']['results'][number];
19
+ export type SmartContract = OperationResponse['get_contract_by_id'];
20
+ export type AddressTransactionWithTransfers = OperationResponse['get_account_transactions_with_transfers']['results'][number];
21
+ export type AddressStxBalanceResponse = OperationResponse['get_account_stx_balance'];
22
+
23
+ export type RpcAddressTxNotificationParams = AddressTransactionWithTransfers & {
24
+ address: string;
25
+ tx_id: string;
26
+ tx_status: Transaction['tx_status'];
27
+ tx_type: Transaction['tx_type'];
28
+ };
29
+ export type RpcAddressBalanceNotificationParams = AddressStxBalanceResponse & {
30
+ address: string;
31
+ };
32
+ export type NftEvent = {
33
+ sender?: string;
34
+ recipient?: string;
35
+ asset_identifier: string;
36
+ asset_event_type: string;
37
+ value: {
38
+ hex: string;
39
+ repr: string;
40
+ };
41
+ tx_id: string;
42
+ tx_index: number;
43
+ block_height: number;
44
+ event_index: number;
45
+ };
46
+ export type RpcTxUpdateSubscriptionParams = {
47
+ event: "tx_update";
48
+ tx_id: string;
49
+ };
50
+ export type RpcBlockSubscriptionParams = {
51
+ event: "block";
52
+ };
53
+ export type RpcMicroblockSubscriptionParams = {
54
+ event: "microblock";
55
+ };
56
+ export type RpcMempoolSubscriptionParams = {
57
+ event: "mempool";
58
+ };
59
+ export type RpcAddressTxSubscriptionParams = {
60
+ event: "address_tx_update";
61
+ address: string;
62
+ };
63
+ export type RpcAddressBalanceSubscriptionParams = {
64
+ event: "address_balance_update";
65
+ address: string;
66
+ };
67
+ export type RpcNftEventSubscriptionParams = {
68
+ event: "nft_event";
69
+ };
70
+ export type RpcNftAssetEventSubscriptionParams = {
71
+ event: "nft_asset_event";
72
+ asset_identifier: string;
73
+ value: string;
74
+ };
75
+ export type RpcNftCollectionEventSubscriptionParams = {
76
+ event: "nft_collection_event";
77
+ asset_identifier: string;
78
+ };
79
+ export type RpcSubscriptionType =
80
+ | "tx_update"
81
+ | "address_tx_update"
82
+ | "address_balance_update"
83
+ | "block"
84
+ | "microblock"
85
+ | "mempool"
86
+ | "nft_event"
87
+ | "nft_asset_event"
88
+ | "nft_collection_event";
89
+ export type AddressTransactionTopic = `address-transaction:${string}`;
90
+ export type AddressStxBalanceTopic = `address-stx-balance:${string}`;
91
+ export type TransactionTopic = `transaction:${string}`;
92
+ export type NftAssetEventTopic = `nft-asset-event:${string}+${string}`;
93
+ export type NftCollectionEventTopic = `nft-collection-event:${string}`;
94
+ export type Topic =
95
+ | 'block'
96
+ | 'microblock'
97
+ | 'mempool'
98
+ | 'nft-event'
99
+ | AddressTransactionTopic
100
+ | AddressStxBalanceTopic
101
+ | TransactionTopic
102
+ | NftAssetEventTopic
103
+ | NftCollectionEventTopic;
104
+ export interface ClientToServerMessages {
105
+ subscribe: (topic: Topic | Topic[], callback: (error: string | null) => void) => void;
106
+ unsubscribe: (...topic: Topic[]) => void;
107
+ }
108
+
109
+ export interface ServerToClientMessages {
110
+ block: (block: Block) => void;
111
+ microblock: (microblock: Microblock) => void;
112
+ mempool: (transaction: MempoolTransaction) => void;
113
+ 'nft-event': (event: NftEvent) => void;
114
+ [key: TransactionTopic]: (transaction: Transaction | MempoolTransaction) => void;
115
+ [key: NftAssetEventTopic]: (assetIdentifier: string, value: string, event: NftEvent) => void;
116
+ [key: NftCollectionEventTopic]: (assetIdentifier: string, event: NftEvent) => void;
117
+ [key: AddressTransactionTopic]: (address: string, stxBalance: AddressTransactionWithTransfers) => void;
118
+ [key: AddressStxBalanceTopic]: (address: string, stxBalance: AddressStxBalanceResponse) => void;
119
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacks/blockchain-api-client",
3
- "version": "8.0.3",
3
+ "version": "8.1.0-beta.2",
4
4
  "access": "public",
5
5
  "description": "Client for the Stacks Blockchain API",
6
6
  "homepage": "https://github.com/hirosystems/stacks-blockchain-api/tree/master/client#readme",
@@ -18,7 +18,7 @@
18
18
  "unpkg": "lib/index.umd.js",
19
19
  "scripts": {
20
20
  "prepublishOnly": "npm run build",
21
- "build": "rimraf ./lib && npm run build:client --prefix .. && npm run build:node && npm run build:browser",
21
+ "build": "rimraf ./lib && npm run build:client --prefix .. && npm run build:node && npm run build:browser && cpx './src/**/*.d.ts' ./lib",
22
22
  "build:node": "tsc",
23
23
  "build:browser": "microbundle -i src/index.ts -o lib/index.umd.js --no-pkg-main -f umd --external none --globals none --no-compress --tsconfig tsconfig.browser.json --name StacksBlockchainApiClient",
24
24
  "build:browser:watch": "npm run build:browser -- watch",
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "concurrently": "7.6.0",
41
+ "cpx": "1.5.0",
41
42
  "http-server": "14.0.0",
42
43
  "microbundle": "0.15.1",
43
44
  "rimraf": "6.0.1",
@@ -840,7 +840,7 @@ export interface paths {
840
840
  };
841
841
  /**
842
842
  * Get account balances
843
- * @description Retrieves total account balance information for a given Address or Contract Identifier. This includes the balances of STX Tokens, Fungible Tokens and Non-Fungible Tokens for the account.
843
+ * @description Retrieves total account balance information for a given Address or Contract Identifier. This includes the balances of STX Tokens, Fungible Tokens and Non-Fungible Tokens for the account.
844
844
  */
845
845
  get: operations["get_account_balance"];
846
846
  put?: never;
@@ -17832,6 +17832,8 @@ export interface operations {
17832
17832
  content: {
17833
17833
  "application/json": {
17834
17834
  balance: string;
17835
+ /** @description Total STX balance considering pending mempool transactions */
17836
+ estimated_balance?: string;
17835
17837
  total_sent: string;
17836
17838
  total_received: string;
17837
17839
  total_fees_sent: string;
@@ -17896,6 +17898,8 @@ export interface operations {
17896
17898
  /** StxBalance */
17897
17899
  stx: {
17898
17900
  balance: string;
17901
+ /** @description Total STX balance considering pending mempool transactions */
17902
+ estimated_balance?: string;
17899
17903
  total_sent: string;
17900
17904
  total_received: string;
17901
17905
  total_fees_sent: string;
@@ -22924,6 +22928,8 @@ export interface operations {
22924
22928
  */
22925
22929
  metadata?: {
22926
22930
  balance: string;
22931
+ /** @description Total STX balance considering pending mempool transactions */
22932
+ estimated_balance?: string;
22927
22933
  total_sent: string;
22928
22934
  total_received: string;
22929
22935
  total_fees_sent: string;