This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
tz16.go
86 lines (74 loc) · 2.4 KB
/
tz16.go
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
// Copyright (c) 2020-2022 Blockwatch Data Inc.
// Author: alex@blockwatch.cc
package contract
import (
"blockwatch.cc/tzgo/micheline"
// "blockwatch.cc/tzgo/rpc"
// "blockwatch.cc/tzgo/tezos"
)
// Represents Tzip16 contract metadata
type Tz16 struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
License *Tz16License `json:"license,omitempty"`
Authors []string `json:"authors,omitempty"`
Homepage string `json:"homepage,omitempty"`
Source *Tz16Source `json:"source,omitempty"`
Interfaces []string `json:"interfaces,omitempty"`
Errors []Tz16Error `json:"errors,omitempty"`
Views []Tz16View `json:"views,omitempty"`
}
type Tz16License struct {
Name string `json:"name"`
Details string `json:"details,omitempty"`
}
type Tz16Source struct {
Tools []string `json:"tools"`
Location string `json:"location,omitempty"`
}
type Tz16Error struct {
Error *micheline.Prim `json:"error,omitempty"`
Expansion *micheline.Prim `json:"expansion,omitempty"`
Languages []string `json:"languages,omitempty"`
View string `json:"view,omitempty"`
}
type Tz16View struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Pure bool `json:"pure,omitempty"`
Implementations []Tz16ViewImpl `json:"implementations,omitempty"`
}
type Tz16ViewImpl struct {
Storage *Tz16StorageView `json:"michelsonStorageView,omitempty"`
Rest *Tz16RestView `json:"restApiQuery,omitempty"`
}
type Tz16StorageView struct {
ParamType *micheline.Prim `json:"parameter,omitempty"`
ReturnType micheline.Prim `json:"returnType"`
Code micheline.Prim `json:"code"`
Annotations []Tz16CodeAnnotation `json:"annotations,omitempty"`
Version string `json:"version,omitempty"`
}
type Tz16CodeAnnotation struct {
Name string `json:"name"`
Description string `json:"description"`
}
type Tz16RestView struct {
SpecUri string `json:"specificationUri"`
BaseUri string `json:"baseUri"`
Path string `json:"path"`
Method string `json:"method"`
}
func (t Tz16) Validate() []error {
// TODO: json schema validator
return nil
}
func (t Tz16) HasView(name string) bool {
for _, v := range t.Views {
if v.Name == name {
return true
}
}
return false
}