diff --git a/app/app.go b/app/app.go index 015349c..402e111 100644 --- a/app/app.go +++ b/app/app.go @@ -71,14 +71,16 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/ibc-go/v3/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v3/modules/core" - ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client" - ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + + icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v4/modules/core" + ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" + ibcporttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" "github.com/spf13/cast" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" @@ -201,6 +203,7 @@ type App struct { UpgradeKeeper upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCICAHostKeeper icahostkeeper.Keeper EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper @@ -208,8 +211,10 @@ type App struct { // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ONFTKeeper onftkeeper.Keeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + // OmniFlix Native modules + ONFTKeeper onftkeeper.Keeper MarketplaceKeeper marketplacemodulekeeper.Keeper // the module manager diff --git a/config.yml b/config.yml deleted file mode 100644 index 67942a5..0000000 --- a/config.yml +++ /dev/null @@ -1,11 +0,0 @@ -accounts: - - name: alice - coins: ["20000token", "200000000stake"] - - name: bob - coins: ["10000token", "100000000stake"] -validator: - name: alice - staked: "100000000stake" -faucet: - name: bob - coins: ["5token", "100000stake"] diff --git a/go.mod b/go.mod index 93226b9..dc8d039 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/OmniFlix/marketplace go 1.19 require ( - github.com/OmniFlix/onft v0.5.0-alpha.2 - github.com/cosmos/cosmos-sdk v0.45.15 - github.com/cosmos/ibc-go/v3 v3.4.0 + github.com/OmniFlix/onft v0.6.0-alpha.1 + github.com/cosmos/cosmos-sdk v0.45.16 + github.com/cosmos/ibc-go/v4 v4.4.2 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 github.com/google/uuid v1.3.0 @@ -14,7 +14,7 @@ require ( github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 - github.com/tendermint/tendermint v0.34.27 + github.com/tendermint/tendermint v0.34.28 github.com/tendermint/tm-db v0.6.7 golang.org/x/exp v0.0.0-20221019170559-20944726eadf google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa @@ -29,7 +29,7 @@ require ( filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect + github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/DataDog/zstd v1.5.0 // indirect github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect @@ -144,6 +144,6 @@ replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 // use cometbft - github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27 + github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index 31f1b42..eb91c95 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= +github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= @@ -76,8 +76,8 @@ github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4K github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= -github.com/OmniFlix/onft v0.5.0-alpha.2 h1:pp0HTYkvgbgdqcoCH48rHp//+IU2hOTjbx0h9avkWPQ= -github.com/OmniFlix/onft v0.5.0-alpha.2/go.mod h1:ZvNsefiGp3bqn5fwS2J/AkZdDmwgwg0yukaVDFo1KoE= +github.com/OmniFlix/onft v0.6.0-alpha.1 h1:3FXGd2BcZMg0GhhMLm4Q6MqNG8KYHsof2no/kDcMq7w= +github.com/OmniFlix/onft v0.6.0-alpha.1/go.mod h1:RW0ooCgUtutpMElh38kbYf3Qb05BmDKK18jCRImwinI= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= @@ -203,8 +203,8 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcju github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= -github.com/cometbft/cometbft v0.34.27 h1:ri6BvmwjWR0gurYjywcBqRe4bbwc3QVs9KRcCzgh/J0= -github.com/cometbft/cometbft v0.34.27/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw= +github.com/cometbft/cometbft v0.34.28 h1:gwryf55P1SWMUP4nOXpRVI2D0yPoYEzN+IBqmRBOsDc= +github.com/cometbft/cometbft v0.34.28/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= @@ -226,8 +226,8 @@ github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 h1:zlCp9n3uwQieEL github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32/go.mod h1:kwMlEC4wWvB48zAShGKVqboJL6w4zCLesaNQ3YLU2BQ= github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbShIocllGaXx/0= github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE= -github.com/cosmos/cosmos-sdk v0.45.15 h1:yyLZ9PylnR1DADf9FYGxnn8t3+Y5K2mMUXNUN38MI5A= -github.com/cosmos/cosmos-sdk v0.45.15/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/cosmos/cosmos-sdk v0.45.16 h1:5ba/Bh5/LE55IwHQuCU4fiG4eXeDKtSWzehXRpaKDcw= +github.com/cosmos/cosmos-sdk v0.45.16/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -235,8 +235,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-go/v3 v3.4.0 h1:ha3cqEG36pqMWqA1D+kxDWBTZXpeFMd/aZIQF7I0xro= -github.com/cosmos/ibc-go/v3 v3.4.0/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= +github.com/cosmos/ibc-go/v4 v4.4.2 h1:PG4Yy0/bw6Hvmha3RZbc53KYzaCwuB07Ot4GLyzcBvo= +github.com/cosmos/ibc-go/v4 v4.4.2/go.mod h1:j/kD2JCIaV5ozvJvaEkWhLxM2zva7/KTM++EtKFYcB8= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= diff --git a/proto/marketplace/v1beta1/params.proto b/proto/marketplace/v1beta1/params.proto index 3beaa95..6c60ecf 100644 --- a/proto/marketplace/v1beta1/params.proto +++ b/proto/marketplace/v1beta1/params.proto @@ -21,6 +21,11 @@ message Params { (gogoproto.stdduration) = true, (gogoproto.nullable) = false ]; + google.protobuf.Duration max_auction_duration = 4 [ + (gogoproto.moretags) = "yaml:\"max_auction_duration\"", + (gogoproto.stdduration) = true, + (gogoproto.nullable) = false + ]; } message Distribution { diff --git a/x/marketplace/keeper/auction.go b/x/marketplace/keeper/auction.go index 66f6129..e67e5ca 100644 --- a/x/marketplace/keeper/auction.go +++ b/x/marketplace/keeper/auction.go @@ -219,30 +219,43 @@ func (k Keeper) UpdateAuctionStatusesAndProcessBids(ctx sdk.Context) error { for ; iterator.Valid(); iterator.Next() { var auction types.AuctionListing k.cdc.MustUnmarshal(iterator.Value(), &auction) + + // if auction is active if auction.StartTime.Before(ctx.BlockTime()) { + + durationFromStartTime := ctx.BlockTime().Sub(auction.StartTime) + bidCloseDuration := k.GetBidCloseDuration(ctx) bid, found := k.GetBid(ctx, auction.GetId()) - if !found && auction.EndTime != nil && auction.EndTime.Before(ctx.BlockTime()) { - err := k.nftKeeper.TransferOwnership(ctx, auction.GetDenomId(), auction.GetNftId(), - k.accountKeeper.GetModuleAddress(types.ModuleName), auction.GetOwner()) - if err != nil { - return err - } - k.RemoveAuctionListing(ctx, auction.GetId()) - k.removeAuctionEvent(ctx, auction) - } else if !found && auction.EndTime == nil && - ctx.BlockTime().Sub(auction.StartTime).Seconds() > k.GetBidCloseDuration(ctx).Seconds() { - err := k.nftKeeper.TransferOwnership(ctx, auction.GetDenomId(), auction.GetNftId(), - k.accountKeeper.GetModuleAddress(types.ModuleName), auction.GetOwner()) - if err != nil { - return err - } - k.RemoveAuctionListing(ctx, auction.GetId()) - k.removeAuctionEvent(ctx, auction) - } else if found && ctx.BlockTime().Sub(bid.Time).Seconds() > k.GetBidCloseDuration(ctx).Seconds() { - err := k.processBid(ctx, auction, bid) - if err != nil { - return err + // if auction has ended + if auction.EndTime != nil && auction.EndTime.Before(ctx.BlockTime()) || + auction.EndTime == nil && durationFromStartTime > bidCloseDuration { + + // process bid if found else return NFT to owner + if found { + err := k.processBid(ctx, auction, bid) + if err != nil { + return err + } + // emit events + k.processBidEvent(ctx, auction, bid) + k.RemoveAuctionListing(ctx, auction.GetId()) + k.RemoveBid(ctx, auction.GetId()) + + } else { + err := k.returnNftToOwner( + ctx, + auction.GetDenomId(), + auction.GetNftId(), + k.accountKeeper.GetModuleAddress(types.ModuleName), + auction.GetOwner(), + ) + if err != nil { + return err + } + // emit events + k.RemoveAuctionListing(ctx, auction.GetId()) + k.removeAuctionEvent(ctx, auction) } } } @@ -327,8 +340,13 @@ func (k Keeper) processBid(ctx sdk.Context, auction types.AuctionListing, bid ty return err } } - k.processBidEvent(ctx, auction, bid) - k.RemoveAuctionListing(ctx, auction.GetId()) - k.RemoveBid(ctx, auction.GetId()) return nil } + +func (k Keeper) returnNftToOwner(ctx sdk.Context, denomId, nftId string, moduleAddress, owner sdk.AccAddress) error { + err := k.nftKeeper.TransferOwnership(ctx, denomId, nftId, moduleAddress, owner) + if err != nil { + return err + } + return nil +} \ No newline at end of file diff --git a/x/marketplace/keeper/msg_server.go b/x/marketplace/keeper/msg_server.go index 785258e..3336ca5 100644 --- a/x/marketplace/keeper/msg_server.go +++ b/x/marketplace/keeper/msg_server.go @@ -142,7 +142,7 @@ func (m msgServer) BuyNFT(goCtx context.Context, msg *types.MsgBuyNFT) (*types.M return &types.MsgBuyNFTResponse{}, nil } -// CreateAuction +// CreateAuction creates a new auction func (m msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -154,6 +154,11 @@ func (m msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuct if err := msg.Validate(ctx.BlockTime()); err != nil { return nil, err } + maxAuctionDuration := m.Keeper.GetMaxAuctionDuration(ctx) + if msg.Duration.Seconds() > maxAuctionDuration.Seconds() { + return nil, sdkerrors.Wrapf(types.ErrInvalidDuration, + "duration %s exceeds max auction duration %s", msg.Duration.String(), maxAuctionDuration.String()) + } nft, err := m.nftKeeper.GetONFT(ctx, msg.DenomId, msg.NftId) if err != nil { diff --git a/x/marketplace/keeper/params.go b/x/marketplace/keeper/params.go index 450d737..6ac4d83 100644 --- a/x/marketplace/keeper/params.go +++ b/x/marketplace/keeper/params.go @@ -5,7 +5,6 @@ import ( "github.com/OmniFlix/marketplace/x/marketplace/types" sdk "github.com/cosmos/cosmos-sdk/types" - ) // GetParams gets the parameters for the marketplace module. @@ -36,3 +35,9 @@ func (k Keeper) GetBidCloseDuration(ctx sdk.Context) (duration time.Duration) { k.paramSpace.Get(ctx, types.ParamStoreKeyBidCloseDuration, &duration) return duration } + +// GetMaxAuctionDuration returns the maximum duration for auctions. +func (k Keeper) GetMaxAuctionDuration(ctx sdk.Context) (duration time.Duration) { + k.paramSpace.Get(ctx, types.ParamStoreKeyMaxAuctionDuration, &duration) + return duration +} diff --git a/x/marketplace/types/params.go b/x/marketplace/types/params.go index 5fcffbd..1c7ba1b 100644 --- a/x/marketplace/types/params.go +++ b/x/marketplace/types/params.go @@ -8,16 +8,18 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -// Default period for closing bids for an auction const ( - DefaultBidClosePeriod time.Duration = time.Hour * 12 // 12 Hours + // DefaultBidClosePeriod Default period for closing bids for an auction + DefaultBidClosePeriod time.Duration = time.Hour * 12 // 12 Hours + DefaultMaxAuctionDuration time.Duration = time.Hour * 24 * 90 // 90 Days ) // Parameter keys var ( - ParamStoreKeySaleCommission = []byte("SaleCommission") - ParamStoreKeyDistribution = []byte("MarketplaceDistribution") - ParamStoreKeyBidCloseDuration = []byte("BidCloseDuration") + ParamStoreKeySaleCommission = []byte("SaleCommission") + ParamStoreKeyDistribution = []byte("MarketplaceDistribution") + ParamStoreKeyBidCloseDuration = []byte("BidCloseDuration") + ParamStoreKeyMaxAuctionDuration = []byte("MaxAuctionDuration") ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -27,11 +29,18 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewMarketplaceParams(saleCommission sdk.Dec, distribution Distribution, bidCloseDuration time.Duration) Params { +func NewMarketplaceParams( + saleCommission sdk.Dec, + distribution Distribution, + bidCloseDuration time.Duration, + maxAuctionDuration time.Duration, +) Params { + return Params{ - SaleCommission: saleCommission, - Distribution: distribution, - BidCloseDuration: bidCloseDuration, + SaleCommission: saleCommission, + Distribution: distribution, + BidCloseDuration: bidCloseDuration, + MaxAuctionDuration: maxAuctionDuration, } } @@ -44,6 +53,7 @@ func DefaultParams() Params { CommunityPool: sdk.NewDecWithPrec(50, 2), // 50% }, DefaultBidClosePeriod, + DefaultMaxAuctionDuration, ) } @@ -53,6 +63,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(ParamStoreKeySaleCommission, &p.SaleCommission, validateSaleCommission), paramtypes.NewParamSetPair(ParamStoreKeyDistribution, &p.Distribution, validateMarketplaceDistributionParams), paramtypes.NewParamSetPair(ParamStoreKeyBidCloseDuration, &p.BidCloseDuration, validateBidCloseDuration), + paramtypes.NewParamSetPair(ParamStoreKeyMaxAuctionDuration, &p.MaxAuctionDuration, validateMaxAuctionDuration), } } @@ -67,6 +78,9 @@ func (p Params) ValidateBasic() error { if err := validateBidCloseDuration(p.BidCloseDuration); err != nil { return err } + if err := validateMaxAuctionDuration(p.MaxAuctionDuration); err != nil { + return err + } return nil } @@ -157,3 +171,14 @@ func validateBidCloseDuration(i interface{}) error { return nil } + +func validateMaxAuctionDuration(d interface{}) error { + v, ok := d.(time.Duration) + if !ok { + return fmt.Errorf("invalid parameter type: %T", d) + } + if v.Seconds() <= 0 { + return fmt.Errorf("max auction duration must be positive: %f", v.Seconds()) + } + return nil +} diff --git a/x/marketplace/types/params.pb.go b/x/marketplace/types/params.pb.go index 821a486..453b860 100644 --- a/x/marketplace/types/params.pb.go +++ b/x/marketplace/types/params.pb.go @@ -29,9 +29,10 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { - SaleCommission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=sale_commission,json=saleCommission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"sale_commission" yaml:"sale_commission"` - Distribution Distribution `protobuf:"bytes,2,opt,name=distribution,proto3" json:"distribution"` - BidCloseDuration time.Duration `protobuf:"bytes,3,opt,name=bid_close_duration,json=bidCloseDuration,proto3,stdduration" json:"bid_close_duration" yaml:"bid_close_duration"` + SaleCommission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=sale_commission,json=saleCommission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"sale_commission" yaml:"sale_commission"` + Distribution Distribution `protobuf:"bytes,2,opt,name=distribution,proto3" json:"distribution"` + BidCloseDuration time.Duration `protobuf:"bytes,3,opt,name=bid_close_duration,json=bidCloseDuration,proto3,stdduration" json:"bid_close_duration" yaml:"bid_close_duration"` + MaxAuctionDuration time.Duration `protobuf:"bytes,4,opt,name=max_auction_duration,json=maxAuctionDuration,proto3,stdduration" json:"max_auction_duration" yaml:"max_auction_duration"` } func (m *Params) Reset() { *m = Params{} } @@ -113,34 +114,36 @@ func init() { func init() { proto.RegisterFile("marketplace/v1beta1/params.proto", fileDescriptor_930108a08bf00b01) } var fileDescriptor_930108a08bf00b01 = []byte{ - // 422 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x33, 0x55, 0x2a, 0x1d, 0xeb, 0x2a, 0x41, 0x65, 0x5b, 0x64, 0xb2, 0x04, 0x94, 0x22, - 0x38, 0x43, 0xed, 0xcd, 0x93, 0xa4, 0x8b, 0x7a, 0xb3, 0x06, 0x4f, 0xbd, 0x2c, 0x93, 0x64, 0x8c, - 0xc3, 0xce, 0xe4, 0x8d, 0x99, 0x89, 0xb8, 0xdf, 0xc2, 0xa3, 0x5f, 0xc7, 0xdb, 0x1e, 0x7b, 0x94, - 0x1e, 0xa2, 0xee, 0x7e, 0x83, 0x7e, 0x02, 0xc9, 0xbf, 0x92, 0x55, 0x10, 0xf6, 0x94, 0xcc, 0x9b, - 0xf7, 0x7d, 0x9e, 0xe7, 0xfd, 0x65, 0xf0, 0x44, 0xf3, 0x62, 0x2e, 0x6c, 0xae, 0x78, 0x2c, 0xd8, - 0xe7, 0xe3, 0x48, 0x58, 0x7e, 0xcc, 0x72, 0x5e, 0x70, 0x6d, 0x68, 0x5e, 0x80, 0x05, 0xf7, 0xd1, - 0x5b, 0x9d, 0xc9, 0x57, 0x4a, 0x7e, 0xa1, 0x83, 0x56, 0xda, 0xb5, 0x1e, 0xde, 0x4f, 0x21, 0x85, - 0xa6, 0x91, 0xd5, 0x6f, 0xed, 0xcc, 0x21, 0x49, 0x01, 0x52, 0x25, 0x58, 0x73, 0x8a, 0xca, 0x0f, - 0x2c, 0x29,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47, 0x1d, 0xc1, 0x56, 0xc6, 0x0f, 0x7b, 0x41, 0x37, - 0xc3, 0xa3, 0x9a, 0x68, 0x99, 0x49, 0xbb, 0x98, 0xe5, 0x00, 0xaa, 0x81, 0xb6, 0x17, 0xbc, 0xde, - 0xda, 0xe2, 0x41, 0x6b, 0xb1, 0xa9, 0xe6, 0x87, 0x77, 0xae, 0x0b, 0x67, 0x00, 0x2a, 0x78, 0xb7, - 0xfc, 0x4d, 0x9c, 0xe5, 0x8a, 0xa0, 0x8b, 0x15, 0x41, 0xbf, 0x56, 0x04, 0x7d, 0x5d, 0x13, 0xe7, - 0x62, 0x4d, 0x9c, 0x1f, 0x6b, 0xe2, 0x9c, 0x9f, 0x0c, 0xdc, 0xfa, 0x9f, 0xc6, 0x86, 0x17, 0x79, - 0xf3, 0xd4, 0xd8, 0x47, 0xbb, 0x0d, 0xfb, 0x93, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x52, - 0xa1, 0x98, 0xf2, 0x02, 0x00, 0x00, + // 457 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0x6d, 0x5a, 0x15, 0x75, 0x29, 0x01, 0xad, 0x0a, 0x4a, 0x0b, 0xb2, 0x23, 0x4b, 0x40, + 0x85, 0xc4, 0x5a, 0xa5, 0x37, 0x4e, 0xe0, 0x46, 0xc0, 0x8d, 0x62, 0x71, 0xea, 0xc5, 0x5a, 0xff, + 0xc1, 0xac, 0xe2, 0xf5, 0x18, 0xef, 0x1a, 0x25, 0x6f, 0xc1, 0x91, 0x37, 0xe1, 0x15, 0x72, 0xec, + 0x11, 0xf5, 0x60, 0x20, 0x79, 0x83, 0x3e, 0x01, 0x5a, 0xaf, 0x5d, 0x1c, 0x40, 0x54, 0x39, 0xd9, + 0x33, 0x3b, 0xf3, 0xfd, 0x66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0x6a, 0x6b, 0xac, 0x20, 0x68, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -163,13 +166,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.BidCloseDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidCloseDuration):]) + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAuctionDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration):]) if err1 != nil { return 0, err1 } i -= n1 i = encodeVarintParams(dAtA, i, uint64(n1)) i-- + dAtA[i] = 0x22 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.BidCloseDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidCloseDuration):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintParams(dAtA, i, uint64(n2)) + i-- dAtA[i] = 0x1a { size, err := m.Distribution.MarshalToSizedBuffer(dAtA[:i]) @@ -260,6 +271,8 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidCloseDuration) n += 1 + l + sovParams(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration) + n += 1 + l + sovParams(uint64(l)) return n } @@ -411,6 +424,39 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAuctionDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAuctionDuration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])