Merge PR #3857: Remove Shares Concept from Unbond/Redelegate UX
* Remove shares concept from unbonding and redelegation * Remove redundant staking REST type declerations * Rename staking REST request types * Fix slashing tests * Fix staking tests * Fix integration tests * Add safety checks for when validator tokens are zero * Attempt to fix simulation * Add pending log entry * Update docs * Implement and use SharesFromTokens * Rename ShareTokens and ShareTokensTruncated * Rename Delegation to Amount in DelegateRequest * Implement and use SharesFromTokensTruncated * Update MsgDelegate to use Amount instead of Value * Use constructors in staking sim messages * Implement and use ValidateUnbondAmount
This commit is contained in:
committed by
frog power 4000
parent
2788c2250d
commit
59765cecb1
@@ -533,7 +533,7 @@ func TestBonding(t *testing.T) {
|
||||
// this test takes a long time to run, eventually this second validator
|
||||
// will get slashed, meaning that it's exchange rate is no-longer 1-to-1,
|
||||
// hence we utilize the exchange rate in the following test
|
||||
delTokensAfterRedelegation := validator2.ShareTokens(delegatorDels[0].GetShares())
|
||||
delTokensAfterRedelegation := validator2.TokensFromShares(delegatorDels[0].GetShares())
|
||||
require.Equal(t, rdTokens.ToDec(), delTokensAfterRedelegation)
|
||||
|
||||
// verify balance after paying fees
|
||||
|
||||
@@ -815,11 +815,11 @@ func doDelegate(
|
||||
from := acc.GetAddress().String()
|
||||
|
||||
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
|
||||
msg := msgDelegationsInput{
|
||||
msg := stakingrest.DelegateRequest{
|
||||
BaseReq: baseReq,
|
||||
DelegatorAddress: delAddr,
|
||||
ValidatorAddress: valAddr,
|
||||
Delegation: sdk.NewCoin(sdk.DefaultBondDenom, amount),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, amount),
|
||||
}
|
||||
|
||||
req, err := cdc.MarshalJSON(msg)
|
||||
@@ -839,13 +839,6 @@ func doDelegate(
|
||||
return txResp
|
||||
}
|
||||
|
||||
type msgDelegationsInput struct {
|
||||
BaseReq rest.BaseReq `json:"base_req"`
|
||||
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
|
||||
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
|
||||
Delegation sdk.Coin `json:"delegation"`
|
||||
}
|
||||
|
||||
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
||||
func doUndelegate(
|
||||
t *testing.T, port, name, pwd string, delAddr sdk.AccAddress,
|
||||
@@ -859,11 +852,11 @@ func doUndelegate(
|
||||
from := acc.GetAddress().String()
|
||||
|
||||
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
|
||||
msg := msgUndelegateInput{
|
||||
msg := stakingrest.UndelegateRequest{
|
||||
BaseReq: baseReq,
|
||||
DelegatorAddress: delAddr,
|
||||
ValidatorAddress: valAddr,
|
||||
SharesAmount: amount.ToDec(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, amount),
|
||||
}
|
||||
|
||||
req, err := cdc.MarshalJSON(msg)
|
||||
@@ -882,13 +875,6 @@ func doUndelegate(
|
||||
return txResp
|
||||
}
|
||||
|
||||
type msgUndelegateInput struct {
|
||||
BaseReq rest.BaseReq `json:"base_req"`
|
||||
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
|
||||
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
|
||||
SharesAmount sdk.Dec `json:"shares"`
|
||||
}
|
||||
|
||||
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
||||
func doBeginRedelegation(
|
||||
t *testing.T, port, name, pwd string, delAddr sdk.AccAddress, valSrcAddr,
|
||||
@@ -902,12 +888,12 @@ func doBeginRedelegation(
|
||||
from := acc.GetAddress().String()
|
||||
|
||||
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
|
||||
msg := stakingrest.MsgBeginRedelegateInput{
|
||||
msg := stakingrest.RedelegateRequest{
|
||||
BaseReq: baseReq,
|
||||
DelegatorAddress: delAddr,
|
||||
ValidatorSrcAddress: valSrcAddr,
|
||||
ValidatorDstAddress: valDstAddr,
|
||||
SharesAmount: amount.ToDec(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, amount),
|
||||
}
|
||||
|
||||
req, err := cdc.MarshalJSON(msg)
|
||||
@@ -926,14 +912,6 @@ func doBeginRedelegation(
|
||||
return txResp
|
||||
}
|
||||
|
||||
type msgBeginRedelegateInput struct {
|
||||
BaseReq rest.BaseReq `json:"base_req"`
|
||||
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
|
||||
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // in bech32
|
||||
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // in bech32
|
||||
SharesAmount sdk.Dec `json:"shares"`
|
||||
}
|
||||
|
||||
// GET /staking/delegators/{delegatorAddr}/delegations Get all delegations from a delegator
|
||||
func getDelegatorDelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress) []staking.Delegation {
|
||||
res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/delegations", delegatorAddr), nil)
|
||||
|
||||
Reference in New Issue
Block a user