-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.go
72 lines (59 loc) · 1.4 KB
/
types.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
package timelock_token
type TimelockState uint8
const (
Unknown TimelockState = iota
Unlocked
WaitingForTimeout
Locked
Closed
)
func putTimelockAccountState(dst []byte, v TimelockState, offset *int) {
putUint8(dst, uint8(v), offset)
}
func getTimelockAccountState(src []byte, dst *TimelockState, offset *int) {
var v uint8
getUint8(src, &v, offset)
*dst = TimelockState(v)
}
func (s TimelockState) String() string {
switch s {
case Unknown:
return "unknown"
case Locked:
return "locked"
case WaitingForTimeout:
return "waiting_for_timeout"
case Unlocked:
return "unlocked"
case Closed:
return "closed"
default:
return "unknown"
}
}
type TimelockDataVersion uint8
const (
UnknownDataVersion TimelockDataVersion = iota
DataVersion1
)
func putTimelockAccountDataVersion(dst []byte, v TimelockDataVersion, offset *int) {
putUint8(dst, uint8(v), offset)
}
func getTimelockAccountDataVersion(src []byte, dst *TimelockDataVersion, offset *int) {
var v uint8
getUint8(src, &v, offset)
*dst = TimelockDataVersion(v)
}
type TimelockPdaVersion uint8
const (
UnknownPdaVersion TimelockPdaVersion = iota
PdaVersion1
)
func putTimelockAccountPdaVersion(dst []byte, v TimelockPdaVersion, offset *int) {
putUint8(dst, uint8(v), offset)
}
func getTimelockAccountPdaVersion(src []byte, dst *TimelockPdaVersion, offset *int) {
var v uint8
getUint8(src, &v, offset)
*dst = TimelockPdaVersion(v)
}