Skip to content

Commit

Permalink
Merge pull request #266 from comdex-official/refactor-code
Browse files Browse the repository at this point in the history
refactor and modify asset module
  • Loading branch information
dheerajkd30 authored Jun 21, 2022
2 parents 4650b79 + 7d8cab3 commit 6e451ed
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 224 deletions.
9 changes: 4 additions & 5 deletions app/wasm/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func (m *CustomMessenger) AddExtendedPairsVault(ctx sdk.Context, contractAddr sd
}

func MsgAddExtendedPairsVault(assetKeeper assetkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress,
a *bindings.MsgAddExtendedPairsVault) error {
err := assetKeeper.WasmAddExtendedPairsVaultRecords(ctx, a.AppMappingId, a.PairId, a.LiquidationRatio, a.StabilityFee, a.ClosingFee, a.LiquidationPenalty, a.DrawDownFee, a.IsVaultActive, a.DebtCeiling, a.DebtFloor, a.IsPsmPair, a.MinCr, a.PairName, a.AssetOutOraclePrice, a.AssetOutPrice, a.MinUsdValueLeft)
pairVaultBinding *bindings.MsgAddExtendedPairsVault) error {
err := assetKeeper.WasmAddExtendedPairsVaultRecords(ctx, pairVaultBinding)
if err != nil {
return err
}
Expand Down Expand Up @@ -241,9 +241,8 @@ func (m *CustomMessenger) UpdateLsrInPairsVault(ctx sdk.Context, contractAddr sd
}

func MsgUpdateLsrInPairsVault(assetKeeper assetkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress,
a *bindings.MsgUpdateLsrInPairsVault) error {
err := assetKeeper.WasmUpdateLsrInPairsVault(ctx, a.AppMappingId, a.ExtPairId, a.LiquidationRatio, a.StabilityFee, a.ClosingFee,
a.LiquidationPenalty, a.DrawDownFee, a.MinCr, a.DebtCeiling, a.DebtFloor, a.MinUsdValueLeft)
updateLsrPairVault *bindings.MsgUpdateLsrInPairsVault) error {
err := assetKeeper.WasmUpdateLsrInPairsVault(ctx, updateLsrPairVault)
if err != nil {
return err
}
Expand Down
54 changes: 27 additions & 27 deletions app/wasm/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ func NewQueryPlugin(
}
}

func (qp QueryPlugin) GetAppInfo(ctx sdk.Context, appMappingId uint64) (int64, int64, uint64, error) {
MinGovDeposit, GovTimeInSeconds, AssetId, err := qp.assetKeeper.GetAppWasmQuery(ctx, appMappingId)
func (qp QueryPlugin) GetAppInfo(ctx sdk.Context, appMappingID uint64) (int64, int64, uint64, error) {
MinGovDeposit, GovTimeInSeconds, AssetID, err := qp.assetKeeper.GetAppWasmQuery(ctx, appMappingID)
if err != nil {
return MinGovDeposit, GovTimeInSeconds, AssetId, nil
return MinGovDeposit, GovTimeInSeconds, AssetID, nil
}
return MinGovDeposit, GovTimeInSeconds, AssetId, nil
return MinGovDeposit, GovTimeInSeconds, AssetID, nil
}

func (qp QueryPlugin) GetAssetInfo(ctx sdk.Context, Id uint64) (string, error) {
assetDenom := qp.assetKeeper.GetAssetDenom(ctx, Id)
func (qp QueryPlugin) GetAssetInfo(ctx sdk.Context, ID uint64) (string, error) {
assetDenom := qp.assetKeeper.GetAssetDenom(ctx, ID)
return assetDenom, nil
}

func (qp QueryPlugin) GetTokenMint(ctx sdk.Context, appMappingId, assetId uint64) (int64, error) {
tokenData, err := qp.tokenMintKeeper.GetAssetDataInTokenMintByAppSupply(ctx, appMappingId, assetId)
if err != true {
func (qp QueryPlugin) GetTokenMint(ctx sdk.Context, appMappingID, assetID uint64) (int64, error) {
tokenData, found := qp.tokenMintKeeper.GetAssetDataInTokenMintByAppSupply(ctx, appMappingID, assetID)
if !found {
return tokenData, nil
}
return tokenData, nil
Expand All @@ -75,43 +75,43 @@ func (qp QueryPlugin) GetWhitelistAppIdLockerRewardsCheck(ctx sdk.Context, appMa
return found, err
}

func (qp QueryPlugin) GetExternalLockerRewardsCheck(ctx sdk.Context, appMappingId, assetId uint64) (found bool, err string) {
found, err = qp.rewardsKeeper.GetExternalLockerRewardsCheck(ctx, appMappingId, assetId)
func (qp QueryPlugin) GetExternalLockerRewardsCheck(ctx sdk.Context, appMappingID, assetID uint64) (found bool, err string) {
found, err = qp.rewardsKeeper.GetExternalLockerRewardsCheck(ctx, appMappingID, assetID)
return found, err
}

func (qp QueryPlugin) GetExternalVaultRewardsCheck(ctx sdk.Context, appMappingId, assetId uint64) (found bool, err string) {
found, err = qp.rewardsKeeper.GetExternalVaultRewardsCheck(ctx, appMappingId, assetId)
func (qp QueryPlugin) GetExternalVaultRewardsCheck(ctx sdk.Context, appMappingID, assetID uint64) (found bool, err string) {
found, err = qp.rewardsKeeper.GetExternalVaultRewardsCheck(ctx, appMappingID, assetID)
return found, err
}

func (qp QueryPlugin) CollectorLookupTableQueryCheck(ctx sdk.Context, AppMappingId, CollectorAssetId, SecondaryAssetId uint64) (found bool, err string) {
found, err = qp.collectorKeeper.WasmSetCollectorLookupTableQuery(ctx, AppMappingId, CollectorAssetId, SecondaryAssetId)
func (qp QueryPlugin) CollectorLookupTableQueryCheck(ctx sdk.Context, appMappingID, collectorAssetID, secondaryAssetID uint64) (found bool, err string) {
found, err = qp.collectorKeeper.WasmSetCollectorLookupTableQuery(ctx, appMappingID, collectorAssetID, secondaryAssetID)
return found, err
}

func (qp QueryPlugin) ExtendedPairsVaultRecordsQueryCheck(ctx sdk.Context, AppMappingId, PairId uint64, StabilityFee, ClosingFee, DrawDownFee sdk.Dec, DebtCeiling, DebtFloor uint64, PairName string) (found bool, err string) {
found, err = qp.assetKeeper.WasmAddExtendedPairsVaultRecordsQuery(ctx, AppMappingId, PairId, StabilityFee, ClosingFee, DrawDownFee, DebtCeiling, DebtFloor, PairName)
func (qp QueryPlugin) ExtendedPairsVaultRecordsQueryCheck(ctx sdk.Context, appMappingID, pairID uint64, StabilityFee, ClosingFee, DrawDownFee sdk.Dec, DebtCeiling, DebtFloor uint64, PairName string) (found bool, err string) {
found, err = qp.assetKeeper.WasmAddExtendedPairsVaultRecordsQuery(ctx, appMappingID, pairID, StabilityFee, ClosingFee, DrawDownFee, DebtCeiling, DebtFloor, PairName)
return found, err
}

func (qp QueryPlugin) AuctionMappingForAppQueryCheck(ctx sdk.Context, AppMappingId uint64) (found bool, err string) {
found, err = qp.collectorKeeper.WasmSetAuctionMappingForAppQuery(ctx, AppMappingId)
func (qp QueryPlugin) AuctionMappingForAppQueryCheck(ctx sdk.Context, appMappingID uint64) (found bool, err string) {
found, err = qp.collectorKeeper.WasmSetAuctionMappingForAppQuery(ctx, appMappingID)
return found, err
}

func (qp QueryPlugin) WhiteListedAssetQueryCheck(ctx sdk.Context, AppMappingId, AssetId uint64) (found bool, err string) {
found, err = qp.lockerKeeper.WasmAddWhiteListedAssetQuery(ctx, AppMappingId, AssetId)
func (qp QueryPlugin) WhiteListedAssetQueryCheck(ctx sdk.Context, appMappingID, assetID uint64) (found bool, err string) {
found, err = qp.lockerKeeper.WasmAddWhiteListedAssetQuery(ctx, appMappingID, assetID)
return found, err
}

func (qp QueryPlugin) UpdateLsrInPairsVaultQueryCheck(ctx sdk.Context, AppMappingId, ExtPairId uint64) (found bool, err string) {
found, err = qp.assetKeeper.WasmUpdateLsrInPairsVaultQuery(ctx, AppMappingId, ExtPairId)
func (qp QueryPlugin) UpdateLsrInPairsVaultQueryCheck(ctx sdk.Context, appMappingID, extPairID uint64) (found bool, err string) {
found, err = qp.assetKeeper.WasmUpdateLsrInPairsVaultQuery(ctx, appMappingID, extPairID)
return found, err
}

func (qp QueryPlugin) UpdateLsrInCollectorLookupTableQueryCheck(ctx sdk.Context, AppMappingId, AssetId uint64) (found bool, err string) {
found, err = qp.collectorKeeper.WasmUpdateLsrInCollectorLookupTableQuery(ctx, AppMappingId, AssetId)
func (qp QueryPlugin) UpdateLsrInCollectorLookupTableQueryCheck(ctx sdk.Context, appMappingID, AssetId uint64) (found bool, err string) {
found, err = qp.collectorKeeper.WasmUpdateLsrInCollectorLookupTableQuery(ctx, appMappingID, AssetId)
return found, err
}

Expand All @@ -120,8 +120,8 @@ func (qp QueryPlugin) WasmRemoveWhitelistAppIdVaultInterestQueryCheck(ctx sdk.Co
return found, err
}

func (qp QueryPlugin) WasmRemoveWhitelistAssetLockerQueryCheck(ctx sdk.Context, AppMappingId, AssetId uint64) (found bool, err string) {
found, err = qp.rewardsKeeper.WasmRemoveWhitelistAssetLockerQuery(ctx, AppMappingId, AssetId)
func (qp QueryPlugin) WasmRemoveWhitelistAssetLockerQueryCheck(ctx sdk.Context, appMappingID, AssetId uint64) (found bool, err string) {
found, err = qp.rewardsKeeper.WasmRemoveWhitelistAssetLockerQuery(ctx, appMappingID, AssetId)
return found, err
}

Expand Down
Loading

0 comments on commit 6e451ed

Please sign in to comment.