removed redelegation stuff
This commit is contained in:
parent
f8b030aece
commit
eeff820427
|
@ -21,7 +21,6 @@ const (
|
|||
QueryDelegator = "delegator"
|
||||
QueryDelegation = "delegation"
|
||||
QueryUnbondingDelegation = "unbondingDelegation"
|
||||
QueryRedelegation = "redelegation"
|
||||
QueryDelegatorValidators = "delegatorValidators"
|
||||
QueryDelegatorValidator = "delegatorValidator"
|
||||
QueryPool = "pool"
|
||||
|
@ -93,14 +92,6 @@ type QueryBondsParams struct {
|
|||
ValidatorAddr sdk.ValAddress
|
||||
}
|
||||
|
||||
// defines the params for the following queries:
|
||||
// - 'custom/stake/redelegation'
|
||||
type QueryRedelegationParams struct {
|
||||
DelegatorAddr sdk.AccAddress
|
||||
SrcValidatorAddr sdk.ValAddress
|
||||
DstValidatorAddr sdk.ValAddress
|
||||
}
|
||||
|
||||
func queryValidators(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) {
|
||||
stakeParams := k.GetParams(ctx)
|
||||
validators := k.GetValidators(ctx, stakeParams.MaxValidators)
|
||||
|
@ -313,26 +304,6 @@ func queryUnbondingDelegation(ctx sdk.Context, cdc *codec.Codec, req abci.Reques
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func queryRedelegation(ctx sdk.Context, cdc *codec.Codec, req abci.RequestQuery, k keep.Keeper) (res []byte, err sdk.Error) {
|
||||
var params QueryRedelegationParams
|
||||
|
||||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms)
|
||||
if errRes != nil {
|
||||
return []byte{}, sdk.ErrUnknownRequest(string(req.Data))
|
||||
}
|
||||
|
||||
redel, found := k.GetRedelegation(ctx, params.DelegatorAddr, params.SrcValidatorAddr, params.DstValidatorAddr)
|
||||
if !found {
|
||||
return []byte{}, types.ErrNoRedelegation(types.DefaultCodespace)
|
||||
}
|
||||
|
||||
res, errRes = codec.MarshalJSONIndent(cdc, redel)
|
||||
if errRes != nil {
|
||||
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", errRes.Error()))
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func queryPool(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) {
|
||||
pool := k.GetPool(ctx)
|
||||
|
||||
|
|
|
@ -36,14 +36,6 @@ func newTestBondQuery(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress
|
|||
}
|
||||
}
|
||||
|
||||
func newTestRedelegationQuery(delegatorAddr sdk.AccAddress, srcValidatorAddr sdk.ValAddress, dstValidatorAddr sdk.ValAddress) QueryRedelegationParams {
|
||||
return QueryRedelegationParams{
|
||||
DelegatorAddr: delegatorAddr,
|
||||
SrcValidatorAddr: srcValidatorAddr,
|
||||
DstValidatorAddr: dstValidatorAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewQuerier(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
ctx, _, keeper := keep.CreateTestInput(t, false, 1000)
|
||||
|
@ -373,27 +365,6 @@ func TestQueryDelegation(t *testing.T) {
|
|||
|
||||
_, err = queryDelegatorUnbondingDelegations(ctx, cdc, query, keeper)
|
||||
require.NotNil(t, err)
|
||||
|
||||
// Query redelegation
|
||||
redel, err := keeper.BeginRedelegation(ctx, addrAcc2, val1.OperatorAddr, val2.OperatorAddr, sdk.NewDec(10))
|
||||
require.Nil(t, err)
|
||||
|
||||
bz, errRes = cdc.MarshalJSON(newTestRedelegationQuery(addrAcc2, val1.OperatorAddr, val2.OperatorAddr))
|
||||
require.Nil(t, errRes)
|
||||
|
||||
query = abci.RequestQuery{
|
||||
Path: "/custom/stake/redelegation",
|
||||
Data: bz,
|
||||
}
|
||||
|
||||
res, err = queryRedelegation(ctx, cdc, query, keeper)
|
||||
require.Nil(t, err)
|
||||
|
||||
var redelRes types.Redelegation
|
||||
errRes = cdc.UnmarshalJSON(res, &redelRes)
|
||||
require.Nil(t, errRes)
|
||||
|
||||
require.Equal(t, redel, redelRes)
|
||||
}
|
||||
|
||||
func TestQueryRedelegations(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue