/
querier.go
121 lines (106 loc) · 4.55 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package types
import (
sdk "github.com/FiboChain/fbc/libs/cosmos-sdk/types"
"github.com/FiboChain/fbc/libs/cosmos-sdk/types/query"
)
// query endpoints supported by the staking Querier
const (
QueryValidators = "validators"
QueryValidator = "validator"
QueryUnbondingDelegation = "unbondingDelegation"
QueryPool = "pool"
QueryParameters = "parameters"
QueryParams4IBC = "params4ibc"
QueryAddress = "address"
QueryForAddress = "validatorAddress"
QueryForAccAddress = "validatorAccAddress"
QueryProxy = "proxy"
QueryValidatorAllShares = "validatorAllShares"
QueryDelegator = "delegator"
QueryDelegatorDelegations = "delegatorDelegations"
QueryUnbondingDelegation2 = "unbondingDelegation2"
QueryHistoricalInfo = "historicalInfo"
QueryDelegatorValidators = "delegatorValidators"
QueryDelegatorValidator = "delegatorValidator"
QueryValidatorDelegations = "validatorDelegations"
QueryValidatorDelegator = "validatorDelegator"
)
// QueryDelegatorParams defines the params for the following queries:
// - 'custom/staking/delegatorDelegations'
// - 'custom/staking/delegatorUnbondingDelegations'
// - 'custom/staking/delegatorValidators'
type QueryDelegatorParams struct {
DelegatorAddr sdk.AccAddress
}
// NewQueryDelegatorParams creates a new instance of QueryDelegatorParams
func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams {
return QueryDelegatorParams{
DelegatorAddr: delegatorAddr,
}
}
// QueryValidatorParams defines the params for the following queries:
// - 'custom/staking/validator'
// - 'custom/staking/validatorDelegations'
// - 'custom/staking/validatorUnbondingDelegations'
// - 'custom/staking/validatorRedelegations'
type QueryValidatorParams struct {
ValidatorAddr sdk.ValAddress
}
// NewQueryValidatorParams creates a new instance of QueryValidatorParams
func NewQueryValidatorParams(validatorAddr sdk.ValAddress) QueryValidatorParams {
return QueryValidatorParams{
ValidatorAddr: validatorAddr,
}
}
// QueryBondsParams defines the params for the following queries:
// - 'custom/staking/delegation'
// - 'custom/staking/unbondingDelegation'
// - 'custom/staking/delegatorValidator'
type QueryBondsParams struct {
DelegatorAddr sdk.AccAddress
ValidatorAddr sdk.ValAddress
}
// NewQueryBondsParams creates a new instance of QueryBondsParams
func NewQueryBondsParams(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) QueryBondsParams {
return QueryBondsParams{
DelegatorAddr: delegatorAddr,
ValidatorAddr: validatorAddr,
}
}
// QueryValidatorsParams defines the params for the following queries:
// - 'custom/staking/validators'
type QueryValidatorsParams struct {
Page, Limit int
Status string
}
// NewQueryValidatorsParams creates a new instance of QueryValidatorsParams
func NewQueryValidatorsParams(page, limit int, status string) QueryValidatorsParams {
return QueryValidatorsParams{page, limit, status}
}
type QueryDelegatorDelegationsRequest struct {
// delegator_addr defines the delegator address to query for.
DelegatorAddr string `protobuf:"bytes,1,opt,name=delegator_addr,json=delegatorAddr,proto3" json:"delegator_addr,omitempty"`
// pagination defines an optional pagination for the request.
Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
type QueryDelegatorUnbondingDelegationsRequest struct {
// delegator_addr defines the delegator address to query for.
DelegatorAddr string `protobuf:"bytes,1,opt,name=delegator_addr,json=delegatorAddr,proto3" json:"delegator_addr,omitempty"`
// pagination defines an optional pagination for the request.
Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
type QueryUnbondingDelegationRequest struct {
// delegator_addr defines the delegator address to query for.
DelegatorAddr string `protobuf:"bytes,1,opt,name=delegator_addr,json=delegatorAddr,proto3" json:"delegator_addr,omitempty"`
// validator_addr defines the validator address to query for.
ValidatorAddr string `protobuf:"bytes,2,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"`
}
// QueryHistoricalInfoParams defines the params for the following queries:
// - 'custom/staking/historicalInfo'
type QueryHistoricalInfoParams struct {
Height int64
}
// NewQueryHistoricalInfoParams creates a new QueryHistoricalInfoParams instance
func NewQueryHistoricalInfoParams(height int64) QueryHistoricalInfoParams {
return QueryHistoricalInfoParams{height}
}