@secondlayer/shared 14.2.0 → 15.0.0
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/README.md +1 -1
- package/package.json +1 -9
- package/dist/src/node/hiro-client.d.ts +0 -196
- package/dist/src/node/hiro-client.js +0 -495
- package/dist/src/node/hiro-client.js.map +0 -12
- package/dist/src/node/hiro-pg-client.d.ts +0 -29
- package/dist/src/node/hiro-pg-client.js +0 -532
- package/dist/src/node/hiro-pg-client.js.map +0 -10
package/README.md
CHANGED
|
@@ -37,4 +37,4 @@ DATABASE_URL=... bun run migrate
|
|
|
37
37
|
| `@secondlayer/shared/crypto/secrets` | AES-GCM secret envelope |
|
|
38
38
|
| `@secondlayer/shared/crypto/standard-webhooks` | Standard Webhooks signing |
|
|
39
39
|
| `@secondlayer/shared/node` | Stacks node client |
|
|
40
|
-
| `@secondlayer/shared/node/*` | Stacks node clients (
|
|
40
|
+
| `@secondlayer/shared/node/*` | Stacks node clients (local-client) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Internal building blocks shared across Secondlayer packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -213,10 +213,6 @@
|
|
|
213
213
|
"types": "./dist/src/node/client.d.ts",
|
|
214
214
|
"import": "./dist/src/node/client.js"
|
|
215
215
|
},
|
|
216
|
-
"./node/hiro-client": {
|
|
217
|
-
"types": "./dist/src/node/hiro-client.d.ts",
|
|
218
|
-
"import": "./dist/src/node/hiro-client.js"
|
|
219
|
-
},
|
|
220
216
|
"./node/nakamoto": {
|
|
221
217
|
"types": "./dist/src/node/nakamoto.d.ts",
|
|
222
218
|
"import": "./dist/src/node/nakamoto.js"
|
|
@@ -229,10 +225,6 @@
|
|
|
229
225
|
"types": "./dist/src/node/local-client.d.ts",
|
|
230
226
|
"import": "./dist/src/node/local-client.js"
|
|
231
227
|
},
|
|
232
|
-
"./node/hiro-pg-client": {
|
|
233
|
-
"types": "./dist/src/node/hiro-pg-client.d.ts",
|
|
234
|
-
"import": "./dist/src/node/hiro-pg-client.js"
|
|
235
|
-
},
|
|
236
228
|
"./node/client": {
|
|
237
229
|
"types": "./dist/src/node/client.d.ts",
|
|
238
230
|
"import": "./dist/src/node/client.js"
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/** v2 /extended/v2/blocks/{height} response */
|
|
2
|
-
interface HiroBlockResponse {
|
|
3
|
-
canonical: boolean;
|
|
4
|
-
height: number;
|
|
5
|
-
hash: string;
|
|
6
|
-
block_time: number;
|
|
7
|
-
block_time_iso: string;
|
|
8
|
-
index_block_hash: string;
|
|
9
|
-
parent_block_hash: string;
|
|
10
|
-
parent_index_block_hash: string;
|
|
11
|
-
burn_block_hash: string;
|
|
12
|
-
burn_block_height: number;
|
|
13
|
-
burn_block_time: number;
|
|
14
|
-
miner_txid: string;
|
|
15
|
-
tx_count: number;
|
|
16
|
-
}
|
|
17
|
-
/** v2 /extended/v2/blocks/{height}/transactions response */
|
|
18
|
-
interface HiroBlockTxsResponse {
|
|
19
|
-
limit: number;
|
|
20
|
-
offset: number;
|
|
21
|
-
total: number;
|
|
22
|
-
results: HiroTxResponse[];
|
|
23
|
-
}
|
|
24
|
-
interface HiroTxResponse {
|
|
25
|
-
tx_id: string;
|
|
26
|
-
tx_type: string;
|
|
27
|
-
tx_status: string;
|
|
28
|
-
sender_address: string;
|
|
29
|
-
fee_rate: string;
|
|
30
|
-
nonce: number;
|
|
31
|
-
block_hash: string;
|
|
32
|
-
block_height: number;
|
|
33
|
-
burn_block_height: number;
|
|
34
|
-
tx_index: number;
|
|
35
|
-
event_count: number;
|
|
36
|
-
token_transfer?: {
|
|
37
|
-
recipient_address: string
|
|
38
|
-
amount: string
|
|
39
|
-
memo: string
|
|
40
|
-
};
|
|
41
|
-
contract_call?: {
|
|
42
|
-
contract_id: string
|
|
43
|
-
function_name: string
|
|
44
|
-
function_args: unknown[]
|
|
45
|
-
};
|
|
46
|
-
smart_contract?: {
|
|
47
|
-
contract_id: string
|
|
48
|
-
source_code: string
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
interface HiroEvent {
|
|
52
|
-
event_index: number;
|
|
53
|
-
event_type: string;
|
|
54
|
-
tx_id: string;
|
|
55
|
-
asset?: {
|
|
56
|
-
asset_event_type: string
|
|
57
|
-
sender?: string
|
|
58
|
-
recipient?: string
|
|
59
|
-
amount?: string
|
|
60
|
-
memo?: string
|
|
61
|
-
asset_id?: string
|
|
62
|
-
value?: unknown
|
|
63
|
-
};
|
|
64
|
-
contract_log?: {
|
|
65
|
-
contract_id: string
|
|
66
|
-
topic: string
|
|
67
|
-
value: unknown
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
interface HiroEventsResponse {
|
|
71
|
-
limit: number;
|
|
72
|
-
offset: number;
|
|
73
|
-
events: HiroEvent[];
|
|
74
|
-
}
|
|
75
|
-
/** Shape our indexer expects at POST /new_block */
|
|
76
|
-
interface NewBlockPayload {
|
|
77
|
-
block_hash: string;
|
|
78
|
-
block_height: number;
|
|
79
|
-
index_block_hash: string;
|
|
80
|
-
parent_block_hash: string;
|
|
81
|
-
parent_index_block_hash: string;
|
|
82
|
-
burn_block_hash: string;
|
|
83
|
-
burn_block_height: number;
|
|
84
|
-
burn_block_timestamp: number;
|
|
85
|
-
miner_txid: string;
|
|
86
|
-
timestamp: number;
|
|
87
|
-
transactions: TransactionPayload[];
|
|
88
|
-
events: TransactionEventPayload[];
|
|
89
|
-
}
|
|
90
|
-
interface TransactionPayload {
|
|
91
|
-
txid: string;
|
|
92
|
-
raw_tx: string;
|
|
93
|
-
status: string;
|
|
94
|
-
tx_index: number;
|
|
95
|
-
tx_type?: string;
|
|
96
|
-
sender_address?: string;
|
|
97
|
-
}
|
|
98
|
-
interface TransactionEventPayload {
|
|
99
|
-
txid: string;
|
|
100
|
-
event_index: number;
|
|
101
|
-
committed: boolean;
|
|
102
|
-
type: string;
|
|
103
|
-
stx_transfer_event?: {
|
|
104
|
-
sender: string
|
|
105
|
-
recipient: string
|
|
106
|
-
amount: string
|
|
107
|
-
memo?: string
|
|
108
|
-
};
|
|
109
|
-
stx_mint_event?: {
|
|
110
|
-
recipient: string
|
|
111
|
-
amount: string
|
|
112
|
-
};
|
|
113
|
-
stx_burn_event?: {
|
|
114
|
-
sender: string
|
|
115
|
-
amount: string
|
|
116
|
-
};
|
|
117
|
-
stx_lock_event?: {
|
|
118
|
-
locked_amount: string
|
|
119
|
-
unlock_height: string
|
|
120
|
-
locked_address: string
|
|
121
|
-
};
|
|
122
|
-
ft_transfer_event?: {
|
|
123
|
-
asset_identifier: string
|
|
124
|
-
sender: string
|
|
125
|
-
recipient: string
|
|
126
|
-
amount: string
|
|
127
|
-
};
|
|
128
|
-
ft_mint_event?: {
|
|
129
|
-
asset_identifier: string
|
|
130
|
-
recipient: string
|
|
131
|
-
amount: string
|
|
132
|
-
};
|
|
133
|
-
ft_burn_event?: {
|
|
134
|
-
asset_identifier: string
|
|
135
|
-
sender: string
|
|
136
|
-
amount: string
|
|
137
|
-
};
|
|
138
|
-
nft_transfer_event?: {
|
|
139
|
-
asset_identifier: string
|
|
140
|
-
sender: string
|
|
141
|
-
recipient: string
|
|
142
|
-
value: unknown
|
|
143
|
-
};
|
|
144
|
-
nft_mint_event?: {
|
|
145
|
-
asset_identifier: string
|
|
146
|
-
recipient: string
|
|
147
|
-
value: unknown
|
|
148
|
-
};
|
|
149
|
-
nft_burn_event?: {
|
|
150
|
-
asset_identifier: string
|
|
151
|
-
sender: string
|
|
152
|
-
value: unknown
|
|
153
|
-
};
|
|
154
|
-
smart_contract_event?: {
|
|
155
|
-
contract_identifier: string
|
|
156
|
-
topic: string
|
|
157
|
-
value: unknown
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
interface GetBlockOptions {
|
|
161
|
-
/** Fetch actual raw_tx hex for each transaction (instead of "0x00" placeholder) */
|
|
162
|
-
includeRawTx?: boolean;
|
|
163
|
-
/** Max concurrent raw_tx fetches per block (default: 10) */
|
|
164
|
-
rawTxConcurrency?: number;
|
|
165
|
-
}
|
|
166
|
-
declare class HiroClient {
|
|
167
|
-
private apiUrl;
|
|
168
|
-
private fallbackUrl;
|
|
169
|
-
private apiKey;
|
|
170
|
-
private maxRetries;
|
|
171
|
-
constructor(apiUrl?: string, maxRetries?: number);
|
|
172
|
-
private get headers();
|
|
173
|
-
/** Fetch with retry on 429/5xx using exponential backoff */
|
|
174
|
-
private fetchWithRetry;
|
|
175
|
-
/**
|
|
176
|
-
* Fetch a complete block by height, including all transactions and events,
|
|
177
|
-
* transformed into the NewBlockPayload format our indexer expects.
|
|
178
|
-
*
|
|
179
|
-
* Uses 3-step approach:
|
|
180
|
-
* 1. GET /extended/v2/blocks/{height} — block metadata
|
|
181
|
-
* 2. GET /extended/v2/blocks/{height}/transactions — all txs (paginated)
|
|
182
|
-
* 3. GET /extended/v1/tx/events?tx_id={txId} — events per tx (only for txs with events)
|
|
183
|
-
*/
|
|
184
|
-
getBlockForIndexer(height: number, options?: GetBlockOptions): Promise<NewBlockPayload | null>;
|
|
185
|
-
/** v2 block metadata */
|
|
186
|
-
private fetchBlock;
|
|
187
|
-
/** v2 block transactions (paginated) */
|
|
188
|
-
private fetchBlockTransactions;
|
|
189
|
-
private fetchAllEvents;
|
|
190
|
-
/** Fetch raw_tx hex for a single transaction */
|
|
191
|
-
fetchRawTx(txId: string): Promise<string | null>;
|
|
192
|
-
/** Fetch raw_tx for multiple transactions with bounded concurrency */
|
|
193
|
-
fetchRawTxBatch(txIds: string[], concurrency?: number): Promise<Map<string, string>>;
|
|
194
|
-
getApiUrl(): string;
|
|
195
|
-
}
|
|
196
|
-
export { GetBlockOptions, HiroBlockResponse, HiroBlockTxsResponse, HiroClient, HiroEvent, HiroEventsResponse, HiroTxResponse, NewBlockPayload };
|