diff --git a/app/app.go b/app/app.go index b7c6813f5..b4099c3db 100644 --- a/app/app.go +++ b/app/app.go @@ -66,6 +66,7 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/mint" mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" @@ -609,7 +610,7 @@ func NewSommelierApp( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), cork.NewAppModule(app.CorkKeeper, appCodec), incentives.NewAppModule(app.IncentivesKeeper, app.DistrKeeper, app.BankKeeper, app.MintKeeper, appCodec), - cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.AuctionKeeper), + cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.AuctionKeeper, app.GetSubspace(cellarfeestypes.ModuleName)), auction.NewAppModule(app.AuctionKeeper, app.BankKeeper, app.AccountKeeper, appCodec), pubsub.NewAppModule(appCodec, app.PubsubKeeper, app.StakingKeeper, app.GravityKeeper), addresses.NewAppModule(appCodec, app.AddressesKeeper), @@ -750,7 +751,7 @@ func NewSommelierApp( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), cork.NewAppModule(app.CorkKeeper, appCodec), incentives.NewAppModule(app.IncentivesKeeper, app.DistrKeeper, app.BankKeeper, app.MintKeeper, appCodec), - cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.AuctionKeeper), + cellarfees.NewAppModule(app.CellarFeesKeeper, appCodec, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.CorkKeeper, app.AuctionKeeper, app.GetSubspace(cellarfeestypes.ModuleName)), auction.NewAppModule(app.AuctionKeeper, app.BankKeeper, app.AccountKeeper, appCodec), pubsub.NewAppModule(appCodec, app.PubsubKeeper, app.StakingKeeper, app.GravityKeeper), addresses.NewAppModule(appCodec, app.AddressesKeeper), @@ -1038,6 +1039,39 @@ func (app *SommelierApp) setupUpgradeStoreLoaders() { } func (app *SommelierApp) setupUpgradeHandlers() { + // Set param key table for params module migration + for _, subspace := range app.ParamsKeeper.GetSubspaces() { + subspace := subspace + found := true + var keyTable paramstypes.KeyTable + switch subspace.Name() { + case authtypes.ModuleName: + keyTable = authtypes.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case banktypes.ModuleName: + keyTable = banktypes.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case stakingtypes.ModuleName: + keyTable = stakingtypes.ParamKeyTable() + case minttypes.ModuleName: + keyTable = minttypes.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case distrtypes.ModuleName: + keyTable = distrtypes.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case slashingtypes.ModuleName: + keyTable = slashingtypes.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case govtypes.ModuleName: + keyTable = govtypesv1.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case crisistypes.ModuleName: + keyTable = crisistypes.ParamKeyTable() //nolint: staticcheck // deprecated but required for upgrade + case ibctransfertypes.ModuleName: + keyTable = ibctransfertypes.ParamKeyTable() + default: + // subspace not handled + found = false + } + if found && !subspace.HasKeyTable() { + subspace.WithKeyTable(keyTable) + } + } + baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) // TODO: Add v8 upgrade handle @@ -1048,6 +1082,10 @@ func (app *SommelierApp) setupUpgradeHandlers() { app.configurator, &baseAppLegacySS, &app.ConsensusParamsKeeper, + app.IBCKeeper, + app.appCodec, + app.IBCKeeper.ClientKeeper, + &app.AccountKeeper, ), ) } diff --git a/app/upgrades/v8/upgrades.go b/app/upgrades/v8/upgrades.go index 5a1ec2337..dd7c80e31 100644 --- a/app/upgrades/v8/upgrades.go +++ b/app/upgrades/v8/upgrades.go @@ -1,12 +1,21 @@ package v8 import ( + "fmt" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" + auctiontypes "github.com/peggyjv/sommelier/v8/x/auction/types" ) func CreateUpgradeHandler( @@ -14,13 +23,61 @@ func CreateUpgradeHandler( configurator module.Configurator, baseAppLegacySS *paramstypes.Subspace, consensusParamsKeeper *consensusparamkeeper.Keeper, + ibcKeeper *ibckeeper.Keeper, + cdc codec.BinaryCodec, + clientKeeper ibctmmigrations.ClientKeeper, + accountKeeper *authkeeper.AccountKeeper, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("v8 upgrade: entering handler and running migrations") + // Include this when migrating to ibc-go v7 (optional) + // source: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/migrations/v6-to-v7.md + // prune expired tendermint consensus states to save storage space + if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, cdc, clientKeeper); err != nil { + return nil, err + } + // new x/consensus module params migration baseapp.MigrateParams(ctx, baseAppLegacySS, consensusParamsKeeper) - return mm.RunMigrations(ctx, configurator, vm) + // explicitly update the IBC 02-client params, adding the localhost client type + params := ibcKeeper.ClientKeeper.GetParams(ctx) + params.AllowedClients = append(params.AllowedClients, ibcexported.Localhost) + ibcKeeper.ClientKeeper.SetParams(ctx, params) + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return nil, err + } + + // add burner permission to auction account + if err := MigrateAuctionAccountPermissions(ctx, accountKeeper); err != nil { + return nil, err + } + + return vm, nil } } + +func MigrateAuctionAccountPermissions(ctx sdk.Context, accountKeeper *authkeeper.AccountKeeper) error { + ctx.Logger().Info("Migrating auction account permissions") + oldAcctI := accountKeeper.GetModuleAccount(ctx, auctiontypes.ModuleName) + + if oldAcctI == nil { + return fmt.Errorf("module account not found") + } + + newAcct := authtypes.NewEmptyModuleAccount(auctiontypes.ModuleName, authtypes.Burner) + newAcct.AccountNumber = oldAcctI.GetAccountNumber() + newAcct.Address = oldAcctI.GetAddress().String() + newAcct.Sequence = oldAcctI.GetSequence() + newAcct.Name = oldAcctI.GetName() + newAcctI := (accountKeeper.NewAccount(ctx, newAcct)).(authtypes.ModuleAccountI) + + accountKeeper.SetModuleAccount(ctx, newAcctI) + + ctx.Logger().Info("Auction account permissions migrated") + + return nil +} diff --git a/integration_tests/auction_test.go b/integration_tests/auction_test.go index 525716d49..3eece8cf3 100644 --- a/integration_tests/auction_test.go +++ b/integration_tests/auction_test.go @@ -315,6 +315,7 @@ func (s *IntegrationTestSuite) TestAuction() { // Calculate the expected burn amount (50% of total SOMM paid in auction) expectedBurnAmount := totalSommPaid.Quo(sdk.NewInt(2)) + s.Require().NotZero(expectedBurnAmount.Int64(), "Expected burn amount should not be zero") // Calculate the expected new total supply expectedNewSupply := supplyRes.Amount.Amount.Sub(expectedBurnAmount) @@ -326,6 +327,10 @@ func (s *IntegrationTestSuite) TestAuction() { // Verify that the new supply matches the expected new supply s.Require().Equal(expectedNewSupply.Int64(), newSupplyRes.Amount.Amount.Int64(), "Total supply of usomm should be reduced by the amount burnt") + // Get auction module account + auctionModuleAccount := authtypes.NewModuleAddress(types.ModuleName) + s.T().Logf("Auction module account: %s", auctionModuleAccount.String()) + s.T().Log("Total supply of usomm has been correctly reduced!") s.T().Log("--Test completed successfully--") diff --git a/x/auction/keeper/migrations.go b/x/auction/keeper/migrations.go index a76c5d7cc..6c776dd12 100644 --- a/x/auction/keeper/migrations.go +++ b/x/auction/keeper/migrations.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - v1 "github.com/peggyjv/sommelier/v8/x/auction/migrations/v1" + "github.com/peggyjv/sommelier/v8/x/auction/types" ) // Migrator is a struct for handling in-place store migrations. @@ -17,5 +17,13 @@ func NewMigrator(keeper Keeper) Migrator { // Migrate1to2 migrates from consensus version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v1.MigrateParamStore(ctx, m.keeper.paramSpace) + ctx.Logger().Info("auction v1 to v2: New params") + subspace := m.keeper.paramSpace + + if !subspace.Has(ctx, types.KeyAuctionBurnRate) { + subspace.Set(ctx, types.KeyAuctionBurnRate, types.DefaultParams().AuctionBurnRate) + } + + ctx.Logger().Info("auction v1 to v2: Params migration complete") + return nil } diff --git a/x/auction/migrations/v1/store.go b/x/auction/migrations/v1/store.go deleted file mode 100644 index 617c57a4a..000000000 --- a/x/auction/migrations/v1/store.go +++ /dev/null @@ -1,18 +0,0 @@ -package v1 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/peggyjv/sommelier/v8/x/auction/types" -) - -func MigrateParamStore(ctx sdk.Context, subspace paramstypes.Subspace) error { - ctx.Logger().Info("auction v1 to v2: Migrating params") - - if !subspace.Has(ctx, types.KeyAuctionBurnRate) { - subspace.Set(ctx, types.KeyAuctionBurnRate, types.DefaultParams().AuctionBurnRate) - } - - ctx.Logger().Info("auction v1 to v2: Params migration complete") - return nil -} diff --git a/x/auction/migrations/v1/types/auction.pb.go b/x/auction/migrations/v1/types/auction.pb.go deleted file mode 100644 index 77b7bc5db..000000000 --- a/x/auction/migrations/v1/types/auction.pb.go +++ /dev/null @@ -1,1917 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: auction/v1/auction.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/regen-network/cosmos-proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Auction struct { - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - StartingTokensForSale types.Coin `protobuf:"bytes,2,opt,name=starting_tokens_for_sale,json=startingTokensForSale,proto3" json:"starting_tokens_for_sale"` - StartBlock uint64 `protobuf:"varint,3,opt,name=start_block,json=startBlock,proto3" json:"start_block,omitempty"` - EndBlock uint64 `protobuf:"varint,4,opt,name=end_block,json=endBlock,proto3" json:"end_block,omitempty"` - InitialPriceDecreaseRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=initial_price_decrease_rate,json=initialPriceDecreaseRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"initial_price_decrease_rate"` - CurrentPriceDecreaseRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=current_price_decrease_rate,json=currentPriceDecreaseRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_price_decrease_rate"` - PriceDecreaseBlockInterval uint64 `protobuf:"varint,7,opt,name=price_decrease_block_interval,json=priceDecreaseBlockInterval,proto3" json:"price_decrease_block_interval,omitempty"` - InitialUnitPriceInUsomm github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=initial_unit_price_in_usomm,json=initialUnitPriceInUsomm,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"initial_unit_price_in_usomm"` - CurrentUnitPriceInUsomm github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=current_unit_price_in_usomm,json=currentUnitPriceInUsomm,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_unit_price_in_usomm"` - RemainingTokensForSale types.Coin `protobuf:"bytes,10,opt,name=remaining_tokens_for_sale,json=remainingTokensForSale,proto3" json:"remaining_tokens_for_sale"` - FundingModuleAccount string `protobuf:"bytes,11,opt,name=funding_module_account,json=fundingModuleAccount,proto3" json:"funding_module_account,omitempty"` - ProceedsModuleAccount string `protobuf:"bytes,12,opt,name=proceeds_module_account,json=proceedsModuleAccount,proto3" json:"proceeds_module_account,omitempty"` -} - -func (m *Auction) Reset() { *m = Auction{} } -func (m *Auction) String() string { return proto.CompactTextString(m) } -func (*Auction) ProtoMessage() {} -func (*Auction) Descriptor() ([]byte, []int) { - return fileDescriptor_efe336ece9e41ddd, []int{0} -} -func (m *Auction) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Auction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Auction.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Auction) XXX_Merge(src proto.Message) { - xxx_messageInfo_Auction.Merge(m, src) -} -func (m *Auction) XXX_Size() int { - return m.Size() -} -func (m *Auction) XXX_DiscardUnknown() { - xxx_messageInfo_Auction.DiscardUnknown(m) -} - -var xxx_messageInfo_Auction proto.InternalMessageInfo - -func (m *Auction) GetId() uint32 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *Auction) GetStartingTokensForSale() types.Coin { - if m != nil { - return m.StartingTokensForSale - } - return types.Coin{} -} - -func (m *Auction) GetStartBlock() uint64 { - if m != nil { - return m.StartBlock - } - return 0 -} - -func (m *Auction) GetEndBlock() uint64 { - if m != nil { - return m.EndBlock - } - return 0 -} - -func (m *Auction) GetPriceDecreaseBlockInterval() uint64 { - if m != nil { - return m.PriceDecreaseBlockInterval - } - return 0 -} - -func (m *Auction) GetRemainingTokensForSale() types.Coin { - if m != nil { - return m.RemainingTokensForSale - } - return types.Coin{} -} - -func (m *Auction) GetFundingModuleAccount() string { - if m != nil { - return m.FundingModuleAccount - } - return "" -} - -func (m *Auction) GetProceedsModuleAccount() string { - if m != nil { - return m.ProceedsModuleAccount - } - return "" -} - -type Bid struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - AuctionId uint32 `protobuf:"varint,2,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` - Bidder string `protobuf:"bytes,3,opt,name=bidder,proto3" json:"bidder,omitempty"` - MaxBidInUsomm types.Coin `protobuf:"bytes,4,opt,name=max_bid_in_usomm,json=maxBidInUsomm,proto3" json:"max_bid_in_usomm"` - SaleTokenMinimumAmount types.Coin `protobuf:"bytes,5,opt,name=sale_token_minimum_amount,json=saleTokenMinimumAmount,proto3" json:"sale_token_minimum_amount"` - TotalFulfilledSaleTokens types.Coin `protobuf:"bytes,6,opt,name=total_fulfilled_sale_tokens,json=totalFulfilledSaleTokens,proto3" json:"total_fulfilled_sale_tokens"` - SaleTokenUnitPriceInUsomm github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=sale_token_unit_price_in_usomm,json=saleTokenUnitPriceInUsomm,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"sale_token_unit_price_in_usomm"` - TotalUsommPaid types.Coin `protobuf:"bytes,8,opt,name=total_usomm_paid,json=totalUsommPaid,proto3" json:"total_usomm_paid"` - BlockHeight uint64 `protobuf:"varint,9,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` -} - -func (m *Bid) Reset() { *m = Bid{} } -func (m *Bid) String() string { return proto.CompactTextString(m) } -func (*Bid) ProtoMessage() {} -func (*Bid) Descriptor() ([]byte, []int) { - return fileDescriptor_efe336ece9e41ddd, []int{1} -} -func (m *Bid) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Bid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Bid.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Bid) XXX_Merge(src proto.Message) { - xxx_messageInfo_Bid.Merge(m, src) -} -func (m *Bid) XXX_Size() int { - return m.Size() -} -func (m *Bid) XXX_DiscardUnknown() { - xxx_messageInfo_Bid.DiscardUnknown(m) -} - -var xxx_messageInfo_Bid proto.InternalMessageInfo - -func (m *Bid) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *Bid) GetAuctionId() uint32 { - if m != nil { - return m.AuctionId - } - return 0 -} - -func (m *Bid) GetBidder() string { - if m != nil { - return m.Bidder - } - return "" -} - -func (m *Bid) GetMaxBidInUsomm() types.Coin { - if m != nil { - return m.MaxBidInUsomm - } - return types.Coin{} -} - -func (m *Bid) GetSaleTokenMinimumAmount() types.Coin { - if m != nil { - return m.SaleTokenMinimumAmount - } - return types.Coin{} -} - -func (m *Bid) GetTotalFulfilledSaleTokens() types.Coin { - if m != nil { - return m.TotalFulfilledSaleTokens - } - return types.Coin{} -} - -func (m *Bid) GetTotalUsommPaid() types.Coin { - if m != nil { - return m.TotalUsommPaid - } - return types.Coin{} -} - -func (m *Bid) GetBlockHeight() uint64 { - if m != nil { - return m.BlockHeight - } - return 0 -} - -// USD price is the value for one non-fractional token (smallest unit of the token * 10^exponent) -type TokenPrice struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - Exponent uint64 `protobuf:"varint,2,opt,name=exponent,proto3" json:"exponent,omitempty"` - UsdPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=usd_price,json=usdPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"usd_price"` - LastUpdatedBlock uint64 `protobuf:"varint,4,opt,name=last_updated_block,json=lastUpdatedBlock,proto3" json:"last_updated_block,omitempty"` -} - -func (m *TokenPrice) Reset() { *m = TokenPrice{} } -func (m *TokenPrice) String() string { return proto.CompactTextString(m) } -func (*TokenPrice) ProtoMessage() {} -func (*TokenPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_efe336ece9e41ddd, []int{2} -} -func (m *TokenPrice) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TokenPrice.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TokenPrice) XXX_Merge(src proto.Message) { - xxx_messageInfo_TokenPrice.Merge(m, src) -} -func (m *TokenPrice) XXX_Size() int { - return m.Size() -} -func (m *TokenPrice) XXX_DiscardUnknown() { - xxx_messageInfo_TokenPrice.DiscardUnknown(m) -} - -var xxx_messageInfo_TokenPrice proto.InternalMessageInfo - -func (m *TokenPrice) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *TokenPrice) GetExponent() uint64 { - if m != nil { - return m.Exponent - } - return 0 -} - -func (m *TokenPrice) GetLastUpdatedBlock() uint64 { - if m != nil { - return m.LastUpdatedBlock - } - return 0 -} - -type ProposedTokenPrice struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - Exponent uint64 `protobuf:"varint,2,opt,name=exponent,proto3" json:"exponent,omitempty"` - UsdPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=usd_price,json=usdPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"usd_price"` -} - -func (m *ProposedTokenPrice) Reset() { *m = ProposedTokenPrice{} } -func (m *ProposedTokenPrice) String() string { return proto.CompactTextString(m) } -func (*ProposedTokenPrice) ProtoMessage() {} -func (*ProposedTokenPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_efe336ece9e41ddd, []int{3} -} -func (m *ProposedTokenPrice) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProposedTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProposedTokenPrice.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ProposedTokenPrice) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProposedTokenPrice.Merge(m, src) -} -func (m *ProposedTokenPrice) XXX_Size() int { - return m.Size() -} -func (m *ProposedTokenPrice) XXX_DiscardUnknown() { - xxx_messageInfo_ProposedTokenPrice.DiscardUnknown(m) -} - -var xxx_messageInfo_ProposedTokenPrice proto.InternalMessageInfo - -func (m *ProposedTokenPrice) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *ProposedTokenPrice) GetExponent() uint64 { - if m != nil { - return m.Exponent - } - return 0 -} - -func init() { - proto.RegisterType((*Auction)(nil), "auction.v1.Auction") - proto.RegisterType((*Bid)(nil), "auction.v1.Bid") - proto.RegisterType((*TokenPrice)(nil), "auction.v1.TokenPrice") - proto.RegisterType((*ProposedTokenPrice)(nil), "auction.v1.ProposedTokenPrice") -} - -func init() { proto.RegisterFile("auction/v1/auction.proto", fileDescriptor_efe336ece9e41ddd) } - -var fileDescriptor_efe336ece9e41ddd = []byte{ - // 799 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x41, 0x6f, 0xdb, 0x36, - 0x14, 0xb6, 0x52, 0xc7, 0xb1, 0xe9, 0xa6, 0x08, 0x88, 0x34, 0x95, 0x1d, 0x54, 0xf1, 0x7c, 0x18, - 0x7c, 0xd8, 0x2c, 0x78, 0x1b, 0xb6, 0xb3, 0xbd, 0xa2, 0xa8, 0x31, 0x14, 0x08, 0xd4, 0x05, 0x18, - 0x7a, 0x18, 0x41, 0x8b, 0xcf, 0x0e, 0x17, 0x89, 0xd4, 0x44, 0xca, 0x70, 0xff, 0xc5, 0x80, 0xfd, - 0x94, 0x9d, 0xf6, 0x0f, 0x7a, 0xec, 0x71, 0xd8, 0xa1, 0x18, 0x92, 0x3f, 0xb1, 0xe3, 0x20, 0x92, - 0x6a, 0x9c, 0xc6, 0x07, 0xcf, 0xa7, 0x9e, 0x2c, 0xbe, 0x4f, 0xef, 0xfb, 0xde, 0xfb, 0xfc, 0x1e, - 0x85, 0x7c, 0x5a, 0xc4, 0x9a, 0x4b, 0x11, 0x2e, 0x47, 0xa1, 0x7b, 0x1c, 0x66, 0xb9, 0xd4, 0x12, - 0xa3, 0xea, 0xb8, 0x1c, 0x75, 0x83, 0x58, 0xaa, 0x54, 0xaa, 0x70, 0x46, 0x15, 0x84, 0xcb, 0xd1, - 0x0c, 0x34, 0x1d, 0x85, 0xb1, 0xe4, 0xee, 0xdd, 0x6e, 0xc7, 0xe2, 0xc4, 0x9c, 0x42, 0x7b, 0x70, - 0xd0, 0xf1, 0x42, 0x2e, 0xa4, 0x8d, 0x97, 0x4f, 0x36, 0xda, 0xff, 0xb7, 0x81, 0x0e, 0xc6, 0x96, - 0x1f, 0x3f, 0x42, 0x7b, 0x9c, 0xf9, 0x5e, 0xcf, 0x1b, 0x1c, 0x46, 0x7b, 0x9c, 0xe1, 0x9f, 0x90, - 0xaf, 0x34, 0xcd, 0x35, 0x17, 0x0b, 0xa2, 0xe5, 0x15, 0x08, 0x45, 0xe6, 0x32, 0x27, 0x8a, 0x26, - 0xe0, 0xef, 0xf5, 0xbc, 0x41, 0xfb, 0xab, 0xce, 0xd0, 0x49, 0x94, 0xf5, 0x0c, 0x5d, 0x3d, 0xc3, - 0xef, 0x25, 0x17, 0x93, 0xfa, 0xdb, 0xf7, 0x67, 0xb5, 0xe8, 0x71, 0x45, 0xf0, 0xa3, 0xc9, 0x7f, - 0x2e, 0xf3, 0x57, 0x34, 0x01, 0x7c, 0x86, 0xda, 0x06, 0x20, 0xb3, 0x44, 0xc6, 0x57, 0xfe, 0x83, - 0x9e, 0x37, 0xa8, 0x47, 0xc8, 0x84, 0x26, 0x65, 0x04, 0x9f, 0xa2, 0x16, 0x08, 0xe6, 0xe0, 0xba, - 0x81, 0x9b, 0x20, 0x98, 0x05, 0x53, 0x74, 0xca, 0x05, 0xd7, 0x9c, 0x26, 0x24, 0xcb, 0x79, 0x0c, - 0x84, 0x41, 0x9c, 0x03, 0x55, 0x40, 0x72, 0xaa, 0xc1, 0xdf, 0xef, 0x79, 0x83, 0xd6, 0x64, 0x58, - 0xea, 0xff, 0xfd, 0xfe, 0xec, 0xf3, 0x05, 0xd7, 0x97, 0xc5, 0x6c, 0x18, 0xcb, 0xd4, 0xf9, 0xe1, - 0x7e, 0xbe, 0x54, 0xec, 0x2a, 0xd4, 0x6f, 0x32, 0x50, 0xc3, 0x67, 0x10, 0x47, 0xbe, 0xa3, 0x3c, - 0x2f, 0x19, 0x9f, 0x39, 0xc2, 0x88, 0x6a, 0x28, 0xe5, 0xe2, 0x22, 0xcf, 0x41, 0xe8, 0x8d, 0x72, - 0x8d, 0xdd, 0xe4, 0x1c, 0xe5, 0x7d, 0xb9, 0x31, 0x7a, 0xfa, 0x91, 0x8c, 0x71, 0x81, 0x70, 0xa1, - 0x21, 0x5f, 0xd2, 0xc4, 0x3f, 0x30, 0x76, 0x74, 0xb3, 0xf5, 0x4c, 0x63, 0xcc, 0xd4, 0xbd, 0x81, - 0x93, 0x5b, 0x83, 0x0a, 0xc1, 0xab, 0xb2, 0xb9, 0x20, 0x85, 0x92, 0x69, 0xea, 0x37, 0x77, 0xaa, - 0xf8, 0x89, 0xa3, 0xbc, 0x10, 0xdc, 0x56, 0x3d, 0x15, 0x17, 0x25, 0x5d, 0xa9, 0x56, 0xf9, 0xb3, - 0x49, 0xad, 0xb5, 0x9b, 0x9a, 0xa3, 0xbc, 0xa7, 0xf6, 0x1a, 0x75, 0x72, 0x48, 0x29, 0x17, 0x9b, - 0xa6, 0x12, 0x6d, 0x37, 0x95, 0x27, 0x1f, 0x18, 0xee, 0x8e, 0xe5, 0x37, 0xe8, 0x64, 0x5e, 0x08, - 0x56, 0x32, 0xa7, 0x92, 0x15, 0x09, 0x10, 0x1a, 0xc7, 0xb2, 0x10, 0xda, 0x6f, 0x97, 0x4d, 0x44, - 0xc7, 0x0e, 0x7d, 0x69, 0xc0, 0xb1, 0xc5, 0xf0, 0xb7, 0xe8, 0x49, 0x96, 0xcb, 0x18, 0x80, 0xa9, - 0x8f, 0xd3, 0x1e, 0x9a, 0xb4, 0xc7, 0x15, 0x7c, 0x27, 0xaf, 0xff, 0x47, 0x1d, 0x3d, 0x98, 0x70, - 0xb6, 0xb6, 0x76, 0x75, 0xb3, 0x76, 0x4f, 0x51, 0xb5, 0xf1, 0x84, 0x33, 0xb3, 0x68, 0x87, 0x51, - 0xcb, 0x45, 0xa6, 0x0c, 0x9f, 0xa0, 0xc6, 0x8c, 0x33, 0x06, 0xb9, 0x59, 0x9b, 0x56, 0xe4, 0x4e, - 0xf8, 0x05, 0x3a, 0x4a, 0xe9, 0x8a, 0xcc, 0x38, 0xbb, 0xf5, 0xbe, 0xbe, 0x9d, 0x1f, 0x87, 0x29, - 0x5d, 0x4d, 0x38, 0x5b, 0xb3, 0xb8, 0x74, 0xd3, 0xba, 0x4b, 0x52, 0x2e, 0x78, 0x5a, 0xa4, 0x84, - 0xa6, 0xa6, 0xa5, 0xfd, 0x2d, 0x2d, 0x2e, 0x19, 0x8c, 0xbb, 0x2f, 0x6d, 0xfe, 0xd8, 0xa4, 0xe3, - 0x9f, 0xd1, 0xa9, 0x96, 0x9a, 0x26, 0x64, 0x5e, 0x24, 0x73, 0x9e, 0x24, 0xc0, 0xc8, 0xad, 0x96, - 0x32, 0xcb, 0xb4, 0x05, 0xbb, 0x6f, 0x38, 0x9e, 0x57, 0x14, 0xaf, 0x2a, 0x2d, 0x85, 0x7f, 0x45, - 0xc1, 0x5a, 0xed, 0x9b, 0xe6, 0xf1, 0x60, 0xa7, 0x79, 0xec, 0x7c, 0xe8, 0xe7, 0xde, 0x44, 0x4e, - 0xd1, 0x91, 0x6d, 0xc9, 0xf0, 0x93, 0x8c, 0x72, 0x66, 0x56, 0x6c, 0x8b, 0x3e, 0x1e, 0x99, 0x44, - 0x43, 0x73, 0x4e, 0x39, 0xc3, 0x9f, 0xa1, 0x87, 0x76, 0xd9, 0x2f, 0x81, 0x2f, 0x2e, 0xb5, 0xd9, - 0x9d, 0x7a, 0xd4, 0x36, 0xb1, 0x17, 0x26, 0xd4, 0xff, 0xd3, 0x43, 0xc8, 0xd4, 0x61, 0x6a, 0xc0, - 0xc7, 0x68, 0x9f, 0x81, 0x90, 0xa9, 0x99, 0x9f, 0x56, 0x64, 0x0f, 0xb8, 0x8b, 0x9a, 0xb0, 0xca, - 0xa4, 0x00, 0xa1, 0xcd, 0x00, 0x95, 0xb7, 0xa7, 0x3b, 0xe3, 0x1f, 0x50, 0xab, 0x50, 0xcc, 0xba, - 0x62, 0x47, 0xe8, 0x7f, 0x9b, 0xd1, 0x2c, 0x14, 0xb3, 0xf2, 0x5f, 0x20, 0x9c, 0x50, 0xa5, 0x49, - 0x91, 0x31, 0xaa, 0xe1, 0xee, 0x85, 0x7d, 0x54, 0x22, 0x17, 0x16, 0x30, 0xf7, 0x53, 0xff, 0x77, - 0x0f, 0xe1, 0xf3, 0x5c, 0x66, 0x52, 0x01, 0xfb, 0x64, 0x7a, 0x98, 0x4c, 0xdf, 0x5e, 0x07, 0xde, - 0xbb, 0xeb, 0xc0, 0xfb, 0xe7, 0x3a, 0xf0, 0x7e, 0xbb, 0x09, 0x6a, 0xef, 0x6e, 0x82, 0xda, 0x5f, - 0x37, 0x41, 0xed, 0x75, 0xb8, 0xc6, 0x95, 0xc1, 0x62, 0xf1, 0xe6, 0x97, 0x65, 0x58, 0xfe, 0x57, - 0x90, 0x70, 0xc8, 0xc3, 0xe5, 0x77, 0xe1, 0xaa, 0xfa, 0x54, 0x5b, 0xe2, 0x59, 0xc3, 0x7c, 0x54, - 0xbf, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x68, 0x28, 0x79, 0x9e, 0xcd, 0x07, 0x00, 0x00, -} - -func (m *Auction) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Auction) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ProceedsModuleAccount) > 0 { - i -= len(m.ProceedsModuleAccount) - copy(dAtA[i:], m.ProceedsModuleAccount) - i = encodeVarintAuction(dAtA, i, uint64(len(m.ProceedsModuleAccount))) - i-- - dAtA[i] = 0x62 - } - if len(m.FundingModuleAccount) > 0 { - i -= len(m.FundingModuleAccount) - copy(dAtA[i:], m.FundingModuleAccount) - i = encodeVarintAuction(dAtA, i, uint64(len(m.FundingModuleAccount))) - i-- - dAtA[i] = 0x5a - } - { - size, err := m.RemainingTokensForSale.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - { - size := m.CurrentUnitPriceInUsomm.Size() - i -= size - if _, err := m.CurrentUnitPriceInUsomm.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - { - size := m.InitialUnitPriceInUsomm.Size() - i -= size - if _, err := m.InitialUnitPriceInUsomm.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - if m.PriceDecreaseBlockInterval != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.PriceDecreaseBlockInterval)) - i-- - dAtA[i] = 0x38 - } - { - size := m.CurrentPriceDecreaseRate.Size() - i -= size - if _, err := m.CurrentPriceDecreaseRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.InitialPriceDecreaseRate.Size() - i -= size - if _, err := m.InitialPriceDecreaseRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.EndBlock != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.EndBlock)) - i-- - dAtA[i] = 0x20 - } - if m.StartBlock != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.StartBlock)) - i-- - dAtA[i] = 0x18 - } - { - size, err := m.StartingTokensForSale.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Id != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Bid) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Bid) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Bid) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BlockHeight != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.BlockHeight)) - i-- - dAtA[i] = 0x48 - } - { - size, err := m.TotalUsommPaid.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - { - size := m.SaleTokenUnitPriceInUsomm.Size() - i -= size - if _, err := m.SaleTokenUnitPriceInUsomm.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - { - size, err := m.TotalFulfilledSaleTokens.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size, err := m.SaleTokenMinimumAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size, err := m.MaxBidInUsomm.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.Bidder) > 0 { - i -= len(m.Bidder) - copy(dAtA[i:], m.Bidder) - i = encodeVarintAuction(dAtA, i, uint64(len(m.Bidder))) - i-- - dAtA[i] = 0x1a - } - if m.AuctionId != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.AuctionId)) - i-- - dAtA[i] = 0x10 - } - if m.Id != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *TokenPrice) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TokenPrice) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LastUpdatedBlock != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.LastUpdatedBlock)) - i-- - dAtA[i] = 0x20 - } - { - size := m.UsdPrice.Size() - i -= size - if _, err := m.UsdPrice.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.Exponent != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.Exponent)) - i-- - dAtA[i] = 0x10 - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintAuction(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ProposedTokenPrice) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProposedTokenPrice) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProposedTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.UsdPrice.Size() - i -= size - if _, err := m.UsdPrice.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.Exponent != 0 { - i = encodeVarintAuction(dAtA, i, uint64(m.Exponent)) - i-- - dAtA[i] = 0x10 - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintAuction(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintAuction(dAtA []byte, offset int, v uint64) int { - offset -= sovAuction(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Auction) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovAuction(uint64(m.Id)) - } - l = m.StartingTokensForSale.Size() - n += 1 + l + sovAuction(uint64(l)) - if m.StartBlock != 0 { - n += 1 + sovAuction(uint64(m.StartBlock)) - } - if m.EndBlock != 0 { - n += 1 + sovAuction(uint64(m.EndBlock)) - } - l = m.InitialPriceDecreaseRate.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.CurrentPriceDecreaseRate.Size() - n += 1 + l + sovAuction(uint64(l)) - if m.PriceDecreaseBlockInterval != 0 { - n += 1 + sovAuction(uint64(m.PriceDecreaseBlockInterval)) - } - l = m.InitialUnitPriceInUsomm.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.CurrentUnitPriceInUsomm.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.RemainingTokensForSale.Size() - n += 1 + l + sovAuction(uint64(l)) - l = len(m.FundingModuleAccount) - if l > 0 { - n += 1 + l + sovAuction(uint64(l)) - } - l = len(m.ProceedsModuleAccount) - if l > 0 { - n += 1 + l + sovAuction(uint64(l)) - } - return n -} - -func (m *Bid) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovAuction(uint64(m.Id)) - } - if m.AuctionId != 0 { - n += 1 + sovAuction(uint64(m.AuctionId)) - } - l = len(m.Bidder) - if l > 0 { - n += 1 + l + sovAuction(uint64(l)) - } - l = m.MaxBidInUsomm.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.SaleTokenMinimumAmount.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.TotalFulfilledSaleTokens.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.SaleTokenUnitPriceInUsomm.Size() - n += 1 + l + sovAuction(uint64(l)) - l = m.TotalUsommPaid.Size() - n += 1 + l + sovAuction(uint64(l)) - if m.BlockHeight != 0 { - n += 1 + sovAuction(uint64(m.BlockHeight)) - } - return n -} - -func (m *TokenPrice) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovAuction(uint64(l)) - } - if m.Exponent != 0 { - n += 1 + sovAuction(uint64(m.Exponent)) - } - l = m.UsdPrice.Size() - n += 1 + l + sovAuction(uint64(l)) - if m.LastUpdatedBlock != 0 { - n += 1 + sovAuction(uint64(m.LastUpdatedBlock)) - } - return n -} - -func (m *ProposedTokenPrice) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovAuction(uint64(l)) - } - if m.Exponent != 0 { - n += 1 + sovAuction(uint64(m.Exponent)) - } - l = m.UsdPrice.Size() - n += 1 + l + sovAuction(uint64(l)) - return n -} - -func sovAuction(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozAuction(x uint64) (n int) { - return sovAuction(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Auction) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Auction: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Auction: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartingTokensForSale", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.StartingTokensForSale.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartBlock", wireType) - } - m.StartBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EndBlock", wireType) - } - m.EndBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EndBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InitialPriceDecreaseRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InitialPriceDecreaseRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentPriceDecreaseRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CurrentPriceDecreaseRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceDecreaseBlockInterval", wireType) - } - m.PriceDecreaseBlockInterval = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PriceDecreaseBlockInterval |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InitialUnitPriceInUsomm", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InitialUnitPriceInUsomm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentUnitPriceInUsomm", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CurrentUnitPriceInUsomm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RemainingTokensForSale", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RemainingTokensForSale.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FundingModuleAccount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FundingModuleAccount = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProceedsModuleAccount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProceedsModuleAccount = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAuction(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAuction - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Bid) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Bid: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Bid: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) - } - m.AuctionId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AuctionId |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bidder", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Bidder = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxBidInUsomm", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxBidInUsomm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleTokenMinimumAmount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SaleTokenMinimumAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalFulfilledSaleTokens", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalFulfilledSaleTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleTokenUnitPriceInUsomm", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SaleTokenUnitPriceInUsomm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalUsommPaid", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalUsommPaid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) - } - m.BlockHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAuction(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAuction - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TokenPrice) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TokenPrice: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Exponent", wireType) - } - m.Exponent = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Exponent |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UsdPrice", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UsdPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastUpdatedBlock", wireType) - } - m.LastUpdatedBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastUpdatedBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAuction(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAuction - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ProposedTokenPrice) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProposedTokenPrice: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProposedTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Exponent", wireType) - } - m.Exponent = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Exponent |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UsdPrice", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UsdPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAuction(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAuction - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipAuction(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowAuction - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowAuction - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowAuction - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthAuction - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAuction - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthAuction - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthAuction = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAuction = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAuction = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/auction/migrations/v1/types/errors.go b/x/auction/migrations/v1/types/errors.go deleted file mode 100644 index 7fc6155bc..000000000 --- a/x/auction/migrations/v1/types/errors.go +++ /dev/null @@ -1,55 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" -) - -// x/auction module sentinel errors -var ( - ErrCouldNotFindSaleTokenPrice = errorsmod.Register(ModuleName, 2, "could not find sale token price, need to resubmit token prices and try again") - ErrCouldNotFindSommTokenPrice = errorsmod.Register(ModuleName, 3, "could not find usomm token price, need to resubmit token prices and try again") - ErrLastSaleTokenPriceTooOld = errorsmod.Register(ModuleName, 4, "last sale token price update too long ago, need to resubmit token prices and try again") - ErrLastSommTokenPriceTooOld = errorsmod.Register(ModuleName, 5, "last usomm token price update too long ago, need to resubmit token prices and try again") - ErrAuctionStartingAmountMustBePositve = errorsmod.Register(ModuleName, 6, "minimum auction sale token starting amount must be a positive amount of coins") - ErrCannotAuctionUsomm = errorsmod.Register(ModuleName, 7, "auctioning usomm for usomm is pointless") - ErrInvalidInitialDecreaseRate = errorsmod.Register(ModuleName, 8, "initial price decrease rate must be a float less than one and greater than zero") - ErrInvalidBlockDecreaseInterval = errorsmod.Register(ModuleName, 9, "price decrease block interval cannot be 0") - ErrUnauthorizedFundingModule = errorsmod.Register(ModuleName, 10, "unauthorized funding module account") - ErrUnauthorizedProceedsModule = errorsmod.Register(ModuleName, 11, "unauthorized proceeds module account") - ErrCannotStartTwoAuctionsForSameDenomSimultaneously = errorsmod.Register(ModuleName, 12, "auction for this denom is currently ongoing, cannot create another auction for the same denom until completed") - ErrConvertingStringToDec = errorsmod.Register(ModuleName, 13, "could not convert string to dec") - ErrAuctionNotFound = errorsmod.Register(ModuleName, 14, "auction not found") - ErrBidAuctionDenomMismatch = errorsmod.Register(ModuleName, 15, "auction denom different from bid requested denom") - ErrAuctionEnded = errorsmod.Register(ModuleName, 16, "auction ended") - ErrInsufficientBid = errorsmod.Register(ModuleName, 17, "max bid amount is too small to purchase minimum sale tokens requested") - ErrMinimumPurchaseAmountLargerThanTokensRemaining = errorsmod.Register(ModuleName, 18, "minimum purchase amount is larger then the number of tokens remaining for sale") - ErrAuctionIDMustBeNonZero = errorsmod.Register(ModuleName, 19, "auction IDs must be non-zero") - ErrInvalidStartBlock = errorsmod.Register(ModuleName, 20, "start block cannot be 0") - ErrInvalidCurrentDecreaseRate = errorsmod.Register(ModuleName, 21, "current price decrease rate must be a float less than one and greater than zero") - ErrPriceMustBePositive = errorsmod.Register(ModuleName, 22, "price must be positive") - ErrDenomCannotBeEmpty = errorsmod.Register(ModuleName, 23, "denom cannot be empty") - ErrInvalidLastUpdatedBlock = errorsmod.Register(ModuleName, 24, "last updated block cannot be 0") - ErrBidIDMustBeNonZero = errorsmod.Register(ModuleName, 25, "bid ID must be non-zero") - ErrBidAmountMustBePositive = errorsmod.Register(ModuleName, 26, "bid amount must be positive") - ErrBidMustBeInUsomm = errorsmod.Register(ModuleName, 27, "bid must be in usomm") - ErrInvalidTokenBeingBidOn = errorsmod.Register(ModuleName, 28, "tokens being bid on must have the gravity prefix") - ErrMinimumAmountMustBePositive = errorsmod.Register(ModuleName, 29, "minimum amount to purchase with bid must be positive") - ErrAddressExpected = errorsmod.Register(ModuleName, 30, "address cannot be empty") - ErrBidUnitPriceInUsommMustBePositive = errorsmod.Register(ModuleName, 31, "unit price of sale tokens in usomm must be positive") - ErrInvalidTokenPriceDenom = errorsmod.Register(ModuleName, 32, "token price denoms must be either usomm or addresses prefixed with 'gravity'") - ErrTokenPriceProposalAttemptsToUpdateTokenPriceMoreThanOnce = errorsmod.Register(ModuleName, 33, "token price proposals should not attempt to update the same denom's price more than once per proposal") - ErrTokenPriceMaxBlockAgeMustBePositive = errorsmod.Register(ModuleName, 34, "price max block age must be positive") - ErrInvalidPriceMaxBlockAgeParameterType = errorsmod.Register(ModuleName, 35, "price max block age type must be uint64") - ErrTokenPriceProposalMustHaveAtLeastOnePrice = errorsmod.Register(ModuleName, 36, "list of proposed token prices must be non-zero") - ErrBidFulfilledSaleTokenAmountMustBeNonNegative = errorsmod.Register(ModuleName, 37, "total sale token fulfilled amount must be non-negative") - ErrBidPaymentCannotBeNegative = errorsmod.Register(ModuleName, 38, "total amount paid in usomm cannot be negative") - ErrBidAmountIsTooSmall = errorsmod.Register(ModuleName, 39, "bid is below minimum amount") - ErrMinimumBidParam = errorsmod.Register(ModuleName, 40, "invalid minimum bid param") - ErrInvalidAuctionMaxBlockAgeParam = errorsmod.Register(ModuleName, 41, "invalid auction max block age param") - ErrInvalidAuctionPriceDecreaseAccelerationRateParam = errorsmod.Register(ModuleName, 42, "invalid auction price decrease acceleration rate param") - ErrTokenPriceExponentTooHigh = errorsmod.Register(ModuleName, 43, "token price exponent too high, maximum precision of 18") - ErrInvalidMinimumSaleTokensUSDValue = errorsmod.Register(ModuleName, 44, "invalid minimum sale tokens USD value") - ErrAuctionBelowMinimumUSDValue = errorsmod.Register(ModuleName, 45, "auction USD value below minimum") - ErrInvalidMinimumAuctionHeightParam = errorsmod.Register(ModuleName, 46, "invalid minimum auction height param") - ErrAuctionBelowMinimumHeight = errorsmod.Register(ModuleName, 47, "auction block height below minimum") -) diff --git a/x/auction/migrations/v1/types/genesis.pb.go b/x/auction/migrations/v1/types/genesis.pb.go deleted file mode 100644 index 17d9f3a50..000000000 --- a/x/auction/migrations/v1/types/genesis.pb.go +++ /dev/null @@ -1,951 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: auction/v1/genesis.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - Auctions []*Auction `protobuf:"bytes,2,rep,name=auctions,proto3" json:"auctions,omitempty"` - Bids []*Bid `protobuf:"bytes,3,rep,name=bids,proto3" json:"bids,omitempty"` - TokenPrices []*TokenPrice `protobuf:"bytes,4,rep,name=token_prices,json=tokenPrices,proto3" json:"token_prices,omitempty"` - LastAuctionId uint32 `protobuf:"varint,5,opt,name=last_auction_id,json=lastAuctionId,proto3" json:"last_auction_id,omitempty"` - LastBidId uint64 `protobuf:"varint,6,opt,name=last_bid_id,json=lastBidId,proto3" json:"last_bid_id,omitempty"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_a762e9d6ba7af420, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func (m *GenesisState) GetAuctions() []*Auction { - if m != nil { - return m.Auctions - } - return nil -} - -func (m *GenesisState) GetBids() []*Bid { - if m != nil { - return m.Bids - } - return nil -} - -func (m *GenesisState) GetTokenPrices() []*TokenPrice { - if m != nil { - return m.TokenPrices - } - return nil -} - -func (m *GenesisState) GetLastAuctionId() uint32 { - if m != nil { - return m.LastAuctionId - } - return 0 -} - -func (m *GenesisState) GetLastBidId() uint64 { - if m != nil { - return m.LastBidId - } - return 0 -} - -type Params struct { - PriceMaxBlockAge uint64 `protobuf:"varint,1,opt,name=price_max_block_age,json=priceMaxBlockAge,proto3" json:"price_max_block_age,omitempty"` - MinimumBidInUsomm uint64 `protobuf:"varint,2,opt,name=minimum_bid_in_usomm,json=minimumBidInUsomm,proto3" json:"minimum_bid_in_usomm,omitempty"` - MinimumSaleTokensUsdValue github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=minimum_sale_tokens_usd_value,json=minimumSaleTokensUsdValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_sale_tokens_usd_value"` - AuctionMaxBlockAge uint64 `protobuf:"varint,4,opt,name=auction_max_block_age,json=auctionMaxBlockAge,proto3" json:"auction_max_block_age,omitempty"` - AuctionPriceDecreaseAccelerationRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=auction_price_decrease_acceleration_rate,json=auctionPriceDecreaseAccelerationRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"auction_price_decrease_acceleration_rate"` - MinimumAuctionHeight uint64 `protobuf:"varint,6,opt,name=minimum_auction_height,json=minimumAuctionHeight,proto3" json:"minimum_auction_height,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_a762e9d6ba7af420, []int{1} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetPriceMaxBlockAge() uint64 { - if m != nil { - return m.PriceMaxBlockAge - } - return 0 -} - -func (m *Params) GetMinimumBidInUsomm() uint64 { - if m != nil { - return m.MinimumBidInUsomm - } - return 0 -} - -func (m *Params) GetAuctionMaxBlockAge() uint64 { - if m != nil { - return m.AuctionMaxBlockAge - } - return 0 -} - -func (m *Params) GetMinimumAuctionHeight() uint64 { - if m != nil { - return m.MinimumAuctionHeight - } - return 0 -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "auction.v1.GenesisState") - proto.RegisterType((*Params)(nil), "auction.v1.Params") -} - -func init() { proto.RegisterFile("auction/v1/genesis.proto", fileDescriptor_a762e9d6ba7af420) } - -var fileDescriptor_a762e9d6ba7af420 = []byte{ - // 541 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x9b, 0x35, 0x54, 0xcc, 0xdd, 0x34, 0xf0, 0xc6, 0x14, 0x26, 0x91, 0x55, 0x03, 0x4d, - 0xb9, 0x2c, 0x61, 0x03, 0x09, 0x71, 0x6c, 0x34, 0x09, 0x7a, 0x40, 0x9a, 0x32, 0xc6, 0x81, 0x4b, - 0xe4, 0xc6, 0x4f, 0xa9, 0x69, 0x12, 0x47, 0xb1, 0x53, 0x75, 0x5f, 0x80, 0x33, 0x57, 0xbe, 0xd1, - 0x0e, 0x1c, 0x76, 0x44, 0x1c, 0x26, 0xd4, 0x7e, 0x11, 0x64, 0xc7, 0x19, 0xe1, 0xc8, 0x29, 0x4f, - 0xfe, 0xff, 0xde, 0xf3, 0x7b, 0xff, 0x17, 0x23, 0x87, 0xd4, 0x89, 0x64, 0xbc, 0x08, 0x16, 0xa7, - 0x41, 0x0a, 0x05, 0x08, 0x26, 0xfc, 0xb2, 0xe2, 0x92, 0x63, 0x64, 0x14, 0x7f, 0x71, 0x7a, 0xb0, - 0xdb, 0xa1, 0xe4, 0xb2, 0x01, 0x0e, 0xba, 0xa9, 0x2d, 0xdb, 0x28, 0x7b, 0x29, 0x4f, 0xb9, 0x0e, - 0x03, 0x15, 0x35, 0xa7, 0x47, 0xdf, 0x37, 0xd0, 0xd6, 0xbb, 0xe6, 0x8a, 0x4b, 0x49, 0x24, 0xe0, - 0x97, 0x68, 0x50, 0x92, 0x8a, 0xe4, 0xc2, 0xb1, 0x46, 0x96, 0x37, 0x3c, 0xc3, 0xfe, 0xdf, 0x2b, - 0xfd, 0x0b, 0xad, 0x84, 0xf6, 0xcd, 0xdd, 0x61, 0x2f, 0x32, 0x1c, 0x0e, 0xd0, 0x43, 0x83, 0x08, - 0x67, 0x63, 0xd4, 0xf7, 0x86, 0x67, 0xbb, 0xdd, 0x9c, 0x71, 0x13, 0x46, 0xf7, 0x10, 0x7e, 0x8e, - 0xec, 0x29, 0xa3, 0xc2, 0xe9, 0x6b, 0x78, 0xa7, 0x0b, 0x87, 0x8c, 0x46, 0x5a, 0xc4, 0x6f, 0xd1, - 0x96, 0xe4, 0x73, 0x28, 0xe2, 0xb2, 0x62, 0x09, 0x08, 0xc7, 0xd6, 0xf0, 0x7e, 0x17, 0xfe, 0xa8, - 0xf4, 0x0b, 0x25, 0x47, 0x43, 0x79, 0x1f, 0x0b, 0x7c, 0x8c, 0x76, 0x32, 0x22, 0x64, 0x6c, 0xd0, - 0x98, 0x51, 0xe7, 0xc1, 0xc8, 0xf2, 0xb6, 0xa3, 0x6d, 0x75, 0x6c, 0xfa, 0x99, 0x50, 0xec, 0xa2, - 0xa1, 0xe6, 0xa6, 0x8c, 0x2a, 0x66, 0x30, 0xb2, 0x3c, 0x3b, 0xda, 0x54, 0x47, 0x21, 0xa3, 0x13, - 0x7a, 0xf4, 0xa3, 0x8f, 0x06, 0xcd, 0xc4, 0xf8, 0x04, 0xed, 0xea, 0x3e, 0xe2, 0x9c, 0x2c, 0xe3, - 0x69, 0xc6, 0x93, 0x79, 0x4c, 0x52, 0xd0, 0x16, 0xd9, 0xd1, 0x23, 0x2d, 0x7d, 0x20, 0xcb, 0x50, - 0x09, 0xe3, 0x14, 0x70, 0x80, 0xf6, 0x72, 0x56, 0xb0, 0xbc, 0xce, 0x9b, 0xe2, 0x45, 0x5c, 0x0b, - 0x9e, 0xe7, 0xce, 0x86, 0xe6, 0x1f, 0x1b, 0x4d, 0xdd, 0x52, 0x5c, 0x29, 0x01, 0x97, 0xe8, 0x59, - 0x9b, 0x20, 0x48, 0x06, 0xb1, 0x1e, 0x47, 0xc4, 0xb5, 0xa0, 0xf1, 0x82, 0x64, 0x35, 0x38, 0xfd, - 0x91, 0xe5, 0x6d, 0x86, 0xbe, 0x32, 0xfe, 0xd7, 0xdd, 0xe1, 0x71, 0xca, 0xe4, 0xac, 0x9e, 0xfa, - 0x09, 0xcf, 0x83, 0x84, 0x8b, 0x9c, 0x0b, 0xf3, 0x39, 0x11, 0x74, 0x1e, 0xc8, 0xeb, 0x12, 0x84, - 0x7f, 0x0e, 0x49, 0xf4, 0xd4, 0x14, 0xbd, 0x24, 0x19, 0x68, 0xb7, 0xc4, 0x95, 0xa0, 0x9f, 0x54, - 0x41, 0x7c, 0x8a, 0x9e, 0xb4, 0xfe, 0xfc, 0x3b, 0x93, 0xad, 0x7b, 0xc4, 0x46, 0xec, 0x4e, 0xf5, - 0xd5, 0x42, 0x5e, 0x9b, 0xd3, 0xb8, 0x41, 0x21, 0xa9, 0x80, 0x08, 0x88, 0x49, 0x92, 0x40, 0x06, - 0x15, 0xd1, 0x5a, 0x45, 0x24, 0x68, 0xc7, 0xff, 0xbf, 0xe1, 0x17, 0xa6, 0xbe, 0xde, 0xe4, 0xb9, - 0xa9, 0x3e, 0xee, 0x14, 0x8f, 0xd4, 0x3f, 0xfa, 0x1a, 0xed, 0xb7, 0x6e, 0xb5, 0xfd, 0xcc, 0x80, - 0xa5, 0x33, 0x69, 0x76, 0xd8, 0x9a, 0x6f, 0x56, 0xfd, 0x5e, 0x6b, 0xe1, 0xe4, 0x66, 0xe5, 0x5a, - 0xb7, 0x2b, 0xd7, 0xfa, 0xbd, 0x72, 0xad, 0x6f, 0x6b, 0xb7, 0x77, 0xbb, 0x76, 0x7b, 0x3f, 0xd7, - 0x6e, 0xef, 0x73, 0xd0, 0xe9, 0xae, 0x84, 0x34, 0xbd, 0xfe, 0xb2, 0x08, 0xd4, 0x5a, 0x20, 0x63, - 0x50, 0x05, 0x8b, 0x37, 0xc1, 0xb2, 0x7d, 0x4b, 0x4d, 0xab, 0xd3, 0x81, 0x7e, 0x3c, 0xaf, 0xfe, - 0x04, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x6a, 0xcf, 0xe9, 0xa9, 0x03, 0x00, 0x00, -} - -func (m *GenesisState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LastBidId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastBidId)) - i-- - dAtA[i] = 0x30 - } - if m.LastAuctionId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastAuctionId)) - i-- - dAtA[i] = 0x28 - } - if len(m.TokenPrices) > 0 { - for iNdEx := len(m.TokenPrices) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.TokenPrices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.Bids) > 0 { - for iNdEx := len(m.Bids) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Bids[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Auctions) > 0 { - for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.MinimumAuctionHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.MinimumAuctionHeight)) - i-- - dAtA[i] = 0x30 - } - { - size := m.AuctionPriceDecreaseAccelerationRate.Size() - i -= size - if _, err := m.AuctionPriceDecreaseAccelerationRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.AuctionMaxBlockAge != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.AuctionMaxBlockAge)) - i-- - dAtA[i] = 0x20 - } - { - size := m.MinimumSaleTokensUsdValue.Size() - i -= size - if _, err := m.MinimumSaleTokensUsdValue.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.MinimumBidInUsomm != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.MinimumBidInUsomm)) - i-- - dAtA[i] = 0x10 - } - if m.PriceMaxBlockAge != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.PriceMaxBlockAge)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - if len(m.Auctions) > 0 { - for _, e := range m.Auctions { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.Bids) > 0 { - for _, e := range m.Bids { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.TokenPrices) > 0 { - for _, e := range m.TokenPrices { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.LastAuctionId != 0 { - n += 1 + sovGenesis(uint64(m.LastAuctionId)) - } - if m.LastBidId != 0 { - n += 1 + sovGenesis(uint64(m.LastBidId)) - } - return n -} - -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PriceMaxBlockAge != 0 { - n += 1 + sovGenesis(uint64(m.PriceMaxBlockAge)) - } - if m.MinimumBidInUsomm != 0 { - n += 1 + sovGenesis(uint64(m.MinimumBidInUsomm)) - } - l = m.MinimumSaleTokensUsdValue.Size() - n += 1 + l + sovGenesis(uint64(l)) - if m.AuctionMaxBlockAge != 0 { - n += 1 + sovGenesis(uint64(m.AuctionMaxBlockAge)) - } - l = m.AuctionPriceDecreaseAccelerationRate.Size() - n += 1 + l + sovGenesis(uint64(l)) - if m.MinimumAuctionHeight != 0 { - n += 1 + sovGenesis(uint64(m.MinimumAuctionHeight)) - } - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GenesisState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Auctions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Auctions = append(m.Auctions, &Auction{}) - if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Bids = append(m.Bids, &Bid{}) - if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenPrices", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TokenPrices = append(m.TokenPrices, &TokenPrice{}) - if err := m.TokenPrices[len(m.TokenPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastAuctionId", wireType) - } - m.LastAuctionId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastAuctionId |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastBidId", wireType) - } - m.LastBidId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastBidId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceMaxBlockAge", wireType) - } - m.PriceMaxBlockAge = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PriceMaxBlockAge |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumBidInUsomm", wireType) - } - m.MinimumBidInUsomm = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinimumBidInUsomm |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumSaleTokensUsdValue", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinimumSaleTokensUsdValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AuctionMaxBlockAge", wireType) - } - m.AuctionMaxBlockAge = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AuctionMaxBlockAge |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AuctionPriceDecreaseAccelerationRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AuctionPriceDecreaseAccelerationRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumAuctionHeight", wireType) - } - m.MinimumAuctionHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinimumAuctionHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenesis(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/auction/migrations/v1/types/keys.go b/x/auction/migrations/v1/types/keys.go deleted file mode 100644 index cb0756d25..000000000 --- a/x/auction/migrations/v1/types/keys.go +++ /dev/null @@ -1,105 +0,0 @@ -package types - -import ( - "encoding/binary" -) - -const ( - // ModuleName is the module name constant used in many places - ModuleName = "auction" - - // StoreKey is the store key string for auction - StoreKey = ModuleName - - // RouterKey is the message route for auction - RouterKey = ModuleName - - // QuerierRoute is the querier route for auction - QuerierRoute = ModuleName -) - -// Keys for auction store, with -> -const ( - _ = byte(iota) - - // - ActiveAuctionsPrefix - - // - EndedAuctionsPrefix - - // - BidsByAuctionPrefix - - // - TokenPricesPrefix - - // - LastAuctionIDKey - - // - LastBidIDKey -) - -// GetActiveAuctionsPrefix returns the key prefix for active auctions -func GetActiveAuctionsPrefix() []byte { - return []byte{ActiveAuctionsPrefix} -} - -// GetActiveAuctionKey returns the key for an active auction -func GetActiveAuctionKey(id uint32) []byte { - b := make([]byte, 4) - binary.BigEndian.PutUint32(b, id) - return append(GetActiveAuctionsPrefix(), b...) -} - -// GetEndedAuctionsPrefix returns the key prefix for ended auctions -func GetEndedAuctionsPrefix() []byte { - return []byte{EndedAuctionsPrefix} -} - -// GetEndedAuctionsKey returns the key for an ended auction -func GetEndedAuctionKey(id uint32) []byte { - b := make([]byte, 4) - binary.BigEndian.PutUint32(b, id) - return append(GetEndedAuctionsPrefix(), b...) -} - -// GetBidsByAuctionPrefix returns the key prefix for bids -func GetBidsByAuctionPrefix() []byte { - return []byte{BidsByAuctionPrefix} -} - -// GetBidsByAuctionIDPrefix returns the bids for an auction id -func GetBidsByAuctionIDPrefix(auctionID uint32) []byte { - b := make([]byte, 4) - binary.BigEndian.PutUint32(b, auctionID) - return append(GetBidsByAuctionPrefix(), b...) -} - -// GetBidKey returns the bid for an auction and bid id -func GetBidKey(auctionID uint32, bidID uint64) []byte { - b := make([]byte, 8) - binary.BigEndian.PutUint64(b, bidID) - return append(GetBidsByAuctionIDPrefix(auctionID), b...) -} - -// GetTokenPricesPrefix returns the key prefix for token prices -func GetTokenPricesPrefix() []byte { - return []byte{TokenPricesPrefix} -} - -// GetTokenPriceKey returns the key for a token price -func GetTokenPriceKey(denom string) []byte { - return append(GetTokenPricesPrefix(), []byte(denom)...) -} - -// GetLastAuctionIDKey returns the key prefix for the last stored auction id -func GetLastAuctionIDKey() []byte { - return []byte{LastAuctionIDKey} -} - -// GetLastBidIDKey returns the key prefix for the last stored bid id -func GetLastBidIDKey() []byte { - return []byte{LastBidIDKey} -} diff --git a/x/auction/migrations/v1/types/params.go b/x/auction/migrations/v1/types/params.go deleted file mode 100644 index 5d06e4159..000000000 --- a/x/auction/migrations/v1/types/params.go +++ /dev/null @@ -1,141 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -// Parameter keys -var ( - KeyPriceMaxBlockAge = []byte("PriceMaxBlockAge") - KeyMinimumBidInUsomm = []byte("MinimumBidInUsomm") - KeyMinimumSaleTokensUSDValue = []byte("MinimumSaleTokensUSDValue") - KeyAuctionMaxBlockAge = []byte("AuctionMaxBlockAge") - KeyAuctionPriceDecreaseAccelerationRate = []byte("AuctionPriceDecreaseAccelerationRate") - KeyMinimumAuctionHeight = []byte("MinimumAuctionHeight") -) - -var _ paramtypes.ParamSet = &Params{} - -// ParamKeyTable returns the parameter key table. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// DefaultParams returns default auction parameters -func DefaultParams() Params { - return Params{ - PriceMaxBlockAge: 806400, // roughly eight weeks based on 6 second blocks - MinimumBidInUsomm: 1000000, // 1 somm - MinimumSaleTokensUsdValue: sdk.MustNewDecFromStr("1.0"), // unimplemented currently -- minimum value of sale tokens to consider starting an auction - AuctionMaxBlockAge: 864000, // roughly 60 days based on 6 second blocks - AuctionPriceDecreaseAccelerationRate: sdk.MustNewDecFromStr("0.001"), // 0.1% - MinimumAuctionHeight: 0, // do not run auctions before this block height - } -} - -// ParamSetPairs returns the parameter set pairs. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyPriceMaxBlockAge, &p.PriceMaxBlockAge, validatePriceMaxBlockAge), - paramtypes.NewParamSetPair(KeyMinimumBidInUsomm, &p.MinimumBidInUsomm, validateMinimumBidInUsomm), - paramtypes.NewParamSetPair(KeyMinimumSaleTokensUSDValue, &p.MinimumSaleTokensUsdValue, validateMinimumSaleTokensUSDValue), - paramtypes.NewParamSetPair(KeyAuctionMaxBlockAge, &p.AuctionMaxBlockAge, validateAuctionMaxBlockAge), - paramtypes.NewParamSetPair(KeyAuctionPriceDecreaseAccelerationRate, &p.AuctionPriceDecreaseAccelerationRate, validateAuctionPriceDecreaseAccelerationRate), - paramtypes.NewParamSetPair(KeyMinimumAuctionHeight, &p.MinimumAuctionHeight, validateMinimumAuctionHeight), - } -} - -// ValidateBasic performs basic validation on auction parameters. -func (p *Params) ValidateBasic() error { - if err := validatePriceMaxBlockAge(p.PriceMaxBlockAge); err != nil { - return err - } - - if err := validateMinimumBidInUsomm(p.MinimumBidInUsomm); err != nil { - return err - } - - if err := validateMinimumSaleTokensUSDValue(p.MinimumSaleTokensUsdValue); err != nil { - return err - } - - if err := validateAuctionMaxBlockAge(p.AuctionMaxBlockAge); err != nil { - return err - } - - if err := validateAuctionPriceDecreaseAccelerationRate(p.AuctionPriceDecreaseAccelerationRate); err != nil { - return err - } - - return nil -} - -func validatePriceMaxBlockAge(i interface{}) error { - priceMaxBlockAge, ok := i.(uint64) - if !ok { - return errorsmod.Wrapf(ErrInvalidPriceMaxBlockAgeParameterType, "type: %T", i) - } - - if priceMaxBlockAge == 0 { - return errorsmod.Wrapf(ErrTokenPriceMaxBlockAgeMustBePositive, "value: %d", priceMaxBlockAge) - } - - return nil -} - -func validateMinimumBidInUsomm(i interface{}) error { - _, ok := i.(uint64) - if !ok { - return errorsmod.Wrapf(ErrMinimumBidParam, "invalid minimum bid in usomm parameter type: %T", i) - } - - return nil -} - -func validateMinimumSaleTokensUSDValue(i interface{}) error { - minimumSaleTokensUsdValue, ok := i.(sdk.Dec) - if !ok { - return errorsmod.Wrapf(ErrInvalidMinimumSaleTokensUSDValue, "invalid minimum sale tokens USD value parameter type: %T", i) - } - - if minimumSaleTokensUsdValue.LT(sdk.MustNewDecFromStr("1.0")) { - // Setting this to a minimum of 1.0 USD to ensure we can realistically charge a non-fractional usomm value - return errorsmod.Wrapf(ErrInvalidMinimumSaleTokensUSDValue, "minimum sale tokens USD value must be at least 1.0") - } - - return nil -} - -func validateAuctionMaxBlockAge(i interface{}) error { - _, ok := i.(uint64) - if !ok { - return errorsmod.Wrapf(ErrInvalidAuctionMaxBlockAgeParam, "invalid auction max block age parameter type: %T", i) - } - - return nil -} - -func validateAuctionPriceDecreaseAccelerationRate(i interface{}) error { - auctionPriceDecreaseAccelerationRate, ok := i.(sdk.Dec) - if !ok { - return errorsmod.Wrapf(ErrInvalidAuctionPriceDecreaseAccelerationRateParam, "invalid auction price decrease acceleration rate parameter type: %T", i) - } - - if auctionPriceDecreaseAccelerationRate.LT(sdk.MustNewDecFromStr("0")) || auctionPriceDecreaseAccelerationRate.GT(sdk.MustNewDecFromStr("1.0")) { - // Acceleration rates could in theory be more than 100% if need be, but we are establishing this as a bound for now - return errorsmod.Wrapf(ErrInvalidAuctionPriceDecreaseAccelerationRateParam, "auction price decrease acceleration rate must be between 0 and 1 inclusive (0%% to 100%%)") - } - - return nil -} - -func validateMinimumAuctionHeight(i interface{}) error { - _, ok := i.(uint64) - if !ok { - return errorsmod.Wrapf(ErrInvalidMinimumAuctionHeightParam, "invalid minimum auction height parameter type: %T", i) - } - - return nil -} diff --git a/x/axelarcork/keeper/genesis.go b/x/axelarcork/keeper/genesis.go index 55e044191..fa5cdfcc7 100644 --- a/x/axelarcork/keeper/genesis.go +++ b/x/axelarcork/keeper/genesis.go @@ -74,8 +74,11 @@ func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) { func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState { var gs types.GenesisState + // These fields are nil by default, so we need to initialize them ps := k.GetParamSet(ctx) gs.Params = &ps + gs.CorkResults = &types.AxelarCorkResults{} + gs.ScheduledCorks = &types.ScheduledAxelarCorks{} k.IterateChainConfigurations(ctx, func(config types.ChainConfiguration) (stop bool) { gs.ChainConfigurations.Configurations = append(gs.ChainConfigurations.Configurations, &config) diff --git a/x/cellarfees/keeper/keeper.go b/x/cellarfees/keeper/keeper.go index c24be7a2b..52d967470 100644 --- a/x/cellarfees/keeper/keeper.go +++ b/x/cellarfees/keeper/keeper.go @@ -67,6 +67,12 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { return p } +func (k Keeper) GetParamSetIfExists(ctx sdk.Context) types.Params { + var p types.Params + k.paramSpace.GetParamSetIfExists(ctx, &p) + return p +} + func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } diff --git a/x/cellarfees/keeper/migrations.go b/x/cellarfees/keeper/migrations.go index 96f2c04f5..423284bd6 100644 --- a/x/cellarfees/keeper/migrations.go +++ b/x/cellarfees/keeper/migrations.go @@ -2,20 +2,40 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" v1 "github.com/peggyjv/sommelier/v8/x/cellarfees/migrations/v1" + v2 "github.com/peggyjv/sommelier/v8/x/cellarfees/types/v2" ) // Migrator is a struct for handling in-place store migrations. type Migrator struct { - keeper Keeper + keeper Keeper + legacySubspace paramtypes.Subspace } // NewMigrator returns a new Migrator. -func NewMigrator(keeper Keeper) Migrator { - return Migrator{keeper: keeper} +func NewMigrator(keeper Keeper, legacySubspace paramtypes.Subspace) Migrator { + return Migrator{keeper: keeper, legacySubspace: legacySubspace} } // Migrate1to2 migrates from consensus version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v1.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.keeper.paramSpace) + currentParams := m.keeper.GetParamSetIfExists(ctx) + params := v2.Params{ + AuctionInterval: currentParams.AuctionInterval, + InitialPriceDecreaseRate: currentParams.InitialPriceDecreaseRate, + PriceDecreaseBlockInterval: currentParams.PriceDecreaseBlockInterval, + RewardEmissionPeriod: currentParams.RewardEmissionPeriod, + AuctionThresholdUsdValue: sdk.MustNewDecFromStr(v2.DefaultAuctionThresholdUsdValue), + } + + if err := params.ValidateBasic(); err != nil { + return err + } + + m.keeper.SetParams(ctx, params) + + v1.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.legacySubspace) + + return nil } diff --git a/x/cellarfees/migrations/v1/store.go b/x/cellarfees/migrations/v1/store.go index 1d4e8cd79..637f92491 100644 --- a/x/cellarfees/migrations/v1/store.go +++ b/x/cellarfees/migrations/v1/store.go @@ -5,51 +5,18 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - v1types "github.com/peggyjv/sommelier/v8/x/cellarfees/migrations/v1/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/peggyjv/sommelier/v8/x/cellarfees/types" - v2types "github.com/peggyjv/sommelier/v8/x/cellarfees/types/v2" ) -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, paramSubspace paramstypes.Subspace) error { +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, legacySubspace paramtypes.Subspace) { ctx.Logger().Info("cellarfees v1 to v2: Beginning store migration") store := ctx.KVStore(storeKey) - err := migrateParamStore(ctx, paramSubspace) - if err != nil { - return err - } migrateCellarfeesFeeAccrualCounters(ctx, store) ctx.Logger().Info("cellarfees v1 to v2: Store migration complete") - - return nil -} - -func migrateParamStore(ctx sdk.Context, subspace paramstypes.Subspace) error { - ctx.Logger().Info("cellarfees v1 to v2: Migrating params") - - oldParamSet := &v1types.Params{} - subspace.GetParamSet(ctx, oldParamSet) - - newParamSet := &v2types.Params{} - newParamSet.AuctionThresholdUsdValue = v2types.DefaultParams().AuctionThresholdUsdValue - newParamSet.AuctionInterval = oldParamSet.AuctionInterval - newParamSet.InitialPriceDecreaseRate = oldParamSet.InitialPriceDecreaseRate - newParamSet.PriceDecreaseBlockInterval = oldParamSet.PriceDecreaseBlockInterval - newParamSet.RewardEmissionPeriod = oldParamSet.RewardEmissionPeriod - - err := newParamSet.ValidateBasic() - if err != nil { - return err - } - - // (Collin): Does this actually delete the old FeeAccrualCounters key? Does it matter? - subspace.SetParamSet(ctx, newParamSet) - - ctx.Logger().Info("cellarfees v1 to v2: Params migration complete") - return nil } // Removes the old FeeAccrualCounters state diff --git a/x/cellarfees/module.go b/x/cellarfees/module.go index 6ca4e66a1..a9357f807 100644 --- a/x/cellarfees/module.go +++ b/x/cellarfees/module.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" sim "github.com/cosmos/cosmos-sdk/types/simulation" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/peggyjv/sommelier/v8/x/cellarfees/client/cli" "github.com/peggyjv/sommelier/v8/x/cellarfees/keeper" @@ -83,11 +84,14 @@ type AppModule struct { mintKeeper types.MintKeeper corkKeeper types.CorkKeeper auctionKeeper types.AuctionKeeper + + // legacy subspace used for v1 -> v2 migration + legacySubspace paramtypes.Subspace } // NewAppModule creates a new AppModule object func NewAppModule(keeper keeper.Keeper, cdc codec.Codec, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, - mintKeeper types.MintKeeper, corkKeeper types.CorkKeeper, auctionKeeper types.AuctionKeeper) AppModule { + mintKeeper types.MintKeeper, corkKeeper types.CorkKeeper, auctionKeeper types.AuctionKeeper, legacySubspace paramtypes.Subspace) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: keeper, @@ -97,6 +101,7 @@ func NewAppModule(keeper keeper.Keeper, cdc codec.Codec, accountKeeper types.Acc mintKeeper: mintKeeper, corkKeeper: corkKeeper, auctionKeeper: auctionKeeper, + legacySubspace: legacySubspace, } } @@ -123,7 +128,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { //types.RegisterMsgServer(cfg.MsgServer(), am.keeper) typesv2.RegisterQueryServer(cfg.QueryServer(), am.keeper) - migrator := keeper.NewMigrator(am.keeper) + migrator := keeper.NewMigrator(am.keeper, am.legacySubspace) if err := cfg.RegisterMigration(types.ModuleName, 1, migrator.Migrate1to2); err != nil { panic(fmt.Sprintf("failed to migrate x/cellarfees from version 1 to 2: %v", err)) } diff --git a/x/cellarfees/types/v1/errors.go b/x/cellarfees/types/v1/errors.go new file mode 100644 index 000000000..e33cdbfb5 --- /dev/null +++ b/x/cellarfees/types/v1/errors.go @@ -0,0 +1,16 @@ +package v1 + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/cellarfees module sentinel errors +var ( + ErrInvalidFeeAccrualAuctionThreshold = errorsmod.Register("cellarfees", 2, "invalid fee accrual auction threshold") + ErrInvalidRewardEmissionPeriod = errorsmod.Register("cellarfees", 3, "invalid reward emission period") + ErrInvalidInitialPriceDecreaseRate = errorsmod.Register("cellarfees", 4, "invalid initial price decrease rate") + ErrInvalidPriceDecreaseBlockInterval = errorsmod.Register("cellarfees", 5, "invalid price decrease block interval") + ErrInvalidFeeAccrualCounters = errorsmod.Register("cellarfees", 6, "invalid fee accrual counters") + ErrInvalidLastRewardSupplyPeak = errorsmod.Register("cellarfees", 7, "invalid last reward supply peak") + ErrInvalidAuctionInterval = errorsmod.Register("cellarfees", 8, "invalid interval blocks between auctions") +) diff --git a/x/cellarfees/types/v1/params.go b/x/cellarfees/types/v1/params.go index 7f383094a..1e50b46cd 100644 --- a/x/cellarfees/types/v1/params.go +++ b/x/cellarfees/types/v1/params.go @@ -1,6 +1,149 @@ package v1 -import "gopkg.in/yaml.v2" +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +const ( + DefaultFeeAccrualAuctionThreshold uint64 = 2 + // Rough number of blocks in 28 days, the time it takes to unbond + DefaultRewardEmissionPeriod uint64 = 403200 + // Initial rate at which an auction should decrease the price of the relevant coin from it's starting price. + // This value was determined experimentally. It is the initial rate at which it takes ~48 hours for the unit + // price to hit 0 usomm, assuming a decrease acceleration rate of 0.001. + DefaultInitialPriceDecreaseRate string = "0.0000648" + // Blocks between each auction price decrease + DefaultPriceDecreaseBlockInterval uint64 = 10 + // Blocks between each auction + DefaultAuctionInterval uint64 = 15000 +) + +// Parameter keys +var ( + KeyFeeAccrualAuctionThreshold = []byte("FeeAccrualAuctionThreshold") + KeyRewardEmissionPeriod = []byte("RewardEmissionPeriod") + KeyInitialPriceDecreaseRate = []byte("InitialPriceDecreaseRate") + KeyPriceDecreaseBlockInterval = []byte("PriceDecreaseBlockInterval") + KeyAuctionInterval = []byte("AuctionInterval") +) + +var _ paramtypes.ParamSet = &Params{} + +// ParamKeyTable returns the parameter key table. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// DefaultParams returns default cellarfees parameters +func DefaultParams() Params { + return Params{ + FeeAccrualAuctionThreshold: DefaultFeeAccrualAuctionThreshold, + RewardEmissionPeriod: DefaultRewardEmissionPeriod, + InitialPriceDecreaseRate: sdk.MustNewDecFromStr(DefaultInitialPriceDecreaseRate), + PriceDecreaseBlockInterval: DefaultPriceDecreaseBlockInterval, + AuctionInterval: DefaultAuctionInterval, + } +} + +// ParamSetPairs returns the parameter set pairs. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyFeeAccrualAuctionThreshold, &p.FeeAccrualAuctionThreshold, validateFeeAccrualAuctionThreshold), + paramtypes.NewParamSetPair(KeyRewardEmissionPeriod, &p.RewardEmissionPeriod, validateRewardEmissionPeriod), + paramtypes.NewParamSetPair(KeyInitialPriceDecreaseRate, &p.InitialPriceDecreaseRate, validateInitialPriceDecreaseRate), + paramtypes.NewParamSetPair(KeyPriceDecreaseBlockInterval, &p.PriceDecreaseBlockInterval, validatePriceDecreaseBlockInterval), + paramtypes.NewParamSetPair(KeyAuctionInterval, &p.AuctionInterval, validateAuctionInterval), + } +} + +// ValidateBasic performs basic validation on cellarfees parameters. +func (p *Params) ValidateBasic() error { + if err := validateFeeAccrualAuctionThreshold(p.FeeAccrualAuctionThreshold); err != nil { + return err + } + if err := validateRewardEmissionPeriod(p.RewardEmissionPeriod); err != nil { + return err + } + if err := validateInitialPriceDecreaseRate(p.InitialPriceDecreaseRate); err != nil { + return err + } + if err := validatePriceDecreaseBlockInterval(p.PriceDecreaseBlockInterval); err != nil { + return err + } + return nil +} + +func validateFeeAccrualAuctionThreshold(i interface{}) error { + threshold, ok := i.(uint64) + if !ok { + return errorsmod.Wrapf(ErrInvalidFeeAccrualAuctionThreshold, "fee accrual auction threshold: %T", i) + } + + if threshold == 0 { + return errorsmod.Wrapf(ErrInvalidFeeAccrualAuctionThreshold, "fee accrual auction threshold cannot be zero") + } + + return nil +} + +func validateRewardEmissionPeriod(i interface{}) error { + emissionPeriod, ok := i.(uint64) + if !ok { + return errorsmod.Wrapf(ErrInvalidRewardEmissionPeriod, "reward emission period: %T", i) + } + + if emissionPeriod == 0 { + return errorsmod.Wrapf(ErrInvalidRewardEmissionPeriod, "reward emission period cannot be zero") + } + + return nil +} + +func validateInitialPriceDecreaseRate(i interface{}) error { + rate, ok := i.(sdk.Dec) + if !ok { + return errorsmod.Wrapf(ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate: %T", i) + } + + if rate == sdk.ZeroDec() { + return errorsmod.Wrapf(ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate cannot be zero, must be 0 < x < 1") + } + + if rate == sdk.OneDec() { + return errorsmod.Wrapf(ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate cannot be one, must be 0 < x < 1") + } + + return nil +} + +func validatePriceDecreaseBlockInterval(i interface{}) error { + interval, ok := i.(uint64) + if !ok { + return errorsmod.Wrapf(ErrInvalidPriceDecreaseBlockInterval, "price decrease block interval: %T", i) + } + + if interval == 0 { + return errorsmod.Wrapf(ErrInvalidPriceDecreaseBlockInterval, "price decrease block interval cannot be zero") + } + + return nil +} + +func validateAuctionInterval(i interface{}) error { + interval, ok := i.(uint64) + if !ok { + return errorsmod.Wrapf(ErrInvalidAuctionInterval, "auction interval: %T", i) + } + + if interval == 0 { + return errorsmod.Wrapf(ErrInvalidAuctionInterval, "auction interval cannot be zero") + } + + return nil +} // String implements the String interface func (p Params) String() string { diff --git a/x/cellarfees/types/v2/params.go b/x/cellarfees/types/v2/params.go index 2630e3b78..5ac534b05 100644 --- a/x/cellarfees/types/v2/params.go +++ b/x/cellarfees/types/v2/params.go @@ -73,6 +73,13 @@ func (p *Params) ValidateBasic() error { if err := validatePriceDecreaseBlockInterval(p.PriceDecreaseBlockInterval); err != nil { return err } + if err := validateAuctionInterval(p.AuctionInterval); err != nil { + return err + } + if err := validateAuctionThresholdUsdValue(p.AuctionThresholdUsdValue); err != nil { + return err + } + return nil } @@ -95,12 +102,12 @@ func validateInitialPriceDecreaseRate(i interface{}) error { return errorsmod.Wrapf(types.ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate: %T", i) } - if rate == sdk.ZeroDec() { - return errorsmod.Wrapf(types.ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate cannot be zero, must be 0 < x < 1") + if rate.LTE(sdk.ZeroDec()) { + return errorsmod.Wrapf(types.ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate cannot be zero or negative,must be 0 < x < 1") } - if rate == sdk.OneDec() { - return errorsmod.Wrapf(types.ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate cannot be one, must be 0 < x < 1") + if rate.GTE(sdk.OneDec()) { + return errorsmod.Wrapf(types.ErrInvalidInitialPriceDecreaseRate, "initial price decrease rate cannot be one or greater, must be 0 < x < 1") } return nil diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go index c5289ef39..adbb215a9 100644 --- a/x/incentives/keeper/keeper.go +++ b/x/incentives/keeper/keeper.go @@ -55,6 +55,12 @@ func (k Keeper) GetParamSet(ctx sdk.Context) types.Params { return p } +func (k Keeper) GetParamSetIfExists(ctx sdk.Context) types.Params { + var p types.Params + k.paramSpace.GetParamSetIfExists(ctx, &p) + return p +} + // setParams sets the parameters in the store func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) diff --git a/x/incentives/keeper/migrations.go b/x/incentives/keeper/migrations.go index 3e6245faa..506ebe2ed 100644 --- a/x/incentives/keeper/migrations.go +++ b/x/incentives/keeper/migrations.go @@ -17,10 +17,28 @@ func NewMigrator(keeper Keeper) Migrator { // Migrate1to2 migrates from consensus version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - currentParams := m.keeper.GetParamSet(ctx) - params := types.DefaultParams() - params.IncentivesCutoffHeight = currentParams.IncentivesCutoffHeight - params.DistributionPerBlock = currentParams.DistributionPerBlock - m.keeper.paramSpace.SetParamSet(ctx, ¶ms) + ctx.Logger().Info("incentives v1 to v2: New params") + + // New params + subspace := m.keeper.paramSpace + + if !subspace.Has(ctx, types.KeyValidatorIncentivesCutoffHeight) { + subspace.Set(ctx, types.KeyValidatorIncentivesCutoffHeight, types.DefaultParams().ValidatorIncentivesCutoffHeight) + } + + if !subspace.Has(ctx, types.KeyValidatorMaxDistributionPerBlock) { + subspace.Set(ctx, types.KeyValidatorMaxDistributionPerBlock, types.DefaultParams().ValidatorMaxDistributionPerBlock) + } + + if !subspace.Has(ctx, types.KeyValidatorIncentivesMaxFraction) { + subspace.Set(ctx, types.KeyValidatorIncentivesMaxFraction, types.DefaultParams().ValidatorIncentivesMaxFraction) + } + + if !subspace.Has(ctx, types.KeyValidatorIncentivesSetSizeLimit) { + subspace.Set(ctx, types.KeyValidatorIncentivesSetSizeLimit, types.DefaultParams().ValidatorIncentivesSetSizeLimit) + } + + ctx.Logger().Info("incentives v1 to v2: Params migration complete") + return nil }