-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmetadata.gen.go
More file actions
3003 lines (2667 loc) · 101 KB
/
metadata.gen.go
File metadata and controls
3003 lines (2667 loc) · 101 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
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
// sequence-metadata v0.4.0 674b211879a80aaf72087afbe63c0fca78a1897b
// --
// Code generated by webrpc-gen@v0.21.1 with golang generator. DO NOT EDIT.
//
// webrpc-gen -schema=metadata.ridl -target=golang -pkg=metadata -client -out=./clients/metadata.gen.go
package metadata
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
"github.com/0xsequence/go-sequence/lib/prototyp"
)
const WebrpcHeader = "Webrpc"
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-golang@v0.16.0;sequence-metadata@v0.4.0"
// WebRPC description and code-gen version
func WebRPCVersion() string {
return "v1"
}
// Schema version of your RIDL schema
func WebRPCSchemaVersion() string {
return "v0.4.0"
}
// Schema hash generated from your RIDL schema
func WebRPCSchemaHash() string {
return "674b211879a80aaf72087afbe63c0fca78a1897b"
}
type WebrpcGenVersions struct {
WebrpcGenVersion string
CodeGenName string
CodeGenVersion string
SchemaName string
SchemaVersion string
}
func VersionFromHeader(h http.Header) (*WebrpcGenVersions, error) {
if h.Get(WebrpcHeader) == "" {
return nil, fmt.Errorf("header is empty or missing")
}
versions, err := parseWebrpcGenVersions(h.Get(WebrpcHeader))
if err != nil {
return nil, fmt.Errorf("webrpc header is invalid: %w", err)
}
return versions, nil
}
func parseWebrpcGenVersions(header string) (*WebrpcGenVersions, error) {
versions := strings.Split(header, ";")
if len(versions) < 3 {
return nil, fmt.Errorf("expected at least 3 parts while parsing webrpc header: %v", header)
}
_, webrpcGenVersion, ok := strings.Cut(versions[0], "@")
if !ok {
return nil, fmt.Errorf("webrpc gen version could not be parsed from: %s", versions[0])
}
tmplTarget, tmplVersion, ok := strings.Cut(versions[1], "@")
if !ok {
return nil, fmt.Errorf("tmplTarget and tmplVersion could not be parsed from: %s", versions[1])
}
schemaName, schemaVersion, ok := strings.Cut(versions[2], "@")
if !ok {
return nil, fmt.Errorf("schema name and schema version could not be parsed from: %s", versions[2])
}
return &WebrpcGenVersions{
WebrpcGenVersion: webrpcGenVersion,
CodeGenName: tmplTarget,
CodeGenVersion: tmplVersion,
SchemaName: schemaName,
SchemaVersion: schemaVersion,
}, nil
}
//
// Common types
//
type ContractType uint16
const (
ContractType_UNKNOWN ContractType = 0
ContractType_ERC20 ContractType = 1
ContractType_ERC721 ContractType = 2
ContractType_ERC1155 ContractType = 3
)
var ContractType_name = map[uint16]string{
0: "UNKNOWN",
1: "ERC20",
2: "ERC721",
3: "ERC1155",
}
var ContractType_value = map[string]uint16{
"UNKNOWN": 0,
"ERC20": 1,
"ERC721": 2,
"ERC1155": 3,
}
func (x ContractType) String() string {
return ContractType_name[uint16(x)]
}
func (x ContractType) MarshalText() ([]byte, error) {
return []byte(ContractType_name[uint16(x)]), nil
}
func (x *ContractType) UnmarshalText(b []byte) error {
*x = ContractType(ContractType_value[string(b)])
return nil
}
func (x *ContractType) Is(values ...ContractType) bool {
if x == nil {
return false
}
for _, v := range values {
if *x == v {
return true
}
}
return false
}
type Source uint8
const (
Source_UNKNOWN Source = 0x00
Source_FETCHER Source = 0x10
Source_FETCHER_ON_CHAIN_CONTRACT_URI Source = 0x11
Source_FETCHER_ON_CHAIN_TOKEN_URI Source = 0x12
Source_FETCHER_ON_CHAIN_ERC20_INTERFACE Source = 0x13
Source_FETCHER_ENS_API Source = 0x14
Source_FETCHER_OPENSEA_API Source = 0x15
Source_TOKEN_DIRECTORY Source = 0x40
Source_TOKEN_DIRECTORY_PUBLIC_TOKEN_LIST Source = 0x41
Source_TOKEN_DIRECTORY_3RD_PARTY Source = 0x42
Source_TOKEN_DIRECTORY_SEQUENCE_GITHUB Source = 0x43
Source_SEQUENCE_BUILDER Source = 0x80
)
var Source_name = map[uint8]string{
0x00: "UNKNOWN",
0x10: "FETCHER",
0x11: "FETCHER_ON_CHAIN_CONTRACT_URI",
0x12: "FETCHER_ON_CHAIN_TOKEN_URI",
0x13: "FETCHER_ON_CHAIN_ERC20_INTERFACE",
0x14: "FETCHER_ENS_API",
0x15: "FETCHER_OPENSEA_API",
0x40: "TOKEN_DIRECTORY",
0x41: "TOKEN_DIRECTORY_PUBLIC_TOKEN_LIST",
0x42: "TOKEN_DIRECTORY_3RD_PARTY",
0x43: "TOKEN_DIRECTORY_SEQUENCE_GITHUB",
0x80: "SEQUENCE_BUILDER",
}
var Source_value = map[string]uint8{
"UNKNOWN": 0x00,
"FETCHER": 0x10,
"FETCHER_ON_CHAIN_CONTRACT_URI": 0x11,
"FETCHER_ON_CHAIN_TOKEN_URI": 0x12,
"FETCHER_ON_CHAIN_ERC20_INTERFACE": 0x13,
"FETCHER_ENS_API": 0x14,
"FETCHER_OPENSEA_API": 0x15,
"TOKEN_DIRECTORY": 0x40,
"TOKEN_DIRECTORY_PUBLIC_TOKEN_LIST": 0x41,
"TOKEN_DIRECTORY_3RD_PARTY": 0x42,
"TOKEN_DIRECTORY_SEQUENCE_GITHUB": 0x43,
"SEQUENCE_BUILDER": 0x80,
}
func (x Source) String() string {
return Source_name[uint8(x)]
}
func (x Source) MarshalText() ([]byte, error) {
return []byte(Source_name[uint8(x)]), nil
}
func (x *Source) UnmarshalText(b []byte) error {
*x = Source(Source_value[string(b)])
return nil
}
func (x *Source) Is(values ...Source) bool {
if x == nil {
return false
}
for _, v := range values {
if *x == v {
return true
}
}
return false
}
type ResourceStatus uint32
const (
ResourceStatus_NOT_AVAILABLE ResourceStatus = 0
ResourceStatus_STALE ResourceStatus = 1
ResourceStatus_AVAILABLE ResourceStatus = 2
)
var ResourceStatus_name = map[uint32]string{
0: "NOT_AVAILABLE",
1: "STALE",
2: "AVAILABLE",
}
var ResourceStatus_value = map[string]uint32{
"NOT_AVAILABLE": 0,
"STALE": 1,
"AVAILABLE": 2,
}
func (x ResourceStatus) String() string {
return ResourceStatus_name[uint32(x)]
}
func (x ResourceStatus) MarshalText() ([]byte, error) {
return []byte(ResourceStatus_name[uint32(x)]), nil
}
func (x *ResourceStatus) UnmarshalText(b []byte) error {
*x = ResourceStatus(ResourceStatus_value[string(b)])
return nil
}
func (x *ResourceStatus) Is(values ...ResourceStatus) bool {
if x == nil {
return false
}
for _, v := range values {
if *x == v {
return true
}
}
return false
}
type PropertyType uint32
const (
PropertyType_INT PropertyType = 0
PropertyType_STRING PropertyType = 1
PropertyType_ARRAY PropertyType = 2
PropertyType_GENERIC PropertyType = 3
)
var PropertyType_name = map[uint32]string{
0: "INT",
1: "STRING",
2: "ARRAY",
3: "GENERIC",
}
var PropertyType_value = map[string]uint32{
"INT": 0,
"STRING": 1,
"ARRAY": 2,
"GENERIC": 3,
}
func (x PropertyType) String() string {
return PropertyType_name[uint32(x)]
}
func (x PropertyType) MarshalText() ([]byte, error) {
return []byte(PropertyType_name[uint32(x)]), nil
}
func (x *PropertyType) UnmarshalText(b []byte) error {
*x = PropertyType(PropertyType_value[string(b)])
return nil
}
func (x *PropertyType) Is(values ...PropertyType) bool {
if x == nil {
return false
}
for _, v := range values {
if *x == v {
return true
}
}
return false
}
type SwapType uint32
const (
SwapType_UNKNOWN SwapType = 0
SwapType_BUY SwapType = 1
SwapType_SELL SwapType = 2
)
var SwapType_name = map[uint32]string{
0: "UNKNOWN",
1: "BUY",
2: "SELL",
}
var SwapType_value = map[string]uint32{
"UNKNOWN": 0,
"BUY": 1,
"SELL": 2,
}
func (x SwapType) String() string {
return SwapType_name[uint32(x)]
}
func (x SwapType) MarshalText() ([]byte, error) {
return []byte(SwapType_name[uint32(x)]), nil
}
func (x *SwapType) UnmarshalText(b []byte) error {
*x = SwapType(SwapType_value[string(b)])
return nil
}
func (x *SwapType) Is(values ...SwapType) bool {
if x == nil {
return false
}
for _, v := range values {
if *x == v {
return true
}
}
return false
}
type TaskStatus uint8
const (
TaskStatus_QUEUED TaskStatus = 0
TaskStatus_PAUSED TaskStatus = 1
TaskStatus_FAILED TaskStatus = 2
TaskStatus_COMPLETED TaskStatus = 3
)
var TaskStatus_name = map[uint8]string{
0: "QUEUED",
1: "PAUSED",
2: "FAILED",
3: "COMPLETED",
}
var TaskStatus_value = map[string]uint8{
"QUEUED": 0,
"PAUSED": 1,
"FAILED": 2,
"COMPLETED": 3,
}
func (x TaskStatus) String() string {
return TaskStatus_name[uint8(x)]
}
func (x TaskStatus) MarshalText() ([]byte, error) {
return []byte(TaskStatus_name[uint8(x)]), nil
}
func (x *TaskStatus) UnmarshalText(b []byte) error {
*x = TaskStatus(TaskStatus_value[string(b)])
return nil
}
func (x *TaskStatus) Is(values ...TaskStatus) bool {
if x == nil {
return false
}
for _, v := range values {
if *x == v {
return true
}
}
return false
}
type Version struct {
WebrpcVersion string `json:"webrpcVersion"`
SchemaVersion string `json:"schemaVersion"`
SchemaHash string `json:"schemaHash"`
AppVersion string `json:"appVersion"`
}
type RuntimeStatus struct {
HealthOK bool `json:"healthOK"`
StartTime time.Time `json:"startTime"`
Uptime uint64 `json:"uptime"`
UptimeString string `json:"uptimeString"`
Ver string `json:"ver"`
Branch string `json:"branch"`
CommitHash string `json:"commitHash"`
Checks *RuntimeChecks `json:"checks"`
Runnable map[string]*RunnableStatus `json:"runnable,omitempty"`
}
type RunnableStatus struct {
Running bool `json:"running"`
Restarts int `json:"restarts"`
StartTime time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime"`
LastError interface{} `json:"lastError"`
}
type RuntimeChecks struct {
}
// ContractIndex is a database type to track the index of contracts which
// are fetched on-demand through traversing on-chain contract metadata.
type ContractIndex struct {
ChainID uint64 `json:"chainId" db:"chain_id"`
Address prototyp.Hash `json:"address" db:"contract_address"`
Type ContractType `json:"type" db:"type"`
Source Source `json:"source" db:"source"`
Metadata map[string]interface{} `json:"metadata" db:"metadata"`
ContentHash uint64 `json:"contentHash,omitempty" db:"content_hash,omitempty"`
Deployed bool `json:"deployed" db:"deployed"`
BytecodeHash prototyp.Hash `json:"bytecodeHash" db:"bytecode_hash"`
NotFound bool `json:"notFound,omitempty" db:"not_found"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
QueuedAt *time.Time `json:"queuedAt" db:"queued_at"`
Status ResourceStatus `json:"status"`
}
// TokenIndex is a database type to track the index of token metadata which
// are fetched on-demand through traversing on-chain contract metadata.
type TokenIndex struct {
Key prototyp.Key `json:"key" db:"key"`
Source Source `json:"source" db:"source"`
ChainID uint64 `json:"chainId" db:"chain_id"`
ContractAddress prototyp.Hash `json:"contractAddress,omitempty" db:"contract_address"`
TokenID prototyp.BigInt `json:"tokenId" db:"token_id"`
Metadata map[string]interface{} `json:"metadata" db:"metadata"`
NotFound bool `json:"notFound,omitempty" db:"not_found"`
LastFetched *time.Time `json:"lastFetched,omitempty" db:"last_fetched"`
FetchCount *uint8 `json:"fetchCount,omitempty" db:"fetch_count"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
QueuedAt *time.Time `json:"queuedAt"`
}
// ContractInfo is RPC type for responding to clients that represents
// the contract-level metadata.
type ContractInfo struct {
ChainID uint64 `json:"chainId" cbor:"-"`
Address string `json:"address" cbor:"-"`
Source string `json:"source" cbor:"-"`
Name string `json:"name" cbor:"-"`
Type string `json:"type" cbor:"-"`
Symbol string `json:"symbol" cbor:"-"`
Decimals *uint64 `json:"decimals,omitempty" cbor:"-"`
LogoURI string `json:"logoURI,omitempty" cbor:"-"`
Deployed bool `json:"deployed" cbor:"-"`
BytecodeHash prototyp.Hash `json:"bytecodeHash" cbor:"-"`
Extensions *ContractInfoExtensions `json:"extensions" cbor:"-"`
ContentHash uint64 `json:"-" cbor:"-"`
UpdatedAt time.Time `json:"updatedAt" cbor:"-"`
NotFound bool `json:"notFound"`
QueuedAt *time.Time `json:"queuedAt"`
Status ResourceStatus `json:"status"`
}
type ContractInfoExtensions struct {
Link string `json:"link" cbor:"-"`
Description string `json:"description" cbor:"-"`
Categories []string `json:"categories,omitempty" cbor:"-"`
OgImage string `json:"ogImage" cbor:"-"`
OgName string `json:"ogName" cbor:"-"`
OriginChainID uint64 `json:"originChainId" cbor:"-"`
OriginAddress string `json:"originAddress" cbor:"-"`
Blacklist bool `json:"blacklist,omitempty" cbor:"-"`
Verified bool `json:"verified" cbor:"-"`
VerifiedBy string `json:"verifiedBy,omitempty" cbor:"-"`
Featured bool `json:"featured,omitempty" cbor:"-"`
}
// TokenMetadata based on 721/1155 standards, as well including some
// fields which are used by OpenSea.
//
// TokenMetadata is RPC type for responding to clients that represents
// the token-level metadata.
type TokenMetadata struct {
TokenID string `json:"tokenId" cbor:"-"`
Source string `json:"source" cbor:"-"`
Name string `json:"name" cbor:"-"`
Description string `json:"description" cbor:"-"`
// url
Image string `json:"image" cbor:"-"`
// non-standard fields we've added for Sequence. Others should adopt
// these too and we should prompt, similar to how `image` field works.
// url
Video string `json:"video,omitempty" cbor:"-"`
// url
Audio string `json:"audio,omitempty" cbor:"-"`
Properties map[string]interface{} `json:"properties" cbor:"-"`
// OpenSea fields
// see https://docs.opensea.io/docs/metadata-standards
//
// NOTE: its a bit unfortunate OpenSea didn't use camelCase, and
// also introduces 'attributes' when 'properties' is actually the correct property name.
// TODO: we could smooth this out / normalize it, but we can leave it for now.
Attributes []map[string]interface{} `json:"attributes" cbor:"-"`
ImageData string `json:"image_data,omitempty" cbor:"-"`
ExternalUrl string `json:"external_url,omitempty" cbor:"-"`
BackgroundColor string `json:"background_color,omitempty" cbor:"-"`
AnimationUrl string `json:"animation_url,omitempty" cbor:"-"`
//
// Misc
//
// decimals is deprecated, but still used by some
Decimals *uint64 `json:"decimals,omitempty" cbor:"-"`
UpdatedAt time.Time `json:"updatedAt" cbor:"-"`
// Assets associated to this token metadata
Assets []*Asset `json:"assets,omitempty" cbor:"-"`
Status ResourceStatus `json:"status"`
QueuedAt *time.Time `json:"queuedAt"`
LastFetched *time.Time `json:"lastFetched,omitempty"`
}
// PropertyFilter
//
// name -> name of the property, eg: hero
// type -> type of the values of the property, eg: Int, string
// min?, max? used if type is int, gives range of values for filtering
// values? -> if string then array of values, eg: ['Ada', 'Ari', 'Axel', 'Banjo' ...]
// NOTE: When Filter has an array of PropertyFilter, the logic used is an 'and' condition
// whereas if the user selects multiple values inside the PropertyFilter, they logic used is the 'or' condition
// this is to achieve the desired effect opensea had on their filters
type PropertyFilter struct {
Name string `json:"name"`
Type PropertyType `json:"type"`
Min *int64 `json:"min"`
Max *int64 `json:"max"`
Values []interface{} `json:"values"`
}
type Filter struct {
Text *string `json:"text"`
Properties []*PropertyFilter `json:"properties"`
}
// Collection represents the contract-level metadata for a collection.
// db table: collections
//
// the fields here should overlap with https://docs.opensea.io/docs/contract-level-metadata
// such that we can use this object for contract-level metadata.
type Collection struct {
ID uint64 `json:"id,omitempty" db:"id,omitempty"`
ProjectID uint64 `json:"projectId,omitempty" db:"project_id"`
Metadata *CollectionMetadata `json:"metadata,omitempty" db:"metadata"`
Private bool `json:"private" db:"private"`
RevealKey string `json:"revealKey,omitempty" db:"reveal_key"`
TokenCount *uint64 `json:"tokenCount,omitempty" db:"-"`
CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt,omitempty" db:"updated_at"`
DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"`
BaseURIs *CollectionBaseURIs `json:"baseURIs,omitempty" db:"-"`
// Assets associated to this collection metadata
Assets []*Asset `json:"assets,omitempty" cbor:"-"`
}
type CollectionMetadata struct {
Name string `json:"name"`
Description string `json:"description"`
Image string `json:"image,omitempty"`
// NOTE: we use `external_link` for the field name because of OpenSea's
// contract-level metadata https://docs.opensea.io/docs/contract-level-metadata
ExternalLink string `json:"external_link,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
Attributes []map[string]interface{} `json:"attributes,omitempty"`
}
type CollectionBaseURIs struct {
// contractMetadataURI is the URI to the contract-level metadata for the collection,
// which is the value to set on a contract. Note, we do not store this in the db, but we
// do return it as part of the response.
//
// aka, `contractURI()` on a contract
ContractMetadataURI string `json:"contractMetadataURI"`
// tokenMetadataURI is the URI to the token-level metadata for the collection,
// which is the value to set on a contract's token baseURI. Note, we do not store this
// in the db, but we do return it as part of the response.
//
// aka `uri(uint256 tokenId)` on 721 and 1155
//
// This base URI which satisfy 721 and 1155
//
// https://eips.ethereum.org/EIPS/eip-721
// uri ending with '/ without placeholder for tokenID
//
// also use for 1155
// https://eips.ethereum.org/EIPS/eip-1155#metadata
TokenMetadataURI string `json:"tokenMetadataURI"`
}
// Contract - Collection
type ContractCollection struct {
ID uint64 `json:"id,omitempty" db:"id,omitempty"`
ChainID uint64 `json:"chainId" db:"chain_id"`
ContractAddress prototyp.Hash `json:"contractAddress" db:"contract_address"`
CollectionID uint64 `json:"collectionId" db:"collection_id"`
}
// Asset is a database type used by 'collections' to record static assets for
// a particular 'token' for the token metadata.
type Asset struct {
// asset id
ID uint64 `json:"id" db:"id,omitempty"`
// collection id associated to this asset
CollectionID uint64 `json:"collectionId" db:"collection_id"`
// token id associated to this collection
TokenID *prototyp.BigInt `json:"tokenId" db:"token_id,omitempty"`
// url where we can view the asset contents
// ie. https://metadata.sequence.app/projects/1/collections/1/tokens/1/image
URL string `json:"url" db:"-"`
// metadata field related to TokenMetadata, some field names:
// ['image', 'video', 'audio', 'animation_url', ...]
MetadataField string `json:"metadataField,omitempty" db:"metadata_field"`
// asset details
Filename string `json:"filename,omitempty" db:"filename"`
Filesize uint32 `json:"filesize,omitempty" db:"filesize"`
MimeType string `json:"mimeType,omitempty" db:"mime_type"`
Width *uint16 `json:"width,omitempty" db:"width"`
Height *uint16 `json:"height,omitempty" db:"height"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
// Token is a database type used by 'collections' that represents the token metadata
// for a collection. We use this as an internal type for storage, but it stores
// just TokenMetadata for a particular collectionId/tokenId.
type Token struct {
CollectionID uint64 `json:"collectionId" db:"collection_id"`
TokenID prototyp.BigInt `json:"tokenId" db:"token_id"`
Metadata *TokenMetadata `json:"metadata" db:"metadata"`
Private bool `json:"private" db:"private"`
SearchColumn string `json:"-" db:"search_col"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
type GetNiftyswapUnitPricesRequest struct {
SwapType SwapType `json:"swapType"`
Ids []prototyp.BigInt `json:"ids"`
Amounts []prototyp.BigInt `json:"amounts"`
}
type GetNiftyswapUnitPricesResponse struct {
UnitPrice prototyp.BigInt `json:"unitPrice"`
UnitAmount prototyp.BigInt `json:"unitAmount"`
AvailableAmount prototyp.BigInt `json:"availableAmount"`
}
// Page represents a results page. This can be used both to request a page and
// to store the state of a page.
type Page struct {
// Numbered pages: Page number, this is multiplied by the value of the <pageSize> parameter.
Page *uint32 `json:"page,omitempty"`
// Cursor: column to compare before/after to
Column *string `json:"column,omitempty"`
// Cursor: return column < before - include to get previous page
Before *interface{} `json:"before,omitempty"`
// Cursor: return column > after - include to get next page
After *interface{} `json:"after,omitempty"`
// Number of items per page
PageSize *uint32 `json:"pageSize,omitempty"`
// Indicates if there are more results available
More *bool `json:"more,omitempty"`
}
type TaskRunner struct {
ID uint64 `json:"id" db:"id,omitempty"`
WorkGroup string `json:"workGroup" db:"work_group"`
RunAt time.Time `json:"runAt" db:"run_at"`
}
type Task struct {
ID uint64 `json:"id" db:"id,omitempty"`
Queue string `json:"queue" db:"queue"`
Status *TaskStatus `json:"status" db:"status"`
Try uint32 `json:"try" db:"try"`
RunAt *time.Time `json:"runAt" db:"run_at,omitempty"`
LastRanAt *time.Time `json:"lastRanAt" db:"last_ran_at,omitempty"`
CreatedAt *time.Time `json:"createdAt" db:"created_at,omitempty"`
Payload json.RawMessage `json:"payload" db:"payload"`
Hash *string `json:"hash" db:"hash,omitempty"`
}
var (
methods = map[string]method{
"/rpc/Metadata/Ping": {
Name: "Ping",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/Version": {
Name: "Version",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/RuntimeStatus": {
Name: "RuntimeStatus",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/GetTask": {
Name: "GetTask",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/GetTaskStatus": {
Name: "GetTaskStatus",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/RefreshTokenMetadata": {
Name: "RefreshTokenMetadata",
Service: "Metadata",
Annotations: map[string]string{"deprecated": ""},
},
"/rpc/Metadata/EnqueueTokensForRefresh": {
Name: "EnqueueTokensForRefresh",
Service: "Metadata",
Annotations: map[string]string{"deprecated": ""},
},
"/rpc/Metadata/GetTokenRefreshStatus": {
Name: "GetTokenRefreshStatus",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/GetTokenRefreshResult": {
Name: "GetTokenRefreshResult",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/CancelRefreshJob": {
Name: "CancelRefreshJob",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/RefreshContractInfo": {
Name: "RefreshContractInfo",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/RefreshContractTokens": {
Name: "RefreshContractTokens",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/RefreshAllContractTokens": {
Name: "RefreshAllContractTokens",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/GetTokenMetadata": {
Name: "GetTokenMetadata",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/GetTokenMetadataBatch": {
Name: "GetTokenMetadataBatch",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/SearchTokenMetadata": {
Name: "SearchTokenMetadata",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/SearchTokenIDs": {
Name: "SearchTokenIDs",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/TokenCollectionFilters": {
Name: "TokenCollectionFilters",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/GetContractInfo": {
Name: "GetContractInfo",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/GetContractInfoBatch": {
Name: "GetContractInfoBatch",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/SearchContractInfo": {
Name: "SearchContractInfo",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/SearchContractInfoBatch": {
Name: "SearchContractInfoBatch",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/SearchMetadata": {
Name: "SearchMetadata",
Service: "Metadata",
Annotations: map[string]string{"deprecated": ""},
},
"/rpc/Metadata/SearchTokens": {
Name: "SearchTokens",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/SearchContracts": {
Name: "SearchContracts",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/GetNiftyswapTokenQuantity": {
Name: "GetNiftyswapTokenQuantity",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/GetNiftyswapUnitPrices": {
Name: "GetNiftyswapUnitPrices",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/GetNiftyswapUnitPricesWithQuantities": {
Name: "GetNiftyswapUnitPricesWithQuantities",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/AddContractToMintMonitor": {
Name: "AddContractToMintMonitor",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/RemoveContractFromMintMonitor": {
Name: "RemoveContractFromMintMonitor",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/MintMonitorJobStatus": {
Name: "MintMonitorJobStatus",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/MintMonitorTriggerJob": {
Name: "MintMonitorTriggerJob",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/SyncContractTokens": {
Name: "SyncContractTokens",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/AbortContractSync": {
Name: "AbortContractSync",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/ContractSyncJobStatus": {
Name: "ContractSyncJobStatus",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Metadata/DirectoryGetNetworks": {
Name: "DirectoryGetNetworks",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/DirectoryGetCollections": {
Name: "DirectoryGetCollections",
Service: "Metadata",
Annotations: map[string]string{},
},
"/rpc/Metadata/DirectorySearchCollections": {
Name: "DirectorySearchCollections",
Service: "Metadata",
Annotations: map[string]string{"internal": ""},
},
"/rpc/Collections/CreateCollection": {
Name: "CreateCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/GetCollection": {
Name: "GetCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/ListCollections": {
Name: "ListCollections",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/UpdateCollection": {
Name: "UpdateCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/DeleteCollection": {
Name: "DeleteCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/PublishCollection": {
Name: "PublishCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/UnpublishCollection": {
Name: "UnpublishCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/CreateContractCollection": {
Name: "CreateContractCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/GetContractCollection": {
Name: "GetContractCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/ListContractCollections": {
Name: "ListContractCollections",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/UpdateContractCollection": {
Name: "UpdateContractCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/DeleteContractCollection": {
Name: "DeleteContractCollection",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/CreateToken": {
Name: "CreateToken",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/GetToken": {
Name: "GetToken",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/ListTokens": {
Name: "ListTokens",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/UpdateToken": {
Name: "UpdateToken",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/DeleteToken": {
Name: "DeleteToken",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/CreateAsset": {
Name: "CreateAsset",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/GetAsset": {
Name: "GetAsset",
Service: "Collections",
Annotations: map[string]string{},
},
"/rpc/Collections/UpdateAsset": {
Name: "UpdateAsset",
Service: "Collections",