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

collector check added #217

Merged
merged 1 commit into from
Jun 9, 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
1 change: 1 addition & 0 deletions x/collector/expected/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ type AssetKeeper interface {
GetAssetForDenom(ctx sdk.Context, denom string) (types.Asset, bool)
GetApp(ctx sdk.Context, id uint64) (types.AppMapping, bool)
GetAsset(ctx sdk.Context, id uint64) (types.Asset, bool)
GetMintGenesisTokenData(ctx sdk.Context, appId, assetId uint64) (mintData types.MintGenesisToken, found bool)
}
4 changes: 4 additions & 0 deletions x/collector/keeper/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ func (k *Keeper) SendCoinFromModuleToModule(ctx sdk.Context, senderModule, recip
}
return k.bank.SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, coin)
}

func (k *Keeper) GetMintGenesisTokenData(ctx sdk.Context, appId, assetId uint64) (mintData types.MintGenesisToken, found bool) {
return k.asset.GetMintGenesisTokenData(ctx,appId, assetId)
}
4 changes: 4 additions & 0 deletions x/collector/keeper/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func (k *Keeper) SetCollectorLookupTable(ctx sdk.Context, records ...types.Colle
if msg.CollectorAssetId == msg.SecondaryAssetId {
return types.ErrorDuplicateAssetDenoms
}
_, found := k.GetMintGenesisTokenData(ctx,msg.AppId,msg.SecondaryAssetId)
if !found {
return types.ErrorAssetNotAddedForGenesisMinting
}
appDenom, found := k.GetAppToDenomsMapping(ctx, msg.AppId)
if found {
//check if assetdenom already exists
Expand Down
4 changes: 2 additions & 2 deletions x/collector/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (q *queryServer) QueryCollectorLookupByProduct(c context.Context, req *type

collectorLookupData, found := q.GetCollectorLookupTable(ctx, req.AppId)
if !found {
return nil, status.Errorf(codes.NotFound, "Lookup table does not exist for product id %d", req.AppId)
return &types.QueryCollectorLookupByProductResponse{}, nil
}

return &types.QueryCollectorLookupByProductResponse{
Expand All @@ -59,7 +59,7 @@ func (q *queryServer) QueryCollectorLookupByProductAndAsset(c context.Context, r

collectorLookupData, found := q.GetCollectorLookupByAsset(ctx, req.AppId, req.AssetId)
if !found {
return nil, status.Errorf(codes.NotFound, "Lookup table does not exist for product id %d", req.AppId)
return &types.QueryCollectorLookupByProductAndAssetResponse{}, nil
}

return &types.QueryCollectorLookupByProductAndAssetResponse{
Expand Down
13 changes: 0 additions & 13 deletions x/collector/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"github.com/comdex-official/comdex/x/collector/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type msgServer struct {
Expand All @@ -17,16 +16,4 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {

var _ types.MsgServer = msgServer{}

func (k *msgServer) TriggerAuction(ctx sdk.Context, appid uint64) {

_, _ = k.GetAppidToAssetCollectorMapping(ctx, appid)
_, _ = k.GetCollectorLookupTable(ctx, appid)
// k.AppIdToAuctionLookupTable

// check for app_id in both get calls
// match asset id's in both
// check if net > surplus threshold + lot_size -> surplus auction
// check if net < debt threshold - lot_size -> debt auction
// update historical data

}
1 change: 1 addition & 0 deletions x/collector/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ var (
ErrorDataDoesNotExists = sdkerrors.Register(ModuleName, 406, "Data does not exists")
ErrorRequestedAmtExceedsCollectedFee = sdkerrors.Register(ModuleName, 407, "Requested Amt Exceeds CollectedFee")
ErrorAppDoesNotExist = sdkerrors.Register(ModuleName, 408, "app does not exist")
ErrorAssetNotAddedForGenesisMinting = sdkerrors.Register(ModuleName, 409, "Asset Not Added For Genesis Minting")
)