Skip to content

Commit

Permalink
refactor(define): making NewAuxiliaryRequest public
Browse files Browse the repository at this point in the history
Signed-off-by: Deepanshu Tripathi <[email protected]>
  • Loading branch information
deepanshutr committed Sep 2, 2024
1 parent 4afe294 commit 3ef86fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 6 additions & 7 deletions x/classifications/auxiliaries/define/auxiliary_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ package define

import (
"context"
"github.com/AssetMantle/modules/helpers"
errorConstants "github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/classifications/constants"
"github.com/AssetMantle/modules/x/classifications/key"
"github.com/AssetMantle/modules/x/classifications/record"
"github.com/AssetMantle/schema/data"
baseData "github.com/AssetMantle/schema/data/base"
"github.com/AssetMantle/schema/documents/base"
Expand All @@ -17,11 +21,6 @@ import (
sdkTypes "github.com/cosmos/cosmos-sdk/types"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/x/classifications/constants"
"github.com/AssetMantle/modules/x/classifications/key"
"github.com/AssetMantle/modules/x/classifications/record"
)

type auxiliaryKeeper struct {
Expand Down Expand Up @@ -78,7 +77,7 @@ func (auxiliaryKeeper auxiliaryKeeper) Help(context context.Context, AuxiliaryRe
classificationID := baseIDs.NewClassificationID(auxiliaryRequest.Immutables, auxiliaryRequest.Mutables)
classifications := auxiliaryKeeper.mapper.NewCollection(context).Fetch(key.NewKey(classificationID))
if classifications.GetMappable(key.NewKey(classificationID)) != nil {
return newAuxiliaryResponse(classificationID), errorConstants.EntityAlreadyExists.Wrapf("classification with ID %s already exists", classificationID.AsString())
return NewAuxiliaryResponse(classificationID), errorConstants.EntityAlreadyExists.Wrapf("classification with ID %s already exists", classificationID.AsString())
}

if err := auxiliaryKeeper.bankKeeper.SendCoinsFromAccountToModule(sdkTypes.UnwrapSDKContext(context), auxiliaryRequest.AccAddress, constants.ModuleName, sdkTypes.NewCoins(sdkTypes.NewCoin(auxiliaryKeeper.stakingKeeper.BondDenom(sdkTypes.UnwrapSDKContext(context)), bondAmount.Get()))); err != nil {
Expand All @@ -93,7 +92,7 @@ func (auxiliaryKeeper auxiliaryKeeper) Help(context context.Context, AuxiliaryRe

classifications.Add(record.NewRecord(classification))

return newAuxiliaryResponse(classificationID), nil
return NewAuxiliaryResponse(classificationID), nil
}

func (auxiliaryKeeper auxiliaryKeeper) Initialize(mapper helpers.Mapper, parameterManager helpers.ParameterManager, auxiliaries []interface{}) helpers.Keeper {
Expand Down
5 changes: 2 additions & 3 deletions x/classifications/auxiliaries/define/auxiliary_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
package define

import (
"github.com/AssetMantle/modules/helpers"
errorConstants "github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/schema/ids"

"github.com/AssetMantle/modules/helpers"
)

type auxiliaryResponse struct {
Expand All @@ -16,7 +15,7 @@ type auxiliaryResponse struct {

var _ helpers.AuxiliaryResponse = (*auxiliaryResponse)(nil)

func newAuxiliaryResponse(classificationID ids.ClassificationID) helpers.AuxiliaryResponse {
func NewAuxiliaryResponse(classificationID ids.ClassificationID) helpers.AuxiliaryResponse {
return auxiliaryResponse{
ClassificationID: classificationID,
}
Expand Down

0 comments on commit 3ef86fa

Please sign in to comment.