-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathopenapi.yaml
More file actions
792 lines (749 loc) · 20.8 KB
/
Copy pathopenapi.yaml
File metadata and controls
792 lines (749 loc) · 20.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
openapi: "3.1.0"
info:
title: Lumenqraph API
version: "0.1.0"
description: |
Open-source, self-hostable event indexer for Soroban smart contracts on Stellar.
Exposes decoded contract events, materialized token transfers, on-chain
contract interfaces, read-only view-function calls, and webhook management
over a plain REST API.
license:
name: MIT
url: https://github.com/Lumen-Scribe/Lumenqraph/blob/main/LICENSE
contact:
url: https://github.com/Lumen-Scribe/Lumenqraph
servers:
- url: http://localhost:8080
description: Local development
security:
- ApiKeyHeader: []
- ApiKeyBearer: []
- {}
# ---------------------------------------------------------------------------
# Security schemes
# ---------------------------------------------------------------------------
components:
securitySchemes:
ApiKeyHeader:
type: apiKey
in: header
name: x-api-key
ApiKeyBearer:
type: http
scheme: bearer
# ---------------------------------------------------------------------------
# Shared schemas
# ---------------------------------------------------------------------------
schemas:
# ---- contracts ----
Contract:
type: object
required: [contract_id, event_count]
properties:
contract_id:
type: string
description: Bech32m `C…` contract address.
event_count:
type: integer
format: int64
first_seen_ledger:
type: integer
format: int64
nullable: true
last_seen_ledger:
type: integer
format: int64
nullable: true
# ---- events ----
EventRecord:
type: object
required:
- event_id
- contract_id
- ledger
- ledger_closed_at
- event_type
- topics
- decoded_topics
- value
- decoded_value
- tx_hash
- in_successful_call
- paging_token
- created_at
properties:
event_id:
type: string
contract_id:
type: string
ledger:
type: integer
format: int64
ledger_closed_at:
type: string
format: date-time
event_type:
type: string
enum: [contract, system, diagnostic]
topics:
type: array
items:
type: string
description: Raw base64 XDR topics.
decoded_topics:
description: Decoded topics as JSON values.
event_name:
type: string
nullable: true
description: Best-effort event name (first topic decoded as a symbol).
value:
type: string
description: Raw base64 XDR event body.
decoded_value:
description: Decoded event body as a JSON value.
enriched:
nullable: true
description: |
Named, typed record built from the contract's on-chain spec.
`null` when no spec is available for this event.
tx_hash:
type: string
in_successful_call:
type: boolean
paging_token:
type: string
created_at:
type: string
format: date-time
# ---- transfers ----
Transfer:
type: object
required: [event_id, contract_id, amount, ledger, ledger_closed_at]
properties:
event_id:
type: string
contract_id:
type: string
from_addr:
type: string
nullable: true
to_addr:
type: string
nullable: true
amount:
type: string
description: Token amount as a decimal string (i128 exceeds JSON integer range).
ledger:
type: integer
format: int64
ledger_closed_at:
type: string
format: date-time
# ---- state ----
StateVersion:
type: object
required: [ledger, storage, captured_at]
properties:
ledger:
type: integer
format: int64
storage:
description: Decoded contract instance storage as a JSON value.
captured_at:
type: string
format: date-time
ContractState:
type: object
required: [contract_id, count, versions]
properties:
contract_id:
type: string
count:
type: integer
versions:
type: array
items:
$ref: "#/components/schemas/StateVersion"
# ---- per-key data ----
DataKey:
type: object
required: [key_hash, key, durability, ledger, value, captured_at]
properties:
key_hash:
type: string
key:
description: The storage key as a JSON value.
durability:
type: string
enum: [persistent, temporary]
ledger:
type: integer
format: int64
value:
description: The decoded value as a JSON value.
label:
type: string
nullable: true
captured_at:
type: string
format: date-time
ContractData:
type: object
required: [contract_id, count, keys]
properties:
contract_id:
type: string
count:
type: integer
keys:
type: array
items:
$ref: "#/components/schemas/DataKey"
DataKeyVersionEntry:
type: object
required: [ledger, value, captured_at]
properties:
ledger:
type: integer
format: int64
value:
description: The decoded value at this ledger.
captured_at:
type: string
format: date-time
DataKeyHistory:
type: object
required: [contract_id, key_hash, key, durability, count, versions]
properties:
contract_id:
type: string
key_hash:
type: string
key:
description: The storage key as a JSON value.
durability:
type: string
enum: [persistent, temporary]
label:
type: string
nullable: true
count:
type: integer
versions:
type: array
items:
$ref: "#/components/schemas/DataKeyVersionEntry"
# ---- call / simulate ----
CallRequest:
type: object
required: [function]
properties:
function:
type: string
args:
description: Arguments by name (object) or as a positional array.
nullable: true
source_account:
type: string
nullable: true
description: Optional `G…` source account for the simulation.
CallResult:
type: object
required: [contract_id, function, result, simulated_at_ledger]
properties:
contract_id:
type: string
function:
type: string
result:
description: Typed result decoded from the contract's on-chain spec.
simulated_at_ledger:
type: integer
format: int64
events:
type: array
description: Present for `simulate` — the events the call would emit.
min_resource_fee:
type: string
description: Present for `simulate` — minimum resource fee in stroops.
nullable: true
# ---- webhooks ----
WebhookKind:
type: string
enum: [event, upgrade]
description: |
`event` — fires when a matching contract event is indexed.
`upgrade` — fires when the contract's on-chain interface changes.
CreateWebhookRequest:
type: object
required: [url]
properties:
url:
type: string
format: uri
kind:
$ref: "#/components/schemas/WebhookKind"
contract_id:
type: string
nullable: true
event_name:
type: string
nullable: true
WebhookSubscription:
type: object
required: [id, url, kind, active, created_at]
properties:
id:
type: string
format: uuid
url:
type: string
format: uri
kind:
$ref: "#/components/schemas/WebhookKind"
contract_id:
type: string
nullable: true
event_name:
type: string
nullable: true
active:
type: boolean
created_at:
type: string
format: date-time
WebhookCreated:
allOf:
- $ref: "#/components/schemas/WebhookSubscription"
- type: object
required: [secret]
properties:
secret:
type: string
description: |
HMAC-SHA256 signing secret. Returned only at creation — store it
securely; it cannot be retrieved later. Use `verifyWebhook()` in
the SDK to verify deliveries.
# ---- health ----
HealthResponse:
type: object
required: [status, last_processed_ledger, chain_tip_ledger, lag_ledgers]
properties:
status:
type: string
enum: [ok, lagging]
last_processed_ledger:
type: integer
format: int64
chain_tip_ledger:
type: integer
format: int64
lag_ledgers:
type: integer
format: int64
events_ingested_total:
type: integer
format: int64
errors_total:
type: integer
format: int64
updated_at:
type: string
format: date-time
nullable: true
# ---- error ----
ErrorResponse:
type: object
required: [error]
properties:
error:
type: string
# ---- reusable parameters ----
parameters:
ContractId:
name: contract_id
in: path
required: true
schema:
type: string
description: Bech32m `C…` contract address.
KeyHash:
name: key_hash
in: path
required: true
schema:
type: string
Limit:
name: limit
in: query
schema:
type: integer
minimum: 1
description: Maximum number of results to return.
Offset:
name: offset
in: query
schema:
type: integer
minimum: 0
description: Number of results to skip (pagination).
# ---- reusable responses ----
responses:
NotFound:
description: The requested resource was not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
Unauthorized:
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
TooManyRequests:
description: Rate limit exceeded.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
# ---------------------------------------------------------------------------
# Paths
# ---------------------------------------------------------------------------
paths:
/health:
get:
operationId: getHealth
summary: Liveness and chain-tip lag report.
description: Always public — no auth required.
security: []
tags: [observability]
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
/contracts:
get:
operationId: listContracts
summary: Contracts the indexer has seen, with per-contract event counts.
tags: [contracts]
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Contract"
"401":
$ref: "#/components/responses/Unauthorized"
"429":
$ref: "#/components/responses/TooManyRequests"
/contracts/{contract_id}/interface:
get:
operationId: getContractInterface
summary: Decoded on-chain interface (functions, events, types).
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
- name: version
in: query
schema:
type: integer
description: Return the interface as of a historical version. Default is current.
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
"404":
$ref: "#/components/responses/NotFound"
/contracts/{contract_id}/interface/history:
get:
operationId: getContractInterfaceHistory
summary: Every interface version observed, newest first.
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
- $ref: "#/components/parameters/Limit"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
"404":
$ref: "#/components/responses/NotFound"
/contracts/{contract_id}/interface/diff:
get:
operationId: getContractInterfaceDiff
summary: What changed between two interface versions.
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
- name: from
in: query
schema:
type: integer
- name: to
in: query
schema:
type: integer
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
"400":
description: Invalid version range.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
$ref: "#/components/responses/NotFound"
/contracts/{contract_id}/state:
get:
operationId: getContractState
summary: Versioned snapshots of contract instance storage.
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
- $ref: "#/components/parameters/Limit"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/ContractState"
"404":
$ref: "#/components/responses/NotFound"
/contracts/{contract_id}/data:
get:
operationId: getContractData
summary: Latest value of every per-key storage entry.
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
- name: label
in: query
schema:
type: string
description: Filter to a discovery label, e.g. `balance`.
- $ref: "#/components/parameters/Limit"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/ContractData"
"404":
$ref: "#/components/responses/NotFound"
/contracts/{contract_id}/data/{key_hash}:
get:
operationId: getContractDataKey
summary: Version history of a single per-key storage entry.
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
- $ref: "#/components/parameters/KeyHash"
- $ref: "#/components/parameters/Limit"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/DataKeyHistory"
"404":
$ref: "#/components/responses/NotFound"
/contracts/{contract_id}/functions:
get:
operationId: listContractFunctions
summary: Callable functions with typed inputs/outputs.
tags: [contracts]
parameters:
- $ref: "#/components/parameters/ContractId"
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
/contracts/{contract_id}/events:
get:
operationId: listContractEvents
summary: Events for a contract, newest first.
tags: [events]
parameters:
- $ref: "#/components/parameters/ContractId"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
- name: event_name
in: query
schema:
type: string
description: Filter to a specific event name.
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/EventRecord"
/contracts/{contract_id}/transfers:
get:
operationId: listContractTransfers
summary: Materialized SEP-41 token transfers, newest first.
tags: [transfers]
parameters:
- $ref: "#/components/parameters/ContractId"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Transfer"
/contracts/{contract_id}/call:
post:
operationId: callContractFunction
summary: Invoke a view function read-only and get a typed result.
tags: [read-layer]
parameters:
- $ref: "#/components/parameters/ContractId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CallRequest"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CallResult"
"400":
description: Unknown function or bad arguments.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/contracts/{contract_id}/simulate:
post:
operationId: simulateContractCall
summary: Dry-run any call and preview its result, events, and cost.
tags: [read-layer]
parameters:
- $ref: "#/components/parameters/ContractId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CallRequest"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CallResult"
"400":
description: Unknown function or bad arguments.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/webhooks:
post:
operationId: createWebhook
summary: Register a webhook subscription.
tags: [webhooks]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateWebhookRequest"
responses:
"200":
description: Subscription created. The `secret` field is only returned here.
content:
application/json:
schema:
$ref: "#/components/schemas/WebhookCreated"
get:
operationId: listWebhooks
summary: List webhook subscriptions (secrets omitted).
tags: [webhooks]
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/WebhookSubscription"
/webhooks/{id}:
delete:
operationId: deleteWebhook
summary: Delete a webhook subscription.
tags: [webhooks]
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
responses:
"204":
description: Deleted.
"404":
$ref: "#/components/responses/NotFound"
/graphql:
post:
operationId: graphql
summary: Execute a GraphQL query.
tags: [graphql]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [query]
properties:
query:
type: string
variables:
type: object
responses:
"200":
description: OK
content:
application/json:
schema:
type: object