Merge PR #4806: Converted balance from sdk.Int to sdk.Coin inside DelegationResponse
This commit is contained in:
parent
451535bd79
commit
f218de8141
|
@ -0,0 +1 @@
|
|||
#4783 The balance field in the DelegationResponse type is now sdk.Coin instead of sdk.Int
|
|
@ -2381,8 +2381,8 @@ definitions:
|
|||
type: string
|
||||
shares:
|
||||
type: string
|
||||
height:
|
||||
type: integer
|
||||
balance:
|
||||
$ref: "#/definitions/Coin"
|
||||
UnbondingDelegationPair:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
@ -350,7 +350,7 @@ func delegationToDelegationResponse(ctx sdk.Context, k Keeper, del types.Delegat
|
|||
del.DelegatorAddress,
|
||||
del.ValidatorAddress,
|
||||
del.Shares,
|
||||
val.TokensFromShares(del.Shares).TruncateInt(),
|
||||
sdk.NewCoin(k.BondDenom(ctx), val.TokensFromShares(del.Shares).TruncateInt()),
|
||||
), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestNewQuerier(t *testing.T) {
|
|||
func TestQueryParametersPool(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
ctx, _, keeper, _ := CreateTestInput(t, false, 1000)
|
||||
bondDenom := keeper.BondDenom(ctx)
|
||||
bondDenom := sdk.DefaultBondDenom
|
||||
|
||||
res, err := queryParameters(ctx, keeper)
|
||||
require.Nil(t, err)
|
||||
|
@ -268,7 +268,7 @@ func TestQueryDelegation(t *testing.T) {
|
|||
|
||||
require.Equal(t, delegation.ValidatorAddress, delegationRes.ValidatorAddress)
|
||||
require.Equal(t, delegation.DelegatorAddress, delegationRes.DelegatorAddress)
|
||||
require.Equal(t, delegation.Shares.TruncateInt(), delegationRes.Balance)
|
||||
require.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, delegation.Shares.TruncateInt()), delegationRes.Balance)
|
||||
|
||||
// Query Delegator Delegations
|
||||
query = abci.RequestQuery{
|
||||
|
@ -285,7 +285,7 @@ func TestQueryDelegation(t *testing.T) {
|
|||
require.Len(t, delegatorDelegations, 1)
|
||||
require.Equal(t, delegation.ValidatorAddress, delegatorDelegations[0].ValidatorAddress)
|
||||
require.Equal(t, delegation.DelegatorAddress, delegatorDelegations[0].DelegatorAddress)
|
||||
require.Equal(t, delegation.Shares.TruncateInt(), delegatorDelegations[0].Balance)
|
||||
require.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, delegation.Shares.TruncateInt()), delegatorDelegations[0].Balance)
|
||||
|
||||
// error unknown request
|
||||
query.Data = bz[:len(bz)-1]
|
||||
|
@ -312,7 +312,7 @@ func TestQueryDelegation(t *testing.T) {
|
|||
require.Len(t, delegatorDelegations, 1)
|
||||
require.Equal(t, delegation.ValidatorAddress, delegationsRes[0].ValidatorAddress)
|
||||
require.Equal(t, delegation.DelegatorAddress, delegationsRes[0].DelegatorAddress)
|
||||
require.Equal(t, delegation.Shares.TruncateInt(), delegationsRes[0].Balance)
|
||||
require.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, delegation.Shares.TruncateInt()), delegationsRes[0].Balance)
|
||||
|
||||
// Query unbonging delegation
|
||||
unbondingTokens := sdk.TokensFromConsensusPower(10)
|
||||
|
|
|
@ -352,10 +352,10 @@ func (d Redelegations) String() (out string) {
|
|||
// in addition to shares which is more suitable for client responses.
|
||||
type DelegationResponse struct {
|
||||
Delegation
|
||||
Balance sdk.Int `json:"balance" yaml:"balance"`
|
||||
Balance sdk.Coin `json:"balance" yaml:"balance"`
|
||||
}
|
||||
|
||||
func NewDelegationResp(d sdk.AccAddress, v sdk.ValAddress, s sdk.Dec, b sdk.Int) DelegationResponse {
|
||||
func NewDelegationResp(d sdk.AccAddress, v sdk.ValAddress, s sdk.Dec, b sdk.Coin) DelegationResponse {
|
||||
return DelegationResponse{NewDelegation(d, v, s), b}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,8 +80,10 @@ func TestRedelegationString(t *testing.T) {
|
|||
|
||||
func TestDelegationResponses(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
dr1 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5), sdk.NewInt(5))
|
||||
dr2 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5), sdk.NewInt(5))
|
||||
dr1 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5)))
|
||||
dr2 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5)))
|
||||
drs := DelegationResponses{dr1, dr2}
|
||||
|
||||
bz1, err := json.Marshal(dr1)
|
||||
|
|
Loading…
Reference in New Issue