From c9f73980ae9d580ad19b873c32eb42c7e57dc71b Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Wed, 7 Sep 2022 23:06:28 +0000 Subject: [PATCH] only allow certain denoms for auctions --- config.yml | 6 +++--- x/colinearcore/auctionconfig/config.go | 4 ++++ x/colinearcore/keeper/msg_server_new_auction.go | 9 +++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config.yml b/config.yml index ce38105..779a5e3 100644 --- a/config.yml +++ b/config.yml @@ -28,9 +28,9 @@ genesis: accounts: - name: alice - coins: ["20000usdc", "200000000000uclr"] + coins: ["20000000000uusdc", "200000000000uclr"] - name: bob - coins: ["10000usdc", "100000000000uclr"] + coins: ["10000000000uusdc", "100000000000uclr"] validator: name: alice staked: "100000000uclr" @@ -41,4 +41,4 @@ client: # path: "vue/src/store" faucet: name: bob - coins: ["500usdc", "100000000uclr"] + coins: ["500uusdc", "100000000uclr"] diff --git a/x/colinearcore/auctionconfig/config.go b/x/colinearcore/auctionconfig/config.go index c394daa..8439070 100644 --- a/x/colinearcore/auctionconfig/config.go +++ b/x/colinearcore/auctionconfig/config.go @@ -1,5 +1,9 @@ package auctionconfig +// Allowed Denoms +// note: as a slice, values can't be immutable, but length can be +var AllowedAuctionDenoms = [...]string{"uusdc", "uclr"} + const ( // Times AuctionTime = 10 // 10 blocks = ~10-30 seconds diff --git a/x/colinearcore/keeper/msg_server_new_auction.go b/x/colinearcore/keeper/msg_server_new_auction.go index 98dd835..1fb01f4 100644 --- a/x/colinearcore/keeper/msg_server_new_auction.go +++ b/x/colinearcore/keeper/msg_server_new_auction.go @@ -24,6 +24,15 @@ func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) ( auctionLen := msg.LeaseEnd - uint64(ctx.BlockTime().Unix()) + // check that submitted denom is allowed + for _, denom := range auctionconfig.AllowedAuctionDenoms { + if msg.Denom == denom { + goto found + } + } + return nil, fmt.Errorf("denom %s is not allowed; must be in %v", msg.Denom, auctionconfig.AllowedAuctionDenoms) +found: + if auctionLen < auctionconfig.MinLeasePeriod { return nil, fmt.Errorf( "Auction length %d is below min lease period of %d",