diff --git a/app/app.go b/app/app.go index 24f6e4e..0c8460a 100644 --- a/app/app.go +++ b/app/app.go @@ -170,6 +170,8 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + // auction module will only need escrow perms, not minting or burning + cosmostestmoduletypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } ) diff --git a/x/cosmostest/auctionconfig/config.go b/x/cosmostest/auctionconfig/config.go index ee5a4c3..8687150 100644 --- a/x/cosmostest/auctionconfig/config.go +++ b/x/cosmostest/auctionconfig/config.go @@ -2,4 +2,10 @@ package auctionconfig // Length of the auction in blocks-- currently 10. // Assuming a block time of 3sec, this should be ~30sec. -const AuctionTime = 100 +const ( + // Times + AuctionTime = 10 + + // Gas Fees + AuctionGas = 10 +) diff --git a/x/cosmostest/keeper/auction_state.go b/x/cosmostest/keeper/auction_state.go index 5748863..d36859d 100644 --- a/x/cosmostest/keeper/auction_state.go +++ b/x/cosmostest/keeper/auction_state.go @@ -3,15 +3,16 @@ package keeper import ( "cosmos-test/x/cosmostest/math" "cosmos-test/x/cosmostest/memdb" + "cosmos-test/x/cosmostest/types" + "log" "math/big" "time" - "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/pkg/errors" ) -func (k *Keeper) AuctionIsExpired(ctx types.Context, auctionId string) (bool, error) { +func (k *Keeper) AuctionIsExpired(ctx sdk.Context, auctionId string) (bool, error) { auction, found := k.GetAuction(ctx, auctionId) // make sure the auction exists on-chain @@ -22,7 +23,7 @@ func (k *Keeper) AuctionIsExpired(ctx types.Context, auctionId string) (bool, er return uint64(ctx.BlockHeight()) >= auction.Deadline, nil } -func (k *Keeper) FinalizeExpiredAuctions(ctx types.Context) { +func (k *Keeper) FinalizeExpiredAuctions(ctx sdk.Context) { memdb.BidDB.ForEachAuction(func(auctionId string) error { auction, found := k.GetAuction(ctx, auctionId) // make sure the auction exists on-chain @@ -56,7 +57,9 @@ func (k *Keeper) FinalizeExpiredAuctions(ctx types.Context) { Amount: sdk.NewIntFromBigInt(amtRemaining), Denom: auction.Denom, }) - k.bank.SendCoinsFromModuleToAccount(ctx, "cosmostest", sdk.AccAddress(auction.Owner), coins) + if err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sdk.AccAddress(auction.Owner), coins); err != nil { + log.Printf("Failed to send coins from module: %s\n", err) + } } // end auction @@ -67,7 +70,7 @@ func (k *Keeper) FinalizeExpiredAuctions(ctx types.Context) { }) } -func (k *Keeper) PayAuctionAmountDue(ctx types.Context, auctionId string) error { +func (k *Keeper) PayAuctionAmountDue(ctx sdk.Context, auctionId string) error { auction, found := k.GetAuction(ctx, auctionId) if !found { return errors.Errorf("auction %s not found", auctionId) diff --git a/x/cosmostest/keeper/msg_server_new_auction.go b/x/cosmostest/keeper/msg_server_new_auction.go index 23b86f9..15f6487 100644 --- a/x/cosmostest/keeper/msg_server_new_auction.go +++ b/x/cosmostest/keeper/msg_server_new_auction.go @@ -51,11 +51,11 @@ func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) ( } coins := sdk.NewCoins(sdk.Coin{ - Amount: spendable.AmountOf(auction.Ceiling), + Amount: sdk.NewIntFromBigInt(ceiling), Denom: auction.Denom, }) - if err := k.bank.SendCoinsFromAccountToModule(ctx, senderAddr, "cosmostest", coins); err != nil { + if err := k.bank.SendCoinsFromAccountToModule(ctx, senderAddr, types.ModuleName, coins); err != nil { return nil, fmt.Errorf("failed to transfer %s%s", auction.Ceiling, auction.Denom) }