This commit is contained in:
0xmuralik
2022-10-17 12:45:01 +05:30
parent a4f2cb5731
commit 74ed0f7e0f
18 changed files with 193 additions and 192 deletions
+4 -1
View File
@@ -134,7 +134,10 @@ func GetCmdCommitBid() *cobra.Command {
}
// Save reveal file.
ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
err = ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
if err != nil {
return err
}
msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress())
err = msg.ValidateBasic()
+1 -1
View File
@@ -32,7 +32,7 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
return &IntegrationTestSuite{cfg: cfg}
}
func (s *IntegrationTestSuite) SetupSuite() {
func (s *IntegrationTestSuite) SetupSuite() { //nolint: all
s.T().Log("setting up integration test suite")
var err error
+1 -1
View File
@@ -274,7 +274,7 @@ func (suite *IntegrationTestSuite) TestGetCmdAuctionsByBidder() {
}
}
func (suite IntegrationTestSuite) createAuctionAndBid(createAuction, createBid bool) string {
func (suite *IntegrationTestSuite) createAuctionAndBid(createAuction, createBid bool) string {
val := suite.network.Validators[0]
sr := suite.Require()
auctionID := ""
+1 -1
View File
@@ -27,7 +27,7 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
params := keeper.GetParams(ctx)
auctions := keeper.ListAuctions(ctx)
var genesisAuctions []*types.Auction
genesisAuctions := []*types.Auction{}
for _, auction := range auctions {
genesisAuctions = append(genesisAuctions, &auction)
}
+9 -8
View File
@@ -99,7 +99,7 @@ func GetBidIndexKey(auctionID string, bidder string) []byte {
}
func GetAuctionBidsIndexPrefix(auctionID string) []byte {
return append(append(PrefixAuctionBidsIndex, []byte(auctionID)...))
return append(PrefixAuctionBidsIndex, []byte(auctionID)...)
}
// SaveAuction - saves a auction to the store.
@@ -226,7 +226,7 @@ func (k Keeper) ListAuctions(ctx sdk.Context) []types.Auction {
func (k Keeper) QueryAuctionsByOwner(ctx sdk.Context, ownerAddress string) []types.Auction {
auctions := []types.Auction{}
ownerPrefix := append(prefixOwnerToAuctionsIndex, []byte(ownerAddress)...)
ownerPrefix := append(prefixOwnerToAuctionsIndex, []byte(ownerAddress)...) //nolint: all
store := ctx.KVStore(k.storeKey)
itr := sdk.KVStorePrefixIterator(store, ownerPrefix)
defer itr.Close()
@@ -247,9 +247,9 @@ func (k Keeper) QueryAuctionsByOwner(ctx sdk.Context, ownerAddress string) []typ
func (k Keeper) QueryAuctionsByBidder(ctx sdk.Context, bidderAddress string) []types.Auction {
auctions := []types.Auction{}
bidderPrefix := append(PrefixBidderToAuctionsIndex, []byte(bidderAddress)...)
bidderPrefix := append(PrefixBidderToAuctionsIndex, []byte(bidderAddress)...) //nolint: all
store := ctx.KVStore(k.storeKey)
itr := sdk.KVStorePrefixIterator(store, []byte(bidderPrefix))
itr := sdk.KVStorePrefixIterator(store, bidderPrefix)
defer itr.Close()
for ; itr.Valid(); itr.Next() {
auctionID := itr.Key()[len(bidderPrefix):]
@@ -312,8 +312,8 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg types.MsgCreateAuction) (*typ
// Compute timestamps.
now := ctx.BlockTime()
commitsEndTime := now.Add(time.Duration(msg.CommitsDuration))
revealsEndTime := now.Add(time.Duration(msg.CommitsDuration + msg.RevealsDuration))
commitsEndTime := now.Add(msg.CommitsDuration)
revealsEndTime := now.Add(msg.CommitsDuration + msg.RevealsDuration)
auction := types.Auction{
Id: auctionID,
@@ -382,7 +382,7 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid,
return &bid, nil
}
// RevealBid reeals a bid comitted earlier.
// RevealBid reeals a bid committed earlier.
func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Auction, error) {
if !k.HasAuction(ctx, msg.AuctionId) {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.")
@@ -553,6 +553,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
continue
}
//nolint: all
if highestBid.BidAmount.IsLT(bid.BidAmount) {
ctx.Logger().Info(fmt.Sprintf("New highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
@@ -637,7 +638,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
// Burn anything over the min. bid amount.
amountToBurn := auction.WinningPrice.Sub(auction.MinimumBid)
if amountToBurn.IsNegative() {
ctx.Logger().Error(fmt.Sprintf("Auction coins to burn cannot be negative."))
ctx.Logger().Error("Auction coins to burn cannot be negative.")
panic("Auction coins to burn cannot be negative.")
}
+1 -1
View File
@@ -56,7 +56,7 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEnc
if err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}
// Once json successfully marshalled, passes along to genesis.go
// Once json successfully marshaled, passes along to genesis.go
return ValidateGenesis(data)
}