From c5fdbff62b6fdf891bea2e11ff6d7d2195b9dd31 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Fri, 30 Jun 2023 21:46:39 +0530 Subject: [PATCH 1/7] update readme with v0.11.0 upgrade details (#69) --- readme.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 0b3d8bdc..beb18014 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.19.3 ``` git clone https://github.com/Omniflix/omniflixhub.git cd omniflixhub -git checkout v0.10.1 +git checkout v0.11.1 go mod tidy make install ``` @@ -48,11 +48,14 @@ curl https://raw.githubusercontent.com/OmniFlix/mainnet/main/omniflixhub-1/genes ### Snapshots - - Check [c29r3/cosmos-snapshots](https://github.com/c29r3/cosmos-snapshots) repository for omniflixhub snapshots + - [c29r3/cosmos-snapshots](https://github.com/c29r3/cosmos-snapshots) repository for omniflixhub snapshots + - [polkachu snapshot](https://polkachu.com/tendermint_snapshots/omniflix) + - [NodeStake snapshot](https://nodestake.top/omniflix) ### OmniFlix Modules - [oNFT](https://github.com/OmniFlix/onft) - [Marketplace](https://github.com/OmniFlix/marketplace) +- [StreamPay](https://github.com/OmniFlix/streampay) ### Documentation @@ -65,7 +68,7 @@ curl https://raw.githubusercontent.com/OmniFlix/mainnet/main/omniflixhub-1/genes ## Upgrades - [upgrade_1](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/upgrade_1.md) at block 4175400 - [v0.10.0](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v0.10.0-upgrade.md) at block 6262420 - - [v0.11.0](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v0.11.0-upgrade.md) at block `TBU` + - [v0.11.0](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v0.11.0-upgrade.md) at block 7339200 ### Testnets From 9e7cc2282f4b195151dbccda9655e23adaeccdcb Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Wed, 19 Jul 2023 12:01:18 +0530 Subject: [PATCH 2/7] feat: add ica host module (#72) --- app/app.go | 24 ++++++++++++++++++--- app/upgrades.go | 57 ++++++++++++++++++++++--------------------------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/app/app.go b/app/app.go index eaac6836..96c52a8b 100644 --- a/app/app.go +++ b/app/app.go @@ -79,6 +79,11 @@ import ( upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" + icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" "github.com/cosmos/ibc-go/v4/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" @@ -152,6 +157,7 @@ var ( crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, ibc.AppModuleBasic{}, + ica.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, authzmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, @@ -176,6 +182,7 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + icatypes.ModuleName: nil, alloctypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, onfttypes.ModuleName: nil, marketplacetypes.ModuleName: nil, @@ -228,6 +235,7 @@ type App struct { UpgradeKeeper upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + ICAHostKeeper icahostkeeper.Keeper EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper @@ -290,6 +298,7 @@ func NewOmniFlixApp( upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, + icahosttypes.StoreKey, capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, @@ -324,6 +333,7 @@ func NewOmniFlixApp( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( @@ -439,7 +449,7 @@ func NewOmniFlixApp( transferModule := transfer.NewAppModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - /* app.ICAHostKeeper = icahostkeeper.NewKeeper( + app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), @@ -450,7 +460,7 @@ func NewOmniFlixApp( app.MsgServiceRouter(), ) icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) - icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) */ + icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( @@ -533,7 +543,10 @@ func NewOmniFlixApp( // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + ibcRouter. + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). + AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -566,6 +579,7 @@ func NewOmniFlixApp( evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), + icaModule, transferModule, allocModule, @@ -594,6 +608,7 @@ func NewOmniFlixApp( govtypes.ModuleName, paramstypes.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, authtypes.ModuleName, @@ -618,6 +633,7 @@ func NewOmniFlixApp( vestingtypes.ModuleName, paramstypes.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, minttypes.ModuleName, slashingtypes.ModuleName, distrtypes.ModuleName, @@ -655,6 +671,7 @@ func NewOmniFlixApp( feegrant.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, + icatypes.ModuleName, alloctypes.ModuleName, onfttypes.ModuleName, marketplacetypes.ModuleName, @@ -878,6 +895,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(alloctypes.ModuleName) paramsKeeper.Subspace(onfttypes.ModuleName) paramsKeeper.Subspace(marketplacetypes.ModuleName) diff --git a/app/upgrades.go b/app/upgrades.go index 18970ce1..320077a2 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -3,21 +3,19 @@ package app import ( "fmt" - appparams "github.com/OmniFlix/omniflixhub/app/params" - - itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" - - maketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" - streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" - store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" ) // next upgrade name -const upgradeName = "v0.11.0" +const upgradeName = "v2" // RegisterUpgradeHandlers returns upgrade handlers func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { @@ -25,30 +23,27 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("running migrations ...") - // Run migrations before applying any other state changes. - versionMap, err := app.mm.RunMigrations(ctx, cfg, fromVM) - if err != nil { - return nil, err - } - // update marketplace module new parameters - marketplaceParamSubspace, ok := app.ParamsKeeper.GetSubspace(maketplacetypes.ModuleName) - if !ok { - panic("marketplace params subspace not found") - } - marketplaceParamSubspace.Set( - ctx, - maketplacetypes.ParamStoreKeyMaxAuctionDuration, - maketplacetypes.DefaultMaxAuctionDuration, - ) - // set streampay params - streampayParams := streampaytypes.DefaultParams() - streampayParams.StreamPaymentFee = sdk.NewInt64Coin(appparams.BondDenom, 50_000_000) - app.StreamPayKeeper.SetParams(ctx, streampayParams) - // set itc module params - app.ItcKeeper.SetParams(ctx, itctypes.DefaultParams()) + // create ICS27 Host submodule params + hostParams := icahosttypes.Params{ + HostEnabled: true, + AllowMessages: []string{ + sdk.MsgTypeURL(&banktypes.MsgSend{}), + sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), + sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), + sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), + sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), + sdk.MsgTypeURL(&govtypes.MsgVote{}), + }, + } + app.ICAHostKeeper.SetParams(ctx, hostParams) - return versionMap, nil + return app.mm.RunMigrations(ctx, cfg, fromVM) }) upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() @@ -58,7 +53,7 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := store.StoreUpgrades{ - Added: []string{streampaytypes.ModuleName, itctypes.ModuleName}, + Added: []string{icahosttypes.StoreKey}, } // configure store loader that checks if height == upgradeHeight and applies store upgrades app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) From 342f24bc65b78b9699580264898c15eaa938b4c5 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Wed, 19 Jul 2023 19:35:31 +0530 Subject: [PATCH 3/7] refactor app (#73) * add keepers and keys in seperate directory * refactor: refactor app (seperate keepers and modules) * fix issues --- app/app.go | 740 +++++----------------------------- app/apptesting/test_suite.go | 2 +- app/export.go | 41 +- app/forks.go | 15 + app/keepers/keepers.go | 398 ++++++++++++++++++ app/keepers/keys.go | 91 +++++ app/modules.go | 299 ++++++++++++++ app/sim_test.go | 150 ------- app/state.go | 246 ----------- app/test_helpers.go | 24 +- app/types.go | 40 -- app/upgrades.go | 61 --- app/upgrades/types.go | 48 +++ app/upgrades/v2/constants.go | 17 + app/upgrades/v2/upgrades.go | 53 +++ cmd/omniflixhubd/cmd/root.go | 6 +- testutil/simapp/simapp.go | 2 +- x/alloc/keeper/keeper_test.go | 2 +- 18 files changed, 1067 insertions(+), 1168 deletions(-) create mode 100644 app/forks.go create mode 100644 app/keepers/keepers.go create mode 100644 app/keepers/keys.go create mode 100644 app/modules.go delete mode 100644 app/sim_test.go delete mode 100644 app/state.go delete mode 100644 app/types.go delete mode 100644 app/upgrades.go create mode 100644 app/upgrades/types.go create mode 100644 app/upgrades/v2/constants.go create mode 100644 app/upgrades/v2/upgrades.go diff --git a/app/app.go b/app/app.go index 96c52a8b..6bd7a709 100644 --- a/app/app.go +++ b/app/app.go @@ -20,80 +20,21 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting" - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/x/authz" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" - "github.com/cosmos/cosmos-sdk/x/bank" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/crisis" - crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distr "github.com/cosmos/cosmos-sdk/x/distribution" distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" - "github.com/cosmos/cosmos-sdk/x/genutil" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/cosmos/cosmos-sdk/x/gov" 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" - "github.com/cosmos/cosmos-sdk/x/mint" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/cosmos/cosmos-sdk/x/slashing" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" - icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" - "github.com/cosmos/ibc-go/v4/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v4/modules/core" - ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" - ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" "github.com/spf13/cast" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" @@ -101,24 +42,10 @@ import ( tmos "github.com/tendermint/tendermint/libs/os" dbm "github.com/tendermint/tm-db" - "github.com/OmniFlix/marketplace/x/marketplace" - marketplacekeeper "github.com/OmniFlix/marketplace/x/marketplace/keeper" - marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" - "github.com/OmniFlix/omniflixhub/x/alloc" - allockeeper "github.com/OmniFlix/omniflixhub/x/alloc/keeper" - alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" - - "github.com/OmniFlix/onft" - onftkeeper "github.com/OmniFlix/onft/keeper" - onfttypes "github.com/OmniFlix/onft/types" - - "github.com/OmniFlix/streampay/v2/x/streampay" - streampaykeeper "github.com/OmniFlix/streampay/v2/x/streampay/keeper" - streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" - - "github.com/OmniFlix/omniflixhub/x/itc" - itckeeper "github.com/OmniFlix/omniflixhub/x/itc/keeper" - itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" + "github.com/OmniFlix/omniflixhub/app/keepers" + "github.com/OmniFlix/omniflixhub/app/upgrades" + v2 "github.com/OmniFlix/omniflixhub/app/upgrades/v2" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) const Name = "omniflixhub" @@ -140,128 +67,41 @@ func getGovProposalHandlers() []govclient.ProposalHandler { var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string - - // ModuleBasics defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration - // and genesis verification. - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - genutil.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic(getGovProposalHandlers()...), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - ibc.AppModuleBasic{}, - ica.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - transfer.AppModuleBasic{}, - vesting.AppModuleBasic{}, - - alloc.AppModuleBasic{}, - onft.AppModuleBasic{}, - marketplace.AppModuleBasic{}, - streampay.AppModuleBasic{}, - itc.AppModuleBasic{}, - // this line is used by starport scaffolding # stargate/app/moduleBasic - ) - - // module account permissions - maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - icatypes.ModuleName: nil, - alloctypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, - onfttypes.ModuleName: nil, - marketplacetypes.ModuleName: nil, - streampaytypes.ModuleName: nil, - itctypes.ModuleName: nil, - } + Upgrades = []upgrades.Upgrade{v2.Upgrade} + Forks []upgrades.Fork ) var ( - _ CosmosApp = (*App)(nil) - _ servertypes.Application = (*App)(nil) + _ simapp.App = (*OmniFlixApp)(nil) + _ servertypes.Application = (*OmniFlixApp)(nil) ) -func init() { - userHomeDir, err := os.UserHomeDir() - if err != nil { - panic(err) - } - - DefaultNodeHome = filepath.Join(userHomeDir, "."+Name) -} - -// App extends an ABCI application, but with most of its parameters exported. +// OmniFlixApp extends an ABCI application, but with most of its parameters exported. // They are exported for convenience in creating helper functions, as object // capabilities aren't needed for testing. -type App struct { +type OmniFlixApp struct { *baseapp.BaseApp + keepers.AppKeepers cdc *codec.LegacyAmino appCodec codec.Codec interfaceRegistry types.InterfaceRegistry + invCheckPeriod uint - invCheckPeriod uint - - // keys to access the substores - keys map[string]*sdk.KVStoreKey - tkeys map[string]*sdk.TransientStoreKey - memKeys map[string]*sdk.MemoryStoreKey - - // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - ICAHostKeeper icahostkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - AuthzKeeper authzkeeper.Keeper - - // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - - AllocKeeper allockeeper.Keeper - ONFTKeeper onftkeeper.Keeper - MarketplaceKeeper marketplacekeeper.Keeper - StreamPayKeeper streampaykeeper.Keeper - ItcKeeper itckeeper.Keeper - - // module manager - mm *module.Manager - - // simulation manager - sm *module.SimulationManager - - // configurator + mm *module.Manager + sm *module.SimulationManager configurator module.Configurator } +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, "."+Name) +} + // New returns a reference to an initialized app. func NewOmniFlixApp( @@ -275,7 +115,7 @@ func NewOmniFlixApp( encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), -) *App { +) *OmniFlixApp { appCodec := encodingConfig.Marshaler cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -285,270 +125,30 @@ func NewOmniFlixApp( bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - keys := sdk.NewKVStoreKeys( - authtypes.StoreKey, - banktypes.StoreKey, - stakingtypes.StoreKey, - minttypes.StoreKey, - distrtypes.StoreKey, - slashingtypes.StoreKey, - govtypes.StoreKey, - paramstypes.StoreKey, - ibchost.StoreKey, - upgradetypes.StoreKey, - evidencetypes.StoreKey, - ibctransfertypes.StoreKey, - icahosttypes.StoreKey, - capabilitytypes.StoreKey, - feegrant.StoreKey, - authzkeeper.StoreKey, - alloctypes.StoreKey, - onfttypes.StoreKey, - marketplacetypes.StoreKey, - streampaytypes.StoreKey, - itctypes.StoreKey, - ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - app := &App{ + app := &OmniFlixApp{ BaseApp: bApp, cdc: cdc, appCodec: appCodec, interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, - keys: keys, - tkeys: tkeys, - memKeys: memKeys, } - app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) - - // set the BaseApp's parameter store - bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) - - // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) - - // grant capabilities for the ibc and ibc-transfer modules - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) - scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + moduleAccountAddresses := app.ModuleAccountAddrs() - // add keepers - app.AccountKeeper = authkeeper.NewAccountKeeper( + // Setup keepers + app.AppKeepers = keepers.NewAppKeeper( appCodec, - keys[authtypes.StoreKey], - app.GetSubspace(authtypes.ModuleName), - authtypes.ProtoBaseAccount, + bApp, + cdc, maccPerms, - ) - app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, - keys[banktypes.StoreKey], - app.AccountKeeper, - app.GetSubspace(banktypes.ModuleName), - app.ModuleAccountAddrs(), - ) - app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], - appCodec, - app.BaseApp.MsgServiceRouter(), - ) - app.FeeGrantKeeper = feegrantkeeper.NewKeeper( - appCodec, - keys[feegrant.StoreKey], - app.AccountKeeper, - ) - stakingKeeper := stakingkeeper.NewKeeper( - appCodec, - keys[stakingtypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.GetSubspace(stakingtypes.ModuleName), - ) - app.MintKeeper = mintkeeper.NewKeeper( - appCodec, - keys[minttypes.StoreKey], - app.GetSubspace(minttypes.ModuleName), - &stakingKeeper, - app.AccountKeeper, - app.BankKeeper, - authtypes.FeeCollectorName, - ) - app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, - keys[distrtypes.StoreKey], - app.GetSubspace(distrtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - &stakingKeeper, - authtypes.FeeCollectorName, - app.ModuleAccountAddrs(), - ) - app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, - keys[slashingtypes.StoreKey], - &stakingKeeper, - app.GetSubspace(slashingtypes.ModuleName), - ) - - app.CrisisKeeper = crisiskeeper.NewKeeper( - app.GetSubspace(crisistypes.ModuleName), - invCheckPeriod, - app.BankKeeper, - authtypes.FeeCollectorName, - ) - app.UpgradeKeeper = upgradekeeper.NewKeeper( + moduleAccountAddresses, + app.BlockedAccountAddrs(), skipUpgradeHeights, - keys[upgradetypes.StoreKey], - appCodec, homePath, - app.BaseApp, - ) - - // register the staking hooks - // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.StakingKeeper = *stakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), - ) - - // ... other modules keepers - - // Create IBC Keeper - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, - keys[ibchost.StoreKey], - app.GetSubspace(ibchost.ModuleName), - app.StakingKeeper, - app.UpgradeKeeper, - scopedIBCKeeper, - ) - - // register the proposal types - govRouter := govtypes.NewRouter() - govRouter. - AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) - - // Create Transfer Keepers - app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, - keys[ibctransfertypes.StoreKey], - app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - app.AccountKeeper, - app.BankKeeper, - scopedTransferKeeper, - ) - transferModule := transfer.NewAppModule(app.TransferKeeper) - transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - - app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, - keys[icahosttypes.StoreKey], - app.GetSubspace(icahosttypes.SubModuleName), - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - app.AccountKeeper, - scopedICAHostKeeper, - app.MsgServiceRouter(), - ) - icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) - icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) - - // Create evidence Keeper for to register the IBC light client misbehaviour evidence route - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, - keys[evidencetypes.StoreKey], - &app.StakingKeeper, - app.SlashingKeeper, - ) - // If evidence needs to be handled for the app, set routes in router here and seal - app.EvidenceKeeper = *evidenceKeeper - - app.GovKeeper = govkeeper.NewKeeper( - appCodec, - keys[govtypes.StoreKey], - app.GetSubspace(govtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - &stakingKeeper, - govRouter, - ) - app.AllocKeeper = *allockeeper.NewKeeper( - appCodec, - keys[alloctypes.StoreKey], - keys[alloctypes.MemStoreKey], - - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - app.DistrKeeper, - app.GetSubspace(alloctypes.ModuleName), - ) - allocModule := alloc.NewAppModule(appCodec, app.AllocKeeper) - - app.ONFTKeeper = onftkeeper.NewKeeper( - appCodec, - keys[onfttypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.DistrKeeper, - app.GetSubspace(onfttypes.ModuleName), - ) - - onftModule := onft.NewAppModule(appCodec, app.ONFTKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper) - - app.MarketplaceKeeper = marketplacekeeper.NewKeeper( - appCodec, - keys[marketplacetypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.ONFTKeeper, - app.DistrKeeper, - app.GetSubspace(marketplacetypes.ModuleName), - ) - - marketplaceModule := marketplace.NewAppModule(appCodec, app.MarketplaceKeeper) - - app.StreamPayKeeper = *streampaykeeper.NewKeeper( - appCodec, - keys[streampaytypes.StoreKey], - keys[streampaytypes.MemStoreKey], - app.AccountKeeper, - app.BankKeeper, - app.DistrKeeper, - app.GetSubspace(streampaytypes.ModuleName), - ) - streamPayModule := streampay.NewAppModule(appCodec, app.StreamPayKeeper) - - app.ItcKeeper = itckeeper.NewKeeper( - appCodec, - keys[itctypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.ONFTKeeper, - app.StreamPayKeeper, - app.DistrKeeper, - app.GetSubspace(itctypes.ModuleName), + invCheckPeriod, + appOpts, ) - itcModule := itc.NewAppModule(appCodec, app.ItcKeeper) - - // Create static IBC router, add transfer route, then set and seal it - ibcRouter := porttypes.NewRouter() - ibcRouter. - AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(ibctransfertypes.ModuleName, transferIBCModule) - - app.IBCKeeper.SetRouter(ibcRouter) - /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment @@ -558,126 +158,22 @@ func NewOmniFlixApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.mm = module.NewManager( - genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, - encodingConfig.TxConfig, - ), - auth.NewAppModule(appCodec, app.AccountKeeper, nil), - vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - upgrade.NewAppModule(app.UpgradeKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - params.NewAppModule(app.ParamsKeeper), - icaModule, - transferModule, - - allocModule, - onftModule, - marketplaceModule, - streamPayModule, - itcModule, - ) + app.mm = module.NewManager(appModules(app, encodingConfig, skipGenesisInvariants)...) // During begin block slashing happens after distr.BeginBlocker so that - // there is nothing left over in the validator fee pool, so as to keep the + // there is nothing left over in the validator fee pool, so to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 - app.mm.SetOrderBeginBlockers( - upgradetypes.ModuleName, - capabilitytypes.ModuleName, - minttypes.ModuleName, - alloctypes.ModuleName, // must run before distribution module - distrtypes.ModuleName, - slashingtypes.ModuleName, - evidencetypes.ModuleName, - stakingtypes.ModuleName, - ibchost.ModuleName, - vestingtypes.ModuleName, - banktypes.ModuleName, - govtypes.ModuleName, - paramstypes.ModuleName, - ibctransfertypes.ModuleName, - icatypes.ModuleName, - genutiltypes.ModuleName, - authz.ModuleName, - authtypes.ModuleName, - crisistypes.ModuleName, - feegrant.ModuleName, - onfttypes.ModuleName, - marketplacetypes.ModuleName, - streampaytypes.ModuleName, - itctypes.ModuleName, - ) + app.mm.SetOrderBeginBlockers(orderBeginBlockers()...) - app.mm.SetOrderEndBlockers( - crisistypes.ModuleName, - govtypes.ModuleName, - stakingtypes.ModuleName, - capabilitytypes.ModuleName, - genutiltypes.ModuleName, - banktypes.ModuleName, - upgradetypes.ModuleName, - evidencetypes.ModuleName, - authtypes.ModuleName, - vestingtypes.ModuleName, - paramstypes.ModuleName, - ibctransfertypes.ModuleName, - icatypes.ModuleName, - minttypes.ModuleName, - slashingtypes.ModuleName, - distrtypes.ModuleName, - ibchost.ModuleName, - feegrant.ModuleName, - authz.ModuleName, - alloctypes.ModuleName, - onfttypes.ModuleName, - marketplacetypes.ModuleName, - streampaytypes.ModuleName, - itctypes.ModuleName, - ) + app.mm.SetOrderEndBlockers(orderEndBlockers()...) // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. // NOTE: Capability module must occur first so that it can initialize any capabilities // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. - app.mm.SetOrderInitGenesis( - capabilitytypes.ModuleName, - authtypes.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - stakingtypes.ModuleName, - slashingtypes.ModuleName, - govtypes.ModuleName, - minttypes.ModuleName, - crisistypes.ModuleName, - genutiltypes.ModuleName, - evidencetypes.ModuleName, - authz.ModuleName, - paramstypes.ModuleName, - upgradetypes.ModuleName, - vestingtypes.ModuleName, - feegrant.ModuleName, - ibchost.ModuleName, - ibctransfertypes.ModuleName, - icatypes.ModuleName, - alloctypes.ModuleName, - onfttypes.ModuleName, - marketplacetypes.ModuleName, - streampaytypes.ModuleName, - itctypes.ModuleName, - ) + app.mm.SetOrderInitGenesis(orderInitGenesis()...) app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) @@ -685,34 +181,14 @@ func NewOmniFlixApp( app.mm.RegisterServices(app.configurator) // simulations - app.sm = module.NewSimulationManager( - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - transferModule, - onftModule, - ) + app.sm = module.NewSimulationManager(simulationModules(app, encodingConfig, skipGenesisInvariants)...) app.sm.RegisterStoreDecoders() // initialize stores - app.MountKVStores(keys) - app.MountTransientStores(tkeys) - app.MountMemoryStores(memKeys) - - // initialize BaseApp - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) + app.MountKVStores(app.GetKVStoreKey()) + app.MountTransientStores(app.GetTransientStoreKey()) + app.MountMemoryStores(app.GetMemoryStoreKey()) anteHandler, err := NewAnteHandler( HandlerOptions{ @@ -731,9 +207,15 @@ func NewOmniFlixApp( if err != nil { panic(fmt.Errorf("failed to create AnteHandler: %s", err)) } + + // initialize BaseApp + app.SetInitChainer(app.InitChainer) + app.SetBeginBlocker(app.BeginBlocker) app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) - app.RegisterUpgradeHandlers(app.configurator) + + app.setupUpgradeHandlers() + app.setupUpgradeStoreLoaders() if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -741,42 +223,42 @@ func NewOmniFlixApp( } } - app.ScopedIBCKeeper = scopedIBCKeeper - app.ScopedTransferKeeper = scopedTransferKeeper return app } // Name returns the name of the App -func (app *App) Name() string { return app.BaseApp.Name() } +func (app *OmniFlixApp) Name() string { return app.BaseApp.Name() } // BeginBlocker application updates every begin block -func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { +func (app *OmniFlixApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { + BeginBlockForks(ctx, app) return app.mm.BeginBlock(ctx, req) } // EndBlocker application updates every end block -func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { +func (app *OmniFlixApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) } // InitChainer application update at chain initialization -func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *OmniFlixApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } // LoadHeight loads a particular height -func (app *App) LoadHeight(height int64) error { +func (app *OmniFlixApp) LoadHeight(height int64) error { return app.LoadVersion(height) } // ModuleAccountAddrs returns all the app's module account addresses. -func (app *App) ModuleAccountAddrs() map[string]bool { +func (app *OmniFlixApp) ModuleAccountAddrs() map[string]bool { modAccAddrs := make(map[string]bool) for acc := range maccPerms { modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true @@ -785,59 +267,43 @@ func (app *App) ModuleAccountAddrs() map[string]bool { return modAccAddrs } -// LegacyAmino returns SimApp's amino codec. +// BlockedAccountAddrs returns all the app's blocked account addresses. +func (app *OmniFlixApp) BlockedAccountAddrs() map[string]bool { + return app.ModuleAccountAddrs() +} + +// LegacyAmino returns omniflixhub's amino codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. -func (app *App) LegacyAmino() *codec.LegacyAmino { +func (app *OmniFlixApp) LegacyAmino() *codec.LegacyAmino { return app.cdc } -// AppCodec returns Gaia's app codec. +// AppCodec returns omniflixhub's app codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. -func (app *App) AppCodec() codec.Codec { +func (app *OmniFlixApp) AppCodec() codec.Codec { return app.appCodec } -// InterfaceRegistry returns Gaia's InterfaceRegistry -func (app *App) InterfaceRegistry() types.InterfaceRegistry { +// InterfaceRegistry returns omniflixhub's InterfaceRegistry +func (app *OmniFlixApp) InterfaceRegistry() types.InterfaceRegistry { return app.interfaceRegistry } -// GetKey returns the KVStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *App) GetKey(storeKey string) *sdk.KVStoreKey { - return app.keys[storeKey] -} - -// GetTKey returns the TransientStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *App) GetTKey(storeKey string) *sdk.TransientStoreKey { - return app.tkeys[storeKey] -} - -// GetMemKey returns the MemStoreKey for the provided mem key. -// -// NOTE: This is solely used for testing purposes. -func (app *App) GetMemKey(storeKey string) *sdk.MemoryStoreKey { - return app.memKeys[storeKey] -} - // GetSubspace returns a param subspace for a given module name. // // NOTE: This is solely to be used for testing purposes. -func (app *App) GetSubspace(moduleName string) paramstypes.Subspace { +func (app *OmniFlixApp) GetSubspace(moduleName string) paramstypes.Subspace { subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) return subspace } // RegisterAPIRoutes registers all application module routes with the provided // API server. -func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { +func (app *OmniFlixApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx rpc.RegisterRoutes(clientCtx, apiSvr.Router) // Register legacy tx routes. @@ -859,19 +325,51 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig } // RegisterTxService implements the Application.RegisterTxService method. -func (app *App) RegisterTxService(clientCtx client.Context) { +func (app *OmniFlixApp) RegisterTxService(clientCtx client.Context) { authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } -func (app *App) SimulationManager() *module.SimulationManager { +func (app *OmniFlixApp) SimulationManager() *module.SimulationManager { return app.sm } // RegisterTendermintService implements the Application.RegisterTendermintService method. -func (app *App) RegisterTendermintService(clientCtx client.Context) { +func (app *OmniFlixApp) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) } +func (app *OmniFlixApp) setupUpgradeHandlers() { + for _, upgrade := range Upgrades { + app.UpgradeKeeper.SetUpgradeHandler( + upgrade.UpgradeName, + upgrade.CreateUpgradeHandler( + app.mm, + app.configurator, + app.BaseApp, + &app.AppKeepers, + ), + ) + } +} + +// configure store loader that checks if version == upgradeHeight and applies store upgrades +func (app *OmniFlixApp) setupUpgradeStoreLoaders() { + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + } + + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } + + for _, upgrade := range Upgrades { + if upgradeInfo.Name == upgrade.UpgradeName { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) + } + } +} + // GetMaccPerms returns a copy of the module account permissions func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) @@ -880,27 +378,3 @@ func GetMaccPerms() map[string][]string { } return dupMaccPerms } - -// initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - - paramsKeeper.Subspace(authtypes.ModuleName) - paramsKeeper.Subspace(banktypes.ModuleName) - paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(minttypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) - paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) - paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibchost.ModuleName) - paramsKeeper.Subspace(icahosttypes.SubModuleName) - paramsKeeper.Subspace(alloctypes.ModuleName) - paramsKeeper.Subspace(onfttypes.ModuleName) - paramsKeeper.Subspace(marketplacetypes.ModuleName) - paramsKeeper.Subspace(streampaytypes.ModuleName) - paramsKeeper.Subspace(itctypes.ModuleName) - - return paramsKeeper -} diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 018013a8..d73e351c 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -30,7 +30,7 @@ import ( type KeeperTestHelper struct { suite.Suite - App *app.App + App *app.OmniFlixApp Ctx sdk.Context QueryHelper *baseapp.QueryServiceTestHelper TestAccs []sdk.AccAddress diff --git a/app/export.go b/app/export.go index e038181e..1c05ae06 100644 --- a/app/export.go +++ b/app/export.go @@ -15,7 +15,7 @@ import ( // ExportAppStateAndValidators exports the state of the application for a genesis // file. -func (app *App) ExportAppStateAndValidators( +func (app *OmniFlixApp) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, ) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block @@ -51,10 +51,10 @@ func (app *App) ExportAppStateAndValidators( // NOTE zero height genesis is a temporary feature which will be deprecated // // in favour of export at a block height -func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { +func (app *OmniFlixApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false - // check if there is a allowed address list + // check if there is an allowed address list if len(jailAllowedAddrs) > 0 { applyAllowedAddrs = true } @@ -145,27 +145,28 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. - store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) + store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) counter := int16(0) - for ; iter.Valid(); iter.Next() { - addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { - panic("expected validator, not found") + func() { + defer iter.Close() + for ; iter.Valid(); iter.Next() { + addr := sdk.ValAddress(iter.Key()[1:]) + validator, found := app.StakingKeeper.GetValidator(ctx, addr) + if !found { + panic("expected validator, not found") + } + + validator.UnbondingHeight = 0 + if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { + validator.Jailed = true + } + + app.StakingKeeper.SetValidator(ctx, validator) + counter++ } - - validator.UnbondingHeight = 0 - if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { - validator.Jailed = true - } - - app.StakingKeeper.SetValidator(ctx, validator) - counter++ - } - - iter.Close() + }() if _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx); err != nil { panic(err) diff --git a/app/forks.go b/app/forks.go new file mode 100644 index 00000000..5797a6f8 --- /dev/null +++ b/app/forks.go @@ -0,0 +1,15 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// BeginBlockForks is intended to be run in a chain upgrade. +func BeginBlockForks(ctx sdk.Context, app *OmniFlixApp) { + for _, fork := range Forks { + if ctx.BlockHeight() == fork.UpgradeHeight { + fork.BeginForkLogic(ctx, &app.AppKeepers) + return + } + } +} diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go new file mode 100644 index 00000000..2ea17311 --- /dev/null +++ b/app/keepers/keepers.go @@ -0,0 +1,398 @@ +package keepers + +import ( + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/store/streaming" + sdk "github.com/cosmos/cosmos-sdk/types" + tmos "github.com/tendermint/tendermint/libs/os" + + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + + evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + + "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + + "github.com/cosmos/cosmos-sdk/x/params" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/cosmos/cosmos-sdk/x/upgrade" + upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" + + icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + + allockeeper "github.com/OmniFlix/omniflixhub/x/alloc/keeper" + alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" + + onftkeeper "github.com/OmniFlix/onft/keeper" + onfttypes "github.com/OmniFlix/onft/types" + + marketplacekeeper "github.com/OmniFlix/marketplace/x/marketplace/keeper" + marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" + + itckeeper "github.com/OmniFlix/omniflixhub/x/itc/keeper" + itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" + + streampaykeeper "github.com/OmniFlix/streampay/v2/x/streampay/keeper" + streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" +) + +type AppKeepers struct { + // keys to access the substores + keys map[string]*sdk.KVStoreKey + tkeys map[string]*sdk.TransientStoreKey + memKeys map[string]*sdk.MemoryStoreKey + + // keepers + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + ICAHostKeeper icahostkeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper + + // make scoped keepers public for test purposes + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + + AllocKeeper allockeeper.Keeper + ONFTKeeper onftkeeper.Keeper + MarketplaceKeeper marketplacekeeper.Keeper + StreamPayKeeper streampaykeeper.Keeper + ItcKeeper itckeeper.Keeper +} + +func NewAppKeeper( + appCodec codec.Codec, + bApp *baseapp.BaseApp, + legacyAmino *codec.LegacyAmino, + maccPerms map[string][]string, + modAccAddrs map[string]bool, + blockedAddress map[string]bool, + skipUpgradeHeights map[int64]bool, + homePath string, + invCheckPeriod uint, + appOpts servertypes.AppOptions, +) AppKeepers { + appKeepers := AppKeepers{} + + // Set keys KVStoreKey, TransientStoreKey, MemoryStoreKey + appKeepers.GenerateKeys() + + /* + configure state listening capabilities using AppOptions + we are doing nothing with the returned streamingServices and waitGroup in this case + */ + if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, appKeepers.keys); err != nil { + tmos.Exit(err.Error()) + } + + appKeepers.ParamsKeeper = initParamsKeeper( + appCodec, + legacyAmino, + appKeepers.keys[paramstypes.StoreKey], + appKeepers.tkeys[paramstypes.TStoreKey], + ) + + // set the BaseApp's parameter store + bApp.SetParamStore( + appKeepers.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()), + ) + + // add capability keeper and ScopeToModule for ibc module + appKeepers.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, appKeepers.keys[capabilitytypes.StoreKey], appKeepers.memKeys[capabilitytypes.MemStoreKey]) + appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) + appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + + appKeepers.CapabilityKeeper.Seal() + + appKeepers.CrisisKeeper = crisiskeeper.NewKeeper( + appKeepers.GetSubspace(crisistypes.ModuleName), + invCheckPeriod, + appKeepers.BankKeeper, + authtypes.FeeCollectorName, + ) + + appKeepers.AccountKeeper = authkeeper.NewAccountKeeper( + appCodec, + appKeepers.keys[authtypes.StoreKey], + appKeepers.GetSubspace(authtypes.ModuleName), + authtypes.ProtoBaseAccount, + maccPerms, + ) + appKeepers.BankKeeper = bankkeeper.NewBaseKeeper( + appCodec, + appKeepers.keys[banktypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.GetSubspace(banktypes.ModuleName), + blockedAddress, + ) + appKeepers.AuthzKeeper = authzkeeper.NewKeeper( + appKeepers.keys[authzkeeper.StoreKey], + appCodec, + bApp.MsgServiceRouter(), + ) + appKeepers.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + appKeepers.keys[feegrant.StoreKey], + appKeepers.AccountKeeper, + ) + stakingKeeper := stakingkeeper.NewKeeper( + appCodec, + appKeepers.keys[stakingtypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.GetSubspace(stakingtypes.ModuleName), + ) + appKeepers.MintKeeper = mintkeeper.NewKeeper( + appCodec, + appKeepers.keys[minttypes.StoreKey], + appKeepers.GetSubspace(minttypes.ModuleName), + &stakingKeeper, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + authtypes.FeeCollectorName, + ) + appKeepers.DistrKeeper = distrkeeper.NewKeeper( + appCodec, + appKeepers.keys[distrtypes.StoreKey], + appKeepers.GetSubspace(distrtypes.ModuleName), + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + &stakingKeeper, + authtypes.FeeCollectorName, + modAccAddrs, + ) + appKeepers.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, + appKeepers.keys[slashingtypes.StoreKey], + &stakingKeeper, + appKeepers.GetSubspace(slashingtypes.ModuleName), + ) + + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + appKeepers.StakingKeeper = *stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(appKeepers.DistrKeeper.Hooks(), appKeepers.SlashingKeeper.Hooks()), + ) + + appKeepers.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + appKeepers.keys[upgradetypes.StoreKey], + appCodec, + homePath, + bApp, + ) + + // Create IBC Keeper + appKeepers.IBCKeeper = ibckeeper.NewKeeper( + appCodec, + appKeepers.keys[ibchost.StoreKey], + appKeepers.GetSubspace(ibchost.ModuleName), + appKeepers.StakingKeeper, + appKeepers.UpgradeKeeper, + appKeepers.ScopedIBCKeeper, + ) + + // register the proposal types + govRouter := govtypes.NewRouter() + govRouter. + AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)). + AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(appKeepers.DistrKeeper)). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)) + + // Create Transfer Keepers + appKeepers.TransferKeeper = ibctransferkeeper.NewKeeper( + appCodec, + appKeepers.keys[ibctransfertypes.StoreKey], + appKeepers.GetSubspace(ibctransfertypes.ModuleName), + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.ScopedTransferKeeper, + ) + transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper) + + appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper( + appCodec, + appKeepers.keys[icahosttypes.StoreKey], + appKeepers.GetSubspace(icahosttypes.SubModuleName), + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + appKeepers.ScopedICAHostKeeper, + bApp.MsgServiceRouter(), + ) + icaHostIBCModule := icahost.NewIBCModule(appKeepers.ICAHostKeeper) + + // Create evidence Keeper for to register the IBC light client misbehaviour evidence route + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, + appKeepers.keys[evidencetypes.StoreKey], + &appKeepers.StakingKeeper, + appKeepers.SlashingKeeper, + ) + // If evidence needs to be handled for the app, set routes in router here and seal + appKeepers.EvidenceKeeper = *evidenceKeeper + + appKeepers.GovKeeper = govkeeper.NewKeeper( + appCodec, + appKeepers.keys[govtypes.StoreKey], + appKeepers.GetSubspace(govtypes.ModuleName), + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + &stakingKeeper, + govRouter, + ) + appKeepers.AllocKeeper = *allockeeper.NewKeeper( + appCodec, + appKeepers.keys[alloctypes.StoreKey], + appKeepers.keys[alloctypes.MemStoreKey], + + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.StakingKeeper, + appKeepers.DistrKeeper, + appKeepers.GetSubspace(alloctypes.ModuleName), + ) + + appKeepers.ONFTKeeper = onftkeeper.NewKeeper( + appCodec, + appKeepers.keys[onfttypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.DistrKeeper, + appKeepers.GetSubspace(onfttypes.ModuleName), + ) + appKeepers.MarketplaceKeeper = marketplacekeeper.NewKeeper( + appCodec, + appKeepers.keys[marketplacetypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.ONFTKeeper, + appKeepers.DistrKeeper, + appKeepers.GetSubspace(marketplacetypes.ModuleName), + ) + + appKeepers.StreamPayKeeper = *streampaykeeper.NewKeeper( + appCodec, + appKeepers.keys[streampaytypes.StoreKey], + appKeepers.keys[streampaytypes.MemStoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.DistrKeeper, + appKeepers.GetSubspace(streampaytypes.ModuleName), + ) + appKeepers.ItcKeeper = itckeeper.NewKeeper( + appCodec, + appKeepers.keys[itctypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.ONFTKeeper, + appKeepers.StreamPayKeeper, + appKeepers.DistrKeeper, + appKeepers.GetSubspace(itctypes.ModuleName), + ) + + // Create static IBC router, add transfer route, then set and seal it + ibcRouter := porttypes.NewRouter() + ibcRouter. + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). + AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + + appKeepers.IBCKeeper.SetRouter(ibcRouter) + + return appKeepers +} + +// GetSubspace returns a param subspace for a given module name. +func (appKeepers *AppKeepers) GetSubspace(moduleName string) paramstypes.Subspace { + subspace, _ := appKeepers.ParamsKeeper.GetSubspace(moduleName) + return subspace +} + +// initParamsKeeper init params keeper and its subspaces +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) + + paramsKeeper.Subspace(authtypes.ModuleName) + paramsKeeper.Subspace(banktypes.ModuleName) + paramsKeeper.Subspace(stakingtypes.ModuleName) + paramsKeeper.Subspace(minttypes.ModuleName) + paramsKeeper.Subspace(distrtypes.ModuleName) + paramsKeeper.Subspace(slashingtypes.ModuleName) + paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) + paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(alloctypes.ModuleName) + paramsKeeper.Subspace(onfttypes.ModuleName) + paramsKeeper.Subspace(marketplacetypes.ModuleName) + paramsKeeper.Subspace(streampaytypes.ModuleName) + paramsKeeper.Subspace(itctypes.ModuleName) + + return paramsKeeper +} diff --git a/app/keepers/keys.go b/app/keepers/keys.go new file mode 100644 index 00000000..7d3ca807 --- /dev/null +++ b/app/keepers/keys.go @@ -0,0 +1,91 @@ +package keepers + +import ( + marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" + alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" + itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" + onfttypes "github.com/OmniFlix/onft/types" + streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" +) + +func (appKeepers *AppKeepers) GenerateKeys() { + appKeepers.keys = sdk.NewKVStoreKeys( + authtypes.StoreKey, + banktypes.StoreKey, + stakingtypes.StoreKey, + minttypes.StoreKey, + distrtypes.StoreKey, + slashingtypes.StoreKey, + govtypes.StoreKey, + paramstypes.StoreKey, + ibchost.StoreKey, + upgradetypes.StoreKey, + evidencetypes.StoreKey, + ibctransfertypes.StoreKey, + icahosttypes.StoreKey, + capabilitytypes.StoreKey, + feegrant.StoreKey, + authzkeeper.StoreKey, + alloctypes.StoreKey, + onfttypes.StoreKey, + marketplacetypes.StoreKey, + streampaytypes.StoreKey, + itctypes.StoreKey, + ) + // Define transient store keys + appKeepers.tkeys = sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + + // MemKeys are for information that is stored only in RAM. + appKeepers.memKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) +} + +func (appKeepers *AppKeepers) GetKVStoreKey() map[string]*storetypes.KVStoreKey { + return appKeepers.keys +} + +func (appKeepers *AppKeepers) GetTransientStoreKey() map[string]*storetypes.TransientStoreKey { + return appKeepers.tkeys +} + +func (appKeepers *AppKeepers) GetMemoryStoreKey() map[string]*storetypes.MemoryStoreKey { + return appKeepers.memKeys +} + +// GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetKey(storeKey string) *storetypes.KVStoreKey { + return appKeepers.keys[storeKey] +} + +// GetTKey returns the TransientStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetTKey(storeKey string) *storetypes.TransientStoreKey { + return appKeepers.tkeys[storeKey] +} + +// GetMemKey returns the MemStoreKey for the provided mem key. +// +// NOTE: This is solely used for testing purposes. +func (appKeepers *AppKeepers) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { + return appKeepers.memKeys[storeKey] +} diff --git a/app/modules.go b/app/modules.go new file mode 100644 index 00000000..dcc58769 --- /dev/null +++ b/app/modules.go @@ -0,0 +1,299 @@ +package app + +import ( + appparams "github.com/OmniFlix/omniflixhub/app/params" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/cosmos/cosmos-sdk/x/auth" + authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + + "github.com/cosmos/cosmos-sdk/x/authz" + authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" + + "github.com/cosmos/cosmos-sdk/x/bank" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/cosmos/cosmos-sdk/x/capability" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + "github.com/cosmos/cosmos-sdk/x/crisis" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + + "github.com/cosmos/cosmos-sdk/x/evidence" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + + "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" + + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + + "github.com/cosmos/cosmos-sdk/x/gov" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/cosmos/cosmos-sdk/x/mint" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + + "github.com/cosmos/cosmos-sdk/x/params" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/cosmos/cosmos-sdk/x/slashing" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + + "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/cosmos/cosmos-sdk/x/upgrade" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v4/modules/core" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + + ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + + "github.com/OmniFlix/omniflixhub/x/alloc" + alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" + + "github.com/OmniFlix/onft" + onfttypes "github.com/OmniFlix/onft/types" + + "github.com/OmniFlix/marketplace/x/marketplace" + marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" + + "github.com/OmniFlix/omniflixhub/x/itc" + itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" + + "github.com/OmniFlix/streampay/v2/x/streampay" + streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" +) + +var ( + // ModuleBasics defines the module BasicManager is in charge of setting up basic, + // non-dependant module elements, such as codec registration + // and genesis verification. + ModuleBasics = module.NewBasicManager( + auth.AppModuleBasic{}, + genutil.AppModuleBasic{}, + bank.AppModuleBasic{}, + capability.AppModuleBasic{}, + staking.AppModuleBasic{}, + mint.AppModuleBasic{}, + distr.AppModuleBasic{}, + gov.NewAppModuleBasic(getGovProposalHandlers()...), + params.AppModuleBasic{}, + crisis.AppModuleBasic{}, + slashing.AppModuleBasic{}, + ibc.AppModuleBasic{}, + ica.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + transfer.AppModuleBasic{}, + vesting.AppModuleBasic{}, + + alloc.AppModuleBasic{}, + onft.AppModuleBasic{}, + marketplace.AppModuleBasic{}, + streampay.AppModuleBasic{}, + itc.AppModuleBasic{}, + // this line is used by starport scaffolding # stargate/app/moduleBasic + ) + + // module account permissions + maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + icatypes.ModuleName: nil, + alloctypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, + onfttypes.ModuleName: nil, + marketplacetypes.ModuleName: nil, + streampaytypes.ModuleName: nil, + itctypes.ModuleName: nil, + } +) + +func appModules( + app *OmniFlixApp, + encodingConfig appparams.EncodingConfig, + skipGenesisInvariants bool, +) []module.AppModule { + appCodec := encodingConfig.Marshaler + return []module.AppModule{ + genutil.NewAppModule( + app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + encodingConfig.TxConfig, + ), + auth.NewAppModule(appCodec, app.AccountKeeper, nil), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + capability.NewAppModule(appCodec, *app.CapabilityKeeper), + crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(app.EvidenceKeeper), + ibc.NewAppModule(app.IBCKeeper), + params.NewAppModule(app.ParamsKeeper), + transfer.NewAppModule(app.TransferKeeper), + ica.NewAppModule(nil, &app.ICAHostKeeper), + alloc.NewAppModule(appCodec, app.AllocKeeper), + onft.NewAppModule(appCodec, app.ONFTKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper), + marketplace.NewAppModule(appCodec, app.MarketplaceKeeper), + streampay.NewAppModule(appCodec, app.StreamPayKeeper), + itc.NewAppModule(appCodec, app.ItcKeeper), + } +} + +// simulationModules returns modules for simulation manager +// define the order of the modules for deterministic simulations +func simulationModules( + app *OmniFlixApp, + encodingConfig appparams.EncodingConfig, + _ bool, +) []module.AppModuleSimulation { + appCodec := encodingConfig.Marshaler + + return []module.AppModuleSimulation{ + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + capability.NewAppModule(appCodec, *app.CapabilityKeeper), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + params.NewAppModule(app.ParamsKeeper), + evidence.NewAppModule(app.EvidenceKeeper), + ibc.NewAppModule(app.IBCKeeper), + } +} + +/* +orderBeginBlockers tells the app's module manager how to set the order of +BeginBlockers, which are run at the beginning of every block. + +During begin block slashing happens after distr.BeginBlocker so that +there is nothing left over in the validator fee pool, so to keep the +CanWithdrawInvariant invariant. +NOTE: staking module is required if HistoricalEntries param > 0 +NOTE: capability module's beginBlocker must come before any modules using capabilities (e.g. IBC) +*/ + +func orderBeginBlockers() []string { + return []string{ + upgradetypes.ModuleName, + capabilitytypes.ModuleName, + minttypes.ModuleName, + alloctypes.ModuleName, // must run before distribution module + distrtypes.ModuleName, + slashingtypes.ModuleName, + evidencetypes.ModuleName, + stakingtypes.ModuleName, + ibchost.ModuleName, + vestingtypes.ModuleName, + banktypes.ModuleName, + govtypes.ModuleName, + paramstypes.ModuleName, + ibctransfertypes.ModuleName, + icatypes.ModuleName, + genutiltypes.ModuleName, + authz.ModuleName, + authtypes.ModuleName, + crisistypes.ModuleName, + feegrant.ModuleName, + onfttypes.ModuleName, + marketplacetypes.ModuleName, + streampaytypes.ModuleName, + itctypes.ModuleName, + } +} + +func orderEndBlockers() []string { + return []string{ + crisistypes.ModuleName, + govtypes.ModuleName, + stakingtypes.ModuleName, + capabilitytypes.ModuleName, + genutiltypes.ModuleName, + banktypes.ModuleName, + upgradetypes.ModuleName, + evidencetypes.ModuleName, + authtypes.ModuleName, + vestingtypes.ModuleName, + paramstypes.ModuleName, + ibctransfertypes.ModuleName, + icatypes.ModuleName, + minttypes.ModuleName, + slashingtypes.ModuleName, + distrtypes.ModuleName, + ibchost.ModuleName, + feegrant.ModuleName, + authz.ModuleName, + alloctypes.ModuleName, + onfttypes.ModuleName, + marketplacetypes.ModuleName, + streampaytypes.ModuleName, + itctypes.ModuleName, + } +} + +/* +NOTE: The genutils module must occur after staking so that pools are +properly initialized with tokens from genesis accounts. +NOTE: The genutils module must also occur after auth so that it can access the params from auth. +NOTE: Capability module must occur first so that it can initialize any capabilities +so that other modules that want to create or claim capabilities after wards in InitChain +can do so safely. +*/ + +func orderInitGenesis() []string { + return []string{ + capabilitytypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + minttypes.ModuleName, + crisistypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + authz.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + vestingtypes.ModuleName, + feegrant.ModuleName, + ibchost.ModuleName, + ibctransfertypes.ModuleName, + icatypes.ModuleName, + alloctypes.ModuleName, + onfttypes.ModuleName, + marketplacetypes.ModuleName, + streampaytypes.ModuleName, + itctypes.ModuleName, + } +} diff --git a/app/sim_test.go b/app/sim_test.go deleted file mode 100644 index 61b2a3b8..00000000 --- a/app/sim_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package app_test - -/* - - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "os" - "testing" - - "github.com/OmniFlix/omniflixhub/app/helpers" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/log" - "github.com/tendermint/tendermint/libs/rand" - dbm "github.com/tendermint/tm-db" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/store" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - simulation2 "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" -) - -func init() { - simapp.GetSimulatorFlags() -} - -// interBlockCacheOpt returns a BaseApp option function that sets the persistent -// inter-block write-through cache. -func interBlockCacheOpt() func(*baseapp.BaseApp) { - return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager()) -} - -func TestFullAppSimulation(t *testing.T) { - config, db, dir, logger, skip, err := simapp.SetupSimulation("leveldb-app-sim", "Simulation") - if skip { - t.Skip("skipping application simulation") - } - require.NoError(t, err, "simulation setup failed") - - defer func() { - db.Close() - require.NoError(t, os.RemoveAll(dir)) - }() - - app := NewOmniFlixApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), helpers.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, "onft", app.Name()) - - // run randomized simulation - _, simParams, simErr := simulation.SimulateFromSeed( - t, - os.Stdout, - app.BaseApp, - AppStateFn(app.AppCodec(), app.SimulationManager()), - simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - - // export state and simParams before the simulation error is checked - err = simapp.CheckExportSimulation(app, config, simParams) - require.NoError(t, err) - require.NoError(t, simErr) - - if config.Commit { - simapp.PrintStats(db) - } -} - -// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of -// an IAVLStore for faster simulation speed. -func fauxMerkleModeOpt(bapp *baseapp.BaseApp) { - bapp.SetFauxMerkleMode() -} - -//// TODO: Make another test for the fuzzer itself, which just has noOp txs -//// and doesn't depend on the application. -func TestAppStateDeterminism(t *testing.T) { - if !simapp.FlagEnabledValue { - t.Skip("skipping application simulation") - } - - config := simapp.NewConfigFromFlags() - config.InitialBlockHeight = 1 - config.ExportParamsPath = "" - config.OnOperation = false - config.AllInvariants = false - config.ChainID = helpers.SimAppChainID - - numSeeds := 3 - numTimesToRunPerSeed := 5 - appHashList := make([]json.RawMessage, numTimesToRunPerSeed) - - for i := 0; i < numSeeds; i++ { - config.Seed = rand.Int63() - - for j := 0; j < numTimesToRunPerSeed; j++ { - var logger log.Logger - if simapp.FlagVerboseValue { - logger = log.TestingLogger() - } else { - logger = log.NewNopLogger() - } - - db := dbm.NewMemDB() - app := NewOmniFlixApp( - logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, - simapp.FlagPeriodValue, MakeEncodingConfig(), - simapp.EmptyAppOptions{}, interBlockCacheOpt()) - - fmt.Printf( - "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", - config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, - ) - - _, _, err := simulation.SimulateFromSeed( - t, - os.Stdout, - app.BaseApp, - AppStateFn(app.AppCodec(), app.SimulationManager()), - simulation2.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - require.NoError(t, err) - - if config.Commit { - simapp.PrintStats(db) - } - - appHash := app.LastCommitID().Hash - appHashList[j] = appHash - - if j != 0 { - require.Equal( - t, hex.EncodeToString(appHashList[0]), hex.EncodeToString(appHashList[j]), - "non-determinism in seed %d: %d/%d, attempt: %d/%d\n", config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, - ) - } - } - } -} -*/ diff --git a/app/state.go b/app/state.go deleted file mode 100644 index 81602fbe..00000000 --- a/app/state.go +++ /dev/null @@ -1,246 +0,0 @@ -package app - -import ( - "encoding/json" - "fmt" - "io" - "math/rand" - "os" - "time" - - tmjson "github.com/tendermint/tendermint/libs/json" - tmtypes "github.com/tendermint/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - sdksimapp "github.com/cosmos/cosmos-sdk/simapp" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -// StateFn returns the initial application state using a genesis or the simulation parameters. -// It panics if the user provides files for both of them. -// If a file is not given for the genesis or the sim params, it creates a randomized one. -func StateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn { - return func( - r *rand.Rand, accs []simtypes.Account, config simtypes.Config, - ) ( - appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time, - ) { - if sdksimapp.FlagGenesisTimeValue == 0 { - genesisTimestamp = simtypes.RandTimestamp(r) - } else { - genesisTimestamp = time.Unix(sdksimapp.FlagGenesisTimeValue, 0) - } - - chainID = config.ChainID - switch { - case config.ParamsFile != "" && config.GenesisFile != "": - panic("cannot provide both a genesis file and a params file") - - case config.GenesisFile != "": - // override the default chain-id from simapp to set it later to the config - genesisDoc, accounts := StateFromGenesisFileFn(r, cdc, config.GenesisFile) - - if sdksimapp.FlagGenesisTimeValue == 0 { - // use genesis timestamp if no custom timestamp is provided (i.e no random timestamp) - genesisTimestamp = genesisDoc.GenesisTime - } - - appState = genesisDoc.AppState - chainID = genesisDoc.ChainID - simAccs = accounts - - case config.ParamsFile != "": - appParams := make(simtypes.AppParams) - bz, err := os.ReadFile(config.ParamsFile) - if err != nil { - panic(err) - } - - err = json.Unmarshal(bz, &appParams) - if err != nil { - panic(err) - } - appState, simAccs = StateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams) - - default: - appParams := make(simtypes.AppParams) - appState, simAccs = StateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams) - } - - rawState := make(map[string]json.RawMessage) - err := json.Unmarshal(appState, &rawState) - if err != nil { - panic(err) - } - - stakingStateBz, ok := rawState[stakingtypes.ModuleName] - if !ok { - panic("staking genesis state is missing") - } - - stakingState := new(stakingtypes.GenesisState) - err = cdc.UnmarshalJSON(stakingStateBz, stakingState) - if err != nil { - panic(err) - } - // compute not bonded balance - notBondedTokens := sdk.ZeroInt() - for _, val := range stakingState.Validators { - if val.Status != stakingtypes.Unbonded { - continue - } - notBondedTokens = notBondedTokens.Add(val.GetTokens()) - } - notBondedCoins := sdk.NewCoin(stakingState.Params.BondDenom, notBondedTokens) - // edit bank state to make it have the not bonded pool tokens - bankStateBz, ok := rawState[banktypes.ModuleName] - // TODO(fdymylja/jonathan): should we panic in this case - if !ok { - panic("bank genesis state is missing") - } - bankState := new(banktypes.GenesisState) - err = cdc.UnmarshalJSON(bankStateBz, bankState) - if err != nil { - panic(err) - } - - stakingAddr := authtypes.NewModuleAddress(stakingtypes.NotBondedPoolName).String() - var found bool - for _, balance := range bankState.Balances { - if balance.Address == stakingAddr { - found = true - break - } - } - if !found { - bankState.Balances = append(bankState.Balances, banktypes.Balance{ - Address: stakingAddr, - Coins: sdk.NewCoins(notBondedCoins), - }) - } - - // change appState back - rawState[stakingtypes.ModuleName] = cdc.MustMarshalJSON(stakingState) - rawState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankState) - - // replace appstate - appState, err = json.Marshal(rawState) - if err != nil { - panic(err) - } - return appState, simAccs, chainID, genesisTimestamp - } -} - -// AppStateRandomizedFn creates calls each module's GenesisState generator function -// and creates the simulation params -func StateRandomizedFn( - simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONCodec, - accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams, -) (json.RawMessage, []simtypes.Account) { - numAccs := int64(len(accs)) - genesisState := NewDefaultGenesisState(cdc) - - // generate a random amount of initial stake coins and a random initial - // number of bonded accounts - var initialStake, numInitiallyBonded int64 - appParams.GetOrGenerate( - cdc, simappparams.StakePerAccount, &initialStake, r, - func(r *rand.Rand) { initialStake = r.Int63n(1e12) }, - ) - appParams.GetOrGenerate( - cdc, simappparams.InitiallyBondedValidators, &numInitiallyBonded, r, - func(r *rand.Rand) { numInitiallyBonded = int64(r.Intn(300)) }, - ) - - if numInitiallyBonded > numAccs { - numInitiallyBonded = numAccs - } - - fmt.Printf( - `Selected randomly generated parameters for simulated genesis: -{ - stake_per_account: "%d", - initially_bonded_validators: "%d" -} -`, initialStake, numInitiallyBonded, - ) - - simState := &module.SimulationState{ - AppParams: appParams, - Cdc: cdc, - Rand: r, - GenState: genesisState, - Accounts: accs, - InitialStake: initialStake, - NumBonded: numInitiallyBonded, - GenTimestamp: genesisTimestamp, - } - - simManager.GenerateGenesisStates(simState) - - appState, err := json.Marshal(genesisState) - if err != nil { - panic(err) - } - - return appState, accs -} - -// AppStateFromGenesisFileFn util function to generate the genesis AppState -// from a genesis.json file. -func StateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account) { - bytes, err := os.ReadFile(genesisFile) - if err != nil { - panic(err) - } - - var genesis tmtypes.GenesisDoc - // NOTE: Tendermint uses a custom JSON decoder for GenesisDoc - err = tmjson.Unmarshal(bytes, &genesis) - if err != nil { - panic(err) - } - - var appState GenesisState - err = json.Unmarshal(genesis.AppState, &appState) - if err != nil { - panic(err) - } - - var authGenesis authtypes.GenesisState - if appState[authtypes.ModuleName] != nil { - cdc.MustUnmarshalJSON(appState[authtypes.ModuleName], &authGenesis) - } - - newAccs := make([]simtypes.Account, len(authGenesis.Accounts)) - for i, acc := range authGenesis.Accounts { - // Pick a random private key, since we don't know the actual key - // This should be fine as it's only used for mock Tendermint validators - // and these keys are never actually used to sign by mock Tendermint. - privkeySeed := make([]byte, 15) - if _, err := r.Read(privkeySeed); err != nil { - panic(err) - } - - privKey := secp256k1.GenPrivKeyFromSecret(privkeySeed) - - a, ok := acc.GetCachedValue().(authtypes.AccountI) - if !ok { - panic("expected account") - } - - // create simulator accounts - simAcc := simtypes.Account{PrivKey: privKey, PubKey: privKey.PubKey(), Address: a.GetAddress()} - newAccs[i] = simAcc - } - - return genesis, newAccs -} diff --git a/app/test_helpers.go b/app/test_helpers.go index 03f62460..4b0ac6e0 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -59,7 +59,7 @@ type EmptyAppOptions struct{} func (EmptyAppOptions) Get(_ string) interface{} { return nil } -func Setup(t *testing.T, _ bool, _ uint) *App { +func Setup(t *testing.T, _ bool, _ uint) *OmniFlixApp { t.Helper() privVal := apphelpers.NewPV() @@ -91,17 +91,17 @@ func SetupWithGenesisValSet( valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance, -) *App { +) *OmniFlixApp { t.Helper() - omniFlixApp, genesisState := setup(true, 5) - genesisState = genesisStateWithValSet(t, omniFlixApp, genesisState, valSet, genAccs, balances...) + omniflixTestApp, genesisState := setup(true, 5) + genesisState = genesisStateWithValSet(t, omniflixTestApp, genesisState, valSet, genAccs, balances...) stateBytes, err := json.MarshalIndent(genesisState, "", " ") require.NoError(t, err) // init chain will set the validator set and initialize the genesis accounts - omniFlixApp.InitChain( + omniflixTestApp.InitChain( abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: DefaultConsensusParams, @@ -110,18 +110,18 @@ func SetupWithGenesisValSet( ) // commit genesis changes - omniFlixApp.Commit() - omniFlixApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ - Height: omniFlixApp.LastBlockHeight() + 1, - AppHash: omniFlixApp.LastCommitID().Hash, + omniflixTestApp.Commit() + omniflixTestApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ + Height: omniflixTestApp.LastBlockHeight() + 1, + AppHash: omniflixTestApp.LastCommitID().Hash, ValidatorsHash: valSet.Hash(), NextValidatorsHash: valSet.Hash(), }}) - return omniFlixApp + return omniflixTestApp } -func setup(withGenesis bool, invCheckPeriod uint) (*App, GenesisState) { +func setup(withGenesis bool, invCheckPeriod uint) (*OmniFlixApp, GenesisState) { db := dbm.NewMemDB() encCdc := MakeEncodingConfig() @@ -145,7 +145,7 @@ func setup(withGenesis bool, invCheckPeriod uint) (*App, GenesisState) { func genesisStateWithValSet( t *testing.T, - app *App, + app *OmniFlixApp, genesisState GenesisState, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, diff --git a/app/types.go b/app/types.go deleted file mode 100644 index 7552998c..00000000 --- a/app/types.go +++ /dev/null @@ -1,40 +0,0 @@ -package app - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/server/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// App implements the common methods for a Cosmos SDK-based application -// specific blockchain. -type CosmosApp interface { - // The assigned name of the app. - Name() string - - // The application types codec. - // NOTE: This shoult be sealed before being returned. - LegacyAmino() *codec.LegacyAmino - - // Application updates every begin block. - BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock - - // Application updates every end block. - EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock - - // Application update at chain (i.e app) initialization. - InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain - - // Loads the app at a given height. - LoadHeight(height int64) error - - // Exports the state of the application for a genesis file. - ExportAppStateAndValidators( - forZeroHeight bool, jailAllowedAddrs []string, - ) (types.ExportedApp, error) - - // All the registered module account addreses. - ModuleAccountAddrs() map[string]bool -} diff --git a/app/upgrades.go b/app/upgrades.go deleted file mode 100644 index 320077a2..00000000 --- a/app/upgrades.go +++ /dev/null @@ -1,61 +0,0 @@ -package app - -import ( - "fmt" - - store "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" -) - -// next upgrade name -const upgradeName = "v2" - -// RegisterUpgradeHandlers returns upgrade handlers -func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { - app.UpgradeKeeper.SetUpgradeHandler( - upgradeName, - func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("running migrations ...") - - // create ICS27 Host submodule params - hostParams := icahosttypes.Params{ - HostEnabled: true, - AllowMessages: []string{ - sdk.MsgTypeURL(&banktypes.MsgSend{}), - sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), - sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), - sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), - sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), - sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), - sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), - sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), - sdk.MsgTypeURL(&govtypes.MsgVote{}), - }, - } - app.ICAHostKeeper.SetParams(ctx, hostParams) - - return app.mm.RunMigrations(ctx, cfg, fromVM) - }) - - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) - } - - if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := store.StoreUpgrades{ - Added: []string{icahosttypes.StoreKey}, - } - // configure store loader that checks if height == upgradeHeight and applies store upgrades - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) - } -} diff --git a/app/upgrades/types.go b/app/upgrades/types.go new file mode 100644 index 00000000..251c63cc --- /dev/null +++ b/app/upgrades/types.go @@ -0,0 +1,48 @@ +package upgrades + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/OmniFlix/omniflixhub/app/keepers" +) + +// BaseAppParamManager defines an interface that BaseApp is expected to full-fill, +// that allows upgrade handlers to modify BaseApp parameters. +type BaseAppParamManager interface { + GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams + StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusParams) +} + +// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal +// must have written, in order for the state migration to go smoothly. +// An upgrade must implement this struct, and then set it in the app.go. +// The app.go will then define the handler. +type Upgrade struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + + // CreateUpgradeHandler defines the function that creates an upgrade handler + CreateUpgradeHandler func(*module.Manager, module.Configurator, BaseAppParamManager, *keepers.AppKeepers) upgradetypes.UpgradeHandler + + // Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. + StoreUpgrades store.StoreUpgrades +} + +// Fork defines a struct containing the requisite fields for a non-software upgrade proposal +// Hard Fork at a given height to implement. +// There is one time code that can be added for the start of the Fork, in `BeginForkLogic`. +// Any other change in the code should be height-gated, if the goal is to have old and new binaries +// to be compatible prior to the upgrade height. +type Fork struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + // height the upgrade occurs at + UpgradeHeight int64 + + // Function that runs some custom state transition code at the beginning of a fork. + BeginForkLogic func(ctx sdk.Context, keepers *keepers.AppKeepers) +} diff --git a/app/upgrades/v2/constants.go b/app/upgrades/v2/constants.go new file mode 100644 index 00000000..b5b2afc5 --- /dev/null +++ b/app/upgrades/v2/constants.go @@ -0,0 +1,17 @@ +package v2 + +import ( + "github.com/OmniFlix/omniflixhub/app/upgrades" + store "github.com/cosmos/cosmos-sdk/store/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" +) + +const UpgradeName = "v2" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{icahosttypes.StoreKey}, + }, +} diff --git a/app/upgrades/v2/upgrades.go b/app/upgrades/v2/upgrades.go new file mode 100644 index 00000000..339b0bc3 --- /dev/null +++ b/app/upgrades/v2/upgrades.go @@ -0,0 +1,53 @@ +package v2 + +import ( + "github.com/OmniFlix/omniflixhub/app/keepers" + "github.com/OmniFlix/omniflixhub/app/upgrades" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + cfg module.Configurator, + bpm upgrades.BaseAppParamManager, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("running migrations ...") + + // Run migrations before applying any other state changes. + // NOTE: DO NOT PUT ANY STATE CHANGES BEFORE RunMigrations(). + versionMap, err := mm.RunMigrations(ctx, cfg, fromVM) + if err != nil { + return nil, err + } + // create ICS27 Host submodule params + hostParams := icahosttypes.Params{ + HostEnabled: true, + AllowMessages: []string{ + sdk.MsgTypeURL(&banktypes.MsgSend{}), + sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), + sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), + sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), + sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), + sdk.MsgTypeURL(&govtypes.MsgVote{}), + }, + } + + keepers.ICAHostKeeper.SetParams(ctx, hostParams) + + return versionMap, nil + } +} diff --git a/cmd/omniflixhubd/cmd/root.go b/cmd/omniflixhubd/cmd/root.go index b61257e1..d1d0867f 100644 --- a/cmd/omniflixhubd/cmd/root.go +++ b/cmd/omniflixhubd/cmd/root.go @@ -38,7 +38,7 @@ import ( var ChainID string -// NewRootCmd creates a new root command for simd. It is called once in the +// NewRootCmd creates a new root command for omniflixhubd. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { // Set config for prefixes @@ -222,12 +222,12 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a ) } -// appExport creates a new simapp (optionally at a given height) +// appExport creates a new app (optionally at a given height) func (a appCreator) appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, ) (servertypes.ExportedApp, error) { - var anApp *app.App + var anApp *app.OmniFlixApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { diff --git a/testutil/simapp/simapp.go b/testutil/simapp/simapp.go index 06457544..ca3733fa 100644 --- a/testutil/simapp/simapp.go +++ b/testutil/simapp/simapp.go @@ -15,7 +15,7 @@ import ( ) // New creates application instance with in-memory database and disabled logging. -func New(dir string) *app.App { +func New(dir string) *app.OmniFlixApp { db := tmdb.NewMemDB() logger := log.NewNopLogger() diff --git a/x/alloc/keeper/keeper_test.go b/x/alloc/keeper/keeper_test.go index e995a697..fce5f96f 100644 --- a/x/alloc/keeper/keeper_test.go +++ b/x/alloc/keeper/keeper_test.go @@ -18,7 +18,7 @@ import ( type KeeperTestSuite struct { suite.Suite ctx sdk.Context - app *app.App + app *app.OmniFlixApp } func (suite *KeeperTestSuite) SetupTest() { From f39402710394bf35120554efdf3cab2dbb1e102c Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Fri, 21 Jul 2023 18:14:01 +0530 Subject: [PATCH 4/7] feat: add marketplace module as internal module (#74) * feat: add marketplace module as internal module * fix lint issues --- app/keepers/keepers.go | 4 +- app/keepers/keys.go | 2 +- app/modules.go | 4 +- go.mod | 5 +- go.sum | 2 - .../marketplace/v1beta1/auction.proto | 60 + .../omniflix/marketplace/v1beta1/events.proto | 63 + .../marketplace/v1beta1/genesis.proto | 19 + .../marketplace/v1beta1/listing.proto | 35 + .../omniflix/marketplace/v1beta1/params.proto | 42 + .../omniflix/marketplace/v1beta1/query.proto | 173 + proto/omniflix/marketplace/v1beta1/tx.proto | 127 + x/itc/types/msgs.go | 4 +- x/marketplace/README.md | 279 + x/marketplace/abci.go | 17 + x/marketplace/client/cli/flags.go | 52 + x/marketplace/client/cli/query.go | 405 ++ x/marketplace/client/cli/tx.go | 479 ++ x/marketplace/client/rest/query.go | 174 + x/marketplace/client/rest/rest.go | 45 + x/marketplace/client/rest/tx.go | 176 + x/marketplace/exported/marketplace.go | 34 + x/marketplace/genesis.go | 57 + x/marketplace/handler.go | 50 + x/marketplace/keeper/alias.go | 13 + x/marketplace/keeper/auction.go | 350 ++ x/marketplace/keeper/bid.go | 73 + x/marketplace/keeper/events.go | 161 + x/marketplace/keeper/grpc_query.go | 393 ++ x/marketplace/keeper/keeper.go | 307 + x/marketplace/keeper/listing.go | 146 + x/marketplace/keeper/msg_server.go | 262 + x/marketplace/keeper/params.go | 43 + x/marketplace/keeper/querier.go | 162 + x/marketplace/module.go | 166 + x/marketplace/types/auction.go | 79 + x/marketplace/types/auction.pb.go | 1104 ++++ x/marketplace/types/bid.go | 36 + x/marketplace/types/codec.go | 68 + x/marketplace/types/constants.go | 8 + x/marketplace/types/errors.go | 36 + x/marketplace/types/events.go | 29 + x/marketplace/types/events.pb.go | 2581 ++++++++ x/marketplace/types/expected_keepers.go | 36 + x/marketplace/types/genesis.go | 44 + x/marketplace/types/genesis.pb.go | 588 ++ x/marketplace/types/keys.go | 74 + x/marketplace/types/listing.go | 48 + x/marketplace/types/listing.pb.go | 802 +++ x/marketplace/types/msgs.go | 354 ++ x/marketplace/types/params.go | 184 + x/marketplace/types/params.pb.go | 685 +++ x/marketplace/types/querier.go | 99 + x/marketplace/types/query.pb.go | 5333 +++++++++++++++++ x/marketplace/types/query.pb.gw.go | 1383 +++++ x/marketplace/types/tx.pb.go | 3472 +++++++++++ x/marketplace/types/utils.go | 27 + x/marketplace/types/validation.go | 148 + 58 files changed, 21590 insertions(+), 12 deletions(-) create mode 100644 proto/omniflix/marketplace/v1beta1/auction.proto create mode 100644 proto/omniflix/marketplace/v1beta1/events.proto create mode 100644 proto/omniflix/marketplace/v1beta1/genesis.proto create mode 100644 proto/omniflix/marketplace/v1beta1/listing.proto create mode 100644 proto/omniflix/marketplace/v1beta1/params.proto create mode 100644 proto/omniflix/marketplace/v1beta1/query.proto create mode 100644 proto/omniflix/marketplace/v1beta1/tx.proto create mode 100644 x/marketplace/README.md create mode 100644 x/marketplace/abci.go create mode 100644 x/marketplace/client/cli/flags.go create mode 100644 x/marketplace/client/cli/query.go create mode 100644 x/marketplace/client/cli/tx.go create mode 100644 x/marketplace/client/rest/query.go create mode 100644 x/marketplace/client/rest/rest.go create mode 100644 x/marketplace/client/rest/tx.go create mode 100644 x/marketplace/exported/marketplace.go create mode 100644 x/marketplace/genesis.go create mode 100644 x/marketplace/handler.go create mode 100644 x/marketplace/keeper/alias.go create mode 100644 x/marketplace/keeper/auction.go create mode 100644 x/marketplace/keeper/bid.go create mode 100644 x/marketplace/keeper/events.go create mode 100644 x/marketplace/keeper/grpc_query.go create mode 100644 x/marketplace/keeper/keeper.go create mode 100644 x/marketplace/keeper/listing.go create mode 100644 x/marketplace/keeper/msg_server.go create mode 100644 x/marketplace/keeper/params.go create mode 100644 x/marketplace/keeper/querier.go create mode 100644 x/marketplace/module.go create mode 100644 x/marketplace/types/auction.go create mode 100644 x/marketplace/types/auction.pb.go create mode 100644 x/marketplace/types/bid.go create mode 100644 x/marketplace/types/codec.go create mode 100644 x/marketplace/types/constants.go create mode 100644 x/marketplace/types/errors.go create mode 100644 x/marketplace/types/events.go create mode 100644 x/marketplace/types/events.pb.go create mode 100644 x/marketplace/types/expected_keepers.go create mode 100644 x/marketplace/types/genesis.go create mode 100644 x/marketplace/types/genesis.pb.go create mode 100644 x/marketplace/types/keys.go create mode 100644 x/marketplace/types/listing.go create mode 100644 x/marketplace/types/listing.pb.go create mode 100644 x/marketplace/types/msgs.go create mode 100644 x/marketplace/types/params.go create mode 100644 x/marketplace/types/params.pb.go create mode 100644 x/marketplace/types/querier.go create mode 100644 x/marketplace/types/query.pb.go create mode 100644 x/marketplace/types/query.pb.gw.go create mode 100644 x/marketplace/types/tx.pb.go create mode 100644 x/marketplace/types/utils.go create mode 100644 x/marketplace/types/validation.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 2ea17311..a87ea98b 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -72,8 +72,8 @@ import ( onftkeeper "github.com/OmniFlix/onft/keeper" onfttypes "github.com/OmniFlix/onft/types" - marketplacekeeper "github.com/OmniFlix/marketplace/x/marketplace/keeper" - marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" + marketplacekeeper "github.com/OmniFlix/omniflixhub/x/marketplace/keeper" + marketplacetypes "github.com/OmniFlix/omniflixhub/x/marketplace/types" itckeeper "github.com/OmniFlix/omniflixhub/x/itc/keeper" itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 7d3ca807..eb8ffae7 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -1,9 +1,9 @@ package keepers import ( - marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" + marketplacetypes "github.com/OmniFlix/omniflixhub/x/marketplace/types" onfttypes "github.com/OmniFlix/onft/types" streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/app/modules.go b/app/modules.go index dcc58769..d92e609c 100644 --- a/app/modules.go +++ b/app/modules.go @@ -67,8 +67,8 @@ import ( "github.com/OmniFlix/onft" onfttypes "github.com/OmniFlix/onft/types" - "github.com/OmniFlix/marketplace/x/marketplace" - marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" + "github.com/OmniFlix/omniflixhub/x/marketplace" + marketplacetypes "github.com/OmniFlix/omniflixhub/x/marketplace/types" "github.com/OmniFlix/omniflixhub/x/itc" itctypes "github.com/OmniFlix/omniflixhub/x/itc/types" diff --git a/go.mod b/go.mod index 259ea469..6e05bbc8 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module github.com/OmniFlix/omniflixhub go 1.19 require ( - github.com/OmniFlix/marketplace v0.6.0 github.com/OmniFlix/onft v0.6.0 github.com/OmniFlix/streampay/v2 v2.1.0 github.com/cosmos/cosmos-sdk v0.45.16 github.com/cosmos/ibc-go/v4 v4.4.2 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 + github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cast v1.5.0 @@ -18,6 +18,7 @@ require ( github.com/stretchr/testify v1.8.1 github.com/tendermint/tendermint v0.34.28 github.com/tendermint/tm-db v0.6.7 + golang.org/x/exp v0.0.0-20221019170559-20944726eadf google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa google.golang.org/grpc v1.52.3 google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 @@ -76,7 +77,6 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -132,7 +132,6 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.5.0 // indirect - golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/term v0.5.0 // indirect diff --git a/go.sum b/go.sum index 0c1c29e2..9e9b01b9 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,6 @@ github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4K github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= -github.com/OmniFlix/marketplace v0.6.0 h1:LF39FBWdjp6ZaNJUIeDGp6c0FVCsbv/KM46GqD19G1g= -github.com/OmniFlix/marketplace v0.6.0/go.mod h1:k3JLhUXCQxjXc7Ro6hvj1cwwnzAMlfdxU/T4v90NzgU= github.com/OmniFlix/onft v0.6.0 h1:RS2ACs1owt5khqURu+x1f5ahV1wbs5eMJZaMmbq3++4= github.com/OmniFlix/onft v0.6.0/go.mod h1:RW0ooCgUtutpMElh38kbYf3Qb05BmDKK18jCRImwinI= github.com/OmniFlix/streampay/v2 v2.1.0 h1:jdoWcAQe4RuD5o82w4tLtkVQyzLmStz4IYo2hYHOeII= diff --git a/proto/omniflix/marketplace/v1beta1/auction.proto b/proto/omniflix/marketplace/v1beta1/auction.proto new file mode 100644 index 00000000..eeb79df8 --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/auction.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "omniflix/marketplace/v1beta1/listing.proto"; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.goproto_enum_prefix_all) = false; + +message AuctionListing { + uint64 id = 1; + string nft_id = 2 [(gogoproto.moretags) = "yaml:\"nft_id\""]; + string denom_id = 3 [(gogoproto.moretags) = "yaml:\"denom_id\""]; + cosmos.base.v1beta1.Coin start_price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"start_price\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + google.protobuf.Timestamp start_time = 5 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + google.protobuf.Timestamp end_time = 6 [ + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"end_time\"" + ]; + string owner = 7; + string increment_percentage = 8 [ + (gogoproto.moretags) = "yaml:\"increment_percentage\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + repeated string whitelist_accounts = 9 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"whitelist_accounts\"" + ]; + repeated WeightedAddress split_shares = 10 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; +} + +enum AuctionStatus { + AUCTION_STATUS_UNSPECIFIED = 0; + AUCTION_STATUS_INACTIVE = 1; + AUCTION_STATUS_ACTIVE = 2; +} + +message Bid { + option (gogoproto.equal) = true; + + uint64 auction_id = 1 [(gogoproto.moretags) = "yaml:\"auction_id\""]; + string bidder = 2; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; + google.protobuf.Timestamp time = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/omniflix/marketplace/v1beta1/events.proto b/proto/omniflix/marketplace/v1beta1/events.proto new file mode 100644 index 00000000..55bd7eec --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/events.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; + +// EventListONFT is emitted on NFT Listing on market +message EventListNFT { + string id = 1; + string nft_id = 2; + string denom_id = 3; + string owner = 4; +} +// EventEditListing is emitted on edit Listing on market +message EventEditListing { + string id = 1; + string nft_id = 2; + string denom_id = 3; + string owner = 4; +} + +// EventDeListONFT is emitted on NFT DeListing from market +message EventDeListNFT { + string id = 1; + string nft_id = 2; + string denom_id = 3; + string owner = 4; +} + +// EventBuyONFT is emitted on NFT Buy +message EventBuyNFT { + string id = 1; + string nft_id = 2; + string denom_id = 3; + string owner = 4; + string buyer = 5; +} + +// EventCreateAuction is emitted on creating auction +message EventCreateAuction { + string id = 1; + string nft_id = 2; + string denom_id = 3; + string owner = 4; + string min_price = 5; +} + +// EventCancelAuction is emitted on canceling auction +message EventCancelAuction { + string id = 1; + string nft_id = 2; + string denom_id = 3; + string owner = 4; +} + +// EventPlaceBid is emitted on placing bid for an auction +message EventPlaceBid { + string auction_id = 1; + string nft_id = 2; + string denom_id = 3; + string bidder = 4; + string amount = 5; +} + diff --git a/proto/omniflix/marketplace/v1beta1/genesis.proto b/proto/omniflix/marketplace/v1beta1/genesis.proto new file mode 100644 index 00000000..97169bbf --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/genesis.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +import "gogoproto/gogo.proto"; +import "omniflix/marketplace/v1beta1/listing.proto"; +import "omniflix/marketplace/v1beta1/auction.proto"; +import "omniflix/marketplace/v1beta1/params.proto"; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; + +message GenesisState { + // NFTs that are listed in marketplace + repeated Listing listings = 1 [(gogoproto.nullable) = false]; + uint64 ListingCount = 2; + Params params = 3 [(gogoproto.nullable) = false]; + repeated AuctionListing auctions = 4 [(gogoproto.nullable) = false]; + repeated Bid bids = 5 [(gogoproto.nullable) = false]; + uint64 next_auction_number = 6; +} \ No newline at end of file diff --git a/proto/omniflix/marketplace/v1beta1/listing.proto b/proto/omniflix/marketplace/v1beta1/listing.proto new file mode 100644 index 00000000..d9d9ada8 --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/listing.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; +option (gogoproto.goproto_getters_all) = false; + + +message Listing { + string id = 1; + string nft_id = 2 [(gogoproto.moretags) = "yaml:\"nft_id\""]; + string denom_id = 3 [(gogoproto.moretags) = "yaml:\"denom_id\""]; + cosmos.base.v1beta1.Coin price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string owner = 5 [(gogoproto.moretags) = "yaml:\"owner\""]; + repeated WeightedAddress split_shares = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; +} + +message WeightedAddress { + option (gogoproto.equal) = true; + + string address = 1 [(gogoproto.moretags) = "yaml:\"address\""]; + string weight = 2 [ + (gogoproto.moretags) = "yaml:\"weight\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/omniflix/marketplace/v1beta1/params.proto b/proto/omniflix/marketplace/v1beta1/params.proto new file mode 100644 index 00000000..1dad65a1 --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/params.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; +option (gogoproto.goproto_getters_all) = false; + + + +message Params { + string sale_commission = 1 [ + (gogoproto.moretags) = "yaml:\"sale_commission\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + Distribution distribution = 2 [(gogoproto.nullable) = false]; + google.protobuf.Duration bid_close_duration = 3 [ + (gogoproto.moretags) = "yaml:\"bid_close_duration\"", + (gogoproto.stdduration) = true, + (gogoproto.nullable) = false + ]; + google.protobuf.Duration max_auction_duration = 4 [ + (gogoproto.moretags) = "yaml:\"max_auction_duration\"", + (gogoproto.stdduration) = true, + (gogoproto.nullable) = false + ]; +} + +message Distribution { + string staking = 1 [ + (gogoproto.moretags) = "yaml:\"staking\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string community_pool = 2 [ + (gogoproto.moretags) = "yaml:\"community_pool\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/omniflix/marketplace/v1beta1/query.proto b/proto/omniflix/marketplace/v1beta1/query.proto new file mode 100644 index 00000000..7d45c347 --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/query.proto @@ -0,0 +1,173 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; +import "omniflix/marketplace/v1beta1/listing.proto"; +import "omniflix/marketplace/v1beta1/params.proto"; +import "omniflix/marketplace/v1beta1/auction.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; + +service Query { + // Params queries params of the marketplace module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/params"; + } + + rpc Listings(QueryListingsRequest) returns (QueryListingsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings"; + } + + rpc Listing(QueryListingRequest) returns (QueryListingResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings/{id}"; + } + + rpc ListingsByOwner(QueryListingsByOwnerRequest) returns (QueryListingsByOwnerResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings-by-owner/{owner}"; + } + + rpc ListingsByPriceDenom(QueryListingsByPriceDenomRequest) returns (QueryListingsByPriceDenomResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings-by-price-denom/{price_denom}"; + } + + rpc ListingByNftId(QueryListingByNFTIDRequest) returns (QueryListingResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listing-by-nft/{nft_id}"; + } + + // auction queries + rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/auctions"; + } + + rpc Auction(QueryAuctionRequest) returns (QueryAuctionResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/auctions/{id}"; + } + + rpc AuctionsByOwner(QueryAuctionsByOwnerRequest) returns (QueryAuctionsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/auctions-by-owner/{owner}"; + } + + rpc AuctionsByPriceDenom(QueryAuctionsByPriceDenomRequest) returns (QueryAuctionsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/auctions-by-price-denom/{price_denom}"; + } + + rpc AuctionByNftId(QueryAuctionByNFTIDRequest) returns (QueryAuctionResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/auction-by-nft/{nft_id}"; + } + + rpc Bids(QueryBidsRequest) returns (QueryBidsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/bids"; + } + + rpc Bid(QueryBidRequest) returns (QueryBidResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/bids/{id}"; + } +} + + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +message QueryListingsRequest { + string owner = 1; + string price_denom = 2 [(gogoproto.moretags) = "yaml:\"price_denom\""]; + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +message QueryListingsResponse { + repeated Listing listings = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryListingRequest { + string id = 1; +} + +message QueryListingResponse { + Listing listing = 1; +} + +message QueryListingsByOwnerRequest { + string owner = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryListingsByOwnerResponse { + repeated Listing listings = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryListingByNFTIDRequest { + string nft_id = 1 [(gogoproto.moretags) = "yaml:\"nft_id\""]; +} + +message QueryListingsByPriceDenomRequest { + string price_denom = 1 [(gogoproto.moretags) = "yaml:\"price_denom\""]; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryListingsByPriceDenomResponse { + repeated Listing listings = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryAuctionsRequest { + AuctionStatus status = 1; + string owner = 2; + string price_denom = 3 [(gogoproto.moretags) = "yaml:\"price_denom\""]; + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +message QueryAuctionsResponse { + repeated AuctionListing auctions = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryAuctionRequest { + uint64 id = 1; +} + +message QueryAuctionResponse { + AuctionListing auction = 1; +} + +message QueryAuctionsByOwnerRequest { + string owner = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryAuctionByNFTIDRequest { + string nft_id = 1 [(gogoproto.moretags) = "yaml:\"nft_id\""]; +} + +message QueryAuctionsByPriceDenomRequest { + string price_denom = 1 [(gogoproto.moretags) = "yaml:\"price_denom\""]; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryBidsRequest { + string bidder = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryBidsResponse { + repeated Bid bids = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; + +} + +message QueryBidRequest { + uint64 id = 1; +} + +message QueryBidResponse { + Bid bid = 1; +} diff --git a/proto/omniflix/marketplace/v1beta1/tx.proto b/proto/omniflix/marketplace/v1beta1/tx.proto new file mode 100644 index 00000000..fb18a8c1 --- /dev/null +++ b/proto/omniflix/marketplace/v1beta1/tx.proto @@ -0,0 +1,127 @@ +syntax = "proto3"; +package OmniFlix.marketplace.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "omniflix/marketplace/v1beta1/listing.proto"; +import "omniflix/marketplace/v1beta1/auction.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/OmniFlix/omniflixhub/x/marketplace/types"; +option (gogoproto.goproto_getters_all) = false; + +service Msg { + + rpc ListNFT(MsgListNFT) returns (MsgListNFTResponse); + + rpc EditListing(MsgEditListing) returns (MsgEditListingResponse); + + rpc DeListNFT(MsgDeListNFT) returns (MsgDeListNFTResponse); + + rpc BuyNFT(MsgBuyNFT) returns (MsgBuyNFTResponse); + + rpc CreateAuction(MsgCreateAuction) returns (MsgCreateAuctionResponse); + + rpc CancelAuction(MsgCancelAuction) returns (MsgCancelAuctionResponse); + + rpc PlaceBid(MsgPlaceBid) returns (MsgPlaceBidResponse); + +} + + +message MsgListNFT { + string id = 1; + string nft_id = 2; + string denom_id = 3; + cosmos.base.v1beta1.Coin price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string owner = 5; + repeated WeightedAddress split_shares = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; +} +message MsgListNFTResponse {} + +message MsgEditListing { + string id = 1; + cosmos.base.v1beta1.Coin price = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string owner = 3; +} +message MsgEditListingResponse {} + +message MsgDeListNFT { + string id = 1; + string owner = 2; +} + +message MsgDeListNFTResponse {} + +message MsgBuyNFT { + string id = 1; + cosmos.base.v1beta1.Coin price = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string buyer = 3; +} + +message MsgBuyNFTResponse {} + +message MsgCreateAuction { + string nft_id = 1; + string denom_id = 2; + google.protobuf.Timestamp start_time = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + cosmos.base.v1beta1.Coin start_price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.moretags) = "yaml:\"start_price\"" + ]; + google.protobuf.Duration duration = 5 [(gogoproto.stdduration) = true]; + string increment_percentage = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"increment_percentage\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec" + ]; + repeated string whitelist_accounts = 7 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"whitelist_accounts\"" + ]; + repeated WeightedAddress split_shares = 8 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; + string owner = 9; +} + +message MsgCreateAuctionResponse { + AuctionListing auction = 1; +} + +message MsgCancelAuction { + uint64 auction_id = 1 [(gogoproto.moretags) = "yaml:\"auction_id\""]; + string owner = 2; +} + +message MsgCancelAuctionResponse {} + +message MsgPlaceBid { + uint64 auction_id = 1 [(gogoproto.moretags) = "yaml:\"auction_id\""]; + cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string bidder = 3; +} + +message MsgPlaceBidResponse {} \ No newline at end of file diff --git a/x/itc/types/msgs.go b/x/itc/types/msgs.go index 0ea5f803..476d004d 100644 --- a/x/itc/types/msgs.go +++ b/x/itc/types/msgs.go @@ -3,7 +3,7 @@ package types import ( "time" - "github.com/OmniFlix/marketplace/x/marketplace/types" + "github.com/OmniFlix/onft/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -206,7 +206,7 @@ func (msg MsgClaim) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid claimer address (%s)", msg.Claimer) } if len(msg.NftId) == 0 { - return sdkerrors.Wrapf(types.ErrInvalidNftId, "invalid nft id (%s)", msg.NftId) + return sdkerrors.Wrapf(types.ErrInvalidONFTID, "invalid nft id (%s)", msg.NftId) } return ValidateInteractionType(msg.Interaction) } diff --git a/x/marketplace/README.md b/x/marketplace/README.md new file mode 100644 index 00000000..730c5885 --- /dev/null +++ b/x/marketplace/README.md @@ -0,0 +1,279 @@ +# x/marketplace + +The `marketplace` module allows users to list NFTs with a fixed price or through timed auctions. Buyers can purchase NFTs from the marketplace by paying the listed price or by participating in an auction. The `marketplace` module supports different types of listings: + +- Fixed Price Listing +- Timed Auction +### Fixed Price Listing + +In a fixed price listing, buyers must pay the listed amount to acquire the NFT. NFT owners can list their NFT with any allowed token and specify split shares between different addresses and the percentage of revenue each address receives. + +```go +message Listing { + string id = 1; + string nft_id = 2 [(gogoproto.moretags) = "yaml:\"nft_id\""]; + string denom_id = 3 [(gogoproto.moretags) = "yaml:\"denom_id\""]; + cosmos.base.v1beta1.Coin price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string owner = 5 [(gogoproto.moretags) = "yaml:\"owner\""]; + repeated WeightedAddress split_shares = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; +} + +message WeightedAddress { + option (gogoproto.equal) = true; + + string address = 1 [(gogoproto.moretags) = "yaml:\"address\""]; + string weight = 2 [ + (gogoproto.moretags) = "yaml:\"weight\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +``` + +## Timed Auction + +- Timed auction require buyers to bid with a minimum amount. +- Only one bid is allowed at a time in these auctions. +- When a new bid is placed, the previous bid amount will be returned to the bidder. +- Auction will end at the end time and the highest bidder will be the winner. +- if no bids were placed on the auction, it will be closed at end time.` + + +```go +message AuctionListing { + uint64 id = 1; + string nft_id = 2 [(gogoproto.moretags) = "yaml:\"nft_id\""]; + string denom_id = 3 [(gogoproto.moretags) = "yaml:\"denom_id\""]; + cosmos.base.v1beta1.Coin start_price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"start_price\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + google.protobuf.Timestamp start_time = 5 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + google.protobuf.Timestamp end_time = 6 [ + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"end_time\"" + ]; + string owner = 7; + string increment_percentage = 8 [ + (gogoproto.moretags) = "yaml:\"increment_percentage\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + repeated string whitelist_accounts = 9 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"whitelist_accounts\"" + ]; + repeated WeightedAddress split_shares = 10 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; +} +``` +## Fees and Distribution + +Whenever an NFT is bought or an auction is concluded, a certain percentage of the sale amount is collected as a commission. This commission is then distributed among different parties based on the distribution parameters that have been set. +- **Staking distribution**: The percentage of the fee that is distributed to stakers. +- **Community pool distribution**: The percentage of the fee that is added to the community pool. + +## State +The state of the module is expressed by following fields + +1. `listings`: A list of NFT listings that are available in the marketplace. +2. `ListingCount`: The total count of NFT listings. +3. `params`: Marketplace module parameters. +4. `auctions`: A list of active auctions in the marketplace. +5. `bids`: A list of bids made on auctions. +6. `next_auction_number`: The number to be assigned to the next auction that is created. + +```go +message GenesisState { + // NFTs that are listed in marketplace + repeated Listing listings = 1 [(gogoproto.nullable) = false]; + uint64 ListingCount = 2; + Params params = 3 [(gogoproto.nullable) = false]; + repeated AuctionListing auctions = 4 [(gogoproto.nullable) = false]; + repeated Bid bids = 5 [(gogoproto.nullable) = false]; + uint64 next_auction_number = 6; +} +``` +### Module parameters +The Marketplace module includes the following parameters: + +- **Sale commission**: A decimal that represents the percentage of the sale price that is collected as a fee. This fee is distributed to various parties according to the configured distribution parameters. +- **Distribution**: A data structure that represents the distribution of the sale commission. It includes two fields: the staking distribution and the community pool distribution. These fields are represented as decimals and represent the percentage of the sale commission that is distributed to each party. +- **Bid close duration**: A duration that represents the amount of time after the last bid was placed before the auction is closed. If no bids were placed on the auction, it will be closed after this duration. + +## Transactions / Messages +### List NFT +`MsgListNFT` can be submitted by any account to list nft on marketplace. +```go +message MsgListNFT { + string id = 1; + string nft_id = 2; + string denom_id = 3; + cosmos.base.v1beta1.Coin price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string owner = 5; + repeated WeightedAddress split_shares = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; +} +``` + +### Edit Listing +`MsgEditListing` can be submitted by owner of the nft to update price of the nft in `Listing` +```go +message MsgEditListing { + string id = 1; + cosmos.base.v1beta1.Coin price = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string owner = 3; +} +``` + +### Remove Listing +`MsgDeListNFT` can be used by owner of the nft to remove the `Listing` from marketplace. +``` +message MsgDeListNFT { + string id = 1; + string owner = 2; +} +``` + +### Buy Listed NFT +`MsgBuyNFT` can be used by anyone to buy nft from marketplace. +```go +message MsgBuyNFT { + string id = 1; + cosmos.base.v1beta1.Coin price = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string buyer = 3; +} +``` +### Create Timed Auction +`MsgCreateAuction` can be submitted by any account to create a `Timed Action` +```go +message MsgCreateAuction { + string nft_id = 1; + string denom_id = 2; + google.protobuf.Timestamp start_time = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + cosmos.base.v1beta1.Coin start_price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.moretags) = "yaml:\"start_price\"" + ]; + google.protobuf.Duration duration = 5 [(gogoproto.stdduration) = true]; + string increment_percentage = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"increment_percentage\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec" + ]; + repeated string whitelist_accounts = 7 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"whitelist_accounts\"" + ]; + repeated WeightedAddress split_shares = 8 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"split_shares\"" + ]; + string owner = 9; +} +``` + +### Cancel Timed Auction +`MsgCancelAuction` can be submitted by auction creator to cancel `Auction` before start time. +```go +message MsgCancelAuction { + uint64 auction_id = 1 [(gogoproto.moretags) = "yaml:\"auction_id\""]; + string owner = 2; +} +``` +`MsgPlaceBid` can be submitted by any account to bid on a `Auction`. +### Place Bid on Auction +```go +message MsgPlaceBid { + uint64 auction_id = 1 [(gogoproto.moretags) = "yaml:\"auction_id\""]; + cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string bidder = 3; +} +``` + +## Queries + +```go +service Query { + // Params queries params of the marketplace module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/params"; + } + + rpc Listings(QueryListingsRequest) returns (QueryListingsResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings"; + } + + rpc Listing(QueryListingRequest) returns (QueryListingResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings/{id}"; + } + + rpc ListingsByOwner(QueryListingsByOwnerRequest) returns (QueryListingsByOwnerResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings-by-owner/{owner}"; + } + + rpc ListingsByPriceDenom(QueryListingsByPriceDenomRequest) returns (QueryListingsByPriceDenomResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listings-by-price-denom/{price_denom}"; + } + + rpc ListingByNftId(QueryListingByNFTIDRequest) returns (QueryListingResponse) { + option (google.api.http).get = "/omniflix/marketplace/v1beta1/listing-by-nft/{nft_id}"; + } + +``` +- Query Listings + ```shell + omniflixhubd q marketplace listings [Flags] + ``` +- Query Listing Details + ```shell + omniflixhubd q marketplace listing [listingId] [Flags] + ``` +- Query listings by owner + ```shell + omniflixhubd q marketplace listings-by-owner [owner] [Flags] + ``` +- Query Auctions + ```shell + omniflixhubd q marketplace auctions [Flags] + ``` +- Query Auction + ```shell + omniflixhubd q marketplace auction [Flags] + ``` +- Query Auction Bid + ```shell + omniflixhubd q marketplace bid [Flags] + ``` diff --git a/x/marketplace/abci.go b/x/marketplace/abci.go new file mode 100644 index 00000000..29b9cf26 --- /dev/null +++ b/x/marketplace/abci.go @@ -0,0 +1,17 @@ +package marketplace + +import ( + "github.com/OmniFlix/omniflixhub/x/marketplace/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + abcitypes "github.com/tendermint/tendermint/abci/types" +) + +func EndBlock(ctx sdk.Context, k keeper.Keeper) []abcitypes.ValidatorUpdate { + log := k.Logger(ctx) + err := k.UpdateAuctionStatusesAndProcessBids(ctx) + if err != nil { + panic(err) + } + log.Info("Updated Auctions and Processed bids.. ") + return []abcitypes.ValidatorUpdate{} +} diff --git a/x/marketplace/client/cli/flags.go b/x/marketplace/client/cli/flags.go new file mode 100644 index 00000000..ee398031 --- /dev/null +++ b/x/marketplace/client/cli/flags.go @@ -0,0 +1,52 @@ +package cli + +import ( + flag "github.com/spf13/pflag" +) + +const ( + FlagDenomId = "denom-id" + FlagNftId = "nft-id" + FlagPrice = "price" + FlagOwner = "owner" + FlagBidder = "bidder" + FlagPriceDenom = "price-denom" + FlagSplitShares = "split-shares" + FlagWhiteListAccounts = "whitelist-accounts" + FlagStartTime = "start-time" + FlagStartPrice = "start-price" + FlagIncrementPercentage = "increment-percentage" + FlagDuration = "duration" + FlagAmount = "amount" +) + +var ( + FsListNft = flag.NewFlagSet("", flag.ContinueOnError) + FsEditListing = flag.NewFlagSet("", flag.ContinueOnError) + FsBuyNFT = flag.NewFlagSet("", flag.ContinueOnError) + + FsCreateAuction = flag.NewFlagSet("", flag.ContinueOnError) + FsPlaceBid = flag.NewFlagSet("", flag.ContinueOnError) +) + +func init() { + FsListNft.String(FlagDenomId, "", "nft denom id") + FsListNft.String(FlagNftId, "", "nft id") + FsListNft.String(FlagPrice, "", "listing price of nft") + FsListNft.String(FlagSplitShares, "", "split shares for listing") + + FsEditListing.String(FlagPrice, "", "listing price of nft") + + FsBuyNFT.String(FlagPrice, "", "buying price of nft") + + FsCreateAuction.String(FlagDenomId, "", "nft denom id") + FsCreateAuction.String(FlagNftId, "", "nft id") + FsCreateAuction.String(FlagStartPrice, "", "auction bid start price of nft") + FsCreateAuction.String(FlagStartTime, "", "auction start time") + FsCreateAuction.String(FlagDuration, "", "auction duration") + FsCreateAuction.String(FlagIncrementPercentage, "0.01", "bid increment percentage") + FsCreateAuction.String(FlagWhiteListAccounts, "", "whitelist accounts for private auction") + FsCreateAuction.String(FlagSplitShares, "", "split shares for listing") + + FsPlaceBid.String(FlagAmount, "", "auction bid amount") +} diff --git a/x/marketplace/client/cli/query.go b/x/marketplace/client/cli/query.go new file mode 100644 index 00000000..50f826ec --- /dev/null +++ b/x/marketplace/client/cli/query.go @@ -0,0 +1,405 @@ +package cli + +import ( + "context" + "fmt" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd() *cobra.Command { + // Group marketplace queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand( + GetCmdQueryParams(), + GetCmdQueryListing(), + GetCmdQueryAllListings(), + GetCmdQueryListingsByOwner(), + GetCmdQueryAuction(), + GetCmdQueryAllAuctions(), + GetCmdQueryAuctionsByOwner(), + GetCmdQueryAuctionBid(), + GetCmdQueryAllBids(), + ) + + return cmd +} + +// GetCmdQueryParams implements the query params command. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "Query Marketplace params", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetCmdQueryListing implements the query listing command. +func GetCmdQueryListing() *cobra.Command { + cmd := &cobra.Command{ + Use: "listing [id]", + Long: "Query a listing by id.", + Example: fmt.Sprintf("$ %s query marketplace listing ", version.AppName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + listingId := strings.ToLower(strings.TrimSpace(args[0])) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Listing(context.Background(), &types.QueryListingRequest{ + Id: listingId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res.Listing) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryAllListings implements the query all listings command. +func GetCmdQueryAllListings() *cobra.Command { + cmd := &cobra.Command{ + Use: "listings", + Long: "Query listings.", + Example: fmt.Sprintf("$ %s query marketplace listings", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + owner, err := cmd.Flags().GetString(FlagOwner) + if err != nil { + return err + } + priceDenom, err := cmd.Flags().GetString(FlagPriceDenom) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + resp, err := queryClient.Listings( + context.Background(), + &types.QueryListingsRequest{ + Owner: owner, + PriceDenom: priceDenom, + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(resp) + }, + } + flags.AddQueryFlagsToCmd(cmd) + cmd.Flags().String(FlagOwner, "", "filter by owner address") + cmd.Flags().String(FlagPriceDenom, "", "filter by listing price-denom") + flags.AddPaginationFlagsToCmd(cmd, "all listings") + + return cmd +} + +// GetCmdQueryListingsByOwner implements the query listings by owner command. +func GetCmdQueryListingsByOwner() *cobra.Command { + cmd := &cobra.Command{ + Use: "listings-by-owner [owner]", + Long: "Query listings by the owner.", + Example: fmt.Sprintf("$ %s query marketplace listings ", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + var owner sdk.AccAddress + if len(args) > 0 { + owner, err = sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + } + + queryClient := types.NewQueryClient(clientCtx) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + resp, err := queryClient.ListingsByOwner( + context.Background(), + &types.QueryListingsByOwnerRequest{ + Owner: owner.String(), + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(resp) + }, + } + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "owner listings") + + return cmd +} + +// GetCmdQueryAuctionListing implements the query auction command. +func GetCmdQueryAuction() *cobra.Command { + cmd := &cobra.Command{ + Use: "auction [id]", + Long: "Query a auction by id.", + Example: fmt.Sprintf("$ %s query marketplace auction ", version.AppName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + auctionId, err := strconv.ParseUint(strings.ToLower(strings.TrimSpace(args[0])), 10, 64) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Auction(context.Background(), &types.QueryAuctionRequest{ + Id: auctionId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res.Auction) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryAllAuctions implements the query all auctions command. +func GetCmdQueryAllAuctions() *cobra.Command { + cmd := &cobra.Command{ + Use: "auctions", + Long: "Query auctions.", + Example: fmt.Sprintf("$ %s query marketplace auctions", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + owner, err := cmd.Flags().GetString(FlagOwner) + if err != nil { + return err + } + priceDenom, err := cmd.Flags().GetString(FlagPriceDenom) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + resp, err := queryClient.Auctions( + context.Background(), + &types.QueryAuctionsRequest{ + Owner: owner, + PriceDenom: priceDenom, + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(resp) + }, + } + flags.AddQueryFlagsToCmd(cmd) + cmd.Flags().String(FlagOwner, "", "filter by owner address") + cmd.Flags().String(FlagPriceDenom, "", "filter by auction price-denom") + flags.AddPaginationFlagsToCmd(cmd, "all auctions") + + return cmd +} + +// GetCmdQueryAuctionsByOwner implements the query auctions by owner command. +func GetCmdQueryAuctionsByOwner() *cobra.Command { + cmd := &cobra.Command{ + Use: "auctions-by-owner [owner]", + Long: "Query auctions by the owner.", + Example: fmt.Sprintf("$ %s query marketplace auctions ", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + var owner sdk.AccAddress + if len(args) > 0 { + owner, err = sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + } + + queryClient := types.NewQueryClient(clientCtx) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + resp, err := queryClient.AuctionsByOwner( + context.Background(), + &types.QueryAuctionsByOwnerRequest{ + Owner: owner.String(), + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(resp) + }, + } + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "owner auctions") + + return cmd +} + +// GetCmdQueryAuctionBid implements the query bid command. +func GetCmdQueryAuctionBid() *cobra.Command { + cmd := &cobra.Command{ + Use: "bid [id]", + Long: "Query a bid by auction id.", + Example: fmt.Sprintf("$ %s query marketplace bid ", version.AppName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + auctionId, err := strconv.ParseUint(strings.ToLower(strings.TrimSpace(args[0])), 10, 64) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Bid(context.Background(), &types.QueryBidRequest{ + Id: auctionId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res.Bid) + }, + } + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryAllBids implements the query all bids command. +func GetCmdQueryAllBids() *cobra.Command { + cmd := &cobra.Command{ + Use: "bids", + Long: "Query bids.", + Example: fmt.Sprintf("$ %s query marketplace bids", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + bidder, err := cmd.Flags().GetString(FlagBidder) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + resp, err := queryClient.Bids( + context.Background(), + &types.QueryBidsRequest{ + Bidder: bidder, + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(resp) + }, + } + flags.AddQueryFlagsToCmd(cmd) + cmd.Flags().String(FlagBidder, "", "filter by bidder address") + flags.AddPaginationFlagsToCmd(cmd, "all bids") + + return cmd +} diff --git a/x/marketplace/client/cli/tx.go b/x/marketplace/client/cli/tx.go new file mode 100644 index 00000000..334881f5 --- /dev/null +++ b/x/marketplace/client/cli/tx.go @@ -0,0 +1,479 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + "time" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/cosmos/cosmos-sdk/client" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + marketplaceTxCmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + marketplaceTxCmd.AddCommand( + GetCmdListNft(), + GetCmdEditListing(), + GetCmdDeListNft(), + GetCmdBuyNft(), + GetCmdCreateAuction(), + GetCmdCancelAuction(), + GetCmdPlaceBid(), + ) + + return marketplaceTxCmd +} + +// GetCmdListNft implements the list-nft command +func GetCmdListNft() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-nft", + Long: "lists an nft on marketplace", + Example: fmt.Sprintf( + "$ %s tx marketplace list-nft "+ + "--nft-id= "+ + "--denom-id= "+ + "--price=\"1000000uflix\" "+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + owner := clientCtx.GetFromAddress() + denomId, err := cmd.Flags().GetString(FlagDenomId) + if err != nil { + return err + } + nftId, err := cmd.Flags().GetString(FlagNftId) + if err != nil { + return err + } + priceStr, err := cmd.Flags().GetString(FlagPrice) + if err != nil { + return err + } + price, err := sdk.ParseCoinNormalized(priceStr) + if err != nil { + return fmt.Errorf("failed to parse price: %s", price) + } + splitSharesStr, err := cmd.Flags().GetString(FlagSplitShares) + if err != nil { + return err + } + var splitShares []types.WeightedAddress + if len(splitSharesStr) > 0 { + splitShares, err = parseSplitShares(splitSharesStr) + if err != nil { + return err + } + } + + msg := types.NewMsgListNFT(denomId, nftId, price, owner, splitShares) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(FsListNft) + _ = cmd.MarkFlagRequired(FlagDenomId) + _ = cmd.MarkFlagRequired(FlagNftId) + _ = cmd.MarkFlagRequired(FlagPrice) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdEditListing implements the edit-listing command +func GetCmdEditListing() *cobra.Command { + cmd := &cobra.Command{ + Use: "edit-listing", + Long: "Edit an existing marketplace listing ", + Example: fmt.Sprintf( + "$ %s tx marketplace edit-listing [listing-id] "+ + "--price=\"1000000uflix\" "+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + owner := clientCtx.GetFromAddress() + + listingId := strings.TrimSpace(args[0]) + + priceStr, err := cmd.Flags().GetString(FlagPrice) + if err != nil { + return err + } + price, err := sdk.ParseCoinNormalized(priceStr) + if err != nil { + return fmt.Errorf("failed to parse price: %s", price) + } + + msg := types.NewMsgEditListing(listingId, price, owner) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(FsEditListing) + _ = cmd.MarkFlagRequired(FlagPrice) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdDeListNft implements the de-list-nft command +func GetCmdDeListNft() *cobra.Command { + cmd := &cobra.Command{ + Use: "de-list-nft", + Long: "de-list an existing listing from marketplace", + Example: fmt.Sprintf( + "$ %s tx marketplace de-list-nft [listing-id] "+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + owner := clientCtx.GetFromAddress() + + listingId := strings.TrimSpace(args[0]) + + msg := types.NewMsgDeListNFT(listingId, owner) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdBuyNft implements the buy-nft command +func GetCmdBuyNft() *cobra.Command { + cmd := &cobra.Command{ + Use: "buy-nft", + Short: "Buy an nft from marketplace", + Example: fmt.Sprintf( + "$ %s tx marketplace buy-nft [listing-id]"+ + "--price="+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + buyer := clientCtx.GetFromAddress() + listingId := args[0] + + priceStr, err := cmd.Flags().GetString(FlagPrice) + if err != nil { + return err + } + price, err := sdk.ParseCoinNormalized(priceStr) + if err != nil { + return fmt.Errorf("failed to parse price: %s", priceStr) + } + + msg := types.NewMsgBuyNFT(listingId, price, buyer) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(FsBuyNFT) + _ = cmd.MarkFlagRequired(FlagPrice) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func parseSplitShares(splitsharesStr string) ([]types.WeightedAddress, error) { + splitsharesStr = strings.TrimSpace(splitsharesStr) + splitsStrList := strings.Split(splitsharesStr, ",") + var weightedAddrsList []types.WeightedAddress + for _, splitStr := range splitsStrList { + var share types.WeightedAddress + split := strings.Split(strings.TrimSpace(splitStr), ":") + address, err := sdk.AccAddressFromBech32(strings.TrimSpace(split[0])) + if err != nil { + return nil, err + } + weight, err := sdk.NewDecFromStr(strings.TrimSpace(split[1])) + if err != nil { + return nil, err + } + share.Address = address.String() + share.Weight = weight + weightedAddrsList = append(weightedAddrsList, share) + } + return weightedAddrsList, nil +} + +func parseWhitelistAccounts(whitelistStr string) ([]string, error) { + whitelistStr = strings.TrimSpace(whitelistStr) + whitelist := strings.Split(whitelistStr, ",") + return whitelist, nil +} + +// GetCmdCreateAuction implements the create-auction command +func GetCmdCreateAuction() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-auction", + Long: "creates an auction on marketplace", + Example: fmt.Sprintf( + "$ %s tx marketplace create-auction "+ + "--nft-id= "+ + "--denom-id= "+ + "--start-price=\"1000000uflix\" "+ + "--start-time=\"2022-06-13T13:02:49.389Z\" "+ + "--increment-percentage=\"0.01\""+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + owner := clientCtx.GetFromAddress() + denomId, err := cmd.Flags().GetString(FlagDenomId) + if err != nil { + return err + } + nftId, err := cmd.Flags().GetString(FlagNftId) + if err != nil { + return err + } + startPriceStr, err := cmd.Flags().GetString(FlagStartPrice) + if err != nil { + return err + } + startPrice, err := sdk.ParseCoinNormalized(startPriceStr) + if err != nil { + return fmt.Errorf("failed to parse start price: %s", startPrice) + } + startTimeStr, err := cmd.Flags().GetString(FlagStartTime) + if err != nil { + return err + } + + var startTime time.Time + if startTimeStr != "" { + startTime, err = time.Parse(time.RFC3339, startTimeStr) + if err != nil { + return err + } + } else { + return fmt.Errorf("failed to parse start time: %s", startTime) + } + splitSharesStr, err := cmd.Flags().GetString(FlagSplitShares) + if err != nil { + return err + } + var splitShares []types.WeightedAddress + if len(splitSharesStr) > 0 { + splitShares, err = parseSplitShares(splitSharesStr) + if err != nil { + return err + } + } + durationStr, err := cmd.Flags().GetString(FlagDuration) + if err != nil { + return err + } + var duration *time.Duration + if len(durationStr) > 0 { + dur, err := time.ParseDuration(durationStr) + if err != nil { + return err + } + duration = &dur + } else { + duration = nil + } + incrementStr, err := cmd.Flags().GetString(FlagIncrementPercentage) + if err != nil { + return err + } + increment, err := sdk.NewDecFromStr(incrementStr) + if err != nil { + return err + } + whitelistAccountsStr, err := cmd.Flags().GetString(FlagWhiteListAccounts) + if err != nil { + return err + } + var whitelist []string + if len(whitelistAccountsStr) > 0 { + whitelist, err = parseWhitelistAccounts(whitelistAccountsStr) + if err != nil { + return err + } + } + msg := types.NewMsgCreateAuction(denomId, nftId, startTime, duration, startPrice, owner, increment, whitelist, splitShares) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(FsCreateAuction) + _ = cmd.MarkFlagRequired(FlagDenomId) + _ = cmd.MarkFlagRequired(FlagNftId) + _ = cmd.MarkFlagRequired(FlagStartPrice) + _ = cmd.MarkFlagRequired(FlagStartTime) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdCancelAuction implements the cancel-auction command +func GetCmdCancelAuction() *cobra.Command { + cmd := &cobra.Command{ + Use: "cancel-auction", + Long: "cancel an existing auction from marketplace with no bids", + Example: fmt.Sprintf( + "$ %s tx marketplace cancel-auction [auction-id] "+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + owner := clientCtx.GetFromAddress() + + auctionId, err := strconv.ParseUint(strings.TrimSpace(args[0]), 10, 64) + if err != nil { + return err + } + + msg := types.NewMsgCancelAuction(auctionId, owner) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdBid implements the bid command +func GetCmdPlaceBid() *cobra.Command { + cmd := &cobra.Command{ + Use: "place-bid", + Short: "Bid for an nft on marketplace", + Example: fmt.Sprintf( + "$ %s tx marketplace place-bid [auction-id]"+ + "--amount="+ + "--from= "+ + "--chain-id= "+ + "--fees=", + version.AppName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + buyer := clientCtx.GetFromAddress() + auctionId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + amountStr, err := cmd.Flags().GetString(FlagAmount) + if err != nil { + return err + } + amount, err := sdk.ParseCoinNormalized(amountStr) + if err != nil { + return fmt.Errorf("failed to parse price: %s", amountStr) + } + + msg := types.NewMsgPlaceBid(auctionId, amount, buyer) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(FsPlaceBid) + _ = cmd.MarkFlagRequired(FlagAmount) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/marketplace/client/rest/query.go b/x/marketplace/client/rest/query.go new file mode 100644 index 00000000..26f124c5 --- /dev/null +++ b/x/marketplace/client/rest/query.go @@ -0,0 +1,174 @@ +package rest + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkquery "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/types/rest" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" +) + +func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { + r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), + queryParams(cliCtx), + ).Methods("GET") + + r.HandleFunc(fmt.Sprintf("/%s/listing/{%s}", + types.ModuleName, RestParamListingId), + queryListing(cliCtx), + ).Methods("GET") + + r.HandleFunc(fmt.Sprintf("/%s/listings", types.ModuleName), + queryAllListings(cliCtx), + ).Methods("GET") + + r.HandleFunc(fmt.Sprintf("/%s/listings/{%s}", types.ModuleName, RestParamOwner), + queryListingsByOwner(cliCtx), + ).Methods("GET") +} + +// queryParams +func queryParams(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + res, height, err := cliCtx.QueryWithData( + fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams), nil, + ) + if err != nil { + rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + cliCtx = cliCtx.WithHeight(height) + rest.PostProcessResponse(w, cliCtx, res) + } +} + +// queryListing +func queryListing(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + listingId := strings.TrimSpace(vars[RestParamListingId]) + params := types.QueryListingParams{ + Id: listingId, + } + + bz, err := cliCtx.LegacyAmino.MarshalJSON(params) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + res, height, err := cliCtx.QueryWithData( + fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListing), bz, + ) + if err != nil { + rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + cliCtx = cliCtx.WithHeight(height) + rest.PostProcessResponse(w, cliCtx, res) + } +} + +// queryAllListings +func queryAllListings(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + var ( + qc = types.NewQueryClient(cliCtx) + query = r.URL.Query() + ) + + _, page, limit, err := rest.ParseHTTPArgs(r) + if rest.CheckBadRequestError(w, err) { + return + } + pageReq := sdkquery.PageRequest{ + Offset: uint64((page - 1) * limit), + Limit: uint64(limit), + CountTotal: true, + } + owner := query.Get("owner") + priceDenom := query.Get("priceDenom") + + listings, err := qc.Listings( + context.Background(), + &types.QueryListingsRequest{ + Owner: owner, + PriceDenom: priceDenom, + Pagination: &pageReq, + }, + ) + if rest.CheckInternalServerError(w, err) { + return + } + + rest.PostProcessResponse(w, cliCtx, listings) + } +} + +// queryListingsByOwner +func queryListingsByOwner(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ownerStr := r.FormValue(RestParamOwner) + + var err error + var owner sdk.AccAddress + + if len(ownerStr) > 0 { + owner, err = sdk.AccAddressFromBech32(ownerStr) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + } + + params := types.QueryListingsByOwnerParams{ + Owner: owner, + } + + bz, err := cliCtx.LegacyAmino.MarshalJSON(params) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + res, height, err := cliCtx.QueryWithData( + fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListingsByOwner), bz, + ) + if err != nil { + rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + cliCtx = cliCtx.WithHeight(height) + rest.PostProcessResponse(w, cliCtx, res) + } +} diff --git a/x/marketplace/client/rest/rest.go b/x/marketplace/client/rest/rest.go new file mode 100644 index 00000000..c3c261d9 --- /dev/null +++ b/x/marketplace/client/rest/rest.go @@ -0,0 +1,45 @@ +package rest + +import ( + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/rest" +) + +// Rest variable names +const ( + RestParamListingId = "listing_id" + RestParamOwner = "owner" +) + +func RegisterHandlers(cliCtx client.Context, r *mux.Router) { + registerQueryRoutes(cliCtx, r) + registerTxRoutes(cliCtx, r) +} + +type listNftReq struct { + BaseReq rest.BaseReq `json:"base_req"` + DenomId string `json:"denom_id"` + NftId string `json:"nft_id"` + Price string `json:"price"` + Owner string `json:"owner"` + SplitShares []types.WeightedAddress `json:"split_shares"` +} +type editListingReq struct { + BaseReq rest.BaseReq `json:"base_req"` + Price string `json:"price"` + Owner string `json:"owner"` +} + +type deListNftReq struct { + BaseReq rest.BaseReq `json:"base_req"` + Owner string `json:"owner"` +} + +type buyNftReq struct { + BaseReq rest.BaseReq `json:"base_req"` + Price string `json:"price"` + Buyer string `json:"buyer"` +} diff --git a/x/marketplace/client/rest/tx.go b/x/marketplace/client/rest/tx.go new file mode 100644 index 00000000..f5d3fb56 --- /dev/null +++ b/x/marketplace/client/rest/tx.go @@ -0,0 +1,176 @@ +package rest + +import ( + "fmt" + "net/http" + "strings" + + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/types/rest" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func registerTxRoutes(cliCtx client.Context, r *mux.Router) { + r.HandleFunc( + fmt.Sprintf("/%s/list-nft", types.ModuleName), + ListNft(cliCtx), + ).Methods("POST") + + r.HandleFunc( + fmt.Sprintf("/%s/listings/{%s}/edit-listing", types.ModuleName, RestParamListingId), + editListing(cliCtx), + ).Methods("PUT") + + r.HandleFunc( + fmt.Sprintf("/%s/listings/{%s}/de-list-nft", types.ModuleName, RestParamListingId), + deListNft(cliCtx), + ).Methods("PUT") + + r.HandleFunc( + fmt.Sprintf("/%s/listings/{%s}/buy-nft", types.ModuleName, RestParamListingId), + buyNft(cliCtx), + ).Methods("POST") +} + +func ListNft(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req listNftReq + if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { + return + } + + baseReq := req.BaseReq.Sanitize() + if !baseReq.ValidateBasic(w) { + return + } + owner, err := sdk.AccAddressFromBech32(req.Owner) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, + fmt.Sprintf("invalid bech32 account address: %s", req.Owner)) + return + } + + price, err := sdk.ParseCoinNormalized(req.Price) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to parse min amount: %s", req.Price)) + return + } + + msg := types.NewMsgListNFT(req.DenomId, req.NftId, price, owner, req.SplitShares) + + if err := msg.ValidateBasic(); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) + } +} + +func editListing(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + listingId := strings.TrimSpace(vars[RestParamListingId]) + var req editListingReq + if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { + return + } + + baseReq := req.BaseReq.Sanitize() + if !baseReq.ValidateBasic(w) { + return + } + owner, err := sdk.AccAddressFromBech32(req.Owner) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, + fmt.Sprintf("invalid bech32 account address: %s", req.Owner)) + return + } + + price, err := sdk.ParseCoinNormalized(req.Price) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to parse min amount: %s", req.Price)) + return + } + + msg := types.NewMsgEditListing(listingId, price, owner) + if err := msg.ValidateBasic(); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) + } +} + +func deListNft(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + listingId := strings.TrimSpace(vars[RestParamListingId]) + var req deListNftReq + if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { + return + } + + baseReq := req.BaseReq.Sanitize() + if !baseReq.ValidateBasic(w) { + return + } + owner, err := sdk.AccAddressFromBech32(req.Owner) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, + fmt.Sprintf("invalid bech32 account address: %s", req.Owner)) + return + } + + msg := types.NewMsgDeListNFT(listingId, owner) + if err := msg.ValidateBasic(); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) + } +} + +func buyNft(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + listingId := strings.TrimSpace(vars[RestParamListingId]) + + var req buyNftReq + if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { + return + } + + baseReq := req.BaseReq.Sanitize() + if !baseReq.ValidateBasic(w) { + return + } + buyer, err := sdk.AccAddressFromBech32(req.Buyer) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, + fmt.Sprintf("invalid bech32 account address: %s", req.Buyer)) + return + } + + price, err := sdk.ParseCoinNormalized(req.Price) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to parse min amount: %s", req.Price)) + return + } + + msg := types.NewMsgBuyNFT(listingId, price, buyer) + if err := msg.ValidateBasic(); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) + } +} diff --git a/x/marketplace/exported/marketplace.go b/x/marketplace/exported/marketplace.go new file mode 100644 index 00000000..81f140c4 --- /dev/null +++ b/x/marketplace/exported/marketplace.go @@ -0,0 +1,34 @@ +package exported + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ListingI interface { + GetId() string + GetDenomId() string + GetNftId() string + GetPrice() sdk.Coin + GetOwner() sdk.AccAddress + GetSplitShares() interface{} +} + +type AuctionListingI interface { + GetId() uint64 + GetDenomId() string + GetNftId() string + GetStartPrice() sdk.Coin + GetStartTime() time.Time + GetIncrementPercentage() sdk.Dec + GetOwner() sdk.AccAddress + GetSplitShares() interface{} + GetStatus() string +} + +type BidI interface { + GetAuctionId() uint64 + GetAmount() sdk.Coin + GetBidder() sdk.AccAddress +} diff --git a/x/marketplace/genesis.go b/x/marketplace/genesis.go new file mode 100644 index 00000000..2d95a6ab --- /dev/null +++ b/x/marketplace/genesis.go @@ -0,0 +1,57 @@ +package marketplace + +import ( + "fmt" + + "github.com/OmniFlix/omniflixhub/x/marketplace/keeper" + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + if err := genState.ValidateGenesis(); err != nil { + panic(err.Error()) + } + for _, l := range genState.Listings { + k.SetListing(ctx, l) + k.SetWithOwner(ctx, l.GetOwner(), l.GetId()) + k.SetWithNFTID(ctx, l.GetNftId(), l.GetId()) + k.SetWithPriceDenom(ctx, l.Price.GetDenom(), l.GetId()) + } + k.SetListingCount(ctx, genState.ListingCount) + k.SetParams(ctx, genState.Params) + + for _, al := range genState.Auctions { + k.SetAuctionListing(ctx, al) + k.SetAuctionListingWithOwner(ctx, al.GetOwner(), al.GetId()) + k.SetAuctionListingWithNFTID(ctx, al.GetNftId(), al.GetId()) + k.SetAuctionListingWithPriceDenom(ctx, al.StartPrice.GetDenom(), al.GetId()) + } + + for _, b := range genState.Bids { + k.SetBid(ctx, b) + } + k.SetNextAuctionNumber(ctx, genState.NextAuctionNumber) + + // check if the module account exists + moduleAcc := k.GetMarketplaceAccount(ctx) + if moduleAcc == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } +} + +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + return types.NewGenesisState( + k.GetAllListings(ctx), + k.GetListingCount(ctx), + k.GetParams(ctx), + k.GetAllAuctionListings(ctx), + k.GetAllBids(ctx), + k.GetNextAuctionNumber(ctx), + ) +} + +func DefaultGenesisState() *types.GenesisState { + return types.NewGenesisState([]types.Listing{}, 0, types.DefaultParams(), []types.AuctionListing{}, []types.Bid{}, 1) +} diff --git a/x/marketplace/handler.go b/x/marketplace/handler.go new file mode 100644 index 00000000..0517cdda --- /dev/null +++ b/x/marketplace/handler.go @@ -0,0 +1,50 @@ +package marketplace + +import ( + "fmt" + + "github.com/OmniFlix/omniflixhub/x/marketplace/keeper" + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgListNFT: + res, err := msgServer.ListNFT(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgEditListing: + res, err := msgServer.EditListing(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeListNFT: + res, err := msgServer.DeListNFT(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgBuyNFT: + res, err := msgServer.BuyNFT(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // Auction messages + case *types.MsgCreateAuction: + res, err := msgServer.CreateAuction(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgCancelAuction: + res, err := msgServer.CancelAuction(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgPlaceBid: + res, err := msgServer.PlaceBid(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/marketplace/keeper/alias.go b/x/marketplace/keeper/alias.go new file mode 100644 index 00000000..ad75207c --- /dev/null +++ b/x/marketplace/keeper/alias.go @@ -0,0 +1,13 @@ +package keeper + +import ( + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// GetMarketplaceAccount returns marketplace ModuleAccount +func (k Keeper) GetMarketplaceAccount(ctx sdk.Context) authtypes.ModuleAccountI { + return k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) +} diff --git a/x/marketplace/keeper/auction.go b/x/marketplace/keeper/auction.go new file mode 100644 index 00000000..217deb13 --- /dev/null +++ b/x/marketplace/keeper/auction.go @@ -0,0 +1,350 @@ +package keeper + +import ( + "fmt" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" +) + +// GetNextAuctionNumber get the next auction number +func (k Keeper) GetNextAuctionNumber(ctx sdk.Context) uint64 { + var nextAuctionNumber uint64 + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.PrefixNextAuctionNumber) + if bz == nil { + panic(fmt.Errorf("%s module not initialized -- Should have been done in InitGenesis", types.ModuleName)) + } else { + val := gogotypes.UInt64Value{} + + err := k.cdc.Unmarshal(bz, &val) + if err != nil { + panic(err) + } + + nextAuctionNumber = val.GetValue() + } + return nextAuctionNumber +} + +// SetNextAuctionNumber set the next auction number +func (k Keeper) SetNextAuctionNumber(ctx sdk.Context, number uint64) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: number}) + store.Set(types.PrefixNextAuctionNumber, bz) +} + +// SetAuctionListing set a specific auction listing in the store +func (k Keeper) SetAuctionListing(ctx sdk.Context, auctionListing types.AuctionListing) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionId) + bz := k.cdc.MustMarshal(&auctionListing) + store.Set(types.KeyAuctionIdPrefix(auctionListing.Id), bz) +} + +// GetAuctionListing returns a auction listing by its id +func (k Keeper) GetAuctionListing(ctx sdk.Context, id uint64) (val types.AuctionListing, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionId) + b := store.Get(types.KeyAuctionIdPrefix(id)) + if b == nil { + return val, false + } + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetListing returns a listing from its nft id +func (k Keeper) GetAuctionListingIdByNftId(ctx sdk.Context, nftId string) (val uint64, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionNFTID) + bz := store.Get(types.KeyAuctionNFTIDPrefix(nftId)) + if bz == nil { + return val, false + } + var auctionId gogotypes.UInt64Value + k.cdc.MustUnmarshal(bz, &auctionId) + return auctionId.Value, true +} + +// RemoveAuctionListing removes a auction listing from the store +func (k Keeper) RemoveAuctionListing(ctx sdk.Context, id uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionId) + store.Delete(types.KeyAuctionIdPrefix(id)) +} + +// GetAllAuctionListings returns all auction listings +func (k Keeper) GetAllAuctionListings(ctx sdk.Context) (list []types.AuctionListing) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionId) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.AuctionListing + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// GetAuctionListingsByOwner returns all auction listings of specific owner +func (k Keeper) GetAuctionListingsByOwner(ctx sdk.Context, owner sdk.AccAddress) (auctionListings []types.AuctionListing) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, append(types.PrefixAuctionOwner, owner.Bytes()...)) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var id gogotypes.UInt64Value + k.cdc.MustUnmarshal(iterator.Value(), &id) + listing, found := k.GetAuctionListing(ctx, id.Value) + if !found { + continue + } + auctionListings = append(auctionListings, listing) + } + + return +} + +func (k Keeper) HasAuctionListing(ctx sdk.Context, id uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.KeyAuctionIdPrefix(id)) +} + +func (k Keeper) SetAuctionListingWithOwner(ctx sdk.Context, owner sdk.AccAddress, id uint64) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: id}) + + store.Set(types.KeyAuctionOwnerPrefix(owner, id), bz) +} + +func (k Keeper) UnsetAuctionListingWithOwner(ctx sdk.Context, owner sdk.AccAddress, id uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyAuctionOwnerPrefix(owner, id)) +} + +func (k Keeper) SetAuctionListingWithNFTID(ctx sdk.Context, nftId string, id uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionNFTID) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: id}) + store.Set(types.KeyAuctionNFTIDPrefix(nftId), bz) +} + +func (k Keeper) UnsetAuctionListingWithNFTID(ctx sdk.Context, nftId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionNFTID) + store.Delete(types.KeyAuctionNFTIDPrefix(nftId)) +} + +func (k Keeper) SetAuctionListingWithPriceDenom(ctx sdk.Context, priceDenom string, id uint64) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: id}) + + store.Set(types.KeyAuctionPriceDenomPrefix(priceDenom, id), bz) +} + +func (k Keeper) UnsetAuctionListingWithPriceDenom(ctx sdk.Context, priceDenom string, id uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyAuctionPriceDenomPrefix(priceDenom, id)) +} + +func (k Keeper) SetInactiveAuction(ctx sdk.Context, auctionId uint64) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: auctionId}) + + store.Set(types.KeyInActiveAuctionPrefix(auctionId), bz) +} + +func (k Keeper) UnsetInactiveAuction(ctx sdk.Context, auctionId uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyInActiveAuctionPrefix(auctionId)) +} + +func (k Keeper) SetActiveAuction(ctx sdk.Context, auctionId uint64) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: auctionId}) + + store.Set(types.KeyActiveAuctionPrefix(auctionId), bz) +} + +func (k Keeper) UnsetActiveAuction(ctx sdk.Context, auctionId uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyActiveAuctionPrefix(auctionId)) +} + +func (k Keeper) IterateInactiveAuctions(ctx sdk.Context, fn func(index int, item types.AuctionListing) (stop bool)) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixInactiveAuction) + iter := sdk.KVStorePrefixIterator(store, []byte{}) + defer iter.Close() + + for i := 0; iter.Valid(); iter.Next() { + var id gogotypes.UInt64Value + k.cdc.MustUnmarshal(iter.Value(), &id) + auction, _ := k.GetAuctionListing(ctx, id.Value) + + if stop := fn(i, auction); stop { + break + } + i++ + } +} + +func (k Keeper) IterateActiveAuctions(ctx sdk.Context, fn func(index int, item types.AuctionListing) (stop bool)) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixActiveAuction) + iter := sdk.KVStorePrefixIterator(store, []byte{}) + defer iter.Close() + + for i := 0; iter.Valid(); iter.Next() { + var id gogotypes.UInt64Value + k.cdc.MustUnmarshal(iter.Value(), &id) + auction, _ := k.GetAuctionListing(ctx, id.Value) + + if stop := fn(i, auction); stop { + break + } + i++ + } +} + +// UpdateAuctionStatusesAndProcessBids update all auction listings status +func (k Keeper) UpdateAuctionStatusesAndProcessBids(ctx sdk.Context) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixAuctionId) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var auction types.AuctionListing + k.cdc.MustUnmarshal(iterator.Value(), &auction) + + // if auction is active + if auction.StartTime.Before(ctx.BlockTime()) { + + durationFromStartTime := ctx.BlockTime().Sub(auction.StartTime) + bidCloseDuration := k.GetBidCloseDuration(ctx) + bid, found := k.GetBid(ctx, auction.GetId()) + + // if auction has ended + if auction.EndTime != nil && auction.EndTime.Before(ctx.BlockTime()) || + auction.EndTime == nil && durationFromStartTime > bidCloseDuration { + + // process bid if found else return NFT to owner + if found { + err := k.processBid(ctx, auction, bid) + if err != nil { + return err + } + // emit events + k.processBidEvent(ctx, auction, bid) + k.RemoveAuctionListing(ctx, auction.GetId()) + k.RemoveBid(ctx, auction.GetId()) + + } else { + err := k.returnNftToOwner( + ctx, + auction.GetDenomId(), + auction.GetNftId(), + k.accountKeeper.GetModuleAddress(types.ModuleName), + auction.GetOwner(), + ) + if err != nil { + return err + } + // emit events + k.RemoveAuctionListing(ctx, auction.GetId()) + k.removeAuctionEvent(ctx, auction) + } + } + } + } + return nil +} + +func (k Keeper) processBid(ctx sdk.Context, auction types.AuctionListing, bid types.Bid) error { + owner, err := sdk.AccAddressFromBech32(auction.Owner) + if err != nil { + return err + } + denom, err := k.nftKeeper.GetDenom(ctx, auction.DenomId) + if err != nil { + return err + } + nft, err := k.nftKeeper.GetONFT(ctx, auction.DenomId, auction.NftId) + if err != nil { + return err + } + BidAmountCoin := bid.Amount + auctionSaleAmountCoin := BidAmountCoin + err = k.nftKeeper.TransferOwnership(ctx, auction.GetDenomId(), auction.GetNftId(), + k.accountKeeper.GetModuleAddress(types.ModuleName), bid.GetBidder()) + if err != nil { + return err + } + saleCommission := k.GetSaleCommission(ctx) + marketplaceCoin := k.GetProportions(bid.Amount, saleCommission) + if marketplaceCoin.Amount.GTE(sdk.OneInt()) { + err = k.DistributeCommission(ctx, marketplaceCoin) + if err != nil { + return err + } + auctionSaleAmountCoin = BidAmountCoin.Sub(marketplaceCoin) + } + if nft.GetRoyaltyShare().GT(sdk.ZeroDec()) { + nftRoyaltyShareCoin := k.GetProportions(auctionSaleAmountCoin, nft.GetRoyaltyShare()) + creator, err := sdk.AccAddressFromBech32(denom.Creator) + if err != nil { + return err + } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creator, sdk.NewCoins(nftRoyaltyShareCoin)) + if err != nil { + return err + } + k.createRoyaltyShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), creator, nftRoyaltyShareCoin) + auctionSaleAmountCoin = auctionSaleAmountCoin.Sub(nftRoyaltyShareCoin) + } + remaining := auctionSaleAmountCoin + + if len(auction.SplitShares) > 0 { + for _, share := range auction.SplitShares { + sharePortionCoin := k.GetProportions(auctionSaleAmountCoin, share.Weight) + sharePortionCoins := sdk.NewCoins(sharePortionCoin) + if share.Address == "" { + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sharePortionCoins) + if err != nil { + return err + } + } else { + saleSplitAddr, err := sdk.AccAddressFromBech32(share.Address) + if err != nil { + return err + } + err = k.bankKeeper.SendCoinsFromModuleToAccount( + ctx, types.ModuleName, saleSplitAddr, sharePortionCoins) + if err != nil { + return err + } + k.createSplitShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), saleSplitAddr, sharePortionCoin) + } + remaining = remaining.Sub(sharePortionCoin) + } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + if err != nil { + return err + } + } else { + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + if err != nil { + return err + } + } + return nil +} + +func (k Keeper) returnNftToOwner(ctx sdk.Context, denomId, nftId string, moduleAddress, owner sdk.AccAddress) error { + err := k.nftKeeper.TransferOwnership(ctx, denomId, nftId, moduleAddress, owner) + if err != nil { + return err + } + return nil +} diff --git a/x/marketplace/keeper/bid.go b/x/marketplace/keeper/bid.go new file mode 100644 index 00000000..b07e2a1e --- /dev/null +++ b/x/marketplace/keeper/bid.go @@ -0,0 +1,73 @@ +package keeper + +import ( + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" +) + +// SetBid set a specific bid for an auction listing in the store +func (k Keeper) SetBid(ctx sdk.Context, bid types.Bid) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixBidByAuctionId) + bz := k.cdc.MustMarshal(&bid) + store.Set(types.KeyBidPrefix(bid.AuctionId), bz) +} + +// GetBid returns a bid of an auction listing by its id +func (k Keeper) GetBid(ctx sdk.Context, id uint64) (val types.Bid, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixBidByAuctionId) + b := store.Get(types.KeyBidPrefix(id)) + if b == nil { + return val, false + } + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveBid removes a bid of an auction listing from the store +func (k Keeper) RemoveBid(ctx sdk.Context, id uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixBidByAuctionId) + store.Delete(types.KeyBidPrefix(id)) +} + +// GetAllBids returns all bids +func (k Keeper) GetAllBids(ctx sdk.Context) (list []types.Bid) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixBidByAuctionId) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Bid + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// GetBidsByBidder returns all bids of specific bidder +func (k Keeper) GetBidsByBidder(ctx sdk.Context, bidder sdk.AccAddress) (bids []types.Bid) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, append(types.PrefixBidByBidder, bidder.Bytes()...)) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var id gogotypes.UInt64Value + k.cdc.MustUnmarshal(iterator.Value(), &id) + bid, found := k.GetBid(ctx, id.Value) + if !found { + continue + } + bids = append(bids, bid) + } + + return +} + +func (k Keeper) HasBid(ctx sdk.Context, id uint64) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixBidByAuctionId) + return store.Has(types.KeyBidPrefix(id)) +} diff --git a/x/marketplace/keeper/events.go b/x/marketplace/keeper/events.go new file mode 100644 index 00000000..0b7e8d63 --- /dev/null +++ b/x/marketplace/keeper/events.go @@ -0,0 +1,161 @@ +package keeper + +import ( + "fmt" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k *Keeper) createListNftEvent(ctx sdk.Context, owner sdk.AccAddress, listingId, denomId, nftId string, price sdk.Coin) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeListNFT, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyOwner, owner.String()), + sdk.NewAttribute(types.AttributeKeyListingId, listingId), + sdk.NewAttribute(types.AttributeKeyDenomId, denomId), + sdk.NewAttribute(types.AttributeKeyNftId, nftId), + sdk.NewAttribute(types.AttributeKeyAmount, price.String()), + ), + }) +} + +func (k *Keeper) createDeListNftEvent(ctx sdk.Context, sender sdk.AccAddress, listingId string) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeDeListNFT, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyListingId, listingId), + ), + }) +} + +func (k *Keeper) createEditListingEvent(ctx sdk.Context, sender sdk.AccAddress, listingId string, price sdk.Coin) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeEditListing, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyListingId, listingId), + sdk.NewAttribute(types.AttributeKeyAmount, price.String()), + ), + }) +} + +func (k *Keeper) createBuyNftEvent(ctx sdk.Context, buyer sdk.AccAddress, listId, nftId string, price sdk.Coin) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeBuyNFT, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyBuyer, buyer.String()), + sdk.NewAttribute(types.AttributeKeyListingId, listId), + sdk.NewAttribute(types.AttributeKeyNftId, nftId), + sdk.NewAttribute(types.AttributeKeyAmount, price.String()), + ), + }) +} + +func (k *Keeper) createRoyaltyShareTransferEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, amount sdk.Coin) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRoyaltyShareTransfer, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyRecipient, recipient.String()), + sdk.NewAttribute(types.AttributeKeyAmount, amount.String()), + ), + }) +} + +func (k *Keeper) createSplitShareTransferEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, amount sdk.Coin) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSplitShareTransfer, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyRecipient, recipient.String()), + sdk.NewAttribute(types.AttributeKeyAmount, amount.String()), + ), + }) +} + +func (k *Keeper) createSaleCommissionTransferEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, amount sdk.Coin) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSaleCommissionTransfer, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyRecipient, recipient.String()), + sdk.NewAttribute(types.AttributeKeyAmount, amount.String()), + ), + }) +} + +func (k *Keeper) createAuctionEvent(ctx sdk.Context, auction types.AuctionListing) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeCreateAuction, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyOwner, auction.GetOwner().String()), + sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())), + sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()), + sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()), + sdk.NewAttribute(types.AttributeKeyStartPrice, auction.GetStartPrice().String()), + ), + }) +} + +func (k *Keeper) cancelAuctionEvent(ctx sdk.Context, auction types.AuctionListing) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeCancelAuction, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyOwner, auction.GetOwner().String()), + sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())), + sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()), + sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()), + ), + }) +} + +func (k *Keeper) placeBidEvent(ctx sdk.Context, auction types.AuctionListing, bid types.Bid) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypePlaceBid, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyBidder, bid.GetBidder().String()), + sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())), + sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()), + sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()), + sdk.NewAttribute(types.AttributeKeyAmount, bid.GetAmount().String()), + ), + }) +} + +func (k *Keeper) removeAuctionEvent(ctx sdk.Context, auction types.AuctionListing) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRemoveAuction, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())), + sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()), + sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()), + ), + }) +} + +func (k *Keeper) processBidEvent(ctx sdk.Context, auction types.AuctionListing, bid types.Bid) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeProcessBid, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())), + sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()), + sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()), + sdk.NewAttribute(types.AttributeKeyBidder, bid.GetBidder().String()), + sdk.NewAttribute(types.AttributeKeyAmount, bid.GetAmount().String()), + ), + }) +} diff --git a/x/marketplace/keeper/grpc_query.go b/x/marketplace/keeper/grpc_query.go new file mode 100644 index 00000000..1f13c180 --- /dev/null +++ b/x/marketplace/keeper/grpc_query.go @@ -0,0 +1,393 @@ +package keeper + +import ( + "context" + "fmt" + "time" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + gogotypes "github.com/gogo/protobuf/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +// Params queries params of marketplace module +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + var params types.Params + k.paramSpace.GetParamSet(ctx, ¶ms) + + return &types.QueryParamsResponse{Params: params}, nil +} + +func (k Keeper) Listing(goCtx context.Context, req *types.QueryListingRequest) (*types.QueryListingResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + listing, found := k.GetListing(ctx, req.Id) + if !found { + return nil, status.Errorf(codes.NotFound, "listing %s not found", req.Id) + } + + return &types.QueryListingResponse{Listing: &listing}, nil +} + +func (k Keeper) Listings(goCtx context.Context, req *types.QueryListingsRequest) (*types.QueryListingsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var listings []types.Listing + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + + var owner sdk.AccAddress + var err error + if len(req.Owner) > 0 { + owner, err = sdk.AccAddressFromBech32(req.Owner) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid owner address (%s)", err)) + } + listingStore := prefix.NewStore(store, append(types.PrefixListingOwner, owner.Bytes()...)) + pageRes, err = query.Paginate(listingStore, req.Pagination, func(key []byte, value []byte) error { + var listingId gogotypes.StringValue + k.cdc.MustUnmarshal(value, &listingId) + listing, found := k.GetListing(ctx, listingId.Value) + if found { + listings = append(listings, listing) + } + return nil + }) + + } else if len(req.PriceDenom) > 0 { + listingStore := prefix.NewStore(store, types.KeyListingPriceDenomPrefix(req.PriceDenom, "")) + pageRes, err = query.Paginate(listingStore, req.Pagination, func(key []byte, value []byte) error { + var listingId gogotypes.StringValue + k.cdc.MustUnmarshal(value, &listingId) + listing, found := k.GetListing(ctx, listingId.Value) + if found { + listings = append(listings, listing) + } + return nil + }) + } else { + + listingStore := prefix.NewStore(store, types.PrefixListingId) + pageRes, err = query.Paginate(listingStore, req.Pagination, func(key []byte, value []byte) error { + var listing types.Listing + k.cdc.MustUnmarshal(value, &listing) + listings = append(listings, listing) + return nil + }) + } + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryListingsResponse{Listings: listings, Pagination: pageRes}, nil +} + +func (k Keeper) ListingsByOwner(goCtx context.Context, req *types.QueryListingsByOwnerRequest) (*types.QueryListingsByOwnerResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var owner sdk.AccAddress + var err error + if len(req.Owner) > 0 { + owner, err = sdk.AccAddressFromBech32(req.Owner) + if err != nil || owner == nil { + return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid owner address (%s)", err)) + } + } + + var listings []types.Listing + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + + listingStore := prefix.NewStore(store, append(types.PrefixListingOwner, owner.Bytes()...)) + pageRes, err = query.Paginate(listingStore, req.Pagination, func(key []byte, value []byte) error { + var listingId gogotypes.StringValue + k.cdc.MustUnmarshal(value, &listingId) + listing, found := k.GetListing(ctx, listingId.Value) + if found { + listings = append(listings, listing) + } + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryListingsByOwnerResponse{Listings: listings, Pagination: pageRes}, nil +} + +func (k Keeper) ListingsByPriceDenom( + goCtx context.Context, + req *types.QueryListingsByPriceDenomRequest, +) (*types.QueryListingsByPriceDenomResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var err error + + var listings []types.Listing + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + + listingStore := prefix.NewStore(store, types.KeyListingPriceDenomPrefix(req.PriceDenom, "")) + pageRes, err = query.Paginate(listingStore, req.Pagination, func(key []byte, value []byte) error { + var listingId gogotypes.StringValue + k.cdc.MustUnmarshal(value, &listingId) + listing, found := k.GetListing(ctx, listingId.Value) + if found { + listings = append(listings, listing) + } + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryListingsByPriceDenomResponse{Listings: listings, Pagination: pageRes}, nil +} + +func (k Keeper) ListingByNftId( + goCtx context.Context, + req *types.QueryListingByNFTIDRequest, +) (*types.QueryListingResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + if req.NftId == "" { + return nil, status.Errorf(codes.InvalidArgument, "need nft id to request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + listingId, found := k.GetListingIdByNftId(ctx, req.NftId) + if found { + listing, err := k.Listing(goCtx, &types.QueryListingRequest{ + Id: listingId, + }) + if err != nil { + return nil, err + } + return listing, nil + } + return nil, status.Errorf(codes.NotFound, "listing not found with given nft id") +} + +func (k Keeper) Auctions(goCtx context.Context, req *types.QueryAuctionsRequest) (*types.QueryAuctionsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var filteredAuctions []types.AuctionListing + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + auctionStore := prefix.NewStore(store, types.PrefixAuctionId) + pageRes, err := query.FilteredPaginate(auctionStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + var al types.AuctionListing + k.cdc.MustUnmarshal(value, &al) + matchOwner, matchPriceDenom, matchStatus := true, true, true + // match status (if supplied/valid) + if types.ValidAuctionStatus(req.Status) { + if req.Status == types.AUCTION_STATUS_ACTIVE { + matchStatus = al.StartTime.Before(time.Now()) + } else { + matchStatus = al.StartTime.After(time.Now()) + } + } + + // match owner address (if supplied) + if len(req.Owner) > 0 { + owner, err := sdk.AccAddressFromBech32(req.Owner) + if err != nil { + return false, err + } + + matchOwner = al.Owner == owner.String() + } + + // match Price Denom (if supplied) + if len(req.PriceDenom) > 0 { + matchPriceDenom = al.StartPrice.Denom == req.PriceDenom + } + + if matchOwner && matchPriceDenom && matchStatus { + if accumulate { + filteredAuctions = append(filteredAuctions, al) + } + + return true, nil + } + + return false, nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryAuctionsResponse{Auctions: filteredAuctions, Pagination: pageRes}, nil +} + +func (k Keeper) Auction(goCtx context.Context, req *types.QueryAuctionRequest) (*types.QueryAuctionResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + auction, found := k.GetAuctionListing(ctx, req.Id) + if !found { + return nil, status.Errorf(codes.NotFound, "auction %d not found", req.Id) + } + return &types.QueryAuctionResponse{Auction: &auction}, nil +} + +func (k Keeper) AuctionsByOwner(goCtx context.Context, req *types.QueryAuctionsByOwnerRequest) (*types.QueryAuctionsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var owner sdk.AccAddress + var err error + if len(req.Owner) > 0 { + owner, err = sdk.AccAddressFromBech32(req.Owner) + if err != nil || owner == nil { + return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid owner address (%s)", err)) + } + } + + var auctions []types.AuctionListing + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + + auctionStore := prefix.NewStore(store, append(types.PrefixAuctionOwner, owner.Bytes()...)) + pageRes, err = query.Paginate(auctionStore, req.Pagination, func(key []byte, value []byte) error { + var auctionId gogotypes.UInt64Value + k.cdc.MustUnmarshal(value, &auctionId) + auction, found := k.GetAuctionListing(ctx, auctionId.Value) + if found { + auctions = append(auctions, auction) + } + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryAuctionsResponse{Auctions: auctions, Pagination: pageRes}, nil +} + +func (k Keeper) AuctionsByPriceDenom(goCtx context.Context, req *types.QueryAuctionsByPriceDenomRequest) (*types.QueryAuctionsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var err error + + var auctions []types.AuctionListing + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + + auctionStore := prefix.NewStore(store, append(types.PrefixAuctionPriceDenom, []byte(req.PriceDenom)...)) + pageRes, err = query.Paginate(auctionStore, req.Pagination, func(key []byte, value []byte) error { + var auctionId gogotypes.UInt64Value + k.cdc.MustUnmarshal(value, &auctionId) + auction, found := k.GetAuctionListing(ctx, auctionId.Value) + if found { + auctions = append(auctions, auction) + } + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryAuctionsResponse{Auctions: auctions, Pagination: pageRes}, nil +} + +func (k Keeper) AuctionByNftId(goCtx context.Context, req *types.QueryAuctionByNFTIDRequest) (*types.QueryAuctionResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + if req.NftId == "" { + return nil, status.Errorf(codes.InvalidArgument, "need nft id to request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + auctionId, found := k.GetAuctionListingIdByNftId(ctx, req.NftId) + if found { + auction, err := k.Auction(goCtx, &types.QueryAuctionRequest{ + Id: auctionId, + }) + if err != nil { + return nil, err + } + return auction, nil + } + return nil, status.Errorf(codes.NotFound, "auction not found with given nft id") +} + +func (k Keeper) Bid(goCtx context.Context, req *types.QueryBidRequest) (*types.QueryBidResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + bid, found := k.GetBid(ctx, req.Id) + if !found { + return nil, status.Errorf(codes.NotFound, "bid not found for auction %d", req.Id) + } + return &types.QueryBidResponse{Bid: &bid}, nil +} + +func (k Keeper) Bids(goCtx context.Context, req *types.QueryBidsRequest) (*types.QueryBidsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + var bids []types.Bid + var pageRes *query.PageResponse + store := ctx.KVStore(k.storeKey) + + if len(req.Bidder) > 0 { + _, err := sdk.AccAddressFromBech32(req.Bidder) + if err != nil { + return nil, err + } + } + + bidStore := prefix.NewStore(store, types.PrefixBidByAuctionId) + pageRes, err := query.Paginate(bidStore, req.Pagination, func(key []byte, value []byte) error { + var bid types.Bid + k.cdc.MustUnmarshal(value, &bid) + if len(req.Bidder) > 0 { + if bid.Bidder == req.Bidder { + bids = append(bids, bid) + } + } else { + bids = append(bids, bid) + } + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + return &types.QueryBidsResponse{Bids: bids, Pagination: pageRes}, nil +} diff --git a/x/marketplace/keeper/keeper.go b/x/marketplace/keeper/keeper.go new file mode 100644 index 00000000..cc46d181 --- /dev/null +++ b/x/marketplace/keeper/keeper.go @@ -0,0 +1,307 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" +) + +type Keeper struct { + storeKey sdk.StoreKey + cdc codec.BinaryCodec + + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + nftKeeper types.NftKeeper + distributionKeeper types.DistributionKeeper + paramSpace paramstypes.Subspace +} + +func NewKeeper( + cdc codec.BinaryCodec, + key sdk.StoreKey, + + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + nftKeeper types.NftKeeper, + distrKeeper types.DistributionKeeper, + paramSpace paramstypes.Subspace, +) Keeper { + // ensure marketplace module account is set + if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } + + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + storeKey: key, + cdc: cdc, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + nftKeeper: nftKeeper, + distributionKeeper: distrKeeper, + paramSpace: paramSpace, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("OmniFlix/%s", types.ModuleName)) +} + +// AddListing adds a listing in the store and set owner to listing and updates the count +func (k Keeper) AddListing(ctx sdk.Context, listing types.Listing) error { + // check listing already exists + if k.HasListing(ctx, listing.GetId()) { + return sdkerrors.Wrapf(types.ErrListingAlreadyExists, "listing already exists: %s", listing.GetId()) + } + + err := k.nftKeeper.TransferOwnership(ctx, + listing.GetDenomId(), listing.GetNftId(), listing.GetOwner(), + k.accountKeeper.GetModuleAddress(types.ModuleName)) + if err != nil { + return err + } + // set listing + k.SetListing(ctx, listing) + if len(listing.GetOwner()) != 0 { + // set listing id with owner prefix + k.SetWithOwner(ctx, listing.GetOwner(), listing.GetId()) + } + // Update listing count + count := k.GetListingCount(ctx) + k.SetListingCount(ctx, count+1) + k.SetWithNFTID(ctx, listing.NftId, listing.Id) + + if len(listing.Price.Denom) > 0 { + k.SetWithPriceDenom(ctx, listing.Price.Denom, listing.Id) + } + return nil +} + +func (k Keeper) DeleteListing(ctx sdk.Context, listing types.Listing) { + k.RemoveListing(ctx, listing.GetId()) + k.UnsetWithOwner(ctx, listing.GetOwner(), listing.GetId()) + k.UnsetWithNFTID(ctx, listing.GetNftId()) + k.UnsetWithPriceDenom(ctx, listing.Price.Denom, listing.GetId()) +} + +func (k Keeper) Buy(ctx sdk.Context, listing types.Listing, buyer sdk.AccAddress) error { + owner, err := sdk.AccAddressFromBech32(listing.Owner) + if err != nil { + return err + } + denom, err := k.nftKeeper.GetDenom(ctx, listing.DenomId) + if err != nil { + return err + } + listingPriceCoin := listing.Price + listingSaleAmountCoin := listingPriceCoin + nft, err := k.nftKeeper.GetONFT(ctx, listing.DenomId, listing.NftId) + if err != nil { + return err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, buyer, types.ModuleName, sdk.NewCoins(listingPriceCoin)) + if err != nil { + return err + } + err = k.nftKeeper.TransferOwnership(ctx, listing.GetDenomId(), listing.GetNftId(), + k.accountKeeper.GetModuleAddress(types.ModuleName), buyer) + if err != nil { + _ = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, buyer, sdk.NewCoins(listing.Price)) + return err + } + saleCommission := k.GetSaleCommission(ctx) + marketplaceCoin := k.GetProportions(listing.Price, saleCommission) + if marketplaceCoin.Amount.GTE(sdk.OneInt()) { + err = k.DistributeCommission(ctx, marketplaceCoin) + if err != nil { + return err + } + listingSaleAmountCoin = listingPriceCoin.Sub(marketplaceCoin) + } + if nft.GetRoyaltyShare().GT(sdk.ZeroDec()) { + nftRoyaltyShareCoin := k.GetProportions(listingSaleAmountCoin, nft.GetRoyaltyShare()) + creator, err := sdk.AccAddressFromBech32(denom.Creator) + if err != nil { + return err + } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creator, sdk.NewCoins(nftRoyaltyShareCoin)) + if err != nil { + return err + } + k.createRoyaltyShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), creator, nftRoyaltyShareCoin) + listingSaleAmountCoin = listingSaleAmountCoin.Sub(nftRoyaltyShareCoin) + } + remaining := listingSaleAmountCoin + + if len(listing.SplitShares) > 0 { + for _, share := range listing.SplitShares { + sharePortionCoin := k.GetProportions(listingSaleAmountCoin, share.Weight) + sharePortionCoins := sdk.NewCoins(sharePortionCoin) + if share.Address == "" { + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sharePortionCoins) + if err != nil { + return err + } + } else { + saleSplitAddr, err := sdk.AccAddressFromBech32(share.Address) + if err != nil { + return err + } + err = k.bankKeeper.SendCoinsFromModuleToAccount( + ctx, types.ModuleName, saleSplitAddr, sharePortionCoins) + if err != nil { + return err + } + k.createSplitShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), saleSplitAddr, sharePortionCoin) + } + remaining = remaining.Sub(sharePortionCoin) + } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + if err != nil { + return err + } + } else { + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + if err != nil { + return err + } + } + + k.DeleteListing(ctx, listing) + return nil +} + +func (k Keeper) GetProportions(totalCoin sdk.Coin, ratio sdk.Dec) sdk.Coin { + return sdk.NewCoin(totalCoin.Denom, totalCoin.Amount.ToDec().Mul(ratio).TruncateInt()) +} + +func (k Keeper) DistributeCommission(ctx sdk.Context, marketplaceCoin sdk.Coin) error { + distrParams := k.GetMarketplaceDistributionParams(ctx) + stakingCommissionCoin := k.GetProportions(marketplaceCoin, distrParams.Staking) + if distrParams.Staking.GT(sdk.ZeroDec()) && stakingCommissionCoin.Amount.GT(sdk.ZeroInt()) { + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, authtypes.FeeCollectorName, sdk.NewCoins(stakingCommissionCoin)) + if err != nil { + return err + } + k.createSaleCommissionTransferEvent(ctx, + k.accountKeeper.GetModuleAddress(types.ModuleName), + k.accountKeeper.GetModuleAddress(authtypes.FeeCollectorName), + stakingCommissionCoin, + ) + marketplaceCoin = marketplaceCoin.Sub(stakingCommissionCoin) + } + communityPoolCommissionCoin := marketplaceCoin + + err := k.distributionKeeper.FundCommunityPool( + ctx, + sdk.NewCoins(communityPoolCommissionCoin), + k.accountKeeper.GetModuleAddress(types.ModuleName), + ) + if err != nil { + return err + } + k.createSaleCommissionTransferEvent(ctx, + k.accountKeeper.GetModuleAddress(types.ModuleName), + k.accountKeeper.GetModuleAddress("distribution"), + communityPoolCommissionCoin, + ) + + return nil +} + +// CreateAuctionListing creates a auction in the store and set owner to auction and updates the next auction number +func (k Keeper) CreateAuctionListing(ctx sdk.Context, auction types.AuctionListing) error { + // check auction already exists or not + if k.HasAuctionListing(ctx, auction.GetId()) { + return sdkerrors.Wrapf(types.ErrListingAlreadyExists, "auction listing already exists: %d", auction.GetId()) + } + + err := k.nftKeeper.TransferOwnership(ctx, + auction.GetDenomId(), auction.GetNftId(), auction.GetOwner(), + k.accountKeeper.GetModuleAddress(types.ModuleName)) + if err != nil { + return err + } + // set auction listing + k.SetAuctionListing(ctx, auction) + + if len(auction.GetOwner()) != 0 { + // set auction listing id with owner prefix + k.SetAuctionListingWithOwner(ctx, auction.GetOwner(), auction.GetId()) + } + // Update auction listing next number + auctionId := k.GetNextAuctionNumber(ctx) + k.SetNextAuctionNumber(ctx, auctionId+1) + k.SetAuctionListingWithNFTID(ctx, auction.NftId, auction.Id) + + if len(auction.StartPrice.Denom) > 0 { + k.SetAuctionListingWithPriceDenom(ctx, auction.StartPrice.Denom, auction.Id) + } + return nil +} + +func (k Keeper) CancelAuctionListing(ctx sdk.Context, auction types.AuctionListing) error { + // Check bid Exists or Not + if k.HasBid(ctx, auction.Id) { + return sdkerrors.Wrapf(types.ErrBidExists, "cannot cancel auction %d, bid exists ", auction.Id) + } + + // Transfer Back NFT ownership to auction owner + err := k.nftKeeper.TransferOwnership(ctx, auction.GetDenomId(), auction.GetNftId(), + k.accountKeeper.GetModuleAddress(types.ModuleName), auction.GetOwner()) + if err != nil { + return err + } + k.RemoveAuctionListing(ctx, auction.GetId()) + k.UnsetAuctionListingWithOwner(ctx, auction.GetOwner(), auction.GetId()) + k.UnsetAuctionListingWithNFTID(ctx, auction.GetNftId()) + k.UnsetAuctionListingWithPriceDenom(ctx, auction.StartPrice.Denom, auction.GetId()) + + return nil +} + +func (k Keeper) PlaceBid(ctx sdk.Context, auction types.AuctionListing, newBid types.Bid) error { + // Check bids of auction + newBidPrice := auction.StartPrice + prevBid, bidExists := k.GetBid(ctx, auction.Id) + if bidExists { + newBidPrice = k.GetNewBidPrice(auction.StartPrice.Denom, prevBid.Amount, auction.IncrementPercentage) + } + if newBid.Amount.IsLT(newBidPrice) { + return sdkerrors.Wrapf(types.ErrBidAmountNotEnough, + "cannot place bid for given auction %d, required amount to bid is %s", auction.Id, newBidPrice.String()) + } + + // Transfer amount from bidder to module account + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, newBid.GetBidder(), types.ModuleName, sdk.NewCoins(newBid.Amount)) + if err != nil { + return err + } + // Release previous Bid + if bidExists { + _ = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, prevBid.GetBidder(), sdk.NewCoins(prevBid.Amount)) + k.RemoveBid(ctx, prevBid.AuctionId) + } + // Set new bid + k.SetBid(ctx, newBid) + + return nil +} + +func (k Keeper) GetNewBidPrice(denom string, amount sdk.Coin, increment sdk.Dec) sdk.Coin { + return sdk.NewCoin(denom, amount.Amount.Add(amount.Amount.ToDec().Mul(increment).TruncateInt())) +} diff --git a/x/marketplace/keeper/listing.go b/x/marketplace/keeper/listing.go new file mode 100644 index 00000000..97549379 --- /dev/null +++ b/x/marketplace/keeper/listing.go @@ -0,0 +1,146 @@ +package keeper + +import ( + "encoding/binary" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" +) + +// GetListingCount get the total number of listings +func (k Keeper) GetListingCount(ctx sdk.Context) uint64 { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.PrefixListingsCount + bz := store.Get(byteKey) + + // Count doesn't exist: no element + if bz == nil { + return 0 + } + + // Parse bytes + return binary.BigEndian.Uint64(bz) +} + +// SetListingCount set the total number of listings +func (k Keeper) SetListingCount(ctx sdk.Context, count uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.PrefixListingsCount + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, count) + store.Set(byteKey, bz) +} + +// SetListing set a specific listing in the store +func (k Keeper) SetListing(ctx sdk.Context, listing types.Listing) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingId) + b := k.cdc.MustMarshal(&listing) + store.Set(types.KeyListingIdPrefix(listing.Id), b) +} + +// GetListing returns a listing from its id +func (k Keeper) GetListing(ctx sdk.Context, id string) (val types.Listing, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingId) + b := store.Get(types.KeyListingIdPrefix(id)) + if b == nil { + return val, false + } + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetListing returns a listing from its nft id +func (k Keeper) GetListingIdByNftId(ctx sdk.Context, nftId string) (val string, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingNFTID) + b := store.Get(types.KeyListingNFTIDPrefix(nftId)) + if b == nil { + return val, false + } + var listingId gogotypes.StringValue + k.cdc.MustUnmarshal(b, &listingId) + return listingId.Value, true +} + +// RemoveListing removes a listing from the store +func (k Keeper) RemoveListing(ctx sdk.Context, id string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingId) + store.Delete(types.KeyListingIdPrefix(id)) +} + +// GetAllListings returns all listings +func (k Keeper) GetAllListings(ctx sdk.Context) (list []types.Listing) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingId) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Listing + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// GetListingsByOwner returns all listings of specific owner +func (k Keeper) GetListingsByOwner(ctx sdk.Context, owner sdk.AccAddress) (listings []types.Listing) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, append(types.PrefixListingOwner, owner.Bytes()...)) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var id gogotypes.StringValue + k.cdc.MustUnmarshal(iterator.Value(), &id) + listing, found := k.GetListing(ctx, id.Value) + if !found { + continue + } + listings = append(listings, listing) + } + + return +} + +func (k Keeper) HasListing(ctx sdk.Context, id string) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.KeyListingIdPrefix(id)) +} + +func (k Keeper) SetWithOwner(ctx sdk.Context, owner sdk.AccAddress, id string) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.StringValue{Value: id}) + + store.Set(types.KeyListingOwnerPrefix(owner, id), bz) +} + +func (k Keeper) UnsetWithOwner(ctx sdk.Context, owner sdk.AccAddress, id string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyListingOwnerPrefix(owner, id)) +} + +func (k Keeper) SetWithNFTID(ctx sdk.Context, nftId, id string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingNFTID) + bz := k.cdc.MustMarshal(&gogotypes.StringValue{Value: id}) + store.Set(types.KeyListingNFTIDPrefix(nftId), bz) +} + +func (k Keeper) UnsetWithNFTID(ctx sdk.Context, nftId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PrefixListingNFTID) + store.Delete(types.KeyListingNFTIDPrefix(nftId)) +} + +func (k Keeper) SetWithPriceDenom(ctx sdk.Context, priceDenom, id string) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.StringValue{Value: id}) + + store.Set(types.KeyListingPriceDenomPrefix(priceDenom, id), bz) +} + +func (k Keeper) UnsetWithPriceDenom(ctx sdk.Context, priceDenom, id string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyListingPriceDenomPrefix(priceDenom, id)) +} diff --git a/x/marketplace/keeper/msg_server.go b/x/marketplace/keeper/msg_server.go new file mode 100644 index 00000000..d80dd373 --- /dev/null +++ b/x/marketplace/keeper/msg_server.go @@ -0,0 +1,262 @@ +package keeper + +import ( + "context" + "time" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "golang.org/x/exp/slices" +) + +type msgServer struct { + Keeper +} + +var _ types.MsgServer = msgServer{} + +// NewMsgServerImpl returns an implementation of the token MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +func (m msgServer) ListNFT(goCtx context.Context, msg *types.MsgListNFT) (*types.MsgListNFTResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return nil, err + } + + nft, err := m.nftKeeper.GetONFT(ctx, msg.DenomId, msg.NftId) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrNftNotExists, + "invalid nft and or denomId, nftId %s, denomId %s", msg.NftId, msg.DenomId) + } + if owner.String() != nft.GetOwner().String() { + return nil, sdkerrors.Wrapf(types.ErrUnauthorized, "unauthorized address %s", owner) + } + if !nft.IsTransferable() { + return nil, sdkerrors.Wrapf( + types.ErrNftNonTransferable, "non-transferable nfts not allowed to list in marketplace") + } + + listing := types.NewListing(msg.Id, msg.NftId, msg.DenomId, msg.Price, owner, msg.SplitShares) + err = m.Keeper.AddListing(ctx, listing) + if err != nil { + return nil, err + } + + m.Keeper.createListNftEvent(ctx, owner, listing.Id, listing.DenomId, listing.NftId, listing.Price) + + return &types.MsgListNFTResponse{}, nil +} + +func (m msgServer) EditListing(goCtx context.Context, + msg *types.MsgEditListing, +) (*types.MsgEditListingResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return nil, err + } + + listing, found := m.Keeper.GetListing(ctx, msg.Id) + if !found { + return nil, sdkerrors.Wrapf(types.ErrListingDoesNotExists, "listing id %s not exists", msg.Id) + } + if owner.String() != listing.Owner { + return nil, sdkerrors.Wrapf(types.ErrUnauthorized, "unauthorized address %s", owner) + } + if err := types.ValidatePrice(msg.Price); err != nil { + return nil, err + } + listing.Price = msg.Price + m.Keeper.SetListing(ctx, listing) + + m.Keeper.createEditListingEvent(ctx, owner, listing.Id, listing.Price) + + return &types.MsgEditListingResponse{}, nil +} + +func (m msgServer) DeListNFT(goCtx context.Context, + msg *types.MsgDeListNFT, +) (*types.MsgDeListNFTResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return nil, err + } + listing, found := m.Keeper.GetListing(ctx, msg.Id) + if !found { + return nil, sdkerrors.Wrapf(types.ErrListingDoesNotExists, "listing id %s not exists", msg.Id) + } + if owner.String() != listing.Owner { + return nil, sdkerrors.Wrapf(types.ErrUnauthorized, "unauthorized address %s", owner) + } + err = m.nftKeeper.TransferOwnership(ctx, listing.GetDenomId(), listing.GetNftId(), + m.accountKeeper.GetModuleAddress(types.ModuleName), listing.GetOwner()) + if err != nil { + return nil, err + } + m.Keeper.DeleteListing(ctx, listing) + + m.Keeper.createDeListNftEvent(ctx, owner, listing.Id) + + return &types.MsgDeListNFTResponse{}, nil +} + +func (m msgServer) BuyNFT(goCtx context.Context, msg *types.MsgBuyNFT) (*types.MsgBuyNFTResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + buyer, err := sdk.AccAddressFromBech32(msg.Buyer) + if err != nil { + return nil, err + } + + listing, found := m.Keeper.GetListing(ctx, msg.Id) + if !found { + return nil, sdkerrors.Wrapf(types.ErrListingDoesNotExists, "listing id %s not exists", msg.Id) + } + if err := types.ValidatePrice(msg.Price); err != nil { + return nil, err + } + if !msg.Price.Equal(listing.Price) { + if msg.Price.Denom != listing.Price.Denom { + return nil, sdkerrors.Wrapf(types.ErrInvalidPriceDenom, "invalid price denom %s", msg.Price.Denom) + } + if msg.Price.Amount.LT(listing.Price.Amount) { + return nil, sdkerrors.Wrapf(types.ErrNotEnoughAmount, + "%s is not enough, to buy %s required", msg.Price.String(), listing.Price.String()) + } + return nil, sdkerrors.Wrapf(types.ErrInvalidPrice, + "price %s not matched with listing price", msg.Price.String()) + } + err = m.Keeper.Buy(ctx, listing, buyer) + if err != nil { + return nil, err + } + + m.Keeper.createBuyNftEvent(ctx, buyer, listing.Id, listing.NftId, listing.Price) + + return &types.MsgBuyNFTResponse{}, nil +} + +// CreateAuction creates a new auction +func (m msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return nil, err + } + if err := msg.Validate(ctx.BlockTime()); err != nil { + return nil, err + } + + nft, err := m.nftKeeper.GetONFT(ctx, msg.DenomId, msg.NftId) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrNftNotExists, + "invalid nft and or denomId, nftId %s, denomId %s", msg.NftId, msg.DenomId) + } + if owner.String() != nft.GetOwner().String() { + return nil, sdkerrors.Wrapf(types.ErrUnauthorized, "unauthorized address %s", owner) + } + if !nft.IsTransferable() { + return nil, sdkerrors.Wrapf( + types.ErrNftNonTransferable, "non-transferable nfts not allowed to list in marketplace") + } + var endTime *time.Time + if msg.Duration != nil { + maxAuctionDuration := m.Keeper.GetMaxAuctionDuration(ctx) + if msg.Duration.Seconds() > maxAuctionDuration.Seconds() { + return nil, sdkerrors.Wrapf(types.ErrInvalidDuration, + "duration %s exceeds max auction duration %s", msg.Duration.String(), maxAuctionDuration.String()) + } + endAt := msg.StartTime.Add(*msg.Duration) + endTime = &endAt + if endTime.Before(msg.StartTime) || endTime.Equal(msg.StartTime) { + return nil, sdkerrors.Wrapf(types.ErrInvalidDuration, "duration must be positive or nil") + } + } + auctionNumber := m.Keeper.GetNextAuctionNumber(ctx) + auction := types.NewAuctionListing(auctionNumber, msg.NftId, msg.DenomId, + msg.StartTime, endTime, msg.StartPrice, + msg.IncrementPercentage, owner, msg.WhitelistAccounts, msg.SplitShares) + err = m.Keeper.CreateAuctionListing(ctx, auction) + if err != nil { + return nil, err + } + + m.Keeper.createAuctionEvent(ctx, auction) + + return &types.MsgCreateAuctionResponse{ + Auction: &auction, + }, nil +} + +// CancelAuction +func (m msgServer) CancelAuction(goCtx context.Context, msg *types.MsgCancelAuction) (*types.MsgCancelAuctionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return nil, err + } + + auction, found := m.Keeper.GetAuctionListing(ctx, msg.AuctionId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrAuctionDoesNotExists, "auction id %d not exists", msg.AuctionId) + } + if owner.String() != auction.Owner { + return nil, sdkerrors.Wrapf(types.ErrUnauthorized, "unauthorized address %s", owner.String()) + } + + err = m.Keeper.CancelAuctionListing(ctx, auction) + if err != nil { + return nil, err + } + + m.Keeper.cancelAuctionEvent(ctx, auction) + + return &types.MsgCancelAuctionResponse{}, nil +} + +// PlaceBid +func (m msgServer) PlaceBid(goCtx context.Context, msg *types.MsgPlaceBid) (*types.MsgPlaceBidResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + bidder, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + return nil, err + } + + auction, found := m.Keeper.GetAuctionListing(ctx, msg.AuctionId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrAuctionDoesNotExists, "auction id %d not exists", msg.AuctionId) + } + if !auction.StartTime.Before(ctx.BlockTime()) { + return nil, sdkerrors.Wrapf(types.ErrInActiveAuction, "cannot place a bid for inactive auction %d, ", auction.Id) + } + if len(auction.WhitelistAccounts) > 0 && !slices.Contains(auction.WhitelistAccounts, bidder.String()) { + return nil, sdkerrors.Wrapf(types.ErrUnauthorized, "cannot place a bid for this auction %d, only whitelisted accounts allowed to bid", auction.Id) + } + if msg.Amount.GetDenom() != auction.StartPrice.GetDenom() { + return nil, sdkerrors.Wrapf(types.ErrInvalidPriceDenom, "given auction only accepts bids in %s, ", auction.StartPrice.GetDenom()) + } + + bid := types.NewBid(auction.Id, msg.Amount, ctx.BlockTime(), bidder) + + err = m.Keeper.PlaceBid(ctx, auction, bid) + if err != nil { + return nil, err + } + + m.Keeper.placeBidEvent(ctx, auction, bid) + + return &types.MsgPlaceBidResponse{}, nil +} diff --git a/x/marketplace/keeper/params.go b/x/marketplace/keeper/params.go new file mode 100644 index 00000000..f840d44f --- /dev/null +++ b/x/marketplace/keeper/params.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "time" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams gets the parameters for the marketplace module. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramSpace.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the parameters for the marketplace module. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} + +// GetSaleCommission returns the current sale commission of marketplace. +func (k Keeper) GetSaleCommission(ctx sdk.Context) (percent sdk.Dec) { + k.paramSpace.Get(ctx, types.ParamStoreKeySaleCommission, &percent) + return percent +} + +// GetMarketplaceDistributionParams returns the current distribution of marketplace commission. +func (k Keeper) GetMarketplaceDistributionParams(ctx sdk.Context) (distParams types.Distribution) { + k.paramSpace.Get(ctx, types.ParamStoreKeyDistribution, &distParams) + return distParams +} + +// GetBidCloseDuration returns the closing duration for bid for auctions. +func (k Keeper) GetBidCloseDuration(ctx sdk.Context) (duration time.Duration) { + k.paramSpace.Get(ctx, types.ParamStoreKeyBidCloseDuration, &duration) + return duration +} + +// GetMaxAuctionDuration returns the maximum duration for auctions. +func (k Keeper) GetMaxAuctionDuration(ctx sdk.Context) (duration time.Duration) { + k.paramSpace.Get(ctx, types.ParamStoreKeyMaxAuctionDuration, &duration) + return duration +} diff --git a/x/marketplace/keeper/querier.go b/x/marketplace/keeper/querier.go new file mode 100644 index 00000000..4011dd41 --- /dev/null +++ b/x/marketplace/keeper/querier.go @@ -0,0 +1,162 @@ +package keeper + +import ( + "fmt" + "strings" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/OmniFlix/omniflixhub/x/marketplace/types" +) + +func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) { + switch path[0] { + case types.QueryParams: + return queryParams(ctx, path[1:], req, k, legacyQuerierCdc) + case types.QueryListing: + return queryListing(ctx, req, k, legacyQuerierCdc) + case types.QueryAllListings: + return queryAllListings(ctx, req, k, legacyQuerierCdc) + case types.QueryListingsByOwner: + return queryListingsByOwner(ctx, req, k, legacyQuerierCdc) + case types.QueryAuction: + return queryAuction(ctx, req, k, legacyQuerierCdc) + case types.QueryAllAuctions: + return queryAllAuctions(ctx, req, k, legacyQuerierCdc) + case types.QueryAuctionsByOwner: + return queryAuctionsByOwner(ctx, req, k, legacyQuerierCdc) + case types.QueryBid: + return queryBid(ctx, req, k, legacyQuerierCdc) + case types.QueryAllBids: + return queryAllBids(ctx, req, k, legacyQuerierCdc) + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) + } + } +} + +func queryParams(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + params := k.GetParams(ctx) + + res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) + } + + return res, nil +} + +func queryListing(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryListingParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + id := strings.ToLower(strings.TrimSpace(params.Id)) + + listing, found := k.GetListing(ctx, id) + if !found { + return nil, sdkerrors.Wrap(types.ErrListingDoesNotExists, fmt.Sprintf("listing %s does not exist", id)) + } + return codec.MarshalJSONIndent(legacyQuerierCdc, listing) +} + +func queryAllListings(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryAllListingsParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + listings := k.GetAllListings(ctx) + + return codec.MarshalJSONIndent(legacyQuerierCdc, listings) +} + +func queryListingsByOwner(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryListingsByOwnerParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + listings := k.GetListingsByOwner(ctx, params.Owner) + return codec.MarshalJSONIndent(legacyQuerierCdc, listings) +} + +func queryAuction(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryAuctionParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + auction, found := k.GetAuctionListing(ctx, params.Id) + if !found { + return nil, sdkerrors.Wrap(types.ErrAuctionDoesNotExists, fmt.Sprintf("auction %d does not exist", params.Id)) + } + return codec.MarshalJSONIndent(legacyQuerierCdc, auction) +} + +func queryAllAuctions(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryAllAuctionsParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + auctions := k.GetAllAuctionListings(ctx) + + return codec.MarshalJSONIndent(legacyQuerierCdc, auctions) +} + +func queryAuctionsByOwner(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryAuctionsByOwnerParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + auctions := k.GetAuctionListingsByOwner(ctx, params.Owner) + return codec.MarshalJSONIndent(legacyQuerierCdc, auctions) +} + +func queryBid(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryBidParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + bid, found := k.GetBid(ctx, params.Id) + if !found { + return nil, sdkerrors.Wrap(types.ErrBidDoesNotExists, fmt.Sprintf("auction %d does not have any bid", params.Id)) + } + return codec.MarshalJSONIndent(legacyQuerierCdc, bid) +} + +func queryAllBids(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + var params types.QueryAllBidsParams + + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } + + bids := k.GetAllBids(ctx) + + return codec.MarshalJSONIndent(legacyQuerierCdc, bids) +} diff --git a/x/marketplace/module.go b/x/marketplace/module.go new file mode 100644 index 00000000..22bf43a3 --- /dev/null +++ b/x/marketplace/module.go @@ -0,0 +1,166 @@ +package marketplace + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/OmniFlix/omniflixhub/x/marketplace/client/cli" + "github.com/OmniFlix/omniflixhub/x/marketplace/client/rest" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/spf13/cobra" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/OmniFlix/omniflixhub/x/marketplace/keeper" + "github.com/OmniFlix/omniflixhub/x/marketplace/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the marketplace module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the marketplace module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the marketplace module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the marketplace module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.ValidateGenesis() +} + +// RegisterRESTRoutes registers the marketplace module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { + rest.RegisterHandlers(clientCtx, rtr) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the marketplace module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the marketplace module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the marketplace module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the marketplace module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the marketplace module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the marketplace module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the marketplace module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return keeper.NewQuerier(am.keeper, legacyQuerierCdc) +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the marketplace module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the marketplace module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the marketplace module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the marketplace module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the marketplace module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return EndBlock(ctx, am.keeper) +} diff --git a/x/marketplace/types/auction.go b/x/marketplace/types/auction.go new file mode 100644 index 00000000..490d9361 --- /dev/null +++ b/x/marketplace/types/auction.go @@ -0,0 +1,79 @@ +package types + +import ( + "time" + + "github.com/OmniFlix/omniflixhub/x/marketplace/exported" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" +) + +var ( + _ proto.Message = &AuctionListing{} + _ exported.AuctionListingI = &AuctionListing{} +) + +func NewAuctionListing(id uint64, nftId, denomId string, startTime time.Time, endTime *time.Time, startPrice sdk.Coin, incrementPercentage sdk.Dec, + owner sdk.AccAddress, whitelistAccounts []string, splitShares []WeightedAddress, +) AuctionListing { + return AuctionListing{ + Id: id, + NftId: nftId, + DenomId: denomId, + StartTime: startTime, + EndTime: endTime, + StartPrice: startPrice, + IncrementPercentage: incrementPercentage, + Owner: owner.String(), + WhitelistAccounts: whitelistAccounts, + SplitShares: splitShares, + } +} + +func (al AuctionListing) GetId() uint64 { + return al.Id +} + +func (al AuctionListing) GetDenomId() string { + return al.DenomId +} + +func (al AuctionListing) GetNftId() string { + return al.NftId +} + +func (al AuctionListing) GetStartTime() time.Time { + return al.StartTime +} + +func (al AuctionListing) GetStartPrice() sdk.Coin { + return al.StartPrice +} + +func (al AuctionListing) GetIncrementPercentage() sdk.Dec { + return al.IncrementPercentage +} + +func (al AuctionListing) GetOwner() sdk.AccAddress { + owner, _ := sdk.AccAddressFromBech32(al.Owner) + return owner +} + +func (al AuctionListing) GetSplitShares() interface{} { + return al.SplitShares +} + +func (al AuctionListing) GetStatus() string { + if al.StartTime.Before(time.Now()) { + return AUCTION_STATUS_ACTIVE.String() + } + return AUCTION_STATUS_INACTIVE.String() +} + +func ValidAuctionStatus(status AuctionStatus) bool { + if status == AUCTION_STATUS_INACTIVE || + status == AUCTION_STATUS_ACTIVE { + return true + } + return false +} diff --git a/x/marketplace/types/auction.pb.go b/x/marketplace/types/auction.pb.go new file mode 100644 index 00000000..1dcf86e4 --- /dev/null +++ b/x/marketplace/types/auction.pb.go @@ -0,0 +1,1104 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/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_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 AuctionStatus int32 + +const ( + AUCTION_STATUS_UNSPECIFIED AuctionStatus = 0 + AUCTION_STATUS_INACTIVE AuctionStatus = 1 + AUCTION_STATUS_ACTIVE AuctionStatus = 2 +) + +var AuctionStatus_name = map[int32]string{ + 0: "AUCTION_STATUS_UNSPECIFIED", + 1: "AUCTION_STATUS_INACTIVE", + 2: "AUCTION_STATUS_ACTIVE", +} + +var AuctionStatus_value = map[string]int32{ + "AUCTION_STATUS_UNSPECIFIED": 0, + "AUCTION_STATUS_INACTIVE": 1, + "AUCTION_STATUS_ACTIVE": 2, +} + +func (x AuctionStatus) String() string { + return proto.EnumName(AuctionStatus_name, int32(x)) +} + +func (AuctionStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_67ff771a16a600e4, []int{0} +} + +type AuctionListing struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty" yaml:"nft_id"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty" yaml:"denom_id"` + StartPrice types.Coin `protobuf:"bytes,4,opt,name=start_price,json=startPrice,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"start_price" yaml:"start_price"` + StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + EndTime *time.Time `protobuf:"bytes,6,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time,omitempty" yaml:"end_time"` + Owner string `protobuf:"bytes,7,opt,name=owner,proto3" json:"owner,omitempty"` + IncrementPercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=increment_percentage,json=incrementPercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_percentage" yaml:"increment_percentage"` + WhitelistAccounts []string `protobuf:"bytes,9,rep,name=whitelist_accounts,json=whitelistAccounts,proto3" json:"whitelist_accounts,omitempty" yaml:"whitelist_accounts"` + SplitShares []WeightedAddress `protobuf:"bytes,10,rep,name=split_shares,json=splitShares,proto3" json:"split_shares" yaml:"split_shares"` +} + +func (m *AuctionListing) Reset() { *m = AuctionListing{} } +func (m *AuctionListing) String() string { return proto.CompactTextString(m) } +func (*AuctionListing) ProtoMessage() {} +func (*AuctionListing) Descriptor() ([]byte, []int) { + return fileDescriptor_67ff771a16a600e4, []int{0} +} +func (m *AuctionListing) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuctionListing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuctionListing.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 *AuctionListing) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuctionListing.Merge(m, src) +} +func (m *AuctionListing) XXX_Size() int { + return m.Size() +} +func (m *AuctionListing) XXX_DiscardUnknown() { + xxx_messageInfo_AuctionListing.DiscardUnknown(m) +} + +var xxx_messageInfo_AuctionListing proto.InternalMessageInfo + +type Bid struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty" yaml:"auction_id"` + Bidder string `protobuf:"bytes,2,opt,name=bidder,proto3" json:"bidder,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` + Time time.Time `protobuf:"bytes,4,opt,name=time,proto3,stdtime" json:"time"` +} + +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_67ff771a16a600e4, []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 init() { + proto.RegisterEnum("OmniFlix.marketplace.v1beta1.AuctionStatus", AuctionStatus_name, AuctionStatus_value) + proto.RegisterType((*AuctionListing)(nil), "OmniFlix.marketplace.v1beta1.AuctionListing") + proto.RegisterType((*Bid)(nil), "OmniFlix.marketplace.v1beta1.Bid") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/auction.proto", fileDescriptor_67ff771a16a600e4) +} + +var fileDescriptor_67ff771a16a600e4 = []byte{ + // 758 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0x8e, 0x93, 0x34, 0x4d, 0x26, 0xec, 0xb2, 0x9d, 0x76, 0x59, 0x37, 0x05, 0x3b, 0xf8, 0x00, + 0xd1, 0x4a, 0x6b, 0x6b, 0x77, 0x91, 0x40, 0x7b, 0x8b, 0xb3, 0x59, 0xc9, 0x12, 0xa4, 0x91, 0x93, + 0x00, 0xe2, 0x62, 0x39, 0x9e, 0x89, 0x33, 0x6a, 0xec, 0x89, 0xec, 0x09, 0x6d, 0x6f, 0xc0, 0x2f, + 0xe8, 0x4f, 0xe0, 0xcc, 0x2f, 0xe9, 0x81, 0x43, 0x8f, 0x88, 0x43, 0x4a, 0xdb, 0x0b, 0xe7, 0xfc, + 0x02, 0xe4, 0x99, 0x71, 0x13, 0x0a, 0x6a, 0xf7, 0x94, 0x79, 0xef, 0x7d, 0xef, 0xcb, 0xe7, 0x6f, + 0xde, 0x1b, 0xf0, 0x9c, 0x46, 0x31, 0x99, 0xcc, 0xc8, 0x89, 0x15, 0xf9, 0xc9, 0x11, 0x66, 0xf3, + 0x99, 0x1f, 0x60, 0xeb, 0xc7, 0x97, 0x63, 0xcc, 0xfc, 0x97, 0x96, 0xbf, 0x08, 0x18, 0xa1, 0xb1, + 0x39, 0x4f, 0x28, 0xa3, 0xf0, 0xe3, 0xc3, 0x28, 0x26, 0xef, 0x66, 0xe4, 0xc4, 0xdc, 0xc0, 0x9a, + 0x12, 0xdb, 0xd0, 0x02, 0x9a, 0x46, 0x34, 0xb5, 0xc6, 0x7e, 0xba, 0x26, 0x08, 0x28, 0x91, 0xdd, + 0x8d, 0xbd, 0x90, 0x86, 0x94, 0x1f, 0xad, 0xec, 0x24, 0xb3, 0x7a, 0x48, 0x69, 0x38, 0xc3, 0x16, + 0x8f, 0xc6, 0x8b, 0x89, 0xc5, 0x48, 0x84, 0x53, 0xe6, 0x47, 0x73, 0x09, 0xb8, 0x5f, 0xe0, 0x8c, + 0xa4, 0x8c, 0xc4, 0xa1, 0xc0, 0x1a, 0xbf, 0x54, 0xc0, 0xe3, 0xb6, 0x90, 0xfc, 0xb5, 0x28, 0xc0, + 0xc7, 0xa0, 0x48, 0x90, 0xaa, 0x34, 0x95, 0x56, 0xd9, 0x2d, 0x12, 0x04, 0x5b, 0xa0, 0x12, 0x4f, + 0x98, 0x47, 0x90, 0x5a, 0x6c, 0x2a, 0xad, 0x9a, 0xbd, 0xb3, 0x5a, 0xea, 0x8f, 0x4e, 0xfd, 0x68, + 0xf6, 0xc6, 0x10, 0x79, 0xc3, 0xdd, 0x8a, 0x27, 0xcc, 0x41, 0xd0, 0x04, 0x55, 0x84, 0x63, 0x1a, + 0x65, 0xd8, 0x12, 0xc7, 0xee, 0xae, 0x96, 0xfa, 0x87, 0x02, 0x9b, 0x57, 0x0c, 0x77, 0x9b, 0x1f, + 0x1d, 0x04, 0x7f, 0x56, 0x40, 0x3d, 0x65, 0x7e, 0xc2, 0xbc, 0x79, 0x42, 0x02, 0xac, 0x96, 0x9b, + 0x4a, 0xab, 0xfe, 0x6a, 0xdf, 0x14, 0xb6, 0x98, 0x99, 0x2d, 0xb9, 0x57, 0x66, 0x87, 0x92, 0xd8, + 0xee, 0x9e, 0x2f, 0xf5, 0xc2, 0x6a, 0xa9, 0x43, 0x41, 0xb9, 0xd1, 0x6b, 0xfc, 0x76, 0xa9, 0x7f, + 0x1e, 0x12, 0x36, 0x5d, 0x8c, 0xcd, 0x80, 0x46, 0x96, 0x74, 0x56, 0xfc, 0xbc, 0x48, 0xd1, 0x91, + 0xc5, 0x4e, 0xe7, 0x38, 0xe5, 0x34, 0x2e, 0xe0, 0x8d, 0xfd, 0xac, 0x0f, 0x7e, 0x0f, 0x44, 0xe4, + 0x65, 0x2e, 0xaa, 0x5b, 0x5c, 0x41, 0xc3, 0x14, 0x16, 0x9b, 0xb9, 0xc5, 0xe6, 0x30, 0xb7, 0xd8, + 0xfe, 0x44, 0x4a, 0xd8, 0xd9, 0x94, 0x90, 0xf5, 0x1a, 0x67, 0x97, 0xba, 0xe2, 0xd6, 0x78, 0x22, + 0x83, 0xc3, 0x1e, 0xa8, 0xe2, 0x18, 0x09, 0xde, 0xca, 0x83, 0xbc, 0xcf, 0xd6, 0x4e, 0xe5, 0x5d, + 0x82, 0x71, 0x1b, 0xc7, 0x88, 0xf3, 0xed, 0x81, 0x2d, 0x7a, 0x1c, 0xe3, 0x44, 0xdd, 0xce, 0xac, + 0x75, 0x45, 0x00, 0x7f, 0x52, 0xc0, 0x1e, 0x89, 0x83, 0x04, 0x47, 0x38, 0x66, 0xde, 0x1c, 0x27, + 0x01, 0x8e, 0x99, 0x1f, 0x62, 0xb5, 0xca, 0x2f, 0xe0, 0x9b, 0x4c, 0xee, 0x9f, 0x4b, 0xfd, 0xb3, + 0xf7, 0xf0, 0xe6, 0x2d, 0x0e, 0x56, 0x4b, 0xfd, 0x40, 0x88, 0xf8, 0x3f, 0x4e, 0xc3, 0xdd, 0xbd, + 0x4d, 0xf7, 0x6f, 0xb3, 0xb0, 0x0f, 0xe0, 0xf1, 0x94, 0x30, 0x9c, 0x4d, 0x96, 0xe7, 0x07, 0x01, + 0x5d, 0xc4, 0x2c, 0x55, 0x6b, 0xcd, 0x52, 0xab, 0x66, 0x7f, 0x2a, 0xed, 0xda, 0x17, 0xac, 0xff, + 0xc5, 0x19, 0xee, 0xce, 0x6d, 0xb2, 0x2d, 0x73, 0x30, 0x02, 0x1f, 0xa4, 0xf3, 0x19, 0x61, 0x5e, + 0x3a, 0xf5, 0x13, 0x9c, 0xaa, 0xa0, 0x59, 0x6a, 0xd5, 0x5f, 0xbd, 0x30, 0xef, 0xdb, 0x26, 0xf3, + 0x3b, 0x4c, 0xc2, 0x29, 0xc3, 0xa8, 0x8d, 0x50, 0x82, 0xd3, 0xd4, 0x3e, 0x90, 0x7f, 0xbd, 0x2b, + 0x6f, 0x6a, 0x83, 0xd0, 0x70, 0xeb, 0x3c, 0x1c, 0x88, 0xe8, 0x77, 0x05, 0x94, 0x6c, 0x82, 0xe0, + 0x17, 0x00, 0xc8, 0xf5, 0xf5, 0xf2, 0x0d, 0xb0, 0x9f, 0xae, 0xef, 0x7a, 0x5d, 0x33, 0xdc, 0x9a, + 0x0c, 0x1c, 0x04, 0x3f, 0x02, 0x95, 0x31, 0x41, 0x08, 0x27, 0x62, 0x3f, 0x5c, 0x19, 0xc1, 0x2f, + 0x41, 0xc5, 0x8f, 0xb2, 0xef, 0xe1, 0xbb, 0x70, 0xef, 0x5c, 0x97, 0x33, 0xa9, 0xae, 0x84, 0xc3, + 0xaf, 0x40, 0x99, 0x0f, 0x4d, 0xf9, 0xc1, 0xa1, 0xa9, 0x66, 0x7d, 0x7c, 0x4a, 0x78, 0xc7, 0x9b, + 0xf2, 0xdf, 0xbf, 0xea, 0xca, 0xf3, 0x10, 0x3c, 0x92, 0x2b, 0x3d, 0x60, 0x3e, 0x5b, 0xa4, 0x50, + 0x03, 0x8d, 0xf6, 0xa8, 0x33, 0x74, 0x0e, 0x7b, 0xde, 0x60, 0xd8, 0x1e, 0x8e, 0x06, 0xde, 0xa8, + 0x37, 0xe8, 0x77, 0x3b, 0xce, 0x3b, 0xa7, 0xfb, 0xf6, 0x49, 0x01, 0x1e, 0x80, 0x67, 0x77, 0xea, + 0x4e, 0xaf, 0xdd, 0x19, 0x3a, 0xdf, 0x76, 0x9f, 0x28, 0x70, 0x1f, 0x3c, 0xbd, 0x53, 0x94, 0xa5, + 0xa2, 0x3d, 0x3a, 0xbf, 0xd2, 0x0a, 0x17, 0x57, 0x5a, 0xe1, 0xfc, 0x5a, 0x53, 0x2e, 0xae, 0x35, + 0xe5, 0xaf, 0x6b, 0x4d, 0x39, 0xbb, 0xd1, 0x0a, 0x17, 0x37, 0x5a, 0xe1, 0x8f, 0x1b, 0xad, 0xf0, + 0xc3, 0xeb, 0x8d, 0xb1, 0xcb, 0x2f, 0xcf, 0xca, 0x9f, 0xa7, 0xe9, 0x62, 0x6c, 0xfd, 0xfb, 0x8d, + 0xe2, 0x73, 0x38, 0xae, 0xf0, 0x2f, 0x7d, 0xfd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x72, 0x67, + 0xd5, 0xdc, 0x69, 0x05, 0x00, 0x00, +} + +func (this *Bid) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Bid) + if !ok { + that2, ok := that.(Bid) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.AuctionId != that1.AuctionId { + return false + } + if this.Bidder != that1.Bidder { + return false + } + if !this.Amount.Equal(&that1.Amount) { + return false + } + if !this.Time.Equal(that1.Time) { + return false + } + return true +} +func (m *AuctionListing) 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 *AuctionListing) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuctionListing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SplitShares) > 0 { + for iNdEx := len(m.SplitShares) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SplitShares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.WhitelistAccounts) > 0 { + for iNdEx := len(m.WhitelistAccounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.WhitelistAccounts[iNdEx]) + copy(dAtA[i:], m.WhitelistAccounts[iNdEx]) + i = encodeVarintAuction(dAtA, i, uint64(len(m.WhitelistAccounts[iNdEx]))) + i-- + dAtA[i] = 0x4a + } + } + { + size := m.IncrementPercentage.Size() + i -= size + if _, err := m.IncrementPercentage.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintAuction(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x3a + } + if m.EndTime != nil { + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.EndTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintAuction(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x32 + } + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintAuction(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x2a + { + size, err := m.StartPrice.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintAuction(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintAuction(dAtA, i, uint64(len(m.NftId))) + 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 + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintAuction(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x22 + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + 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] = 0x12 + } + if m.AuctionId != 0 { + i = encodeVarintAuction(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + 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 *AuctionListing) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovAuction(uint64(m.Id)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = m.StartPrice.Size() + n += 1 + l + sovAuction(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovAuction(uint64(l)) + if m.EndTime != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.EndTime) + n += 1 + l + sovAuction(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = m.IncrementPercentage.Size() + n += 1 + l + sovAuction(uint64(l)) + if len(m.WhitelistAccounts) > 0 { + for _, s := range m.WhitelistAccounts { + l = len(s) + n += 1 + l + sovAuction(uint64(l)) + } + } + if len(m.SplitShares) > 0 { + for _, e := range m.SplitShares { + l = e.Size() + 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.AuctionId != 0 { + n += 1 + sovAuction(uint64(m.AuctionId)) + } + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovAuction(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) + 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 *AuctionListing) 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: AuctionListing: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuctionListing: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", 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.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", 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.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartPrice", 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.StartPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", 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 m.EndTime == nil { + m.EndTime = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncrementPercentage", 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.IncrementPercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistAccounts", 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.WhitelistAccounts = append(m.WhitelistAccounts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SplitShares", 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 + } + m.SplitShares = append(m.SplitShares, WeightedAddress{}) + if err := m.SplitShares[len(m.SplitShares)-1].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 (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 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 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, 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/marketplace/types/bid.go b/x/marketplace/types/bid.go new file mode 100644 index 00000000..e1a0abba --- /dev/null +++ b/x/marketplace/types/bid.go @@ -0,0 +1,36 @@ +package types + +import ( + "time" + + "github.com/OmniFlix/omniflixhub/x/marketplace/exported" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" +) + +var ( + _ proto.Message = &Bid{} + _ exported.BidI = &Bid{} +) + +func NewBid(auctionId uint64, amount sdk.Coin, bidTime time.Time, bidder sdk.AccAddress) Bid { + return Bid{ + AuctionId: auctionId, + Amount: amount, + Time: bidTime, + Bidder: bidder.String(), + } +} + +func (b Bid) GetAuctionId() uint64 { + return b.AuctionId +} + +func (b Bid) GetAmount() sdk.Coin { + return b.Amount +} + +func (b Bid) GetBidder() sdk.AccAddress { + bidder, _ := sdk.AccAddressFromBech32(b.Bidder) + return bidder +} diff --git a/x/marketplace/types/codec.go b/x/marketplace/types/codec.go new file mode 100644 index 00000000..a8000a7d --- /dev/null +++ b/x/marketplace/types/codec.go @@ -0,0 +1,68 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" + + "github.com/OmniFlix/omniflixhub/x/marketplace/exported" +) + +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgListNFT{}, "OmniFlix/marketplace/MsgListNFT", nil) + cdc.RegisterConcrete(&MsgEditListing{}, "OmniFlix/marketplace/MsgEditListing", nil) + cdc.RegisterConcrete(&MsgDeListNFT{}, "OmniFlix/marketplace/MsgDeListNFT", nil) + cdc.RegisterConcrete(&MsgBuyNFT{}, "OmniFlix/marketplace/MsgBuyNFT", nil) + cdc.RegisterConcrete(&MsgCreateAuction{}, "OmniFlix/marketplace/MsgCreateAuction", nil) + cdc.RegisterConcrete(&MsgCancelAuction{}, "OmniFlix/marketplace/MsgCancelAuction", nil) + cdc.RegisterConcrete(&MsgPlaceBid{}, "OmniFlix/marketplace/MsgPlaceBid", nil) + + cdc.RegisterInterface((*exported.ListingI)(nil), nil) + cdc.RegisterConcrete(&Listing{}, "OmniFlix/marketplace/Listing", nil) + cdc.RegisterInterface((*exported.AuctionListingI)(nil), nil) + cdc.RegisterConcrete(&AuctionListing{}, "OmniFlix/marketplace/AuctionListing", nil) +} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgListNFT{}, + &MsgEditListing{}, + &MsgDeListNFT{}, + &MsgBuyNFT{}, + &MsgCreateAuction{}, + &MsgCancelAuction{}, + &MsgPlaceBid{}, + ) + + registry.RegisterImplementations((*exported.ListingI)(nil), + &Listing{}, + ) + registry.RegisterImplementations((*exported.AuctionListingI)(nil), + &AuctionListing{}, + ) +} + +var ( + amino = codec.NewLegacyAmino() + + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} + +func MustMarshalListingID(cdc codec.BinaryCodec, listingId string) []byte { + listingIdWrap := gogotypes.StringValue{Value: listingId} + return cdc.MustMarshal(&listingIdWrap) +} + +func MustUnMarshalListingID(cdc codec.BinaryCodec, value []byte) string { + var listingIdWrap gogotypes.StringValue + cdc.MustUnmarshal(value, &listingIdWrap) + return listingIdWrap.Value +} diff --git a/x/marketplace/types/constants.go b/x/marketplace/types/constants.go new file mode 100644 index 00000000..9d0d41b1 --- /dev/null +++ b/x/marketplace/types/constants.go @@ -0,0 +1,8 @@ +package types + +const ( + MinListingIdLength = 4 + MaxListingIdLength = 64 + MaxSplits = 5 + MaxWhitelistAccounts = 10 +) diff --git a/x/marketplace/types/errors.go b/x/marketplace/types/errors.go new file mode 100644 index 00000000..a2068bae --- /dev/null +++ b/x/marketplace/types/errors.go @@ -0,0 +1,36 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// Listing module errors +var ( + ErrListingNotExists = sdkerrors.Register(ModuleName, 2, "Listing does not exist") + ErrInvalidOwner = sdkerrors.Register(ModuleName, 3, "invalid Listing owner") + ErrInvalidPrice = sdkerrors.Register(ModuleName, 4, "invalid amount") + ErrInvalidListing = sdkerrors.Register(ModuleName, 5, "invalid Listing") + ErrListingAlreadyExists = sdkerrors.Register(ModuleName, 6, "Listing already exists") + ErrNotEnoughAmount = sdkerrors.Register(ModuleName, 7, "amount is not enough to buy") + ErrInvalidPriceDenom = sdkerrors.Register(ModuleName, 8, "invalid price denom") + ErrInvalidListingId = sdkerrors.Register(ModuleName, 9, "invalid Listing id") + ErrInvalidNftId = sdkerrors.Register(ModuleName, 10, "invalid nft id") + ErrNftNotExists = sdkerrors.Register(ModuleName, 11, "nft not exists with given details") + ErrUnauthorized = sdkerrors.Register(ModuleName, 12, "unauthorized") + ErrNftNonTransferable = sdkerrors.Register(ModuleName, 13, "non-transferable nft") + ErrListingDoesNotExists = sdkerrors.Register(ModuleName, 14, "listing doesn't exists") + ErrInvalidSplits = sdkerrors.Register(ModuleName, 15, "invalid split shares") + ErrNonPositiveNumber = sdkerrors.Register(ModuleName, 16, "non positive number") + ErrInvalidAuctionId = sdkerrors.Register(ModuleName, 17, "invalid auction id") + ErrInvalidWhitelistAccounts = sdkerrors.Register(ModuleName, 18, "invalid whitelist accounts") + ErrAuctionDoesNotExists = sdkerrors.Register(ModuleName, 19, "auction listing doesn't exists") + ErrBidExists = sdkerrors.Register(ModuleName, 20, "bid exists") + ErrEndedAuction = sdkerrors.Register(ModuleName, 21, "auction ended") + ErrInActiveAuction = sdkerrors.Register(ModuleName, 22, "inactive auction") + ErrBidAmountNotEnough = sdkerrors.Register(ModuleName, 23, "amount is not enough to bid") + ErrBidDoesNotExists = sdkerrors.Register(ModuleName, 24, "bid does not exists") + ErrInvalidStartTime = sdkerrors.Register(ModuleName, 25, "invalid start time") + ErrInvalidPercentage = sdkerrors.Register(ModuleName, 26, "invalid percentage decimal value") + ErrInvalidTime = sdkerrors.Register(ModuleName, 27, "invalid timestamp value") + ErrInvalidDuration = sdkerrors.Register(ModuleName, 28, "invalid duration") +) diff --git a/x/marketplace/types/events.go b/x/marketplace/types/events.go new file mode 100644 index 00000000..967ca9f7 --- /dev/null +++ b/x/marketplace/types/events.go @@ -0,0 +1,29 @@ +package types + +const ( + EventTypeListNFT = "list_nft" + EventTypeEditListing = "edit_listing" + EventTypeDeListNFT = "de_list_nft" + EventTypeBuyNFT = "buy_nft" + EventTypeRoyaltyShareTransfer = "royalty_share_transfer" + EventTypeSplitShareTransfer = "split_share_transfer" + EventTypeSaleCommissionTransfer = "sale_commission_transfer" + + EventTypeCreateAuction = "create_auction" + EventTypeCancelAuction = "cancel_auction" + EventTypePlaceBid = "place_bid" + EventTypeRemoveAuction = "remove_auction" + EventTypeProcessBid = "process_bid" + + AttributeValueCategory = ModuleName + AttributeKeyListingId = "listing-id" + AttributeKeyDenomId = "denom-id" + AttributeKeyNftId = "nft-id" + AttributeKeyBuyer = "buyer" + AttributeKeyOwner = "owner" + AttributeKeyRecipient = "recipient" + AttributeKeyAmount = "amount" + AttributeKeyAuctionId = "auction-id" + AttributeKeyStartPrice = "start-price" + AttributeKeyBidder = "bidder" +) diff --git a/x/marketplace/types/events.pb.go b/x/marketplace/types/events.pb.go new file mode 100644 index 00000000..3cfbb77a --- /dev/null +++ b/x/marketplace/types/events.pb.go @@ -0,0 +1,2581 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/events.proto + +package types + +import ( + fmt "fmt" + 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 + +// EventListONFT is emitted on NFT Listing on market +type EventListNFT struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *EventListNFT) Reset() { *m = EventListNFT{} } +func (m *EventListNFT) String() string { return proto.CompactTextString(m) } +func (*EventListNFT) ProtoMessage() {} +func (*EventListNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{0} +} +func (m *EventListNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventListNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventListNFT.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 *EventListNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventListNFT.Merge(m, src) +} +func (m *EventListNFT) XXX_Size() int { + return m.Size() +} +func (m *EventListNFT) XXX_DiscardUnknown() { + xxx_messageInfo_EventListNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_EventListNFT proto.InternalMessageInfo + +func (m *EventListNFT) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *EventListNFT) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventListNFT) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventListNFT) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// EventEditListing is emitted on edit Listing on market +type EventEditListing struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *EventEditListing) Reset() { *m = EventEditListing{} } +func (m *EventEditListing) String() string { return proto.CompactTextString(m) } +func (*EventEditListing) ProtoMessage() {} +func (*EventEditListing) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{1} +} +func (m *EventEditListing) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventEditListing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventEditListing.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 *EventEditListing) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventEditListing.Merge(m, src) +} +func (m *EventEditListing) XXX_Size() int { + return m.Size() +} +func (m *EventEditListing) XXX_DiscardUnknown() { + xxx_messageInfo_EventEditListing.DiscardUnknown(m) +} + +var xxx_messageInfo_EventEditListing proto.InternalMessageInfo + +func (m *EventEditListing) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *EventEditListing) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventEditListing) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventEditListing) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// EventDeListONFT is emitted on NFT DeListing from market +type EventDeListNFT struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *EventDeListNFT) Reset() { *m = EventDeListNFT{} } +func (m *EventDeListNFT) String() string { return proto.CompactTextString(m) } +func (*EventDeListNFT) ProtoMessage() {} +func (*EventDeListNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{2} +} +func (m *EventDeListNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventDeListNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventDeListNFT.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 *EventDeListNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventDeListNFT.Merge(m, src) +} +func (m *EventDeListNFT) XXX_Size() int { + return m.Size() +} +func (m *EventDeListNFT) XXX_DiscardUnknown() { + xxx_messageInfo_EventDeListNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_EventDeListNFT proto.InternalMessageInfo + +func (m *EventDeListNFT) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *EventDeListNFT) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventDeListNFT) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventDeListNFT) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// EventBuyONFT is emitted on NFT Buy +type EventBuyNFT struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` + Buyer string `protobuf:"bytes,5,opt,name=buyer,proto3" json:"buyer,omitempty"` +} + +func (m *EventBuyNFT) Reset() { *m = EventBuyNFT{} } +func (m *EventBuyNFT) String() string { return proto.CompactTextString(m) } +func (*EventBuyNFT) ProtoMessage() {} +func (*EventBuyNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{3} +} +func (m *EventBuyNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBuyNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBuyNFT.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 *EventBuyNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBuyNFT.Merge(m, src) +} +func (m *EventBuyNFT) XXX_Size() int { + return m.Size() +} +func (m *EventBuyNFT) XXX_DiscardUnknown() { + xxx_messageInfo_EventBuyNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBuyNFT proto.InternalMessageInfo + +func (m *EventBuyNFT) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *EventBuyNFT) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventBuyNFT) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventBuyNFT) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *EventBuyNFT) GetBuyer() string { + if m != nil { + return m.Buyer + } + return "" +} + +// EventCreateAuction is emitted on creating auction +type EventCreateAuction struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` + MinPrice string `protobuf:"bytes,5,opt,name=min_price,json=minPrice,proto3" json:"min_price,omitempty"` +} + +func (m *EventCreateAuction) Reset() { *m = EventCreateAuction{} } +func (m *EventCreateAuction) String() string { return proto.CompactTextString(m) } +func (*EventCreateAuction) ProtoMessage() {} +func (*EventCreateAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{4} +} +func (m *EventCreateAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreateAuction.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 *EventCreateAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateAuction.Merge(m, src) +} +func (m *EventCreateAuction) XXX_Size() int { + return m.Size() +} +func (m *EventCreateAuction) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateAuction proto.InternalMessageInfo + +func (m *EventCreateAuction) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *EventCreateAuction) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventCreateAuction) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventCreateAuction) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *EventCreateAuction) GetMinPrice() string { + if m != nil { + return m.MinPrice + } + return "" +} + +// EventCancelAuction is emitted on canceling auction +type EventCancelAuction struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *EventCancelAuction) Reset() { *m = EventCancelAuction{} } +func (m *EventCancelAuction) String() string { return proto.CompactTextString(m) } +func (*EventCancelAuction) ProtoMessage() {} +func (*EventCancelAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{5} +} +func (m *EventCancelAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCancelAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCancelAuction.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 *EventCancelAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCancelAuction.Merge(m, src) +} +func (m *EventCancelAuction) XXX_Size() int { + return m.Size() +} +func (m *EventCancelAuction) XXX_DiscardUnknown() { + xxx_messageInfo_EventCancelAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCancelAuction proto.InternalMessageInfo + +func (m *EventCancelAuction) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *EventCancelAuction) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventCancelAuction) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventCancelAuction) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// EventPlaceBid is emitted on placing bid for an auction +type EventPlaceBid struct { + AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Bidder string `protobuf:"bytes,4,opt,name=bidder,proto3" json:"bidder,omitempty"` + Amount string `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *EventPlaceBid) Reset() { *m = EventPlaceBid{} } +func (m *EventPlaceBid) String() string { return proto.CompactTextString(m) } +func (*EventPlaceBid) ProtoMessage() {} +func (*EventPlaceBid) Descriptor() ([]byte, []int) { + return fileDescriptor_1f26db43bc3ef6c8, []int{6} +} +func (m *EventPlaceBid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventPlaceBid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventPlaceBid.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 *EventPlaceBid) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPlaceBid.Merge(m, src) +} +func (m *EventPlaceBid) XXX_Size() int { + return m.Size() +} +func (m *EventPlaceBid) XXX_DiscardUnknown() { + xxx_messageInfo_EventPlaceBid.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPlaceBid proto.InternalMessageInfo + +func (m *EventPlaceBid) GetAuctionId() string { + if m != nil { + return m.AuctionId + } + return "" +} + +func (m *EventPlaceBid) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +func (m *EventPlaceBid) GetDenomId() string { + if m != nil { + return m.DenomId + } + return "" +} + +func (m *EventPlaceBid) GetBidder() string { + if m != nil { + return m.Bidder + } + return "" +} + +func (m *EventPlaceBid) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func init() { + proto.RegisterType((*EventListNFT)(nil), "OmniFlix.marketplace.v1beta1.EventListNFT") + proto.RegisterType((*EventEditListing)(nil), "OmniFlix.marketplace.v1beta1.EventEditListing") + proto.RegisterType((*EventDeListNFT)(nil), "OmniFlix.marketplace.v1beta1.EventDeListNFT") + proto.RegisterType((*EventBuyNFT)(nil), "OmniFlix.marketplace.v1beta1.EventBuyNFT") + proto.RegisterType((*EventCreateAuction)(nil), "OmniFlix.marketplace.v1beta1.EventCreateAuction") + proto.RegisterType((*EventCancelAuction)(nil), "OmniFlix.marketplace.v1beta1.EventCancelAuction") + proto.RegisterType((*EventPlaceBid)(nil), "OmniFlix.marketplace.v1beta1.EventPlaceBid") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/events.proto", fileDescriptor_1f26db43bc3ef6c8) +} + +var fileDescriptor_1f26db43bc3ef6c8 = []byte{ + // 374 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xcf, 0x4e, 0xea, 0x40, + 0x14, 0xc6, 0x29, 0xf7, 0xc2, 0x85, 0x73, 0xef, 0x25, 0xa6, 0x51, 0x53, 0xa3, 0x36, 0xa6, 0x2b, + 0xdd, 0xb4, 0x21, 0x3c, 0x81, 0x28, 0x24, 0x24, 0xfe, 0x21, 0xc6, 0x95, 0x1b, 0x32, 0xed, 0x4c, + 0xe1, 0x68, 0x67, 0xa6, 0x29, 0x53, 0x84, 0xf8, 0x04, 0xee, 0x78, 0x2c, 0x97, 0x2c, 0x5d, 0x1a, + 0x78, 0x11, 0xd3, 0xa1, 0x10, 0xdd, 0x9a, 0x74, 0xf9, 0x7d, 0xe7, 0x4c, 0x7e, 0xdf, 0x4c, 0xe6, + 0x83, 0x33, 0xc9, 0x05, 0x86, 0x11, 0x4e, 0x3d, 0x4e, 0x92, 0x27, 0xa6, 0xe2, 0x88, 0x04, 0xcc, + 0x9b, 0x34, 0x7d, 0xa6, 0x48, 0xd3, 0x63, 0x13, 0x26, 0xd4, 0xd8, 0x8d, 0x13, 0xa9, 0xa4, 0x79, + 0x74, 0xcb, 0x05, 0x76, 0x23, 0x9c, 0xba, 0x5f, 0x56, 0xdd, 0x7c, 0xd5, 0x09, 0xe1, 0x5f, 0x27, + 0xdb, 0xbe, 0xc2, 0xb1, 0xba, 0xe9, 0xde, 0x9b, 0x0d, 0x28, 0x23, 0xb5, 0x8c, 0x13, 0xe3, 0xb4, + 0x7e, 0x57, 0x46, 0x6a, 0xee, 0x41, 0x55, 0x84, 0x6a, 0x80, 0xd4, 0x2a, 0x6b, 0xaf, 0x22, 0x42, + 0xd5, 0xa3, 0xe6, 0x01, 0xd4, 0x28, 0x13, 0x92, 0x67, 0x83, 0x5f, 0x7a, 0xf0, 0x47, 0xeb, 0x1e, + 0x35, 0x77, 0xa1, 0x22, 0x9f, 0x05, 0x4b, 0xac, 0xdf, 0xeb, 0x03, 0x5a, 0x38, 0x8f, 0xb0, 0xa3, + 0x39, 0x1d, 0x8a, 0x9a, 0x85, 0x62, 0x58, 0x18, 0x6b, 0x04, 0x0d, 0xcd, 0xba, 0x64, 0x45, 0xdf, + 0xea, 0x05, 0xfe, 0x6a, 0x52, 0x3b, 0x9d, 0x15, 0x88, 0xc9, 0x5c, 0x3f, 0x9d, 0xb1, 0xc4, 0xaa, + 0xac, 0x5d, 0x2d, 0x9c, 0x57, 0x03, 0x4c, 0x4d, 0xbf, 0x48, 0x18, 0x51, 0xec, 0x3c, 0x0d, 0x14, + 0x4a, 0x51, 0x58, 0x88, 0x43, 0xa8, 0x73, 0x14, 0x83, 0x38, 0xc1, 0x80, 0xe5, 0x41, 0x6a, 0x1c, + 0x45, 0x3f, 0xd3, 0x4e, 0xb4, 0x89, 0x42, 0x44, 0xc0, 0xa2, 0x82, 0xa3, 0x38, 0x73, 0x03, 0xfe, + 0x6b, 0x5c, 0x3f, 0xfb, 0xcb, 0x6d, 0xa4, 0xe6, 0x31, 0x00, 0x59, 0x43, 0x07, 0x5b, 0x62, 0x3d, + 0x77, 0x7a, 0x3f, 0x01, 0xef, 0x43, 0xd5, 0x47, 0x4a, 0xb7, 0xe4, 0x5c, 0x65, 0x3e, 0xe1, 0x32, + 0x15, 0x2a, 0x7f, 0x82, 0x5c, 0xb5, 0xaf, 0xdf, 0x96, 0xb6, 0xb1, 0x58, 0xda, 0xc6, 0xc7, 0xd2, + 0x36, 0xe6, 0x2b, 0xbb, 0xb4, 0x58, 0xd9, 0xa5, 0xf7, 0x95, 0x5d, 0x7a, 0x68, 0x0d, 0x51, 0x8d, + 0x52, 0xdf, 0x0d, 0x24, 0xf7, 0x36, 0x55, 0xf4, 0x36, 0xf5, 0x1d, 0xa5, 0xbe, 0xf7, 0xbd, 0xc3, + 0x6a, 0x16, 0xb3, 0xb1, 0x5f, 0xd5, 0xdd, 0x6d, 0x7d, 0x06, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x3b, + 0xfa, 0xf0, 0xe8, 0x03, 0x00, 0x00, +} + +func (m *EventListNFT) 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 *EventListNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventListNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventEditListing) 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 *EventEditListing) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventEditListing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventDeListNFT) 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 *EventDeListNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventDeListNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBuyNFT) 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 *EventBuyNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBuyNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Buyer) > 0 { + i -= len(m.Buyer) + copy(dAtA[i:], m.Buyer) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Buyer))) + i-- + dAtA[i] = 0x2a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventCreateAuction) 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 *EventCreateAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MinPrice) > 0 { + i -= len(m.MinPrice) + copy(dAtA[i:], m.MinPrice) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MinPrice))) + i-- + dAtA[i] = 0x2a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventCancelAuction) 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 *EventCancelAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCancelAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventPlaceBid) 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 *EventPlaceBid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x2a + } + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0x22 + } + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.AuctionId) > 0 { + i -= len(m.AuctionId) + copy(dAtA[i:], m.AuctionId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.AuctionId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventListNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventEditListing) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventDeListNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBuyNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Buyer) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventCreateAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.MinPrice) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventCancelAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventPlaceBid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AuctionId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventListNFT) 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 ErrIntOverflowEvents + } + 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: EventListNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventListNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventEditListing) 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 ErrIntOverflowEvents + } + 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: EventEditListing: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventEditListing: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventDeListNFT) 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 ErrIntOverflowEvents + } + 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: EventDeListNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventDeListNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBuyNFT) 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 ErrIntOverflowEvents + } + 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: EventBuyNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBuyNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Buyer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Buyer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventCreateAuction) 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 ErrIntOverflowEvents + } + 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: EventCreateAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MinPrice = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventCancelAuction) 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 ErrIntOverflowEvents + } + 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: EventCancelAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCancelAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPlaceBid) 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 ErrIntOverflowEvents + } + 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: EventPlaceBid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventPlaceBid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuctionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/marketplace/types/expected_keepers.go b/x/marketplace/types/expected_keepers.go new file mode 100644 index 00000000..7e5ca8cc --- /dev/null +++ b/x/marketplace/types/expected_keepers.go @@ -0,0 +1,36 @@ +package types + +import ( + nft "github.com/OmniFlix/onft/exported" + nftypes "github.com/OmniFlix/onft/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +type AccountKeeper interface { + // Methods imported from account should be defined here + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI + GetModuleAddress(module string) sdk.AccAddress +} + +type BankKeeper interface { + // Methods imported from bank should be defined here + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SendCoins(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amount sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, formModule string, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, formModule string, toModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, fromAddr sdk.AccAddress, toModule string, amt sdk.Coins) error +} + +type NftKeeper interface { + // methods imported from nft should be defined here + GetONFT(ctx sdk.Context, denomId, onftId string) (nft nft.ONFT, err error) + GetDenom(ctx sdk.Context, denomId string) (nftypes.Denom, error) + TransferOwnership(ctx sdk.Context, denomId, nftId string, srcOwner, dstOwner sdk.AccAddress) error +} + +// DistributionKeeper defines the expected distribution keeper +type DistributionKeeper interface { + FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error +} diff --git a/x/marketplace/types/genesis.go b/x/marketplace/types/genesis.go new file mode 100644 index 00000000..62eee785 --- /dev/null +++ b/x/marketplace/types/genesis.go @@ -0,0 +1,44 @@ +package types + +import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + +func NewGenesisState(listings []Listing, listingCount uint64, params Params, + auctions []AuctionListing, bids []Bid, nextAuctionNumber uint64, +) *GenesisState { + return &GenesisState{ + Listings: listings, + ListingCount: listingCount, + Params: params, + Auctions: auctions, + Bids: bids, + NextAuctionNumber: nextAuctionNumber, + } +} + +func (m *GenesisState) ValidateGenesis() error { + for _, l := range m.Listings { + if l.GetOwner().Empty() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing nft owner") + } + if err := ValidateListing(l); err != nil { + return err + } + } + if err := m.Params.ValidateBasic(); err != nil { + return err + } + for _, auction := range m.Auctions { + if err := ValidateAuctionListing(auction); err != nil { + return err + } + } + for _, bid := range m.Bids { + if err := ValidateBid(bid); err != nil { + return err + } + } + if m.NextAuctionNumber <= 0 { + return sdkerrors.Wrap(ErrNonPositiveNumber, "must be a number and greater than 0.") + } + return nil +} diff --git a/x/marketplace/types/genesis.pb.go b/x/marketplace/types/genesis.pb.go new file mode 100644 index 00000000..34771e13 --- /dev/null +++ b/x/marketplace/types/genesis.pb.go @@ -0,0 +1,588 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "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 { + // NFTs that are listed in marketplace + Listings []Listing `protobuf:"bytes,1,rep,name=listings,proto3" json:"listings"` + ListingCount uint64 `protobuf:"varint,2,opt,name=ListingCount,proto3" json:"ListingCount,omitempty"` + Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"` + Auctions []AuctionListing `protobuf:"bytes,4,rep,name=auctions,proto3" json:"auctions"` + Bids []Bid `protobuf:"bytes,5,rep,name=bids,proto3" json:"bids"` + NextAuctionNumber uint64 `protobuf:"varint,6,opt,name=next_auction_number,json=nextAuctionNumber,proto3" json:"next_auction_number,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_2158df64a6fb9282, []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) GetListings() []Listing { + if m != nil { + return m.Listings + } + return nil +} + +func (m *GenesisState) GetListingCount() uint64 { + if m != nil { + return m.ListingCount + } + return 0 +} + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetAuctions() []AuctionListing { + if m != nil { + return m.Auctions + } + return nil +} + +func (m *GenesisState) GetBids() []Bid { + if m != nil { + return m.Bids + } + return nil +} + +func (m *GenesisState) GetNextAuctionNumber() uint64 { + if m != nil { + return m.NextAuctionNumber + } + return 0 +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "OmniFlix.marketplace.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/genesis.proto", fileDescriptor_2158df64a6fb9282) +} + +var fileDescriptor_2158df64a6fb9282 = []byte{ + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x4d, 0x4f, 0xc2, 0x30, + 0x18, 0xc7, 0x37, 0x98, 0x84, 0x14, 0x2e, 0x56, 0x0f, 0x0b, 0x31, 0x13, 0x89, 0x26, 0x68, 0x4c, + 0x1b, 0xe0, 0xe8, 0xc9, 0x99, 0xc8, 0x45, 0xd1, 0xe0, 0xcd, 0x0b, 0xe9, 0xa0, 0x8e, 0xc6, 0xad, + 0x5d, 0xd6, 0xce, 0xe0, 0xb7, 0xf0, 0x63, 0x71, 0xe4, 0xe8, 0xc9, 0x18, 0xf8, 0x1a, 0x1e, 0x0c, + 0x5d, 0x31, 0xe2, 0x61, 0xf1, 0xd6, 0xf4, 0xf9, 0x3d, 0xff, 0x97, 0x3c, 0xe0, 0x4c, 0xc4, 0x9c, + 0x3d, 0x45, 0x6c, 0x86, 0x63, 0x92, 0x3e, 0x53, 0x95, 0x44, 0x64, 0x4c, 0xf1, 0x4b, 0x27, 0xa0, + 0x8a, 0x74, 0x70, 0x48, 0x39, 0x95, 0x4c, 0xa2, 0x24, 0x15, 0x4a, 0xc0, 0x83, 0xbb, 0x98, 0xb3, + 0xeb, 0x88, 0xcd, 0xd0, 0x2f, 0x16, 0x19, 0xb6, 0xb1, 0x1f, 0x8a, 0x50, 0x68, 0x10, 0xaf, 0x5f, + 0xf9, 0x4e, 0xa3, 0x58, 0x3f, 0x62, 0x52, 0x31, 0x1e, 0xfe, 0x8b, 0x25, 0xd9, 0x58, 0x31, 0xc1, + 0x0d, 0x7b, 0x5a, 0xc8, 0x26, 0x24, 0x25, 0xb1, 0x89, 0xdd, 0xfa, 0x2a, 0x81, 0x7a, 0x3f, 0x2f, + 0xf2, 0xa0, 0x88, 0xa2, 0xb0, 0x0f, 0xaa, 0xc6, 0x58, 0xba, 0x76, 0xb3, 0xdc, 0xae, 0x75, 0x4f, + 0x50, 0x51, 0x35, 0x74, 0x93, 0xd3, 0xbe, 0x33, 0xff, 0x38, 0xb4, 0x86, 0x3f, 0xcb, 0xb0, 0x05, + 0xea, 0x66, 0x74, 0x25, 0x32, 0xae, 0xdc, 0x52, 0xd3, 0x6e, 0x3b, 0xc3, 0xad, 0x3f, 0xe8, 0x83, + 0x4a, 0x9e, 0xc6, 0x2d, 0x37, 0xed, 0x76, 0xad, 0x7b, 0x5c, 0x6c, 0x75, 0xaf, 0x59, 0xe3, 0x64, + 0x36, 0xe1, 0x00, 0x54, 0x4d, 0x7b, 0xe9, 0x3a, 0x3a, 0xf0, 0x79, 0xb1, 0xca, 0x65, 0x4e, 0xff, + 0xc9, 0xbd, 0xd1, 0x80, 0x17, 0xc0, 0x09, 0xd8, 0x44, 0xba, 0x3b, 0x5a, 0xeb, 0xa8, 0x58, 0xcb, + 0x67, 0x13, 0x23, 0xa0, 0x97, 0x20, 0x02, 0x7b, 0x9c, 0xce, 0xd4, 0xc8, 0xa8, 0x8d, 0x78, 0x16, + 0x07, 0x34, 0x75, 0x2b, 0xba, 0xfb, 0xee, 0x7a, 0x64, 0xdc, 0x07, 0x7a, 0xe0, 0xdf, 0xce, 0x97, + 0x9e, 0xbd, 0x58, 0x7a, 0xf6, 0xe7, 0xd2, 0xb3, 0xdf, 0x56, 0x9e, 0xb5, 0x58, 0x79, 0xd6, 0xfb, + 0xca, 0xb3, 0x1e, 0x7b, 0x21, 0x53, 0xd3, 0x2c, 0x40, 0x63, 0x11, 0xe3, 0x4d, 0x04, 0xbc, 0xb9, + 0xeb, 0x34, 0x0b, 0xf0, 0xf6, 0x71, 0xd5, 0x6b, 0x42, 0x65, 0x50, 0xd1, 0x47, 0xed, 0x7d, 0x07, + 0x00, 0x00, 0xff, 0xff, 0xe7, 0x61, 0xce, 0x68, 0xb9, 0x02, 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.NextAuctionNumber != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextAuctionNumber)) + i-- + dAtA[i] = 0x30 + } + 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] = 0x2a + } + } + 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] = 0x22 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.ListingCount != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ListingCount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Listings) > 0 { + for iNdEx := len(m.Listings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Listings[iNdEx].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 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 + if len(m.Listings) > 0 { + for _, e := range m.Listings { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.ListingCount != 0 { + n += 1 + sovGenesis(uint64(m.ListingCount)) + } + 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 m.NextAuctionNumber != 0 { + n += 1 + sovGenesis(uint64(m.NextAuctionNumber)) + } + 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 Listings", 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.Listings = append(m.Listings, Listing{}) + if err := m.Listings[len(m.Listings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ListingCount", wireType) + } + m.ListingCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ListingCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + 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 4: + 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, AuctionListing{}) + if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + 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 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextAuctionNumber", wireType) + } + m.NextAuctionNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextAuctionNumber |= 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/marketplace/types/keys.go b/x/marketplace/types/keys.go new file mode 100644 index 00000000..9bb499bd --- /dev/null +++ b/x/marketplace/types/keys.go @@ -0,0 +1,74 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + ModuleName = "marketplace" + StoreKey string = ModuleName + QuerierRoute string = ModuleName + RouterKey string = ModuleName + DefaultParamspace = ModuleName +) + +var ( + PrefixListingId = []byte{0x01} + PrefixListingOwner = []byte{0x02} + PrefixListingsCount = []byte{0x03} + PrefixListingNFTID = []byte{0x04} + PrefixListingPriceDenom = []byte{0x05} + PrefixAuctionId = []byte{0x06} + PrefixAuctionOwner = []byte{0x07} + PrefixAuctionNFTID = []byte{0x08} + PrefixAuctionPriceDenom = []byte{0x09} + PrefixNextAuctionNumber = []byte{0x10} + PrefixBidByAuctionId = []byte{0x11} + PrefixBidByBidder = []byte{0x12} + PrefixInactiveAuction = []byte{0x13} + PrefixActiveAuction = []byte{0x14} +) + +func KeyListingIdPrefix(id string) []byte { + return append(PrefixListingId, []byte(id)...) +} + +func KeyListingOwnerPrefix(owner sdk.AccAddress, id string) []byte { + return append(append(PrefixListingOwner, owner.Bytes()...), []byte(id)...) +} + +func KeyListingNFTIDPrefix(nftId string) []byte { + return append(PrefixListingNFTID, []byte(nftId)...) +} + +func KeyListingPriceDenomPrefix(priceDenom, id string) []byte { + return append(append(PrefixListingPriceDenom, []byte(priceDenom)...), []byte(id)...) +} + +func KeyAuctionIdPrefix(id uint64) []byte { + return append(PrefixAuctionId, sdk.Uint64ToBigEndian(id)...) +} + +func KeyAuctionOwnerPrefix(owner sdk.AccAddress, id uint64) []byte { + return append(append(PrefixAuctionOwner, owner.Bytes()...), sdk.Uint64ToBigEndian(id)...) +} + +func KeyAuctionNFTIDPrefix(nftId string) []byte { + return append(PrefixAuctionNFTID, []byte(nftId)...) +} + +func KeyAuctionPriceDenomPrefix(priceDenom string, id uint64) []byte { + return append(append(PrefixAuctionPriceDenom, []byte(priceDenom)...), sdk.Uint64ToBigEndian(id)...) +} + +func KeyBidPrefix(id uint64) []byte { + return append(PrefixBidByAuctionId, sdk.Uint64ToBigEndian(id)...) +} + +func KeyInActiveAuctionPrefix(id uint64) []byte { + return append(PrefixInactiveAuction, sdk.Uint64ToBigEndian(id)...) +} + +func KeyActiveAuctionPrefix(id uint64) []byte { + return append(PrefixActiveAuction, sdk.Uint64ToBigEndian(id)...) +} diff --git a/x/marketplace/types/listing.go b/x/marketplace/types/listing.go new file mode 100644 index 00000000..1fbe1aae --- /dev/null +++ b/x/marketplace/types/listing.go @@ -0,0 +1,48 @@ +package types + +import ( + "github.com/OmniFlix/omniflixhub/x/marketplace/exported" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" +) + +var ( + _ proto.Message = &Listing{} + _ exported.ListingI = &Listing{} +) + +func NewListing(id, nftId, denomId string, price sdk.Coin, owner sdk.AccAddress, splitShares []WeightedAddress) Listing { + return Listing{ + Id: id, + NftId: nftId, + DenomId: denomId, + Price: price, + Owner: owner.String(), + SplitShares: splitShares, + } +} + +func (l Listing) GetId() string { + return l.Id +} + +func (l Listing) GetDenomId() string { + return l.DenomId +} + +func (l Listing) GetNftId() string { + return l.NftId +} + +func (l Listing) GetPrice() sdk.Coin { + return l.Price +} + +func (l Listing) GetOwner() sdk.AccAddress { + owner, _ := sdk.AccAddressFromBech32(l.Owner) + return owner +} + +func (l Listing) GetSplitShares() interface{} { + return l.SplitShares +} diff --git a/x/marketplace/types/listing.pb.go b/x/marketplace/types/listing.pb.go new file mode 100644 index 00000000..e584e5b8 --- /dev/null +++ b/x/marketplace/types/listing.pb.go @@ -0,0 +1,802 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/listing.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" + 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 Listing struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty" yaml:"nft_id"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty" yaml:"denom_id"` + Price types.Coin `protobuf:"bytes,4,opt,name=price,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"price"` + Owner string `protobuf:"bytes,5,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` + SplitShares []WeightedAddress `protobuf:"bytes,6,rep,name=split_shares,json=splitShares,proto3" json:"split_shares" yaml:"split_shares"` +} + +func (m *Listing) Reset() { *m = Listing{} } +func (m *Listing) String() string { return proto.CompactTextString(m) } +func (*Listing) ProtoMessage() {} +func (*Listing) Descriptor() ([]byte, []int) { + return fileDescriptor_a9dd475f3f5b4525, []int{0} +} +func (m *Listing) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Listing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Listing.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 *Listing) XXX_Merge(src proto.Message) { + xxx_messageInfo_Listing.Merge(m, src) +} +func (m *Listing) XXX_Size() int { + return m.Size() +} +func (m *Listing) XXX_DiscardUnknown() { + xxx_messageInfo_Listing.DiscardUnknown(m) +} + +var xxx_messageInfo_Listing proto.InternalMessageInfo + +type WeightedAddress struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Weight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight" yaml:"weight"` +} + +func (m *WeightedAddress) Reset() { *m = WeightedAddress{} } +func (m *WeightedAddress) String() string { return proto.CompactTextString(m) } +func (*WeightedAddress) ProtoMessage() {} +func (*WeightedAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_a9dd475f3f5b4525, []int{1} +} +func (m *WeightedAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WeightedAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WeightedAddress.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 *WeightedAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_WeightedAddress.Merge(m, src) +} +func (m *WeightedAddress) XXX_Size() int { + return m.Size() +} +func (m *WeightedAddress) XXX_DiscardUnknown() { + xxx_messageInfo_WeightedAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_WeightedAddress proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Listing)(nil), "OmniFlix.marketplace.v1beta1.Listing") + proto.RegisterType((*WeightedAddress)(nil), "OmniFlix.marketplace.v1beta1.WeightedAddress") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/listing.proto", fileDescriptor_a9dd475f3f5b4525) +} + +var fileDescriptor_a9dd475f3f5b4525 = []byte{ + // 477 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x31, 0x6f, 0xd4, 0x30, + 0x14, 0x4e, 0xae, 0xbd, 0x2b, 0xf8, 0x4a, 0x0b, 0x2e, 0x43, 0x28, 0x28, 0x39, 0x65, 0x28, 0x27, + 0x44, 0x6d, 0xb5, 0xdd, 0xba, 0x20, 0x02, 0x42, 0xaa, 0x84, 0x84, 0x08, 0x43, 0x25, 0x96, 0x92, + 0xc4, 0xbe, 0x9c, 0xd5, 0xc4, 0x8e, 0x62, 0x97, 0xb6, 0xff, 0x82, 0x5f, 0x80, 0x98, 0xf9, 0x25, + 0x37, 0x76, 0x44, 0x0c, 0x01, 0xee, 0x16, 0x06, 0xa6, 0xfc, 0x02, 0x14, 0x3b, 0x51, 0x0f, 0x06, + 0xc4, 0xe4, 0xe7, 0xf7, 0xbe, 0xf7, 0x7d, 0x9f, 0x9f, 0x1f, 0x78, 0x24, 0x72, 0xce, 0x26, 0x19, + 0xbb, 0xc0, 0x79, 0x54, 0x9e, 0x52, 0x55, 0x64, 0x51, 0x42, 0xf1, 0xfb, 0xbd, 0x98, 0xaa, 0x68, + 0x0f, 0x67, 0x4c, 0x2a, 0xc6, 0x53, 0x54, 0x94, 0x42, 0x09, 0xf8, 0xe0, 0x55, 0xce, 0xd9, 0x8b, + 0x8c, 0x5d, 0xa0, 0x25, 0x2c, 0x6a, 0xb1, 0xdb, 0x6e, 0x22, 0x64, 0x2e, 0x24, 0x8e, 0x23, 0x79, + 0x4d, 0x90, 0x08, 0xc6, 0x4d, 0xf7, 0xf6, 0xdd, 0x54, 0xa4, 0x42, 0x87, 0xb8, 0x89, 0x4c, 0xd6, + 0xff, 0xd5, 0x03, 0x6b, 0x2f, 0x8d, 0x0a, 0xdc, 0x00, 0x3d, 0x46, 0x1c, 0x7b, 0x64, 0x8f, 0x6f, + 0x86, 0x3d, 0x46, 0xe0, 0x18, 0x0c, 0xf8, 0x44, 0x9d, 0x30, 0xe2, 0xf4, 0x9a, 0x5c, 0x70, 0xa7, + 0xae, 0xbc, 0x5b, 0x97, 0x51, 0x9e, 0x1d, 0xfa, 0x26, 0xef, 0x87, 0x7d, 0x3e, 0x51, 0x47, 0x04, + 0x22, 0x70, 0x83, 0x50, 0x2e, 0xf2, 0x06, 0xbb, 0xa2, 0xb1, 0x5b, 0x75, 0xe5, 0x6d, 0x1a, 0x6c, + 0x57, 0xf1, 0xc3, 0x35, 0x1d, 0x1e, 0x11, 0xf8, 0x0e, 0xf4, 0x8b, 0x92, 0x25, 0xd4, 0x59, 0x1d, + 0xd9, 0xe3, 0xe1, 0xfe, 0x3d, 0x64, 0xbc, 0xa3, 0xc6, 0x7b, 0xf7, 0x20, 0xf4, 0x4c, 0x30, 0x1e, + 0xe0, 0x59, 0xe5, 0x59, 0x9f, 0xbf, 0x79, 0x0f, 0x53, 0xa6, 0xa6, 0x67, 0x31, 0x4a, 0x44, 0x8e, + 0xdb, 0x87, 0x9a, 0x63, 0x57, 0x92, 0x53, 0xac, 0x2e, 0x0b, 0x2a, 0x75, 0x43, 0x68, 0x88, 0xe1, + 0x0e, 0xe8, 0x8b, 0x73, 0x4e, 0x4b, 0xa7, 0xaf, 0xed, 0xdc, 0xae, 0x2b, 0x6f, 0xdd, 0xd8, 0xd1, + 0x69, 0x3f, 0x34, 0x65, 0x98, 0x83, 0x75, 0x59, 0x64, 0x4c, 0x9d, 0xc8, 0x69, 0x54, 0x52, 0xe9, + 0x0c, 0x46, 0x2b, 0xe3, 0xe1, 0xfe, 0x2e, 0xfa, 0xd7, 0xa8, 0xd1, 0x31, 0x65, 0xe9, 0x54, 0x51, + 0xf2, 0x94, 0x90, 0x92, 0x4a, 0x19, 0xdc, 0x6f, 0x4c, 0xd6, 0x95, 0xb7, 0x65, 0x14, 0x96, 0x09, + 0xfd, 0x70, 0xa8, 0xaf, 0x6f, 0xcc, 0xed, 0xa3, 0x0d, 0x36, 0xff, 0xea, 0x86, 0x8f, 0xc1, 0x5a, + 0x64, 0x42, 0x33, 0xfb, 0x00, 0xd6, 0x95, 0xb7, 0x61, 0xa8, 0xda, 0x82, 0x1f, 0x76, 0x10, 0x78, + 0x0c, 0x06, 0xe7, 0x9a, 0xa0, 0xfd, 0x94, 0x27, 0x8d, 0xf6, 0xd7, 0xca, 0xdb, 0xf9, 0x8f, 0x01, + 0x3d, 0xa7, 0xc9, 0xf5, 0x17, 0x1a, 0x16, 0x3f, 0x6c, 0xe9, 0x0e, 0x57, 0x7f, 0x7e, 0xf2, 0xec, + 0xe0, 0xf5, 0xec, 0x87, 0x6b, 0xcd, 0xe6, 0xae, 0x7d, 0x35, 0x77, 0xed, 0xef, 0x73, 0xd7, 0xfe, + 0xb0, 0x70, 0xad, 0xab, 0x85, 0x6b, 0x7d, 0x59, 0xb8, 0xd6, 0xdb, 0x83, 0x25, 0x91, 0x6e, 0x42, + 0xb8, 0xdb, 0xe0, 0xe9, 0x59, 0x8c, 0xff, 0x5c, 0x63, 0xad, 0x1a, 0x0f, 0xf4, 0xa6, 0x1d, 0xfc, + 0x0e, 0x00, 0x00, 0xff, 0xff, 0x20, 0x4a, 0x49, 0x47, 0xeb, 0x02, 0x00, 0x00, +} + +func (this *WeightedAddress) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*WeightedAddress) + if !ok { + that2, ok := that.(WeightedAddress) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if !this.Weight.Equal(that1.Weight) { + return false + } + return true +} +func (m *Listing) 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 *Listing) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Listing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SplitShares) > 0 { + for iNdEx := len(m.SplitShares) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SplitShares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintListing(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintListing(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.Price.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintListing(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintListing(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintListing(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintListing(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *WeightedAddress) 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 *WeightedAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WeightedAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Weight.Size() + i -= size + if _, err := m.Weight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintListing(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintListing(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintListing(dAtA []byte, offset int, v uint64) int { + offset -= sovListing(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Listing) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovListing(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovListing(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovListing(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovListing(uint64(l)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovListing(uint64(l)) + } + if len(m.SplitShares) > 0 { + for _, e := range m.SplitShares { + l = e.Size() + n += 1 + l + sovListing(uint64(l)) + } + } + return n +} + +func (m *WeightedAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovListing(uint64(l)) + } + l = m.Weight.Size() + n += 1 + l + sovListing(uint64(l)) + return n +} + +func sovListing(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozListing(x uint64) (n int) { + return sovListing(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Listing) 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 ErrIntOverflowListing + } + 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: Listing: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Listing: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + 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 ErrInvalidLengthListing + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + 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 ErrInvalidLengthListing + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + 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 ErrInvalidLengthListing + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthListing + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + 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 ErrInvalidLengthListing + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SplitShares", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthListing + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SplitShares = append(m.SplitShares, WeightedAddress{}) + if err := m.SplitShares[len(m.SplitShares)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipListing(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthListing + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *WeightedAddress) 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 ErrIntOverflowListing + } + 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: WeightedAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WeightedAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + 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 ErrInvalidLengthListing + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowListing + } + 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 ErrInvalidLengthListing + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthListing + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Weight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipListing(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthListing + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipListing(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, ErrIntOverflowListing + } + 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, ErrIntOverflowListing + } + 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, ErrIntOverflowListing + } + 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, ErrInvalidLengthListing + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupListing + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthListing + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthListing = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowListing = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupListing = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/marketplace/types/msgs.go b/x/marketplace/types/msgs.go new file mode 100644 index 00000000..9457e47e --- /dev/null +++ b/x/marketplace/types/msgs.go @@ -0,0 +1,354 @@ +package types + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + MsgRoute = "marketplace" + + TypeMsgListNFT = "list_nft" + TypeMsgEditListing = "edit_listing" + TypeMsgDeListNFT = "de_list_nft" + TypeMsgBuyNFT = "buy_nft" + TypeMsgCreateAuction = "create_auction" + TypeMsgCancelAuction = "cancel_auction" + TypeMsgPlaceBid = "place_bid" + + // DoNotModify used to indicate that some field should not be updated + DoNotModify = "[do-not-modify]" + IdPrefix = "list" +) + +var ( + _ sdk.Msg = &MsgListNFT{} + _ sdk.Msg = &MsgEditListing{} + _ sdk.Msg = &MsgDeListNFT{} + _ sdk.Msg = &MsgBuyNFT{} + _ sdk.Msg = &MsgCreateAuction{} + _ sdk.Msg = &MsgCancelAuction{} + _ sdk.Msg = &MsgPlaceBid{} +) + +func NewMsgListNFT(denomId, nftId string, price sdk.Coin, owner sdk.AccAddress, splitShares []WeightedAddress) *MsgListNFT { + return &MsgListNFT{ + Id: GenUniqueID(IdPrefix), + NftId: nftId, + DenomId: denomId, + Price: price, + Owner: owner.String(), + SplitShares: splitShares, + } +} + +func (msg MsgListNFT) Route() string { return MsgRoute } + +func (msg MsgListNFT) Type() string { return TypeMsgListNFT } + +func (msg MsgListNFT) ValidateBasic() error { + return ValidateListing( + NewListing( + msg.Id, + msg.NftId, + msg.DenomId, + msg.Price, + sdk.AccAddress(msg.Owner), + msg.SplitShares, + ), + ) +} + +// GetSignBytes Implements Msg. +func (msg MsgListNFT) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgListNFT) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +func NewMsgEditListing(id string, price sdk.Coin, owner sdk.AccAddress) *MsgEditListing { + return &MsgEditListing{ + Id: id, + Price: price, + Owner: owner.String(), + } +} + +func (msg MsgEditListing) Route() string { return MsgRoute } + +func (msg MsgEditListing) Type() string { return TypeMsgEditListing } + +func (msg MsgEditListing) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + return ValidatePrice(msg.Price) +} + +// GetSignBytes Implements Msg. +func (msg MsgEditListing) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgEditListing) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +// NewMsgDeListNFT +func NewMsgDeListNFT(id string, owner sdk.AccAddress) *MsgDeListNFT { + return &MsgDeListNFT{ + Id: id, + Owner: owner.String(), + } +} + +// Route Implements Msg. +func (msg MsgDeListNFT) Route() string { return MsgRoute } + +// Type Implements Msg. +func (msg MsgDeListNFT) Type() string { return TypeMsgDeListNFT } + +// ValidateBasic Implements Msg. +func (msg MsgDeListNFT) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgDeListNFT) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgDeListNFT) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +// NewMsgBuyNFT +func NewMsgBuyNFT(id string, price sdk.Coin, buyer sdk.AccAddress) *MsgBuyNFT { + return &MsgBuyNFT{ + Id: id, + Price: price, + Buyer: buyer.String(), + } +} + +// Route Implements Msg. +func (msg MsgBuyNFT) Route() string { return MsgRoute } + +// Type Implements Msg. +func (msg MsgBuyNFT) Type() string { return TypeMsgBuyNFT } + +// ValidateBasic Implements Msg. +func (msg MsgBuyNFT) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Buyer) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return ValidatePrice(msg.Price) +} + +// GetSignBytes Implements Msg. +func (msg MsgBuyNFT) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgBuyNFT) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Buyer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +// Auction messages + +func NewMsgCreateAuction(denomId, nftId string, startTime time.Time, duration *time.Duration, startPrice sdk.Coin, owner sdk.AccAddress, + incrementPercentage sdk.Dec, whitelistAccounts []string, splitShares []WeightedAddress, +) *MsgCreateAuction { + return &MsgCreateAuction{ + NftId: nftId, + DenomId: denomId, + Duration: duration, + StartTime: startTime, + StartPrice: startPrice, + Owner: owner.String(), + IncrementPercentage: incrementPercentage, + WhitelistAccounts: whitelistAccounts, + SplitShares: splitShares, + } +} + +func (msg MsgCreateAuction) Route() string { return MsgRoute } + +func (msg MsgCreateAuction) Type() string { return TypeMsgCreateAuction } + +func (msg MsgCreateAuction) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + if err = ValidatePrice(msg.StartPrice); err != nil { + return err + } + if msg.Duration != nil { + if err = ValidateDuration(msg.Duration); err != nil { + return err + } + } + if !msg.IncrementPercentage.IsPositive() || !msg.IncrementPercentage.LTE(sdk.NewDec(1)) { + return sdkerrors.Wrapf(ErrInvalidPercentage, "invalid percentage value (%s)", msg.IncrementPercentage.String()) + } + if err = ValidateSplitShares(msg.SplitShares); err != nil { + return err + } + if err = ValidateWhiteListAccounts(msg.WhitelistAccounts); err != nil { + return err + } + return nil +} + +func (msg MsgCreateAuction) Validate(now time.Time) error { + if err := msg.ValidateBasic(); err != nil { + return err + } + if msg.StartTime.Before(now) { + return sdkerrors.Wrapf(ErrInvalidStartTime, "start time must be after current time %s", now.String()) + } + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgCreateAuction) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgCreateAuction) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +func NewMsgCancelAuction(auctionId uint64, owner sdk.AccAddress) *MsgCancelAuction { + return &MsgCancelAuction{ + AuctionId: auctionId, + Owner: owner.String(), + } +} + +func (msg MsgCancelAuction) Route() string { return MsgRoute } + +func (msg MsgCancelAuction) Type() string { return TypeMsgCancelAuction } + +func (msg MsgCancelAuction) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgCancelAuction) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgCancelAuction) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +func NewMsgPlaceBid(auctionId uint64, amount sdk.Coin, bidder sdk.AccAddress) *MsgPlaceBid { + return &MsgPlaceBid{ + AuctionId: auctionId, + Amount: amount, + Bidder: bidder.String(), + } +} + +func (msg MsgPlaceBid) Route() string { return MsgRoute } + +func (msg MsgPlaceBid) Type() string { return TypeMsgPlaceBid } + +func (msg MsgPlaceBid) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid bidder address (%s)", err) + } + if err := ValidatePrice(msg.Amount); err != nil { + return err + } + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgPlaceBid) GetSignBytes() []byte { + b, err := ModuleCdc.MarshalJSON(&msg) + if err != nil { + panic(err) + } + return sdk.MustSortJSON(b) +} + +// GetSigners Implements Msg. +func (msg MsgPlaceBid) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} diff --git a/x/marketplace/types/params.go b/x/marketplace/types/params.go new file mode 100644 index 00000000..22c6f7d6 --- /dev/null +++ b/x/marketplace/types/params.go @@ -0,0 +1,184 @@ +package types + +import ( + "fmt" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +const ( + // DefaultBidClosePeriod Default period for closing bids for an auction + DefaultBidClosePeriod time.Duration = time.Hour * 12 // 12 Hours + DefaultMaxAuctionDuration time.Duration = time.Hour * 24 * 90 // 90 Days +) + +// Parameter keys +var ( + ParamStoreKeySaleCommission = []byte("SaleCommission") + ParamStoreKeyDistribution = []byte("MarketplaceDistribution") + ParamStoreKeyBidCloseDuration = []byte("BidCloseDuration") + ParamStoreKeyMaxAuctionDuration = []byte("MaxAuctionDuration") +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable returns the parameter key table. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewMarketplaceParams( + saleCommission sdk.Dec, + distribution Distribution, + bidCloseDuration time.Duration, + maxAuctionDuration time.Duration, +) Params { + return Params{ + SaleCommission: saleCommission, + Distribution: distribution, + BidCloseDuration: bidCloseDuration, + MaxAuctionDuration: maxAuctionDuration, + } +} + +// DefaultParams returns default marketplace parameters +func DefaultParams() Params { + return NewMarketplaceParams( + sdk.NewDecWithPrec(1, 2), // 1% + Distribution{ + Staking: sdk.NewDecWithPrec(50, 2), // 50% + CommunityPool: sdk.NewDecWithPrec(50, 2), // 50% + }, + DefaultBidClosePeriod, + DefaultMaxAuctionDuration, + ) +} + +// ParamSetPairs returns the parameter set pairs. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(ParamStoreKeySaleCommission, &p.SaleCommission, validateSaleCommission), + paramtypes.NewParamSetPair(ParamStoreKeyDistribution, &p.Distribution, validateMarketplaceDistributionParams), + paramtypes.NewParamSetPair(ParamStoreKeyBidCloseDuration, &p.BidCloseDuration, validateBidCloseDuration), + paramtypes.NewParamSetPair(ParamStoreKeyMaxAuctionDuration, &p.MaxAuctionDuration, validateMaxAuctionDuration), + } +} + +// ValidateBasic performs basic validation on marketplace parameters. +func (p Params) ValidateBasic() error { + if err := validateSaleCommission(p.SaleCommission); err != nil { + return err + } + if err := validateMarketplaceDistributionParams(p.Distribution); err != nil { + return err + } + if err := validateBidCloseDuration(p.BidCloseDuration); err != nil { + return err + } + if err := validateMaxAuctionDuration(p.MaxAuctionDuration); err != nil { + return err + } + return nil +} + +func validateSaleCommission(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("sale commission must be not nil") + } + if v.IsNegative() { + return fmt.Errorf("sale commission must be positive: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("sale commission too large: %s", v) + } + + return nil +} + +func validateStakingDistribution(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("staking distribution value must be not nil") + } + if v.IsNegative() { + return fmt.Errorf("staking distribution value must be positive: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("staking distribution value too large: %s", v) + } + + return nil +} + +func validateCommunityPoolDistribution(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("community pool distribution value must be not nil") + } + if v.IsNegative() { + return fmt.Errorf("community pool distribution value must be positive: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("community pool distribution value too large: %s", v) + } + + return nil +} + +func validateMarketplaceDistributionParams(i interface{}) error { + v, ok := i.(Distribution) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + err := validateStakingDistribution(v.Staking) + if err != nil { + return err + } + err = validateCommunityPoolDistribution(v.CommunityPool) + if err != nil { + return err + } + if !v.Staking.Add(v.CommunityPool).Equal(sdk.OneDec()) { + return fmt.Errorf("marketplace distribtution commission params sum must be equal to : %d", 1) + } + return nil +} + +func validateBidCloseDuration(i interface{}) error { + v, ok := i.(time.Duration) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.Seconds() <= 0 { + return fmt.Errorf("bid close duration must be positive: %f", v.Seconds()) + } + + return nil +} + +func validateMaxAuctionDuration(d interface{}) error { + v, ok := d.(time.Duration) + if !ok { + return fmt.Errorf("invalid parameter type: %T", d) + } + if v.Seconds() <= 0 { + return fmt.Errorf("max auction duration must be positive: %f", v.Seconds()) + } + return nil +} diff --git a/x/marketplace/types/params.pb.go b/x/marketplace/types/params.pb.go new file mode 100644 index 00000000..892b6b61 --- /dev/null +++ b/x/marketplace/types/params.pb.go @@ -0,0 +1,685 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/params.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" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/durationpb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 Params struct { + SaleCommission github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=sale_commission,json=saleCommission,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"sale_commission" yaml:"sale_commission"` + Distribution Distribution `protobuf:"bytes,2,opt,name=distribution,proto3" json:"distribution"` + BidCloseDuration time.Duration `protobuf:"bytes,3,opt,name=bid_close_duration,json=bidCloseDuration,proto3,stdduration" json:"bid_close_duration" yaml:"bid_close_duration"` + MaxAuctionDuration time.Duration `protobuf:"bytes,4,opt,name=max_auction_duration,json=maxAuctionDuration,proto3,stdduration" json:"max_auction_duration" yaml:"max_auction_duration"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_782e8767fdab5ddb, []int{0} +} +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 + +type Distribution struct { + Staking github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=staking,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"staking" yaml:"staking"` + CommunityPool github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=community_pool,json=communityPool,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"community_pool" yaml:"community_pool"` +} + +func (m *Distribution) Reset() { *m = Distribution{} } +func (m *Distribution) String() string { return proto.CompactTextString(m) } +func (*Distribution) ProtoMessage() {} +func (*Distribution) Descriptor() ([]byte, []int) { + return fileDescriptor_782e8767fdab5ddb, []int{1} +} +func (m *Distribution) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Distribution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Distribution.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 *Distribution) XXX_Merge(src proto.Message) { + xxx_messageInfo_Distribution.Merge(m, src) +} +func (m *Distribution) XXX_Size() int { + return m.Size() +} +func (m *Distribution) XXX_DiscardUnknown() { + xxx_messageInfo_Distribution.DiscardUnknown(m) +} + +var xxx_messageInfo_Distribution proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "OmniFlix.marketplace.v1beta1.Params") + proto.RegisterType((*Distribution)(nil), "OmniFlix.marketplace.v1beta1.Distribution") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/params.proto", fileDescriptor_782e8767fdab5ddb) +} + +var fileDescriptor_782e8767fdab5ddb = []byte{ + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6e, 0xd4, 0x30, + 0x10, 0xc6, 0x13, 0x5a, 0x15, 0xd5, 0x94, 0x05, 0x59, 0x05, 0x6d, 0x0b, 0x4a, 0xaa, 0x48, 0x40, + 0x41, 0xc2, 0x56, 0xe9, 0x8d, 0x13, 0xa4, 0x2b, 0xe0, 0x46, 0x89, 0x38, 0xf5, 0x12, 0x39, 0x7f, + 0x9a, 0x5a, 0x6b, 0x67, 0x42, 0xec, 0xa0, 0xdd, 0xb7, 0xe0, 0xc8, 0x9b, 0xf0, 0x0a, 0x7b, 0xec, + 0x11, 0xf5, 0xb0, 0xc0, 0xee, 0x1b, 0xf4, 0x09, 0x50, 0xe2, 0xa4, 0xec, 0x02, 0x02, 0xed, 0x29, + 0xf1, 0x78, 0xe6, 0xfb, 0x8d, 0xe7, 0xb3, 0xd1, 0x63, 0x90, 0x39, 0x3f, 0x15, 0x7c, 0x44, 0x25, + 0x2b, 0x87, 0xa9, 0x2e, 0x04, 0x8b, 0x53, 0xfa, 0xf1, 0x20, 0x4a, 0x35, 0x3b, 0xa0, 0x05, 0x2b, + 0x99, 0x54, 0xa4, 0x28, 0x41, 0x03, 0xbe, 0xff, 0x56, 0xe6, 0xfc, 0x95, 0xe0, 0x23, 0xb2, 0x90, + 0x4a, 0xda, 0xd4, 0xdd, 0xed, 0x0c, 0x32, 0x68, 0x12, 0x69, 0xfd, 0x67, 0x6a, 0x76, 0x9d, 0x0c, + 0x20, 0x13, 0x29, 0x6d, 0x56, 0x51, 0x75, 0x4a, 0x93, 0xaa, 0x64, 0x9a, 0x43, 0x6e, 0xf6, 0xbd, + 0x2f, 0x6b, 0x68, 0xe3, 0xb8, 0x81, 0xe0, 0x0f, 0xe8, 0x96, 0x62, 0x22, 0x0d, 0x63, 0x90, 0x92, + 0x2b, 0xc5, 0x21, 0xef, 0xdb, 0x7b, 0xf6, 0xfe, 0xa6, 0xff, 0x66, 0x32, 0x75, 0xad, 0x8b, 0xa9, + 0xfb, 0x30, 0xe3, 0xfa, 0xac, 0x8a, 0x48, 0x0c, 0x92, 0xc6, 0xa0, 0x24, 0xa8, 0xf6, 0xf3, 0x54, + 0x25, 0x43, 0xaa, 0xc7, 0x45, 0xaa, 0xc8, 0x20, 0x8d, 0x2f, 0xa7, 0xee, 0xdd, 0x31, 0x93, 0xe2, + 0xb9, 0xf7, 0x9b, 0x9c, 0x17, 0xf4, 0xea, 0xc8, 0xd1, 0x55, 0x00, 0xbf, 0x47, 0x5b, 0x09, 0x57, + 0xba, 0xe4, 0x51, 0x55, 0xf7, 0xd4, 0xbf, 0xb6, 0x67, 0xef, 0xdf, 0x78, 0xf6, 0x84, 0xfc, 0xeb, + 0xa0, 0x64, 0xb0, 0x50, 0xe1, 0xaf, 0xd7, 0xbd, 0x05, 0x4b, 0x2a, 0x38, 0x47, 0x38, 0xe2, 0x49, + 0x18, 0x0b, 0x50, 0x69, 0xd8, 0x9d, 0xb7, 0xbf, 0xd6, 0x68, 0xef, 0x10, 0x33, 0x10, 0xd2, 0x0d, + 0x84, 0x0c, 0xda, 0x04, 0xff, 0x41, 0x2d, 0x75, 0x39, 0x75, 0x77, 0x4c, 0xf3, 0x7f, 0x4a, 0x78, + 0x9f, 0xbf, 0xb9, 0x76, 0x70, 0x3b, 0xe2, 0xc9, 0x51, 0x1d, 0xef, 0x0a, 0xb1, 0x46, 0xdb, 0x92, + 0x8d, 0x42, 0x56, 0xc5, 0xf5, 0xf2, 0x17, 0x71, 0xfd, 0x7f, 0xc4, 0x47, 0x2d, 0xf1, 0x9e, 0x21, + 0xfe, 0x4d, 0xc4, 0x30, 0xb1, 0x64, 0xa3, 0x97, 0x66, 0xa7, 0x2b, 0xf6, 0x2e, 0x6c, 0xb4, 0xb5, + 0x38, 0x0a, 0x7c, 0x82, 0xae, 0x2b, 0xcd, 0x86, 0x3c, 0xcf, 0x5a, 0xdf, 0x5e, 0xac, 0xec, 0x5b, + 0xaf, 0xf5, 0xcd, 0xc8, 0x78, 0x41, 0x27, 0x88, 0x73, 0xd4, 0xab, 0x7d, 0xac, 0x72, 0xae, 0xc7, + 0x61, 0x01, 0x20, 0x1a, 0xab, 0x36, 0xfd, 0xd7, 0x2b, 0x23, 0xee, 0x18, 0xc4, 0xb2, 0x9a, 0x17, + 0xdc, 0xbc, 0x0a, 0x1c, 0x03, 0x08, 0xff, 0xdd, 0xe4, 0x87, 0x63, 0x4d, 0x66, 0x8e, 0x7d, 0x3e, + 0x73, 0xec, 0xef, 0x33, 0xc7, 0xfe, 0x34, 0x77, 0xac, 0xf3, 0xb9, 0x63, 0x7d, 0x9d, 0x3b, 0xd6, + 0xc9, 0xe1, 0x02, 0xad, 0xbb, 0x2a, 0xb4, 0x7b, 0x47, 0x67, 0x55, 0x44, 0x97, 0x1f, 0x53, 0x83, + 0x8f, 0x36, 0x9a, 0xf9, 0x1f, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x4c, 0x4c, 0xe3, 0x71, + 0x03, 0x00, 0x00, +} + +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 + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAuctionDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintParams(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x22 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.BidCloseDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidCloseDuration):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintParams(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x1a + { + size, err := m.Distribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.SaleCommission.Size() + i -= size + if _, err := m.SaleCommission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Distribution) 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 *Distribution) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Distribution) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.CommunityPool.Size() + i -= size + if _, err := m.CommunityPool.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Staking.Size() + i -= size + if _, err := m.Staking.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SaleCommission.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.Distribution.Size() + n += 1 + l + sovParams(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidCloseDuration) + n += 1 + l + sovParams(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration) + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *Distribution) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Staking.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.CommunityPool.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowParams + } + 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SaleCommission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SaleCommission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Distribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BidCloseDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.BidCloseDuration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAuctionDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAuctionDuration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Distribution) 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 ErrIntOverflowParams + } + 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: Distribution: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Distribution: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Staking", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Staking.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommunityPool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/marketplace/types/querier.go b/x/marketplace/types/querier.go new file mode 100644 index 00000000..b06b3908 --- /dev/null +++ b/x/marketplace/types/querier.go @@ -0,0 +1,99 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + QueryParams = "params" + QueryListing = "listing" + QueryAllListings = "listings" + QueryListingsByOwner = "listings-by-owner" + QueryAuction = "auction" + QueryAllAuctions = "auctions" + QueryBid = "bid" + QueryAllBids = "bids" + QueryAuctionsByOwner = "auctions-by-owner" +) + +// QueryListingParams is the query parameters for '/marketplace/listings/{id}' +type QueryListingParams struct { + Id string +} + +// NewQueryListingParams +func NewQueryListingParams(id string) QueryListingParams { + return QueryListingParams{ + Id: id, + } +} + +// QueryAllListingsParams is the query parameters for 'marketplace/listings' +type QueryAllListingsParams struct{} + +// NewQueryAllListingsParams +func NewQueryAllListingsParams() QueryAllListingsParams { + return QueryAllListingsParams{} +} + +// QueryListingsByOwnerParams is the query parameters for 'marketplace/listings/{owner}' +type QueryListingsByOwnerParams struct { + Owner sdk.AccAddress +} + +// NewQueryListingsByOwnerParams +func NewQueryListingsByOwnerParams(owner sdk.AccAddress) QueryListingsByOwnerParams { + return QueryListingsByOwnerParams{ + Owner: owner, + } +} + +// QueryAuctionParams is the query parameters for '/marketplace/auctions/{id}' +type QueryAuctionParams struct { + Id uint64 +} + +// NewQueryAuctionParams +func NewQueryAuctionParams(id uint64) QueryAuctionParams { + return QueryAuctionParams{ + Id: id, + } +} + +// QueryAllListingsParams is the query parameters for 'marketplace/auctions' +type QueryAllAuctionsParams struct{} + +// NewQueryAllListingsParams +func NewQueryAllAuctionsParams() QueryAllAuctionsParams { + return QueryAllAuctionsParams{} +} + +// QueryListingsByOwnerParams is the query parameters for 'marketplace/auctions/{owner}' +type QueryAuctionsByOwnerParams struct { + Owner sdk.AccAddress +} + +// NewQueryAuctionsByOwnerParams +func NewQueryAuctionsByOwnerParams(owner sdk.AccAddress) QueryAuctionsByOwnerParams { + return QueryAuctionsByOwnerParams{ + Owner: owner, + } +} + +// QueryBidParams is the query parameters for '/marketplace/bids/{id}' +type QueryBidParams struct { + Id uint64 +} + +// NewQueryAuctionParams +func NewQueryBidParams(id uint64) QueryBidParams { + return QueryBidParams{ + Id: id, + } +} + +// QueryAllBidsParams is the query parameters for 'marketplace/bids' +type QueryAllBidsParams struct{} + +// NewQueryAllListingsParams +func NewQueryAllBidsParams() QueryAllBidsParams { + return QueryAllBidsParams{} +} diff --git a/x/marketplace/types/query.pb.go b/x/marketplace/types/query.pb.go new file mode 100644 index 00000000..f578ed95 --- /dev/null +++ b/x/marketplace/types/query.pb.go @@ -0,0 +1,5333 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type QueryListingsRequest struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + PriceDenom string `protobuf:"bytes,2,opt,name=price_denom,json=priceDenom,proto3" json:"price_denom,omitempty" yaml:"price_denom"` + Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListingsRequest) Reset() { *m = QueryListingsRequest{} } +func (m *QueryListingsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListingsRequest) ProtoMessage() {} +func (*QueryListingsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{2} +} +func (m *QueryListingsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingsRequest.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 *QueryListingsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingsRequest.Merge(m, src) +} +func (m *QueryListingsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListingsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingsRequest proto.InternalMessageInfo + +func (m *QueryListingsRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryListingsRequest) GetPriceDenom() string { + if m != nil { + return m.PriceDenom + } + return "" +} + +func (m *QueryListingsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryListingsResponse struct { + Listings []Listing `protobuf:"bytes,1,rep,name=listings,proto3" json:"listings"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListingsResponse) Reset() { *m = QueryListingsResponse{} } +func (m *QueryListingsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListingsResponse) ProtoMessage() {} +func (*QueryListingsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{3} +} +func (m *QueryListingsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingsResponse.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 *QueryListingsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingsResponse.Merge(m, src) +} +func (m *QueryListingsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListingsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingsResponse proto.InternalMessageInfo + +func (m *QueryListingsResponse) GetListings() []Listing { + if m != nil { + return m.Listings + } + return nil +} + +func (m *QueryListingsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryListingRequest struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryListingRequest) Reset() { *m = QueryListingRequest{} } +func (m *QueryListingRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListingRequest) ProtoMessage() {} +func (*QueryListingRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{4} +} +func (m *QueryListingRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingRequest.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 *QueryListingRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingRequest.Merge(m, src) +} +func (m *QueryListingRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListingRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingRequest proto.InternalMessageInfo + +func (m *QueryListingRequest) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +type QueryListingResponse struct { + Listing *Listing `protobuf:"bytes,1,opt,name=listing,proto3" json:"listing,omitempty"` +} + +func (m *QueryListingResponse) Reset() { *m = QueryListingResponse{} } +func (m *QueryListingResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListingResponse) ProtoMessage() {} +func (*QueryListingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{5} +} +func (m *QueryListingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingResponse.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 *QueryListingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingResponse.Merge(m, src) +} +func (m *QueryListingResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingResponse proto.InternalMessageInfo + +func (m *QueryListingResponse) GetListing() *Listing { + if m != nil { + return m.Listing + } + return nil +} + +type QueryListingsByOwnerRequest struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListingsByOwnerRequest) Reset() { *m = QueryListingsByOwnerRequest{} } +func (m *QueryListingsByOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListingsByOwnerRequest) ProtoMessage() {} +func (*QueryListingsByOwnerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{6} +} +func (m *QueryListingsByOwnerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingsByOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingsByOwnerRequest.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 *QueryListingsByOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingsByOwnerRequest.Merge(m, src) +} +func (m *QueryListingsByOwnerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListingsByOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingsByOwnerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingsByOwnerRequest proto.InternalMessageInfo + +func (m *QueryListingsByOwnerRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryListingsByOwnerRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryListingsByOwnerResponse struct { + Listings []Listing `protobuf:"bytes,1,rep,name=listings,proto3" json:"listings"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListingsByOwnerResponse) Reset() { *m = QueryListingsByOwnerResponse{} } +func (m *QueryListingsByOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListingsByOwnerResponse) ProtoMessage() {} +func (*QueryListingsByOwnerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{7} +} +func (m *QueryListingsByOwnerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingsByOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingsByOwnerResponse.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 *QueryListingsByOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingsByOwnerResponse.Merge(m, src) +} +func (m *QueryListingsByOwnerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListingsByOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingsByOwnerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingsByOwnerResponse proto.InternalMessageInfo + +func (m *QueryListingsByOwnerResponse) GetListings() []Listing { + if m != nil { + return m.Listings + } + return nil +} + +func (m *QueryListingsByOwnerResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryListingByNFTIDRequest struct { + NftId string `protobuf:"bytes,1,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty" yaml:"nft_id"` +} + +func (m *QueryListingByNFTIDRequest) Reset() { *m = QueryListingByNFTIDRequest{} } +func (m *QueryListingByNFTIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListingByNFTIDRequest) ProtoMessage() {} +func (*QueryListingByNFTIDRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{8} +} +func (m *QueryListingByNFTIDRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingByNFTIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingByNFTIDRequest.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 *QueryListingByNFTIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingByNFTIDRequest.Merge(m, src) +} +func (m *QueryListingByNFTIDRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListingByNFTIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingByNFTIDRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingByNFTIDRequest proto.InternalMessageInfo + +func (m *QueryListingByNFTIDRequest) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +type QueryListingsByPriceDenomRequest struct { + PriceDenom string `protobuf:"bytes,1,opt,name=price_denom,json=priceDenom,proto3" json:"price_denom,omitempty" yaml:"price_denom"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListingsByPriceDenomRequest) Reset() { *m = QueryListingsByPriceDenomRequest{} } +func (m *QueryListingsByPriceDenomRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListingsByPriceDenomRequest) ProtoMessage() {} +func (*QueryListingsByPriceDenomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{9} +} +func (m *QueryListingsByPriceDenomRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingsByPriceDenomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingsByPriceDenomRequest.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 *QueryListingsByPriceDenomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingsByPriceDenomRequest.Merge(m, src) +} +func (m *QueryListingsByPriceDenomRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListingsByPriceDenomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingsByPriceDenomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingsByPriceDenomRequest proto.InternalMessageInfo + +func (m *QueryListingsByPriceDenomRequest) GetPriceDenom() string { + if m != nil { + return m.PriceDenom + } + return "" +} + +func (m *QueryListingsByPriceDenomRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryListingsByPriceDenomResponse struct { + Listings []Listing `protobuf:"bytes,1,rep,name=listings,proto3" json:"listings"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListingsByPriceDenomResponse) Reset() { *m = QueryListingsByPriceDenomResponse{} } +func (m *QueryListingsByPriceDenomResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListingsByPriceDenomResponse) ProtoMessage() {} +func (*QueryListingsByPriceDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{10} +} +func (m *QueryListingsByPriceDenomResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListingsByPriceDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListingsByPriceDenomResponse.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 *QueryListingsByPriceDenomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListingsByPriceDenomResponse.Merge(m, src) +} +func (m *QueryListingsByPriceDenomResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListingsByPriceDenomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListingsByPriceDenomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListingsByPriceDenomResponse proto.InternalMessageInfo + +func (m *QueryListingsByPriceDenomResponse) GetListings() []Listing { + if m != nil { + return m.Listings + } + return nil +} + +func (m *QueryListingsByPriceDenomResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAuctionsRequest struct { + Status AuctionStatus `protobuf:"varint,1,opt,name=status,proto3,enum=OmniFlix.marketplace.v1beta1.AuctionStatus" json:"status,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + PriceDenom string `protobuf:"bytes,3,opt,name=price_denom,json=priceDenom,proto3" json:"price_denom,omitempty" yaml:"price_denom"` + Pagination *query.PageRequest `protobuf:"bytes,4,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAuctionsRequest) Reset() { *m = QueryAuctionsRequest{} } +func (m *QueryAuctionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionsRequest) ProtoMessage() {} +func (*QueryAuctionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{11} +} +func (m *QueryAuctionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionsRequest.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 *QueryAuctionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionsRequest.Merge(m, src) +} +func (m *QueryAuctionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionsRequest proto.InternalMessageInfo + +func (m *QueryAuctionsRequest) GetStatus() AuctionStatus { + if m != nil { + return m.Status + } + return AUCTION_STATUS_UNSPECIFIED +} + +func (m *QueryAuctionsRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryAuctionsRequest) GetPriceDenom() string { + if m != nil { + return m.PriceDenom + } + return "" +} + +func (m *QueryAuctionsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAuctionsResponse struct { + Auctions []AuctionListing `protobuf:"bytes,1,rep,name=auctions,proto3" json:"auctions"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAuctionsResponse) Reset() { *m = QueryAuctionsResponse{} } +func (m *QueryAuctionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionsResponse) ProtoMessage() {} +func (*QueryAuctionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{12} +} +func (m *QueryAuctionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionsResponse.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 *QueryAuctionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionsResponse.Merge(m, src) +} +func (m *QueryAuctionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionsResponse proto.InternalMessageInfo + +func (m *QueryAuctionsResponse) GetAuctions() []AuctionListing { + if m != nil { + return m.Auctions + } + return nil +} + +func (m *QueryAuctionsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAuctionRequest struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryAuctionRequest) Reset() { *m = QueryAuctionRequest{} } +func (m *QueryAuctionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionRequest) ProtoMessage() {} +func (*QueryAuctionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{13} +} +func (m *QueryAuctionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionRequest.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 *QueryAuctionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionRequest.Merge(m, src) +} +func (m *QueryAuctionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionRequest proto.InternalMessageInfo + +func (m *QueryAuctionRequest) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type QueryAuctionResponse struct { + Auction *AuctionListing `protobuf:"bytes,1,opt,name=auction,proto3" json:"auction,omitempty"` +} + +func (m *QueryAuctionResponse) Reset() { *m = QueryAuctionResponse{} } +func (m *QueryAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionResponse) ProtoMessage() {} +func (*QueryAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{14} +} +func (m *QueryAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionResponse.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 *QueryAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionResponse.Merge(m, src) +} +func (m *QueryAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionResponse proto.InternalMessageInfo + +func (m *QueryAuctionResponse) GetAuction() *AuctionListing { + if m != nil { + return m.Auction + } + return nil +} + +type QueryAuctionsByOwnerRequest struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAuctionsByOwnerRequest) Reset() { *m = QueryAuctionsByOwnerRequest{} } +func (m *QueryAuctionsByOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionsByOwnerRequest) ProtoMessage() {} +func (*QueryAuctionsByOwnerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{15} +} +func (m *QueryAuctionsByOwnerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionsByOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionsByOwnerRequest.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 *QueryAuctionsByOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionsByOwnerRequest.Merge(m, src) +} +func (m *QueryAuctionsByOwnerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionsByOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionsByOwnerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionsByOwnerRequest proto.InternalMessageInfo + +func (m *QueryAuctionsByOwnerRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryAuctionsByOwnerRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAuctionByNFTIDRequest struct { + NftId string `protobuf:"bytes,1,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty" yaml:"nft_id"` +} + +func (m *QueryAuctionByNFTIDRequest) Reset() { *m = QueryAuctionByNFTIDRequest{} } +func (m *QueryAuctionByNFTIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionByNFTIDRequest) ProtoMessage() {} +func (*QueryAuctionByNFTIDRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{16} +} +func (m *QueryAuctionByNFTIDRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionByNFTIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionByNFTIDRequest.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 *QueryAuctionByNFTIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionByNFTIDRequest.Merge(m, src) +} +func (m *QueryAuctionByNFTIDRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionByNFTIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionByNFTIDRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionByNFTIDRequest proto.InternalMessageInfo + +func (m *QueryAuctionByNFTIDRequest) GetNftId() string { + if m != nil { + return m.NftId + } + return "" +} + +type QueryAuctionsByPriceDenomRequest struct { + PriceDenom string `protobuf:"bytes,1,opt,name=price_denom,json=priceDenom,proto3" json:"price_denom,omitempty" yaml:"price_denom"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAuctionsByPriceDenomRequest) Reset() { *m = QueryAuctionsByPriceDenomRequest{} } +func (m *QueryAuctionsByPriceDenomRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionsByPriceDenomRequest) ProtoMessage() {} +func (*QueryAuctionsByPriceDenomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{17} +} +func (m *QueryAuctionsByPriceDenomRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionsByPriceDenomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionsByPriceDenomRequest.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 *QueryAuctionsByPriceDenomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionsByPriceDenomRequest.Merge(m, src) +} +func (m *QueryAuctionsByPriceDenomRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionsByPriceDenomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionsByPriceDenomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionsByPriceDenomRequest proto.InternalMessageInfo + +func (m *QueryAuctionsByPriceDenomRequest) GetPriceDenom() string { + if m != nil { + return m.PriceDenom + } + return "" +} + +func (m *QueryAuctionsByPriceDenomRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryBidsRequest struct { + Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryBidsRequest) Reset() { *m = QueryBidsRequest{} } +func (m *QueryBidsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBidsRequest) ProtoMessage() {} +func (*QueryBidsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{18} +} +func (m *QueryBidsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBidsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBidsRequest.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 *QueryBidsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBidsRequest.Merge(m, src) +} +func (m *QueryBidsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBidsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBidsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBidsRequest proto.InternalMessageInfo + +func (m *QueryBidsRequest) GetBidder() string { + if m != nil { + return m.Bidder + } + return "" +} + +func (m *QueryBidsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryBidsResponse struct { + Bids []Bid `protobuf:"bytes,1,rep,name=bids,proto3" json:"bids"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryBidsResponse) Reset() { *m = QueryBidsResponse{} } +func (m *QueryBidsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBidsResponse) ProtoMessage() {} +func (*QueryBidsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{19} +} +func (m *QueryBidsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBidsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBidsResponse.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 *QueryBidsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBidsResponse.Merge(m, src) +} +func (m *QueryBidsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBidsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBidsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBidsResponse proto.InternalMessageInfo + +func (m *QueryBidsResponse) GetBids() []Bid { + if m != nil { + return m.Bids + } + return nil +} + +func (m *QueryBidsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryBidRequest struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryBidRequest) Reset() { *m = QueryBidRequest{} } +func (m *QueryBidRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBidRequest) ProtoMessage() {} +func (*QueryBidRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{20} +} +func (m *QueryBidRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBidRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBidRequest.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 *QueryBidRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBidRequest.Merge(m, src) +} +func (m *QueryBidRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBidRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBidRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBidRequest proto.InternalMessageInfo + +func (m *QueryBidRequest) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type QueryBidResponse struct { + Bid *Bid `protobuf:"bytes,1,opt,name=bid,proto3" json:"bid,omitempty"` +} + +func (m *QueryBidResponse) Reset() { *m = QueryBidResponse{} } +func (m *QueryBidResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBidResponse) ProtoMessage() {} +func (*QueryBidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1a332bb20b3f9d15, []int{21} +} +func (m *QueryBidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBidResponse.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 *QueryBidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBidResponse.Merge(m, src) +} +func (m *QueryBidResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBidResponse proto.InternalMessageInfo + +func (m *QueryBidResponse) GetBid() *Bid { + if m != nil { + return m.Bid + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryListingsRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryListingsRequest") + proto.RegisterType((*QueryListingsResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryListingsResponse") + proto.RegisterType((*QueryListingRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryListingRequest") + proto.RegisterType((*QueryListingResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryListingResponse") + proto.RegisterType((*QueryListingsByOwnerRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryListingsByOwnerRequest") + proto.RegisterType((*QueryListingsByOwnerResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryListingsByOwnerResponse") + proto.RegisterType((*QueryListingByNFTIDRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryListingByNFTIDRequest") + proto.RegisterType((*QueryListingsByPriceDenomRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryListingsByPriceDenomRequest") + proto.RegisterType((*QueryListingsByPriceDenomResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryListingsByPriceDenomResponse") + proto.RegisterType((*QueryAuctionsRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionsRequest") + proto.RegisterType((*QueryAuctionsResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionsResponse") + proto.RegisterType((*QueryAuctionRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionRequest") + proto.RegisterType((*QueryAuctionResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionResponse") + proto.RegisterType((*QueryAuctionsByOwnerRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionsByOwnerRequest") + proto.RegisterType((*QueryAuctionByNFTIDRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionByNFTIDRequest") + proto.RegisterType((*QueryAuctionsByPriceDenomRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryAuctionsByPriceDenomRequest") + proto.RegisterType((*QueryBidsRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryBidsRequest") + proto.RegisterType((*QueryBidsResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryBidsResponse") + proto.RegisterType((*QueryBidRequest)(nil), "OmniFlix.marketplace.v1beta1.QueryBidRequest") + proto.RegisterType((*QueryBidResponse)(nil), "OmniFlix.marketplace.v1beta1.QueryBidResponse") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/query.proto", fileDescriptor_1a332bb20b3f9d15) +} + +var fileDescriptor_1a332bb20b3f9d15 = []byte{ + // 1140 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x98, 0x51, 0x6f, 0xdb, 0x54, + 0x14, 0xc7, 0x7b, 0x93, 0x34, 0x2d, 0xa7, 0xa2, 0x65, 0x97, 0x6c, 0xaa, 0x42, 0x95, 0xae, 0x56, + 0xd7, 0x65, 0xdd, 0x62, 0xd3, 0x44, 0xa8, 0x6c, 0x08, 0x2a, 0xbc, 0x91, 0x6a, 0x02, 0xb6, 0x61, + 0x90, 0x10, 0x3c, 0x30, 0x39, 0xb1, 0x9b, 0x5d, 0x91, 0xd8, 0x59, 0xec, 0xc0, 0xa2, 0xa8, 0x2f, + 0x7c, 0x02, 0xa4, 0x89, 0x07, 0xc4, 0xe3, 0xc4, 0x03, 0x0f, 0x48, 0xbc, 0xf0, 0xc8, 0xcb, 0x9e, + 0xc6, 0xdb, 0x24, 0x5e, 0xf6, 0x54, 0xa1, 0x76, 0x9f, 0xa0, 0x9f, 0x00, 0xf9, 0xfa, 0x5e, 0xc7, + 0x76, 0x82, 0x77, 0xe3, 0x55, 0x53, 0x9f, 0x56, 0xc7, 0xf7, 0x9c, 0xf3, 0x3b, 0xe7, 0xdc, 0xff, + 0xf1, 0xd1, 0xa0, 0x6c, 0x77, 0x2c, 0xb2, 0xd7, 0x26, 0x0f, 0x94, 0x8e, 0xde, 0xfb, 0xd6, 0x74, + 0xbb, 0x6d, 0xbd, 0x69, 0x2a, 0xdf, 0x6d, 0x35, 0x4c, 0x57, 0xdf, 0x52, 0xee, 0xf7, 0xcd, 0xde, + 0x40, 0xee, 0xf6, 0x6c, 0xd7, 0xc6, 0x2b, 0xb7, 0x3b, 0x16, 0xa9, 0xb7, 0xc9, 0x03, 0x39, 0x74, + 0x52, 0x66, 0x27, 0x8b, 0x9b, 0x4d, 0xdb, 0xe9, 0xd8, 0x8e, 0xd2, 0xd0, 0x1d, 0xd3, 0x37, 0x0b, + 0x9c, 0x74, 0xf5, 0x16, 0xb1, 0x74, 0x97, 0xd8, 0x96, 0xef, 0xa9, 0xb8, 0xd2, 0xb2, 0xed, 0x56, + 0xdb, 0x54, 0xf4, 0x2e, 0x51, 0x74, 0xcb, 0xb2, 0x5d, 0xfa, 0xd2, 0x61, 0x6f, 0x37, 0x13, 0x89, + 0xda, 0xc4, 0x71, 0x89, 0xd5, 0x62, 0x67, 0x2f, 0x25, 0x9e, 0xed, 0xea, 0x3d, 0xbd, 0x23, 0xe6, + 0x56, 0xef, 0x37, 0x43, 0x80, 0x85, 0x96, 0xdd, 0xb2, 0xe9, 0x9f, 0x8a, 0xf7, 0x97, 0xff, 0xab, + 0x54, 0x00, 0xfc, 0x99, 0x97, 0xd8, 0x1d, 0xea, 0x56, 0x33, 0xef, 0xf7, 0x4d, 0xc7, 0x95, 0xbe, + 0x82, 0x37, 0x23, 0xbf, 0x3a, 0x5d, 0xdb, 0x72, 0x4c, 0xac, 0x42, 0xde, 0x0f, 0xbf, 0x8c, 0xce, + 0xa3, 0xf2, 0x42, 0x75, 0x5d, 0x4e, 0x2a, 0x9f, 0xec, 0x5b, 0xab, 0xb9, 0x27, 0x07, 0xab, 0x33, + 0x1a, 0xb3, 0x94, 0x7e, 0x47, 0x50, 0xa0, 0xbe, 0x3f, 0xf1, 0x93, 0xe6, 0x31, 0x71, 0x01, 0x66, + 0xed, 0xef, 0x2d, 0xb3, 0x47, 0x7d, 0xbf, 0xa6, 0xf9, 0x0f, 0x78, 0x1b, 0x16, 0xba, 0x3d, 0xd2, + 0x34, 0xef, 0x1a, 0xa6, 0x65, 0x77, 0x96, 0x33, 0xde, 0x3b, 0xf5, 0xdc, 0xf1, 0xc1, 0x2a, 0x1e, + 0xe8, 0x9d, 0xf6, 0x35, 0x29, 0xf4, 0x52, 0xd2, 0x80, 0x3e, 0xdd, 0xf0, 0x1e, 0x70, 0x1d, 0x60, + 0xd4, 0xa3, 0xe5, 0x2c, 0xe5, 0xdd, 0x90, 0xfd, 0x86, 0xca, 0x5e, 0x43, 0x65, 0xff, 0x1e, 0x8c, + 0x60, 0x5b, 0x26, 0x43, 0xd1, 0x42, 0x96, 0xd2, 0x6f, 0x08, 0xce, 0xc6, 0x78, 0x59, 0x35, 0x76, + 0x61, 0x9e, 0x35, 0xce, 0xab, 0x47, 0xb6, 0xbc, 0x50, 0xbd, 0x90, 0x5c, 0x0f, 0xe6, 0x81, 0x15, + 0x24, 0x30, 0xc6, 0xbb, 0x11, 0xd4, 0x0c, 0x45, 0xbd, 0xf8, 0x42, 0x54, 0x9f, 0x22, 0xc2, 0x7a, + 0x81, 0xb5, 0x8d, 0x05, 0xe2, 0x95, 0x5d, 0x84, 0x0c, 0x31, 0x58, 0x59, 0x33, 0xc4, 0x90, 0xbe, + 0x8c, 0x76, 0x20, 0x48, 0x68, 0x07, 0xe6, 0x18, 0x13, 0xeb, 0xaf, 0x58, 0x3e, 0x1a, 0xb7, 0x92, + 0x86, 0xf0, 0x56, 0xa4, 0x54, 0xea, 0xe0, 0xb6, 0xd7, 0xc4, 0xe4, 0x0e, 0xd7, 0x27, 0x64, 0x9f, + 0xa6, 0x51, 0x7f, 0x20, 0x58, 0x99, 0x1c, 0xfd, 0xd4, 0xf6, 0xab, 0x0e, 0xc5, 0x30, 0xb1, 0x3a, + 0xb8, 0x55, 0xff, 0xe2, 0xe6, 0x0d, 0x5e, 0xae, 0x32, 0xe4, 0xad, 0x3d, 0xf7, 0x2e, 0x6f, 0x9d, + 0x7a, 0xe6, 0xf8, 0x60, 0xf5, 0x75, 0xff, 0xd6, 0xfb, 0xbf, 0x4b, 0xda, 0xac, 0xb5, 0xe7, 0xde, + 0x34, 0xa4, 0x47, 0x08, 0xce, 0xc7, 0x52, 0xbf, 0x13, 0x28, 0x81, 0xbb, 0x8b, 0x29, 0x09, 0xa5, + 0x54, 0x52, 0xfa, 0x06, 0xfd, 0x89, 0x60, 0x2d, 0x81, 0xf2, 0xd4, 0x76, 0xe9, 0x98, 0x4f, 0xac, + 0x0f, 0xfd, 0x79, 0x1a, 0x4c, 0xac, 0xeb, 0x90, 0x77, 0x5c, 0xdd, 0xed, 0xfb, 0xe3, 0x70, 0xb1, + 0x7a, 0x39, 0x19, 0x94, 0x99, 0x7f, 0x4e, 0x4d, 0x34, 0x66, 0x3a, 0x12, 0x45, 0x26, 0x61, 0xec, + 0x65, 0x53, 0x36, 0x2b, 0xf7, 0x32, 0x6a, 0x3a, 0x1b, 0x4b, 0x9a, 0x35, 0xe8, 0x16, 0xcc, 0xb3, + 0x0f, 0x0b, 0x6f, 0xd0, 0x15, 0xa1, 0xbc, 0x63, 0x7d, 0xe2, 0x3e, 0x4e, 0x7e, 0xfa, 0xb1, 0x78, + 0xe3, 0xd3, 0x2f, 0x47, 0xa7, 0xdf, 0x37, 0xd1, 0x6e, 0x06, 0x79, 0xd5, 0x61, 0x8e, 0x31, 0xb1, + 0xe9, 0x37, 0x55, 0x5a, 0x1a, 0x37, 0x0e, 0x86, 0x20, 0x2f, 0xdc, 0x2b, 0x1d, 0x82, 0x7c, 0xa2, + 0xb0, 0xe0, 0x2f, 0x3f, 0x51, 0x46, 0x59, 0x9c, 0xc2, 0x89, 0xd2, 0x83, 0x37, 0x28, 0xa4, 0x4a, + 0x8c, 0x40, 0x94, 0xe7, 0x20, 0xdf, 0x20, 0x86, 0x11, 0x14, 0x98, 0x3d, 0x9d, 0x58, 0xcc, 0x9f, + 0x11, 0x9c, 0x09, 0x05, 0x65, 0x97, 0xe7, 0x3d, 0xc8, 0x35, 0x88, 0xc1, 0x05, 0xb1, 0x96, 0x7c, + 0x73, 0x54, 0x62, 0x30, 0x15, 0x50, 0xa3, 0x93, 0x53, 0xc0, 0x1a, 0x2c, 0x71, 0xb4, 0xff, 0xbb, + 0xfd, 0xbb, 0xa3, 0x92, 0x05, 0xf0, 0x35, 0xc8, 0x36, 0xd8, 0x21, 0x11, 0x76, 0xcd, 0x3b, 0x5d, + 0x7d, 0x8c, 0x61, 0x96, 0x7a, 0xc2, 0xbf, 0x20, 0xc8, 0xfb, 0xab, 0x1e, 0x7e, 0x3b, 0xd9, 0x78, + 0x7c, 0xd3, 0x2c, 0x6e, 0x4d, 0x61, 0xe1, 0xe3, 0x4a, 0x57, 0x7e, 0xf8, 0xe7, 0xf9, 0xc3, 0xcc, + 0x06, 0x5e, 0x57, 0x04, 0x16, 0x65, 0xfc, 0x08, 0xc1, 0x3c, 0xff, 0xe0, 0xe0, 0xaa, 0x40, 0xb4, + 0xd8, 0x5e, 0x5a, 0xac, 0x4d, 0x65, 0xc3, 0x18, 0x65, 0xca, 0x58, 0xc6, 0x1b, 0x8a, 0xc8, 0xe2, + 0xef, 0xe0, 0x5f, 0x11, 0xcc, 0x31, 0x27, 0x78, 0x4b, 0x3c, 0x20, 0x67, 0xac, 0x4e, 0x63, 0xc2, + 0x10, 0x6b, 0x14, 0xb1, 0x82, 0x2f, 0x8b, 0x21, 0x2a, 0x43, 0x62, 0xec, 0xe3, 0xbf, 0x11, 0x2c, + 0xc5, 0xf6, 0x2b, 0x7c, 0x75, 0x8a, 0x02, 0x45, 0x87, 0x61, 0xf1, 0x5a, 0x1a, 0x53, 0xc6, 0xbf, + 0x43, 0xf9, 0xaf, 0xe2, 0x6d, 0x31, 0xfe, 0x4a, 0x63, 0x50, 0xa1, 0xb3, 0x56, 0x19, 0xd2, 0x7f, + 0xf6, 0xf1, 0x73, 0x04, 0x85, 0x49, 0xab, 0x08, 0xfe, 0x60, 0x2a, 0xaa, 0xb1, 0xb9, 0x58, 0xdc, + 0x49, 0x6d, 0xcf, 0x52, 0xfb, 0x98, 0xa6, 0xf6, 0x11, 0xbe, 0x2e, 0x9e, 0x1a, 0x9d, 0xae, 0x15, + 0x3a, 0x6b, 0x95, 0x61, 0x68, 0xf0, 0xee, 0xe3, 0xbf, 0x10, 0x2c, 0x8e, 0x16, 0x4c, 0x6f, 0xba, + 0xe3, 0x77, 0xc5, 0x01, 0xa3, 0x5f, 0x90, 0x54, 0x17, 0xed, 0x7d, 0x9a, 0xcd, 0x36, 0x7e, 0x47, + 0x28, 0x1b, 0x2f, 0x19, 0x6b, 0xcf, 0x55, 0x86, 0xfe, 0x17, 0x69, 0x9f, 0x0a, 0x98, 0x7f, 0x85, + 0x84, 0x04, 0x1c, 0x5b, 0xd3, 0x84, 0x04, 0x1c, 0xdf, 0x72, 0x44, 0x05, 0x1c, 0x6c, 0x31, 0x9e, + 0x80, 0x99, 0x13, 0x21, 0x01, 0x47, 0x97, 0x94, 0x62, 0x75, 0x1a, 0x93, 0xe9, 0x04, 0xcc, 0x11, + 0x7d, 0x01, 0x3f, 0x46, 0xb0, 0x14, 0xdb, 0x4c, 0x84, 0x04, 0x3c, 0x79, 0x9b, 0x49, 0x57, 0x5b, + 0x41, 0xe5, 0x72, 0xf0, 0x71, 0xe5, 0x3e, 0x43, 0x50, 0x98, 0xb4, 0x98, 0x08, 0x29, 0x37, 0x61, + 0xa3, 0x49, 0x97, 0x8e, 0xa0, 0x5a, 0xc3, 0xe9, 0x24, 0xab, 0x75, 0xb4, 0xbc, 0x09, 0xab, 0x75, + 0xe2, 0xbe, 0x97, 0xea, 0x56, 0x09, 0xaa, 0x95, 0x65, 0x33, 0xa6, 0xd6, 0x87, 0x08, 0x72, 0xde, + 0x66, 0x84, 0x65, 0x81, 0xd8, 0xa1, 0xbd, 0xad, 0xa8, 0x08, 0x9f, 0x67, 0xa0, 0x9b, 0x14, 0x74, + 0x1d, 0x4b, 0xc9, 0xa0, 0x74, 0xc3, 0xfa, 0x09, 0x41, 0x56, 0x25, 0x06, 0xae, 0x88, 0x05, 0xe1, + 0x4c, 0xb2, 0xe8, 0x71, 0x86, 0xa4, 0x50, 0xa4, 0x4b, 0xf8, 0xe2, 0x8b, 0x91, 0xa8, 0x1a, 0xd5, + 0x4f, 0x9f, 0x1c, 0x96, 0xd0, 0xd3, 0xc3, 0x12, 0xfa, 0xf7, 0xb0, 0x84, 0x7e, 0x3c, 0x2a, 0xcd, + 0x3c, 0x3d, 0x2a, 0xcd, 0x3c, 0x3b, 0x2a, 0xcd, 0x7c, 0x5d, 0x6b, 0x11, 0xf7, 0x5e, 0xbf, 0x21, + 0x37, 0xed, 0x8e, 0xc2, 0x21, 0x02, 0xaf, 0xf7, 0xfa, 0x0d, 0x25, 0xea, 0xda, 0x1d, 0x74, 0x4d, + 0xa7, 0x91, 0xa7, 0xff, 0xa7, 0x57, 0xfb, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x68, 0xb1, 0x2a, 0x2e, + 0x00, 0x15, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params queries params of the marketplace module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + Listings(ctx context.Context, in *QueryListingsRequest, opts ...grpc.CallOption) (*QueryListingsResponse, error) + Listing(ctx context.Context, in *QueryListingRequest, opts ...grpc.CallOption) (*QueryListingResponse, error) + ListingsByOwner(ctx context.Context, in *QueryListingsByOwnerRequest, opts ...grpc.CallOption) (*QueryListingsByOwnerResponse, error) + ListingsByPriceDenom(ctx context.Context, in *QueryListingsByPriceDenomRequest, opts ...grpc.CallOption) (*QueryListingsByPriceDenomResponse, error) + ListingByNftId(ctx context.Context, in *QueryListingByNFTIDRequest, opts ...grpc.CallOption) (*QueryListingResponse, error) + // auction queries + Auctions(ctx context.Context, in *QueryAuctionsRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) + Auction(ctx context.Context, in *QueryAuctionRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) + AuctionsByOwner(ctx context.Context, in *QueryAuctionsByOwnerRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) + AuctionsByPriceDenom(ctx context.Context, in *QueryAuctionsByPriceDenomRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) + AuctionByNftId(ctx context.Context, in *QueryAuctionByNFTIDRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) + Bids(ctx context.Context, in *QueryBidsRequest, opts ...grpc.CallOption) (*QueryBidsResponse, error) + Bid(ctx context.Context, in *QueryBidRequest, opts ...grpc.CallOption) (*QueryBidResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Listings(ctx context.Context, in *QueryListingsRequest, opts ...grpc.CallOption) (*QueryListingsResponse, error) { + out := new(QueryListingsResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Listings", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Listing(ctx context.Context, in *QueryListingRequest, opts ...grpc.CallOption) (*QueryListingResponse, error) { + out := new(QueryListingResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Listing", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ListingsByOwner(ctx context.Context, in *QueryListingsByOwnerRequest, opts ...grpc.CallOption) (*QueryListingsByOwnerResponse, error) { + out := new(QueryListingsByOwnerResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/ListingsByOwner", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ListingsByPriceDenom(ctx context.Context, in *QueryListingsByPriceDenomRequest, opts ...grpc.CallOption) (*QueryListingsByPriceDenomResponse, error) { + out := new(QueryListingsByPriceDenomResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/ListingsByPriceDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ListingByNftId(ctx context.Context, in *QueryListingByNFTIDRequest, opts ...grpc.CallOption) (*QueryListingResponse, error) { + out := new(QueryListingResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/ListingByNftId", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Auctions(ctx context.Context, in *QueryAuctionsRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) { + out := new(QueryAuctionsResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Auctions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Auction(ctx context.Context, in *QueryAuctionRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) { + out := new(QueryAuctionResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Auction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AuctionsByOwner(ctx context.Context, in *QueryAuctionsByOwnerRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) { + out := new(QueryAuctionsResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/AuctionsByOwner", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AuctionsByPriceDenom(ctx context.Context, in *QueryAuctionsByPriceDenomRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) { + out := new(QueryAuctionsResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/AuctionsByPriceDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AuctionByNftId(ctx context.Context, in *QueryAuctionByNFTIDRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) { + out := new(QueryAuctionResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/AuctionByNftId", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Bids(ctx context.Context, in *QueryBidsRequest, opts ...grpc.CallOption) (*QueryBidsResponse, error) { + out := new(QueryBidsResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Bids", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Bid(ctx context.Context, in *QueryBidRequest, opts ...grpc.CallOption) (*QueryBidResponse, error) { + out := new(QueryBidResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Query/Bid", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries params of the marketplace module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + Listings(context.Context, *QueryListingsRequest) (*QueryListingsResponse, error) + Listing(context.Context, *QueryListingRequest) (*QueryListingResponse, error) + ListingsByOwner(context.Context, *QueryListingsByOwnerRequest) (*QueryListingsByOwnerResponse, error) + ListingsByPriceDenom(context.Context, *QueryListingsByPriceDenomRequest) (*QueryListingsByPriceDenomResponse, error) + ListingByNftId(context.Context, *QueryListingByNFTIDRequest) (*QueryListingResponse, error) + // auction queries + Auctions(context.Context, *QueryAuctionsRequest) (*QueryAuctionsResponse, error) + Auction(context.Context, *QueryAuctionRequest) (*QueryAuctionResponse, error) + AuctionsByOwner(context.Context, *QueryAuctionsByOwnerRequest) (*QueryAuctionsResponse, error) + AuctionsByPriceDenom(context.Context, *QueryAuctionsByPriceDenomRequest) (*QueryAuctionsResponse, error) + AuctionByNftId(context.Context, *QueryAuctionByNFTIDRequest) (*QueryAuctionResponse, error) + Bids(context.Context, *QueryBidsRequest) (*QueryBidsResponse, error) + Bid(context.Context, *QueryBidRequest) (*QueryBidResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Listings(ctx context.Context, req *QueryListingsRequest) (*QueryListingsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Listings not implemented") +} +func (*UnimplementedQueryServer) Listing(ctx context.Context, req *QueryListingRequest) (*QueryListingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Listing not implemented") +} +func (*UnimplementedQueryServer) ListingsByOwner(ctx context.Context, req *QueryListingsByOwnerRequest) (*QueryListingsByOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListingsByOwner not implemented") +} +func (*UnimplementedQueryServer) ListingsByPriceDenom(ctx context.Context, req *QueryListingsByPriceDenomRequest) (*QueryListingsByPriceDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListingsByPriceDenom not implemented") +} +func (*UnimplementedQueryServer) ListingByNftId(ctx context.Context, req *QueryListingByNFTIDRequest) (*QueryListingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListingByNftId not implemented") +} +func (*UnimplementedQueryServer) Auctions(ctx context.Context, req *QueryAuctionsRequest) (*QueryAuctionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Auctions not implemented") +} +func (*UnimplementedQueryServer) Auction(ctx context.Context, req *QueryAuctionRequest) (*QueryAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Auction not implemented") +} +func (*UnimplementedQueryServer) AuctionsByOwner(ctx context.Context, req *QueryAuctionsByOwnerRequest) (*QueryAuctionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AuctionsByOwner not implemented") +} +func (*UnimplementedQueryServer) AuctionsByPriceDenom(ctx context.Context, req *QueryAuctionsByPriceDenomRequest) (*QueryAuctionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AuctionsByPriceDenom not implemented") +} +func (*UnimplementedQueryServer) AuctionByNftId(ctx context.Context, req *QueryAuctionByNFTIDRequest) (*QueryAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AuctionByNftId not implemented") +} +func (*UnimplementedQueryServer) Bids(ctx context.Context, req *QueryBidsRequest) (*QueryBidsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Bids not implemented") +} +func (*UnimplementedQueryServer) Bid(ctx context.Context, req *QueryBidRequest) (*QueryBidResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Bid not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Listings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListingsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Listings(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Listings", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Listings(ctx, req.(*QueryListingsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Listing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Listing(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Listing", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Listing(ctx, req.(*QueryListingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListingsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListingsByOwnerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListingsByOwner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/ListingsByOwner", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListingsByOwner(ctx, req.(*QueryListingsByOwnerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListingsByPriceDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListingsByPriceDenomRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListingsByPriceDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/ListingsByPriceDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListingsByPriceDenom(ctx, req.(*QueryListingsByPriceDenomRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListingByNftId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListingByNFTIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListingByNftId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/ListingByNftId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListingByNftId(ctx, req.(*QueryListingByNFTIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Auctions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Auctions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Auctions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Auctions(ctx, req.(*QueryAuctionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Auction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Auction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Auction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Auction(ctx, req.(*QueryAuctionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AuctionsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionsByOwnerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AuctionsByOwner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/AuctionsByOwner", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AuctionsByOwner(ctx, req.(*QueryAuctionsByOwnerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AuctionsByPriceDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionsByPriceDenomRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AuctionsByPriceDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/AuctionsByPriceDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AuctionsByPriceDenom(ctx, req.(*QueryAuctionsByPriceDenomRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AuctionByNftId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionByNFTIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AuctionByNftId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/AuctionByNftId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AuctionByNftId(ctx, req.(*QueryAuctionByNFTIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Bids_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBidsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Bids(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Bids", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Bids(ctx, req.(*QueryBidsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Bid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBidRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Bid(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Query/Bid", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Bid(ctx, req.(*QueryBidRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "OmniFlix.marketplace.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Listings", + Handler: _Query_Listings_Handler, + }, + { + MethodName: "Listing", + Handler: _Query_Listing_Handler, + }, + { + MethodName: "ListingsByOwner", + Handler: _Query_ListingsByOwner_Handler, + }, + { + MethodName: "ListingsByPriceDenom", + Handler: _Query_ListingsByPriceDenom_Handler, + }, + { + MethodName: "ListingByNftId", + Handler: _Query_ListingByNftId_Handler, + }, + { + MethodName: "Auctions", + Handler: _Query_Auctions_Handler, + }, + { + MethodName: "Auction", + Handler: _Query_Auction_Handler, + }, + { + MethodName: "AuctionsByOwner", + Handler: _Query_AuctionsByOwner_Handler, + }, + { + MethodName: "AuctionsByPriceDenom", + Handler: _Query_AuctionsByPriceDenom_Handler, + }, + { + MethodName: "AuctionByNftId", + Handler: _Query_AuctionByNftId_Handler, + }, + { + MethodName: "Bids", + Handler: _Query_Bids_Handler, + }, + { + MethodName: "Bid", + Handler: _Query_Bid_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "omniflix/marketplace/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryListingsRequest) 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 *QueryListingsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.PriceDenom) > 0 { + i -= len(m.PriceDenom) + copy(dAtA[i:], m.PriceDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PriceDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListingsResponse) 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 *QueryListingsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Listings) > 0 { + for iNdEx := len(m.Listings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Listings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryListingRequest) 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 *QueryListingRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListingResponse) 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 *QueryListingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Listing != nil { + { + size, err := m.Listing.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListingsByOwnerRequest) 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 *QueryListingsByOwnerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListingsByOwnerResponse) 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 *QueryListingsByOwnerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingsByOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Listings) > 0 { + for iNdEx := len(m.Listings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Listings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryListingByNFTIDRequest) 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 *QueryListingByNFTIDRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingByNFTIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListingsByPriceDenomRequest) 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 *QueryListingsByPriceDenomRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingsByPriceDenomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.PriceDenom) > 0 { + i -= len(m.PriceDenom) + copy(dAtA[i:], m.PriceDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PriceDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListingsByPriceDenomResponse) 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 *QueryListingsByPriceDenomResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListingsByPriceDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Listings) > 0 { + for iNdEx := len(m.Listings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Listings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionsRequest) 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 *QueryAuctionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.PriceDenom) > 0 { + i -= len(m.PriceDenom) + copy(dAtA[i:], m.PriceDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PriceDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionsResponse) 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 *QueryAuctionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionRequest) 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 *QueryAuctionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionResponse) 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 *QueryAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Auction != nil { + { + size, err := m.Auction.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionsByOwnerRequest) 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 *QueryAuctionsByOwnerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionByNFTIDRequest) 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 *QueryAuctionByNFTIDRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionByNFTIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionsByPriceDenomRequest) 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 *QueryAuctionsByPriceDenomRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsByPriceDenomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.PriceDenom) > 0 { + i -= len(m.PriceDenom) + copy(dAtA[i:], m.PriceDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PriceDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBidsRequest) 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 *QueryBidsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBidsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBidsResponse) 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 *QueryBidsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBidsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryBidRequest) 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 *QueryBidRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBidRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryBidResponse) 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 *QueryBidResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBidResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Bid != nil { + { + size, err := m.Bid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryListingsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.PriceDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Listings) > 0 { + for _, e := range m.Listings { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Listing != nil { + l = m.Listing.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingsByOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingsByOwnerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Listings) > 0 { + for _, e := range m.Listings { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingByNFTIDRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingsByPriceDenomRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PriceDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListingsByPriceDenomResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Listings) > 0 { + for _, e := range m.Listings { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.PriceDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Auctions) > 0 { + for _, e := range m.Auctions { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n +} + +func (m *QueryAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Auction != nil { + l = m.Auction.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionsByOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionByNFTIDRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionsByPriceDenomRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PriceDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBidsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBidsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Bids) > 0 { + for _, e := range m.Bids { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBidRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n +} + +func (m *QueryBidResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Bid != nil { + l = m.Bid.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingsRequest) 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 ErrIntOverflowQuery + } + 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: QueryListingsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PriceDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingsResponse) 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 ErrIntOverflowQuery + } + 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: QueryListingsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Listings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Listings = append(m.Listings, Listing{}) + if err := m.Listings[len(m.Listings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingRequest) 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 ErrIntOverflowQuery + } + 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: QueryListingRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingResponse) 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 ErrIntOverflowQuery + } + 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: QueryListingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Listing", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Listing == nil { + m.Listing = &Listing{} + } + if err := m.Listing.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingsByOwnerRequest) 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 ErrIntOverflowQuery + } + 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: QueryListingsByOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingsByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingsByOwnerResponse) 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 ErrIntOverflowQuery + } + 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: QueryListingsByOwnerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingsByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Listings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Listings = append(m.Listings, Listing{}) + if err := m.Listings[len(m.Listings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingByNFTIDRequest) 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 ErrIntOverflowQuery + } + 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: QueryListingByNFTIDRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingByNFTIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingsByPriceDenomRequest) 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 ErrIntOverflowQuery + } + 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: QueryListingsByPriceDenomRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingsByPriceDenomRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PriceDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListingsByPriceDenomResponse) 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 ErrIntOverflowQuery + } + 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: QueryListingsByPriceDenomResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListingsByPriceDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Listings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Listings = append(m.Listings, Listing{}) + if err := m.Listings[len(m.Listings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionsRequest) 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 ErrIntOverflowQuery + } + 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: QueryAuctionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= AuctionStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PriceDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionsResponse) 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 ErrIntOverflowQuery + } + 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: QueryAuctionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Auctions = append(m.Auctions, AuctionListing{}) + if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionRequest) 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 ErrIntOverflowQuery + } + 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: QueryAuctionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionResponse) 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 ErrIntOverflowQuery + } + 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: QueryAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Auction", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Auction == nil { + m.Auction = &AuctionListing{} + } + if err := m.Auction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionsByOwnerRequest) 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 ErrIntOverflowQuery + } + 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: QueryAuctionsByOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionsByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionByNFTIDRequest) 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 ErrIntOverflowQuery + } + 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: QueryAuctionByNFTIDRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionByNFTIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAuctionsByPriceDenomRequest) 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 ErrIntOverflowQuery + } + 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: QueryAuctionsByPriceDenomRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionsByPriceDenomRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PriceDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBidsRequest) 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 ErrIntOverflowQuery + } + 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: QueryBidsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBidsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBidsResponse) 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 ErrIntOverflowQuery + } + 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: QueryBidsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBidsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBidRequest) 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 ErrIntOverflowQuery + } + 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: QueryBidRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBidRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBidResponse) 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 ErrIntOverflowQuery + } + 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: QueryBidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBidResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Bid == nil { + m.Bid = &Bid{} + } + if err := m.Bid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/marketplace/types/query.pb.gw.go b/x/marketplace/types/query.pb.gw.go new file mode 100644 index 00000000..98c7c1ad --- /dev/null +++ b/x/marketplace/types/query.pb.gw.go @@ -0,0 +1,1383 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Listings_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Listings_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Listings_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Listings(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Listings_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Listings_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Listings(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Listing_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.Listing(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Listing_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.Listing(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ListingsByOwner_0 = &utilities.DoubleArray{Encoding: map[string]int{"owner": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ListingsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingsByOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListingsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListingsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListingsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingsByOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListingsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListingsByOwner(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ListingsByPriceDenom_0 = &utilities.DoubleArray{Encoding: map[string]int{"price_denom": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ListingsByPriceDenom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingsByPriceDenomRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["price_denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "price_denom") + } + + protoReq.PriceDenom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "price_denom", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListingsByPriceDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListingsByPriceDenom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListingsByPriceDenom_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingsByPriceDenomRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["price_denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "price_denom") + } + + protoReq.PriceDenom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "price_denom", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListingsByPriceDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListingsByPriceDenom(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ListingByNftId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingByNFTIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["nft_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nft_id") + } + + protoReq.NftId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nft_id", err) + } + + msg, err := client.ListingByNftId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListingByNftId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListingByNFTIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["nft_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nft_id") + } + + protoReq.NftId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nft_id", err) + } + + msg, err := server.ListingByNftId(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Auctions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Auctions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Auctions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Auctions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Auctions(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.Auction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.Auction(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AuctionsByOwner_0 = &utilities.DoubleArray{Encoding: map[string]int{"owner": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_AuctionsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsByOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuctionsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AuctionsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AuctionsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsByOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuctionsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AuctionsByOwner(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AuctionsByPriceDenom_0 = &utilities.DoubleArray{Encoding: map[string]int{"price_denom": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_AuctionsByPriceDenom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsByPriceDenomRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["price_denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "price_denom") + } + + protoReq.PriceDenom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "price_denom", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuctionsByPriceDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AuctionsByPriceDenom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AuctionsByPriceDenom_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsByPriceDenomRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["price_denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "price_denom") + } + + protoReq.PriceDenom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "price_denom", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuctionsByPriceDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AuctionsByPriceDenom(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_AuctionByNftId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionByNFTIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["nft_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nft_id") + } + + protoReq.NftId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nft_id", err) + } + + msg, err := client.AuctionByNftId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AuctionByNftId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionByNFTIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["nft_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nft_id") + } + + protoReq.NftId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nft_id", err) + } + + msg, err := server.AuctionByNftId(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Bids_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Bids_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBidsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Bids_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Bids(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Bids_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBidsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Bids_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Bids(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Bid_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBidRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.Bid(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Bid_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBidRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.Bid(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Listings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Listings_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Listings_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Listing_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Listing_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Listing_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListingsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ListingsByOwner_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListingsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListingsByPriceDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ListingsByPriceDenom_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListingsByPriceDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListingByNftId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ListingByNftId_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListingByNftId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Auctions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Auctions_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Auction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Auction_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuctionsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AuctionsByOwner_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuctionsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuctionsByPriceDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AuctionsByPriceDenom_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuctionsByPriceDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuctionByNftId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AuctionByNftId_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuctionByNftId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Bids_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Bids_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Bids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Bid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Bid_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Bid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Listings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Listings_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Listings_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Listing_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Listing_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Listing_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListingsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ListingsByOwner_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListingsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListingsByPriceDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ListingsByPriceDenom_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListingsByPriceDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListingByNftId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ListingByNftId_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListingByNftId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Auctions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Auctions_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Auction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Auction_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuctionsByOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AuctionsByOwner_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuctionsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuctionsByPriceDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AuctionsByPriceDenom_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuctionsByPriceDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuctionByNftId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AuctionByNftId_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuctionByNftId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Bids_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Bids_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Bids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Bid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Bid_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Bid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"omniflix", "marketplace", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Listings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"omniflix", "marketplace", "v1beta1", "listings"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Listing_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "listings", "id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ListingsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "listings-by-owner", "owner"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ListingsByPriceDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "listings-by-price-denom", "price_denom"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ListingByNftId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "listing-by-nft", "nft_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"omniflix", "marketplace", "v1beta1", "auctions"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "auctions", "id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AuctionsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "auctions-by-owner", "owner"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AuctionsByPriceDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "auctions-by-price-denom", "price_denom"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AuctionByNftId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "auction-by-nft", "nft_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Bids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"omniflix", "marketplace", "v1beta1", "bids"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Bid_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"omniflix", "marketplace", "v1beta1", "bids", "id"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Listings_0 = runtime.ForwardResponseMessage + + forward_Query_Listing_0 = runtime.ForwardResponseMessage + + forward_Query_ListingsByOwner_0 = runtime.ForwardResponseMessage + + forward_Query_ListingsByPriceDenom_0 = runtime.ForwardResponseMessage + + forward_Query_ListingByNftId_0 = runtime.ForwardResponseMessage + + forward_Query_Auctions_0 = runtime.ForwardResponseMessage + + forward_Query_Auction_0 = runtime.ForwardResponseMessage + + forward_Query_AuctionsByOwner_0 = runtime.ForwardResponseMessage + + forward_Query_AuctionsByPriceDenom_0 = runtime.ForwardResponseMessage + + forward_Query_AuctionByNftId_0 = runtime.ForwardResponseMessage + + forward_Query_Bids_0 = runtime.ForwardResponseMessage + + forward_Query_Bid_0 = runtime.ForwardResponseMessage +) diff --git a/x/marketplace/types/tx.pb.go b/x/marketplace/types/tx.pb.go new file mode 100644 index 00000000..c5dfab6e --- /dev/null +++ b/x/marketplace/types/tx.pb.go @@ -0,0 +1,3472 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: omniflix/marketplace/v1beta1/tx.proto + +package types + +import ( + context "context" + 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" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 MsgListNFT struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + NftId string `protobuf:"bytes,2,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,3,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + Price types.Coin `protobuf:"bytes,4,opt,name=price,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"price"` + Owner string `protobuf:"bytes,5,opt,name=owner,proto3" json:"owner,omitempty"` + SplitShares []WeightedAddress `protobuf:"bytes,6,rep,name=split_shares,json=splitShares,proto3" json:"split_shares" yaml:"split_shares"` +} + +func (m *MsgListNFT) Reset() { *m = MsgListNFT{} } +func (m *MsgListNFT) String() string { return proto.CompactTextString(m) } +func (*MsgListNFT) ProtoMessage() {} +func (*MsgListNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{0} +} +func (m *MsgListNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgListNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgListNFT.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 *MsgListNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgListNFT.Merge(m, src) +} +func (m *MsgListNFT) XXX_Size() int { + return m.Size() +} +func (m *MsgListNFT) XXX_DiscardUnknown() { + xxx_messageInfo_MsgListNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgListNFT proto.InternalMessageInfo + +type MsgListNFTResponse struct { +} + +func (m *MsgListNFTResponse) Reset() { *m = MsgListNFTResponse{} } +func (m *MsgListNFTResponse) String() string { return proto.CompactTextString(m) } +func (*MsgListNFTResponse) ProtoMessage() {} +func (*MsgListNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{1} +} +func (m *MsgListNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgListNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgListNFTResponse.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 *MsgListNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgListNFTResponse.Merge(m, src) +} +func (m *MsgListNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgListNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgListNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgListNFTResponse proto.InternalMessageInfo + +type MsgEditListing struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Price types.Coin `protobuf:"bytes,2,opt,name=price,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"price"` + Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *MsgEditListing) Reset() { *m = MsgEditListing{} } +func (m *MsgEditListing) String() string { return proto.CompactTextString(m) } +func (*MsgEditListing) ProtoMessage() {} +func (*MsgEditListing) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{2} +} +func (m *MsgEditListing) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditListing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditListing.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 *MsgEditListing) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditListing.Merge(m, src) +} +func (m *MsgEditListing) XXX_Size() int { + return m.Size() +} +func (m *MsgEditListing) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditListing.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditListing proto.InternalMessageInfo + +type MsgEditListingResponse struct { +} + +func (m *MsgEditListingResponse) Reset() { *m = MsgEditListingResponse{} } +func (m *MsgEditListingResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEditListingResponse) ProtoMessage() {} +func (*MsgEditListingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{3} +} +func (m *MsgEditListingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditListingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditListingResponse.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 *MsgEditListingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditListingResponse.Merge(m, src) +} +func (m *MsgEditListingResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEditListingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditListingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditListingResponse proto.InternalMessageInfo + +type MsgDeListNFT struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *MsgDeListNFT) Reset() { *m = MsgDeListNFT{} } +func (m *MsgDeListNFT) String() string { return proto.CompactTextString(m) } +func (*MsgDeListNFT) ProtoMessage() {} +func (*MsgDeListNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{4} +} +func (m *MsgDeListNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeListNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeListNFT.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 *MsgDeListNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeListNFT.Merge(m, src) +} +func (m *MsgDeListNFT) XXX_Size() int { + return m.Size() +} +func (m *MsgDeListNFT) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeListNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeListNFT proto.InternalMessageInfo + +type MsgDeListNFTResponse struct { +} + +func (m *MsgDeListNFTResponse) Reset() { *m = MsgDeListNFTResponse{} } +func (m *MsgDeListNFTResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeListNFTResponse) ProtoMessage() {} +func (*MsgDeListNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{5} +} +func (m *MsgDeListNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeListNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeListNFTResponse.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 *MsgDeListNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeListNFTResponse.Merge(m, src) +} +func (m *MsgDeListNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeListNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeListNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeListNFTResponse proto.InternalMessageInfo + +type MsgBuyNFT struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Price types.Coin `protobuf:"bytes,2,opt,name=price,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"price"` + Buyer string `protobuf:"bytes,3,opt,name=buyer,proto3" json:"buyer,omitempty"` +} + +func (m *MsgBuyNFT) Reset() { *m = MsgBuyNFT{} } +func (m *MsgBuyNFT) String() string { return proto.CompactTextString(m) } +func (*MsgBuyNFT) ProtoMessage() {} +func (*MsgBuyNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{6} +} +func (m *MsgBuyNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBuyNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBuyNFT.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 *MsgBuyNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBuyNFT.Merge(m, src) +} +func (m *MsgBuyNFT) XXX_Size() int { + return m.Size() +} +func (m *MsgBuyNFT) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBuyNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBuyNFT proto.InternalMessageInfo + +type MsgBuyNFTResponse struct { +} + +func (m *MsgBuyNFTResponse) Reset() { *m = MsgBuyNFTResponse{} } +func (m *MsgBuyNFTResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBuyNFTResponse) ProtoMessage() {} +func (*MsgBuyNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{7} +} +func (m *MsgBuyNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBuyNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBuyNFTResponse.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 *MsgBuyNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBuyNFTResponse.Merge(m, src) +} +func (m *MsgBuyNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBuyNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBuyNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBuyNFTResponse proto.InternalMessageInfo + +type MsgCreateAuction struct { + NftId string `protobuf:"bytes,1,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` + DenomId string `protobuf:"bytes,2,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty"` + StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + StartPrice types.Coin `protobuf:"bytes,4,opt,name=start_price,json=startPrice,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"start_price" yaml:"start_price"` + Duration *time.Duration `protobuf:"bytes,5,opt,name=duration,proto3,stdduration" json:"duration,omitempty"` + IncrementPercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=increment_percentage,json=incrementPercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_percentage" yaml:"increment_percentage"` + WhitelistAccounts []string `protobuf:"bytes,7,rep,name=whitelist_accounts,json=whitelistAccounts,proto3" json:"whitelist_accounts,omitempty" yaml:"whitelist_accounts"` + SplitShares []WeightedAddress `protobuf:"bytes,8,rep,name=split_shares,json=splitShares,proto3" json:"split_shares" yaml:"split_shares"` + Owner string `protobuf:"bytes,9,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *MsgCreateAuction) Reset() { *m = MsgCreateAuction{} } +func (m *MsgCreateAuction) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAuction) ProtoMessage() {} +func (*MsgCreateAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{8} +} +func (m *MsgCreateAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAuction.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 *MsgCreateAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAuction.Merge(m, src) +} +func (m *MsgCreateAuction) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAuction) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAuction proto.InternalMessageInfo + +type MsgCreateAuctionResponse struct { + Auction *AuctionListing `protobuf:"bytes,1,opt,name=auction,proto3" json:"auction,omitempty"` +} + +func (m *MsgCreateAuctionResponse) Reset() { *m = MsgCreateAuctionResponse{} } +func (m *MsgCreateAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAuctionResponse) ProtoMessage() {} +func (*MsgCreateAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{9} +} +func (m *MsgCreateAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAuctionResponse.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 *MsgCreateAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAuctionResponse.Merge(m, src) +} +func (m *MsgCreateAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAuctionResponse proto.InternalMessageInfo + +type MsgCancelAuction struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty" yaml:"auction_id"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *MsgCancelAuction) Reset() { *m = MsgCancelAuction{} } +func (m *MsgCancelAuction) String() string { return proto.CompactTextString(m) } +func (*MsgCancelAuction) ProtoMessage() {} +func (*MsgCancelAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{10} +} +func (m *MsgCancelAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCancelAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCancelAuction.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 *MsgCancelAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCancelAuction.Merge(m, src) +} +func (m *MsgCancelAuction) XXX_Size() int { + return m.Size() +} +func (m *MsgCancelAuction) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCancelAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCancelAuction proto.InternalMessageInfo + +type MsgCancelAuctionResponse struct { +} + +func (m *MsgCancelAuctionResponse) Reset() { *m = MsgCancelAuctionResponse{} } +func (m *MsgCancelAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCancelAuctionResponse) ProtoMessage() {} +func (*MsgCancelAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{11} +} +func (m *MsgCancelAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCancelAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCancelAuctionResponse.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 *MsgCancelAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCancelAuctionResponse.Merge(m, src) +} +func (m *MsgCancelAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCancelAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCancelAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCancelAuctionResponse proto.InternalMessageInfo + +type MsgPlaceBid struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty" yaml:"auction_id"` + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount"` + Bidder string `protobuf:"bytes,3,opt,name=bidder,proto3" json:"bidder,omitempty"` +} + +func (m *MsgPlaceBid) Reset() { *m = MsgPlaceBid{} } +func (m *MsgPlaceBid) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceBid) ProtoMessage() {} +func (*MsgPlaceBid) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{12} +} +func (m *MsgPlaceBid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceBid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceBid.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 *MsgPlaceBid) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceBid.Merge(m, src) +} +func (m *MsgPlaceBid) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceBid) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceBid.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceBid proto.InternalMessageInfo + +type MsgPlaceBidResponse struct { +} + +func (m *MsgPlaceBidResponse) Reset() { *m = MsgPlaceBidResponse{} } +func (m *MsgPlaceBidResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceBidResponse) ProtoMessage() {} +func (*MsgPlaceBidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9ef324d37a95f547, []int{13} +} +func (m *MsgPlaceBidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceBidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceBidResponse.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 *MsgPlaceBidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceBidResponse.Merge(m, src) +} +func (m *MsgPlaceBidResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceBidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceBidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceBidResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgListNFT)(nil), "OmniFlix.marketplace.v1beta1.MsgListNFT") + proto.RegisterType((*MsgListNFTResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgListNFTResponse") + proto.RegisterType((*MsgEditListing)(nil), "OmniFlix.marketplace.v1beta1.MsgEditListing") + proto.RegisterType((*MsgEditListingResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgEditListingResponse") + proto.RegisterType((*MsgDeListNFT)(nil), "OmniFlix.marketplace.v1beta1.MsgDeListNFT") + proto.RegisterType((*MsgDeListNFTResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgDeListNFTResponse") + proto.RegisterType((*MsgBuyNFT)(nil), "OmniFlix.marketplace.v1beta1.MsgBuyNFT") + proto.RegisterType((*MsgBuyNFTResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgBuyNFTResponse") + proto.RegisterType((*MsgCreateAuction)(nil), "OmniFlix.marketplace.v1beta1.MsgCreateAuction") + proto.RegisterType((*MsgCreateAuctionResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgCreateAuctionResponse") + proto.RegisterType((*MsgCancelAuction)(nil), "OmniFlix.marketplace.v1beta1.MsgCancelAuction") + proto.RegisterType((*MsgCancelAuctionResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgCancelAuctionResponse") + proto.RegisterType((*MsgPlaceBid)(nil), "OmniFlix.marketplace.v1beta1.MsgPlaceBid") + proto.RegisterType((*MsgPlaceBidResponse)(nil), "OmniFlix.marketplace.v1beta1.MsgPlaceBidResponse") +} + +func init() { + proto.RegisterFile("omniflix/marketplace/v1beta1/tx.proto", fileDescriptor_9ef324d37a95f547) +} + +var fileDescriptor_9ef324d37a95f547 = []byte{ + // 980 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0x8e, 0x93, 0x26, 0x6d, 0xde, 0x2c, 0x2b, 0xea, 0xa6, 0x95, 0xeb, 0x05, 0xa7, 0x58, 0x82, + 0x0d, 0xab, 0x5d, 0x9b, 0x66, 0x2b, 0x0e, 0x70, 0xaa, 0xb7, 0x5b, 0xa9, 0xd2, 0x06, 0x4a, 0x58, + 0x09, 0xc4, 0x81, 0xe0, 0x8f, 0xa9, 0x33, 0x6a, 0x6c, 0x07, 0xcf, 0x84, 0xb6, 0x37, 0xb8, 0x73, + 0x58, 0x89, 0xcb, 0xfe, 0x06, 0xee, 0x1c, 0x38, 0x71, 0xed, 0x71, 0x8f, 0x88, 0x43, 0x17, 0xda, + 0x7f, 0xb0, 0xbf, 0x00, 0x79, 0xc6, 0x9e, 0x38, 0xfd, 0x8a, 0x8b, 0x54, 0x4e, 0xc9, 0xcc, 0x3c, + 0xef, 0xf3, 0x7e, 0xcc, 0xfb, 0xbc, 0x63, 0x78, 0x3f, 0x0a, 0x42, 0xbc, 0x37, 0xc4, 0x87, 0x66, + 0x60, 0xc7, 0xfb, 0x88, 0x8e, 0x86, 0xb6, 0x8b, 0xcc, 0x1f, 0xd6, 0x1d, 0x44, 0xed, 0x75, 0x93, + 0x1e, 0x1a, 0xa3, 0x38, 0xa2, 0x91, 0xfc, 0xce, 0xe7, 0x41, 0x88, 0xb7, 0x87, 0xf8, 0xd0, 0xc8, + 0xc1, 0x8c, 0x14, 0xa6, 0x6a, 0x6e, 0x44, 0x82, 0x88, 0x98, 0x8e, 0x4d, 0x26, 0xb6, 0x6e, 0x84, + 0x43, 0x6e, 0xad, 0x3e, 0xb8, 0xd6, 0xc9, 0x10, 0x13, 0x8a, 0x43, 0xbf, 0x10, 0xd6, 0x1e, 0xbb, + 0x14, 0x47, 0x19, 0x6f, 0xd3, 0x8f, 0xfc, 0x88, 0xfd, 0x35, 0x93, 0x7f, 0xe9, 0xae, 0xe6, 0x47, + 0x91, 0x3f, 0x44, 0x26, 0x5b, 0x39, 0xe3, 0x3d, 0xd3, 0x1b, 0xc7, 0x76, 0xce, 0xaa, 0x75, 0xfe, + 0x9c, 0xe2, 0x00, 0x11, 0x6a, 0x07, 0x23, 0x0e, 0xd0, 0x7f, 0x2b, 0x03, 0x74, 0x89, 0xff, 0x0c, + 0x13, 0xfa, 0xd9, 0xf6, 0x73, 0xf9, 0x2e, 0x94, 0xb1, 0xa7, 0x48, 0x6b, 0x52, 0xbb, 0xde, 0x2b, + 0x63, 0x4f, 0x5e, 0x86, 0x5a, 0xb8, 0x47, 0xfb, 0xd8, 0x53, 0xca, 0x6c, 0xaf, 0x1a, 0xee, 0xd1, + 0x1d, 0x4f, 0x5e, 0x85, 0x05, 0x0f, 0x85, 0x51, 0x90, 0x1c, 0x54, 0xd8, 0xc1, 0x3c, 0x5b, 0xef, + 0x78, 0xf2, 0x77, 0x50, 0x1d, 0xc5, 0xd8, 0x45, 0xca, 0xdc, 0x9a, 0xd4, 0x6e, 0x74, 0x56, 0x0d, + 0x5e, 0x2f, 0x23, 0xa9, 0x57, 0x56, 0x44, 0xe3, 0x49, 0x84, 0x43, 0xcb, 0x3c, 0x3e, 0x69, 0x95, + 0x7e, 0x7d, 0xdd, 0xba, 0xef, 0x63, 0x3a, 0x18, 0x3b, 0x86, 0x1b, 0x05, 0x66, 0x5a, 0x5c, 0xfe, + 0xf3, 0x88, 0x78, 0xfb, 0x26, 0x3d, 0x1a, 0x21, 0xc2, 0x0c, 0x7a, 0x9c, 0x58, 0x6e, 0x42, 0x35, + 0x3a, 0x08, 0x51, 0xac, 0x54, 0x79, 0x48, 0x6c, 0x21, 0x07, 0x70, 0x87, 0x8c, 0x86, 0x98, 0xf6, + 0xc9, 0xc0, 0x8e, 0x11, 0x51, 0x6a, 0x6b, 0x95, 0x76, 0xa3, 0xf3, 0xc8, 0xb8, 0xee, 0x32, 0x8d, + 0xaf, 0x10, 0xf6, 0x07, 0x14, 0x79, 0x9b, 0x9e, 0x17, 0x23, 0x42, 0xac, 0x7b, 0x49, 0x48, 0x6f, + 0x4e, 0x5a, 0x4b, 0x47, 0x76, 0x30, 0xfc, 0x44, 0xcf, 0x13, 0xea, 0xbd, 0x06, 0x5b, 0x7e, 0xc9, + 0x57, 0x4d, 0x90, 0x27, 0x65, 0xeb, 0x21, 0x32, 0x8a, 0x42, 0x82, 0xf4, 0x97, 0x12, 0xdc, 0xed, + 0x12, 0xff, 0xa9, 0x87, 0xe9, 0x33, 0x7e, 0xd3, 0x17, 0x2a, 0x2a, 0xea, 0x53, 0xbe, 0xf5, 0xfa, + 0x54, 0x72, 0xf5, 0xd1, 0x15, 0x58, 0x99, 0x8e, 0x4c, 0x04, 0xbd, 0x01, 0x77, 0xba, 0xc4, 0xdf, + 0x42, 0x57, 0xf5, 0x80, 0xe0, 0x2b, 0xe7, 0xf9, 0x56, 0xa0, 0x99, 0xb7, 0x12, 0x6c, 0xbf, 0x48, + 0x50, 0xef, 0x12, 0xdf, 0x1a, 0x1f, 0x5d, 0xc6, 0xf5, 0xbf, 0x64, 0xef, 0x8c, 0x8f, 0x26, 0xd9, + 0xb3, 0x85, 0xbe, 0x04, 0x8b, 0x22, 0x28, 0x11, 0xea, 0xef, 0x55, 0x78, 0xbb, 0x4b, 0xfc, 0x27, + 0x31, 0xb2, 0x29, 0xda, 0xe4, 0x6a, 0xcb, 0x75, 0xbc, 0x74, 0x55, 0xc7, 0x97, 0xa7, 0x3b, 0xfe, + 0x6b, 0x00, 0x42, 0xed, 0x98, 0xf6, 0x13, 0x6d, 0x31, 0xb7, 0x8d, 0x8e, 0x6a, 0x70, 0xe1, 0x19, + 0x99, 0xf0, 0x8c, 0xe7, 0x99, 0xf0, 0xac, 0x77, 0xd3, 0x26, 0x5b, 0x4c, 0x9b, 0x4c, 0xd8, 0xea, + 0x2f, 0x5e, 0xb7, 0xa4, 0x5e, 0x9d, 0x6d, 0x24, 0x70, 0xf9, 0x27, 0x09, 0x1a, 0xfc, 0xb8, 0xa0, + 0xa4, 0x9e, 0xa6, 0xd4, 0x72, 0x9e, 0x9a, 0xd9, 0xea, 0x37, 0x29, 0x25, 0xcf, 0x67, 0x97, 0xd5, + 0xf3, 0x53, 0x58, 0xc8, 0x66, 0x0a, 0x13, 0x5c, 0xe2, 0xff, 0x7c, 0x6e, 0x5b, 0x29, 0xc0, 0x9a, + 0x7b, 0x99, 0x64, 0x20, 0x0c, 0xe4, 0x1f, 0x25, 0x68, 0xe2, 0xd0, 0x8d, 0x51, 0x80, 0x42, 0xda, + 0x1f, 0xa1, 0xd8, 0x45, 0x21, 0xb5, 0x7d, 0xa4, 0xd4, 0x92, 0x12, 0x5a, 0xdd, 0x24, 0xdc, 0xbf, + 0x4e, 0x5a, 0x1f, 0x14, 0x08, 0x6c, 0x0b, 0xb9, 0x6f, 0x4e, 0x5a, 0xf7, 0x78, 0x62, 0x97, 0x71, + 0xea, 0xbd, 0x25, 0xb1, 0xbd, 0x2b, 0x76, 0xe5, 0x5d, 0x90, 0x0f, 0x06, 0x98, 0xa2, 0x64, 0xf2, + 0xf6, 0x6d, 0xd7, 0x8d, 0xc6, 0x21, 0x25, 0xca, 0xfc, 0x5a, 0xa5, 0x5d, 0xb7, 0xde, 0x4b, 0xcb, + 0xb5, 0xca, 0x59, 0x2f, 0xe2, 0xf4, 0xde, 0xa2, 0xd8, 0xdc, 0x4c, 0xf7, 0x2e, 0x4c, 0x9a, 0x85, + 0x5b, 0x9d, 0x34, 0x13, 0xf9, 0xd5, 0xf3, 0xf2, 0x73, 0x40, 0x39, 0xdf, 0xba, 0x59, 0x5f, 0xcb, + 0xdb, 0x30, 0x9f, 0xbe, 0x1d, 0xac, 0x87, 0x1b, 0x9d, 0x87, 0xd7, 0xc7, 0x96, 0xda, 0x67, 0x73, + 0x21, 0x33, 0xd6, 0xbf, 0xe5, 0xf2, 0xb0, 0x43, 0x17, 0x0d, 0x33, 0x79, 0x6c, 0x00, 0xa4, 0xc7, + 0x99, 0x44, 0xe6, 0xac, 0xe5, 0x49, 0x33, 0x4f, 0xce, 0xf4, 0x5e, 0x3d, 0x5d, 0xec, 0x5c, 0x35, + 0x42, 0x54, 0x9e, 0x43, 0x9e, 0x5f, 0x68, 0xf3, 0x0f, 0x09, 0x1a, 0x5d, 0xe2, 0xef, 0x26, 0x81, + 0x5a, 0xd8, 0xfb, 0x8f, 0x7e, 0x1d, 0xa8, 0xd9, 0x41, 0x72, 0x6b, 0xb7, 0x30, 0x6f, 0x52, 0x66, + 0x79, 0x05, 0x6a, 0x0e, 0xf6, 0x3c, 0x31, 0x71, 0xd2, 0x95, 0xbe, 0x0c, 0x4b, 0xb9, 0x04, 0xb2, + 0xc4, 0x3a, 0x3f, 0xd7, 0xa0, 0xd2, 0x25, 0xbe, 0x8c, 0x60, 0x3e, 0x1b, 0xb8, 0xed, 0xeb, 0xaf, + 0x67, 0xf2, 0xce, 0xa8, 0x1f, 0x15, 0x45, 0x8a, 0x5e, 0xf8, 0x1e, 0x1a, 0xf9, 0xd7, 0xe8, 0xe1, + 0x4c, 0x82, 0x1c, 0x5a, 0xdd, 0xb8, 0x09, 0x5a, 0xb8, 0xdc, 0x87, 0xfa, 0xe4, 0x31, 0x79, 0x30, + 0x93, 0x42, 0x60, 0xd5, 0x4e, 0x71, 0xac, 0x70, 0xe6, 0x40, 0x2d, 0x7d, 0x6a, 0xee, 0xcf, 0xb4, + 0xe6, 0x40, 0xd5, 0x2c, 0x08, 0x14, 0x3e, 0x0e, 0xe0, 0xad, 0xe9, 0x37, 0xc2, 0x98, 0xc9, 0x30, + 0x85, 0x57, 0x3f, 0xbe, 0x19, 0x7e, 0xca, 0xf1, 0x94, 0xfa, 0x0a, 0x38, 0xce, 0xe3, 0x8b, 0x38, + 0xbe, 0x4c, 0x7d, 0xf2, 0x00, 0x16, 0x84, 0xf2, 0x3e, 0x9c, 0xc9, 0x91, 0x41, 0xd5, 0xf5, 0xc2, + 0xd0, 0xcc, 0x93, 0xf5, 0xc5, 0xf1, 0x3f, 0x5a, 0xe9, 0xf8, 0x54, 0x93, 0x5e, 0x9d, 0x6a, 0xd2, + 0xdf, 0xa7, 0x9a, 0xf4, 0xe2, 0x4c, 0x2b, 0xbd, 0x3a, 0xd3, 0x4a, 0x7f, 0x9e, 0x69, 0xa5, 0x6f, + 0x1e, 0xe7, 0xc4, 0x98, 0x51, 0x9b, 0xd9, 0x47, 0xf3, 0x60, 0xec, 0x98, 0xd3, 0x5f, 0xce, 0x4c, + 0x9d, 0x4e, 0x8d, 0xbd, 0x4b, 0x8f, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x23, 0x14, 0x66, 0xc5, + 0xef, 0x0b, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + ListNFT(ctx context.Context, in *MsgListNFT, opts ...grpc.CallOption) (*MsgListNFTResponse, error) + EditListing(ctx context.Context, in *MsgEditListing, opts ...grpc.CallOption) (*MsgEditListingResponse, error) + DeListNFT(ctx context.Context, in *MsgDeListNFT, opts ...grpc.CallOption) (*MsgDeListNFTResponse, error) + BuyNFT(ctx context.Context, in *MsgBuyNFT, opts ...grpc.CallOption) (*MsgBuyNFTResponse, error) + CreateAuction(ctx context.Context, in *MsgCreateAuction, opts ...grpc.CallOption) (*MsgCreateAuctionResponse, error) + CancelAuction(ctx context.Context, in *MsgCancelAuction, opts ...grpc.CallOption) (*MsgCancelAuctionResponse, error) + PlaceBid(ctx context.Context, in *MsgPlaceBid, opts ...grpc.CallOption) (*MsgPlaceBidResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) ListNFT(ctx context.Context, in *MsgListNFT, opts ...grpc.CallOption) (*MsgListNFTResponse, error) { + out := new(MsgListNFTResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/ListNFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) EditListing(ctx context.Context, in *MsgEditListing, opts ...grpc.CallOption) (*MsgEditListingResponse, error) { + out := new(MsgEditListingResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/EditListing", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeListNFT(ctx context.Context, in *MsgDeListNFT, opts ...grpc.CallOption) (*MsgDeListNFTResponse, error) { + out := new(MsgDeListNFTResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/DeListNFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) BuyNFT(ctx context.Context, in *MsgBuyNFT, opts ...grpc.CallOption) (*MsgBuyNFTResponse, error) { + out := new(MsgBuyNFTResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/BuyNFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreateAuction(ctx context.Context, in *MsgCreateAuction, opts ...grpc.CallOption) (*MsgCreateAuctionResponse, error) { + out := new(MsgCreateAuctionResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/CreateAuction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CancelAuction(ctx context.Context, in *MsgCancelAuction, opts ...grpc.CallOption) (*MsgCancelAuctionResponse, error) { + out := new(MsgCancelAuctionResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/CancelAuction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PlaceBid(ctx context.Context, in *MsgPlaceBid, opts ...grpc.CallOption) (*MsgPlaceBidResponse, error) { + out := new(MsgPlaceBidResponse) + err := c.cc.Invoke(ctx, "/OmniFlix.marketplace.v1beta1.Msg/PlaceBid", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + ListNFT(context.Context, *MsgListNFT) (*MsgListNFTResponse, error) + EditListing(context.Context, *MsgEditListing) (*MsgEditListingResponse, error) + DeListNFT(context.Context, *MsgDeListNFT) (*MsgDeListNFTResponse, error) + BuyNFT(context.Context, *MsgBuyNFT) (*MsgBuyNFTResponse, error) + CreateAuction(context.Context, *MsgCreateAuction) (*MsgCreateAuctionResponse, error) + CancelAuction(context.Context, *MsgCancelAuction) (*MsgCancelAuctionResponse, error) + PlaceBid(context.Context, *MsgPlaceBid) (*MsgPlaceBidResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) ListNFT(ctx context.Context, req *MsgListNFT) (*MsgListNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListNFT not implemented") +} +func (*UnimplementedMsgServer) EditListing(ctx context.Context, req *MsgEditListing) (*MsgEditListingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditListing not implemented") +} +func (*UnimplementedMsgServer) DeListNFT(ctx context.Context, req *MsgDeListNFT) (*MsgDeListNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeListNFT not implemented") +} +func (*UnimplementedMsgServer) BuyNFT(ctx context.Context, req *MsgBuyNFT) (*MsgBuyNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BuyNFT not implemented") +} +func (*UnimplementedMsgServer) CreateAuction(ctx context.Context, req *MsgCreateAuction) (*MsgCreateAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateAuction not implemented") +} +func (*UnimplementedMsgServer) CancelAuction(ctx context.Context, req *MsgCancelAuction) (*MsgCancelAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CancelAuction not implemented") +} +func (*UnimplementedMsgServer) PlaceBid(ctx context.Context, req *MsgPlaceBid) (*MsgPlaceBidResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PlaceBid not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_ListNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgListNFT) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ListNFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/ListNFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ListNFT(ctx, req.(*MsgListNFT)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_EditListing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditListing) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EditListing(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/EditListing", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditListing(ctx, req.(*MsgEditListing)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeListNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeListNFT) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeListNFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/DeListNFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeListNFT(ctx, req.(*MsgDeListNFT)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_BuyNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBuyNFT) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).BuyNFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/BuyNFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).BuyNFT(ctx, req.(*MsgBuyNFT)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreateAuction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateAuction) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateAuction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/CreateAuction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateAuction(ctx, req.(*MsgCreateAuction)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CancelAuction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCancelAuction) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CancelAuction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/CancelAuction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CancelAuction(ctx, req.(*MsgCancelAuction)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PlaceBid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPlaceBid) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PlaceBid(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/OmniFlix.marketplace.v1beta1.Msg/PlaceBid", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PlaceBid(ctx, req.(*MsgPlaceBid)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "OmniFlix.marketplace.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListNFT", + Handler: _Msg_ListNFT_Handler, + }, + { + MethodName: "EditListing", + Handler: _Msg_EditListing_Handler, + }, + { + MethodName: "DeListNFT", + Handler: _Msg_DeListNFT_Handler, + }, + { + MethodName: "BuyNFT", + Handler: _Msg_BuyNFT_Handler, + }, + { + MethodName: "CreateAuction", + Handler: _Msg_CreateAuction_Handler, + }, + { + MethodName: "CancelAuction", + Handler: _Msg_CancelAuction_Handler, + }, + { + MethodName: "PlaceBid", + Handler: _Msg_PlaceBid_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "omniflix/marketplace/v1beta1/tx.proto", +} + +func (m *MsgListNFT) 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 *MsgListNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgListNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SplitShares) > 0 { + for iNdEx := len(m.SplitShares) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SplitShares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.Price.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x1a + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintTx(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgListNFTResponse) 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 *MsgListNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgListNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgEditListing) 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 *MsgEditListing) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditListing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Price.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgEditListingResponse) 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 *MsgEditListingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditListingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeListNFT) 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 *MsgDeListNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeListNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeListNFTResponse) 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 *MsgDeListNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeListNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBuyNFT) 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 *MsgBuyNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBuyNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Buyer) > 0 { + i -= len(m.Buyer) + copy(dAtA[i:], m.Buyer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Buyer))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Price.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBuyNFTResponse) 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 *MsgBuyNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBuyNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateAuction) 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 *MsgCreateAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x4a + } + if len(m.SplitShares) > 0 { + for iNdEx := len(m.SplitShares) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SplitShares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.WhitelistAccounts) > 0 { + for iNdEx := len(m.WhitelistAccounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.WhitelistAccounts[iNdEx]) + copy(dAtA[i:], m.WhitelistAccounts[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.WhitelistAccounts[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + { + size := m.IncrementPercentage.Size() + i -= size + if _, err := m.IncrementPercentage.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.Duration != nil { + n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.Duration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Duration):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintTx(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.StartPrice.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintTx(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0x1a + if len(m.DenomId) > 0 { + i -= len(m.DenomId) + copy(dAtA[i:], m.DenomId) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenomId))) + i-- + dAtA[i] = 0x12 + } + if len(m.NftId) > 0 { + i -= len(m.NftId) + copy(dAtA[i:], m.NftId) + i = encodeVarintTx(dAtA, i, uint64(len(m.NftId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateAuctionResponse) 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 *MsgCreateAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Auction != nil { + { + size, err := m.Auction.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCancelAuction) 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 *MsgCancelAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if m.AuctionId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgCancelAuctionResponse) 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 *MsgCancelAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPlaceBid) 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 *MsgPlaceBid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintTx(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.AuctionId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgPlaceBidResponse) 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 *MsgPlaceBidResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceBidResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgListNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.SplitShares) > 0 { + for _, e := range m.SplitShares { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgListNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgEditListing) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgEditListingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeListNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDeListNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgBuyNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Buyer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgBuyNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NftId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DenomId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovTx(uint64(l)) + l = m.StartPrice.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Duration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.Duration) + n += 1 + l + sovTx(uint64(l)) + } + l = m.IncrementPercentage.Size() + n += 1 + l + sovTx(uint64(l)) + if len(m.WhitelistAccounts) > 0 { + for _, s := range m.WhitelistAccounts { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.SplitShares) > 0 { + for _, e := range m.SplitShares { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Auction != nil { + l = m.Auction.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCancelAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AuctionId != 0 { + n += 1 + sovTx(uint64(m.AuctionId)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCancelAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPlaceBid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AuctionId != 0 { + n += 1 + sovTx(uint64(m.AuctionId)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPlaceBidResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgListNFT) 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 ErrIntOverflowTx + } + 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: MsgListNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgListNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SplitShares", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SplitShares = append(m.SplitShares, WeightedAddress{}) + if err := m.SplitShares[len(m.SplitShares)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgListNFTResponse) 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 ErrIntOverflowTx + } + 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: MsgListNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgListNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditListing) 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 ErrIntOverflowTx + } + 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: MsgEditListing: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditListing: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditListingResponse) 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 ErrIntOverflowTx + } + 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: MsgEditListingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditListingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeListNFT) 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 ErrIntOverflowTx + } + 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: MsgDeListNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeListNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeListNFTResponse) 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 ErrIntOverflowTx + } + 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: MsgDeListNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeListNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBuyNFT) 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 ErrIntOverflowTx + } + 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: MsgBuyNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBuyNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Buyer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Buyer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBuyNFTResponse) 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 ErrIntOverflowTx + } + 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: MsgBuyNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBuyNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateAuction) 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 ErrIntOverflowTx + } + 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: MsgCreateAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NftId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NftId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartPrice", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StartPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Duration == nil { + m.Duration = new(time.Duration) + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.Duration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncrementPercentage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.IncrementPercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistAccounts", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistAccounts = append(m.WhitelistAccounts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SplitShares", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SplitShares = append(m.SplitShares, WeightedAddress{}) + if err := m.SplitShares[len(m.SplitShares)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateAuctionResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Auction", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Auction == nil { + m.Auction = &AuctionListing{} + } + if err := m.Auction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCancelAuction) 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 ErrIntOverflowTx + } + 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: MsgCancelAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCancelAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCancelAuctionResponse) 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 ErrIntOverflowTx + } + 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: MsgCancelAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCancelAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPlaceBid) 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 ErrIntOverflowTx + } + 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: MsgPlaceBid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceBid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPlaceBidResponse) 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 ErrIntOverflowTx + } + 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: MsgPlaceBidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceBidResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/marketplace/types/utils.go b/x/marketplace/types/utils.go new file mode 100644 index 00000000..0a702e5a --- /dev/null +++ b/x/marketplace/types/utils.go @@ -0,0 +1,27 @@ +package types + +import ( + "regexp" + "strings" + + "github.com/google/uuid" +) + +var ( + IsAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString + IsBeginWithAlpha = regexp.MustCompile(`^[a-zA-Z].*`).MatchString + IsAlpha = regexp.MustCompile(`^[a-zA-Z]+`).MatchString +) + +func GenUniqueID(prefix string) string { + return prefix + strings.ReplaceAll(uuid.New().String(), "-", "") +} + +func StringInSlice(a string, list []string) bool { + for _, b := range list { + if b == a { + return true + } + } + return false +} diff --git a/x/marketplace/types/validation.go b/x/marketplace/types/validation.go new file mode 100644 index 00000000..86aaa7a8 --- /dev/null +++ b/x/marketplace/types/validation.go @@ -0,0 +1,148 @@ +package types + +import ( + "strings" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// ValidateListing checks listing is valid or not +func ValidateListing(listing Listing) error { + if len(listing.Owner) > 0 { + if _, err := sdk.AccAddressFromBech32(listing.Owner); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + } + if err := ValidateId(listing.Id); err != nil { + return err + } + if err := ValidatePrice(listing.Price); err != nil { + return err + } + if err := ValidateSplitShares(listing.SplitShares); err != nil { + return err + } + return nil +} + +// ValidatePrice +func ValidatePrice(price sdk.Coin) error { + if price.IsZero() || price.IsNegative() { + return sdkerrors.Wrapf(ErrInvalidPrice, "invalid price %s, only accepts positive amount", price.String()) + } + return nil +} + +func ValidateDuration(t interface{}) error { + duration, ok := t.(*time.Duration) + if !ok { + return sdkerrors.Wrapf(ErrInvalidDuration, "invalid value for duration: %T", t) + } + if duration.Nanoseconds() <= 0 { + return sdkerrors.Wrapf(ErrInvalidDuration, "invalid duration %s, only accepts positive value", duration.String()) + } + return nil +} + +func ValidateId(id string) error { + id = strings.TrimSpace(id) + if len(id) < MinListingIdLength || len(id) > MaxListingIdLength { + return sdkerrors.Wrapf( + ErrInvalidListingId, + "invalid id %s, only accepts value [%d, %d]", id, MinListingIdLength, MaxListingIdLength, + ) + } + if !IsBeginWithAlpha(id) || !IsAlphaNumeric(id) { + return sdkerrors.Wrapf(ErrInvalidListingId, "invalid id %s, only accepts alphanumeric characters,and begin with an english letter", id) + } + return nil +} + +func ValidateSplitShares(splitShares []WeightedAddress) error { + if len(splitShares) > MaxSplits { + return sdkerrors.Wrapf(ErrInvalidSplits, "number of splits are more than the limit, len must be less than or equal to %d ", MaxSplits) + } + totalWeight := sdk.NewDec(0) + for _, share := range splitShares { + _, err := sdk.AccAddressFromBech32(share.Address) + if err != nil { + return err + } + totalWeight = totalWeight.Add(share.Weight) + } + if !totalWeight.LTE(sdk.OneDec()) { + return sdkerrors.Wrapf(ErrInvalidSplits, "invalid weights, total sum of weights must be less than %d", 1) + } + return nil +} + +func ValidateWhiteListAccounts(whitelistAccounts []string) error { + if len(whitelistAccounts) > MaxWhitelistAccounts { + return sdkerrors.Wrapf(ErrInvalidWhitelistAccounts, + "number of whitelist accounts are more than the limit, len must be less than or equal to %d ", MaxWhitelistAccounts) + } + for _, address := range whitelistAccounts { + _, err := sdk.AccAddressFromBech32(address) + if err != nil { + return err + } + } + return nil +} + +func validateIncrementPercentage(increment sdk.Dec) error { + if !increment.IsPositive() || !increment.LTE(sdk.NewDec(1)) { + return sdkerrors.Wrapf(ErrInvalidPercentage, "invalid percentage value (%s)", increment.String()) + } + return nil +} + +func validateAuctionId(id uint64) error { + if id <= 0 { + return sdkerrors.Wrapf(ErrInvalidAuctionId, "invalid auction id (%d)", id) + } + return nil +} + +// ValidateAuctionListing checks auction listing is valid or not +func ValidateAuctionListing(auction AuctionListing) error { + if len(auction.Owner) > 0 { + if _, err := sdk.AccAddressFromBech32(auction.Owner); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + } + if err := validateAuctionId(auction.Id); err != nil { + return err + } + if err := ValidatePrice(auction.StartPrice); err != nil { + return err + } + if err := validateIncrementPercentage(auction.IncrementPercentage); err != nil { + return err + } + if err := ValidateSplitShares(auction.SplitShares); err != nil { + return err + } + if err := ValidateWhiteListAccounts(auction.WhitelistAccounts); err != nil { + return err + } + return nil +} + +// ValidateBid checks bid is valid or not +func ValidateBid(bid Bid) error { + if len(bid.Bidder) > 0 { + if _, err := sdk.AccAddressFromBech32(bid.Bidder); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid bidder address (%s)", bid.Bidder) + } + } + if err := ValidatePrice(bid.Amount); err != nil { + return err + } + if bid.Time.IsZero() { + return sdkerrors.Wrapf(ErrInvalidTime, "invalid time (%s)", bid.Time.String()) + } + return nil +} From 3d46f5eb665c4fceb635a9e0b5268034497d8757 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Thu, 3 Aug 2023 16:37:17 +0530 Subject: [PATCH 5/7] itc patch updates (#78) * remove max claims check * add claim count to campaign * add upgrade handler for itc-patch * fix: end fully claimed campaigns * Revert "add upgrade handler for itc-patch" This reverts commit 2eced935506f5cf4d31fd6a861f40d92193c25da. --- proto/omniflix/itc/v1/itc.proto | 3 + x/itc/keeper/campaign.go | 5 +- x/itc/keeper/itc.go | 3 + x/itc/types/itc.pb.go | 181 +++++++++++++++++++------------- 4 files changed, 114 insertions(+), 78 deletions(-) diff --git a/proto/omniflix/itc/v1/itc.proto b/proto/omniflix/itc/v1/itc.proto index cc52761a..bcf2338e 100644 --- a/proto/omniflix/itc/v1/itc.proto +++ b/proto/omniflix/itc/v1/itc.proto @@ -57,6 +57,9 @@ message Campaign { uint64 mint_count = 17 [ (gogoproto.moretags) = "yaml:\"mint_count\"" ]; + uint64 claim_count = 18 [ + (gogoproto.moretags) = "yaml:\"claim_count\"" + ]; } message Distribution { diff --git a/x/itc/keeper/campaign.go b/x/itc/keeper/campaign.go index a8eba357..048582bc 100644 --- a/x/itc/keeper/campaign.go +++ b/x/itc/keeper/campaign.go @@ -119,8 +119,7 @@ func (k Keeper) Claim(ctx sdk.Context, campaign types.Campaign, claimer sdk.AccA return sdkerrors.Wrapf(types.ErrClaimExists, "claim exists with given nft %s", nft.GetID()) } - claims := k.GetClaims(ctx, campaign.GetId()) - if uint64(len(claims)) >= campaign.MaxAllowedClaims { + if (campaign.MaxAllowedClaims - campaign.ClaimCount) <= 0 { return sdkerrors.Wrapf(types.ErrClaimNotAllowed, "max allowed claims reached for this campaign (campaign: %d, maxAllowedClaims: %d).", campaign.GetId(), @@ -216,10 +215,10 @@ func (k Keeper) Claim(ctx sdk.Context, campaign types.Campaign, claimer sdk.AccA } } // set claim - k.SetClaim(ctx, claim) // set campaign + campaign.ClaimCount += 1 k.SetCampaign(ctx, campaign) // emit events diff --git a/x/itc/keeper/itc.go b/x/itc/keeper/itc.go index 940b20d6..3b0b0fc9 100644 --- a/x/itc/keeper/itc.go +++ b/x/itc/keeper/itc.go @@ -167,6 +167,9 @@ func (k Keeper) FinalizeAndEndCampaigns(ctx sdk.Context) error { if campaign.EndTime.Before(ctx.BlockTime()) { // finalize campaign after endtime k.endCampaign(ctx, campaign) + } else if campaign.ClaimCount == campaign.MaxAllowedClaims { + // finalize campaign after reaching max allowed claims + k.endCampaign(ctx, campaign) } } return nil diff --git a/x/itc/types/itc.pb.go b/x/itc/types/itc.pb.go index 8f1cf039..30dc1694 100644 --- a/x/itc/types/itc.pb.go +++ b/x/itc/types/itc.pb.go @@ -157,6 +157,7 @@ type Campaign struct { NftMintDetails *NFTDetails `protobuf:"bytes,15,opt,name=nft_mint_details,json=nftMintDetails,proto3" json:"nft_mint_details,omitempty" yaml:"nft_mint_details"` Distribution *Distribution `protobuf:"bytes,16,opt,name=distribution,proto3" json:"distribution,omitempty" yaml:"distribution"` MintCount uint64 `protobuf:"varint,17,opt,name=mint_count,json=mintCount,proto3" json:"mint_count,omitempty" yaml:"mint_count"` + ClaimCount uint64 `protobuf:"varint,18,opt,name=claim_count,json=claimCount,proto3" json:"claim_count,omitempty" yaml:"claim_count"` } func (m *Campaign) Reset() { *m = Campaign{} } @@ -330,81 +331,82 @@ func init() { func init() { proto.RegisterFile("omniflix/itc/v1/itc.proto", fileDescriptor_b99fa199354013a9) } var fileDescriptor_b99fa199354013a9 = []byte{ - // 1176 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x16, 0x15, 0x3b, 0x91, 0x46, 0x8a, 0xcc, 0x6c, 0x92, 0x86, 0xb6, 0x6b, 0x49, 0xe5, 0xa1, - 0x30, 0x5c, 0x94, 0x82, 0xd3, 0xf6, 0x90, 0xde, 0xf4, 0xdb, 0x12, 0x8d, 0x69, 0x63, 0x45, 0x17, - 0x4d, 0x2e, 0xc4, 0x8a, 0x5c, 0x39, 0x0b, 0x8b, 0xa4, 0x40, 0xae, 0x1c, 0xfb, 0xde, 0x07, 0x08, - 0xd0, 0x4b, 0x2f, 0x7d, 0x9f, 0x1c, 0x73, 0x2c, 0x7a, 0x70, 0x9b, 0xe4, 0x0d, 0x8c, 0x3e, 0x40, - 0xb1, 0xbb, 0xa4, 0x25, 0x4b, 0x45, 0x83, 0xe6, 0xa4, 0x9d, 0xbf, 0x6f, 0x86, 0xc3, 0x8f, 0xdf, - 0x0a, 0x36, 0xe3, 0x30, 0x62, 0xe3, 0x09, 0x3b, 0x6f, 0x31, 0xee, 0xb7, 0xce, 0xf6, 0xc5, 0x8f, - 0x35, 0x4d, 0x62, 0x1e, 0xa3, 0x8d, 0xc3, 0x30, 0x62, 0x83, 0x09, 0x3b, 0xb7, 0x84, 0xef, 0x6c, - 0x7f, 0xab, 0xee, 0xc7, 0x69, 0x18, 0xa7, 0xad, 0x11, 0x49, 0x69, 0xeb, 0x6c, 0x7f, 0x44, 0x39, - 0xd9, 0x6f, 0xf9, 0x31, 0x8b, 0x54, 0xc1, 0xd6, 0x83, 0x93, 0xf8, 0x24, 0x96, 0xc7, 0x96, 0x38, - 0x65, 0xde, 0xc6, 0x49, 0x1c, 0x9f, 0x4c, 0x68, 0x4b, 0x5a, 0xa3, 0xd9, 0xb8, 0xc5, 0x59, 0x48, - 0x53, 0x4e, 0xc2, 0x69, 0x96, 0x50, 0x5f, 0x4e, 0x08, 0x66, 0x09, 0xe1, 0x2c, 0xce, 0x60, 0xcd, - 0x9f, 0xcb, 0x50, 0xea, 0x92, 0x70, 0x4a, 0xd8, 0x49, 0x84, 0x6a, 0x50, 0x64, 0x81, 0xa1, 0x35, - 0xb5, 0xdd, 0x35, 0x5c, 0x64, 0x01, 0x42, 0xb0, 0x16, 0x91, 0x90, 0x1a, 0xc5, 0xa6, 0xb6, 0x5b, - 0xc6, 0xf2, 0x8c, 0x9a, 0x50, 0x09, 0x68, 0xea, 0x27, 0x6c, 0x2a, 0x50, 0x8c, 0x5b, 0x32, 0xb4, - 0xe8, 0x42, 0x3f, 0x01, 0xa4, 0x9c, 0x24, 0xdc, 0x13, 0xb3, 0x18, 0x6b, 0x4d, 0x6d, 0xb7, 0xf2, - 0x78, 0xcb, 0x52, 0x73, 0x58, 0xf9, 0x1c, 0x96, 0x9b, 0x0f, 0xda, 0xd9, 0x79, 0x7d, 0xd9, 0x28, - 0x5c, 0x5d, 0x36, 0xee, 0x5d, 0x90, 0x70, 0xf2, 0xad, 0x39, 0xaf, 0x35, 0x5f, 0xfd, 0xd9, 0xd0, - 0x70, 0x59, 0x3a, 0x44, 0x3a, 0xc2, 0x50, 0xa2, 0x51, 0xa0, 0x70, 0xd7, 0x3f, 0x88, 0xbb, 0x9d, - 0xe1, 0x6e, 0x28, 0xdc, 0xbc, 0x52, 0xa1, 0xde, 0xa1, 0x51, 0x20, 0x31, 0x0d, 0xb8, 0xe3, 0x27, - 0x94, 0xf0, 0x38, 0x31, 0x6e, 0xcb, 0x67, 0xc9, 0x4d, 0xf4, 0x04, 0xaa, 0xd1, 0x98, 0x7b, 0x01, - 0x8d, 0xe2, 0xd0, 0x63, 0x81, 0x71, 0x47, 0x84, 0x3b, 0x8f, 0xae, 0x2e, 0x1b, 0xf7, 0x15, 0xe2, - 0x62, 0xd4, 0xc4, 0x10, 0x8d, 0x79, 0x4f, 0x58, 0x76, 0x80, 0x7e, 0x00, 0x14, 0x92, 0x73, 0x8f, - 0x4c, 0x26, 0xf1, 0x4b, 0x1a, 0x78, 0xfe, 0x84, 0xb0, 0x30, 0x35, 0x4a, 0x62, 0xb1, 0x9d, 0x9d, - 0xab, 0xcb, 0xc6, 0xa6, 0x02, 0x58, 0xcd, 0x31, 0xb1, 0x1e, 0x92, 0xf3, 0xb6, 0xf2, 0x75, 0xa5, - 0x0b, 0x75, 0xa0, 0xc2, 0x22, 0x4e, 0x13, 0xe2, 0xcb, 0x8d, 0x97, 0x9b, 0xda, 0x6e, 0xed, 0x71, - 0xd3, 0x5a, 0x22, 0x90, 0x65, 0xcf, 0x73, 0xdc, 0x8b, 0x29, 0xc5, 0x8b, 0x45, 0xe8, 0x09, 0x80, - 0x6c, 0xe0, 0xf1, 0x8b, 0x29, 0x35, 0x40, 0x42, 0x6c, 0xad, 0x40, 0xc8, 0x86, 0xb2, 0xb8, 0xec, - 0xe7, 0x47, 0x14, 0x80, 0xce, 0xe3, 0x53, 0x1a, 0xa5, 0xde, 0x94, 0x26, 0x6a, 0x4c, 0xa3, 0x22, - 0x97, 0xbf, 0x69, 0x29, 0xce, 0x5a, 0x82, 0xb3, 0x56, 0xc6, 0x59, 0xab, 0x1b, 0xb3, 0xa8, 0xd3, - 0xc8, 0x76, 0xff, 0x48, 0x3d, 0xe8, 0x32, 0x80, 0x89, 0x6b, 0xca, 0x75, 0x44, 0x13, 0xd9, 0x14, - 0x3d, 0x83, 0x2a, 0x8f, 0x39, 0x99, 0x78, 0xca, 0x6f, 0x54, 0x3f, 0xd4, 0x21, 0x7f, 0xbb, 0xf7, - 0xf3, 0x0e, 0xf3, 0x62, 0x13, 0x57, 0xa4, 0xe9, 0x4a, 0x0b, 0x51, 0xd0, 0xc9, 0x19, 0x61, 0x13, - 0x32, 0x9a, 0xd0, 0x1c, 0xfe, 0xee, 0xff, 0x7c, 0x80, 0x65, 0x00, 0x13, 0x6f, 0x5c, 0xbb, 0xb2, - 0x36, 0x7d, 0xd0, 0x13, 0xea, 0x53, 0x76, 0x46, 0x03, 0x4f, 0x30, 0x83, 0x05, 0xa9, 0x51, 0x6b, - 0xde, 0xda, 0x2d, 0x77, 0xb6, 0xe7, 0x38, 0xcb, 0x19, 0x26, 0xae, 0xe5, 0x2e, 0x67, 0xcc, 0xed, - 0x20, 0x45, 0x23, 0xd0, 0x45, 0x2c, 0x64, 0x91, 0x20, 0x17, 0x27, 0x6c, 0x92, 0x1a, 0x1b, 0x72, - 0xda, 0xed, 0x95, 0xf7, 0xe5, 0x0c, 0xdc, 0x9e, 0x4a, 0x59, 0xec, 0xb1, 0x5c, 0x6e, 0xe2, 0x5a, - 0x34, 0xe6, 0x07, 0x2c, 0xe2, 0x59, 0x32, 0x7a, 0x0e, 0xd5, 0x80, 0xa5, 0x3c, 0x61, 0xa3, 0x99, - 0xa4, 0x94, 0x2e, 0xf1, 0x77, 0x56, 0xf0, 0x7b, 0x0b, 0x49, 0x8b, 0xc4, 0x5f, 0x2c, 0x36, 0xf1, - 0x0d, 0x2c, 0xf4, 0x35, 0x80, 0x6c, 0xee, 0xc7, 0xb3, 0x88, 0x1b, 0xf7, 0x24, 0xe5, 0x1f, 0xce, - 0xbf, 0xee, 0x79, 0xcc, 0xc4, 0x65, 0x61, 0x74, 0xe5, 0xf9, 0x17, 0x0d, 0xaa, 0x8b, 0xdd, 0xd0, - 0x37, 0xb0, 0x26, 0xa9, 0xaa, 0x49, 0xaa, 0x7e, 0xf6, 0x9f, 0xa3, 0x49, 0xc6, 0xca, 0x74, 0xf4, - 0x14, 0x36, 0x52, 0x9e, 0x50, 0x12, 0x7a, 0xb9, 0xce, 0x49, 0xf1, 0x12, 0xaf, 0x7a, 0x59, 0x28, - 0x7a, 0x59, 0x42, 0xa7, 0x24, 0x5e, 0xf5, 0xaf, 0x42, 0x14, 0x6a, 0xaa, 0x36, 0x8f, 0x98, 0x7f, - 0x17, 0x01, 0xe6, 0x3b, 0x46, 0x9b, 0x50, 0xba, 0x16, 0x03, 0x4d, 0x69, 0x45, 0x90, 0x7d, 0xf0, - 0x1f, 0xa7, 0x94, 0xdb, 0x50, 0x0e, 0x69, 0xc0, 0x88, 0x37, 0x4b, 0x98, 0x14, 0xca, 0x32, 0x2e, - 0x49, 0xc7, 0x71, 0xc2, 0x50, 0x03, 0x2a, 0xd3, 0x84, 0x9e, 0x31, 0xfa, 0x52, 0x86, 0xd7, 0x65, - 0x18, 0x32, 0x97, 0x48, 0x38, 0x85, 0xbb, 0x49, 0x7c, 0x41, 0x26, 0xfc, 0xc2, 0x4b, 0x5f, 0x90, - 0x84, 0x2a, 0xfd, 0xea, 0x0c, 0xc4, 0xe3, 0xfc, 0x71, 0xd9, 0xf8, 0xfc, 0x84, 0xf1, 0x17, 0xb3, - 0x91, 0xe5, 0xc7, 0x61, 0x2b, 0xbb, 0x5b, 0xd4, 0xcf, 0x97, 0x69, 0x70, 0xda, 0x12, 0xdb, 0x4a, - 0xad, 0x1e, 0xf5, 0xaf, 0x2e, 0x1b, 0x0f, 0x32, 0x6e, 0x2e, 0x82, 0x99, 0xb8, 0x9a, 0xd9, 0x43, - 0x61, 0x22, 0x13, 0xaa, 0x3c, 0x21, 0x51, 0x3a, 0xa6, 0x89, 0xe0, 0xbc, 0x14, 0xc3, 0x12, 0xbe, - 0xe1, 0x43, 0x75, 0x00, 0x7a, 0xce, 0x69, 0x94, 0x32, 0x91, 0x51, 0x92, 0x19, 0x0b, 0x1e, 0xb9, - 0xa4, 0x74, 0xfc, 0x52, 0x2a, 0x58, 0x09, 0xcb, 0xb3, 0xf0, 0x05, 0x84, 0x13, 0x29, 0x49, 0x65, - 0x2c, 0xcf, 0xe6, 0x6f, 0x1a, 0xac, 0x2b, 0x55, 0x68, 0x40, 0xc5, 0xcf, 0x2e, 0x27, 0xef, 0xfa, - 0x66, 0x82, 0xdc, 0x65, 0x07, 0x42, 0xbd, 0x49, 0x10, 0x24, 0x34, 0x4d, 0xb3, 0xd5, 0xe7, 0x26, - 0x7a, 0x08, 0xb7, 0xd5, 0x37, 0x96, 0x2d, 0x7e, 0x3d, 0x12, 0xdf, 0xd7, 0xb2, 0x98, 0xae, 0x7d, - 0x84, 0x98, 0xee, 0x1d, 0x82, 0xbe, 0x4c, 0x3f, 0xb4, 0x03, 0x9b, 0x3d, 0x7b, 0xe8, 0x62, 0xbb, - 0x73, 0xec, 0xda, 0x87, 0x8e, 0xe7, 0x3e, 0x3b, 0xea, 0x7b, 0xb6, 0x33, 0x74, 0xdb, 0x8e, 0xab, - 0x17, 0xd0, 0xa7, 0x60, 0xac, 0x86, 0x87, 0x2e, 0xee, 0xb7, 0x0f, 0x74, 0x6d, 0x6f, 0x0c, 0x1b, - 0x4b, 0x0d, 0xd1, 0x26, 0x3c, 0xb4, 0x1d, 0xb7, 0x8f, 0xdb, 0xdd, 0x79, 0x7e, 0xe7, 0x18, 0x3b, - 0x7a, 0x41, 0xb4, 0x5a, 0x09, 0xb9, 0xb8, 0xed, 0x0c, 0x07, 0x7d, 0xac, 0x6b, 0xff, 0x5a, 0xf9, - 0xfd, 0xe1, 0xd3, 0x9e, 0x5e, 0xdc, 0x3b, 0x85, 0x5a, 0x7e, 0xd7, 0x0f, 0x39, 0xe1, 0xb3, 0x14, - 0x35, 0x60, 0xbb, 0xdb, 0x3e, 0x38, 0x6a, 0xdb, 0xdf, 0x39, 0xde, 0xd0, 0x6d, 0xbb, 0xc7, 0x43, - 0xef, 0xd8, 0x19, 0x1e, 0xf5, 0xbb, 0xf6, 0xc0, 0xee, 0xf7, 0xd4, 0xe0, 0xcb, 0x09, 0xb6, 0x23, - 0xa0, 0x7f, 0xec, 0xeb, 0x1a, 0xda, 0x82, 0x4f, 0x96, 0xa3, 0x59, 0xac, 0xb8, 0x77, 0x00, 0xe5, - 0xeb, 0xfb, 0x04, 0xdd, 0x83, 0xbb, 0xdd, 0xa7, 0x6d, 0xfb, 0x40, 0x8d, 0x33, 0x10, 0x2b, 0x41, - 0x50, 0x5b, 0x70, 0x39, 0x03, 0x57, 0xcd, 0x7e, 0x23, 0xcd, 0x6b, 0x3b, 0x3d, 0x19, 0x2a, 0x76, - 0x0e, 0x5e, 0xbf, 0xad, 0x17, 0xde, 0xbc, 0xad, 0x17, 0x5e, 0xbf, 0xab, 0x6b, 0x6f, 0xde, 0xd5, - 0xb5, 0xbf, 0xde, 0xd5, 0xb5, 0x57, 0xef, 0xeb, 0x85, 0x37, 0xef, 0xeb, 0x85, 0xdf, 0xdf, 0xd7, - 0x0b, 0xcf, 0xbf, 0x58, 0x20, 0x7c, 0xfe, 0x3e, 0x5b, 0xf9, 0x3f, 0xb0, 0x17, 0xb3, 0x51, 0x4b, - 0xfd, 0x0d, 0x93, 0xcc, 0x1f, 0xdd, 0x96, 0x3a, 0xf0, 0xd5, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x10, 0xf7, 0x5b, 0x6d, 0xa3, 0x09, 0x00, 0x00, + // 1199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcb, 0x6e, 0xdb, 0x46, + 0x14, 0x15, 0x15, 0x3b, 0x91, 0xae, 0x14, 0x59, 0x99, 0xbc, 0x68, 0xbb, 0x96, 0x54, 0x2e, 0x0a, + 0xc3, 0x45, 0x29, 0x38, 0x6d, 0x51, 0xa4, 0x3b, 0x3d, 0x5b, 0xa2, 0x31, 0x6d, 0x8c, 0xe8, 0xa2, + 0xc9, 0x86, 0x18, 0x91, 0x23, 0x67, 0x60, 0x91, 0x14, 0xc8, 0x91, 0x63, 0xff, 0x45, 0x80, 0x6e, + 0xba, 0xe9, 0xa7, 0x74, 0x9f, 0x65, 0x96, 0x45, 0x17, 0x6a, 0x93, 0xfc, 0x81, 0xd1, 0x0f, 0x28, + 0x66, 0x86, 0xb4, 0x18, 0xb9, 0x68, 0xd0, 0xac, 0x34, 0xf7, 0x75, 0xee, 0x9d, 0xcb, 0xc3, 0x43, + 0xc1, 0x66, 0x14, 0x84, 0x6c, 0x32, 0x65, 0xe7, 0x6d, 0xc6, 0xbd, 0xf6, 0xd9, 0xbe, 0xf8, 0x31, + 0x67, 0x71, 0xc4, 0x23, 0xb4, 0x71, 0x18, 0x84, 0x6c, 0x38, 0x65, 0xe7, 0xa6, 0xf0, 0x9d, 0xed, + 0x6f, 0x35, 0xbc, 0x28, 0x09, 0xa2, 0xa4, 0x3d, 0x26, 0x09, 0x6d, 0x9f, 0xed, 0x8f, 0x29, 0x27, + 0xfb, 0x6d, 0x2f, 0x62, 0xa1, 0x2a, 0xd8, 0xba, 0x77, 0x12, 0x9d, 0x44, 0xf2, 0xd8, 0x16, 0xa7, + 0xd4, 0xdb, 0x3c, 0x89, 0xa2, 0x93, 0x29, 0x6d, 0x4b, 0x6b, 0x3c, 0x9f, 0xb4, 0x39, 0x0b, 0x68, + 0xc2, 0x49, 0x30, 0x4b, 0x13, 0x1a, 0xab, 0x09, 0xfe, 0x3c, 0x26, 0x9c, 0x45, 0x29, 0xac, 0xf1, + 0x5b, 0x19, 0x4a, 0x3d, 0x12, 0xcc, 0x08, 0x3b, 0x09, 0x51, 0x0d, 0x8a, 0xcc, 0xd7, 0xb5, 0x96, + 0xb6, 0xbb, 0x86, 0x8b, 0xcc, 0x47, 0x08, 0xd6, 0x42, 0x12, 0x50, 0xbd, 0xd8, 0xd2, 0x76, 0xcb, + 0x58, 0x9e, 0x51, 0x0b, 0x2a, 0x3e, 0x4d, 0xbc, 0x98, 0xcd, 0x04, 0x8a, 0x7e, 0x43, 0x86, 0xf2, + 0x2e, 0xf4, 0x13, 0x40, 0xc2, 0x49, 0xcc, 0x5d, 0x31, 0x8b, 0xbe, 0xd6, 0xd2, 0x76, 0x2b, 0x8f, + 0xb6, 0x4c, 0x35, 0x87, 0x99, 0xcd, 0x61, 0x3a, 0xd9, 0xa0, 0xdd, 0x9d, 0x57, 0x8b, 0x66, 0xe1, + 0x72, 0xd1, 0xbc, 0x73, 0x41, 0x82, 0xe9, 0xb7, 0xc6, 0xb2, 0xd6, 0x78, 0xf9, 0x67, 0x53, 0xc3, + 0x65, 0xe9, 0x10, 0xe9, 0x08, 0x43, 0x89, 0x86, 0xbe, 0xc2, 0x5d, 0xff, 0x20, 0xee, 0x76, 0x8a, + 0xbb, 0xa1, 0x70, 0xb3, 0x4a, 0x85, 0x7a, 0x8b, 0x86, 0xbe, 0xc4, 0xd4, 0xe1, 0x96, 0x17, 0x53, + 0xc2, 0xa3, 0x58, 0xbf, 0x29, 0xef, 0x92, 0x99, 0xe8, 0x31, 0x54, 0xc3, 0x09, 0x77, 0x7d, 0x1a, + 0x46, 0x81, 0xcb, 0x7c, 0xfd, 0x96, 0x08, 0x77, 0x1f, 0x5e, 0x2e, 0x9a, 0x77, 0x15, 0x62, 0x3e, + 0x6a, 0x60, 0x08, 0x27, 0xbc, 0x2f, 0x2c, 0xcb, 0x47, 0x3f, 0x00, 0x0a, 0xc8, 0xb9, 0x4b, 0xa6, + 0xd3, 0xe8, 0x05, 0xf5, 0x5d, 0x6f, 0x4a, 0x58, 0x90, 0xe8, 0x25, 0xb1, 0xd8, 0xee, 0xce, 0xe5, + 0xa2, 0xb9, 0xa9, 0x00, 0xae, 0xe7, 0x18, 0xb8, 0x1e, 0x90, 0xf3, 0x8e, 0xf2, 0xf5, 0xa4, 0x0b, + 0x75, 0xa1, 0xc2, 0x42, 0x4e, 0x63, 0xe2, 0xc9, 0x8d, 0x97, 0x5b, 0xda, 0x6e, 0xed, 0x51, 0xcb, + 0x5c, 0x21, 0x90, 0x69, 0x2d, 0x73, 0x9c, 0x8b, 0x19, 0xc5, 0xf9, 0x22, 0xf4, 0x18, 0x40, 0x36, + 0x70, 0xf9, 0xc5, 0x8c, 0xea, 0x20, 0x21, 0xb6, 0xae, 0x41, 0xc8, 0x86, 0xb2, 0xb8, 0xec, 0x65, + 0x47, 0xe4, 0x43, 0x9d, 0x47, 0xa7, 0x34, 0x4c, 0xdc, 0x19, 0x8d, 0xd5, 0x98, 0x7a, 0x45, 0x2e, + 0x7f, 0xd3, 0x54, 0x9c, 0x35, 0x05, 0x67, 0xcd, 0x94, 0xb3, 0x66, 0x2f, 0x62, 0x61, 0xb7, 0x99, + 0xee, 0xfe, 0xa1, 0xba, 0xe8, 0x2a, 0x80, 0x81, 0x6b, 0xca, 0x75, 0x44, 0x63, 0xd9, 0x14, 0x3d, + 0x85, 0x2a, 0x8f, 0x38, 0x99, 0xba, 0xca, 0xaf, 0x57, 0x3f, 0xd4, 0x21, 0x7b, 0xba, 0x77, 0xb3, + 0x0e, 0xcb, 0x62, 0x03, 0x57, 0xa4, 0xe9, 0x48, 0x0b, 0x51, 0xa8, 0x93, 0x33, 0xc2, 0xa6, 0x64, + 0x3c, 0xa5, 0x19, 0xfc, 0xed, 0xff, 0x79, 0x81, 0x55, 0x00, 0x03, 0x6f, 0x5c, 0xb9, 0xd2, 0x36, + 0x03, 0xa8, 0xc7, 0xd4, 0xa3, 0xec, 0x8c, 0xfa, 0xae, 0x60, 0x06, 0xf3, 0x13, 0xbd, 0xd6, 0xba, + 0xb1, 0x5b, 0xee, 0x6e, 0x2f, 0x71, 0x56, 0x33, 0x0c, 0x5c, 0xcb, 0x5c, 0xf6, 0x84, 0x5b, 0x7e, + 0x82, 0xc6, 0x50, 0x17, 0xb1, 0x80, 0x85, 0x82, 0x5c, 0x9c, 0xb0, 0x69, 0xa2, 0x6f, 0xc8, 0x69, + 0xb7, 0xaf, 0x3d, 0x2f, 0x7b, 0xe8, 0xf4, 0x55, 0x4a, 0xbe, 0xc7, 0x6a, 0xb9, 0x81, 0x6b, 0xe1, + 0x84, 0x1f, 0xb0, 0x90, 0xa7, 0xc9, 0xe8, 0x19, 0x54, 0x7d, 0x96, 0xf0, 0x98, 0x8d, 0xe7, 0x92, + 0x52, 0x75, 0x89, 0xbf, 0x73, 0x0d, 0xbf, 0x9f, 0x4b, 0xca, 0x13, 0x3f, 0x5f, 0x6c, 0xe0, 0xf7, + 0xb0, 0xd0, 0x57, 0x00, 0xb2, 0xb9, 0x17, 0xcd, 0x43, 0xae, 0xdf, 0x91, 0x94, 0xbf, 0xbf, 0x7c, + 0xbb, 0x97, 0x31, 0x03, 0x97, 0x85, 0xd1, 0x13, 0x67, 0xf4, 0x0d, 0x54, 0x14, 0x3f, 0x55, 0x19, + 0x92, 0x65, 0x0f, 0x2e, 0x17, 0x4d, 0xa4, 0xca, 0x72, 0x41, 0x03, 0x2b, 0x2a, 0xcb, 0x42, 0xe3, + 0x67, 0x0d, 0xaa, 0xf9, 0x31, 0xd1, 0xd7, 0xb0, 0x26, 0x39, 0xae, 0x49, 0x8e, 0x7f, 0xfa, 0x9f, + 0x77, 0x92, 0x54, 0x97, 0xe9, 0xe8, 0x09, 0x6c, 0x24, 0x3c, 0xa6, 0x24, 0x70, 0x33, 0x81, 0x94, + 0xaa, 0x27, 0x38, 0xb2, 0xaa, 0x30, 0xfd, 0x34, 0xa1, 0x5b, 0x12, 0x1c, 0xf9, 0x45, 0xa8, 0x49, + 0x4d, 0xd5, 0x66, 0x11, 0xe3, 0xef, 0x22, 0xc0, 0xf2, 0xe1, 0xa0, 0x4d, 0x28, 0x5d, 0xa9, 0x88, + 0xa6, 0x44, 0xc6, 0x4f, 0x95, 0xe2, 0xe3, 0x24, 0x76, 0x1b, 0xca, 0x01, 0xf5, 0x19, 0x71, 0xe7, + 0x31, 0x93, 0x0a, 0x5b, 0xc6, 0x25, 0xe9, 0x38, 0x8e, 0x19, 0x6a, 0x42, 0x65, 0x16, 0xd3, 0x33, + 0x46, 0x5f, 0xc8, 0xf0, 0xba, 0x0c, 0x43, 0xea, 0x12, 0x09, 0xa7, 0x70, 0x3b, 0x8e, 0x2e, 0xc8, + 0x94, 0x5f, 0xb8, 0xc9, 0x73, 0x12, 0x53, 0x25, 0x7c, 0xdd, 0xa1, 0xb8, 0xce, 0x1f, 0x8b, 0xe6, + 0x67, 0x27, 0x8c, 0x3f, 0x9f, 0x8f, 0x4d, 0x2f, 0x0a, 0xda, 0xe9, 0x47, 0x49, 0xfd, 0x7c, 0x91, + 0xf8, 0xa7, 0x6d, 0xb1, 0xad, 0xc4, 0xec, 0x53, 0xef, 0x72, 0xd1, 0xbc, 0x97, 0x92, 0x3a, 0x0f, + 0x66, 0xe0, 0x6a, 0x6a, 0x8f, 0x84, 0x89, 0x0c, 0xa8, 0xf2, 0x98, 0x84, 0xc9, 0x84, 0xc6, 0xe2, + 0x65, 0x91, 0x2a, 0x5a, 0xc2, 0xef, 0xf9, 0x50, 0x03, 0x80, 0x9e, 0x73, 0x1a, 0x26, 0x4c, 0x64, + 0x94, 0x64, 0x46, 0xce, 0x23, 0x97, 0x94, 0x4c, 0x5e, 0x48, 0xe9, 0x2b, 0x61, 0x79, 0x16, 0x3e, + 0x9f, 0x70, 0x22, 0xb5, 0xac, 0x8c, 0xe5, 0xd9, 0xf8, 0x55, 0x83, 0x75, 0x25, 0x27, 0x4d, 0xa8, + 0x78, 0xe9, 0x57, 0xcd, 0xbd, 0xfa, 0xa4, 0x41, 0xe6, 0xb2, 0x7c, 0x21, 0xfb, 0xc4, 0xf7, 0x63, + 0x9a, 0x24, 0xe9, 0xea, 0x33, 0x13, 0xdd, 0x87, 0x9b, 0xea, 0xe5, 0x4c, 0x17, 0xbf, 0x1e, 0x8a, + 0x17, 0x73, 0x55, 0x85, 0xd7, 0x3e, 0x42, 0x85, 0xf7, 0x0e, 0xa1, 0xbe, 0x4a, 0x3f, 0xb4, 0x03, + 0x9b, 0x7d, 0x6b, 0xe4, 0x60, 0xab, 0x7b, 0xec, 0x58, 0x87, 0xb6, 0xeb, 0x3c, 0x3d, 0x1a, 0xb8, + 0x96, 0x3d, 0x72, 0x3a, 0xb6, 0x53, 0x2f, 0xa0, 0x4f, 0x40, 0xbf, 0x1e, 0x1e, 0x39, 0x78, 0xd0, + 0x39, 0xa8, 0x6b, 0x7b, 0x13, 0xd8, 0x58, 0x69, 0x88, 0x36, 0xe1, 0xbe, 0x65, 0x3b, 0x03, 0xdc, + 0xe9, 0x2d, 0xf3, 0xbb, 0xc7, 0xd8, 0xae, 0x17, 0x44, 0xab, 0x6b, 0x21, 0x07, 0x77, 0xec, 0xd1, + 0x70, 0x80, 0xeb, 0xda, 0xbf, 0x56, 0x7e, 0x7f, 0xf8, 0xa4, 0x5f, 0x2f, 0xee, 0x9d, 0x42, 0x2d, + 0xfb, 0x93, 0x30, 0xe2, 0x84, 0xcf, 0x13, 0xd4, 0x84, 0xed, 0x5e, 0xe7, 0xe0, 0xa8, 0x63, 0x7d, + 0x67, 0xbb, 0x23, 0xa7, 0xe3, 0x1c, 0x8f, 0xdc, 0x63, 0x7b, 0x74, 0x34, 0xe8, 0x59, 0x43, 0x6b, + 0xd0, 0x57, 0x83, 0xaf, 0x26, 0x58, 0xb6, 0x80, 0xfe, 0x71, 0x50, 0xd7, 0xd0, 0x16, 0x3c, 0x58, + 0x8d, 0xa6, 0xb1, 0xe2, 0xde, 0x01, 0x94, 0xaf, 0x3e, 0x44, 0xe8, 0x0e, 0xdc, 0xee, 0x3d, 0xe9, + 0x58, 0x07, 0x6a, 0x9c, 0xa1, 0x58, 0x09, 0x82, 0x5a, 0xce, 0x65, 0x0f, 0x1d, 0x35, 0xfb, 0x7b, + 0x69, 0x6e, 0xc7, 0xee, 0xcb, 0x50, 0xb1, 0x7b, 0xf0, 0xea, 0x4d, 0xa3, 0xf0, 0xfa, 0x4d, 0xa3, + 0xf0, 0xea, 0x6d, 0x43, 0x7b, 0xfd, 0xb6, 0xa1, 0xfd, 0xf5, 0xb6, 0xa1, 0xbd, 0x7c, 0xd7, 0x28, + 0xbc, 0x7e, 0xd7, 0x28, 0xfc, 0xfe, 0xae, 0x51, 0x78, 0xf6, 0x79, 0x8e, 0xf0, 0xd9, 0xf3, 0x6c, + 0x67, 0x7f, 0xdd, 0x9e, 0xcf, 0xc7, 0x6d, 0xf5, 0xff, 0x4d, 0x32, 0x7f, 0x7c, 0x53, 0xea, 0xc0, + 0x97, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x32, 0x36, 0xba, 0x98, 0xdc, 0x09, 0x00, 0x00, } func (m *Campaign) Marshal() (dAtA []byte, err error) { @@ -427,6 +429,13 @@ func (m *Campaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ClaimCount != 0 { + i = encodeVarintItc(dAtA, i, uint64(m.ClaimCount)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } if m.MintCount != 0 { i = encodeVarintItc(dAtA, i, uint64(m.MintCount)) i-- @@ -826,6 +835,9 @@ func (m *Campaign) Size() (n int) { if m.MintCount != 0 { n += 2 + sovItc(uint64(m.MintCount)) } + if m.ClaimCount != 0 { + n += 2 + sovItc(uint64(m.ClaimCount)) + } return n } @@ -1437,6 +1449,25 @@ func (m *Campaign) Unmarshal(dAtA []byte) error { break } } + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClaimCount", wireType) + } + m.ClaimCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowItc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClaimCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipItc(dAtA[iNdEx:]) From ddfa764958bff5cf49ec4125c80088f1fa953f49 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Fri, 4 Aug 2023 15:35:59 +0530 Subject: [PATCH 6/7] add pfm (#82) --- app/keepers/keepers.go | 67 +++++++++++++++++++++++++++++------------- app/keepers/keys.go | 2 ++ app/modules.go | 8 +++++ go.mod | 3 +- go.sum | 7 +++-- 5 files changed, 64 insertions(+), 23 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index a87ea98b..d5cdfc1f 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -66,6 +66,10 @@ import ( icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + packetforward "github.com/strangelove-ventures/packet-forward-middleware/v4/router" + packetforwardkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper" + packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types" + allockeeper "github.com/OmniFlix/omniflixhub/x/alloc/keeper" alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" @@ -89,23 +93,24 @@ type AppKeepers struct { memKeys map[string]*sdk.MemoryStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - ICAHostKeeper icahostkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - AuthzKeeper authzkeeper.Keeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + ICAHostKeeper icahostkeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + PacketForwardKeeper *packetforwardkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -261,19 +266,31 @@ func NewAppKeeper( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)) + // initialize ibc packet forwarding middleware router + appKeepers.PacketForwardKeeper = packetforwardkeeper.NewKeeper( + appCodec, appKeepers.keys[packetforwardtypes.StoreKey], + appKeepers.GetSubspace(packetforwardtypes.ModuleName), + appKeepers.TransferKeeper, // Will be zero-value here. Reference is set later on with SetTransferKeeper. + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.DistrKeeper, + appKeepers.BankKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + ) + // Create Transfer Keepers appKeepers.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, appKeepers.keys[ibctransfertypes.StoreKey], appKeepers.GetSubspace(ibctransfertypes.ModuleName), - appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.PacketForwardKeeper, appKeepers.IBCKeeper.ChannelKeeper, &appKeepers.IBCKeeper.PortKeeper, appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.ScopedTransferKeeper, ) - transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper) + // Set TransferKeeper reference in PacketForwardKeeper + appKeepers.PacketForwardKeeper.SetTransferKeeper(appKeepers.TransferKeeper) appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, @@ -356,11 +373,21 @@ func NewAppKeeper( appKeepers.GetSubspace(itctypes.ModuleName), ) + var ibcStack porttypes.IBCModule + ibcStack = transfer.NewIBCModule(appKeepers.TransferKeeper) + ibcStack = packetforward.NewIBCMiddleware( + ibcStack, + appKeepers.PacketForwardKeeper, + 0, + packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, + packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, + ) + // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() ibcRouter. AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + AddRoute(ibctransfertypes.ModuleName, ibcStack) appKeepers.IBCKeeper.SetRouter(ibcRouter) diff --git a/app/keepers/keys.go b/app/keepers/keys.go index eb8ffae7..cc9491a7 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -24,6 +24,7 @@ import ( icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types" ) func (appKeepers *AppKeepers) GenerateKeys() { @@ -41,6 +42,7 @@ func (appKeepers *AppKeepers) GenerateKeys() { evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, + packetforwardtypes.StoreKey, capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, diff --git a/app/modules.go b/app/modules.go index d92e609c..aa440706 100644 --- a/app/modules.go +++ b/app/modules.go @@ -61,6 +61,9 @@ import ( icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + packetforward "github.com/strangelove-ventures/packet-forward-middleware/v4/router" + packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types" + "github.com/OmniFlix/omniflixhub/x/alloc" alloctypes "github.com/OmniFlix/omniflixhub/x/alloc/types" @@ -95,6 +98,7 @@ var ( slashing.AppModuleBasic{}, ibc.AppModuleBasic{}, ica.AppModuleBasic{}, + packetforward.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, authzmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, @@ -157,6 +161,7 @@ func appModules( params.NewAppModule(app.ParamsKeeper), transfer.NewAppModule(app.TransferKeeper), ica.NewAppModule(nil, &app.ICAHostKeeper), + packetforward.NewAppModule(app.PacketForwardKeeper), alloc.NewAppModule(appCodec, app.AllocKeeper), onft.NewAppModule(appCodec, app.ONFTKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper), marketplace.NewAppModule(appCodec, app.MarketplaceKeeper), @@ -219,6 +224,7 @@ func orderBeginBlockers() []string { paramstypes.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, + packetforwardtypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, authtypes.ModuleName, @@ -246,6 +252,7 @@ func orderEndBlockers() []string { paramstypes.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, + packetforwardtypes.ModuleName, minttypes.ModuleName, slashingtypes.ModuleName, distrtypes.ModuleName, @@ -290,6 +297,7 @@ func orderInitGenesis() []string { ibchost.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, + packetforwardtypes.ModuleName, alloctypes.ModuleName, onfttypes.ModuleName, marketplacetypes.ModuleName, diff --git a/go.mod b/go.mod index 6e05bbc8..0799c2f7 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 + github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.6 github.com/stretchr/testify v1.8.1 github.com/tendermint/tendermint v0.34.28 github.com/tendermint/tm-db v0.6.7 @@ -75,7 +76,6 @@ require ( github.com/gogo/gateway v1.1.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -87,6 +87,7 @@ require ( github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect + github.com/iancoleman/orderedmap v0.2.0 // indirect github.com/improbable-eng/grpc-web v0.14.1 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jmhodges/levigo v1.0.0 // indirect diff --git a/go.sum b/go.sum index 9e9b01b9..88eac61c 100644 --- a/go.sum +++ b/go.sum @@ -141,8 +141,8 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= -github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd v0.22.2 h1:vBZ+lGGd1XubpOWO67ITJpAEsICWhA0YzqkcpkgNBfo= github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= @@ -458,7 +458,6 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -556,6 +555,8 @@ github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= +github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA= +github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= @@ -941,6 +942,8 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.6 h1:aY64yjKZyDyzlIbDOkGBPvVpR0ArzIjunpCRKqoIm7o= +github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.6/go.mod h1:4zAtg449/JISRmf+sbmqolqSLP+QJBh+EtWkWtt/AKE= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= From e648cdcd926a820e129451b9c84c2cf837b3e9f9 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Fri, 4 Aug 2023 17:26:41 +0530 Subject: [PATCH 7/7] add upgrade handler for v0.12.x (#83) --- app/app.go | 4 ++-- app/keepers/keepers.go | 1 + app/upgrades/{v2 => v012}/constants.go | 7 ++++--- app/upgrades/{v2 => v012}/upgrades.go | 14 +++++++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) rename app/upgrades/{v2 => v012}/constants.go (63%) rename app/upgrades/{v2 => v012}/upgrades.go (78%) diff --git a/app/app.go b/app/app.go index 6bd7a709..6559198c 100644 --- a/app/app.go +++ b/app/app.go @@ -44,7 +44,7 @@ import ( "github.com/OmniFlix/omniflixhub/app/keepers" "github.com/OmniFlix/omniflixhub/app/upgrades" - v2 "github.com/OmniFlix/omniflixhub/app/upgrades/v2" + v012 "github.com/OmniFlix/omniflixhub/app/upgrades/v012" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -67,7 +67,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler { var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string - Upgrades = []upgrades.Upgrade{v2.Upgrade} + Upgrades = []upgrades.Upgrade{v012.Upgrade} Forks []upgrades.Fork ) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index d5cdfc1f..6873ace8 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -415,6 +415,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable()) paramsKeeper.Subspace(alloctypes.ModuleName) paramsKeeper.Subspace(onfttypes.ModuleName) paramsKeeper.Subspace(marketplacetypes.ModuleName) diff --git a/app/upgrades/v2/constants.go b/app/upgrades/v012/constants.go similarity index 63% rename from app/upgrades/v2/constants.go rename to app/upgrades/v012/constants.go index b5b2afc5..8d0101d2 100644 --- a/app/upgrades/v2/constants.go +++ b/app/upgrades/v012/constants.go @@ -1,17 +1,18 @@ -package v2 +package v012 import ( "github.com/OmniFlix/omniflixhub/app/upgrades" store "github.com/cosmos/cosmos-sdk/store/types" icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types" ) -const UpgradeName = "v2" +const UpgradeName = "v0.12.x" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, StoreUpgrades: store.StoreUpgrades{ - Added: []string{icahosttypes.StoreKey}, + Added: []string{icahosttypes.StoreKey, packetforwardtypes.StoreKey}, }, } diff --git a/app/upgrades/v2/upgrades.go b/app/upgrades/v012/upgrades.go similarity index 78% rename from app/upgrades/v2/upgrades.go rename to app/upgrades/v012/upgrades.go index 339b0bc3..1bcaf9cd 100644 --- a/app/upgrades/v2/upgrades.go +++ b/app/upgrades/v012/upgrades.go @@ -1,4 +1,4 @@ -package v2 +package v012 import ( "github.com/OmniFlix/omniflixhub/app/keepers" @@ -11,6 +11,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types" ) func CreateUpgradeHandler( @@ -48,6 +49,17 @@ func CreateUpgradeHandler( keepers.ICAHostKeeper.SetParams(ctx, hostParams) + // Packet Forward middleware initial params + keepers.PacketForwardKeeper.SetParams(ctx, packetforwardtypes.DefaultParams()) + + // itc campaigns migrations + campaigns := keepers.ItcKeeper.GetAllCampaigns(ctx) + for _, campaign := range campaigns { + claims := keepers.ItcKeeper.GetClaims(ctx, campaign.Id) + campaign.ClaimCount = uint64(len(claims)) + keepers.ItcKeeper.SetCampaign(ctx, campaign) + } + return versionMap, nil } }