From 34542076bb67b9afc2df5c761933f7dda50cbfd1 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Mon, 24 Jun 2024 22:22:34 +0530 Subject: [PATCH] address the coderabbitai suggestions --- CHANGELOG.md | 2 +- proto/umee/leverage/v1/query.proto | 4 +- swagger/swagger.yaml | 104 ++++++++++++++------------- x/leverage/keeper/grpc_query_test.go | 16 ++--- x/leverage/types/query.pb.go | 4 +- 5 files changed, 68 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 366a879230..5699f14a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [2494](https://github.com/umee-network/umee/pull/2494) Use go 1.22 - [2495](https://github.com/umee-network/umee/pull/2495) (util) `KeyWithUint64` and `KeyWithUint32` helper functions for db keys. - [2504](https://github.com/umee-network/umee/pull/2504) bump `wasmd` to v0.45.0. -- [2562](https://github.com/umee-network/umee/pull/2562) (x/leverage): improve the existed inspect account response. +- [2562](https://github.com/umee-network/umee/pull/2562) (x/leverage): Improved the existing inspect account response by adding `base_denom` and `base_amount`. ### Bug Fixes diff --git a/proto/umee/leverage/v1/query.proto b/proto/umee/leverage/v1/query.proto index 1e8dd5215a..b0c2196c05 100644 --- a/proto/umee/leverage/v1/query.proto +++ b/proto/umee/leverage/v1/query.proto @@ -505,14 +505,14 @@ message PositionBalance { string denom = 1; // base_denom will be ibc_denom or native base denom of umee (Ex: uumee, ibc/XXXX) string base_denom = 2; - // amount will be convert base tokens into symbol tokens with exchange rates + // amount represents the converted base tokens into symbol tokens using exchange rates // Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 string amount = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // base_amount will base tokens without coverting to symbol denoms + // base_amount will represent base tokens without converting to symbol denominations string base_amount = 4 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index caab4ab899..d1ce8ecd75 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -590,16 +590,16 @@ paths: amount: type: string title: >- - amount will be convert base tokens into symbol - tokens with exchange rates + amount represents the converted base tokens + into symbol tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting - to symbol denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -623,16 +623,16 @@ paths: amount: type: string title: >- - amount will be convert base tokens into symbol - tokens with exchange rates + amount represents the converted base tokens + into symbol tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting - to symbol denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -783,16 +783,16 @@ paths: amount: type: string title: >- - amount will be convert base tokens into symbol - tokens with exchange rates + amount represents the converted base tokens into + symbol tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting - to symbol denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -816,16 +816,16 @@ paths: amount: type: string title: >- - amount will be convert base tokens into symbol - tokens with exchange rates + amount represents the converted base tokens into + symbol tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting - to symbol denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -6853,14 +6853,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens with - exchange rates + amount represents the converted base tokens into symbol tokens + using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string - title: base_amount will base tokens without coverting to symbol denoms + title: >- + base_amount will represent base tokens without converting to + symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -6883,14 +6885,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens with - exchange rates + amount represents the converted base tokens into symbol tokens + using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string - title: base_amount will base tokens without coverting to symbol denoms + title: >- + base_amount will represent base tokens without converting to + symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -6942,16 +6946,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens with - exchange rates + amount represents the converted base tokens into symbol + tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting to symbol - denoms + base_amount will represent base tokens without converting to + symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -6974,16 +6978,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens with - exchange rates + amount represents the converted base tokens into symbol + tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting to symbol - denoms + base_amount will represent base tokens without converting to + symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -7101,14 +7105,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens with exchange - rates + amount represents the converted base tokens into symbol tokens using + exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string - title: base_amount will base tokens without coverting to symbol denoms + title: >- + base_amount will represent base tokens without converting to symbol + denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -7450,16 +7456,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens - with exchange rates + amount represents the converted base tokens into symbol + tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting to symbol - denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -7482,16 +7488,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens - with exchange rates + amount represents the converted base tokens into symbol + tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting to symbol - denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -7563,16 +7569,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens - with exchange rates + amount represents the converted base tokens into + symbol tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting to - symbol denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. @@ -7596,16 +7602,16 @@ definitions: amount: type: string title: >- - amount will be convert base tokens into symbol tokens - with exchange rates + amount represents the converted base tokens into + symbol tokens using exchange rates Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 base_amount: type: string title: >- - base_amount will base tokens without coverting to - symbol denoms + base_amount will represent base tokens without + converting to symbol denominations description: >- PositionBalance contains denom, amount with base_denom, base_amount for account position. diff --git a/x/leverage/keeper/grpc_query_test.go b/x/leverage/keeper/grpc_query_test.go index 9db7696af9..669caaea70 100644 --- a/x/leverage/keeper/grpc_query_test.go +++ b/x/leverage/keeper/grpc_query_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "context" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "gotest.tools/v3/assert" @@ -250,7 +250,7 @@ func (s *IntegrationTestSuite) TestQuerier_Inspect() { resp, err := s.queryClient.Inspect(ctx, &types.QueryInspect{}) require.NoError(err) - positionBal := func(c sdk.DecCoins, baseAmount math.Int) []types.PositionBalance { + convertToPositionBalances := func(c sdk.DecCoins, baseAmount sdkmath.Int) []types.PositionBalance { res := make([]types.PositionBalance, 0) for _, c := range c { res = append(res, types.PositionBalance{ @@ -273,8 +273,8 @@ func (s *IntegrationTestSuite) TestQuerier_Inspect() { Value: 2526, }, Position: &types.DecBalances{ - Collateral: positionBal(sdk.NewDecCoins(coin.Dec("UMEE", "600")), math.NewInt(600_000000)), - Borrowed: positionBal(sdk.NewDecCoins(coin.Dec("UMEE", "15")), math.NewInt(15_000000)), + Collateral: convertToPositionBalances(sdk.NewDecCoins(coin.Dec("UMEE", "600")), sdkmath.NewInt(600_000000)), + Borrowed: convertToPositionBalances(sdk.NewDecCoins(coin.Dec("UMEE", "15")), sdkmath.NewInt(15_000000)), }, }, { @@ -285,8 +285,8 @@ func (s *IntegrationTestSuite) TestQuerier_Inspect() { Value: 4210, }, Position: &types.DecBalances{ - Collateral: positionBal(sdk.NewDecCoins(coin.Dec("UMEE", "1000")), math.NewInt(1000_000000)), - Borrowed: positionBal(sdk.NewDecCoins(coin.Dec("UMEE", "10.5")), math.NewInt(10_500000)), + Collateral: convertToPositionBalances(sdk.NewDecCoins(coin.Dec("UMEE", "1000")), sdkmath.NewInt(1000_000000)), + Borrowed: convertToPositionBalances(sdk.NewDecCoins(coin.Dec("UMEE", "10.5")), sdkmath.NewInt(10_500000)), }, }, { @@ -297,8 +297,8 @@ func (s *IntegrationTestSuite) TestQuerier_Inspect() { Value: 252, }, Position: &types.DecBalances{ - Collateral: positionBal(sdk.NewDecCoins(coin.Dec("UMEE", "60")), math.NewInt(60_000000)), - Borrowed: positionBal(sdk.NewDecCoins(coin.Dec("UMEE", "1.5")), math.NewInt(1_500000)), + Collateral: convertToPositionBalances(sdk.NewDecCoins(coin.Dec("UMEE", "60")), sdkmath.NewInt(60_000000)), + Borrowed: convertToPositionBalances(sdk.NewDecCoins(coin.Dec("UMEE", "1.5")), sdkmath.NewInt(1_500000)), }, }, }, diff --git a/x/leverage/types/query.pb.go b/x/leverage/types/query.pb.go index d7b3a18f33..3b9dde2ad6 100644 --- a/x/leverage/types/query.pb.go +++ b/x/leverage/types/query.pb.go @@ -1424,10 +1424,10 @@ type PositionBalance struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` // base_denom will be ibc_denom or native base denom of umee (Ex: uumee, ibc/XXXX) BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // amount will be convert base tokens into symbol tokens with exchange rates + // amount represents the converted base tokens into symbol tokens using exchange rates // Ex: 1000u/uumee becomes 0.0015UMEE at an exponent of 6 and uToken exchange rate of 1.5 Amount cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=amount,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"amount"` - // base_amount will base tokens without coverting to symbol denoms + // base_amount will represent base tokens without converting to symbol denominations BaseAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=base_amount,json=baseAmount,proto3,customtype=cosmossdk.io/math.Int" json:"base_amount"` }