@secondlayer/shared 6.8.1 → 6.9.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/dist/src/db/index.d.ts +25 -1
- package/dist/src/db/index.js +42 -3
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +14 -0
- package/dist/src/db/queries/chain-reorgs.js +41 -3
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +761 -0
- package/dist/src/db/queries/contracts.js +90 -0
- package/dist/src/db/queries/contracts.js.map +11 -0
- package/dist/src/db/queries/integrity.d.ts +14 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +14 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +14 -0
- package/dist/src/db/queries/subgraphs.d.ts +36 -1
- package/dist/src/db/queries/subgraphs.js +390 -6
- package/dist/src/db/queries/subgraphs.js.map +9 -4
- package/dist/src/db/queries/subscriptions.d.ts +14 -0
- package/dist/src/db/schema.d.ts +18 -1
- package/dist/src/index.d.ts +33 -1
- package/dist/src/index.js +45 -4
- package/dist/src/index.js.map +4 -4
- package/dist/src/node/client.d.ts +2 -0
- package/dist/src/node/client.js +11 -1
- package/dist/src/node/client.js.map +3 -3
- package/dist/src/node/local-client.d.ts +14 -0
- package/dist/src/schemas/index.d.ts +8 -0
- package/dist/src/schemas/index.js +4 -2
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subgraphs.d.ts +8 -0
- package/dist/src/schemas/subgraphs.js +4 -2
- package/dist/src/schemas/subgraphs.js.map +3 -3
- package/migrations/0081_subgraphs_database_url_enc.ts +16 -0
- package/migrations/0082_contracts_registry.ts +44 -0
- package/package.json +6 -2
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import { ColumnType, Generated, Selectable } from "kysely";
|
|
3
|
+
interface BlocksTable {
|
|
4
|
+
height: number;
|
|
5
|
+
hash: string;
|
|
6
|
+
parent_hash: string;
|
|
7
|
+
burn_block_height: number;
|
|
8
|
+
burn_block_hash: ColumnType<string | null, string | null | undefined, string | null>;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
canonical: Generated<boolean>;
|
|
11
|
+
created_at: Generated<Date>;
|
|
12
|
+
}
|
|
13
|
+
interface TransactionsTable {
|
|
14
|
+
tx_id: string;
|
|
15
|
+
block_height: number;
|
|
16
|
+
tx_index: Generated<number>;
|
|
17
|
+
type: string;
|
|
18
|
+
sender: string;
|
|
19
|
+
status: string;
|
|
20
|
+
contract_id: string | null;
|
|
21
|
+
function_name: string | null;
|
|
22
|
+
function_args: Generated<unknown | null>;
|
|
23
|
+
raw_result: Generated<string | null>;
|
|
24
|
+
raw_tx: string;
|
|
25
|
+
created_at: Generated<Date>;
|
|
26
|
+
}
|
|
27
|
+
interface EventsTable {
|
|
28
|
+
id: Generated<string>;
|
|
29
|
+
tx_id: string;
|
|
30
|
+
block_height: number;
|
|
31
|
+
event_index: number;
|
|
32
|
+
type: string;
|
|
33
|
+
data: unknown;
|
|
34
|
+
created_at: Generated<Date>;
|
|
35
|
+
}
|
|
36
|
+
interface IndexProgressTable {
|
|
37
|
+
network: string;
|
|
38
|
+
last_indexed_block: Generated<number>;
|
|
39
|
+
last_contiguous_block: Generated<number>;
|
|
40
|
+
highest_seen_block: Generated<number>;
|
|
41
|
+
updated_at: Generated<Date>;
|
|
42
|
+
}
|
|
43
|
+
interface SubgraphsTable {
|
|
44
|
+
id: Generated<string>;
|
|
45
|
+
name: string;
|
|
46
|
+
version: Generated<string>;
|
|
47
|
+
status: Generated<string>;
|
|
48
|
+
definition: Record<string, unknown>;
|
|
49
|
+
schema_hash: string;
|
|
50
|
+
handler_path: string;
|
|
51
|
+
schema_name: string | null;
|
|
52
|
+
start_block: Generated<number>;
|
|
53
|
+
last_processed_block: Generated<number>;
|
|
54
|
+
reindex_from_block: number | null;
|
|
55
|
+
reindex_to_block: number | null;
|
|
56
|
+
last_error: string | null;
|
|
57
|
+
last_error_at: Date | null;
|
|
58
|
+
total_processed: Generated<number>;
|
|
59
|
+
total_errors: Generated<number>;
|
|
60
|
+
account_id: string;
|
|
61
|
+
handler_code: string | null;
|
|
62
|
+
source_code: string | null;
|
|
63
|
+
project_id: string | null;
|
|
64
|
+
database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
|
|
65
|
+
created_at: Generated<Date>;
|
|
66
|
+
updated_at: Generated<Date>;
|
|
67
|
+
}
|
|
68
|
+
interface ContractsTable {
|
|
69
|
+
contract_id: string;
|
|
70
|
+
deployer: string;
|
|
71
|
+
block_height: number;
|
|
72
|
+
canonical: Generated<boolean>;
|
|
73
|
+
abi: unknown | null;
|
|
74
|
+
declared_traits: Generated<string[]>;
|
|
75
|
+
inferred_standards: Generated<string[]>;
|
|
76
|
+
abi_status: Generated<string>;
|
|
77
|
+
abi_fetched_at: Date | null;
|
|
78
|
+
created_at: Generated<Date>;
|
|
79
|
+
}
|
|
80
|
+
interface SubgraphGapsTable {
|
|
81
|
+
id: Generated<string>;
|
|
82
|
+
subgraph_id: string;
|
|
83
|
+
subgraph_name: string;
|
|
84
|
+
gap_start: number;
|
|
85
|
+
gap_end: number;
|
|
86
|
+
reason: string;
|
|
87
|
+
detected_at: Generated<Date>;
|
|
88
|
+
resolved_at: Date | null;
|
|
89
|
+
}
|
|
90
|
+
type SubgraphOperationKind = "reindex" | "backfill";
|
|
91
|
+
type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
92
|
+
interface SubgraphOperationsTable {
|
|
93
|
+
id: Generated<string>;
|
|
94
|
+
subgraph_id: string;
|
|
95
|
+
subgraph_name: string;
|
|
96
|
+
account_id: string | null;
|
|
97
|
+
kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
|
|
98
|
+
status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
|
|
99
|
+
from_block: number | null;
|
|
100
|
+
to_block: number | null;
|
|
101
|
+
cancel_requested: Generated<boolean>;
|
|
102
|
+
locked_by: string | null;
|
|
103
|
+
locked_until: Date | null;
|
|
104
|
+
started_at: Date | null;
|
|
105
|
+
finished_at: Date | null;
|
|
106
|
+
processed_blocks: number | null;
|
|
107
|
+
error: string | null;
|
|
108
|
+
created_at: Generated<Date>;
|
|
109
|
+
updated_at: Generated<Date>;
|
|
110
|
+
}
|
|
111
|
+
interface ApiKeysTable {
|
|
112
|
+
id: Generated<string>;
|
|
113
|
+
key_hash: string;
|
|
114
|
+
key_prefix: string;
|
|
115
|
+
name: string | null;
|
|
116
|
+
status: Generated<string>;
|
|
117
|
+
rate_limit: Generated<number>;
|
|
118
|
+
ip_address: string;
|
|
119
|
+
account_id: string;
|
|
120
|
+
product: Generated<"account" | "streams" | "index">;
|
|
121
|
+
tier: "free" | "build" | "scale" | "enterprise" | null;
|
|
122
|
+
last_used_at: Date | null;
|
|
123
|
+
revoked_at: Date | null;
|
|
124
|
+
created_at: Generated<Date>;
|
|
125
|
+
}
|
|
126
|
+
interface AccountsTable {
|
|
127
|
+
id: Generated<string>;
|
|
128
|
+
email: string;
|
|
129
|
+
plan: Generated<string>;
|
|
130
|
+
display_name: string | null;
|
|
131
|
+
bio: string | null;
|
|
132
|
+
avatar_url: string | null;
|
|
133
|
+
slug: string | null;
|
|
134
|
+
stripe_customer_id: string | null;
|
|
135
|
+
created_at: Generated<Date>;
|
|
136
|
+
}
|
|
137
|
+
interface SessionsTable {
|
|
138
|
+
id: Generated<string>;
|
|
139
|
+
token_hash: string;
|
|
140
|
+
token_prefix: string;
|
|
141
|
+
account_id: string;
|
|
142
|
+
ip_address: string;
|
|
143
|
+
expires_at: Generated<Date>;
|
|
144
|
+
revoked_at: Date | null;
|
|
145
|
+
last_used_at: Date | null;
|
|
146
|
+
created_at: Generated<Date>;
|
|
147
|
+
}
|
|
148
|
+
interface MagicLinksTable {
|
|
149
|
+
id: Generated<string>;
|
|
150
|
+
email: string;
|
|
151
|
+
token: string;
|
|
152
|
+
code: string | null;
|
|
153
|
+
expires_at: Date;
|
|
154
|
+
used_at: Date | null;
|
|
155
|
+
failed_attempts: Generated<number>;
|
|
156
|
+
created_at: Generated<Date>;
|
|
157
|
+
}
|
|
158
|
+
interface UsageDailyTable {
|
|
159
|
+
account_id: string;
|
|
160
|
+
tenant_id: string | null;
|
|
161
|
+
date: string;
|
|
162
|
+
api_requests: Generated<number>;
|
|
163
|
+
deliveries: Generated<number>;
|
|
164
|
+
streams_events_returned: Generated<number>;
|
|
165
|
+
index_decoded_events_returned: Generated<number>;
|
|
166
|
+
}
|
|
167
|
+
interface UsageSnapshotsTable {
|
|
168
|
+
id: Generated<string>;
|
|
169
|
+
account_id: string;
|
|
170
|
+
measured_at: Generated<Date>;
|
|
171
|
+
storage_bytes: Generated<number>;
|
|
172
|
+
}
|
|
173
|
+
interface AccountInsightsTable {
|
|
174
|
+
id: Generated<string>;
|
|
175
|
+
account_id: string;
|
|
176
|
+
category: string;
|
|
177
|
+
insight_type: string;
|
|
178
|
+
resource_id: string | null;
|
|
179
|
+
severity: string;
|
|
180
|
+
title: string;
|
|
181
|
+
body: string;
|
|
182
|
+
data: unknown;
|
|
183
|
+
dismissed_at: Date | null;
|
|
184
|
+
expires_at: Date | null;
|
|
185
|
+
created_at: Generated<Date>;
|
|
186
|
+
}
|
|
187
|
+
interface AccountAgentRunsTable {
|
|
188
|
+
id: Generated<string>;
|
|
189
|
+
account_id: string;
|
|
190
|
+
started_at: Generated<Date>;
|
|
191
|
+
completed_at: Date | null;
|
|
192
|
+
status: Generated<string>;
|
|
193
|
+
input_tokens: Generated<number>;
|
|
194
|
+
output_tokens: Generated<number>;
|
|
195
|
+
cost_usd: Generated<number>;
|
|
196
|
+
insights_created: Generated<number>;
|
|
197
|
+
error: string | null;
|
|
198
|
+
}
|
|
199
|
+
interface SubgraphProcessingStatsTable {
|
|
200
|
+
id: Generated<string>;
|
|
201
|
+
subgraph_name: string;
|
|
202
|
+
api_key_id: string | null;
|
|
203
|
+
bucket_start: Date | null;
|
|
204
|
+
bucket_end: Date | null;
|
|
205
|
+
blocks_processed: number | null;
|
|
206
|
+
total_time_ms: number | null;
|
|
207
|
+
handler_time_ms: number | null;
|
|
208
|
+
flush_time_ms: number | null;
|
|
209
|
+
max_block_time_ms: number | null;
|
|
210
|
+
max_handler_time_ms: number | null;
|
|
211
|
+
avg_ops_per_block: number | null;
|
|
212
|
+
is_catchup: Generated<boolean>;
|
|
213
|
+
created_at: Generated<Date>;
|
|
214
|
+
}
|
|
215
|
+
interface SubgraphTableSnapshotsTable {
|
|
216
|
+
id: Generated<string>;
|
|
217
|
+
subgraph_name: string;
|
|
218
|
+
api_key_id: string | null;
|
|
219
|
+
table_name: string;
|
|
220
|
+
row_count: number | null;
|
|
221
|
+
created_at: Generated<Date>;
|
|
222
|
+
}
|
|
223
|
+
interface SubgraphHealthSnapshotsTable {
|
|
224
|
+
id: Generated<string>;
|
|
225
|
+
subgraph_id: string;
|
|
226
|
+
total_processed: number;
|
|
227
|
+
total_errors: number;
|
|
228
|
+
last_processed_block: number | null;
|
|
229
|
+
captured_at: Generated<Date>;
|
|
230
|
+
}
|
|
231
|
+
interface SubgraphUsageDailyTable {
|
|
232
|
+
subgraph_id: string;
|
|
233
|
+
date: string;
|
|
234
|
+
query_count: Generated<number>;
|
|
235
|
+
}
|
|
236
|
+
interface ProjectsTable {
|
|
237
|
+
id: Generated<string>;
|
|
238
|
+
name: string;
|
|
239
|
+
slug: string;
|
|
240
|
+
account_id: string;
|
|
241
|
+
settings: Generated<Record<string, unknown>>;
|
|
242
|
+
network: Generated<string>;
|
|
243
|
+
node_rpc: string | null;
|
|
244
|
+
created_at: Generated<Date>;
|
|
245
|
+
updated_at: Generated<Date>;
|
|
246
|
+
}
|
|
247
|
+
interface TeamMembersTable {
|
|
248
|
+
id: Generated<string>;
|
|
249
|
+
project_id: string;
|
|
250
|
+
account_id: string;
|
|
251
|
+
role: Generated<string>;
|
|
252
|
+
invited_by: string | null;
|
|
253
|
+
created_at: Generated<Date>;
|
|
254
|
+
}
|
|
255
|
+
interface TeamInvitationsTable {
|
|
256
|
+
id: Generated<string>;
|
|
257
|
+
project_id: string;
|
|
258
|
+
email: string;
|
|
259
|
+
role: Generated<string>;
|
|
260
|
+
token: string;
|
|
261
|
+
invited_by: string | null;
|
|
262
|
+
expires_at: Date;
|
|
263
|
+
accepted_at: Date | null;
|
|
264
|
+
created_at: Generated<Date>;
|
|
265
|
+
}
|
|
266
|
+
interface ChatSessionsTable {
|
|
267
|
+
id: Generated<string>;
|
|
268
|
+
account_id: string;
|
|
269
|
+
title: string | null;
|
|
270
|
+
summary: unknown | null;
|
|
271
|
+
created_at: Generated<Date>;
|
|
272
|
+
updated_at: Generated<Date>;
|
|
273
|
+
}
|
|
274
|
+
interface ChatMessagesTable {
|
|
275
|
+
id: Generated<string>;
|
|
276
|
+
chat_session_id: string;
|
|
277
|
+
role: string;
|
|
278
|
+
parts: unknown;
|
|
279
|
+
metadata: unknown | null;
|
|
280
|
+
created_at: Generated<Date>;
|
|
281
|
+
}
|
|
282
|
+
interface ProcessedStripeEventsTable {
|
|
283
|
+
event_id: string;
|
|
284
|
+
event_type: string;
|
|
285
|
+
processed_at: Generated<Date>;
|
|
286
|
+
}
|
|
287
|
+
interface DecodedEventsTable {
|
|
288
|
+
cursor: string;
|
|
289
|
+
block_height: number;
|
|
290
|
+
tx_id: string;
|
|
291
|
+
tx_index: number;
|
|
292
|
+
event_index: number;
|
|
293
|
+
event_type: string;
|
|
294
|
+
microblock_hash: string | null;
|
|
295
|
+
canonical: Generated<boolean>;
|
|
296
|
+
contract_id: string | null;
|
|
297
|
+
sender: string | null;
|
|
298
|
+
recipient: string | null;
|
|
299
|
+
amount: string | null;
|
|
300
|
+
asset_identifier: string | null;
|
|
301
|
+
value: string | null;
|
|
302
|
+
memo: string | null;
|
|
303
|
+
/** Decoded payload for event types that don't fit the flat columns
|
|
304
|
+
* (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */
|
|
305
|
+
payload: unknown | null;
|
|
306
|
+
source_cursor: string;
|
|
307
|
+
created_at: Generated<Date>;
|
|
308
|
+
}
|
|
309
|
+
interface L2DecoderCheckpointsTable {
|
|
310
|
+
decoder_name: string;
|
|
311
|
+
last_cursor: string | null;
|
|
312
|
+
updated_at: Generated<Date>;
|
|
313
|
+
}
|
|
314
|
+
interface ChainReorgsTable {
|
|
315
|
+
id: Generated<string>;
|
|
316
|
+
detected_at: Generated<Date>;
|
|
317
|
+
fork_point_height: number;
|
|
318
|
+
old_index_block_hash: string | null;
|
|
319
|
+
new_index_block_hash: string | null;
|
|
320
|
+
orphaned_from_height: number;
|
|
321
|
+
orphaned_from_event_index: number;
|
|
322
|
+
orphaned_to_height: number;
|
|
323
|
+
orphaned_to_event_index: number;
|
|
324
|
+
new_canonical_height: number;
|
|
325
|
+
new_canonical_event_index: number;
|
|
326
|
+
created_at: Generated<Date>;
|
|
327
|
+
}
|
|
328
|
+
type Pox4FunctionName = "stack-stx" | "delegate-stx" | "stack-extend" | "stack-increase" | "revoke-delegate-stx" | "delegate-stack-stx" | "delegate-stack-extend" | "delegate-stack-increase" | "stack-aggregation-commit" | "stack-aggregation-commit-indexed" | "stack-aggregation-increase" | "set-signer-key-authorization";
|
|
329
|
+
interface Pox4CallsTable {
|
|
330
|
+
cursor: string;
|
|
331
|
+
block_height: number;
|
|
332
|
+
block_time: Date;
|
|
333
|
+
burn_block_height: number;
|
|
334
|
+
tx_id: string;
|
|
335
|
+
tx_index: number;
|
|
336
|
+
function_name: Pox4FunctionName;
|
|
337
|
+
caller: string;
|
|
338
|
+
stacker: string | null;
|
|
339
|
+
delegate_to: string | null;
|
|
340
|
+
amount_ustx: string | null;
|
|
341
|
+
lock_period: number | null;
|
|
342
|
+
pox_addr_version: number | null;
|
|
343
|
+
pox_addr_hashbytes: string | null;
|
|
344
|
+
pox_addr_btc: string | null;
|
|
345
|
+
start_cycle: number | null;
|
|
346
|
+
end_cycle: number | null;
|
|
347
|
+
signer_key: string | null;
|
|
348
|
+
signer_signature: string | null;
|
|
349
|
+
auth_id: string | null;
|
|
350
|
+
max_amount: string | null;
|
|
351
|
+
reward_cycle: number | null;
|
|
352
|
+
aggregated_amount_ustx: string | null;
|
|
353
|
+
aggregated_signer_index: number | null;
|
|
354
|
+
auth_period: number | null;
|
|
355
|
+
auth_topic: string | null;
|
|
356
|
+
auth_allowed: boolean | null;
|
|
357
|
+
result_ok: boolean;
|
|
358
|
+
result_raw: string;
|
|
359
|
+
canonical: Generated<boolean>;
|
|
360
|
+
source_cursor: string;
|
|
361
|
+
created_at: Generated<Date>;
|
|
362
|
+
}
|
|
363
|
+
interface Pox4CyclesDailyTable {
|
|
364
|
+
date: string;
|
|
365
|
+
reward_cycle: number;
|
|
366
|
+
total_stacked_ustx: Generated<string>;
|
|
367
|
+
solo_stackers: Generated<number>;
|
|
368
|
+
delegated_principals: Generated<number>;
|
|
369
|
+
unique_pools: Generated<number>;
|
|
370
|
+
unique_signers: Generated<number>;
|
|
371
|
+
calls_today: Generated<number>;
|
|
372
|
+
updated_at: Generated<Date>;
|
|
373
|
+
}
|
|
374
|
+
interface Pox4SignersDailyTable {
|
|
375
|
+
date: string;
|
|
376
|
+
reward_cycle: number;
|
|
377
|
+
signer_key: string;
|
|
378
|
+
weight_ustx: Generated<string>;
|
|
379
|
+
stacker_count: Generated<number>;
|
|
380
|
+
aggregation_calls: Generated<number>;
|
|
381
|
+
updated_at: Generated<Date>;
|
|
382
|
+
}
|
|
383
|
+
type SbtcEventTopic = "completed-deposit" | "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject" | "key-rotation" | "update-protocol-contract";
|
|
384
|
+
interface SbtcEventsTable {
|
|
385
|
+
cursor: string;
|
|
386
|
+
block_height: number;
|
|
387
|
+
block_time: Date;
|
|
388
|
+
tx_id: string;
|
|
389
|
+
tx_index: number;
|
|
390
|
+
event_index: number;
|
|
391
|
+
topic: SbtcEventTopic;
|
|
392
|
+
request_id: number | null;
|
|
393
|
+
amount: string | null;
|
|
394
|
+
sender: string | null;
|
|
395
|
+
recipient_btc_version: number | null;
|
|
396
|
+
recipient_btc_hashbytes: string | null;
|
|
397
|
+
bitcoin_txid: string | null;
|
|
398
|
+
output_index: number | null;
|
|
399
|
+
sweep_txid: string | null;
|
|
400
|
+
burn_hash: string | null;
|
|
401
|
+
burn_height: number | null;
|
|
402
|
+
signer_bitmap: string | null;
|
|
403
|
+
max_fee: string | null;
|
|
404
|
+
fee: string | null;
|
|
405
|
+
block_height_at_request: number | null;
|
|
406
|
+
governance_contract_type: number | null;
|
|
407
|
+
governance_new_contract: string | null;
|
|
408
|
+
signer_aggregate_pubkey: string | null;
|
|
409
|
+
signer_threshold: number | null;
|
|
410
|
+
signer_address: string | null;
|
|
411
|
+
signer_keys_count: number | null;
|
|
412
|
+
canonical: Generated<boolean>;
|
|
413
|
+
source_cursor: string;
|
|
414
|
+
created_at: Generated<Date>;
|
|
415
|
+
}
|
|
416
|
+
type SbtcTokenEventType = "transfer" | "mint" | "burn";
|
|
417
|
+
interface SbtcTokenEventsTable {
|
|
418
|
+
cursor: string;
|
|
419
|
+
block_height: number;
|
|
420
|
+
block_time: Date;
|
|
421
|
+
tx_id: string;
|
|
422
|
+
tx_index: number;
|
|
423
|
+
event_index: number;
|
|
424
|
+
event_type: SbtcTokenEventType;
|
|
425
|
+
sender: string | null;
|
|
426
|
+
recipient: string | null;
|
|
427
|
+
amount: string;
|
|
428
|
+
memo: string | null;
|
|
429
|
+
canonical: Generated<boolean>;
|
|
430
|
+
source_cursor: string;
|
|
431
|
+
created_at: Generated<Date>;
|
|
432
|
+
}
|
|
433
|
+
interface SbtcSupplySnapshotsTable {
|
|
434
|
+
date: string;
|
|
435
|
+
total_supply: Generated<string>;
|
|
436
|
+
mints_today: Generated<string>;
|
|
437
|
+
burns_today: Generated<string>;
|
|
438
|
+
deposit_count: Generated<number>;
|
|
439
|
+
withdrawal_create_count: Generated<number>;
|
|
440
|
+
withdrawal_accept_count: Generated<number>;
|
|
441
|
+
withdrawal_reject_count: Generated<number>;
|
|
442
|
+
updated_at: Generated<Date>;
|
|
443
|
+
}
|
|
444
|
+
type BnsNameEventTopic = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "new-airdrop";
|
|
445
|
+
interface BnsNameEventsTable {
|
|
446
|
+
cursor: string;
|
|
447
|
+
block_height: number;
|
|
448
|
+
block_time: Date;
|
|
449
|
+
tx_id: string;
|
|
450
|
+
tx_index: number;
|
|
451
|
+
event_index: number;
|
|
452
|
+
topic: BnsNameEventTopic;
|
|
453
|
+
namespace: string;
|
|
454
|
+
name: string;
|
|
455
|
+
fqn: string;
|
|
456
|
+
owner: string | null;
|
|
457
|
+
bns_id: string;
|
|
458
|
+
registered_at: number | null;
|
|
459
|
+
imported_at: number | null;
|
|
460
|
+
renewal_height: number | null;
|
|
461
|
+
stx_burn: string | null;
|
|
462
|
+
preordered_by: string | null;
|
|
463
|
+
hashed_salted_fqn_preorder: string | null;
|
|
464
|
+
canonical: Generated<boolean>;
|
|
465
|
+
source_cursor: string;
|
|
466
|
+
created_at: Generated<Date>;
|
|
467
|
+
}
|
|
468
|
+
type BnsNamespaceEventStatus = "launch" | "transfer-manager" | "freeze-manager" | "update-price-manager" | "freeze-price-manager" | "turn-off-manager-transfers";
|
|
469
|
+
interface BnsNamespaceEventsTable {
|
|
470
|
+
cursor: string;
|
|
471
|
+
block_height: number;
|
|
472
|
+
block_time: Date;
|
|
473
|
+
tx_id: string;
|
|
474
|
+
tx_index: number;
|
|
475
|
+
event_index: number;
|
|
476
|
+
status: BnsNamespaceEventStatus;
|
|
477
|
+
namespace: string;
|
|
478
|
+
manager: string | null;
|
|
479
|
+
manager_frozen: boolean | null;
|
|
480
|
+
manager_transfers_disabled: boolean | null;
|
|
481
|
+
price_function: string | null;
|
|
482
|
+
price_frozen: boolean | null;
|
|
483
|
+
lifetime: number | null;
|
|
484
|
+
revealed_at: number | null;
|
|
485
|
+
launched_at: number | null;
|
|
486
|
+
canonical: Generated<boolean>;
|
|
487
|
+
source_cursor: string;
|
|
488
|
+
created_at: Generated<Date>;
|
|
489
|
+
}
|
|
490
|
+
type BnsMarketplaceAction = "list-in-ustx" | "unlist-in-ustx" | "buy-in-ustx";
|
|
491
|
+
interface BnsMarketplaceEventsTable {
|
|
492
|
+
cursor: string;
|
|
493
|
+
block_height: number;
|
|
494
|
+
block_time: Date;
|
|
495
|
+
tx_id: string;
|
|
496
|
+
tx_index: number;
|
|
497
|
+
event_index: number;
|
|
498
|
+
action: BnsMarketplaceAction;
|
|
499
|
+
bns_id: string;
|
|
500
|
+
price_ustx: string | null;
|
|
501
|
+
commission: string | null;
|
|
502
|
+
canonical: Generated<boolean>;
|
|
503
|
+
source_cursor: string;
|
|
504
|
+
created_at: Generated<Date>;
|
|
505
|
+
}
|
|
506
|
+
interface BnsNamesTable {
|
|
507
|
+
fqn: string;
|
|
508
|
+
namespace: string;
|
|
509
|
+
name: string;
|
|
510
|
+
owner: string;
|
|
511
|
+
bns_id: string;
|
|
512
|
+
registered_at: number | null;
|
|
513
|
+
renewal_height: number | null;
|
|
514
|
+
last_event_cursor: string;
|
|
515
|
+
last_event_at: Date;
|
|
516
|
+
updated_at: Generated<Date>;
|
|
517
|
+
}
|
|
518
|
+
interface BnsNamespacesTable {
|
|
519
|
+
namespace: string;
|
|
520
|
+
manager: string | null;
|
|
521
|
+
manager_frozen: Generated<boolean>;
|
|
522
|
+
price_frozen: Generated<boolean>;
|
|
523
|
+
lifetime: number | null;
|
|
524
|
+
launched_at: number | null;
|
|
525
|
+
last_event_cursor: string;
|
|
526
|
+
last_event_at: Date;
|
|
527
|
+
name_count: Generated<number>;
|
|
528
|
+
updated_at: Generated<Date>;
|
|
529
|
+
}
|
|
530
|
+
interface Database {
|
|
531
|
+
blocks: BlocksTable;
|
|
532
|
+
transactions: TransactionsTable;
|
|
533
|
+
events: EventsTable;
|
|
534
|
+
index_progress: IndexProgressTable;
|
|
535
|
+
contracts: ContractsTable;
|
|
536
|
+
subgraphs: SubgraphsTable;
|
|
537
|
+
api_keys: ApiKeysTable;
|
|
538
|
+
accounts: AccountsTable;
|
|
539
|
+
sessions: SessionsTable;
|
|
540
|
+
magic_links: MagicLinksTable;
|
|
541
|
+
usage_daily: UsageDailyTable;
|
|
542
|
+
usage_snapshots: UsageSnapshotsTable;
|
|
543
|
+
account_insights: AccountInsightsTable;
|
|
544
|
+
account_agent_runs: AccountAgentRunsTable;
|
|
545
|
+
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
546
|
+
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
547
|
+
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
548
|
+
subgraph_gaps: SubgraphGapsTable;
|
|
549
|
+
subgraph_operations: SubgraphOperationsTable;
|
|
550
|
+
subgraph_usage_daily: SubgraphUsageDailyTable;
|
|
551
|
+
projects: ProjectsTable;
|
|
552
|
+
team_members: TeamMembersTable;
|
|
553
|
+
team_invitations: TeamInvitationsTable;
|
|
554
|
+
chat_sessions: ChatSessionsTable;
|
|
555
|
+
chat_messages: ChatMessagesTable;
|
|
556
|
+
processed_stripe_events: ProcessedStripeEventsTable;
|
|
557
|
+
tenants: TenantsTable;
|
|
558
|
+
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
559
|
+
tenant_compute_addons: TenantComputeAddonsTable;
|
|
560
|
+
account_spend_caps: AccountSpendCapsTable;
|
|
561
|
+
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
562
|
+
subscriptions: SubscriptionsTable;
|
|
563
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
564
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
565
|
+
decoded_events: DecodedEventsTable;
|
|
566
|
+
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
567
|
+
chain_reorgs: ChainReorgsTable;
|
|
568
|
+
pox4_calls: Pox4CallsTable;
|
|
569
|
+
pox4_cycles_daily: Pox4CyclesDailyTable;
|
|
570
|
+
pox4_signers_daily: Pox4SignersDailyTable;
|
|
571
|
+
sbtc_events: SbtcEventsTable;
|
|
572
|
+
sbtc_token_events: SbtcTokenEventsTable;
|
|
573
|
+
sbtc_supply_snapshots: SbtcSupplySnapshotsTable;
|
|
574
|
+
bns_name_events: BnsNameEventsTable;
|
|
575
|
+
bns_namespace_events: BnsNamespaceEventsTable;
|
|
576
|
+
bns_marketplace_events: BnsMarketplaceEventsTable;
|
|
577
|
+
bns_names: BnsNamesTable;
|
|
578
|
+
bns_namespaces: BnsNamespacesTable;
|
|
579
|
+
service_heartbeats: ServiceHeartbeatsTable;
|
|
580
|
+
}
|
|
581
|
+
interface ServiceHeartbeatsTable {
|
|
582
|
+
name: string;
|
|
583
|
+
updated_at: Generated<Date>;
|
|
584
|
+
}
|
|
585
|
+
type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
|
|
586
|
+
interface TenantsTable {
|
|
587
|
+
id: Generated<string>;
|
|
588
|
+
account_id: string;
|
|
589
|
+
slug: string;
|
|
590
|
+
status: ColumnType<TenantStatus, TenantStatus | undefined, TenantStatus>;
|
|
591
|
+
plan: string;
|
|
592
|
+
cpus: ColumnType<number, number | string, number | string>;
|
|
593
|
+
memory_mb: number;
|
|
594
|
+
storage_limit_mb: number;
|
|
595
|
+
storage_used_mb: number | null;
|
|
596
|
+
pg_container_id: string | null;
|
|
597
|
+
api_container_id: string | null;
|
|
598
|
+
processor_container_id: string | null;
|
|
599
|
+
target_database_url_enc: Buffer;
|
|
600
|
+
tenant_jwt_secret_enc: Buffer;
|
|
601
|
+
anon_key_enc: Buffer;
|
|
602
|
+
service_key_enc: Buffer;
|
|
603
|
+
api_url_internal: string;
|
|
604
|
+
api_url_public: string;
|
|
605
|
+
suspended_at: Date | null;
|
|
606
|
+
last_health_check_at: Date | null;
|
|
607
|
+
last_active_at: Generated<Date>;
|
|
608
|
+
service_gen: Generated<number>;
|
|
609
|
+
anon_gen: Generated<number>;
|
|
610
|
+
project_id: string | null;
|
|
611
|
+
created_at: Generated<Date>;
|
|
612
|
+
updated_at: Generated<Date>;
|
|
613
|
+
}
|
|
614
|
+
interface TenantUsageMonthlyTable {
|
|
615
|
+
id: Generated<string>;
|
|
616
|
+
tenant_id: string;
|
|
617
|
+
period_month: Date;
|
|
618
|
+
storage_peak_mb: Generated<number>;
|
|
619
|
+
storage_avg_mb: Generated<number>;
|
|
620
|
+
storage_last_mb: Generated<number>;
|
|
621
|
+
measurements: Generated<number>;
|
|
622
|
+
first_at: Generated<Date>;
|
|
623
|
+
last_at: Generated<Date>;
|
|
624
|
+
}
|
|
625
|
+
interface TenantComputeAddonsTable {
|
|
626
|
+
id: Generated<string>;
|
|
627
|
+
tenant_id: string;
|
|
628
|
+
memory_mb_delta: Generated<number>;
|
|
629
|
+
cpu_delta: Generated<number | string>;
|
|
630
|
+
storage_mb_delta: Generated<number>;
|
|
631
|
+
effective_from: Generated<Date>;
|
|
632
|
+
effective_until: Date | null;
|
|
633
|
+
stripe_subscription_item_id: string | null;
|
|
634
|
+
created_at: Generated<Date>;
|
|
635
|
+
}
|
|
636
|
+
interface AccountSpendCapsTable {
|
|
637
|
+
account_id: string;
|
|
638
|
+
monthly_cap_cents: number | null;
|
|
639
|
+
compute_cap_cents: number | null;
|
|
640
|
+
storage_cap_cents: number | null;
|
|
641
|
+
alert_threshold_pct: Generated<number>;
|
|
642
|
+
alert_sent_at: Date | null;
|
|
643
|
+
frozen_at: Date | null;
|
|
644
|
+
updated_at: Generated<Date>;
|
|
645
|
+
}
|
|
646
|
+
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
647
|
+
type ProvisioningAuditStatus = "ok" | "error";
|
|
648
|
+
interface ProvisioningAuditLogTable {
|
|
649
|
+
id: Generated<string>;
|
|
650
|
+
tenant_id: string | null;
|
|
651
|
+
tenant_slug: string | null;
|
|
652
|
+
account_id: string | null;
|
|
653
|
+
actor: string;
|
|
654
|
+
event: ProvisioningAuditEvent;
|
|
655
|
+
status: ProvisioningAuditStatus;
|
|
656
|
+
detail: unknown | null;
|
|
657
|
+
error: string | null;
|
|
658
|
+
created_at: Generated<Date>;
|
|
659
|
+
}
|
|
660
|
+
type Contract = Selectable<ContractsTable>;
|
|
661
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
662
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
663
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
664
|
+
interface SubscriptionsTable {
|
|
665
|
+
id: Generated<string>;
|
|
666
|
+
account_id: string;
|
|
667
|
+
project_id: string | null;
|
|
668
|
+
name: string;
|
|
669
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
670
|
+
subgraph_name: string;
|
|
671
|
+
table_name: string;
|
|
672
|
+
filter: Generated<unknown>;
|
|
673
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
674
|
+
runtime: SubscriptionRuntime | null;
|
|
675
|
+
url: string;
|
|
676
|
+
signing_secret_enc: Buffer;
|
|
677
|
+
auth_config: Generated<unknown>;
|
|
678
|
+
max_retries: Generated<number>;
|
|
679
|
+
timeout_ms: Generated<number>;
|
|
680
|
+
concurrency: Generated<number>;
|
|
681
|
+
circuit_failures: Generated<number>;
|
|
682
|
+
circuit_opened_at: Date | null;
|
|
683
|
+
last_delivery_at: Date | null;
|
|
684
|
+
last_success_at: Date | null;
|
|
685
|
+
last_error: string | null;
|
|
686
|
+
created_at: Generated<Date>;
|
|
687
|
+
updated_at: Generated<Date>;
|
|
688
|
+
}
|
|
689
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
690
|
+
interface SubscriptionOutboxTable {
|
|
691
|
+
id: Generated<string>;
|
|
692
|
+
subscription_id: string;
|
|
693
|
+
subgraph_name: string;
|
|
694
|
+
table_name: string;
|
|
695
|
+
block_height: number | bigint;
|
|
696
|
+
tx_id: string | null;
|
|
697
|
+
row_pk: unknown;
|
|
698
|
+
event_type: string;
|
|
699
|
+
payload: unknown;
|
|
700
|
+
dedup_key: string;
|
|
701
|
+
attempt: Generated<number>;
|
|
702
|
+
next_attempt_at: Generated<Date>;
|
|
703
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
704
|
+
is_replay: Generated<boolean>;
|
|
705
|
+
delivered_at: Date | null;
|
|
706
|
+
failed_at: Date | null;
|
|
707
|
+
locked_by: string | null;
|
|
708
|
+
locked_until: Date | null;
|
|
709
|
+
created_at: Generated<Date>;
|
|
710
|
+
}
|
|
711
|
+
interface SubscriptionDeliveriesTable {
|
|
712
|
+
id: Generated<string>;
|
|
713
|
+
/** Nullable after migration 0077 — outbox row may be cleaned up while
|
|
714
|
+
* delivery telemetry is retained. */
|
|
715
|
+
outbox_id: string | null;
|
|
716
|
+
subscription_id: string;
|
|
717
|
+
attempt: number;
|
|
718
|
+
status_code: number | null;
|
|
719
|
+
response_headers: unknown | null;
|
|
720
|
+
response_body: string | null;
|
|
721
|
+
error_message: string | null;
|
|
722
|
+
duration_ms: number | null;
|
|
723
|
+
dispatched_at: Generated<Date>;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Contract registry queries — backing for trait-based discovery. Populated from
|
|
727
|
+
* contract deploys; ABI fetched async; standards inferred by static analysis.
|
|
728
|
+
*/
|
|
729
|
+
type AbiStatus = "pending" | "fetched" | "failed" | "unparseable";
|
|
730
|
+
/** Record a contract deploy (idempotent). ABI is fetched separately + async. */
|
|
731
|
+
declare function recordContractDeploy(db: Kysely<Database>, row: {
|
|
732
|
+
contractId: string
|
|
733
|
+
deployer: string
|
|
734
|
+
blockHeight: number
|
|
735
|
+
}): Promise<void>;
|
|
736
|
+
/** Store a fetched ABI + the traits/standards derived from it. */
|
|
737
|
+
declare function setContractAbi(db: Kysely<Database>, contractId: string, data: {
|
|
738
|
+
abi: unknown | null
|
|
739
|
+
status: AbiStatus
|
|
740
|
+
declaredTraits?: string[]
|
|
741
|
+
inferredStandards?: string[]
|
|
742
|
+
}): Promise<void>;
|
|
743
|
+
declare function getContract(db: Kysely<Database>, contractId: string): Promise<Contract | null>;
|
|
744
|
+
/** Contracts still awaiting an ABI fetch (drives the fetch/backfill worker). */
|
|
745
|
+
declare function listContractsPendingAbi(db: Kysely<Database>, limit?: number): Promise<Contract[]>;
|
|
746
|
+
type Conformance = "declared" | "inferred" | "any";
|
|
747
|
+
/** Discovery: contracts matching a trait/standard, by conformance source. */
|
|
748
|
+
declare function listContractsByTrait(db: Kysely<Database>, trait: string, opts?: {
|
|
749
|
+
conformance?: Conformance
|
|
750
|
+
limit?: number
|
|
751
|
+
afterId?: string
|
|
752
|
+
}): Promise<Contract[]>;
|
|
753
|
+
/**
|
|
754
|
+
* As-of-block trait resolution (B4): contract IDs conforming to `trait` whose
|
|
755
|
+
* deploy block ≤ `asOfBlock`. Lets a trait-scoped subgraph reindex a token's
|
|
756
|
+
* full history even if classification lagged its deploy.
|
|
757
|
+
*/
|
|
758
|
+
declare function resolveTraitContractIds(db: Kysely<Database>, trait: string, asOfBlock: number): Promise<string[]>;
|
|
759
|
+
/** Reorg: flip contracts deployed at/above a reorged height to non-canonical. */
|
|
760
|
+
declare function markContractsNonCanonical(db: Kysely<Database>, fromBlockHeight: number): Promise<void>;
|
|
761
|
+
export { setContractAbi, resolveTraitContractIds, recordContractDeploy, markContractsNonCanonical, listContractsPendingAbi, listContractsByTrait, getContract, Conformance, AbiStatus };
|