-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/go_modules/google.golang.org/prot…
…obuf-1.34.1
- Loading branch information
Showing
13 changed files
with
598 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
package auction | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// DefaultGenesis creates a default genesis state | ||
func DefaultGenesis() *GenesisState { | ||
// TODO | ||
return &GenesisState{} | ||
return &GenesisState{ | ||
RewardsParams: RewardsParams{BidDuration: 14 * 24 * 3600}, // 14 days | ||
RewardAuctionId: 0, | ||
RewardsAuctions: []RewardsKV{}, | ||
RewardsBids: []BidKV{}, | ||
} | ||
} | ||
|
||
func (gs *GenesisState) Validate() error { | ||
// TODO | ||
if gs.RewardsParams.BidDuration <= 60 { | ||
return errors.New("RewardsParams.BidDuration must be at least 60s") | ||
} | ||
if gs.RewardsParams.BidDuration >= 180*24*3600 { | ||
return errors.New("RewardsParams.BidDuration must be at most 15552000s = 180days") | ||
} | ||
for _, elem := range gs.RewardsAuctions { | ||
coins := sdk.Coins(elem.Rewards.Rewards) | ||
if err := coins.Validate(); err != nil { | ||
return err | ||
} | ||
if elem.Id > gs.RewardAuctionId { | ||
return fmt.Errorf("rewards_auctions ID must be at most rewards_auction_id") | ||
} | ||
} | ||
for _, elem := range gs.RewardsBids { | ||
if elem.Id > gs.RewardAuctionId { | ||
return fmt.Errorf("rewards_bids ID must be at most rewards_auction_id") | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.