-
Notifications
You must be signed in to change notification settings - Fork 4
/
querier.go
executable file
·69 lines (62 loc) · 2.13 KB
/
querier.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 types
import (
"encoding/json"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Query endpoints supported by the oracle Querier.
const (
QueryParams = "params"
QueryCounts = "counts"
QueryData = "data"
QueryDataSources = "data_sources"
QueryOracleScripts = "oracle_scripts"
QueryRequests = "requests"
QueryRequestReports = "request_reports"
QueryRequestPrices = "request_prices"
QueryPriceSymbols = "price_symbols"
QueryLatestRequest = "latest_request"
QueryMultiRequestSearch = "multi_request_search"
QueryRequestSearch = "request_search"
QueryValidatorStatus = "validator_status"
QueryReporters = "reporters"
QueryActiveValidators = "active_validators"
QueryPendingRequests = "pending_requests"
QueryDataProvidersPool = "data_providers_pool"
QueryDataProviderReward = "data_provider_reward"
QueryProof = "proof"
QueryMultiProof = "multi_proof"
QueryRequestsCountProof = "requests_count_proof"
)
// QueryResult wraps querier result with HTTP status to return to application.
type QueryResult struct {
Status int `json:"status,string"`
Result json.RawMessage `json:"result"`
}
// deprecated: for legacy REST use only
// QueryActiveValidatorResult is the struct for the result of request active validators.
type QueryActiveValidatorResult struct {
Address sdk.ValAddress `json:"address"`
Power uint64 `json:"power"`
}
func NewQueryRequestSearchRequest(oid int64, callData []byte, askCount, minCount int64) *QueryRequestSearchRequest {
return &QueryRequestSearchRequest{
OracleScriptId: oid,
Calldata: callData,
AskCount: askCount,
MinCount: minCount,
}
}
func NewQueryRequestSearchResponse(req QueryRequestResponse) *QueryRequestSearchResponse {
return &QueryRequestSearchResponse{
Request: req.Request,
Result: req.Result,
Reports: req.Reports,
}
}
func NewQueryRequestPricesRequest(symbol string, minCount, askCount int64) QueryRequestPriceRequest {
return QueryRequestPriceRequest{
Symbol: symbol,
MinCount: minCount,
AskCount: askCount,
}
}