-
Notifications
You must be signed in to change notification settings - Fork 9
/
schema.graphql
1090 lines (956 loc) · 22.4 KB
/
schema.graphql
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
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
schema {
query: RootQueryType
}
type Account {
account_udts(input: AccountChildAccountUdtsInput = {page: 1, page_size: 20, sort_type: DESC}): [AccountUdt]
eth_address: String
id: Int
nonce: Int
script: Json
script_hash: String
short_address: String
smart_contract: SmartContract
token_transfer_count: Int
transaction_count: Int
type: AccountType
}
input AccountChildAccountUdtsInput {
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
"""
argument: the sort of type by custom condition
default: desc
"""
sort_type: SortType = DESC
}
type AccountCkb {
address_hash: String
balance: Decimal
}
input AccountCkbsInput {
address_hashes: [String] = []
}
input AccountInput {
"""
argument: account address(eth_address or short_address)
example-1: "0x15ca4f2165ff0e798d9c7434010eaacc4d768d85"
example-2: "0xc5e133e6b01b2c335055576c51a53647b1b9b624"
"""
address: String!
}
enum AccountType {
META_CONTRACT
POLYJUICE_CONTRACT
POLYJUICE_ROOT
UDT
USER
}
type AccountUdt {
account: Account
address_hash: String
balance: Decimal
id: Int
udt: Udt
}
input AccountUdtContractAddressInput {
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
"""
argument: the sort of type by custom condition
default: desc
"""
sort_type: SortType = DESC
token_contract_address_hash: String!
}
input AccountUdtsInput {
"""
argument: the list of account udt address
example: ["0x15ca4f2165ff0e798d9c7434010eaacc4d768d85"]
"""
address_hashes: [String] = []
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
"""
argument: the address of smart contract which supply udts
example: "0xbf1f27daea43849b67f839fd101569daaa321e2c"
"""
token_contract_address_hash: String
}
type Block {
account: Account
aggregator_id: Int
difficulty: Decimal
extra_data: String
gas_limit: Decimal
gas_used: Decimal
hash: String
layer1_block_number: Int
layer1_tx_hash: String
logs_bloom: String
nonce: String
number: Int
parent_hash: String
sha3_uncles: String
size: Int
state_root: String
status: BlockStatus
timestamp: DateTime
total_difficulty: Decimal
transaction_count: Int
transactions(input: PageAndSizeInput = {page: 1, page_size: 5}): [Transaction]
}
input BlockInput {
hash: String
number: Int
}
input BlocksInput {
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
"""
argument: the sort of type by custom condition
default: desc
"""
sort_type: SortType = DESC
}
enum BlockStatus {
COMMITTED
FINALIZED
}
"""
The `DateTime` scalar type represents a date and time in the UTC
timezone. The DateTime appears in a JSON response as an ISO8601 formatted
string, including UTC timezone ("Z"). The parsed date and time string will
be converted to UTC if there is an offset.
"""
scalar DateTime
"""
The `Decimal` scalar type represents signed double-precision fractional
values parsed by the `Decimal` library. The Decimal appears in a JSON
response as a string to preserve precision.
Formally:
sign ::= '+' | '-'
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' |
'8' | '9'
indicator ::= 'e' | 'E'
digits ::= digit [digit]...
decimal-part ::= digits '.' [digits] | ['.'] digits
exponent-part ::= indicator [sign] digits
infinity ::= 'Infinity' | 'Inf'
nan ::= 'NaN' [digits] | 'sNaN' [digits]
numeric-value ::= decimal-part [exponent-part] | infinity
numeric-string ::= [sign] numeric-value | [sign] nan
Examples:
Some numeric strings are:
"0" -- zero
"12" -- a whole number
"-76" -- a signed whole number
"12.70" -- some decimal places
"+0.003" -- a plus sign is allowed, too
"017." -- the same as 17
".5" -- the same as 0.5
"4E+9" -- exponential notation
"0.73e-7" -- exponential notation, negative power
"Inf" -- the same as Infinity
"-infinity" -- the same as -Inf
"NaN" -- not-a-Number
"NaN8275" -- diagnostic NaN
"""
scalar Decimal
"""
The `Json` scalar type represents arbitrary json string data, represented as UTF-8
character sequences. The Json type is most often used to represent a free-form
human-readable json string.
"""
scalar Json
type Log {
address_hash: String
block_hash: String
block_number: Int
data: String
first_topic: String
fourth_topic: String
index: Int
second_topic: String
third_topic: String
transaction_hash: String
}
input LogInput {
address_hash: String
"""argument: the end of block number(inclusive) for search query"""
end_block_number: Int
first_topic: String
fourth_topic: String
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
second_topic: String
"""
argument: the sort of type by custom condition
default: desc
"""
sort_type: SortType = DESC
"""argument: the start of block number(inclusive) for search query"""
start_block_number: Int
third_topic: String
transaction_hash: String
}
input PageAndSizeInput {
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
}
type Polyjuice {
gas_limit: Int
gas_price: Decimal
gas_used: Int
id: Int
input: String
input_size: Int
is_create: Boolean
status: PolyjuiceStatus
tx_hash: String
value: Decimal
}
type PolyjuiceCreator {
code_hash: String
fee_amount: Decimal
fee_udt_id: Int
hash_type: String
id: Int
script_args: String
tx_hash: String
}
enum PolyjuiceStatus {
FAILED
SUCCEED
}
type RootQueryType {
"""
function: get account by account addresses
request-example-1:
query {
account(input: {address: "0xbfbe23681d99a158f632e64a31288946770c7a9e"}){
id
type
account_udts{
id
balance
udt{
name
type
}
}
}
}
result-example-1:
{
"data": {
"account": {
"account_udts": [
{
"balance": "1352700556596252988061",
"id": 22651,
"udt": {
"name": "Yokai",
"type": "NATIVE"
}
},
{
"balance": "950876407191",
"id": 21837,
"udt": {
"name": "Nervos Token",
"type": "BRIDGE"
}
}
],
"id": 51118,
"type": "USER"
}
}
}
request-example-2:
query {
account(input: {address: "0xc5e133e6b01b2c335055576c51a53647b1b9b624"}){
id
type
smart_contract{
id
name
deployment_tx_hash
}
}
}
result-example-2:
{
"data": {
"account": {
"id": 3014,
"smart_contract": {
"deployment_tx_hash": "0x0000000000",
"id": 1,
"name": "YOKAI"
},
"type": "POLYJUICE_CONTRACT"
}
}
}
"""
account(input: AccountInput!): Account
"""
function: get list of account ckbs by account addresses
request-example:
query {
account_ckbs(input: {address_hashes: ["0x15ca4f2165ff0e798d9c7434010eaacc4d768d85"]}){
address_hash
balance
}
}
result-example:
{
"data": {
"account_ckbs": [
{
"address_hash": "0x15ca4f2165ff0e798d9c7434010eaacc4d768d85",
"balance": "993799999325"
}
]
}
}
"""
account_ckbs(input: AccountCkbsInput!): [AccountCkb]
"""
function: get list of account udt by account addresses
request-example:
query {
account_udts(input: {address_hashes:
["0x15ca4f2165ff0e798d9c7434010eaacc4d768d85",
"0xc20538aa80bb3ced9e240dc8f8130b7f7d0b0c49"],
token_contract_address_hash: "0xbf1f27daea43849b67f839fd101569daaa321e2c"}) {
address_hash
balance
udt{
type
name
}
}
}
result-example:
{
"data": {
"account_udts": [
{
"address_hash": "0x15ca4f2165ff0e798d9c7434010eaacc4d768d85",
"balance": "993799999325",
"udt": {
"name": "Nervos Token",
"type": "BRIDGE"
}
},
{
"address_hash": "0xc20538aa80bb3ced9e240dc8f8130b7f7d0b0c49",
"balance": "950876407191",
"udt": {
"name": "Nervos Token",
"type": "BRIDGE"
}
}
]
}
}
"""
account_udts(input: AccountUdtsInput!): [AccountUdt]
"""
function: get list account udts by smart contract address which sort of balance
request-example:
query {
account_udts_by_contract_address(input: {token_contract_address_hash:
"0xbf1f27daea43849b67f839fd101569daaa321e2c", page_size: 2}){
address_hash
balance
udt {
type
name
}
}
}
result-example:
{
"data": {
"account_udts_by_contract_address": [
{
"address_hash": "0x68f5cea51fa6fcfdcc10f6cddcafa13bf6717436",
"balance": "3711221022882427",
"udt": {
"name": "Nervos Token",
"type": "BRIDGE"
}
},
{
"address_hash": "0x7c12cbcbc3703bff1230434f792d84d70d47bb6f",
"balance": "1075120930414037",
"udt": {
"name": "Nervos Token",
"type": "BRIDGE"
}
}
]
}
}
"""
account_udts_by_contract_address(input: AccountUdtContractAddressInput!): [AccountUdt]
"""
function: get block by block number or block hash
request-example:
query {
block(input: {number: 345600}){
hash
parent_hash
number
gas_used
gas_limit
account{
id
short_address
}
transactions (input: {page: 1, page_size: 2}) {
type
from_account_id
to_account_id
}
}
}
result-example:
{
"data": {
"block": {
"account": {
"id": 2,
"short_address": "0x68f5cea51fa6fcfdcc10f6cddcafa13bf6717436"
},
"gas_limit": "981000000",
"gas_used": "95240385",
"hash": "0x67dad5ec7f3bc8b5b8f623f4df230cb50c9c39493080a6b32d94023994ba886b",
"number": 345600,
"parent_hash": "0x962906210825c339fa4f871239d967c60b62005a6b780ced4334dba56618dbf5",
"transactions": [
{
"from_account_id": 52269,
"to_account_id": 64241,
"type": "POLYJUICE"
},
{
"from_account_id": 52920,
"to_account_id": 197067,
"type": "POLYJUICE"
}
]
}
}
}
"""
block(input: BlockInput): Block
"""
function: get list of block sort by block number
request-example:
query {
blocks(input: {page: 1, page_size: 1}){
hash
parent_hash
number
gas_used
gas_limit
account{
id
short_address
}
transactions (input: {page: 1, page_size: 2}) {
type
from_account_id
to_account_id
}
}
}
result-example:
{
"data": {
"blocks": [
{
"account": {
"id": 2,
"short_address": "0x68f5cea51fa6fcfdcc10f6cddcafa13bf6717436"
},
"gas_limit": "12500000",
"gas_used": "0",
"hash": "0xba8cf2630dfb02bebb208aa674d835073c9a0ff61c881689622e7e07490669e5",
"number": 346124,
"parent_hash": "0x4a35f2a925a51aeb3f780afbd485226ec9603fceb2a2c77a04c9b49657b5ead4",
"transactions": []
}
]
}
}
"""
blocks(input: BlocksInput = {page: 1, page_size: 10, sort_type: DESC}): [Block]
"""
function: get list of logs by filter or conditions
request-example:
query {
logs(input: {first_topic: "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",end_block_number:
346283, page: 1, page_size: 1}) {
transaction_hash
block_number
address_hash
data
first_topic
second_topic
third_topic
fourth_topic
}
}
result-example:
{
"data": {
"logs": [
{
"address_hash": "0x2406a7233d72540291ff0627c397b26fd73dc3d9",
"block_number": 346283,
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"first_topic": "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
"fourth_topic": null,
"second_topic": "0x0000000000000000000000000000000000000000000000000000000000000000",
"third_topic": "0x000000000000000000000000b3a91e71f67c29ae9ed5e164e8a1daa4c9e71361",
"transaction_hash": "0x835eadb22bd55661717b0829b6bb29fb461facdbdc21f803752f9e7383577581"
}
]
}
}
"""
logs(input: LogInput!): [Log]
"""
function: get smart contract by address
request-example:
query {
smart_contract(input: {contract_address: "0x21c814bf216ec7b988d872c56bf948d9cc1638a2"}) {
name
account_id
account {
eth_address
}
}
}
result-example:
{
"data": {
"smart_contract": {
"account": {
"eth_address": "0x21c814bf216ec7b988d872c56bf948d9cc1638a2"
},
"account_id": "3014",
"name": "YOKAI"
}
}
}
"""
smart_contract(input: SmartContractInput!): SmartContract
"""
function: get list of smart contracts
request-example:
query {
smart_contracts {
name
account_id
account {
eth_address
}
}
}
result-example:
{
"data": {
"smart_contracts": [
{
"account": {
"eth_address": "0x21c814bf216ec7b988d872c56bf948d9cc1638a2"
},
"account_id": "3014",
"name": "YOKAI"
}
]
}
}
"""
smart_contracts(input: PageAndSizeInput = {page: 1, page_size: 20}): [SmartContract]
"""
function: get list of token transfers by filter
request-example:
query {
token_transfers(input: {from_address_hash:
"0x3770f660a5b6fde2dadd765c0f336543ff285097", start_block_number: 300000,
end_block_number:344620, page: 1, page_size: 1, sort_type: DESC}) {
transaction_hash
block_number
to_account{
id
short_address
}
to_address_hash
from_account{
id
short_address
}
}
}
result-example:
{
"data": {
"token_transfers": [
{
"block_number": 344620,
"from_account": {
"id": 53057,
"short_address": "0x3770f660a5b6fde2dadd765c0f336543ff285097"
},
"to_account": {
"id": 53057,
"short_address": "0x3770f660a5b6fde2dadd765c0f336543ff285097"
},
"to_address_hash": "0x3770f660a5b6fde2dadd765c0f336543ff285097",
"transaction_hash": "0xf6caf10b0a43adaabd08ef00fde03aa6d25310a1872dd08e7a7a4a4d3bd82301"
}
]
}
}
"""
token_transfers(input: TokenTransferInput!): [TokenTransfer]
"""
function: get transaction by transaction_hash
request-example:
query {
transaction (input: {transaction_hash: "0x21d6428f5325fc3632fb4762d40a1833a4e739329ca5bcb1de0a91fb519cf8a4"}) {
hash
block_hash
block_number
type
from_account_id
to_account_id
}
}
result-example:
{
"data": {
"transaction": {
"block_hash": "0x47d74ac830a8da437da48d95844a9f60c71eaaeffa9e0547738dd49ffe5417cf",
"block_number": 341275,
"from_account_id": 27455,
"hash": "0x21d6428f5325fc3632fb4762d40a1833a4e739329ca5bcb1de0a91fb519cf8a4",
"to_account_id": 3014,
"type": "POLYJUICE"
}
}
}
"""
transaction(input: TransactionHashInput!): Transaction
"""
function: list transactions by account address
request-example:
query {
transactions (input: {address: "0xc5e133e6b01b2c335055576c51a53647b1b9b624",
page: 1, page_size: 2, start_block_number: 335796, end_block_number: 341275}) {
block_hash
block_number
type
from_account_id
to_account_id
}
}
result-example:
{
"data": {
"transactions": [
{
"block_hash": "0x47d74ac830a8da437da48d95844a9f60c71eaaeffa9e0547738dd49ffe5417cf",
"block_number": 341275,
"from_account_id": 27455,
"to_account_id": 3014,
"type": "POLYJUICE"
},
{
"block_hash": "0xb68eee6a72bfd54a06101bedb264e1026af2228250b82dd7c3f06beb35f5d865",
"block_number": 335796,
"from_account_id": 172581,
"to_account_id": 3014,
"type": "POLYJUICE"
}
]
}
}
"""
transactions(input: TransactionInput!): [Transaction]
"""
function: get udt by contract address
request-example:
query {
udt(input: {contract_address: "0xbf1f27daea43849b67f839fd101569daaa321e2c"}){
id
name
type
supply
account{
short_address
}
}
}
result-example:
{
"data": {
"udt": {
"account": {
"short_address": "0xbf1f27daea43849b67f839fd101569daaa321e2c"
},
"id": "1",
"name": "Nervos Token",
"supply": "693247799.35570027",
"type": "BRIDGE"
}
}
}
"""
udt(input: SmartContractInput!): Udt
"""
function: get list of udts
request-example:
query {
udts(input: {page: 1, page_size: 2, sort_type: ASC}){
id
name
type
supply
account{
eth_address
short_address
}
}
}
result-example:
{
"data": {
"udts": [
{
"account": {
"eth_address": null,
"short_address": "0xbf1f27daea43849b67f839fd101569daaa321e2c"
},
"id": "1",
"name": "Nervos Token",
"supply": "693247799.35570027",
"type": "BRIDGE"
},
{
"account": {
"eth_address": null,
"short_address": "0x21ad25fab1d759da1a419a589c0f36dee5e7fe3d"
},
"id": "17",
"name": null,
"supply": "400000002840",
"type": "BRIDGE"
}
]
}
}
"""
udts(input: UdtsInput = {page: 1, page_size: 10, sort_type: ASC, type: BRIDGE}): [Udt]
}
type SmartContract {
abi: [Json]
account: Account
account_id: String
compiler_file_format: String
compiler_version: String
constructor_arguments: String
contract_source_code: String
deployment_tx_hash: String
id: Int
name: String
other_info: String
}
input SmartContractInput {
contract_address: String!
}
enum SortType {
ASC
DESC
}
type TokenTransfer {
amount: Decimal
block: Block
block_hash: String
block_number: Int
from_account: Account
from_address_hash: String
log_index: Int
polyjuice: Polyjuice
to_account: Account
to_address_hash: String
token_contract_address_hash: String
token_id: Decimal
transaction: Transaction
transaction_hash: String
udt: Udt
}
input TokenTransferInput {
"""argument: the end of block number(inclusive) for search query"""
end_block_number: Int
from_address_hash: String
"""
argument: the page of query result, the relations of postgres offset: offset = (page - 1) * page_size
default: 1
"""
page: Int = 1
"""
argument: the page_size of query result, it's the same of postgres limit
default: 20
"""
page_size: Int = 20
"""
argument: the sort of type by custom condition
default: desc
"""
sort_type: SortType = DESC
"""argument: the start of block number(inclusive) for search query"""
start_block_number: Int
to_address_hash: String
token_contract_address_hash: String
transaction_hash: String
}
type Transaction {
args: String
block: Block
block_hash: String
block_number: Int
from_account: Account
from_account_id: Int
hash: String
nonce: Int
polyjuice: Polyjuice
polyjuice_creator: PolyjuiceCreator
to_account: Account
to_account_id: Int
type: TransactionType