-
Notifications
You must be signed in to change notification settings - Fork 3
/
contracts.go
69 lines (57 loc) · 1.87 KB
/
contracts.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
package hiveenginego
type ContractQueryParams struct {
Contract string `json:"contract"`
Table string `json:"table"`
Query interface{} `json:"query"`
Limit int `json:"limit"`
Offset int `json:"offset"`
Index []ContractQueryParamsIndex `json:"indexes"`
}
type QueryIDRange struct {
Id QueryIntRange `json:"_id"`
}
type QueryIntRange struct {
GreaterThanEqual int `json:"$gte,omitempty"`
LessThanEqual int `json:"$lte,omitempty"`
}
type BroadcastTx struct {
}
type ContractQueryParamsQuery struct {
Account string `json:"account,omitempty"`
NftId string `json:"_id,omitempty"`
}
type ContractQueryParamsIndex struct {
Index string `json:"index,omitempty"`
Descending bool `json:"descending"`
}
type ContractTx struct {
ContractName string `json:"contractName"`
ContractAction string `json:"contractAction"`
ContractPayload interface{} `json:"contractPayload"`
}
func (h HiveEngineRpcNode) QueryContract(qParams ContractQueryParams) ([]byte, error){
if h.Endpoints.Contracts == "" {
h.Endpoints.Contracts = "/contract"
}
query := herpcQuery{method: "find", params: qParams}
qRes, err := h.rpcExec(h.Endpoints.Contracts, query)
if err != nil {
return nil, err
}
return qRes, nil
}
func (h HiveEngineRpcNode) QueryContractBatch(qParams []ContractQueryParams) ([][]byte, error){
if h.Endpoints.Contracts == "" {
h.Endpoints.Contracts = "/contract"
}
var queries []herpcQuery
for _, qParam := range qParams{
query := herpcQuery{method: "find", params: qParam}
queries = append(queries, query)
}
qRes, err := h.rpcExecBatch(h.Endpoints.Contracts, queries)
if err != nil{
return nil, err
}
return qRes, nil
}