@valve-tech/trueblocks-sdk 0.0.1
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +140 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +35 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated.d.ts +3686 -0
- package/dist/generated.d.ts.map +1 -0
- package/dist/generated.js +10 -0
- package/dist/generated.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/variants/blocks.d.ts +65 -0
- package/dist/variants/blocks.d.ts.map +1 -0
- package/dist/variants/blocks.js +24 -0
- package/dist/variants/blocks.js.map +1 -0
- package/dist/variants/chunks.d.ts +47 -0
- package/dist/variants/chunks.d.ts.map +1 -0
- package/dist/variants/chunks.js +18 -0
- package/dist/variants/chunks.js.map +1 -0
- package/dist/variants/export.d.ts +51 -0
- package/dist/variants/export.d.ts.map +1 -0
- package/dist/variants/export.js +25 -0
- package/dist/variants/export.js.map +1 -0
- package/dist/variants/slurp.d.ts +21 -0
- package/dist/variants/slurp.d.ts.map +1 -0
- package/dist/variants/slurp.js +13 -0
- package/dist/variants/slurp.js.map +1 -0
- package/dist/variants/state.d.ts +27 -0
- package/dist/variants/state.d.ts.map +1 -0
- package/dist/variants/state.js +8 -0
- package/dist/variants/state.js.map +1 -0
- package/dist/variants/traces.d.ts +19 -0
- package/dist/variants/traces.d.ts.map +1 -0
- package/dist/variants/traces.js +8 -0
- package/dist/variants/traces.js.map +1 -0
- package/dist/variants/transactions.d.ts +24 -0
- package/dist/variants/transactions.d.ts.map +1 -0
- package/dist/variants/transactions.js +10 -0
- package/dist/variants/transactions.js.map +1 -0
- package/dist/verbs.d.ts +331 -0
- package/dist/verbs.d.ts.map +1 -0
- package/dist/verbs.js +141 -0
- package/dist/verbs.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { makeVerb } from '../verbs.js';
|
|
2
|
+
export function makeTransactionsVerb(request) {
|
|
3
|
+
const base = makeVerb(request, '/transactions');
|
|
4
|
+
return Object.assign(base, {
|
|
5
|
+
traces: (query) => base({ ...query, traces: true }),
|
|
6
|
+
uniq: (query) => base({ ...query, uniq: true }),
|
|
7
|
+
logs: (query) => base({ ...query, logs: true }),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/variants/transactions.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAA2B,MAAM,aAAa,CAAA;AAoB/D,MAAM,UAAU,oBAAoB,CAAC,OAAkB;IACrD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QACzB,MAAM,EAAE,CAAC,KAA8B,EAAE,EAAE,CACzC,IAAI,CAAC,EAAE,GAAI,KAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,CAE3C;QACH,IAAI,EAAE,CAAC,KAA4B,EAAE,EAAE,CACrC,IAAI,CAAC,EAAE,GAAI,KAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,CAEzC;QACH,IAAI,EAAE,CAAC,KAA4B,EAAE,EAAE,CACrC,IAAI,CAAC,EAAE,GAAI,KAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,CAEzC;KACJ,CAAqB,CAAA;AACxB,CAAC"}
|
package/dist/verbs.d.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import type { RequestFn } from './client.js';
|
|
2
|
+
import type { paths } from './generated.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the query-parameter type for a given chifra endpoint
|
|
5
|
+
* from the generated OpenAPI types. The `query?: infer Q` form
|
|
6
|
+
* matches both required (`query: { … }`) and optional (`query?: { … }`)
|
|
7
|
+
* spec definitions, returning the inner object type either way.
|
|
8
|
+
*/
|
|
9
|
+
export type Query<P extends keyof paths> = paths[P]['get'] extends {
|
|
10
|
+
parameters: {
|
|
11
|
+
query?: infer Q;
|
|
12
|
+
};
|
|
13
|
+
} ? Q : never;
|
|
14
|
+
/**
|
|
15
|
+
* True at type level when a chifra endpoint's `query` parameter is
|
|
16
|
+
* required (the OpenAPI spec did not mark it optional). Used to
|
|
17
|
+
* narrow `VerbFn<P>` to a required-arg signature for endpoints like
|
|
18
|
+
* `/blocks` (which mandates `blocks: string[]`) while keeping a
|
|
19
|
+
* no-arg-allowed signature for endpoints like `/status`.
|
|
20
|
+
*/
|
|
21
|
+
export type IsRequiredQuery<P extends keyof paths> = paths[P]['get'] extends {
|
|
22
|
+
parameters: {
|
|
23
|
+
query: unknown;
|
|
24
|
+
};
|
|
25
|
+
} ? true : false;
|
|
26
|
+
/**
|
|
27
|
+
* Extracts the JSON response body type for a given chifra endpoint.
|
|
28
|
+
*/
|
|
29
|
+
export type Response<P extends keyof paths> = paths[P]['get'] extends {
|
|
30
|
+
responses: {
|
|
31
|
+
200: {
|
|
32
|
+
content: {
|
|
33
|
+
'application/json': infer R;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
} ? R : never;
|
|
38
|
+
/**
|
|
39
|
+
* The callable signature of a verb. Distinguishes endpoints whose
|
|
40
|
+
* `query` is required (call MUST pass an arg, e.g. `client.blocks({ blocks: [...] })`)
|
|
41
|
+
* from those whose `query` is optional (call MAY omit the arg, e.g.
|
|
42
|
+
* `client.status()`). Required fields inside the query object remain
|
|
43
|
+
* required regardless.
|
|
44
|
+
*/
|
|
45
|
+
export type VerbFn<P extends keyof paths> = IsRequiredQuery<P> extends true ? (query: Query<P>) => Promise<Response<P>> : (query?: Query<P>) => Promise<Response<P>>;
|
|
46
|
+
/**
|
|
47
|
+
* Builds a typed verb-method for a chifra endpoint. The runtime is
|
|
48
|
+
* uniform — `query` is always passed through to `request` whether
|
|
49
|
+
* provided or undefined — but the public type narrows to required
|
|
50
|
+
* vs optional based on the spec.
|
|
51
|
+
*/
|
|
52
|
+
export declare function makeVerb<P extends keyof paths>(request: RequestFn, path: P): VerbFn<P>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the full chifra verb surface, one method per OpenAPI path.
|
|
55
|
+
* Each method is typed against its endpoint's parameters and
|
|
56
|
+
* response. JSDoc on each property surfaces the chifra description
|
|
57
|
+
* in editor tooltips.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createVerbs(request: RequestFn): {
|
|
60
|
+
/**
|
|
61
|
+
* `GET /list` — list every appearance of an address (or
|
|
62
|
+
* addresses) anywhere on the chain. Mirrors `chifra list`.
|
|
63
|
+
*/
|
|
64
|
+
list: (query: {
|
|
65
|
+
addrs: string[];
|
|
66
|
+
count?: boolean;
|
|
67
|
+
noZero?: boolean;
|
|
68
|
+
bounds?: boolean;
|
|
69
|
+
unripe?: boolean;
|
|
70
|
+
silent?: boolean;
|
|
71
|
+
firstRecord?: number;
|
|
72
|
+
maxRecords?: number;
|
|
73
|
+
reversed?: boolean;
|
|
74
|
+
firstBlock?: number;
|
|
75
|
+
lastBlock?: number;
|
|
76
|
+
chain?: string;
|
|
77
|
+
noHeader?: boolean;
|
|
78
|
+
fmt?: string;
|
|
79
|
+
}) => Promise<{
|
|
80
|
+
data?: (import("./generated.js").components["schemas"]["appearance"] | import("./generated.js").components["schemas"]["bounds"] | import("./generated.js").components["schemas"]["monitor"])[];
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* `GET /export` — export full transaction details for one or
|
|
84
|
+
* more monitored addresses. Callable directly for the
|
|
85
|
+
* polymorphic union; attached variants (`.appearances`,
|
|
86
|
+
* `.receipts`, `.logs`, `.approvals`, `.traces`, `.neighbors`,
|
|
87
|
+
* `.statements`, `.transfers`, `.assets`, `.balances`,
|
|
88
|
+
* `.withdrawals`, `.count`) preselect the corresponding flag
|
|
89
|
+
* and narrow the return. Mirrors `chifra export`.
|
|
90
|
+
*/
|
|
91
|
+
export: import("./variants/export.js").ExportVerb;
|
|
92
|
+
/**
|
|
93
|
+
* `GET /monitors` — manage and inspect address monitors. Mirrors
|
|
94
|
+
* `chifra monitors`.
|
|
95
|
+
*/
|
|
96
|
+
monitors: (query?: {
|
|
97
|
+
addrs?: string[];
|
|
98
|
+
delete?: boolean;
|
|
99
|
+
undelete?: boolean;
|
|
100
|
+
remove?: boolean;
|
|
101
|
+
clean?: boolean;
|
|
102
|
+
list?: boolean;
|
|
103
|
+
count?: boolean;
|
|
104
|
+
staged?: boolean;
|
|
105
|
+
chain?: string;
|
|
106
|
+
noHeader?: boolean;
|
|
107
|
+
cache?: boolean;
|
|
108
|
+
decache?: boolean;
|
|
109
|
+
fmt?: string;
|
|
110
|
+
} | undefined) => Promise<{
|
|
111
|
+
data?: (import("./generated.js").components["schemas"]["message"] | import("./generated.js").components["schemas"]["monitor"] | import("./generated.js").components["schemas"]["monitorClean"])[];
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* `GET /names` — query and manage address-to-name mappings.
|
|
115
|
+
* Mirrors `chifra names`.
|
|
116
|
+
*/
|
|
117
|
+
names: (query: {
|
|
118
|
+
terms: string[];
|
|
119
|
+
expand?: boolean;
|
|
120
|
+
matchCase?: boolean;
|
|
121
|
+
all?: boolean;
|
|
122
|
+
custom?: boolean;
|
|
123
|
+
prefund?: boolean;
|
|
124
|
+
addr?: boolean;
|
|
125
|
+
tags?: boolean;
|
|
126
|
+
clean?: boolean;
|
|
127
|
+
regular?: boolean;
|
|
128
|
+
count?: boolean;
|
|
129
|
+
dryRun?: boolean;
|
|
130
|
+
autoname?: string;
|
|
131
|
+
create?: string;
|
|
132
|
+
update?: string;
|
|
133
|
+
delete?: string;
|
|
134
|
+
undelete?: string;
|
|
135
|
+
remove?: string;
|
|
136
|
+
chain?: string;
|
|
137
|
+
noHeader?: boolean;
|
|
138
|
+
fmt?: string;
|
|
139
|
+
}) => Promise<{
|
|
140
|
+
data?: (import("./generated.js").components["schemas"]["message"] | import("./generated.js").components["schemas"]["name"])[];
|
|
141
|
+
}>;
|
|
142
|
+
/**
|
|
143
|
+
* `GET /abis` — fetch ABIs for known contracts. Mirrors
|
|
144
|
+
* `chifra abis`.
|
|
145
|
+
*/
|
|
146
|
+
abis: (query: {
|
|
147
|
+
addrs: string[];
|
|
148
|
+
known?: boolean;
|
|
149
|
+
proxyFor?: string;
|
|
150
|
+
list?: boolean;
|
|
151
|
+
details?: boolean;
|
|
152
|
+
count?: boolean;
|
|
153
|
+
find?: string[];
|
|
154
|
+
hint?: string[];
|
|
155
|
+
encode?: string;
|
|
156
|
+
chain?: string;
|
|
157
|
+
noHeader?: boolean;
|
|
158
|
+
cache?: boolean;
|
|
159
|
+
decache?: boolean;
|
|
160
|
+
fmt?: string;
|
|
161
|
+
}) => Promise<{
|
|
162
|
+
data?: (import("./generated.js").components["schemas"]["abi"] | import("./generated.js").components["schemas"]["function"] | import("./generated.js").components["schemas"]["parameter"])[];
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* `GET /blocks` — retrieve one or more blocks from chain or
|
|
166
|
+
* local cache. Callable directly for the polymorphic response
|
|
167
|
+
* (10-type union from the OpenAPI spec); attached variants
|
|
168
|
+
* (`.hashes`, `.uncles`, `.traces`, `.uniq`, `.logs`,
|
|
169
|
+
* `.withdrawals`, `.count`) preselect the corresponding flag
|
|
170
|
+
* and narrow the return to a single concrete type. Mirrors
|
|
171
|
+
* `chifra blocks` with its various output modes.
|
|
172
|
+
*/
|
|
173
|
+
blocks: import("./variants/blocks.js").BlocksVerb;
|
|
174
|
+
/**
|
|
175
|
+
* `GET /transactions` — retrieve one or more transactions by
|
|
176
|
+
* hash, block.txid, or block.address. Callable directly for
|
|
177
|
+
* the polymorphic union; attached variants (`.traces`, `.uniq`,
|
|
178
|
+
* `.logs`) preselect the corresponding flag and narrow the
|
|
179
|
+
* return. Mirrors `chifra transactions`.
|
|
180
|
+
*/
|
|
181
|
+
transactions: import("./variants/transactions.js").TransactionsVerb;
|
|
182
|
+
/**
|
|
183
|
+
* `GET /receipts` — retrieve receipts for one or more
|
|
184
|
+
* transactions. Mirrors `chifra receipts`.
|
|
185
|
+
*/
|
|
186
|
+
receipts: (query: {
|
|
187
|
+
transactions: string[];
|
|
188
|
+
articulate?: boolean;
|
|
189
|
+
chain?: string;
|
|
190
|
+
noHeader?: boolean;
|
|
191
|
+
cache?: boolean;
|
|
192
|
+
decache?: boolean;
|
|
193
|
+
fmt?: string;
|
|
194
|
+
}) => Promise<{
|
|
195
|
+
data?: (import("./generated.js").components["schemas"]["function"] | import("./generated.js").components["schemas"]["parameter"] | import("./generated.js").components["schemas"]["receipt"])[];
|
|
196
|
+
}>;
|
|
197
|
+
/**
|
|
198
|
+
* `GET /logs` — retrieve event logs for one or more
|
|
199
|
+
* transactions. Mirrors `chifra logs`.
|
|
200
|
+
*/
|
|
201
|
+
logs: (query: {
|
|
202
|
+
transactions: string[];
|
|
203
|
+
emitter?: string[];
|
|
204
|
+
topic?: string[];
|
|
205
|
+
articulate?: boolean;
|
|
206
|
+
chain?: string;
|
|
207
|
+
noHeader?: boolean;
|
|
208
|
+
cache?: boolean;
|
|
209
|
+
decache?: boolean;
|
|
210
|
+
fmt?: string;
|
|
211
|
+
}) => Promise<{
|
|
212
|
+
data?: (import("./generated.js").components["schemas"]["function"] | import("./generated.js").components["schemas"]["log"] | import("./generated.js").components["schemas"]["message"] | import("./generated.js").components["schemas"]["parameter"])[];
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* `GET /traces` — retrieve execution traces for one or more
|
|
216
|
+
* transactions. Callable directly; `.count` variant returns
|
|
217
|
+
* trace counts only. Mirrors `chifra traces`.
|
|
218
|
+
*/
|
|
219
|
+
traces: import("./variants/traces.js").TracesVerb;
|
|
220
|
+
/**
|
|
221
|
+
* `GET /when` — block-by-time / block-by-date queries; map
|
|
222
|
+
* timestamps and named events to block numbers. Mirrors
|
|
223
|
+
* `chifra when`.
|
|
224
|
+
*/
|
|
225
|
+
when: (query?: {
|
|
226
|
+
blocks?: string[];
|
|
227
|
+
list?: boolean;
|
|
228
|
+
timestamps?: boolean;
|
|
229
|
+
count?: boolean;
|
|
230
|
+
repair?: boolean;
|
|
231
|
+
check?: boolean;
|
|
232
|
+
update?: boolean;
|
|
233
|
+
deep?: number;
|
|
234
|
+
chain?: string;
|
|
235
|
+
noHeader?: boolean;
|
|
236
|
+
cache?: boolean;
|
|
237
|
+
decache?: boolean;
|
|
238
|
+
fmt?: string;
|
|
239
|
+
} | undefined) => Promise<{
|
|
240
|
+
data?: (import("./generated.js").components["schemas"]["count"] | import("./generated.js").components["schemas"]["message"] | import("./generated.js").components["schemas"]["namedBlock"] | import("./generated.js").components["schemas"]["timestamp"])[];
|
|
241
|
+
}>;
|
|
242
|
+
/**
|
|
243
|
+
* `GET /state` — read account state at a block (balance, nonce,
|
|
244
|
+
* code, storage). Callable directly; `.call` variant performs
|
|
245
|
+
* an `eth_call`-style read. Mirrors `chifra state`.
|
|
246
|
+
*/
|
|
247
|
+
state: import("./variants/state.js").StateVerb;
|
|
248
|
+
/**
|
|
249
|
+
* `GET /tokens` — read token balances for accounts at given
|
|
250
|
+
* block(s). Mirrors `chifra tokens`.
|
|
251
|
+
*/
|
|
252
|
+
tokens: (query: {
|
|
253
|
+
addrs: string[];
|
|
254
|
+
blocks?: string[];
|
|
255
|
+
approvals?: boolean;
|
|
256
|
+
parts?: ("name" | "symbol" | "decimals" | "totalSupply" | "version" | "some" | "all")[];
|
|
257
|
+
byAcct?: boolean;
|
|
258
|
+
changes?: boolean;
|
|
259
|
+
noZero?: boolean;
|
|
260
|
+
chain?: string;
|
|
261
|
+
noHeader?: boolean;
|
|
262
|
+
cache?: boolean;
|
|
263
|
+
decache?: boolean;
|
|
264
|
+
fmt?: string;
|
|
265
|
+
}) => Promise<{
|
|
266
|
+
data?: (import("./generated.js").components["schemas"]["approval"] | import("./generated.js").components["schemas"]["token"])[];
|
|
267
|
+
}>;
|
|
268
|
+
/**
|
|
269
|
+
* `GET /config` — daemon configuration; read effective settings
|
|
270
|
+
* or list known chains. Mirrors `chifra config`.
|
|
271
|
+
*/
|
|
272
|
+
config: (query?: {
|
|
273
|
+
mode?: "show" | "edit";
|
|
274
|
+
paths?: boolean;
|
|
275
|
+
dump?: boolean;
|
|
276
|
+
chain?: string;
|
|
277
|
+
noHeader?: boolean;
|
|
278
|
+
fmt?: string;
|
|
279
|
+
} | undefined) => Promise<{
|
|
280
|
+
data?: import("./generated.js").components["schemas"]["chain"][];
|
|
281
|
+
}>;
|
|
282
|
+
/**
|
|
283
|
+
* `GET /status` — daemon health and per-cache status. Mirrors
|
|
284
|
+
* `chifra status`.
|
|
285
|
+
*/
|
|
286
|
+
status: (query?: {
|
|
287
|
+
modes?: ("index" | "blooms" | "blocks" | "transactions" | "traces" | "logs" | "statements" | "results" | "state" | "tokens" | "monitors" | "names" | "abis" | "slurps" | "staging" | "unripe" | "maps" | "some" | "all")[];
|
|
288
|
+
diagnose?: boolean;
|
|
289
|
+
firstRecord?: number;
|
|
290
|
+
maxRecords?: number;
|
|
291
|
+
chains?: boolean;
|
|
292
|
+
caches?: boolean;
|
|
293
|
+
healthcheck?: boolean;
|
|
294
|
+
chain?: string;
|
|
295
|
+
noHeader?: boolean;
|
|
296
|
+
fmt?: string;
|
|
297
|
+
} | undefined) => Promise<{
|
|
298
|
+
data?: (import("./generated.js").components["schemas"]["cacheItem"] | import("./generated.js").components["schemas"]["chain"] | import("./generated.js").components["schemas"]["status"])[];
|
|
299
|
+
}>;
|
|
300
|
+
/**
|
|
301
|
+
* `GET /chunks` — manage and inspect index chunks. Callable
|
|
302
|
+
* directly; mode variants (`.manifest`, `.index`, `.blooms`,
|
|
303
|
+
* `.pins`, `.addresses`, `.appearances`, `.stats`) preselect
|
|
304
|
+
* the chunks `mode` enum and narrow the return. Mirrors
|
|
305
|
+
* `chifra chunks`.
|
|
306
|
+
*/
|
|
307
|
+
chunks: import("./variants/chunks.js").ChunksVerb;
|
|
308
|
+
/**
|
|
309
|
+
* `GET /init` — initialize the daemon's index by downloading
|
|
310
|
+
* pinned chunks. Mirrors `chifra init`.
|
|
311
|
+
*/
|
|
312
|
+
init: (query?: {
|
|
313
|
+
all?: boolean;
|
|
314
|
+
example?: string;
|
|
315
|
+
dryRun?: boolean;
|
|
316
|
+
firstBlock?: number;
|
|
317
|
+
sleep?: number;
|
|
318
|
+
chain?: string;
|
|
319
|
+
} | undefined) => Promise<{
|
|
320
|
+
data?: (import("./generated.js").components["schemas"]["chunkRecord"] | import("./generated.js").components["schemas"]["manifest"])[];
|
|
321
|
+
}>;
|
|
322
|
+
/**
|
|
323
|
+
* `GET /slurp` — fetch transactions for an address from a
|
|
324
|
+
* 3rd-party source (e.g. Etherscan). Callable directly;
|
|
325
|
+
* `.appearances` and `.count` variants narrow to specific
|
|
326
|
+
* output modes. Mirrors `chifra slurp`.
|
|
327
|
+
*/
|
|
328
|
+
slurp: import("./variants/slurp.js").SlurpVerb;
|
|
329
|
+
};
|
|
330
|
+
export type Verbs = ReturnType<typeof createVerbs>;
|
|
331
|
+
//# sourceMappingURL=verbs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verbs.d.ts","sourceRoot":"","sources":["../src/verbs.ts"],"names":[],"mappings":"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"}
|
package/dist/verbs.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { makeBlocksVerb } from './variants/blocks.js';
|
|
2
|
+
import { makeChunksVerb } from './variants/chunks.js';
|
|
3
|
+
import { makeExportVerb } from './variants/export.js';
|
|
4
|
+
import { makeSlurpVerb } from './variants/slurp.js';
|
|
5
|
+
import { makeStateVerb } from './variants/state.js';
|
|
6
|
+
import { makeTracesVerb } from './variants/traces.js';
|
|
7
|
+
import { makeTransactionsVerb } from './variants/transactions.js';
|
|
8
|
+
/**
|
|
9
|
+
* Builds a typed verb-method for a chifra endpoint. The runtime is
|
|
10
|
+
* uniform — `query` is always passed through to `request` whether
|
|
11
|
+
* provided or undefined — but the public type narrows to required
|
|
12
|
+
* vs optional based on the spec.
|
|
13
|
+
*/
|
|
14
|
+
export function makeVerb(request, path) {
|
|
15
|
+
const fn = async (query) => {
|
|
16
|
+
return request(path, query);
|
|
17
|
+
};
|
|
18
|
+
return fn;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the full chifra verb surface, one method per OpenAPI path.
|
|
22
|
+
* Each method is typed against its endpoint's parameters and
|
|
23
|
+
* response. JSDoc on each property surfaces the chifra description
|
|
24
|
+
* in editor tooltips.
|
|
25
|
+
*/
|
|
26
|
+
export function createVerbs(request) {
|
|
27
|
+
return {
|
|
28
|
+
/**
|
|
29
|
+
* `GET /list` — list every appearance of an address (or
|
|
30
|
+
* addresses) anywhere on the chain. Mirrors `chifra list`.
|
|
31
|
+
*/
|
|
32
|
+
list: makeVerb(request, '/list'),
|
|
33
|
+
/**
|
|
34
|
+
* `GET /export` — export full transaction details for one or
|
|
35
|
+
* more monitored addresses. Callable directly for the
|
|
36
|
+
* polymorphic union; attached variants (`.appearances`,
|
|
37
|
+
* `.receipts`, `.logs`, `.approvals`, `.traces`, `.neighbors`,
|
|
38
|
+
* `.statements`, `.transfers`, `.assets`, `.balances`,
|
|
39
|
+
* `.withdrawals`, `.count`) preselect the corresponding flag
|
|
40
|
+
* and narrow the return. Mirrors `chifra export`.
|
|
41
|
+
*/
|
|
42
|
+
export: makeExportVerb(request),
|
|
43
|
+
/**
|
|
44
|
+
* `GET /monitors` — manage and inspect address monitors. Mirrors
|
|
45
|
+
* `chifra monitors`.
|
|
46
|
+
*/
|
|
47
|
+
monitors: makeVerb(request, '/monitors'),
|
|
48
|
+
/**
|
|
49
|
+
* `GET /names` — query and manage address-to-name mappings.
|
|
50
|
+
* Mirrors `chifra names`.
|
|
51
|
+
*/
|
|
52
|
+
names: makeVerb(request, '/names'),
|
|
53
|
+
/**
|
|
54
|
+
* `GET /abis` — fetch ABIs for known contracts. Mirrors
|
|
55
|
+
* `chifra abis`.
|
|
56
|
+
*/
|
|
57
|
+
abis: makeVerb(request, '/abis'),
|
|
58
|
+
/**
|
|
59
|
+
* `GET /blocks` — retrieve one or more blocks from chain or
|
|
60
|
+
* local cache. Callable directly for the polymorphic response
|
|
61
|
+
* (10-type union from the OpenAPI spec); attached variants
|
|
62
|
+
* (`.hashes`, `.uncles`, `.traces`, `.uniq`, `.logs`,
|
|
63
|
+
* `.withdrawals`, `.count`) preselect the corresponding flag
|
|
64
|
+
* and narrow the return to a single concrete type. Mirrors
|
|
65
|
+
* `chifra blocks` with its various output modes.
|
|
66
|
+
*/
|
|
67
|
+
blocks: makeBlocksVerb(request),
|
|
68
|
+
/**
|
|
69
|
+
* `GET /transactions` — retrieve one or more transactions by
|
|
70
|
+
* hash, block.txid, or block.address. Callable directly for
|
|
71
|
+
* the polymorphic union; attached variants (`.traces`, `.uniq`,
|
|
72
|
+
* `.logs`) preselect the corresponding flag and narrow the
|
|
73
|
+
* return. Mirrors `chifra transactions`.
|
|
74
|
+
*/
|
|
75
|
+
transactions: makeTransactionsVerb(request),
|
|
76
|
+
/**
|
|
77
|
+
* `GET /receipts` — retrieve receipts for one or more
|
|
78
|
+
* transactions. Mirrors `chifra receipts`.
|
|
79
|
+
*/
|
|
80
|
+
receipts: makeVerb(request, '/receipts'),
|
|
81
|
+
/**
|
|
82
|
+
* `GET /logs` — retrieve event logs for one or more
|
|
83
|
+
* transactions. Mirrors `chifra logs`.
|
|
84
|
+
*/
|
|
85
|
+
logs: makeVerb(request, '/logs'),
|
|
86
|
+
/**
|
|
87
|
+
* `GET /traces` — retrieve execution traces for one or more
|
|
88
|
+
* transactions. Callable directly; `.count` variant returns
|
|
89
|
+
* trace counts only. Mirrors `chifra traces`.
|
|
90
|
+
*/
|
|
91
|
+
traces: makeTracesVerb(request),
|
|
92
|
+
/**
|
|
93
|
+
* `GET /when` — block-by-time / block-by-date queries; map
|
|
94
|
+
* timestamps and named events to block numbers. Mirrors
|
|
95
|
+
* `chifra when`.
|
|
96
|
+
*/
|
|
97
|
+
when: makeVerb(request, '/when'),
|
|
98
|
+
/**
|
|
99
|
+
* `GET /state` — read account state at a block (balance, nonce,
|
|
100
|
+
* code, storage). Callable directly; `.call` variant performs
|
|
101
|
+
* an `eth_call`-style read. Mirrors `chifra state`.
|
|
102
|
+
*/
|
|
103
|
+
state: makeStateVerb(request),
|
|
104
|
+
/**
|
|
105
|
+
* `GET /tokens` — read token balances for accounts at given
|
|
106
|
+
* block(s). Mirrors `chifra tokens`.
|
|
107
|
+
*/
|
|
108
|
+
tokens: makeVerb(request, '/tokens'),
|
|
109
|
+
/**
|
|
110
|
+
* `GET /config` — daemon configuration; read effective settings
|
|
111
|
+
* or list known chains. Mirrors `chifra config`.
|
|
112
|
+
*/
|
|
113
|
+
config: makeVerb(request, '/config'),
|
|
114
|
+
/**
|
|
115
|
+
* `GET /status` — daemon health and per-cache status. Mirrors
|
|
116
|
+
* `chifra status`.
|
|
117
|
+
*/
|
|
118
|
+
status: makeVerb(request, '/status'),
|
|
119
|
+
/**
|
|
120
|
+
* `GET /chunks` — manage and inspect index chunks. Callable
|
|
121
|
+
* directly; mode variants (`.manifest`, `.index`, `.blooms`,
|
|
122
|
+
* `.pins`, `.addresses`, `.appearances`, `.stats`) preselect
|
|
123
|
+
* the chunks `mode` enum and narrow the return. Mirrors
|
|
124
|
+
* `chifra chunks`.
|
|
125
|
+
*/
|
|
126
|
+
chunks: makeChunksVerb(request),
|
|
127
|
+
/**
|
|
128
|
+
* `GET /init` — initialize the daemon's index by downloading
|
|
129
|
+
* pinned chunks. Mirrors `chifra init`.
|
|
130
|
+
*/
|
|
131
|
+
init: makeVerb(request, '/init'),
|
|
132
|
+
/**
|
|
133
|
+
* `GET /slurp` — fetch transactions for an address from a
|
|
134
|
+
* 3rd-party source (e.g. Etherscan). Callable directly;
|
|
135
|
+
* `.appearances` and `.count` variants narrow to specific
|
|
136
|
+
* output modes. Mirrors `chifra slurp`.
|
|
137
|
+
*/
|
|
138
|
+
slurp: makeSlurpVerb(request),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=verbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verbs.js","sourceRoot":"","sources":["../src/verbs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAgDjE;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAkB,EAClB,IAAO;IAEP,MAAM,EAAE,GAAG,KAAK,EAAE,KAAe,EAAwB,EAAE;QACzD,OAAO,OAAO,CACZ,IAAI,EACJ,KAA4C,CAC7C,CAAA;IACH,CAAC,CAAA;IACD,OAAO,EAAe,CAAA;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAkB;IAC5C,OAAO;QACL;;;WAGG;QACH,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAEhC;;;;;;;;WAQG;QACH,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC;QAE/B;;;WAGG;QACH,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;QAExC;;;WAGG;QACH,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;QAElC;;;WAGG;QACH,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAEhC;;;;;;;;WAQG;QACH,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC;QAE/B;;;;;;WAMG;QACH,YAAY,EAAE,oBAAoB,CAAC,OAAO,CAAC;QAE3C;;;WAGG;QACH,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;QAExC;;;WAGG;QACH,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAEhC;;;;WAIG;QACH,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC;QAE/B;;;;WAIG;QACH,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAEhC;;;;WAIG;QACH,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC;QAE7B;;;WAGG;QACH,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;QAEpC;;;WAGG;QACH,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;QAEpC;;;WAGG;QACH,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;QAEpC;;;;;;WAMG;QACH,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC;QAE/B;;;WAGG;QACH,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAEhC;;;;;WAKG;QACH,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC;KAC9B,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@valve-tech/trueblocks-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Typed TypeScript HTTP client to a running TrueBlocks chifra daemon. Wraps chifra's REST surface (the same one served by `chifra daemon`) with TS types generated from the upstream OpenAPI spec; no Go runtime, no shelling-out.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node scripts/codegen.mjs --if-missing && tsc -p .",
|
|
24
|
+
"typecheck": "node scripts/codegen.mjs --if-missing && tsc -p . --noEmit",
|
|
25
|
+
"lint": "eslint src",
|
|
26
|
+
"test": "node scripts/codegen.mjs --if-missing && vitest run",
|
|
27
|
+
"test:coverage": "node scripts/codegen.mjs --if-missing && vitest run --coverage",
|
|
28
|
+
"codegen": "node scripts/codegen.mjs",
|
|
29
|
+
"prepare": "yarn build"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"openapi-typescript": "^7.4.0"
|
|
33
|
+
}
|
|
34
|
+
}
|