Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code inspection error refactor #282

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/wasm/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (m *CustomMessenger) WhitelistAppIDLiquidation(ctx sdk.Context, contractAdd

func MsgWhitelistAppIDLiquidation(liquidationKeeper liquidationkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress,
a *bindings.MsgWhitelistAppIDLiquidation) error {
err := liquidationKeeper.WasmWhitelistAppIdLiquidation(ctx, a.AppMappingID)
err := liquidationKeeper.WasmWhitelistAppIDLiquidation(ctx, a.AppMappingID)
if err != nil {
return err
}
Expand All @@ -329,7 +329,7 @@ func (m *CustomMessenger) RemoveWhitelistAppIDLiquidation(ctx sdk.Context, contr

func MsgRemoveWhitelistAppIDLiquidation(liquidationKeeper liquidationkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress,
a *bindings.MsgRemoveWhitelistAppIDLiquidation) error {
err := liquidationKeeper.WasmRemoveWhitelistAppIdLiquidation(ctx, a.AppMappingID)
err := liquidationKeeper.WasmRemoveWhitelistAppIDLiquidation(ctx, a.AppMappingID)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions app/wasm/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ func (qp QueryPlugin) WasmRemoveWhitelistAssetLockerQueryCheck(ctx sdk.Context,
}

func (qp QueryPlugin) WasmWhitelistAppIDLiquidationQueryCheck(ctx sdk.Context, appMappingID uint64) (found bool, err string) {
found, err = qp.liquidationKeeper.WasmWhitelistAppIdLiquidationQuery(ctx, appMappingID)
found, err = qp.liquidationKeeper.WasmWhitelistAppIDLiquidationQuery(ctx, appMappingID)
return found, err
}

func (qp QueryPlugin) WasmRemoveWhitelistAppIDLiquidationQueryCheck(ctx sdk.Context, appMappingID uint64) (found bool, err string) {
found, err = qp.liquidationKeeper.WasmRemoveWhitelistAppIdLiquidationQuery(ctx, appMappingID)
found, err = qp.liquidationKeeper.WasmRemoveWhitelistAppIDLiquidationQuery(ctx, appMappingID)
return found, err
}
1 change: 0 additions & 1 deletion cmd/comdex/genwasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ func AddGenesisWasmMsgCmd(defaultNodeHome string) *cobra.Command {
wasmcli.GenesisListCodesCmd(defaultNodeHome, genesisIO),
)
return txCmd

}
1 change: 0 additions & 1 deletion cmd/comdex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

func main() {

comdex.SetAccountAddressPrefixes()

root, _ := NewRootCmd()
Expand Down
1 change: 0 additions & 1 deletion x/asset/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
)

const (
flagLiquidationRatio = "liquidation-ratio"
flagName = "name"
flagDenom = "denom"
flagDecimals = "decimals"
Expand Down
27 changes: 0 additions & 27 deletions x/asset/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ var (
_ sdk.Msg = (*MsgAddPairRequest)(nil)
)

func NewMsgAddPairRequest(from sdk.AccAddress, assetIn, assetOut uint64, liquidationRatio sdk.Dec) *MsgAddPairRequest {
return &MsgAddPairRequest{
From: from.String(),
AssetIn: assetIn,
AssetOut: assetOut,
}
}

func (m *MsgAddPairRequest) ValidateBasic() error {
if m.From == "" {
return errors.Wrap(ErrorInvalidFrom, "from cannot be empty")
Expand All @@ -45,15 +37,6 @@ func (m *MsgAddPairRequest) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{from}
}

func NewMsgAddAssetRequest(from sdk.AccAddress, name, denom string, decimals int64) *MsgAddAssetRequest {
return &MsgAddAssetRequest{
From: from.String(),
Name: name,
Denom: denom,
Decimals: decimals,
}
}

func (m *MsgAddAssetRequest) ValidateBasic() error {
if m.From == "" {
return errors.Wrap(ErrorInvalidFrom, "from cannot be empty")
Expand Down Expand Up @@ -89,16 +72,6 @@ func (m *MsgAddAssetRequest) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{from}
}

func NewMsgUpdateAssetRequest(from sdk.AccAddress, id uint64, name, denom string, decimals int64) *MsgUpdateAssetRequest {
return &MsgUpdateAssetRequest{
From: from.String(),
Id: id,
Name: name,
Denom: denom,
Decimals: decimals,
}
}

func (m *MsgUpdateAssetRequest) ValidateBasic() error {
if m.From == "" {
return errors.Wrap(ErrorInvalidFrom, "from cannot be empty")
Expand Down
4 changes: 2 additions & 2 deletions x/auction/keeper/dutch.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ func (k Keeper) CloseDutchAuction(

// //Transfer balance from collector module to auction module
// requiredAmount := dutchAuction.InflowTokenTargetAmount.Sub(dutchAuction.InflowTokenCurrentAmount)
// _, err := k.GetAmountFromCollector(ctx, dutchAuction.AppId, dutchAuction.AssetInId, requiredAmount.Amount)
// _, err := k.GetAmountFromCollector(ctx, dutchAuction.appID, dutchAuction.AssetInId, requiredAmount.Amount)
// if err != nil {

// return err
// }

// //storing protocol loss
// k.SetProtocolStatistics(ctx, dutchAuction.AppId, dutchAuction.AssetInId, requiredAmount.Amount)
// k.SetProtocolStatistics(ctx, dutchAuction.appID, dutchAuction.AssetInId, requiredAmount.Amount)
// // burnToken.Amount = lockedVault.AmountOut
// }

Expand Down
8 changes: 0 additions & 8 deletions x/auction/keeper/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ func Multiply(a, b sdk.Dec) sdk.Dec {
return a.Mul(b)
}

func Add(a, b sdk.Dec) sdk.Dec {
return a.Add(b)
}

func Sub(a, b sdk.Dec) sdk.Dec {
return a.Sub(b)
}

func (k Keeper) getOutflowTokenInitialPrice(price sdk.Int, buffer sdk.Dec) sdk.Dec {
result := buffer.Mul(price.ToDec())
return result
Expand Down
2 changes: 1 addition & 1 deletion x/auction/keeper/query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (q *QueryServer) QueryProtocolStatistics(c context.Context, req *types.Quer
key []byte
)

key = types.ProtocolStatisticsAppIdKey(req.AppId)
key = types.ProtocolStatisticsAppIDKey(req.AppId)

pagination, err := query.FilteredPaginate(
prefix.NewStore(q.Store(ctx), key),
Expand Down
12 changes: 6 additions & 6 deletions x/auction/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func AuctionKey(appID uint64, auctionType string, auctionID uint64) []byte {
return append(append(append(AuctionKeyPrefix, sdk.Uint64ToBigEndian(appID)...), auctionType...), sdk.Uint64ToBigEndian(auctionID)...)
}

func UserKey(bidder string, appID uint64, auctionType string, bidId uint64) []byte {
return append(append(append(append(UserKeyPrefix, bidder...), sdk.Uint64ToBigEndian(appID)...), auctionType...), sdk.Uint64ToBigEndian(bidId)...)
func UserKey(bidder string, appID uint64, auctionType string, bidID uint64) []byte {
return append(append(append(append(UserKeyPrefix, bidder...), sdk.Uint64ToBigEndian(appID)...), auctionType...), sdk.Uint64ToBigEndian(bidID)...)
}

func UserAuctionTypeKey(bidder string, appID uint64, auctionType string) []byte {
Expand All @@ -73,12 +73,12 @@ func HistoryAuctionTypeKey(appID uint64, auctionType string) []byte {
return append(append(HistoryAuctionKeyPrefix, sdk.Uint64ToBigEndian(appID)...), auctionType...)
}

func ProtocolStatisticsKey(appID, assetId uint64) []byte {
return append(append(ProtocolStatisticsPrefixKey, sdk.Uint64ToBigEndian(appID)...), sdk.Uint64ToBigEndian(assetId)...)
func ProtocolStatisticsKey(appID, assetID uint64) []byte {
return append(append(ProtocolStatisticsPrefixKey, sdk.Uint64ToBigEndian(appID)...), sdk.Uint64ToBigEndian(assetID)...)
}

func ProtocolStatisticsAppIdKey(appId uint64) []byte {
return append(ProtocolStatisticsPrefixKey, sdk.Uint64ToBigEndian(appId)...)
func ProtocolStatisticsAppIDKey(appID uint64) []byte {
return append(ProtocolStatisticsPrefixKey, sdk.Uint64ToBigEndian(appID)...)
}

func AuctionParamsKey(id uint64) []byte {
Expand Down
5 changes: 1 addition & 4 deletions x/collector/keeper/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (k *Keeper) UpdateCollector(ctx sdk.Context, appID, assetID uint64, collect

collectorData, found := k.GetAppidToAssetCollectorMapping(ctx, appID)
if !found {
//create a new instance of AppId To AssetCollectorMapping
//create a new instance of appID To AssetCollectorMapping
var collectorNewData types.AppIdToAssetCollectorMapping
collectorNewData.AppId = appID

Expand Down Expand Up @@ -157,7 +157,6 @@ func (k *Keeper) UpdateCollector(ctx sdk.Context, appID, assetID uint64, collect
}
}
return nil

}

// SetAppidToAssetCollectorMapping update collector with app_id and asset
Expand Down Expand Up @@ -249,7 +248,6 @@ func (k *Keeper) SetCollectorLookupTable(ctx sdk.Context, records ...types.Colle
store.Set(key, value)
}
return nil

}

func (k *Keeper) SetCollectorLookupTableForWasm(ctx sdk.Context, records ...types.CollectorLookupTable) error {
Expand All @@ -276,7 +274,6 @@ func (k *Keeper) SetCollectorLookupTableForWasm(ctx sdk.Context, records ...type
}
}
return nil

}

// GetCollectorLookupTable returns collector lookup table
Expand Down
1 change: 0 additions & 1 deletion x/collector/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
func (am AppModule) RegisterServices(cfg module.Configurator) {
//types.RegisterQueryServiceServer(cfg.QueryServer(), am.keeper)
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper))

}

// RegisterInvariants registers the capability module's invariants.
Expand Down
14 changes: 0 additions & 14 deletions x/lend/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ func ParseStringFromString(s string, separator string) ([]string, error) {
return parsedStrings, nil
}

func ParseInt64SliceFromString(s string, separator string) ([]int64, error) {
var parsedInts []int64
for _, s := range strings.Split(s, separator) {
s = strings.TrimSpace(s)

parsed, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return []int64{}, err
}
parsedInts = append(parsedInts, parsed)
}
return parsedInts, nil
}

func ParseUint64SliceFromString(s string, separator string) ([]uint64, error) {
var parsedInts []uint64
for _, s := range strings.Split(s, separator) {
Expand Down
2 changes: 1 addition & 1 deletion x/liquidation/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func txWhitelistAppID() *cobra.Command {
return err
}

msg := types.NewMsgWhitelistAppId(
msg := types.NewMsgWhitelistAppID(
appMappingID,
ctx.GetFromAddress(),
)
Expand Down
10 changes: 5 additions & 5 deletions x/liquidation/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func uint64InSlice(a uint64, list []uint64) bool {
return false
}

func (k Keeper) WhitelistAppId(ctx sdk.Context, appMappingId uint64) error {
func (k Keeper) WhitelistAppID(ctx sdk.Context, appMappingId uint64) error {
found := uint64InSlice(appMappingId, k.GetAppIds(ctx).WhitelistedAppMappingIds)
if found {
return types.ErrAppIDExists
Expand Down Expand Up @@ -111,7 +111,7 @@ func (k Keeper) RemoveWhitelistAsset(ctx sdk.Context, appMappingID uint64) error

//Wasm tx and query binding functions

func (k Keeper) WasmWhitelistAppIdLiquidation(ctx sdk.Context, appMappingId uint64) error {
func (k Keeper) WasmWhitelistAppIDLiquidation(ctx sdk.Context, appMappingId uint64) error {
WhitelistedAppIds := append(k.GetAppIds(ctx).WhitelistedAppMappingIds, appMappingId)
UpdatedWhitelistedAppIds := types.WhitelistedAppIds{
WhitelistedAppMappingIds: WhitelistedAppIds,
Expand All @@ -120,15 +120,15 @@ func (k Keeper) WasmWhitelistAppIdLiquidation(ctx sdk.Context, appMappingId uint
return nil
}

func (k Keeper) WasmWhitelistAppIdLiquidationQuery(ctx sdk.Context, appMappingId uint64) (bool, string) {
func (k Keeper) WasmWhitelistAppIDLiquidationQuery(ctx sdk.Context, appMappingId uint64) (bool, string) {
found := uint64InSlice(appMappingId, k.GetAppIds(ctx).WhitelistedAppMappingIds)
if found {
return false, types.ErrAppIDExists.Error()
}
return true, ""
}

func (k Keeper) WasmRemoveWhitelistAppIdLiquidation(ctx sdk.Context, appMappingId uint64) error {
func (k Keeper) WasmRemoveWhitelistAppIDLiquidation(ctx sdk.Context, appMappingId uint64) error {
WhitelistedAppIds := k.GetAppIds(ctx).WhitelistedAppMappingIds
found := uint64InSlice(appMappingId, k.GetAppIds(ctx).WhitelistedAppMappingIds)
if !found {
Expand All @@ -149,7 +149,7 @@ func (k Keeper) WasmRemoveWhitelistAppIdLiquidation(ctx sdk.Context, appMappingI
return nil
}

func (k Keeper) WasmRemoveWhitelistAppIdLiquidationQuery(ctx sdk.Context, appMappingId uint64) (bool, string) {
func (k Keeper) WasmRemoveWhitelistAppIDLiquidationQuery(ctx sdk.Context, appMappingId uint64) (bool, string) {
found := uint64InSlice(appMappingId, k.GetAppIds(ctx).WhitelistedAppMappingIds)
if !found {
return false, types.ErrAppIDDoesNotExists.Error()
Expand Down
2 changes: 1 addition & 1 deletion x/liquidation/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ types.MsgServer = msgServer{}
func (m msgServer) WhitelistApp(goCtx context.Context, id *types.WhitelistAppId) (*types.MsgWhitelistAppIdResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

if err := m.Keeper.WhitelistAppId(ctx, id.AppMappingId); err != nil {
if err := m.Keeper.WhitelistAppID(ctx, id.AppMappingId); err != nil {
return nil, err
}
return &types.MsgWhitelistAppIdResponse{}, nil
Expand Down
1 change: 0 additions & 1 deletion x/liquidation/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {

registry.RegisterImplementations(
(*sdk.Msg)(nil),
&WhitelistAppId{},
Expand Down
2 changes: 1 addition & 1 deletion x/liquidation/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package types

import sdk "github.com/cosmos/cosmos-sdk/types"

func NewMsgWhitelistAppId(appMappingId uint64, from sdk.AccAddress) *WhitelistAppId {
func NewMsgWhitelistAppID(appMappingId uint64, from sdk.AccAddress) *WhitelistAppId {
return &WhitelistAppId{
AppMappingId: appMappingId,
From: from.String(),
Expand Down