-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresources.go
More file actions
66 lines (50 loc) · 1.56 KB
/
resources.go
File metadata and controls
66 lines (50 loc) · 1.56 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
package glav
import "strings"
const (
AccountModule = "Account"
BlockModule = "Block"
CoinsModule = "Coins"
XfiModule = "XFI"
DfinanceModule = "Dfinance"
TimeModule = "Time"
BalanceStruct = "Balance"
BlockStruct = "BlockMetadata"
XfiStruct = "T"
PriceStruct = "Price"
TimeStruct = "CurrentTimestamp"
InfoStruct = "Info"
)
func OracleAccessVector(first string, second string) []byte {
params := [2]TypeParam{
currencyType(first),
currencyType(second),
}
tag := NewStructTag(codeCoreAddress, CoinsModule, PriceStruct, params[0:])
return tag.AccessVector()
}
func BlockMetadataVector() []byte {
empty := [0]TypeParam{}
tag := NewStructTag(codeCoreAddress, BlockModule, BlockStruct, empty[0:])
return tag.AccessVector()
}
func TimeMetadataVector() []byte {
empty := [0]TypeParam{}
tag := NewStructTag(codeCoreAddress, TimeModule, TimeStruct, empty[0:])
return tag.AccessVector()
}
func BalanceVector(curr string) []byte {
tag := NewStructTag(codeCoreAddress, AccountModule, BalanceStruct, []TypeParam{currencyType(curr)})
return tag.AccessVector()
}
func CurrencyInfoVector(curr string) []byte {
tag := NewStructTag(codeCoreAddress, DfinanceModule, InfoStruct, []TypeParam{currencyType(curr)})
return tag.AccessVector()
}
func currencyType(curr string) TypeParam {
empty := [0]TypeParam{}
curr = strings.ToUpper(curr)
if curr == "XFI" {
return NewStructTypeParam(NewStructTag(codeCoreAddress, XfiModule, XfiStruct, empty[0:]))
}
return NewStructTypeParam(NewStructTag(codeCoreAddress, CoinsModule, curr, empty[0:]))
}