-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathheaders.go
68 lines (58 loc) · 1.94 KB
/
headers.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
package tela
import (
"fmt"
"strings"
)
// Standard SC header value stores
type Headers struct {
NameHdr string `json:"nameHdr"` // On-chain name of SC. For TELA-DOCs, they are recreated using this as the file name, it should include the file extension
DescrHdr string `json:"descrHdr"` // On-chain description of DOC, INDEX or Asset SC
IconHdr string `json:"iconHdr"` // On-chain icon URL, (size 100x100)
}
// DERO signature
type Signature struct {
CheckC string `json:"checkC"` // C signature value
CheckS string `json:"checkS"` // S signature value
}
// Standard SC header keys
type Header string
const (
HEADER_NAME Header = `"nameHdr"`
HEADER_DESCRIPTION Header = `"descrHdr"`
HEADER_ICON_URL Header = `"iconURLHdr"`
HEADER_CHECK_C Header = `"fileCheckC"`
HEADER_CHECK_S Header = `"fileCheckS"`
HEADER_DURL Header = `"dURL"`
HEADER_DOCUMENT Header = `"DOC` // append with Number()
HEADER_SUBDIR Header = `"subDir"`
HEADER_DOCTYPE Header = `"docType"`
HEADER_COLLECTION Header = `"collection"`
HEADER_TYPE Header = `"typeHdr"`
HEADER_TAGS Header = `"tagsHdr"`
HEADER_FILE_URL Header = `"fileURL"`
HEADER_SIGN_URL Header = `"fileSignURL"`
HEADER_COVER_URL Header = `"coverURL"`
HEADER_ART_FEE Header = `"artificerFee"`
HEADER_ROYALTY Header = `"royalty"`
HEADER_OWNER Header = `"owner"`
HEADER_OWNER_UPDATE Header = `"ownerCanUpdate"`
)
// Trim any `"` from Header and return string
func (h Header) Trim() string {
return strings.Trim(string(h), `"`)
}
// Returns if Header can be appended. Headers ending in `"` or with len < 2 will return false
func (h Header) CanAppend() bool {
i := len(h) - 1
if i < 1 {
return false
}
return h[i] != byte(0x22)
}
// Append a number to Header if applicable, otherwise return unchanged Header
func (h Header) Number(i int) Header {
if !h.CanAppend() {
return h
}
return Header(fmt.Sprintf(`%s%d"`, h, i))
}