removed redelegation stuff
This commit is contained in:
parent
f8b030aece
commit
eeff820427
|
@ -21,7 +21,6 @@ const (
|
||||||
QueryDelegator = "delegator"
|
QueryDelegator = "delegator"
|
||||||
QueryDelegation = "delegation"
|
QueryDelegation = "delegation"
|
||||||
QueryUnbondingDelegation = "unbondingDelegation"
|
QueryUnbondingDelegation = "unbondingDelegation"
|
||||||
QueryRedelegation = "redelegation"
|
|
||||||
QueryDelegatorValidators = "delegatorValidators"
|
QueryDelegatorValidators = "delegatorValidators"
|
||||||
QueryDelegatorValidator = "delegatorValidator"
|
QueryDelegatorValidator = "delegatorValidator"
|
||||||
QueryPool = "pool"
|
QueryPool = "pool"
|
||||||
|
@ -93,14 +92,6 @@ type QueryBondsParams struct {
|
||||||
ValidatorAddr sdk.ValAddress
|
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) {
|
func queryValidators(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) {
|
||||||
stakeParams := k.GetParams(ctx)
|
stakeParams := k.GetParams(ctx)
|
||||||
validators := k.GetValidators(ctx, stakeParams.MaxValidators)
|
validators := k.GetValidators(ctx, stakeParams.MaxValidators)
|
||||||
|
@ -313,26 +304,6 @@ func queryUnbondingDelegation(ctx sdk.Context, cdc *codec.Codec, req abci.Reques
|
||||||
return res, nil
|
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) {
|
func queryPool(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) {
|
||||||
pool := k.GetPool(ctx)
|
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) {
|
func TestNewQuerier(t *testing.T) {
|
||||||
cdc := codec.New()
|
cdc := codec.New()
|
||||||
ctx, _, keeper := keep.CreateTestInput(t, false, 1000)
|
ctx, _, keeper := keep.CreateTestInput(t, false, 1000)
|
||||||
|
@ -373,27 +365,6 @@ func TestQueryDelegation(t *testing.T) {
|
||||||
|
|
||||||
_, err = queryDelegatorUnbondingDelegations(ctx, cdc, query, keeper)
|
_, err = queryDelegatorUnbondingDelegations(ctx, cdc, query, keeper)
|
||||||
require.NotNil(t, err)
|
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) {
|
func TestQueryRedelegations(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue