-
Notifications
You must be signed in to change notification settings - Fork 4
/
key_hash.go
39 lines (32 loc) · 933 Bytes
/
key_hash.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
package types
import (
"github.com/dave/jennifer/jen"
"github.com/dipdup-net/go-lib/tzkt/data"
)
// KeyHash -
type KeyHash struct{}
// AsField -
func (KeyHash) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
tags := map[string]string{
"json": name,
}
if isRequired {
tags["validate"] = TagRequired
}
return jen.Id(fieldName("KeyHash", name)).String().Tag(tags), nil
}
// AsCode -
func (KeyHash) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
typName := result.GetName("KeyHash", name)
return Code{
Statement: jen.Comment(typName).Line().Type().Id(typName).String().Line(),
Name: typName,
}, nil
}
// AsType -
func (KeyHash) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
return Code{
Statement: jen.String(),
Name: name,
}, nil
}