only allow certain denoms for auctions

master
michael 2022-09-07 23:06:28 +00:00
parent 627308d809
commit c9f73980ae
3 changed files with 16 additions and 3 deletions

View File

@ -28,9 +28,9 @@ genesis:
accounts: accounts:
- name: alice - name: alice
coins: ["20000usdc", "200000000000uclr"] coins: ["20000000000uusdc", "200000000000uclr"]
- name: bob - name: bob
coins: ["10000usdc", "100000000000uclr"] coins: ["10000000000uusdc", "100000000000uclr"]
validator: validator:
name: alice name: alice
staked: "100000000uclr" staked: "100000000uclr"
@ -41,4 +41,4 @@ client:
# path: "vue/src/store" # path: "vue/src/store"
faucet: faucet:
name: bob name: bob
coins: ["500usdc", "100000000uclr"] coins: ["500uusdc", "100000000uclr"]

View File

@ -1,5 +1,9 @@
package auctionconfig package auctionconfig
// Allowed Denoms
// note: as a slice, values can't be immutable, but length can be
var AllowedAuctionDenoms = [...]string{"uusdc", "uclr"}
const ( const (
// Times // Times
AuctionTime = 10 // 10 blocks = ~10-30 seconds AuctionTime = 10 // 10 blocks = ~10-30 seconds

View File

@ -24,6 +24,15 @@ func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) (
auctionLen := msg.LeaseEnd - uint64(ctx.BlockTime().Unix()) 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 { if auctionLen < auctionconfig.MinLeasePeriod {
return nil, fmt.Errorf( return nil, fmt.Errorf(
"Auction length %d is below min lease period of %d", "Auction length %d is below min lease period of %d",