From 7783af49717080d90df81018d3f5711fde95f85d Mon Sep 17 00:00:00 2001 From: fynn-0xc Date: Thu, 9 Feb 2023 17:51:08 +0800 Subject: [PATCH] feat: add storage module (#18) * add storage module * fix review tips * add approval and unique resource id * add signature check * fix go line * add basic test * fix ci * add sequence test * refactor the uint256 id * rename field name * Apply suggestions from code review Co-authored-by: Owen * fix buf format and params * change sha 256 from crypto.Sha256 to sdk.keccak256 * format the code * format go import * fix review tips * refactor keeper * fix go lint * fix test * change Short for all command of cli * fix rebase and format code * change gnfd-cosmos-sdk version --------- Co-authored-by: fynn z Co-authored-by: Owen --- Makefile | 3 + app/app.go | 45 +- app/config.go | 4 +- deployment/localup/create_sp.json | 27 + deployment/localup/create_sp.json | 26 - docs/docs.go | 4 +- format.sh | 10 + go.mod | 14 +- go.sum | 28 +- proto/greenfield/bridge/genesis.proto | 3 +- proto/greenfield/greenfield/params.proto | 11 - proto/greenfield/greenfield/query.proto | 29 - proto/greenfield/greenfield/tx.proto | 13 - proto/greenfield/storage/common.proto | 13 + .../{greenfield => storage}/genesis.proto | 8 +- proto/greenfield/storage/params.proto | 21 + proto/greenfield/storage/query.proto | 59 + proto/greenfield/storage/tx.proto | 189 + proto/greenfield/storage/types.proto | 108 + testutil/keeper/bridge.go | 14 +- testutil/keeper/greenfield.go | 52 - testutil/keeper/sp.go | 18 +- testutil/keeper/storage.go | 162 + testutil/sample/sample.go | 12 + x/bridge/client/cli/query.go | 6 +- x/bridge/client/cli/query_params.go | 3 +- x/bridge/client/cli/tx.go | 3 +- x/bridge/client/cli/tx_transfer_out.go | 3 +- x/bridge/genesis.go | 3 +- x/bridge/keeper/cross_app.go | 3 +- x/bridge/keeper/cross_app_test.go | 7 +- x/bridge/keeper/grpc_query_params.go | 3 +- x/bridge/keeper/keeper.go | 3 +- x/bridge/keeper/msg_server_test.go | 7 +- x/bridge/keeper/msg_server_transfer_out.go | 3 +- x/bridge/keeper/params.go | 3 +- x/bridge/module.go | 12 +- x/bridge/module_simulation.go | 7 +- x/bridge/simulation/transfer_out.go | 5 +- x/bridge/types/errors.go | 2 - x/bridge/types/genesis_test.go | 3 +- x/bridge/types/message_transfer_out_test.go | 3 +- x/greenfield/client/cli/query.go | 31 - x/greenfield/client/cli/tx.go | 31 - x/greenfield/keeper/keeper.go | 46 - x/greenfield/keeper/msg_server.go | 17 - x/greenfield/keeper/params.go | 16 - x/greenfield/module_simulation.go | 64 - x/greenfield/types/codec.go | 23 - x/greenfield/types/errors.go | 12 - x/greenfield/types/keys.go | 19 - x/greenfield/types/params.go | 39 - x/greenfield/types/params.pb.go | 266 - x/greenfield/types/query.pb.go | 537 -- x/greenfield/types/query.pb.gw.go | 153 - x/greenfield/types/tx.pb.go | 80 - x/greenfield/types/types.go | 1 - x/sp/client/cli/query.go | 4 +- x/sp/client/cli/query_params.go | 3 +- x/sp/client/cli/tx.go | 4 +- x/sp/genesis.go | 3 +- x/sp/genesis_test.go | 3 +- x/sp/keeper/genesis.go | 3 +- x/sp/keeper/grpc_query.go | 8 +- x/sp/keeper/grpc_query_params.go | 3 +- x/sp/keeper/grpc_query_params_test.go | 5 +- x/sp/keeper/keeper.go | 7 +- x/sp/keeper/msg_server.go | 3 +- x/sp/keeper/msg_server_test.go | 3 +- x/sp/keeper/params.go | 3 +- x/sp/keeper/params_test.go | 3 +- x/sp/keeper/slash.go | 3 +- x/sp/keeper/sp.go | 3 +- x/sp/module.go | 12 +- x/sp/module_simulation.go | 7 +- x/sp/simulation/operations.go | 5 +- x/sp/types/errors.go | 2 - x/sp/types/genesis_test.go | 3 +- x/sp/types/params.go | 12 +- x/storage/README.md | 0 x/storage/client/cli/flags.go | 8 + x/storage/client/cli/query.go | 102 + .../client/cli/query_params.go | 3 +- x/storage/client/cli/tx.go | 461 ++ x/{greenfield => storage}/genesis.go | 7 +- x/{greenfield => storage}/genesis_test.go | 15 +- .../keeper/grpc_query.go | 2 +- .../keeper/grpc_query_params.go | 3 +- .../keeper/grpc_query_params_test.go | 7 +- x/storage/keeper/keeper.go | 293 + x/storage/keeper/msg_server.go | 369 ++ .../keeper/msg_server_test.go | 9 +- x/storage/keeper/params.go | 41 + .../keeper/params_test.go | 7 +- x/storage/keeper/query.go | 44 + x/storage/keeper/sequence.go | 66 + x/storage/keeper/sequence_test.go | 67 + x/{greenfield => storage}/module.go | 22 +- x/storage/module_simulation.go | 230 + .../simulation/helpers.go | 0 x/storage/simulation/operations.go | 210 + x/storage/simulation/operations_test.go | 1 + x/storage/types/codec.go | 79 + x/storage/types/common.pb.go | 71 + x/storage/types/errors.go | 34 + .../types/expected_keepers.go | 10 +- x/{greenfield => storage}/types/genesis.go | 4 - x/{greenfield => storage}/types/genesis.pb.go | 41 +- .../types/genesis_test.go | 11 +- x/storage/types/keys.go | 52 + x/storage/types/message.go | 670 ++ x/storage/types/message_test.go | 418 ++ x/storage/types/params.go | 131 + x/storage/types/params.pb.go | 417 ++ x/storage/types/query.pb.go | 1375 ++++ x/storage/types/query.pb.gw.go | 377 ++ x/storage/types/tx.pb.go | 5663 +++++++++++++++++ x/storage/types/types.go | 33 + x/storage/types/types.pb.go | 1986 ++++++ x/storage/types/util.go | 130 + 120 files changed, 14173 insertions(+), 1685 deletions(-) create mode 100644 deployment/localup/create_sp.json delete mode 100644 deployment/localup/create_sp.json create mode 100644 format.sh delete mode 100644 proto/greenfield/greenfield/params.proto delete mode 100644 proto/greenfield/greenfield/query.proto delete mode 100644 proto/greenfield/greenfield/tx.proto create mode 100644 proto/greenfield/storage/common.proto rename proto/greenfield/{greenfield => storage}/genesis.proto (55%) create mode 100644 proto/greenfield/storage/params.proto create mode 100644 proto/greenfield/storage/query.proto create mode 100644 proto/greenfield/storage/tx.proto create mode 100644 proto/greenfield/storage/types.proto delete mode 100644 testutil/keeper/greenfield.go create mode 100644 testutil/keeper/storage.go delete mode 100644 x/greenfield/client/cli/query.go delete mode 100644 x/greenfield/client/cli/tx.go delete mode 100644 x/greenfield/keeper/keeper.go delete mode 100644 x/greenfield/keeper/msg_server.go delete mode 100644 x/greenfield/keeper/params.go delete mode 100644 x/greenfield/module_simulation.go delete mode 100644 x/greenfield/types/codec.go delete mode 100644 x/greenfield/types/errors.go delete mode 100644 x/greenfield/types/keys.go delete mode 100644 x/greenfield/types/params.go delete mode 100644 x/greenfield/types/params.pb.go delete mode 100644 x/greenfield/types/query.pb.go delete mode 100644 x/greenfield/types/query.pb.gw.go delete mode 100644 x/greenfield/types/tx.pb.go delete mode 100644 x/greenfield/types/types.go create mode 100644 x/storage/README.md create mode 100644 x/storage/client/cli/flags.go create mode 100644 x/storage/client/cli/query.go rename x/{greenfield => storage}/client/cli/query_params.go (92%) create mode 100644 x/storage/client/cli/tx.go rename x/{greenfield => storage}/genesis.go (82%) rename x/{greenfield => storage}/genesis_test.go (65%) rename x/{greenfield => storage}/keeper/grpc_query.go (53%) rename x/{greenfield => storage}/keeper/grpc_query_params.go (89%) rename x/{greenfield => storage}/keeper/grpc_query_params_test.go (82%) create mode 100644 x/storage/keeper/keeper.go create mode 100644 x/storage/keeper/msg_server.go rename x/{greenfield => storage}/keeper/msg_server_test.go (67%) create mode 100644 x/storage/keeper/params.go rename x/{greenfield => storage}/keeper/params_test.go (75%) create mode 100644 x/storage/keeper/query.go create mode 100644 x/storage/keeper/sequence.go create mode 100644 x/storage/keeper/sequence_test.go rename x/{greenfield => storage}/module.go (95%) create mode 100644 x/storage/module_simulation.go rename x/{greenfield => storage}/simulation/helpers.go (100%) create mode 100644 x/storage/simulation/operations.go create mode 100644 x/storage/simulation/operations_test.go create mode 100644 x/storage/types/codec.go create mode 100644 x/storage/types/common.pb.go create mode 100644 x/storage/types/errors.go rename x/{greenfield => storage}/types/expected_keepers.go (60%) rename x/{greenfield => storage}/types/genesis.go (87%) rename x/{greenfield => storage}/types/genesis.pb.go (80%) rename x/{greenfield => storage}/types/genesis_test.go (74%) create mode 100644 x/storage/types/keys.go create mode 100644 x/storage/types/message.go create mode 100644 x/storage/types/message_test.go create mode 100644 x/storage/types/params.go create mode 100644 x/storage/types/params.pb.go create mode 100644 x/storage/types/query.pb.go create mode 100644 x/storage/types/query.pb.gw.go create mode 100644 x/storage/types/tx.pb.go create mode 100644 x/storage/types/types.go create mode 100644 x/storage/types/types.pb.go create mode 100644 x/storage/types/util.go diff --git a/Makefile b/Makefile index d761e928a..550ef3678 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ ldflags = -X $(REPO)/version.AppVersion=$(VERSION) \ -X $(REPO)/version.GitCommit=$(GIT_COMMIT) \ -X $(REPO)/version.GitCommitDate=$(GIT_COMMIT_DATE) +format: + bash format.sh + tools: curl https://get.ignite.com/cli! | bash diff --git a/app/app.go b/app/app.go index fbfb9484c..b1b5832a2 100644 --- a/app/app.go +++ b/app/app.go @@ -91,18 +91,16 @@ import ( bridgemodule "github.com/bnb-chain/greenfield/x/bridge" bridgemodulekeeper "github.com/bnb-chain/greenfield/x/bridge/keeper" bridgemoduletypes "github.com/bnb-chain/greenfield/x/bridge/types" - greenfieldmodule "github.com/bnb-chain/greenfield/x/greenfield" - greenfieldmodulekeeper "github.com/bnb-chain/greenfield/x/greenfield/keeper" - greenfieldmoduletypes "github.com/bnb-chain/greenfield/x/greenfield/types" spmodule "github.com/bnb-chain/greenfield/x/sp" spmodulekeeper "github.com/bnb-chain/greenfield/x/sp/keeper" spmoduletypes "github.com/bnb-chain/greenfield/x/sp/types" - // this line is used by starport scaffolding # stargate/app/moduleImport paymentmodule "github.com/bnb-chain/greenfield/x/payment" paymentmodulekeeper "github.com/bnb-chain/greenfield/x/payment/keeper" paymentmoduletypes "github.com/bnb-chain/greenfield/x/payment/types" - // this line is used by starport scaffolding # stargate/app/moduleImport + storagemodule "github.com/bnb-chain/greenfield/x/storage" + storagemodulekeeper "github.com/bnb-chain/greenfield/x/storage/keeper" + storagemoduletypes "github.com/bnb-chain/greenfield/x/storage/types" ) const ( @@ -150,13 +148,13 @@ var ( slashing.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, - greenfieldmodule.AppModuleBasic{}, crosschain.AppModuleBasic{}, oracle.AppModuleBasic{}, bridgemodule.AppModuleBasic{}, gashub.AppModuleBasic{}, spmodule.AppModuleBasic{}, paymentmodule.AppModuleBasic{}, + storagemodule.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -222,11 +220,10 @@ type App struct { OracleKeeper oraclekeeper.Keeper GashubKeeper gashubkeeper.Keeper - GreenfieldKeeper greenfieldmodulekeeper.Keeper - BridgeKeeper bridgemodulekeeper.Keeper SpKeeper spmodulekeeper.Keeper PaymentKeeper paymentmodulekeeper.Keeper + StorageKeeper storagemodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // mm is the module manager @@ -275,13 +272,13 @@ func New( paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, - greenfieldmoduletypes.StoreKey, crosschaintypes.StoreKey, oracletypes.StoreKey, bridgemoduletypes.StoreKey, gashubtypes.StoreKey, spmoduletypes.StoreKey, paymentmoduletypes.StoreKey, + storagemoduletypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -407,13 +404,6 @@ func New( govConfig, ) - app.GreenfieldKeeper = *greenfieldmodulekeeper.NewKeeper( - appCodec, - keys[greenfieldmoduletypes.StoreKey], - keys[greenfieldmoduletypes.MemStoreKey], - app.GetSubspace(greenfieldmoduletypes.ModuleName), - ) - // Register the upgrade keeper upgradeInitlizier, upgradeHandler := UpgradeInitializerAndHandler(app.AccountKeeper) var err error @@ -427,8 +417,6 @@ func New( panic(err) } - greenfieldModule := greenfieldmodule.NewAppModule(appCodec, app.GreenfieldKeeper, app.AccountKeeper, app.BankKeeper) - app.BridgeKeeper = *bridgemodulekeeper.NewKeeper( appCodec, keys[bridgemoduletypes.StoreKey], @@ -469,6 +457,15 @@ func New( ) paymentModule := paymentmodule.NewAppModule(appCodec, app.PaymentKeeper, app.AccountKeeper, app.BankKeeper) + app.StorageKeeper = *storagemodulekeeper.NewKeeper( + appCodec, + keys[storagemoduletypes.StoreKey], + keys[storagemoduletypes.MemStoreKey], + app.GetSubspace(storagemoduletypes.ModuleName), + app.SpKeeper, + ) + storageModule := storagemodule.NewAppModule(appCodec, app.StorageKeeper, app.AccountKeeper, app.BankKeeper, app.SpKeeper) + // this line is used by starport scaffolding # stargate/app/keeperDefinition /**** Module Options ****/ @@ -496,11 +493,11 @@ func New( params.NewAppModule(app.ParamsKeeper), crosschain.NewAppModule(app.CrossChainKeeper, app.BankKeeper, app.StakingKeeper), oracle.NewAppModule(app.OracleKeeper), - greenfieldModule, bridgeModule, gashubModule, spModule, paymentModule, + storageModule, // this line is used by starport scaffolding # stargate/app/appModule ) @@ -521,13 +518,13 @@ func New( authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, - greenfieldmoduletypes.ModuleName, crosschaintypes.ModuleName, oracletypes.ModuleName, bridgemoduletypes.ModuleName, gashubtypes.ModuleName, spmoduletypes.ModuleName, paymentmoduletypes.ModuleName, + storagemoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -543,13 +540,13 @@ func New( feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, - greenfieldmoduletypes.ModuleName, crosschaintypes.ModuleName, oracletypes.ModuleName, bridgemoduletypes.ModuleName, gashubtypes.ModuleName, spmoduletypes.ModuleName, paymentmoduletypes.ModuleName, + storagemoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -571,12 +568,12 @@ func New( feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, - greenfieldmoduletypes.ModuleName, crosschaintypes.ModuleName, oracletypes.ModuleName, bridgemoduletypes.ModuleName, spmoduletypes.ModuleName, paymentmoduletypes.ModuleName, + storagemoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -601,11 +598,11 @@ func New( params.NewAppModule(app.ParamsKeeper), crosschain.NewAppModule(app.CrossChainKeeper, app.BankKeeper, app.StakingKeeper), oracle.NewAppModule(app.OracleKeeper), - greenfieldModule, bridgeModule, gashubModule, spModule, paymentModule, + storageModule, // this line is used by starport scaffolding # stargate/app/appModule ) app.sm.RegisterStoreDecoders() @@ -830,13 +827,13 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) - paramsKeeper.Subspace(greenfieldmoduletypes.ModuleName) paramsKeeper.Subspace(crosschaintypes.ModuleName) paramsKeeper.Subspace(oracletypes.ModuleName) paramsKeeper.Subspace(bridgemoduletypes.ModuleName) paramsKeeper.Subspace(gashubtypes.ModuleName) paramsKeeper.Subspace(spmoduletypes.ModuleName) paramsKeeper.Subspace(paymentmoduletypes.ModuleName) + paramsKeeper.Subspace(storagemoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/app/config.go b/app/config.go index a41b7cbce..e2f57bc04 100644 --- a/app/config.go +++ b/app/config.go @@ -1,6 +1,8 @@ package app -import serverconfig "github.com/cosmos/cosmos-sdk/server/config" +import ( + serverconfig "github.com/cosmos/cosmos-sdk/server/config" +) type AppConfig struct { serverconfig.Config diff --git a/deployment/localup/create_sp.json b/deployment/localup/create_sp.json new file mode 100644 index 000000000..e6b2cded7 --- /dev/null +++ b/deployment/localup/create_sp.json @@ -0,0 +1,27 @@ +{ + "messages":[ + { + "@type":"/bnbchain.greenfield.sp.MsgCreateStorageProvider", + "description":{ + "moniker": "sp0", + "identity":"", + "website":"", + "security_contact":"", + "details":"" + }, + "sp_address":"0x78FeF615b06251ecfA9Ba01B7DB2BFA892722dDC", + "funding_address":"0x1d05CCD43A6c27fBCdfE6Ac727B0e9B889AAbC3B", + "seal_address": "0x2163A7A41a71ea4A831E4F5Af7f90dd32E440592", + "approval_address": "0x78FeF615b06251ecfA9Ba01B7DB2BFA892722dDC", + "endpoint": "sp0.greenfield.io", + "deposit":{ + "denom":"bnb", + "amount":"10000" + }, + "creator":"0x7b5Fe22B5446f7C62Ea27B8BD71CeF94e03f3dF2" + } +], + "metadata": "4pIMOgIGx1vZGU=", + "deposit": "1bnb" +} + diff --git a/deployment/localup/create_sp.json b/deployment/localup/create_sp.json deleted file mode 100644 index 3379fb86c..000000000 --- a/deployment/localup/create_sp.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "messages":[ - { - "@type":"/bnbchain.greenfield.sp.MsgCreateStorageProvider", - "description":{ - "moniker": "sp0", - "identity":"", - "website":"", - "security_contact":"", - "details":"" - }, - "sp_address":"0x698F9f203748a9Af4a1663F59c2f9f8529Dd925d", - "funding_address":"0x756eD1374Fd79032E22857c227CBE58C00fA003E", - "seal_address": "0x698F9f203748a9Af4a1663F59c2f9f8529Dd925d", - "approval_address": "0x698F9f203748a9Af4a1663F59c2f9f8529Dd925d", - "endpoint": "sp0.greenfield.io" - "amount":{ - "denom":"gweibnb", - "amount":"1000000" - }, - "creator":"0x7b5Fe22B5446f7C62Ea27B8BD71CeF94e03f3dF2" - } -], - "metadata": "4pIMOgIGx1vZGU=", - "deposit": "1bnb" -} diff --git a/docs/docs.go b/docs/docs.go index 1167d5657..23b9cc8e4 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,6 +1,8 @@ package docs -import "embed" +import ( + "embed" +) //go:embed static var Docs embed.FS diff --git a/format.sh b/format.sh new file mode 100644 index 000000000..383fcb9c9 --- /dev/null +++ b/format.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +go install github.com/AanZee/goimportssort + +for entry in `find . -name "*.go"`; do + if grep -q "DO NOT EDIT" "$entry"; then + continue + fi + goimportssort -w -local github.com/bnb-chain/ $entry +done \ No newline at end of file diff --git a/go.mod b/go.mod index b8055de16..0a28803ba 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( sigs.k8s.io/yaml v1.3.0 ) -require golang.org/x/text v0.5.0 // indirect +require golang.org/x/text v0.6.0 // indirect require ( github.com/cosmos/gogoproto v1.4.3 @@ -211,12 +211,12 @@ require ( go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.1.0 // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/mod v0.6.0 // indirect - golang.org/x/net v0.3.0 // indirect + golang.org/x/mod v0.7.0 // indirect + golang.org/x/net v0.5.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/term v0.3.0 // indirect - golang.org/x/tools v0.2.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/term v0.4.0 // indirect + golang.org/x/tools v0.5.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect gopkg.in/ini.v1 v1.67.0 // indirect @@ -228,7 +228,7 @@ require ( replace ( github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/gnfd-cosmos-sdk v0.0.2-0.20230203064030-594124083cf3 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/gnfd-cosmos-sdk v0.0.2-0.20230209090945-5a119caf6b3e github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/bnb-chain/gnfd-tendermint v0.0.1 ) diff --git a/go.sum b/go.sum index 0f2761bf8..bfb84b8fd 100644 --- a/go.sum +++ b/go.sum @@ -218,8 +218,8 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/bnb-chain/gnfd-cosmos-sdk v0.0.2-0.20230203064030-594124083cf3 h1:vepZdEQE0KfLdCX/MkIr3ZN7AaAoO9X/Un3oC6TuQyE= -github.com/bnb-chain/gnfd-cosmos-sdk v0.0.2-0.20230203064030-594124083cf3/go.mod h1:NlIOmju3uhTOJ2YAzLPidpmh7sAgJ+J9dkUlSysHmjw= +github.com/bnb-chain/gnfd-cosmos-sdk v0.0.2-0.20230209090945-5a119caf6b3e h1:w2B9A4FlZ24MEtPIcWA6T4tKvCMBSiaYPIT0dkk6wh0= +github.com/bnb-chain/gnfd-cosmos-sdk v0.0.2-0.20230209090945-5a119caf6b3e/go.mod h1:NlIOmju3uhTOJ2YAzLPidpmh7sAgJ+J9dkUlSysHmjw= github.com/bnb-chain/gnfd-tendermint v0.0.1 h1:KWFuxWv8m6t1vUi3ADyVcEG0qVnEzQt1tjA6dk/b7+Q= github.com/bnb-chain/gnfd-tendermint v0.0.1/go.mod h1:/v9z9F6cq0+f7EGG92lYSLBcPYQDILoK91X8YM28hWo= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= @@ -2017,8 +2017,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -2094,8 +2094,8 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -2256,14 +2256,14 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg= +golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2274,8 +2274,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20170424234030-8be79e1e0910/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2358,8 +2358,8 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= +golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= +golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proto/greenfield/bridge/genesis.proto b/proto/greenfield/bridge/genesis.proto index 6916cee63..1785ad9e8 100644 --- a/proto/greenfield/bridge/genesis.proto +++ b/proto/greenfield/bridge/genesis.proto @@ -3,10 +3,11 @@ package bnbchain.greenfield.bridge; import "gogoproto/gogo.proto"; import "greenfield/bridge/params.proto"; -// this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/bnb-chain/greenfield/x/bridge/types"; +// this line is used by starport scaffolding # genesis/proto/import + // GenesisState defines the bridge module's genesis state. message GenesisState { // Params defines all the paramaters of the module. diff --git a/proto/greenfield/greenfield/params.proto b/proto/greenfield/greenfield/params.proto deleted file mode 100644 index 104ab57f1..000000000 --- a/proto/greenfield/greenfield/params.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; -package greenfield.greenfield; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/bnb-chain/greenfield/x/greenfield/types"; - -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; -} diff --git a/proto/greenfield/greenfield/query.proto b/proto/greenfield/greenfield/query.proto deleted file mode 100644 index 40519d5a0..000000000 --- a/proto/greenfield/greenfield/query.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; -package greenfield.greenfield; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "greenfield/greenfield/params.proto"; -// this line is used by starport scaffolding # 1 - -option go_package = "github.com/bnb-chain/greenfield/x/greenfield/types"; - -// Query defines the gRPC querier service. -service Query { - // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/greenfield/greenfield/params"; - } - - // this line is used by starport scaffolding # 2 -} - -// QueryParamsRequest is request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is response type for the Query/Params RPC method. -message QueryParamsResponse { - // params holds all the parameters of this module. - Params params = 1 [(gogoproto.nullable) = false]; -} diff --git a/proto/greenfield/greenfield/tx.proto b/proto/greenfield/greenfield/tx.proto deleted file mode 100644 index 9d34e8541..000000000 --- a/proto/greenfield/greenfield/tx.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; -package greenfield.greenfield; - -// this line is used by starport scaffolding # proto/tx/import - -option go_package = "github.com/bnb-chain/greenfield/x/greenfield/types"; - -// Msg defines the Msg service. -service Msg { - // this line is used by starport scaffolding # proto/tx/rpc -} - -// this line is used by starport scaffolding # proto/tx/message diff --git a/proto/greenfield/storage/common.proto b/proto/greenfield/storage/common.proto new file mode 100644 index 000000000..560e4fcaa --- /dev/null +++ b/proto/greenfield/storage/common.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package bnbchain.greenfield.storage; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; + +enum SourceType { + option (gogoproto.goproto_enum_prefix) = false; + + SOURCE_TYPE_ORIGIN = 0; + SOURCE_TYPE_BSC_CROSS_CHAIN = 1; +} diff --git a/proto/greenfield/greenfield/genesis.proto b/proto/greenfield/storage/genesis.proto similarity index 55% rename from proto/greenfield/greenfield/genesis.proto rename to proto/greenfield/storage/genesis.proto index 76f2cca7f..de58a30d4 100644 --- a/proto/greenfield/greenfield/genesis.proto +++ b/proto/greenfield/storage/genesis.proto @@ -1,13 +1,13 @@ syntax = "proto3"; -package greenfield.greenfield; +package bnbchain.greenfield.storage; import "gogoproto/gogo.proto"; -import "greenfield/greenfield/params.proto"; +import "greenfield/storage/params.proto"; // this line is used by starport scaffolding # genesis/proto/import -option go_package = "github.com/bnb-chain/greenfield/x/greenfield/types"; +option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; -// GenesisState defines the greenfield module's genesis state. +// GenesisState defines the bridge module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state diff --git a/proto/greenfield/storage/params.proto b/proto/greenfield/storage/params.proto new file mode 100644 index 000000000..1e95aa41a --- /dev/null +++ b/proto/greenfield/storage/params.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package bnbchain.greenfield.storage; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; + +// Params defines the parameters for the module. +message Params { + // TODO: We should think more about the version-control of the storage params. + option (gogoproto.goproto_stringer) = false; + + // max_segment_size is the maximum size of a segment. default: 16M + uint64 max_segment_size = 1; + // redundant_data_check_num is the num of data chunks of EC redundancy algorithm + uint32 redundant_data_chunk_num = 2; + // redundant_data_check_num is the num of parity chunks of EC redundancy algorithm + uint32 redundant_parity_chunk_num = 3; + // max_payload_size is the maximum size of the payload, default: 2G + uint64 max_payload_size = 4; +} diff --git a/proto/greenfield/storage/query.proto b/proto/greenfield/storage/query.proto new file mode 100644 index 000000000..11a98be17 --- /dev/null +++ b/proto/greenfield/storage/query.proto @@ -0,0 +1,59 @@ +syntax = "proto3"; +package bnbchain.greenfield.storage; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "greenfield/storage/params.proto"; +import "greenfield/storage/types.proto"; + +// this line is used by starport scaffolding # 1 + +option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/greenfield/storage/params"; + } + + // this line is used by starport scaffolding # 2 + + // Queries a list of Bucket items. + rpc Bucket(QueryBucketRequest) returns (QueryBucketResponse) { + option (google.api.http).get = "/greenfield/storage/bucket/{bucket_name}"; + } + + // Queries a list of Object items. + rpc Object(QueryObjectRequest) returns (QueryObjectResponse) { + option (google.api.http).get = "/greenfield/storage/object/{bucket_name}/{object_name}"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// this line is used by starport scaffolding # 3 +message QueryBucketRequest { + string bucket_name = 1; +} + +message QueryBucketResponse { + BucketInfo bucket_info = 1; +} + +message QueryObjectRequest { + string bucket_name = 1; + string object_name = 2; +} + +message QueryObjectResponse { + ObjectInfo object_info = 1; +} diff --git a/proto/greenfield/storage/tx.proto b/proto/greenfield/storage/tx.proto new file mode 100644 index 000000000..4f9581e75 --- /dev/null +++ b/proto/greenfield/storage/tx.proto @@ -0,0 +1,189 @@ +syntax = "proto3"; +package bnbchain.greenfield.storage; + +import "cosmos/msg/v1/msg.proto"; +// this line is used by starport scaffolding # proto/tx/import +import "cosmos_proto/cosmos.proto"; +import "greenfield/storage/common.proto"; + +option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; + +// Msg defines the Msg service. +service Msg { + rpc CreateBucket(MsgCreateBucket) returns (MsgCreateBucketResponse); + rpc DeleteBucket(MsgDeleteBucket) returns (MsgDeleteBucketResponse); + rpc CreateObject(MsgCreateObject) returns (MsgCreateObjectResponse); + rpc SealObject(MsgSealObject) returns (MsgSealObjectResponse); + rpc RejectSealObject(MsgRejectSealObject) returns (MsgRejectSealObjectResponse); + rpc DeleteObject(MsgDeleteObject) returns (MsgDeleteObjectResponse); + rpc CreateGroup(MsgCreateGroup) returns (MsgCreateGroupResponse); + rpc DeleteGroup(MsgDeleteGroup) returns (MsgDeleteGroupResponse); + rpc UpdateGroupMember(MsgUpdateGroupMember) returns (MsgUpdateGroupMemberResponse); + rpc LeaveGroup(MsgLeaveGroup) returns (MsgLeaveGroupResponse); + rpc CopyObject(MsgCopyObject) returns (MsgCopyObjectResponse); + // this line is used by starport scaffolding # proto/tx/rpc +} + +message MsgCreateBucket { + option (cosmos.msg.v1.signer) = "creator"; + // creator is the account address of bucket creator, it is also the bucket owner. + string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is a globally unique name of bucket + string bucket_name = 2; + // is_public means the bucket is private or public. if private, only bucket owner or grantee can read it, + // otherwise every greenfield user can read it. + bool is_public = 3; + // payment_address is an account address specified by bucket owner to pay the read fee. Default: creator + string payment_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // primary_sp_address is the address of primary sp. + string primary_sp_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // primary_sp_approval_signature is the signature of the primary SP which indicates that primary sp confirm the user's request. + bytes primary_sp_approval_signature = 7; +} + +message MsgCreateBucketResponse {} + +message MsgDeleteBucket { + option (cosmos.msg.v1.signer) = "operator"; + // creator is the account address of the grantee who has the DeleteBucket permission of the bucket to be deleted. + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is the name of the bucket to be deleted. + string bucket_name = 2; +} + +message MsgDeleteBucketResponse {} + +message MsgCreateObject { + option (cosmos.msg.v1.signer) = "creator"; + // creator is the account address of object uploader + string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is the name of the bucket where the object is stored. + string bucket_name = 2; + // object_name is the name of object + string object_name = 3; + // payload_size is size of the object's payload + uint64 payload_size = 4; + // is_public means the bucket is private or public. if private, only bucket owner or grantee can access it, + // otherwise every greenfield user can access it. + bool is_public = 5; + // content_type is a standard MIME type describing the format of the object. + string content_type = 6; + // primary_sp_approval_signature is the signature of the primary SP with its signature + // which indicates that primary sp confirm the user's creation request. + bytes primary_sp_approval_signature = 7; + // expect_checksums is a list of hashes which was generate by redundancy algorithm. + repeated bytes expect_checksums = 8; + // expect_secondarySPs is a list of StorageProvider address, which is optional + repeated string expect_secondary_sp_addresses = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgCreateObjectResponse {} + +message MsgSealObject { + option (cosmos.msg.v1.signer) = "operator"; + // operator is the account address of primary SP + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is the name of the bucket where the object is stored. + string bucket_name = 2; + // object_name is the name of object to be sealed. + string object_name = 3; + // secondary_sp_addresses is a list of storage provider which store the redundant data. + repeated string secondary_sp_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // secondary_sp_signatures is the signature of the secondary sp that can + // acknowledge that the payload data has received and stored. + repeated bytes secondary_sp_signatures = 5; +} + +message MsgSealObjectResponse {} + +message MsgRejectSealObject { + option (cosmos.msg.v1.signer) = "operator"; + // operator is the account address of the object owner + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is the name of the bucket where the object is stored. + string bucket_name = 2; + // object_name is the name of unsealed object to be reject. + string object_name = 3; +} + +message MsgRejectSealObjectResponse {} + +message MsgCopyObject { + option (cosmos.msg.v1.signer) = "operator"; + // operator is the account address of the operator who has the CopyObject permission of the object to be deleted. + string operator = 1; + // src_bucket_name is the name of the bucket where the object to be copied is located + string src_bucket_name = 2; + // dst_bucket_name is the name of the bucket where the object is copied to. + string dst_bucket_name = 3; + // src_object_name is the name of the object which to be copied + string src_object_name = 4; + // dst_object_name is the name of the object which is copied to + string dst_object_name = 5; + // dst_primary_sp_approval_signature is a approval signature of primary sp + bytes dst_primary_sp_approval_signature = 6; +} + +message MsgCopyObjectResponse {} + +message MsgDeleteObject { + option (cosmos.msg.v1.signer) = "operator"; + // operator is the account address of the operator who has the DeleteObject permission of the object to be deleted. + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is the name of the bucket where the object which to be deleted is stored. + string bucket_name = 2; + // object_name is the name of the object which to be deleted. + string object_name = 3; +} + +message MsgDeleteObjectResponse {} + +message MsgCreateGroup { + option (cosmos.msg.v1.signer) = "creator"; + // owner is the account address of group owner who create the group + string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_name is the name of the group. it's not globally unique. + string group_name = 2; + // member_request is a list of member which to be add or remove + repeated string members = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgCreateGroupResponse {} + +message MsgDeleteGroup { + option (cosmos.msg.v1.signer) = "operator"; + // operator is the account address of the operator who has the DeleteGroup permission of the group to be deleted. + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_name is the name of the group which to be deleted + string group_name = 2; +} + +message MsgDeleteGroupResponse {} + +message MsgUpdateGroupMember { + option (cosmos.msg.v1.signer) = "operator"; + // operator is the account address of the operator who has the UpdateGroupMember permission of the group. + string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_name is the name of the group which to be updated + string group_name = 2; + // members_to_add is a list of members account address which will be add to the group + repeated string members_to_add = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // members_to_delete is a list of members account address which will be remove from the group + repeated string members_to_delete = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgUpdateGroupMemberResponse {} + +message MsgLeaveGroup { + option (cosmos.msg.v1.signer) = "member"; + // member is the account address of the member who want to leave the group + string member = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_owner is the owner of the group you want to leave + string group_owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_name is the name of the group you want to leave + string group_name = 3; +} + +message MsgLeaveGroupResponse {} + +// this line is used by starport scaffolding # proto/tx/message diff --git a/proto/greenfield/storage/types.proto b/proto/greenfield/storage/types.proto new file mode 100644 index 000000000..2a657efb6 --- /dev/null +++ b/proto/greenfield/storage/types.proto @@ -0,0 +1,108 @@ +syntax = "proto3"; +package bnbchain.greenfield.storage; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "greenfield/storage/common.proto"; + +option go_package = "github.com/bnb-chain/greenfield/x/storage/types"; + +enum ReadQuota { + option (gogoproto.goproto_enum_prefix) = false; + + READ_QUOTA_FREE = 0; +} + +message BucketInfo { + // owner is the account address of bucket creator, it is also the bucket owner. + string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is a globally unique name of bucket + string bucket_name = 2; + // is_public define the highest permissions for bucket. When the bucket is public, everyone can get the object in it. + bool is_public = 3; + // id is the unique identification for bucket. + string id = 4 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; + // create_at define the block number when the bucket created. + int64 create_at = 5; + // payment_address is the address of the payment account + string payment_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // primary_sp_address is the address of the primary sp. Objects belongs to this bucket will never + // leave this SP, unless you explicitly shift them to another SP. + string primary_sp_address = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // read_quota defines the traffic quota for read + ReadQuota read_quota = 8; +} + +enum RedundancyType { + option (gogoproto.goproto_enum_prefix) = false; + + REDUNDANCY_REPLICA_TYPE = 0; + REDUNDANCY_EC_TYPE = 1; + REDUNDANCY_INLINE_TYPE = 2; +} + +enum ObjectStatus { + option (gogoproto.goproto_enum_prefix) = false; + + OBJECT_STATUS_INIT = 0; + OBJECT_STATUS_IN_SERVICE = 1; +} + +message ObjectInfo { + string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // bucket_name is the name of the bucket + string bucket_name = 2; + // object_name is the name of object + string object_name = 3; + // id is the unique identifier of object + string id = 4 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; + // payloadSize is the total size of the object payload + uint64 payload_size = 5; + // is_public define the highest permissions for object. When the object is public, everyone can access it. + bool is_public = 6; + // content_type define the format of the object which should be a standard MIME type. + string content_type = 7; + // create_at define the block number when the object created + int64 create_at = 8; + // object_status define the upload status of the object. + ObjectStatus object_status = 9; + // redundancy_type define the type of the redundancy which can be multi-replication or EC. + RedundancyType redundancy_type = 10; + // source_type define the source of the object. + SourceType source_type = 11; + // checksums define the root hash of the pieces which stored in a SP. + repeated bytes checksums = 12; + // secondary_sp_addresses define the addresses of secondary_sps + repeated string secondary_sp_addresses = 13 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message GroupInfo { + // owner is the owner of the group. It can not changed once it created. + string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // group_name is the name of group which is unique under an account. + string group_name = 2; + // id is the unique identifier of group + string id = 3 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; +} + +message GroupMemberInfo { + string member = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string id = 2 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; + uint64 expire_time = 3; +} diff --git a/testutil/keeper/bridge.go b/testutil/keeper/bridge.go index a7a0c8ff1..12b64a038 100644 --- a/testutil/keeper/bridge.go +++ b/testutil/keeper/bridge.go @@ -3,10 +3,6 @@ package keeper import ( "testing" - "github.com/bnb-chain/greenfield/app" - "github.com/bnb-chain/greenfield/x/bridge/keeper" - "github.com/bnb-chain/greenfield/x/bridge/types" - greenfieldmoduletypes "github.com/bnb-chain/greenfield/x/greenfield/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" @@ -44,6 +40,11 @@ import ( "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" + + "github.com/bnb-chain/greenfield/app" + "github.com/bnb-chain/greenfield/x/bridge/keeper" + "github.com/bnb-chain/greenfield/x/bridge/types" + storagemoduletypes "github.com/bnb-chain/greenfield/x/storage/types" ) var ( @@ -77,10 +78,9 @@ func BridgeKeeper(t testing.TB) (*BridgeKeeperSuite, *keeper.Keeper, sdk.Context paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, - greenfieldmoduletypes.StoreKey, + storagemoduletypes.StoreKey, crosschaintypes.StoreKey, oracletypes.StoreKey, - types.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -212,7 +212,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) - paramsKeeper.Subspace(greenfieldmoduletypes.ModuleName) + paramsKeeper.Subspace(storagemoduletypes.ModuleName) paramsKeeper.Subspace(crosschaintypes.ModuleName) paramsKeeper.Subspace(oracletypes.ModuleName) paramsKeeper.Subspace(types.ModuleName) diff --git a/testutil/keeper/greenfield.go b/testutil/keeper/greenfield.go deleted file mode 100644 index f582a6603..000000000 --- a/testutil/keeper/greenfield.go +++ /dev/null @@ -1,52 +0,0 @@ -package keeper - -import ( - "testing" - - "github.com/bnb-chain/greenfield/x/greenfield/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/types" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/log" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmdb "github.com/tendermint/tm-db" -) - -func GreenfieldKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { - storeKey := sdk.NewKVStoreKey(types.StoreKey) - memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) - - db := tmdb.NewMemDB() - stateStore := store.NewCommitMultiStore(db) - stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) - stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) - - registry := codectypes.NewInterfaceRegistry() - cdc := codec.NewProtoCodec(registry) - - paramsSubspace := typesparams.NewSubspace(cdc, - types.Amino, - storeKey, - memStoreKey, - "GreenfieldParams", - ) - k := keeper.NewKeeper( - cdc, - storeKey, - memStoreKey, - paramsSubspace, - ) - - ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil, log.NewNopLogger()) - - // Initialize params - k.SetParams(ctx, types.DefaultParams()) - - return k, ctx -} diff --git a/testutil/keeper/sp.go b/testutil/keeper/sp.go index d6d3f98f4..f01acfecc 100644 --- a/testutil/keeper/sp.go +++ b/testutil/keeper/sp.go @@ -3,9 +3,6 @@ package keeper import ( "testing" - greenfieldmoduletypes "github.com/bnb-chain/greenfield/x/greenfield/types" - "github.com/bnb-chain/greenfield/x/sp/keeper" - "github.com/bnb-chain/greenfield/x/sp/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -40,16 +37,18 @@ import ( "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" + + "github.com/bnb-chain/greenfield/x/sp/keeper" + "github.com/bnb-chain/greenfield/x/sp/types" + storagemoduletypes "github.com/bnb-chain/greenfield/x/storage/types" ) var ( spMaccPerms = map[string][]string{ authtypes.FeeCollectorName: {authtypes.Minter, authtypes.Staking}, - distrtypes.ModuleName: nil, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, - crosschaintypes.ModuleName: {authtypes.Minter}, types.ModuleName: {authtypes.Staking}, } ) @@ -60,7 +59,7 @@ func SpKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, - greenfieldmoduletypes.StoreKey, + storagemoduletypes.StoreKey, crosschaintypes.StoreKey, oracletypes.StoreKey, types.StoreKey) @@ -143,13 +142,6 @@ func SpKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { if err != nil { panic("mint coins error") } - err = bankKeeper.MintCoins(ctx, crosschaintypes.ModuleName, sdk.Coins{sdk.Coin{ - Denom: "stake", - Amount: sdk.NewInt(1000000000), - }}) - if err != nil { - panic("mint coins error") - } return k, ctx } diff --git a/testutil/keeper/storage.go b/testutil/keeper/storage.go new file mode 100644 index 000000000..5f9a2460f --- /dev/null +++ b/testutil/keeper/storage.go @@ -0,0 +1,162 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" + 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" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/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" + "github.com/cosmos/cosmos-sdk/x/group" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + oracletypes "github.com/cosmos/cosmos-sdk/x/oracle/types" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + typesparams "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" + icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types" + ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" + ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" + + spkeeper "github.com/bnb-chain/greenfield/x/sp/keeper" + sptypes "github.com/bnb-chain/greenfield/x/sp/types" + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +var ( + storageMaccPerms = map[string][]string{ + authtypes.FeeCollectorName: {authtypes.Minter, authtypes.Staking}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + sptypes.ModuleName: {authtypes.Staking}, + types.ModuleName: {authtypes.Staking}, + } +) + +func StorageKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKeys := sdk.NewKVStoreKeys(authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, + minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, + paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, + ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, + icacontrollertypes.StoreKey, + crosschaintypes.StoreKey, + oracletypes.StoreKey, types.StoreKey) + + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + + storeKey := sdk.NewKVStoreKey(types.StoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + + stateStore.MountStoreWithDB(storeKeys[paramstypes.StoreKey], storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(storeKeys[authtypes.StoreKey], storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(storeKeys[banktypes.StoreKey], storetypes.StoreTypeIAVL, db) + + stateStore.MountStoreWithDB(tkeys[paramstypes.TStoreKey], storetypes.StoreTypeTransient, nil) + + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramKeeper := paramskeeper.NewKeeper(cdc, types.Amino, storeKeys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + + paramKeeper.Subspace(authtypes.ModuleName) + paramKeeper.Subspace(banktypes.ModuleName) + paramKeeper.Subspace(authz.ModuleName) + paramKeeper.Subspace(sptypes.ModuleName) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "StorageParams", + ) + + accountKeeper := authkeeper.NewAccountKeeper( + cdc, + storeKeys[authtypes.StoreKey], + GetSubspace(paramKeeper, authtypes.ModuleName), + authtypes.ProtoBaseAccount, + storageMaccPerms, + ) + + authzKeeper := authzkeeper.NewKeeper( + storeKeys[authz.ModuleName], + cdc, + baseapp.NewMsgServiceRouter(), + accountKeeper, + ) + + bankKeeper := bankkeeper.NewBaseKeeper( + cdc, + storeKeys[banktypes.StoreKey], + accountKeeper, + GetSubspace(paramKeeper, banktypes.ModuleName), + nil, + ) + + spKeeper := spkeeper.NewKeeper( + cdc, + storeKeys[sptypes.ModuleName], + storeKeys[sptypes.MemStoreKey], + GetSubspace(paramKeeper, sptypes.ModuleName), + accountKeeper, + bankKeeper, + authzKeeper, + ) + + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + spKeeper, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + accountKeeper.SetParams(ctx, authtypes.DefaultParams()) + spKeeper.SetParams(ctx, sptypes.DefaultParams()) + + err := bankKeeper.MintCoins(ctx, authtypes.FeeCollectorName, sdk.Coins{sdk.Coin{ + Denom: "stake", + Amount: sdk.NewInt(1000000000), + }}) + if err != nil { + panic("mint coins error") + } + + return k, ctx +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 98f2153ed..ec9396dbf 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -1,6 +1,8 @@ package sample import ( + "math/rand" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -11,3 +13,13 @@ func AccAddress() string { addr := pk.Address() return sdk.AccAddress(addr).String() } + +func Checksum() []byte { + return sdk.Keccak256(RandStr(256)) +} + +func RandStr(length int) []byte { + randBytes := make([]byte, length/2) + rand.Read(randBytes) + return randBytes +} diff --git a/x/bridge/client/cli/query.go b/x/bridge/client/cli/query.go index edee1b919..f15f54f23 100644 --- a/x/bridge/client/cli/query.go +++ b/x/bridge/client/cli/query.go @@ -2,13 +2,9 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" "github.com/bnb-chain/greenfield/x/bridge/types" ) diff --git a/x/bridge/client/cli/query_params.go b/x/bridge/client/cli/query_params.go index cd874856e..6e9dfb222 100644 --- a/x/bridge/client/cli/query_params.go +++ b/x/bridge/client/cli/query_params.go @@ -3,10 +3,11 @@ package cli import ( "context" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/bridge/client/cli/tx.go b/x/bridge/client/cli/tx.go index 96fc41262..3bc52b97e 100644 --- a/x/bridge/client/cli/tx.go +++ b/x/bridge/client/cli/tx.go @@ -3,10 +3,9 @@ package cli import ( "fmt" + "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/bnb-chain/greenfield/x/bridge/types" ) diff --git a/x/bridge/client/cli/tx_transfer_out.go b/x/bridge/client/cli/tx_transfer_out.go index ce75d511f..3895e6132 100644 --- a/x/bridge/client/cli/tx_transfer_out.go +++ b/x/bridge/client/cli/tx_transfer_out.go @@ -3,12 +3,13 @@ package cli import ( "strconv" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) var _ = strconv.Itoa(0) diff --git a/x/bridge/genesis.go b/x/bridge/genesis.go index bcd9d1684..9e50d6d10 100644 --- a/x/bridge/genesis.go +++ b/x/bridge/genesis.go @@ -1,9 +1,10 @@ package bridge import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/bnb-chain/greenfield/x/bridge/keeper" "github.com/bnb-chain/greenfield/x/bridge/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/bridge/keeper/cross_app.go b/x/bridge/keeper/cross_app.go index 61f35131c..08236ac4b 100644 --- a/x/bridge/keeper/cross_app.go +++ b/x/bridge/keeper/cross_app.go @@ -5,10 +5,11 @@ import ( "math/big" "cosmossdk.io/errors" - "github.com/bnb-chain/greenfield/x/bridge/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/types" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) func RegisterCrossApps(keeper Keeper) { diff --git a/x/bridge/keeper/cross_app_test.go b/x/bridge/keeper/cross_app_test.go index df9728e81..60e6b7bac 100644 --- a/x/bridge/keeper/cross_app_test.go +++ b/x/bridge/keeper/cross_app_test.go @@ -5,15 +5,16 @@ import ( "math/big" "testing" - keepertest "github.com/bnb-chain/greenfield/testutil/keeper" - "github.com/bnb-chain/greenfield/x/bridge/keeper" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/bsc/rlp" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/types" "github.com/stretchr/testify/require" + + keepertest "github.com/bnb-chain/greenfield/testutil/keeper" + "github.com/bnb-chain/greenfield/x/bridge/keeper" + "github.com/bnb-chain/greenfield/x/bridge/types" ) func TestTransferOutCheck(t *testing.T) { diff --git a/x/bridge/keeper/grpc_query_params.go b/x/bridge/keeper/grpc_query_params.go index fcd9fffe5..7a50ab6de 100644 --- a/x/bridge/keeper/grpc_query_params.go +++ b/x/bridge/keeper/grpc_query_params.go @@ -3,10 +3,11 @@ package keeper import ( "context" - "github.com/bnb-chain/greenfield/x/bridge/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/bridge/keeper/keeper.go b/x/bridge/keeper/keeper.go index 54f77b6df..28df0d435 100644 --- a/x/bridge/keeper/keeper.go +++ b/x/bridge/keeper/keeper.go @@ -4,13 +4,14 @@ import ( "fmt" "cosmossdk.io/errors" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/bsc/rlp" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) type ( diff --git a/x/bridge/keeper/msg_server_test.go b/x/bridge/keeper/msg_server_test.go index afd0ce726..8a04a8692 100644 --- a/x/bridge/keeper/msg_server_test.go +++ b/x/bridge/keeper/msg_server_test.go @@ -3,14 +3,15 @@ package keeper_test import ( "testing" - keepertest "github.com/bnb-chain/greenfield/testutil/keeper" - "github.com/bnb-chain/greenfield/x/bridge/keeper" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" types2 "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" + + keepertest "github.com/bnb-chain/greenfield/testutil/keeper" + "github.com/bnb-chain/greenfield/x/bridge/keeper" + "github.com/bnb-chain/greenfield/x/bridge/types" ) func TestCrossTransferOut(t *testing.T) { diff --git a/x/bridge/keeper/msg_server_transfer_out.go b/x/bridge/keeper/msg_server_transfer_out.go index 6fe754f93..12fa42416 100644 --- a/x/bridge/keeper/msg_server_transfer_out.go +++ b/x/bridge/keeper/msg_server_transfer_out.go @@ -5,10 +5,11 @@ import ( "math/big" "cosmossdk.io/errors" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/bsc/rlp" sdk "github.com/cosmos/cosmos-sdk/types" crosschaintypes "github.com/cosmos/cosmos-sdk/x/crosschain/types" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) func (k msgServer) TransferOut(goCtx context.Context, msg *types.MsgTransferOut) (*types.MsgTransferOutResponse, error) { diff --git a/x/bridge/keeper/params.go b/x/bridge/keeper/params.go index 91f2704ef..a70208e96 100644 --- a/x/bridge/keeper/params.go +++ b/x/bridge/keeper/params.go @@ -4,8 +4,9 @@ import ( "fmt" "math/big" - "github.com/bnb-chain/greenfield/x/bridge/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) // GetParams get all parameters as types.Params diff --git a/x/bridge/module.go b/x/bridge/module.go index 2538844f5..f0df6d79b 100644 --- a/x/bridge/module.go +++ b/x/bridge/module.go @@ -4,21 +4,19 @@ import ( "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 + "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" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/bnb-chain/greenfield/x/bridge/client/cli" "github.com/bnb-chain/greenfield/x/bridge/keeper" "github.com/bnb-chain/greenfield/x/bridge/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" - "github.com/cosmos/cosmos-sdk/types/module" ) var ( diff --git a/x/bridge/module_simulation.go b/x/bridge/module_simulation.go index f14345f55..326b3f859 100644 --- a/x/bridge/module_simulation.go +++ b/x/bridge/module_simulation.go @@ -3,15 +3,16 @@ package bridge import ( "math/rand" - "github.com/bnb-chain/greenfield/testutil/sample" - bridgesimulation "github.com/bnb-chain/greenfield/x/bridge/simulation" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/baseapp" 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" "github.com/cosmos/cosmos-sdk/x/simulation" + + "github.com/bnb-chain/greenfield/testutil/sample" + bridgesimulation "github.com/bnb-chain/greenfield/x/bridge/simulation" + "github.com/bnb-chain/greenfield/x/bridge/types" ) // avoid unused import issue diff --git a/x/bridge/simulation/transfer_out.go b/x/bridge/simulation/transfer_out.go index 716a33102..e41de719c 100644 --- a/x/bridge/simulation/transfer_out.go +++ b/x/bridge/simulation/transfer_out.go @@ -3,11 +3,12 @@ package simulation import ( "math/rand" - "github.com/bnb-chain/greenfield/x/bridge/keeper" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/bnb-chain/greenfield/x/bridge/keeper" + "github.com/bnb-chain/greenfield/x/bridge/types" ) func SimulateMsgTransferOut( diff --git a/x/bridge/types/errors.go b/x/bridge/types/errors.go index 7dc3a33a8..2a38c09d1 100644 --- a/x/bridge/types/errors.go +++ b/x/bridge/types/errors.go @@ -1,7 +1,5 @@ package types -// DONTCOVER - import ( "cosmossdk.io/errors" ) diff --git a/x/bridge/types/genesis_test.go b/x/bridge/types/genesis_test.go index 90734979e..118bfcfaf 100644 --- a/x/bridge/types/genesis_test.go +++ b/x/bridge/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/bnb-chain/greenfield/x/bridge/types" "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/bridge/types/message_transfer_out_test.go b/x/bridge/types/message_transfer_out_test.go index f82af3dde..97ed5bf8f 100644 --- a/x/bridge/types/message_transfer_out_test.go +++ b/x/bridge/types/message_transfer_out_test.go @@ -3,10 +3,11 @@ package types import ( "testing" - "github.com/bnb-chain/greenfield/testutil/sample" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" ) func TestMsgTransferOut_ValidateBasic(t *testing.T) { diff --git a/x/greenfield/client/cli/query.go b/x/greenfield/client/cli/query.go deleted file mode 100644 index 26c63bca9..000000000 --- a/x/greenfield/client/cli/query.go +++ /dev/null @@ -1,31 +0,0 @@ -package cli - -import ( - "fmt" - // "strings" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bnb-chain/greenfield/x/greenfield/types" -) - -// GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { - // Group greenfield 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(CmdQueryParams()) - // this line is used by starport scaffolding # 1 - - return cmd -} diff --git a/x/greenfield/client/cli/tx.go b/x/greenfield/client/cli/tx.go deleted file mode 100644 index 75abe0725..000000000 --- a/x/greenfield/client/cli/tx.go +++ /dev/null @@ -1,31 +0,0 @@ -package cli - -import ( - "fmt" - "time" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/bnb-chain/greenfield/x/greenfield/types" -) - -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -) - -// GetTxCmd returns the transaction commands for this module -func GetTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: types.ModuleName, - Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - // this line is used by starport scaffolding # 1 - - return cmd -} diff --git a/x/greenfield/keeper/keeper.go b/x/greenfield/keeper/keeper.go deleted file mode 100644 index 15e8cf658..000000000 --- a/x/greenfield/keeper/keeper.go +++ /dev/null @@ -1,46 +0,0 @@ -package keeper - -import ( - "fmt" - - "github.com/bnb-chain/greenfield/x/greenfield/types" - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/tendermint/tendermint/libs/log" -) - -type ( - Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace - } -) - -func NewKeeper( - cdc codec.BinaryCodec, - storeKey, - memKey storetypes.StoreKey, - ps paramtypes.Subspace, - -) *Keeper { - // set KeyTable if it has not already been set - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } - - return &Keeper{ - - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - } -} - -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} diff --git a/x/greenfield/keeper/msg_server.go b/x/greenfield/keeper/msg_server.go deleted file mode 100644 index 4cdaf2b7b..000000000 --- a/x/greenfield/keeper/msg_server.go +++ /dev/null @@ -1,17 +0,0 @@ -package keeper - -import ( - "github.com/bnb-chain/greenfield/x/greenfield/types" -) - -type msgServer struct { - Keeper -} - -// NewMsgServerImpl returns an implementation of the MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} - -var _ types.MsgServer = msgServer{} diff --git a/x/greenfield/keeper/params.go b/x/greenfield/keeper/params.go deleted file mode 100644 index 6d331cb8d..000000000 --- a/x/greenfield/keeper/params.go +++ /dev/null @@ -1,16 +0,0 @@ -package keeper - -import ( - "github.com/bnb-chain/greenfield/x/greenfield/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams() -} - -// SetParams set the params -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) -} diff --git a/x/greenfield/module_simulation.go b/x/greenfield/module_simulation.go deleted file mode 100644 index 8fd8d6d47..000000000 --- a/x/greenfield/module_simulation.go +++ /dev/null @@ -1,64 +0,0 @@ -package greenfield - -import ( - "math/rand" - - "github.com/bnb-chain/greenfield/testutil/sample" - greenfieldsimulation "github.com/bnb-chain/greenfield/x/greenfield/simulation" - "github.com/bnb-chain/greenfield/x/greenfield/types" - "github.com/cosmos/cosmos-sdk/baseapp" - 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" - "github.com/cosmos/cosmos-sdk/x/simulation" -) - -// avoid unused import issue -var ( - _ = sample.AccAddress - _ = greenfieldsimulation.FindAccount - _ = simappparams.StakePerAccount - _ = simulation.MsgEntryKind - _ = baseapp.Paramspace -) - -const ( -// this line is used by starport scaffolding # simapp/module/const -) - -// GenerateGenesisState creates a randomized GenState of the module -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - accs := make([]string, len(simState.Accounts)) - for i, acc := range simState.Accounts { - accs[i] = acc.Address.String() - } - greenfieldGenesis := types.GenesisState{ - Params: types.DefaultParams(), - // this line is used by starport scaffolding # simapp/module/genesisState - } - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&greenfieldGenesis) -} - -// ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - -// RandomizedParams creates randomized param changes for the simulator -func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { - - return []simtypes.ParamChange{} -} - -// RegisterStoreDecoder registers a decoder -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} - -// WeightedOperations returns the all the gov module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - operations := make([]simtypes.WeightedOperation, 0) - - // this line is used by starport scaffolding # simapp/module/operation - - return operations -} diff --git a/x/greenfield/types/codec.go b/x/greenfield/types/codec.go deleted file mode 100644 index 844157a87..000000000 --- a/x/greenfield/types/codec.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - // this line is used by starport scaffolding # 1 - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -func RegisterCodec(cdc *codec.LegacyAmino) { - // this line is used by starport scaffolding # 2 -} - -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // this line is used by starport scaffolding # 3 - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -var ( - Amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) -) diff --git a/x/greenfield/types/errors.go b/x/greenfield/types/errors.go deleted file mode 100644 index b0ebd28bc..000000000 --- a/x/greenfield/types/errors.go +++ /dev/null @@ -1,12 +0,0 @@ -package types - -// DONTCOVER - -import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// x/greenfield module sentinel errors -var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") -) diff --git a/x/greenfield/types/keys.go b/x/greenfield/types/keys.go deleted file mode 100644 index f2180d762..000000000 --- a/x/greenfield/types/keys.go +++ /dev/null @@ -1,19 +0,0 @@ -package types - -const ( - // ModuleName defines the module name - ModuleName = "greenfield" - - // StoreKey defines the primary module store key - StoreKey = ModuleName - - // RouterKey defines the module's message routing key - RouterKey = ModuleName - - // MemStoreKey defines the in-memory store key - MemStoreKey = "mem_greenfield" -) - -func KeyPrefix(p string) []byte { - return []byte(p) -} diff --git a/x/greenfield/types/params.go b/x/greenfield/types/params.go deleted file mode 100644 index 357196ad6..000000000 --- a/x/greenfield/types/params.go +++ /dev/null @@ -1,39 +0,0 @@ -package types - -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "gopkg.in/yaml.v2" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// NewParams creates a new Params instance -func NewParams() Params { - return Params{} -} - -// DefaultParams returns a default set of parameters -func DefaultParams() Params { - return NewParams() -} - -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - -// Validate validates the set of params -func (p Params) Validate() error { - return nil -} - -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} diff --git a/x/greenfield/types/params.pb.go b/x/greenfield/types/params.pb.go deleted file mode 100644 index a49c1a3d1..000000000 --- a/x/greenfield/types/params.pb.go +++ /dev/null @@ -1,266 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: greenfield/greenfield/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/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 - -// Params defines the parameters for the module. -type Params struct { -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_6e2d96768394e060, []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 - -func init() { - proto.RegisterType((*Params)(nil), "greenfield.greenfield.Params") -} - -func init() { - proto.RegisterFile("greenfield/greenfield/params.proto", fileDescriptor_6e2d96768394e060) -} - -var fileDescriptor_6e2d96768394e060 = []byte{ - // 148 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0x2f, 0x4a, 0x4d, - 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x47, 0x62, 0x16, 0x24, 0x16, 0x25, 0xe6, 0x16, 0xeb, - 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x89, 0x22, 0x24, 0xf4, 0x10, 0x4c, 0x29, 0x91, 0xf4, 0xfc, - 0xf4, 0x7c, 0xb0, 0x0a, 0x7d, 0x10, 0x0b, 0xa2, 0x58, 0x89, 0x8f, 0x8b, 0x2d, 0x00, 0xac, 0xd9, - 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x27, 0x9f, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, - 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, - 0x63, 0x88, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xca, - 0x4b, 0xd2, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0x43, 0x76, 0x44, 0x05, 0x32, 0xa7, 0xa4, 0xb2, 0x20, - 0xb5, 0x38, 0x89, 0x0d, 0x6c, 0x89, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x39, 0x14, 0x40, 0x86, - 0xb7, 0x00, 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 - 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 - 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 { - 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/greenfield/types/query.pb.go b/x/greenfield/types/query.pb.go deleted file mode 100644 index d54212591..000000000 --- a/x/greenfield/types/query.pb.go +++ /dev/null @@ -1,537 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: greenfield/greenfield/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/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 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_582bebb26ab007f4, []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 response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params holds all the parameters of this 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_582bebb26ab007f4, []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{} -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.greenfield.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.greenfield.QueryParamsResponse") -} - -func init() { proto.RegisterFile("greenfield/greenfield/query.proto", fileDescriptor_582bebb26ab007f4) } - -var fileDescriptor_582bebb26ab007f4 = []byte{ - // 299 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x50, 0x31, 0x4b, 0x03, 0x31, - 0x18, 0xbd, 0x88, 0x76, 0x88, 0x5b, 0xac, 0x20, 0xc5, 0xa6, 0x7a, 0x20, 0x68, 0xc1, 0x0b, 0xad, - 0xa3, 0x5b, 0x67, 0x07, 0xed, 0xe8, 0x96, 0xd4, 0x98, 0x06, 0xda, 0x7c, 0xe9, 0x25, 0x15, 0xbb, - 0x3a, 0x38, 0x17, 0xfc, 0x53, 0x1d, 0x0b, 0x2e, 0x4e, 0x22, 0x77, 0xfe, 0x10, 0xe9, 0xe5, 0xa0, - 0x27, 0x56, 0x71, 0x7b, 0x79, 0x79, 0xef, 0xe5, 0xe5, 0xe1, 0x63, 0x95, 0x4a, 0x69, 0xee, 0xb5, - 0x1c, 0xdd, 0xb1, 0x0a, 0x9c, 0x4c, 0x65, 0x3a, 0x4b, 0x6c, 0x0a, 0x1e, 0xc8, 0xfe, 0x9a, 0x4f, - 0xd6, 0xb0, 0xd1, 0x1e, 0x80, 0x1b, 0x83, 0x63, 0x82, 0x3b, 0x19, 0xf4, 0xec, 0xa1, 0x23, 0xa4, - 0xe7, 0x1d, 0x66, 0xb9, 0xd2, 0x86, 0x7b, 0x0d, 0x26, 0x44, 0x34, 0xea, 0x0a, 0x14, 0x14, 0x90, - 0xad, 0x50, 0xc9, 0x1e, 0x2a, 0x00, 0x35, 0x92, 0x8c, 0x5b, 0xcd, 0xb8, 0x31, 0xe0, 0x0b, 0x8b, - 0x2b, 0x6f, 0xe3, 0xcd, 0xcd, 0x2c, 0x4f, 0xf9, 0xb8, 0xd4, 0xc4, 0x75, 0x4c, 0x6e, 0x56, 0x2f, - 0x5f, 0x17, 0x64, 0x5f, 0x4e, 0xa6, 0xd2, 0xf9, 0xb8, 0x8f, 0xf7, 0xbe, 0xb1, 0xce, 0x82, 0x71, - 0x92, 0x5c, 0xe2, 0x5a, 0x30, 0x1f, 0xa0, 0x23, 0x74, 0xba, 0xdb, 0x6d, 0x26, 0x1b, 0x3f, 0x96, - 0x04, 0x5b, 0x6f, 0x7b, 0xf1, 0xde, 0x8a, 0xfa, 0xa5, 0xa5, 0x3b, 0x47, 0x78, 0xa7, 0x08, 0x25, - 0xcf, 0x08, 0xd7, 0x82, 0x84, 0x9c, 0xfd, 0x92, 0xf0, 0xb3, 0x53, 0xa3, 0xfd, 0x1f, 0x69, 0x28, - 0x1a, 0x9f, 0x3c, 0xbd, 0x7e, 0xbe, 0x6c, 0xb5, 0x48, 0x93, 0xfd, 0x35, 0x41, 0xef, 0x6a, 0x91, - 0x51, 0xb4, 0xcc, 0x28, 0xfa, 0xc8, 0x28, 0x9a, 0xe7, 0x34, 0x5a, 0xe6, 0x34, 0x7a, 0xcb, 0x69, - 0x74, 0xdb, 0x55, 0xda, 0x0f, 0xa7, 0x22, 0x19, 0xc0, 0x98, 0x09, 0x23, 0xce, 0x07, 0x43, 0xae, - 0x4d, 0x35, 0xe1, 0xb1, 0x7a, 0xf0, 0x33, 0x2b, 0x9d, 0xa8, 0x15, 0x8b, 0x5e, 0x7c, 0x05, 0x00, - 0x00, 0xff, 0xff, 0x14, 0xc9, 0x60, 0xd5, 0x11, 0x02, 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 { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, 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, "/greenfield.greenfield.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, 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 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: "/greenfield.greenfield.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "greenfield.greenfield.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "greenfield/greenfield/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 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 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 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/greenfield/types/query.pb.gw.go b/x/greenfield/types/query.pb.gw.go deleted file mode 100644 index b4de97b4a..000000000 --- a/x/greenfield/types/query.pb.gw.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: greenfield/greenfield/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 - -} - -// 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()...) - - }) - - 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()...) - - }) - - return nil -} - -var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 0, 2, 1}, []string{"greenfield", "params"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage -) diff --git a/x/greenfield/types/tx.pb.go b/x/greenfield/types/tx.pb.go deleted file mode 100644 index 0f60ef81c..000000000 --- a/x/greenfield/types/tx.pb.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: greenfield/greenfield/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - math "math" -) - -// 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 - -func init() { proto.RegisterFile("greenfield/greenfield/tx.proto", fileDescriptor_c88d5bd7e914fd2c) } - -var fileDescriptor_c88d5bd7e914fd2c = []byte{ - // 125 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0x2f, 0x4a, 0x4d, - 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x47, 0x62, 0x96, 0x54, 0xe8, 0x15, 0x14, 0xe5, 0x97, - 0xe4, 0x0b, 0x89, 0x22, 0x04, 0xf5, 0x10, 0x4c, 0x23, 0x56, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0x27, - 0x9f, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, - 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xca, 0x4b, 0xd2, 0x4d, 0xce, 0x48, 0xcc, 0xcc, - 0x43, 0xb6, 0xa1, 0x02, 0xc5, 0xba, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x95, 0xc6, 0x80, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x61, 0xf4, 0x25, 0xf2, 0x94, 0x00, 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 { -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "greenfield.greenfield.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "greenfield/greenfield/tx.proto", -} diff --git a/x/greenfield/types/types.go b/x/greenfield/types/types.go deleted file mode 100644 index ab1254f4c..000000000 --- a/x/greenfield/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types diff --git a/x/sp/client/cli/query.go b/x/sp/client/cli/query.go index 7bc6882bf..0d40b10a2 100644 --- a/x/sp/client/cli/query.go +++ b/x/sp/client/cli/query.go @@ -2,13 +2,11 @@ package cli import ( "fmt" - // "strings" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - // sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/bnb-chain/greenfield/x/sp/types" ) diff --git a/x/sp/client/cli/query_params.go b/x/sp/client/cli/query_params.go index 24b712160..ade73c071 100644 --- a/x/sp/client/cli/query_params.go +++ b/x/sp/client/cli/query_params.go @@ -3,10 +3,11 @@ package cli import ( "context" - "github.com/bnb-chain/greenfield/x/sp/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/sp/client/cli/tx.go b/x/sp/client/cli/tx.go index 1d9977763..622ebd658 100644 --- a/x/sp/client/cli/tx.go +++ b/x/sp/client/cli/tx.go @@ -4,16 +4,14 @@ import ( "fmt" "time" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" types2 "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" + "github.com/spf13/cobra" - // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/bnb-chain/greenfield/x/sp/types" ) diff --git a/x/sp/genesis.go b/x/sp/genesis.go index b51787f50..995a1948b 100644 --- a/x/sp/genesis.go +++ b/x/sp/genesis.go @@ -1,9 +1,10 @@ package sp import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/bnb-chain/greenfield/x/sp/keeper" "github.com/bnb-chain/greenfield/x/sp/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/sp/genesis_test.go b/x/sp/genesis_test.go index 53bf6f803..d48400812 100644 --- a/x/sp/genesis_test.go +++ b/x/sp/genesis_test.go @@ -3,11 +3,12 @@ package sp_test import ( "testing" + "github.com/stretchr/testify/require" + keepertest "github.com/bnb-chain/greenfield/testutil/keeper" "github.com/bnb-chain/greenfield/testutil/nullify" "github.com/bnb-chain/greenfield/x/sp" "github.com/bnb-chain/greenfield/x/sp/types" - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { diff --git a/x/sp/keeper/genesis.go b/x/sp/keeper/genesis.go index 31f40e53a..159fbe424 100644 --- a/x/sp/keeper/genesis.go +++ b/x/sp/keeper/genesis.go @@ -3,8 +3,9 @@ package keeper import ( "fmt" - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { diff --git a/x/sp/keeper/grpc_query.go b/x/sp/keeper/grpc_query.go index 29f8b192f..e2d46af66 100644 --- a/x/sp/keeper/grpc_query.go +++ b/x/sp/keeper/grpc_query.go @@ -3,13 +3,13 @@ package keeper import ( "context" - "github.com/bnb-chain/greenfield/x/sp/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/sp/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/sp/keeper/grpc_query_params.go b/x/sp/keeper/grpc_query_params.go index 3b6c3a392..e97b2f509 100644 --- a/x/sp/keeper/grpc_query_params.go +++ b/x/sp/keeper/grpc_query_params.go @@ -3,10 +3,11 @@ package keeper import ( "context" - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/sp/keeper/grpc_query_params_test.go b/x/sp/keeper/grpc_query_params_test.go index c0ba6578b..72fb7ed1b 100644 --- a/x/sp/keeper/grpc_query_params_test.go +++ b/x/sp/keeper/grpc_query_params_test.go @@ -3,10 +3,11 @@ package keeper_test import ( "testing" - testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" + "github.com/bnb-chain/greenfield/x/sp/types" ) func TestParamsQuery(t *testing.T) { diff --git a/x/sp/keeper/keeper.go b/x/sp/keeper/keeper.go index 982ab2db4..9a4bab0f7 100644 --- a/x/sp/keeper/keeper.go +++ b/x/sp/keeper/keeper.go @@ -3,12 +3,13 @@ package keeper import ( "fmt" - "github.com/bnb-chain/greenfield/x/sp/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + + "github.com/bnb-chain/greenfield/x/sp/types" ) type ( @@ -41,11 +42,11 @@ func NewKeeper( return &Keeper{ cdc: cdc, storeKey: key, + memKey: memKey, + paramstore: ps, authKeeper: ak, bankKeeper: bk, authzKeeper: azk, - memKey: memKey, - paramstore: ps, } } diff --git a/x/sp/keeper/msg_server.go b/x/sp/keeper/msg_server.go index c9ab0dd52..13340f469 100644 --- a/x/sp/keeper/msg_server.go +++ b/x/sp/keeper/msg_server.go @@ -3,10 +3,11 @@ package keeper import ( "context" - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" gov "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/bnb-chain/greenfield/x/sp/types" ) type msgServer struct { diff --git a/x/sp/keeper/msg_server_test.go b/x/sp/keeper/msg_server_test.go index 0c5c0cb87..b42fdf6c2 100644 --- a/x/sp/keeper/msg_server_test.go +++ b/x/sp/keeper/msg_server_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/bnb-chain/greenfield/testutil/keeper" "github.com/bnb-chain/greenfield/x/sp/keeper" "github.com/bnb-chain/greenfield/x/sp/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // nolint diff --git a/x/sp/keeper/params.go b/x/sp/keeper/params.go index e319f34c0..2c5fa0025 100644 --- a/x/sp/keeper/params.go +++ b/x/sp/keeper/params.go @@ -2,8 +2,9 @@ package keeper import ( "cosmossdk.io/math" - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func (k Keeper) MaxStorageProviders(ctx sdk.Context) (res uint32) { diff --git a/x/sp/keeper/params_test.go b/x/sp/keeper/params_test.go index 96ffcb32c..676649d33 100644 --- a/x/sp/keeper/params_test.go +++ b/x/sp/keeper/params_test.go @@ -3,9 +3,10 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" "github.com/bnb-chain/greenfield/x/sp/types" - "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { diff --git a/x/sp/keeper/slash.go b/x/sp/keeper/slash.go index 2f975a5f1..9755497b9 100644 --- a/x/sp/keeper/slash.go +++ b/x/sp/keeper/slash.go @@ -2,8 +2,9 @@ package keeper import ( sdkmath "cosmossdk.io/math" - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func (k Keeper) Slash(ctx sdk.Context, spAcc sdk.AccAddress, rewardInfos []types.RewardInfo) error { diff --git a/x/sp/keeper/sp.go b/x/sp/keeper/sp.go index 1236b79ae..e231b888f 100644 --- a/x/sp/keeper/sp.go +++ b/x/sp/keeper/sp.go @@ -1,8 +1,9 @@ package keeper import ( - "github.com/bnb-chain/greenfield/x/sp/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func (k Keeper) GetStorageProvider(ctx sdk.Context, addr sdk.AccAddress) (sp types.StorageProvider, found bool) { diff --git a/x/sp/module.go b/x/sp/module.go index 02b83fbe2..98079de46 100644 --- a/x/sp/module.go +++ b/x/sp/module.go @@ -4,21 +4,19 @@ import ( "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 + "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" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/bnb-chain/greenfield/x/sp/client/cli" "github.com/bnb-chain/greenfield/x/sp/keeper" "github.com/bnb-chain/greenfield/x/sp/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" - "github.com/cosmos/cosmos-sdk/types/module" ) var ( diff --git a/x/sp/module_simulation.go b/x/sp/module_simulation.go index 783ce778d..9276097e8 100644 --- a/x/sp/module_simulation.go +++ b/x/sp/module_simulation.go @@ -3,15 +3,16 @@ package sp import ( "math/rand" - "github.com/bnb-chain/greenfield/testutil/sample" - spsimulation "github.com/bnb-chain/greenfield/x/sp/simulation" - "github.com/bnb-chain/greenfield/x/sp/types" "github.com/cosmos/cosmos-sdk/baseapp" 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" "github.com/cosmos/cosmos-sdk/x/simulation" + + "github.com/bnb-chain/greenfield/testutil/sample" + spsimulation "github.com/bnb-chain/greenfield/x/sp/simulation" + "github.com/bnb-chain/greenfield/x/sp/types" ) // avoid unused import issue diff --git a/x/sp/simulation/operations.go b/x/sp/simulation/operations.go index 23997db66..c65e0f815 100644 --- a/x/sp/simulation/operations.go +++ b/x/sp/simulation/operations.go @@ -3,11 +3,12 @@ package simulation import ( "math/rand" - "github.com/bnb-chain/greenfield/x/sp/keeper" - "github.com/bnb-chain/greenfield/x/sp/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/bnb-chain/greenfield/x/sp/keeper" + "github.com/bnb-chain/greenfield/x/sp/types" ) // SimulateMsgCreateStorageProvider generates a MsgCreateStorageProvider with random values diff --git a/x/sp/types/errors.go b/x/sp/types/errors.go index 9cea8fbdc..fdd594397 100644 --- a/x/sp/types/errors.go +++ b/x/sp/types/errors.go @@ -1,7 +1,5 @@ package types -// DONTCOVER - import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/sp/types/genesis_test.go b/x/sp/types/genesis_test.go index c9935e5a2..01addf27b 100644 --- a/x/sp/types/genesis_test.go +++ b/x/sp/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/bnb-chain/greenfield/x/sp/types" "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/x/sp/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/sp/types/params.go b/x/sp/types/params.go index 5fd75928e..4c14c2621 100644 --- a/x/sp/types/params.go +++ b/x/sp/types/params.go @@ -15,8 +15,8 @@ import ( const ( // Default maximum number of SP DefaultMaxStorageProviders uint32 = 100 - // Dafault - DefaultDepositDenom = "deposit" + // Dafault deposit denom + DefaultDepositDenom = "bnb" ) // DefaultMinDeposit defines the minimum deposit amount for all storage provider @@ -24,8 +24,8 @@ var DefaulMinDeposit math.Int = math.NewInt(10000) var ( KeyMaxStorageProviders = []byte("MaxStorageProviders") - KeyDepostDenom = []byte("DepositDenom") - KeyMinDeposit = []byte("MinDeposit") + KeyDepostDenom = []byte("DepositDenom") + KeyMinDeposit = []byte("MinDeposit") ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -39,8 +39,8 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams(maxStorageProviders uint32, depositDenom string, minDeposit math.Int) Params { return Params{ MaxStorageProviders: maxStorageProviders, - DepositDenom: depositDenom, - MinDeposit: minDeposit, + DepositDenom: depositDenom, + MinDeposit: minDeposit, } } diff --git a/x/storage/README.md b/x/storage/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/x/storage/client/cli/flags.go b/x/storage/client/cli/flags.go new file mode 100644 index 000000000..a13edc13d --- /dev/null +++ b/x/storage/client/cli/flags.go @@ -0,0 +1,8 @@ +package cli + +const ( + FlagPublic = "public" + FlagPaymentAccount = "payment-account" + // TODO: Use a primary-account instead, which can load account from keyring and sign automatically. + FlagPrimarySPApproval = "primary-sp-signature" +) diff --git a/x/storage/client/cli/query.go b/x/storage/client/cli/query.go new file mode 100644 index 000000000..8c17d9a77 --- /dev/null +++ b/x/storage/client/cli/query.go @@ -0,0 +1,102 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +// TODO: Support List bucket/object/group with pagination. +// TODO: Support GetGroup + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group storage 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(CmdQueryParams()) + cmd.AddCommand(CmdBucket()) + cmd.AddCommand(CmdObject()) + + // this line is used by starport scaffolding # 1 + + return cmd +} + +func CmdBucket() *cobra.Command { + cmd := &cobra.Command{ + Use: "bucket [bucket-name]", + Short: "Query bucket", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqBucketName := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryBucketRequest{ + BucketName: reqBucketName, + } + + res, err := queryClient.Bucket(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdObject() *cobra.Command { + cmd := &cobra.Command{ + Use: "object [bucket-name] [object-name]", + Short: "Query object", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqBucketName := args[0] + reqObjectName := args[1] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryObjectRequest{ + BucketName: reqBucketName, + ObjectName: reqObjectName, + } + + res, err := queryClient.Object(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/greenfield/client/cli/query_params.go b/x/storage/client/cli/query_params.go similarity index 92% rename from x/greenfield/client/cli/query_params.go rename to x/storage/client/cli/query_params.go index 8053d6f23..6e9dfb222 100644 --- a/x/greenfield/client/cli/query_params.go +++ b/x/storage/client/cli/query_params.go @@ -3,10 +3,11 @@ package cli import ( "context" - "github.com/bnb-chain/greenfield/x/greenfield/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" + + "github.com/bnb-chain/greenfield/x/bridge/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/storage/client/cli/tx.go b/x/storage/client/cli/tx.go new file mode 100644 index 000000000..c123d8fab --- /dev/null +++ b/x/storage/client/cli/tx.go @@ -0,0 +1,461 @@ +package cli + +import ( + "crypto/sha256" + "fmt" + "io" + "net/http" + "os" + "time" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdCreateBucket()) + cmd.AddCommand(CmdDeleteBucket()) + cmd.AddCommand(CmdCreateObject()) + cmd.AddCommand(CmdSealObject()) + cmd.AddCommand(CmdRejectSealObject()) + cmd.AddCommand(CmdDeleteObject()) + cmd.AddCommand(CmdCreateGroup()) + cmd.AddCommand(CmdDeleteGroup()) + cmd.AddCommand(CmdUpdateGroupMember()) + cmd.AddCommand(CmdLeaveGroup()) + cmd.AddCommand(CmdCopyObject()) + // this line is used by starport scaffolding # 1 + + return cmd +} + +// CmdCreateBucket returns a CLI command handler for creating a MsgCreateBucket transaction. +func CmdCreateBucket() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-bucket [bucket-name] [primarySP]", + Short: "create a new bucket which associate to a primary sp", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + argBucketName := args[0] + primarySPAddress, err := sdk.AccAddressFromHexUnsafe(args[1]) + if err != nil { + return err + } + + var paymentAddress sdk.AccAddress + isPublic, err := cmd.Flags().GetBool(FlagPublic) + if err != nil { + return err + } + paymentAccStr, err := cmd.Flags().GetString(FlagPaymentAccount) + if err != nil { + return err + } + // TODO: verify the signature in advance. + primarySPApproval, err := cmd.Flags().GetBytesHex(FlagPrimarySPApproval) + if err != nil { + return err + } + + if paymentAccStr != "" { + if paymentAddress, err = sdk.AccAddressFromHexUnsafe(paymentAccStr); err != nil { + return err + } + } + + msg := types.NewMsgCreateBucket( + clientCtx.GetFromAddress(), + argBucketName, + isPublic, + primarySPAddress, + paymentAddress, + primarySPApproval, // TODO: Refine the cli parameters + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().Bool(FlagPublic, false, "If true(by default), only owner and grantee can access it. Otherwise, every one have permission to access it.") + cmd.Flags().String(FlagPaymentAccount, "", "The address of the account used to pay for the read fee. The default is the sender account.") + cmd.Flags().BytesHex(FlagPrimarySPApproval, []byte(""), "The signature of the primary SP which means the SP has confirm this transaction.") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdDeleteBucket() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete-bucket [bucket-name]", + Short: "delete an existing bucket", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argBucketName := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDeleteBucket( + clientCtx.GetFromAddress(), + argBucketName, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdCreateObject() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-object [bucket-name] [object-name]", + Short: "create a new object in the bucket", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argBucketName := args[0] + argObjectName := args[1] + argObjectPath := args[2] + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // read file + f, err := os.OpenFile(argObjectPath, os.O_RDONLY, 0644) + if err != nil { + return err + } + + // TODO(fynn): calc redundancy hashes. hard code here. + expectChecksum := make([][]byte, 7) + buf, _ := io.ReadAll(f) + h := sha256.New() + h.Write(buf) + sum := h.Sum(nil) + expectChecksum[0] = sum + expectChecksum[1] = sum + expectChecksum[2] = sum + expectChecksum[3] = sum + expectChecksum[4] = sum + expectChecksum[5] = sum + expectChecksum[6] = sum + + contentType := http.DetectContentType(buf) + + isPublic, _ := cmd.Flags().GetBool(FlagPublic) + + msg := types.NewMsgCreateObject( + clientCtx.GetFromAddress(), + argBucketName, + argObjectName, + uint64(len(buf)), + isPublic, + expectChecksum, + contentType, + []byte("for-test"), + nil, // NOTE(fynn): Not specified here. + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().Bool(FlagPublic, true, "If true(by default), only owner and grantee can access it. Otherwise, every one have permission to access it.") + cmd.Flags().BytesHex(FlagPrimarySPApproval, []byte(""), "The signature of the primary SP which means the SP has confirm this transaction.") + return cmd +} + +func CmdCopyObject() *cobra.Command { + cmd := &cobra.Command{ + Use: "copy-object [src-bucket-name] [dst-bucket-name] [src-object-name] [dst-object-name]", + Short: "Copy an existing object in a bucket to another bucket", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argSrcBucketName := args[0] + argDstBucketName := args[1] + argSrcObjectName := args[2] + argDstObjectName := args[3] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCopyObject( + clientCtx.GetFromAddress(), + argSrcBucketName, + argDstBucketName, + argSrcObjectName, + argDstObjectName, + nil, // TODO: Refine the cli parameters + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdSealObject() *cobra.Command { + cmd := &cobra.Command{ + Use: "seal-object [bucket-name] [object-name]", + Short: "Seal the object", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argBucketName := args[0] + argObjectName := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // TODO(fynn): hardcode here, impl after signature ready + spSignatures := make([][]byte, 7) + for i := 0; i < len(spSignatures); i++ { + spSignatures[i] = []byte("for-test") + } + msg := types.NewMsgSealObject( + clientCtx.GetFromAddress(), + argBucketName, + argObjectName, + nil, + spSignatures, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdRejectSealObject() *cobra.Command { + cmd := &cobra.Command{ + Use: "reject-seal-object [bucket-name] [object-name]", + Short: "Reject to seal the object", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argBucketName := args[0] + argObjectName := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRejectUnsealedObject( + clientCtx.GetFromAddress(), + argBucketName, + argObjectName, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdDeleteObject() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete-object [bucket-name] [object-name]", + Short: "Delete an existing object", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argBucketName := args[0] + argObjectName := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDeleteObject( + clientCtx.GetFromAddress(), + argBucketName, + argObjectName, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdCreateGroup() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-group [group-name]", + Short: "Create a new group", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argGroupName := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCreateGroup( + clientCtx.GetFromAddress(), + argGroupName, + nil, // TODO: Refine the cli parameters + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdDeleteGroup() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete-group [group-name]", + Short: "Delete an existing group", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argGroupName := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDeleteGroup( + clientCtx.GetFromAddress(), + argGroupName, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdLeaveGroup() *cobra.Command { + cmd := &cobra.Command{ + Use: "leave-group [group-name]", + Short: "Leave the group you're a member of", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argGroupName := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgLeaveGroup( + clientCtx.GetFromAddress(), + sdk.AccAddress{}, // TODO: add group owner acc + argGroupName, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdUpdateGroupMember() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-member [group-name]", + Short: "Update the member of the group you own", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argGroupName := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateGroupMember( + clientCtx.GetFromAddress(), + argGroupName, + nil, // TODO: Refine the cli parameters + nil, // TODO: Refine the cli parameters + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/greenfield/genesis.go b/x/storage/genesis.go similarity index 82% rename from x/greenfield/genesis.go rename to x/storage/genesis.go index c2849914d..eaff19c19 100644 --- a/x/greenfield/genesis.go +++ b/x/storage/genesis.go @@ -1,9 +1,10 @@ -package greenfield +package storage import ( - "github.com/bnb-chain/greenfield/x/greenfield/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/greenfield/genesis_test.go b/x/storage/genesis_test.go similarity index 65% rename from x/greenfield/genesis_test.go rename to x/storage/genesis_test.go index b70ce94cc..5537495f6 100644 --- a/x/greenfield/genesis_test.go +++ b/x/storage/genesis_test.go @@ -1,13 +1,14 @@ -package greenfield_test +package storage_test import ( "testing" + "github.com/stretchr/testify/require" + keepertest "github.com/bnb-chain/greenfield/testutil/keeper" "github.com/bnb-chain/greenfield/testutil/nullify" - "github.com/bnb-chain/greenfield/x/greenfield" - "github.com/bnb-chain/greenfield/x/greenfield/types" - "github.com/stretchr/testify/require" + "github.com/bnb-chain/greenfield/x/storage" + "github.com/bnb-chain/greenfield/x/storage/types" ) func TestGenesis(t *testing.T) { @@ -17,9 +18,9 @@ func TestGenesis(t *testing.T) { // this line is used by starport scaffolding # genesis/test/state } - k, ctx := keepertest.GreenfieldKeeper(t) - greenfield.InitGenesis(ctx, *k, genesisState) - got := greenfield.ExportGenesis(ctx, *k) + k, ctx := keepertest.StorageKeeper(t) + storage.InitGenesis(ctx, *k, genesisState) + got := storage.ExportGenesis(ctx, *k) require.NotNil(t, got) nullify.Fill(&genesisState) diff --git a/x/greenfield/keeper/grpc_query.go b/x/storage/keeper/grpc_query.go similarity index 53% rename from x/greenfield/keeper/grpc_query.go rename to x/storage/keeper/grpc_query.go index 7d296c3a7..ca1067f02 100644 --- a/x/greenfield/keeper/grpc_query.go +++ b/x/storage/keeper/grpc_query.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/bnb-chain/greenfield/x/greenfield/types" + "github.com/bnb-chain/greenfield/x/storage/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/greenfield/keeper/grpc_query_params.go b/x/storage/keeper/grpc_query_params.go similarity index 89% rename from x/greenfield/keeper/grpc_query_params.go rename to x/storage/keeper/grpc_query_params.go index fbf4a70c0..9101bfc8d 100644 --- a/x/greenfield/keeper/grpc_query_params.go +++ b/x/storage/keeper/grpc_query_params.go @@ -3,10 +3,11 @@ package keeper import ( "context" - "github.com/bnb-chain/greenfield/x/greenfield/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/storage/types" ) func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/greenfield/keeper/grpc_query_params_test.go b/x/storage/keeper/grpc_query_params_test.go similarity index 82% rename from x/greenfield/keeper/grpc_query_params_test.go rename to x/storage/keeper/grpc_query_params_test.go index e1d22f04f..eafd47d54 100644 --- a/x/greenfield/keeper/grpc_query_params_test.go +++ b/x/storage/keeper/grpc_query_params_test.go @@ -3,14 +3,15 @@ package keeper_test import ( "testing" - testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" ) func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.GreenfieldKeeper(t) + keeper, ctx := testkeeper.StorageKeeper(t) wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, params) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go new file mode 100644 index 000000000..682265ac0 --- /dev/null +++ b/x/storage/keeper/keeper.go @@ -0,0 +1,293 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" + + sptypes "github.com/bnb-chain/greenfield/x/sp/types" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + spKeeper types.SpKeeper + + // sequence + bucketSeq Sequence + objectSeq Sequence + groupSeq Sequence + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + spKeeper types.SpKeeper, + +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + k := Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + spKeeper: spKeeper, + } + + k.bucketSeq = NewSequence(types.BucketPrefix) + k.objectSeq = NewSequence(types.ObjectPrefix) + k.groupSeq = NewSequence(types.GroupPrefix) + return &k +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) CreateBucket(ctx sdk.Context, bucketInfo types.BucketInfo) error { + store := ctx.KVStore(k.storeKey) + bucketStore := prefix.NewStore(store, types.BucketPrefix) + + bucketKey := types.GetBucketKey(bucketInfo.BucketName) + if bucketStore.Has(bucketKey) { + return types.ErrBucketAlreadyExists + } + + bz := k.cdc.MustMarshal(&bucketInfo) + bucketStore.Set(bucketKey, bz) + return nil +} + +func (k Keeper) DeleteBucket(ctx sdk.Context, bucketName string) error { + store := ctx.KVStore(k.storeKey) + bucketStore := prefix.NewStore(store, types.BucketPrefix) + + bucketKey := types.GetBucketKey(bucketName) + if !bucketStore.Has(bucketKey) { + return types.ErrNoSuchBucket + } + // check if the bucket empty + if k.isEmptyBucket(ctx, bucketKey) { + return types.ErrBucketNotEmpty + } + bucketStore.Delete(bucketKey) + return nil +} + +func (k Keeper) MustGetBucket(ctx sdk.Context, bucketName string) (bucketInfo types.BucketInfo, found bool) { + store := ctx.KVStore(k.storeKey) + bucketStore := prefix.NewStore(store, types.BucketPrefix) + + bz := bucketStore.Get(types.GetBucketKey(bucketName)) + if bz == nil { + panic(fmt.Sprintf("bucket not found for address: %X\n", bucketName)) + } + + k.cdc.MustUnmarshal(bz, &bucketInfo) + return bucketInfo, true +} + +func (k Keeper) GetBucket(ctx sdk.Context, bucketName string) (bucketInfo types.BucketInfo, found bool) { + store := ctx.KVStore(k.storeKey) + bucketStore := prefix.NewStore(store, types.BucketPrefix) + + bucketKey := types.GetBucketKey(bucketName) + bz := bucketStore.Get(bucketKey) + if bz == nil { + return bucketInfo, false + } + + k.cdc.MustUnmarshal(bz, &bucketInfo) + + return bucketInfo, true +} + +func (k Keeper) GetBucketId(ctx sdk.Context) math.Uint { + store := ctx.KVStore(k.storeKey) + + seq := k.bucketSeq.NextVal(store) + return seq +} + +func (k Keeper) GetObjectID(ctx sdk.Context) math.Uint { + store := ctx.KVStore(k.storeKey) + + seq := k.objectSeq.NextVal(store) + return seq +} + +func (k Keeper) GetGroupId(ctx sdk.Context) math.Uint { + store := ctx.KVStore(k.storeKey) + + seq := k.groupSeq.NextVal(store) + return seq +} + +func (k Keeper) isEmptyBucket(ctx sdk.Context, bucketKey []byte) bool { + store := ctx.KVStore(k.storeKey) + objectStore := prefix.NewStore(store, types.ObjectPrefix) + + iter := objectStore.Iterator(bucketKey, nil) + return iter.Valid() +} + +func (k Keeper) CreateObject(ctx sdk.Context, objectInfo types.ObjectInfo) error { + store := ctx.KVStore(k.storeKey) + objectStore := prefix.NewStore(store, types.ObjectPrefix) + + objectKey := types.GetObjectKey(objectInfo.BucketName, objectInfo.ObjectName) + if objectStore.Has(objectKey) { + return types.ErrObjectAlreadyExists + } + + bz := k.cdc.MustMarshal(&objectInfo) + objectStore.Set(objectKey, bz) + return nil +} + +func (k Keeper) GetObject(ctx sdk.Context, bucketName string, objectName string) (objectInfo types.ObjectInfo, found bool) { + store := ctx.KVStore(k.storeKey) + objectStore := prefix.NewStore(store, types.ObjectPrefix) + + objectKey := types.GetObjectKey(bucketName, objectName) + bz := objectStore.Get(objectKey) + if bz == nil { + return objectInfo, false + } + + k.cdc.MustUnmarshal(bz, &objectInfo) + + return objectInfo, true +} + +func (k Keeper) SetObject(ctx sdk.Context, objectInfo types.ObjectInfo) { + store := ctx.KVStore(k.storeKey) + objectStore := prefix.NewStore(store, types.ObjectPrefix) + + objectKey := types.GetObjectKey(objectInfo.BucketName, objectInfo.ObjectName) + bz := k.cdc.MustMarshal(&objectInfo) + objectStore.Set(objectKey, bz) +} + +func (k Keeper) DeleteObject(ctx sdk.Context, bucketName string, objectName string) { + store := ctx.KVStore(k.storeKey) + objectStore := prefix.NewStore(store, types.ObjectPrefix) + objectKey := types.GetObjectKey(bucketName, objectName) + + objectStore.Delete(objectKey) +} + +func (k Keeper) CreateGroup(ctx sdk.Context, groupInfo types.GroupInfo) error { + store := ctx.KVStore(k.storeKey) + groupStore := prefix.NewStore(store, types.GroupPrefix) + + groupKey := types.GetGroupKey(groupInfo.Owner, groupInfo.GroupName) + if groupStore.Has(groupKey) { + return types.ErrGroupAlreadyExists + } + bz := k.cdc.MustMarshal(&groupInfo) + groupStore.Set(groupKey, bz) + return nil +} + +func (k Keeper) GetGroup(ctx sdk.Context, ownerAddr string, groupName string) (groupInfo types.GroupInfo, found bool) { + store := ctx.KVStore(k.storeKey) + groupStore := prefix.NewStore(store, types.GroupPrefix) + + groupKey := types.GetGroupKey(ownerAddr, groupName) + bz := groupStore.Get(groupKey) + if bz == nil { + return groupInfo, false + } + + k.cdc.MustUnmarshal(bz, &groupInfo) + return groupInfo, true +} + +func (k Keeper) DeleteGroup(ctx sdk.Context, ownerAddr string, groupName string) error { + store := ctx.KVStore(k.storeKey) + groupStore := prefix.NewStore(store, types.GroupPrefix) + + groupKey := types.GetGroupKey(ownerAddr, groupName) + if !groupStore.Has(groupKey) { + return types.ErrNoSuchGroup + } + + groupStore.Delete(groupKey) + return nil +} + +func (k Keeper) AddGroupMember(ctx sdk.Context, groupMemberInfo types.GroupMemberInfo) error { + store := ctx.KVStore(k.storeKey) + groupMemberStore := prefix.NewStore(store, types.GroupMemberPrefix) + + groupMemberKey := types.GetGroupMemberKey(groupMemberInfo.Id, groupMemberInfo.Member) + if groupMemberStore.Has(groupMemberKey) { + return types.ErrGroupMemberAlreadyExists + } + bz := k.cdc.MustMarshal(&groupMemberInfo) + groupMemberStore.Set(groupMemberKey, bz) + return nil +} + +func (k Keeper) RemoveGroupMember(ctx sdk.Context, groupId math.Uint, member string) error { + store := ctx.KVStore(k.storeKey) + groupMemberStore := prefix.NewStore(store, types.GroupMemberPrefix) + memberKey := types.GetGroupMemberKey(groupId, member) + if groupMemberStore.Has(memberKey) { + return types.ErrNoSuchGroupMember + } + groupMemberStore.Delete(memberKey) + return nil +} + +func (k Keeper) HasGroupMember(ctx sdk.Context, groupMemberKey []byte) bool { + store := ctx.KVStore(k.storeKey) + groupMemberStore := prefix.NewStore(store, types.GroupMemberPrefix) + + return groupMemberStore.Has(groupMemberKey) +} + +func (k Keeper) CheckSPAndSignature(ctx sdk.Context, spAddrs []string, sigData [][]byte, signature [][]byte) error { + for i, spAddr := range spAddrs { + spAcc, err := sdk.AccAddressFromHexUnsafe(spAddr) + if err != nil { + return err + } + sp, found := k.spKeeper.GetStorageProvider(ctx, spAcc) + if !found { + return types.ErrNoSuchStorageProvider + } + if sp.Status != sptypes.STATUS_IN_SERVICE { + return types.ErrStorageProviderNotInService + } + + approvalAcc, err := sdk.AccAddressFromHexUnsafe(sp.ApprovalAddress) + if err != nil { + return err + } + + err = types.VerifySignature(approvalAcc, sigData[i], signature[i]) + if err != nil { + return err + } + } + return nil +} diff --git a/x/storage/keeper/msg_server.go b/x/storage/keeper/msg_server.go new file mode 100644 index 000000000..637eec8f1 --- /dev/null +++ b/x/storage/keeper/msg_server.go @@ -0,0 +1,369 @@ +package keeper + +import ( + "context" + sptypes "github.com/bnb-chain/greenfield/x/sp/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +type msgServer struct { + Keeper +} + +// TODO: add event for all message + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) CreateBucket(goCtx context.Context, msg *types.MsgCreateBucket) (*types.MsgCreateBucketResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: check the bucket permission + ownerAcc, err := sdk.AccAddressFromHexUnsafe(msg.Creator) + if err != nil { + return nil, err + } + + var paymentAcc sdk.AccAddress + if msg.PaymentAddress != "" { + // TODO: validate that the paymentAcc is ownered by ownerAcc if payment module is ready + paymentAcc, err = sdk.AccAddressFromHexUnsafe(msg.PaymentAddress) + if err != nil { + return nil, err + } + } else { + paymentAcc = ownerAcc + } + + primarySPAcc, err := sdk.AccAddressFromHexUnsafe(msg.PrimarySpAddress) + if err != nil { + return nil, err + } + + // TODO: this is a very tricky implement. Will be refactor later. + spApproval := msg.PrimarySpApprovalSignature + msg.PrimarySpApprovalSignature = []byte("") + bz, err := msg.Marshal() + if err != nil { + return nil, err + } + + err = k.CheckSPAndSignature(ctx, []string{msg.PrimarySpAddress}, [][]byte{sdk.Keccak256(bz)}, [][]byte{spApproval}) + if err != nil { + return nil, err + } + + // Store bucket meta + bucketInfo := types.BucketInfo{ + Owner: ownerAcc.String(), + BucketName: msg.BucketName, + IsPublic: msg.IsPublic, + CreateAt: ctx.BlockHeight(), + Id: k.GetBucketId(ctx), + ReadQuota: types.READ_QUOTA_FREE, + PaymentAddress: paymentAcc.String(), + PrimarySpAddress: primarySPAcc.String(), + } + + return &types.MsgCreateBucketResponse{}, k.Keeper.CreateBucket(ctx, bucketInfo) +} + +func (k msgServer) DeleteBucket(goCtx context.Context, msg *types.MsgDeleteBucket) (*types.MsgDeleteBucketResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: check if have the permission to delete bucket + return &types.MsgDeleteBucketResponse{}, k.Keeper.DeleteBucket(ctx, msg.BucketName) +} + +func (k msgServer) CreateObject(goCtx context.Context, msg *types.MsgCreateObject) (*types.MsgCreateObjectResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // TODO: check bucket and object permission + // TODO: pay for the object. Interact with PaymentModule + + // check owner AccAddress + ownerAcc, err := sdk.AccAddressFromHexUnsafe(msg.Creator) + if err != nil { + return nil, err + } + + // check bucket + bucketInfo, found := k.GetBucket(ctx, msg.BucketName) + if !found { + return nil, types.ErrNoSuchBucket + } + + // TODO: this is a very tricky implement. Will be refactor later. + spApproval := msg.PrimarySpApprovalSignature + msg.PrimarySpApprovalSignature = []byte("") + bz, err := msg.Marshal() + if err != nil { + return nil, err + } + err = k.CheckSPAndSignature(ctx, []string{bucketInfo.PrimarySpAddress}, [][]byte{sdk.Keccak256(bz)}, [][]byte{spApproval}) + if err != nil { + return nil, err + } + + objectInfo := types.ObjectInfo{ + Owner: ownerAcc.String(), + BucketName: msg.BucketName, + ObjectName: msg.ObjectName, + PayloadSize: msg.PayloadSize, + IsPublic: msg.IsPublic, + ContentType: msg.ContentType, + Id: k.GetObjectID(ctx), + CreateAt: ctx.BlockHeight(), + ObjectStatus: types.OBJECT_STATUS_INIT, + RedundancyType: types.REDUNDANCY_EC_TYPE, // TODO: base on redundancy policy + SourceType: types.SOURCE_TYPE_ORIGIN, + + Checksums: msg.ExpectChecksums, + SecondarySpAddresses: msg.ExpectSecondarySpAddresses, + } + + return &types.MsgCreateObjectResponse{}, k.Keeper.CreateObject(ctx, objectInfo) +} + +func (k msgServer) SealObject(goCtx context.Context, msg *types.MsgSealObject) (*types.MsgSealObjectResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: check permission when permission module ready + // TODO: submit event/log + spAcc, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return nil, err + } + bucketInfo, found := k.Keeper.GetBucket(ctx, msg.BucketName) + if !found { + return nil, types.ErrNoSuchBucket + } + + if bucketInfo.PrimarySpAddress != spAcc.String() { + return nil, types.ErrSPAddressMismatch + } + + objectInfo, found := k.Keeper.GetObject(ctx, msg.BucketName, msg.ObjectName) + if !found { + return nil, types.ErrNoSuchObject + } + if objectInfo.ObjectStatus != types.OBJECT_STATUS_INIT { + return nil, types.ErrObjectAlreadyExists + } else { + objectInfo.ObjectStatus = types.OBJECT_STATUS_IN_SERVICE + } + + err = k.CheckSPAndSignature(ctx, msg.SecondarySpAddresses, objectInfo.Checksums[1:], msg.SecondarySpSignatures) + if err != nil { + return nil, err + } + + k.Keeper.SetObject(ctx, objectInfo) + + return &types.MsgSealObjectResponse{}, nil +} + +func (k msgServer) CopyObject(goCtx context.Context, msg *types.MsgCopyObject) (*types.MsgCopyObjectResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + ownerAcc, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return nil, err + } + + _, found := k.Keeper.GetBucket(ctx, msg.SrcBucketName) + if !found { + return nil, sdkerrors.Wrapf(types.ErrNoSuchBucket, "src bucket name (%s)", msg.SrcBucketName) + } + + dstBucketInfo, found := k.Keeper.GetBucket(ctx, msg.DstBucketName) + if !found { + return nil, sdkerrors.Wrapf(types.ErrNoSuchBucket, "dst bucket name (%s)", msg.DstBucketName) + } + + srcObjectInfo, found := k.Keeper.GetObject(ctx, msg.SrcBucketName, msg.SrcObjectName) + if !found { + return nil, sdkerrors.Wrapf(types.ErrNoSuchObject, "src object name (%s)", msg.SrcObjectName) + } + + // TODO: this is a very tricky implement. Will be refactor later. + spApproval := msg.DstPrimarySpApprovalSignature + msg.DstPrimarySpApprovalSignature = []byte("") + bz, err := msg.Marshal() + if err != nil { + return nil, err + } + err = k.CheckSPAndSignature(ctx, []string{dstBucketInfo.PrimarySpAddress}, [][]byte{sdk.Keccak256(bz)}, [][]byte{spApproval}) + if err != nil { + return nil, err + } + + // check if have permission for copy object from this bucket + // Currently only allowed object owner to CopyObject + if srcObjectInfo.Owner != msg.Operator { + return nil, sdkerrors.Wrapf(types.ErrAccessDenied, "access denied (%s)", srcObjectInfo.String()) + } + objectInfo := types.ObjectInfo{ + Owner: ownerAcc.String(), + BucketName: dstBucketInfo.BucketName, + ObjectName: msg.DstObjectName, + PayloadSize: srcObjectInfo.PayloadSize, + IsPublic: srcObjectInfo.IsPublic, + ContentType: srcObjectInfo.ContentType, + CreateAt: ctx.BlockHeight(), + ObjectStatus: types.OBJECT_STATUS_INIT, + RedundancyType: types.REDUNDANCY_EC_TYPE, + SourceType: types.SOURCE_TYPE_ORIGIN, + + Checksums: srcObjectInfo.Checksums, + } + + k.Keeper.SetObject(ctx, objectInfo) + + return &types.MsgCopyObjectResponse{}, nil +} + +func (k msgServer) DeleteObject(goCtx context.Context, msg *types.MsgDeleteObject) (*types.MsgDeleteObjectResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + objectInfo, found := k.Keeper.GetObject(ctx, msg.BucketName, msg.ObjectName) + if !found { + return nil, types.ErrNoSuchObject + } + + // Currently, only the owner is allowed to delete object + if objectInfo.Owner != msg.Operator { + return nil, types.ErrAccessDenied + } + + k.Keeper.DeleteObject(ctx, msg.BucketName, msg.ObjectName) + return &types.MsgDeleteObjectResponse{}, nil +} + +func (k msgServer) RejectSealObject(goCtx context.Context, msg *types.MsgRejectSealObject) (*types.MsgRejectSealObjectResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + objectInfo, found := k.Keeper.GetObject(ctx, msg.BucketName, msg.ObjectName) + if !found { + return nil, types.ErrNoSuchObject + } + + if objectInfo.ObjectStatus != types.OBJECT_STATUS_INIT { + return nil, types.ErrObjectStatusNotInit + } + + // Currently, only the primary sp is allowed to reject seal object + spAcc, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return nil, err + } + // TODO: operator address or other address (for reject seal object) + sp, found := k.spKeeper.GetStorageProvider(ctx, spAcc) + if !found { + return nil, types.ErrNoSuchStorageProvider + } + if sp.Status != sptypes.STATUS_IN_SERVICE { + return nil, types.ErrStorageProviderNotInService + } + + // TODO: Interact with payment. unlock the pre-pay fee. + k.Keeper.DeleteObject(ctx, msg.BucketName, msg.ObjectName) + return &types.MsgRejectSealObjectResponse{}, nil +} + +func (k msgServer) CreateGroup(goCtx context.Context, msg *types.MsgCreateGroup) (*types.MsgCreateGroupResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + groupInfo := types.GroupInfo{ + Owner: msg.Creator, + Id: k.GetGroupId(ctx), + GroupName: msg.GroupName, + } + err := k.Keeper.CreateGroup(ctx, groupInfo) + if err != nil { + return nil, err + } + + // need to limit the size of Msg.Members to avoid taking too long to execute the msg + for _, member := range msg.Members { + memberAddress, err := sdk.AccAddressFromHexUnsafe(member) + if err != nil { + return nil, err + } + groupMemberInfo := types.GroupMemberInfo{ + Member: memberAddress.String(), + Id: groupInfo.Id, + ExpireTime: 0, + } + err = k.Keeper.AddGroupMember(ctx, groupMemberInfo) + if err != nil { + return nil, err + } + } + return &types.MsgCreateGroupResponse{}, nil +} + +func (k msgServer) DeleteGroup(goCtx context.Context, msg *types.MsgDeleteGroup) (*types.MsgDeleteGroupResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Note: Delete group does not require the group is empty. The group member will be deleted by on-chain GC. + return &types.MsgDeleteGroupResponse{}, k.Keeper.DeleteGroup(ctx, msg.Operator, msg.GroupName) +} + +func (k msgServer) LeaveGroup(goCtx context.Context, msg *types.MsgLeaveGroup) (*types.MsgLeaveGroupResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + groupInfo, found := k.Keeper.GetGroup(ctx, msg.GroupOwner, msg.GroupName) + if !found { + return nil, types.ErrNoSuchGroup + } + return &types.MsgLeaveGroupResponse{}, k.Keeper.RemoveGroupMember(ctx, groupInfo.Id, msg.Member) +} + +func (k msgServer) UpdateGroupMember(goCtx context.Context, msg *types.MsgUpdateGroupMember) (*types.MsgUpdateGroupMemberResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Now only allowed group owner to update member + groupInfo, found := k.Keeper.GetGroup(ctx, msg.Operator, msg.GroupName) + if !found { + return nil, types.ErrNoSuchGroup + } + + for _, member := range msg.MembersToAdd { + memberAcc, err := sdk.AccAddressFromHexUnsafe(member) + if err != nil { + return nil, err + } + memberInfo := types.GroupMemberInfo{ + Member: memberAcc.String(), + Id: groupInfo.Id, + ExpireTime: 0, + } + + err = k.Keeper.AddGroupMember(ctx, memberInfo) + if err != nil { + return nil, err + } + } + + for _, member := range msg.MembersToDelete { + memberAcc, err := sdk.AccAddressFromHexUnsafe(member) + if err != nil { + return nil, err + } + err = k.Keeper.RemoveGroupMember(ctx, groupInfo.Id, memberAcc.String()) + if err != nil { + return nil, err + } + } + + return &types.MsgUpdateGroupMemberResponse{}, nil +} diff --git a/x/greenfield/keeper/msg_server_test.go b/x/storage/keeper/msg_server_test.go similarity index 67% rename from x/greenfield/keeper/msg_server_test.go rename to x/storage/keeper/msg_server_test.go index 291793839..a1a7ca048 100644 --- a/x/greenfield/keeper/msg_server_test.go +++ b/x/storage/keeper/msg_server_test.go @@ -4,14 +4,15 @@ import ( "context" "testing" - keepertest "github.com/bnb-chain/greenfield/testutil/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/types" sdk "github.com/cosmos/cosmos-sdk/types" + + keepertest "github.com/bnb-chain/greenfield/testutil/keeper" + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" ) // nolint: unused func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.GreenfieldKeeper(t) + k, ctx := keepertest.StorageKeeper(t) return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) } diff --git a/x/storage/keeper/params.go b/x/storage/keeper/params.go new file mode 100644 index 000000000..21884d040 --- /dev/null +++ b/x/storage/keeper/params.go @@ -0,0 +1,41 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +func (k Keeper) MaxSegmentSize(ctx sdk.Context) (res uint64) { + k.paramstore.Get(ctx, types.KeyMaxSegmentSize, &res) + return +} + +func (k Keeper) RedundantDataChunkNum(ctx sdk.Context) (res uint32) { + k.paramstore.Get(ctx, types.KeyRedundantDataChunkNum, &res) + return +} + +func (k Keeper) RedundantParityChunkNum(ctx sdk.Context) (res uint32) { + k.paramstore.Get(ctx, types.KeyRedundantParityChunkNum, &res) + return +} + +func (k Keeper) MaxPayloadSize(ctx sdk.Context) (res uint64) { + k.paramstore.Get(ctx, types.KeyMaxPayloadSize, &res) + return +} + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams( + k.MaxSegmentSize(ctx), + k.RedundantDataChunkNum(ctx), + k.RedundantParityChunkNum(ctx), + k.MaxPayloadSize(ctx)) +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/greenfield/keeper/params_test.go b/x/storage/keeper/params_test.go similarity index 75% rename from x/greenfield/keeper/params_test.go rename to x/storage/keeper/params_test.go index ad83a2c8e..8e05d089c 100644 --- a/x/greenfield/keeper/params_test.go +++ b/x/storage/keeper/params_test.go @@ -3,13 +3,14 @@ package keeper_test import ( "testing" - testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/types" "github.com/stretchr/testify/require" + + testkeeper "github.com/bnb-chain/greenfield/testutil/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" ) func TestGetParams(t *testing.T) { - k, ctx := testkeeper.GreenfieldKeeper(t) + k, ctx := testkeeper.StorageKeeper(t) params := types.DefaultParams() k.SetParams(ctx, params) diff --git a/x/storage/keeper/query.go b/x/storage/keeper/query.go new file mode 100644 index 000000000..d1166605c --- /dev/null +++ b/x/storage/keeper/query.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +func (k Keeper) Bucket(goCtx context.Context, req *types.QueryBucketRequest) (*types.QueryBucketResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + bucketInfo, found := k.GetBucket(ctx, req.BucketName) + if found { + return &types.QueryBucketResponse{ + BucketInfo: &bucketInfo, + }, nil + + } + return nil, types.ErrNoSuchBucket +} + +func (k Keeper) Object(goCtx context.Context, req *types.QueryObjectRequest) (*types.QueryObjectResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + objectInfo, found := k.GetObject(ctx, req.BucketName, req.ObjectName) + if found { + return &types.QueryObjectResponse{ + ObjectInfo: &objectInfo, + }, nil + } + return nil, types.ErrNoSuchObject +} diff --git a/x/storage/keeper/sequence.go b/x/storage/keeper/sequence.go new file mode 100644 index 000000000..97a9b4786 --- /dev/null +++ b/x/storage/keeper/sequence.go @@ -0,0 +1,66 @@ +package keeper + +import ( + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +// sequenceIDPrefix a fix key to read/ write data on the storage layer +var sequenceIDPrefix = []byte{0x1} + +// sequence is a persistent unique key generator based on a counter. +type Sequence struct { + prefix []byte +} + +func NewSequence(prefix []byte) Sequence { + return Sequence{ + prefix: prefix, + } +} + +// NextVal increments and persists the counter by one and returns the value. +func (s Sequence) NextVal(store sdk.KVStore) math.Uint { + pStore := prefix.NewStore(store, s.prefix) + v := pStore.Get(sequenceIDPrefix) + seq := types.MustUnmarshalUint(v) + seq = seq.Incr() + + pStore.Set(sequenceIDPrefix, types.MustMarshalUint(seq)) + return seq +} + +// CurVal returns the last value used. 0 if none. +func (s Sequence) CurVal(store sdk.KVStore) math.Uint { + pStore := prefix.NewStore(store, s.prefix) + v := pStore.Get(sequenceIDPrefix) + return types.MustUnmarshalUint(v) +} + +// PeekNextVal returns the CurVal + increment step. Not persistent. +func (s Sequence) PeekNextVal(store sdk.KVStore) math.Uint { + pStore := prefix.NewStore(store, s.prefix) + v := pStore.Get(sequenceIDPrefix) + seq := types.MustUnmarshalUint(v) + seq = seq.Incr() + return seq +} + +// InitVal sets the start value for the sequence. It must be called only once on an empty DB. +// Otherwise an error is returned when the key exists. The given start value is stored as current +// value. +// +// It is recommended to call this method only for a sequence start value other than `1` as the +// method consumes unnecessary gas otherwise. A scenario would be an import from genesis. +func (s Sequence) InitVal(store sdk.KVStore, seq math.Uint) error { + pStore := prefix.NewStore(store, s.prefix) + if pStore.Has(sequenceIDPrefix) { + return types.ErrSequenceUniqueConstraint + } + + pStore.Set(sequenceIDPrefix, types.MustMarshalUint(seq)) + return nil +} diff --git a/x/storage/keeper/sequence_test.go b/x/storage/keeper/sequence_test.go new file mode 100644 index 000000000..e283765df --- /dev/null +++ b/x/storage/keeper/sequence_test.go @@ -0,0 +1,67 @@ +package keeper + +import ( + "fmt" + "testing" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + + "github.com/bnb-chain/greenfield/x/storage/types" +) + +type MockContext struct { + db *dbm.MemDB + store storetypes.CommitMultiStore +} + +func (m MockContext) KVStore(key storetypes.StoreKey) sdk.KVStore { + if s := m.store.GetCommitKVStore(key); s != nil { + return s + } + m.store.MountStoreWithDB(key, storetypes.StoreTypeIAVL, m.db) + if err := m.store.LoadLatestVersion(); err != nil { + panic(err) + } + return m.store.GetCommitKVStore(key) +} + +func NewMockContext() *MockContext { + db := dbm.NewMemDB() + return &MockContext{ + db: dbm.NewMemDB(), + store: store.NewCommitMultiStore(db), + } +} + +func TestSequenceUniqueConstraint(t *testing.T) { + ctx := NewMockContext() + store := ctx.KVStore(sdk.NewKVStoreKey("test")) + + seq := NewSequence([]byte{0x1}) + err := seq.InitVal(store, math.NewUint(0)) + require.NoError(t, err) + err = seq.InitVal(store, math.NewUint(1)) + require.True(t, types.ErrSequenceUniqueConstraint.Is(err)) +} + +func TestSequenceIncrements(t *testing.T) { + ctx := NewMockContext() + store := ctx.KVStore(sdk.NewKVStoreKey("test")) + seq := NewSequence([]byte{0x1}) + max := math.NewUint(10) + i := math.ZeroUint() + for i.LT(max) { + id := seq.NextVal(store) + curId := seq.CurVal(store) + i = i.Incr() + assert.True(t, i.Equal(id)) + assert.True(t, i.Equal(curId)) + fmt.Print("i= ", i.Uint64(), "id=", id.Uint64(), "curID", curId.Uint64()) + } +} diff --git a/x/greenfield/module.go b/x/storage/module.go similarity index 95% rename from x/greenfield/module.go rename to x/storage/module.go index 81bba352e..824ce8f59 100644 --- a/x/greenfield/module.go +++ b/x/storage/module.go @@ -1,25 +1,22 @@ -package greenfield +package storage import ( "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/bnb-chain/greenfield/x/greenfield/client/cli" - "github.com/bnb-chain/greenfield/x/greenfield/keeper" - "github.com/bnb-chain/greenfield/x/greenfield/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" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/bnb-chain/greenfield/x/storage/client/cli" + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" ) var ( @@ -96,6 +93,7 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + spKeeper types.SpKeeper } func NewAppModule( @@ -103,12 +101,14 @@ func NewAppModule( keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + spKeeper types.SpKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + spKeeper: spKeeper, } } diff --git a/x/storage/module_simulation.go b/x/storage/module_simulation.go new file mode 100644 index 000000000..7f0c9aa53 --- /dev/null +++ b/x/storage/module_simulation.go @@ -0,0 +1,230 @@ +package storage + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + 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" + "github.com/cosmos/cosmos-sdk/x/simulation" + + "github.com/bnb-chain/greenfield/testutil/sample" + storagesimulation "github.com/bnb-chain/greenfield/x/storage/simulation" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = storagesimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( + opWeightMsgCreateBucket = "op_weight_msg_create_bucket" + // TODO: Determine the simulation weight value + defaultWeightMsgCreateBucket int = 100 + + opWeightMsgDeleteBucket = "op_weight_msg_delete_bucket" + // TODO: Determine the simulation weight value + defaultWeightMsgDeleteBucket int = 100 + + opWeightMsgPutObject = "op_weight_msg_put_object" + // TODO: Determine the simulation weight value + defaultWeightMsgPutObject int = 100 + + opWeightMsgSealObject = "op_weight_msg_seal_object" + // TODO: Determine the simulation weight value + defaultWeightMsgSealObject int = 100 + + opWeightMsgRejectUnsealedObject = "op_weight_msg_reject_unsealed_object" + // TODO: Determine the simulation weight value + defaultWeightMsgRejectUnsealedObject int = 100 + + opWeightMsgDeleteObject = "op_weight_msg_delete_object" + // TODO: Determine the simulation weight value + defaultWeightMsgDeleteObject int = 100 + + opWeightMsgCreateGroup = "op_weight_msg_create_group" + // TODO: Determine the simulation weight value + defaultWeightMsgCreateGroup int = 100 + + opWeightMsgDeleteGroup = "op_weight_msg_delete_group" + // TODO: Determine the simulation weight value + defaultWeightMsgDeleteGroup int = 100 + + opWeightMsgUpdateGroupMember = "op_weight_msg_update_group_member" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateGroupMember int = 100 + + opWeightMsgLeaveGroup = "op_weight_msg_leave_group" + // TODO: Determine the simulation weight value + defaultWeightMsgLeaveGroup int = 100 + + opWeightMsgCopyObject = "op_weight_msg_copy_object" + // TODO: Determine the simulation weight value + defaultWeightMsgCopyObject int = 100 + + // this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + greenfieldGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&greenfieldGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + + return []simtypes.ParamChange{} +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + var weightMsgCreateBucket int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateBucket, &weightMsgCreateBucket, nil, + func(_ *rand.Rand) { + weightMsgCreateBucket = defaultWeightMsgCreateBucket + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgCreateBucket, + storagesimulation.SimulateMsgCreateBucket(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgDeleteBucket int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteBucket, &weightMsgDeleteBucket, nil, + func(_ *rand.Rand) { + weightMsgDeleteBucket = defaultWeightMsgDeleteBucket + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgDeleteBucket, + storagesimulation.SimulateMsgDeleteBucket(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgPutObject int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgPutObject, &weightMsgPutObject, nil, + func(_ *rand.Rand) { + weightMsgPutObject = defaultWeightMsgPutObject + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgPutObject, + storagesimulation.SimulateMsgPutObject(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgSealObject int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgSealObject, &weightMsgSealObject, nil, + func(_ *rand.Rand) { + weightMsgSealObject = defaultWeightMsgSealObject + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgSealObject, + storagesimulation.SimulateMsgSealObject(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgRejectUnsealedObject int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgRejectUnsealedObject, &weightMsgRejectUnsealedObject, nil, + func(_ *rand.Rand) { + weightMsgRejectUnsealedObject = defaultWeightMsgRejectUnsealedObject + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgRejectUnsealedObject, + storagesimulation.SimulateMsgRejectUnsealedObject(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgDeleteObject int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteObject, &weightMsgDeleteObject, nil, + func(_ *rand.Rand) { + weightMsgDeleteObject = defaultWeightMsgDeleteObject + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgDeleteObject, + storagesimulation.SimulateMsgDeleteObject(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgCreateGroup int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateGroup, &weightMsgCreateGroup, nil, + func(_ *rand.Rand) { + weightMsgCreateGroup = defaultWeightMsgCreateGroup + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgCreateGroup, + storagesimulation.SimulateMsgCreateGroup(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgDeleteGroup int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteGroup, &weightMsgDeleteGroup, nil, + func(_ *rand.Rand) { + weightMsgDeleteGroup = defaultWeightMsgDeleteGroup + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgDeleteGroup, + storagesimulation.SimulateMsgDeleteGroup(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgUpdateGroupMember int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateGroupMember, &weightMsgUpdateGroupMember, nil, + func(_ *rand.Rand) { + weightMsgUpdateGroupMember = defaultWeightMsgUpdateGroupMember + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateGroupMember, + storagesimulation.SimulateMsgUpdateGroupMember(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgLeaveGroup int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgLeaveGroup, &weightMsgLeaveGroup, nil, + func(_ *rand.Rand) { + weightMsgLeaveGroup = defaultWeightMsgLeaveGroup + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgLeaveGroup, + storagesimulation.SimulateMsgLeaveGroup(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgCopyObject int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCopyObject, &weightMsgCopyObject, nil, + func(_ *rand.Rand) { + weightMsgCopyObject = defaultWeightMsgCopyObject + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgCopyObject, + storagesimulation.SimulateMsgCopyObject(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} diff --git a/x/greenfield/simulation/helpers.go b/x/storage/simulation/helpers.go similarity index 100% rename from x/greenfield/simulation/helpers.go rename to x/storage/simulation/helpers.go diff --git a/x/storage/simulation/operations.go b/x/storage/simulation/operations.go new file mode 100644 index 000000000..fd37dec7b --- /dev/null +++ b/x/storage/simulation/operations.go @@ -0,0 +1,210 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/bnb-chain/greenfield/x/storage/keeper" + "github.com/bnb-chain/greenfield/x/storage/types" +) + +func SimulateMsgCreateBucket( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgCreateBucket{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the CreateBucket simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "CreateBucket simulation not implemented"), nil, nil + } +} + +func SimulateMsgDeleteBucket( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgDeleteBucket{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the DeleteBucket simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "DeleteBucket simulation not implemented"), nil, nil + } +} + +func SimulateMsgPutObject( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgCreateObject{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the CreateObject simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "CreateObject simulation not implemented"), nil, nil + } +} + +func SimulateMsgDeleteObject( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgDeleteObject{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the DeleteObject simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "DeleteObject simulation not implemented"), nil, nil + } +} + +func SimulateMsgSealObject( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgSealObject{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the SealObject simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "SealObject simulation not implemented"), nil, nil + } +} + +func SimulateMsgRejectUnsealedObject( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgRejectSealObject{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the RejectSealObject simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "RejectSealObject simulation not implemented"), nil, nil + } +} + +func SimulateMsgCopyObject( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgCopyObject{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the CopyObject simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "CopyObject simulation not implemented"), nil, nil + } +} + +func SimulateMsgCreateGroup( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgCreateGroup{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the CreateGroup simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "CreateGroup simulation not implemented"), nil, nil + } +} + +func SimulateMsgDeleteGroup( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgDeleteGroup{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the DeleteGroup simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "DeleteGroup simulation not implemented"), nil, nil + } +} + +func SimulateMsgLeaveGroup( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgLeaveGroup{ + Member: simAccount.Address.String(), + } + + // TODO: Handling the LeaveGroup simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "LeaveGroup simulation not implemented"), nil, nil + } +} + +func SimulateMsgUpdateGroupMember( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUpdateGroupMember{ + Operator: simAccount.Address.String(), + } + + // TODO: Handling the UpdateGroupMember simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "UpdateGroupMember simulation not implemented"), nil, nil + } +} diff --git a/x/storage/simulation/operations_test.go b/x/storage/simulation/operations_test.go new file mode 100644 index 000000000..5c6452f9a --- /dev/null +++ b/x/storage/simulation/operations_test.go @@ -0,0 +1 @@ +package simulation_test diff --git a/x/storage/types/codec.go b/x/storage/types/codec.go new file mode 100644 index 000000000..5a1b766ff --- /dev/null +++ b/x/storage/types/codec.go @@ -0,0 +1,79 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreateBucket{}, "storage/CreateBucket", nil) + cdc.RegisterConcrete(&MsgDeleteBucket{}, "storage/DeleteBucket", nil) + cdc.RegisterConcrete(&MsgCreateObject{}, "storage/CreateObject", nil) + cdc.RegisterConcrete(&MsgSealObject{}, "storage/SealObject", nil) + cdc.RegisterConcrete(&MsgRejectSealObject{}, "storage/RejectSealObject", nil) + cdc.RegisterConcrete(&MsgDeleteObject{}, "storage/DeleteObject", nil) + cdc.RegisterConcrete(&MsgCreateGroup{}, "storage/CreateGroup", nil) + cdc.RegisterConcrete(&MsgDeleteGroup{}, "storage/DeleteGroup", nil) + cdc.RegisterConcrete(&MsgUpdateGroupMember{}, "storage/UpdateGroupMember", nil) + cdc.RegisterConcrete(&MsgLeaveGroup{}, "storage/LeaveGroup", nil) + cdc.RegisterConcrete(&MsgCopyObject{}, "storage/CopyObject", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateBucket{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDeleteBucket{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateObject{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSealObject{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRejectSealObject{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDeleteObject{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateGroup{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDeleteGroup{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateGroupMember{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgLeaveGroup{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCopyObject{}, + ) + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(Amino) +) + +func init() { + RegisterCodec(Amino) + cryptocodec.RegisterCrypto(Amino) + sdk.RegisterLegacyAminoCodec(Amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterCodec(authzcodec.Amino) +} diff --git a/x/storage/types/common.pb.go b/x/storage/types/common.pb.go new file mode 100644 index 000000000..4c137dbca --- /dev/null +++ b/x/storage/types/common.pb.go @@ -0,0 +1,71 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: greenfield/storage/common.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + math "math" +) + +// 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 SourceType int32 + +const ( + SOURCE_TYPE_ORIGIN SourceType = 0 + SOURCE_TYPE_BSC_CROSS_CHAIN SourceType = 1 +) + +var SourceType_name = map[int32]string{ + 0: "SOURCE_TYPE_ORIGIN", + 1: "SOURCE_TYPE_BSC_CROSS_CHAIN", +} + +var SourceType_value = map[string]int32{ + "SOURCE_TYPE_ORIGIN": 0, + "SOURCE_TYPE_BSC_CROSS_CHAIN": 1, +} + +func (x SourceType) String() string { + return proto.EnumName(SourceType_name, int32(x)) +} + +func (SourceType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4eff6c0fa4aaf4c9, []int{0} +} + +func init() { + proto.RegisterEnum("bnbchain.greenfield.storage.SourceType", SourceType_name, SourceType_value) +} + +func init() { proto.RegisterFile("greenfield/storage/common.proto", fileDescriptor_4eff6c0fa4aaf4c9) } + +var fileDescriptor_4eff6c0fa4aaf4c9 = []byte{ + // 217 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x2f, 0x4a, 0x4d, + 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0x4c, 0x4f, 0xd5, 0x4f, + 0xce, 0xcf, 0xcd, 0xcd, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x4e, 0xca, 0x4b, + 0x4a, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x43, 0xa8, 0xd4, 0x83, 0xaa, 0x94, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0xab, 0xd3, 0x07, 0xb1, 0x20, 0x5a, 0xb4, 0xbc, 0xb9, 0xb8, 0x82, 0xf3, 0x4b, 0x8b, + 0x92, 0x53, 0x43, 0x2a, 0x0b, 0x52, 0x85, 0xc4, 0xb8, 0x84, 0x82, 0xfd, 0x43, 0x83, 0x9c, 0x5d, + 0xe3, 0x43, 0x22, 0x03, 0x5c, 0xe3, 0xfd, 0x83, 0x3c, 0xdd, 0x3d, 0xfd, 0x04, 0x18, 0x84, 0xe4, + 0xb9, 0xa4, 0x91, 0xc5, 0x9d, 0x82, 0x9d, 0xe3, 0x9d, 0x83, 0xfc, 0x83, 0x83, 0xe3, 0x9d, 0x3d, + 0x1c, 0x3d, 0xfd, 0x04, 0x18, 0xa5, 0x58, 0x3a, 0x16, 0xcb, 0x31, 0x38, 0x79, 0x9e, 0x78, 0x24, + 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, + 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x5e, 0x92, 0x2e, 0xd8, 0x95, 0xfa, 0x48, 0xfe, 0xa9, 0x80, 0xfb, + 0xa8, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x3c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x19, 0xdd, 0x57, 0xbc, 0xf4, 0x00, 0x00, 0x00, +} diff --git a/x/storage/types/errors.go b/x/storage/types/errors.go new file mode 100644 index 000000000..6f9ac3e8e --- /dev/null +++ b/x/storage/types/errors.go @@ -0,0 +1,34 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/storage module sentinel errors +var ( + ErrNoSuchBucket = sdkerrors.Register(ModuleName, 1100, "no such bucket") + ErrNoSuchObject = sdkerrors.Register(ModuleName, 1101, "no such object") + ErrNoSuchGroup = sdkerrors.Register(ModuleName, 1102, "no such group") + ErrBucketAlreadyExists = sdkerrors.Register(ModuleName, 1103, "bucket already exists") + ErrObjectAlreadyExists = sdkerrors.Register(ModuleName, 1104, "object already exists") + ErrGroupAlreadyExists = sdkerrors.Register(ModuleName, 1105, "group already exists") + ErrAccessDenied = sdkerrors.Register(ModuleName, 1106, "access denied") + ErrSPAddressMismatch = sdkerrors.Register(ModuleName, 1107, "sp address mismatch") + ErrObjectAlreadySealed = sdkerrors.Register(ModuleName, 1108, "object already sealed") + ErrBucketNotEmpty = sdkerrors.Register(ModuleName, 1109, "bucket is not empty") + ErrNoSuchGroupMember = sdkerrors.Register(ModuleName, 1110, "no such group member") + ErrGroupMemberAlreadyExists = sdkerrors.Register(ModuleName, 1111, "group member already exists") + ErrGroupMemberNotExists = sdkerrors.Register(ModuleName, 1112, "group member already exists") + ErrNoSuchStorageProvider = sdkerrors.Register(ModuleName, 1113, "no such storage provider") + ErrSequenceUniqueConstraint = sdkerrors.Register(ModuleName, 1114, "sequence already initialized") + ErrStorageProviderNotInService = sdkerrors.Register(ModuleName, 1115, "storage provider not in service") + ErrObjectStatusNotInit = sdkerrors.Register(ModuleName, 1116, "not a INIT object") + + ErrInvalidBucketName = sdkerrors.Register(ModuleName, 2000, "invalid bucket name") + ErrInvalidObjectName = sdkerrors.Register(ModuleName, 2001, "invalid object name") + ErrInvalidGroupName = sdkerrors.Register(ModuleName, 2002, "invalid group name") + ErrInvalidChcecksum = sdkerrors.Register(ModuleName, 2003, "invalid checksum") + ErrInvalidContentType = sdkerrors.Register(ModuleName, 2004, "invalid content type") + ErrInvalidSPSignature = sdkerrors.Register(ModuleName, 2005, "invalid sp signature") + ErrInvalidSPAddress = sdkerrors.Register(ModuleName, 2006, "invalid sp address") +) diff --git a/x/greenfield/types/expected_keepers.go b/x/storage/types/expected_keepers.go similarity index 60% rename from x/greenfield/types/expected_keepers.go rename to x/storage/types/expected_keepers.go index 6aa6e9778..7b5423a64 100644 --- a/x/greenfield/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -2,12 +2,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + sptypes "github.com/bnb-chain/greenfield/x/sp/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // Methods imported from account should be defined here } @@ -16,3 +18,7 @@ type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins // Methods imported from bank should be defined here } + +type SpKeeper interface { + GetStorageProvider(ctx sdk.Context, addr sdk.AccAddress) (sp sptypes.StorageProvider, found bool) +} diff --git a/x/greenfield/types/genesis.go b/x/storage/types/genesis.go similarity index 87% rename from x/greenfield/types/genesis.go rename to x/storage/types/genesis.go index 0af9b4416..f2689b73b 100644 --- a/x/greenfield/types/genesis.go +++ b/x/storage/types/genesis.go @@ -1,9 +1,5 @@ package types -import ( -// this line is used by starport scaffolding # genesis/types/import -) - // DefaultIndex is the default global index const DefaultIndex uint64 = 1 diff --git a/x/greenfield/types/genesis.pb.go b/x/storage/types/genesis.pb.go similarity index 80% rename from x/greenfield/types/genesis.pb.go rename to x/storage/types/genesis.pb.go index fc72f0749..cee0c58a0 100644 --- a/x/greenfield/types/genesis.pb.go +++ b/x/storage/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: greenfield/greenfield/genesis.proto +// source: greenfield/storage/genesis.proto package types @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the greenfield module's genesis state. +// GenesisState defines the bridge module's genesis state. type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } @@ -32,7 +32,7 @@ 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_e64ba616cca8cc1c, []int{0} + return fileDescriptor_39c34a3268b4007b, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -69,27 +69,26 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "greenfield.greenfield.GenesisState") + proto.RegisterType((*GenesisState)(nil), "bnbchain.greenfield.storage.GenesisState") } -func init() { - proto.RegisterFile("greenfield/greenfield/genesis.proto", fileDescriptor_e64ba616cca8cc1c) -} +func init() { proto.RegisterFile("greenfield/storage/genesis.proto", fileDescriptor_39c34a3268b4007b) } -var fileDescriptor_e64ba616cca8cc1c = []byte{ - // 189 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0x2f, 0x4a, 0x4d, - 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x47, 0x66, 0xa6, 0xe6, 0xa5, 0x16, 0x67, 0x16, 0xeb, - 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x89, 0x22, 0x64, 0xf4, 0x10, 0x4c, 0x29, 0x91, 0xf4, 0xfc, - 0xf4, 0x7c, 0xb0, 0x0a, 0x7d, 0x10, 0x0b, 0xa2, 0x58, 0x4a, 0x09, 0xbb, 0x89, 0x05, 0x89, 0x45, - 0x89, 0xb9, 0x50, 0x03, 0x95, 0xbc, 0xb9, 0x78, 0xdc, 0x21, 0x36, 0x04, 0x97, 0x24, 0x96, 0xa4, - 0x0a, 0x59, 0x73, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x64, 0xf5, 0xb0, - 0xda, 0xa8, 0x17, 0x00, 0x56, 0xe4, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x8b, 0x93, - 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, - 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, - 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe5, 0x25, 0xe9, 0x26, 0x67, 0x24, 0x66, 0xe6, - 0x21, 0x3b, 0xaa, 0x02, 0x99, 0x53, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0xa1, 0x31, - 0x20, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x67, 0x18, 0x5b, 0x19, 0x01, 0x00, 0x00, +var fileDescriptor_39c34a3268b4007b = []byte{ + // 204 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x2f, 0x4a, 0x4d, + 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0x4c, 0x4f, 0xd5, 0x4f, + 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x4e, 0xca, + 0x4b, 0x4a, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x43, 0x28, 0xd5, 0x83, 0x2a, 0x95, 0x12, 0x49, 0xcf, + 0x4f, 0xcf, 0x07, 0xab, 0xd3, 0x07, 0xb1, 0x20, 0x5a, 0xa4, 0xe4, 0xb1, 0x18, 0x5a, 0x90, 0x58, + 0x94, 0x98, 0x0b, 0x35, 0x53, 0x29, 0x90, 0x8b, 0xc7, 0x1d, 0x62, 0x49, 0x70, 0x49, 0x62, 0x49, + 0xaa, 0x90, 0x23, 0x17, 0x1b, 0x44, 0x5e, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x59, 0x0f, + 0x8f, 0xa5, 0x7a, 0x01, 0x60, 0xa5, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x35, 0x3a, + 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, + 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, + 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x5e, 0x92, 0x2e, 0xd8, 0x5c, 0x7d, 0x24, + 0x27, 0x56, 0xc0, 0x1d, 0x59, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0xa4, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0xc6, 0xcd, 0xf1, 0x17, 0x1c, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/greenfield/types/genesis_test.go b/x/storage/types/genesis_test.go similarity index 74% rename from x/greenfield/types/genesis_test.go rename to x/storage/types/genesis_test.go index e4dfe007b..a542e9597 100644 --- a/x/greenfield/types/genesis_test.go +++ b/x/storage/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/bnb-chain/greenfield/x/greenfield/types" "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/x/storage/types" ) func TestGenesisState_Validate(t *testing.T) { @@ -19,8 +20,14 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ + types.Params{ + MaxSegmentSize: 20, + RedundantDataChunkNum: 10, + RedundantParityChunkNum: 8, + MaxPayloadSize: 2000, + }, // this line is used by starport scaffolding # types/genesis/validField }, diff --git a/x/storage/types/keys.go b/x/storage/types/keys.go new file mode 100644 index 000000000..392e62d5e --- /dev/null +++ b/x/storage/types/keys.go @@ -0,0 +1,52 @@ +package types + +import ( + "regexp" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName defines the module name + ModuleName = "storage" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_storage" +) + +var ( + BucketPrefix = []byte{0x10} + ObjectPrefix = []byte{0x11} + GroupPrefix = []byte{0x12} + GroupMemberPrefix = []byte{0x13} // TODO(fynn): will be deprecated after permission module ready + + validBucketName = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`) + ipAddress = regexp.MustCompile(`^(\d+\.){3}\d+$`) +) + +func GetBucketKey(bucketName string) []byte { + return sdk.Keccak256([]byte(bucketName)) +} + +func GetObjectKey(bucketName string, objectName string) []byte { + sdk.Keccak256() + bucketKey := sdk.Keccak256([]byte(bucketName)) + objectKey := sdk.Keccak256([]byte(objectName)) + return append(bucketKey, objectKey...) +} + +func GetGroupKey(owner string, groupName string) []byte { + groupKey := sdk.Keccak256([]byte(groupName)) + return append([]byte(owner), groupKey...) +} + +func GetGroupMemberKey(groupId math.Uint, memberAcc string) []byte { + return append(MustMarshalUint(groupId), []byte(memberAcc)...) +} diff --git a/x/storage/types/message.go b/x/storage/types/message.go new file mode 100644 index 000000000..13ca30991 --- /dev/null +++ b/x/storage/types/message.go @@ -0,0 +1,670 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcrypto "github.com/ethereum/go-ethereum/crypto" +) + +const ( + // For bucket + TypeMsgCreateBucket = "create_bucket" + TypeMsgDeleteBucket = "delete_bucket" + + // For object + TypeMsgCopyObject = "copy_object" + TypeMsgCreateObject = "create_object" + TypeMsgDeleteObject = "delete_object" + TypeMsgSealObject = "seal_object" + TypeMsgRejectSealObject = "reject_seal_object" + + // For group + TypeMsgCreateGroup = "create_group" + TypeMsgDeleteGroup = "delete_group" + TypeMsgLeaveGroup = "leave_group" + TypeMsgUpdateGroupMember = "update_group_member" +) + +var ( + // For bucket + _ sdk.Msg = &MsgCreateBucket{} + _ sdk.Msg = &MsgDeleteBucket{} + // For object + _ sdk.Msg = &MsgCreateObject{} + _ sdk.Msg = &MsgDeleteObject{} + _ sdk.Msg = &MsgSealObject{} + _ sdk.Msg = &MsgCopyObject{} + _ sdk.Msg = &MsgRejectSealObject{} + + // For group + _ sdk.Msg = &MsgCreateGroup{} + _ sdk.Msg = &MsgDeleteGroup{} + _ sdk.Msg = &MsgLeaveGroup{} + _ sdk.Msg = &MsgUpdateGroupMember{} +) + +// NewMsgCreateBucket creates a new MsgCreateBucket instance. +func NewMsgCreateBucket( + creator sdk.AccAddress, bucketName string, isPublic bool, + primarySPAddress sdk.AccAddress, paymentAddress sdk.AccAddress, primarySPApproval []byte) *MsgCreateBucket { + return &MsgCreateBucket{ + Creator: creator.String(), + BucketName: bucketName, + IsPublic: isPublic, + PaymentAddress: paymentAddress.String(), + PrimarySpAddress: primarySPAddress.String(), + PrimarySpApprovalSignature: primarySPApproval, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgCreateBucket) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgCreateBucket) Type() string { + return TypeMsgCreateBucket +} + +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +func (msg *MsgCreateBucket) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgCreateBucket) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgCreateBucket) ValidateBasic() error { + if _, err := sdk.AccAddressFromHexUnsafe(msg.Creator); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if _, err := sdk.AccAddressFromHexUnsafe(msg.PrimarySpAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid primary sp address (%s)", err) + } + + // PaymentAddress is optional, use creator by default if not set. + if msg.PaymentAddress != "" { + if _, err := sdk.AccAddressFromHexUnsafe(msg.PaymentAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid store payment address (%s)", err) + } + } + + if err := CheckValidBucketName(msg.BucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid bucket name (%s)", err) + } + return nil +} + +// NewMsgDeleteBucket creates a new MsgDeleteBucket instance +func NewMsgDeleteBucket(operator sdk.AccAddress, bucketName string) *MsgDeleteBucket { + return &MsgDeleteBucket{ + Operator: operator.String(), + BucketName: bucketName, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgDeleteBucket) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgDeleteBucket) Type() string { + return TypeMsgDeleteBucket +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgDeleteBucket) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes implements the sdk.Msg interface. +func (msg *MsgDeleteBucket) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgDeleteBucket) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidBucketName(msg.BucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid bucket name (%s)", err) + } + + return nil +} + +// NewMsgCreateObject creates a new MsgCreateObject instance. +func NewMsgCreateObject( + creator sdk.AccAddress, bucketName string, objectName string, payloadSize uint64, + isPublic bool, expectChecksums [][]byte, contentType string, primarySPApproval []byte, + secondarySPAccs []sdk.AccAddress) *MsgCreateObject { + + var secSPAddrs []string + for _, secondarySP := range secondarySPAccs { + secSPAddrs = append(secSPAddrs, secondarySP.String()) + } + + return &MsgCreateObject{ + Creator: creator.String(), + BucketName: bucketName, + ObjectName: objectName, + PayloadSize: payloadSize, + IsPublic: isPublic, + ContentType: contentType, + PrimarySpApprovalSignature: primarySPApproval, + ExpectChecksums: expectChecksums, + ExpectSecondarySpAddresses: secSPAddrs, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgCreateObject) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgCreateObject) Type() string { + return TypeMsgCreateObject +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgCreateObject) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgCreateObject) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgCreateObject) ValidateBasic() error { + if _, err := sdk.AccAddressFromHexUnsafe(msg.Creator); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidBucketName(msg.BucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid bucket name (%s)", err) + } + + if err := CheckValidObjectName(msg.ObjectName); err != nil { + return sdkerrors.Wrapf(ErrInvalidObjectName, "invalid object name (%s)", err) + } + + if err := CheckValidExpectChecksums(msg.ExpectChecksums); err != nil { + return sdkerrors.Wrapf(ErrInvalidChcecksum, "invalid checksum (%s)", err) + } + + if err := CheckValidContentType(msg.ContentType); err != nil { + return sdkerrors.Wrapf(ErrInvalidContentType, "invalid checksum (%s)", err) + } + + if msg.PrimarySpApprovalSignature == nil { + return sdkerrors.Wrapf(ErrInvalidSPSignature, "empty sp signature") + } + + for _, spAddress := range msg.ExpectSecondarySpAddresses { + if _, err := sdk.AccAddressFromHexUnsafe(spAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sp address (%s) in expect secondary SPs", err) + } + } + return nil +} + +func NewMsgDeleteObject(operator sdk.AccAddress, bucketName string, objectName string) *MsgDeleteObject { + return &MsgDeleteObject{ + Operator: operator.String(), + BucketName: bucketName, + ObjectName: objectName, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgDeleteObject) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgDeleteObject) Type() string { + return TypeMsgDeleteObject +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgDeleteObject) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgDeleteObject) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgDeleteObject) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidBucketName(msg.BucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid bucket name (%s)", err) + } + + if err := CheckValidObjectName(msg.ObjectName); err != nil { + return sdkerrors.Wrapf(ErrInvalidObjectName, "invalid object name (%s)", err) + } + return nil +} + +func NewMsgSealObject( + operator sdk.AccAddress, bucketName string, objectName string, + secondarySPAccs []sdk.AccAddress, secondarySpSignatures [][]byte) *MsgSealObject { + + var secondarySPAddresses []string + for _, secondarySP := range secondarySPAccs { + secondarySPAddresses = append(secondarySPAddresses, secondarySP.String()) + } + + return &MsgSealObject{ + Operator: operator.String(), + BucketName: bucketName, + ObjectName: objectName, + SecondarySpAddresses: secondarySPAddresses, + SecondarySpSignatures: secondarySpSignatures, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgSealObject) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgSealObject) Type() string { + return TypeMsgSealObject +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgSealObject) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgSealObject) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgSealObject) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if _, err := sdk.AccAddressFromHexUnsafe(msg.Operator); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidBucketName(msg.BucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid bucket name (%s)", err) + } + + if err := CheckValidObjectName(msg.ObjectName); err != nil { + return sdkerrors.Wrapf(ErrInvalidObjectName, "invalid object name (%s)", err) + } + + if len(msg.SecondarySpAddresses) != 6 { + return sdkerrors.Wrapf(ErrInvalidSPAddress, "Missing SP expect: (d%), but (d%)", 6, len(msg.SecondarySpAddresses)) + } + + for _, addr := range msg.SecondarySpAddresses { + _, err := sdk.AccAddressFromHexUnsafe(addr) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid secondary sp address (%s)", err) + } + } + + if len(msg.SecondarySpSignatures) != 6 { + return sdkerrors.Wrapf(ErrInvalidSPSignature, "Missing SP signatures") + } + + for _, sig := range msg.SecondarySpSignatures { + if sig == nil && len(sig) != ethcrypto.SignatureLength { + return sdkerrors.Wrapf(ErrInvalidSPSignature, "invalid SP signatures") + } + } + + return nil +} + +func NewMsgCopyObject( + operator sdk.AccAddress, srcBucketName string, dstBucketName string, + srcObjectName string, dstObjectName string, dstPrimarySPApproval []byte) *MsgCopyObject { + return &MsgCopyObject{ + Operator: operator.String(), + SrcBucketName: srcBucketName, + DstBucketName: dstBucketName, + SrcObjectName: srcObjectName, + DstObjectName: dstObjectName, + DstPrimarySpApprovalSignature: dstPrimarySPApproval, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgCopyObject) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgCopyObject) Type() string { + return TypeMsgCopyObject +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgCopyObject) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgCopyObject) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgCopyObject) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidBucketName(msg.SrcBucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid src bucket name (%s)", err) + } + + if err := CheckValidObjectName(msg.SrcObjectName); err != nil { + return sdkerrors.Wrapf(ErrInvalidObjectName, "invalid src object name (%s)", err) + } + + if err := CheckValidBucketName(msg.DstBucketName); err != nil { + return sdkerrors.Wrapf(ErrInvalidBucketName, "invalid src bucket name (%s)", err) + } + + if err := CheckValidObjectName(msg.DstObjectName); err != nil { + return sdkerrors.Wrapf(ErrInvalidObjectName, "invalid src object name (%s)", err) + } + return nil +} + +func NewMsgRejectUnsealedObject(operator sdk.AccAddress, bucketName string, objectName string) *MsgRejectSealObject { + return &MsgRejectSealObject{ + Operator: operator.String(), + BucketName: bucketName, + ObjectName: objectName, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgRejectSealObject) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgRejectSealObject) Type() string { + return TypeMsgRejectSealObject +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgRejectSealObject) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgRejectSealObject) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgRejectSealObject) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} + +func NewMsgCreateGroup(creator sdk.AccAddress, groupName string, membersAcc []sdk.AccAddress) *MsgCreateGroup { + var members []string + for _, member := range membersAcc { + members = append(members, member.String()) + } + return &MsgCreateGroup{ + Creator: creator.String(), + GroupName: groupName, + Members: members, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgCreateGroup) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgCreateGroup) Type() string { + return TypeMsgCreateGroup +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgCreateGroup) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgCreateGroup) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgCreateGroup) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidGroupName(msg.GroupName); err != nil { + return sdkerrors.Wrapf(ErrInvalidGroupName, "invalid groupName (%s)", err) + } + return nil +} + +func NewMsgDeleteGroup(operator sdk.AccAddress, groupName string) *MsgDeleteGroup { + return &MsgDeleteGroup{ + Operator: operator.String(), + GroupName: groupName, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgDeleteGroup) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgDeleteGroup) Type() string { + return TypeMsgDeleteGroup +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgDeleteGroup) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgDeleteGroup) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgDeleteGroup) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidGroupName(msg.GroupName); err != nil { + return sdkerrors.Wrapf(ErrInvalidGroupName, "invalid groupName (%s)", err) + } + return nil +} + +func NewMsgLeaveGroup(member sdk.AccAddress, groupOwner sdk.AccAddress, groupName string) *MsgLeaveGroup { + return &MsgLeaveGroup{ + Member: member.String(), + GroupOwner: groupOwner.String(), + GroupName: groupName, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgLeaveGroup) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgLeaveGroup) Type() string { + return TypeMsgLeaveGroup +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgLeaveGroup) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Member) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgLeaveGroup) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgLeaveGroup) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Member) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if err := CheckValidGroupName(msg.GroupName); err != nil { + return sdkerrors.Wrapf(ErrInvalidGroupName, "invalid groupName (%s)", err) + } + return nil +} + +func NewMsgUpdateGroupMember( + operator sdk.AccAddress, groupName string, membersToAdd []sdk.AccAddress, + membersToDelete []sdk.AccAddress) *MsgUpdateGroupMember { + var membersAddrToAdd, membersAddrToDelete []string + for _, member := range membersToAdd { + membersAddrToAdd = append(membersAddrToAdd, member.String()) + } + for _, member := range membersToDelete { + membersAddrToDelete = append(membersAddrToDelete, member.String()) + } + return &MsgUpdateGroupMember{ + Operator: operator.String(), + GroupName: groupName, + MembersToAdd: membersAddrToAdd, + MembersToDelete: membersAddrToDelete, + } +} + +// Route implements the sdk.Msg interface. +func (msg *MsgUpdateGroupMember) Route() string { + return RouterKey +} + +// Type implements the sdk.Msg interface. +func (msg *MsgUpdateGroupMember) Type() string { + return TypeMsgUpdateGroupMember +} + +// GetSigners implements the sdk.Msg interface. +func (msg *MsgUpdateGroupMember) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +// GetSignBytes returns the message bytes to sign over. +func (msg *MsgUpdateGroupMember) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgUpdateGroupMember) ValidateBasic() error { + _, err := sdk.AccAddressFromHexUnsafe(msg.Operator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/storage/types/message_test.go b/x/storage/types/message_test.go new file mode 100644 index 000000000..728e2d366 --- /dev/null +++ b/x/storage/types/message_test.go @@ -0,0 +1,418 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bnb-chain/greenfield/testutil/sample" +) + +var ( + testBucketName = "testbucket" + testObjectName = "testobject" + testGroupName = "testgroup" + testInvalidBucketNameWithLongLength = [68]byte{} +) + +func TestMsgCreateBucket_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateBucket + err error + }{ + { + name: "normal", + msg: MsgCreateBucket{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + IsPublic: true, + PaymentAddress: sample.AccAddress(), + PrimarySpAddress: sample.AccAddress(), + PrimarySpApprovalSignature: []byte(""), + }, + }, { + name: "invalid bucket name", + msg: MsgCreateBucket{ + Creator: sample.AccAddress(), + BucketName: "TestBucket", + IsPublic: true, + PaymentAddress: sample.AccAddress(), + PrimarySpAddress: sample.AccAddress(), + PrimarySpApprovalSignature: []byte(""), + }, + err: ErrInvalidBucketName, + }, { + name: "invalid bucket name", + msg: MsgCreateBucket{ + Creator: sample.AccAddress(), + BucketName: "Test-Bucket", + IsPublic: true, + PaymentAddress: sample.AccAddress(), + PrimarySpAddress: sample.AccAddress(), + PrimarySpApprovalSignature: []byte(""), + }, + err: ErrInvalidBucketName, + }, { + name: "invalid bucket name", + msg: MsgCreateBucket{ + Creator: sample.AccAddress(), + BucketName: "ss", + IsPublic: true, + PaymentAddress: sample.AccAddress(), + PrimarySpAddress: sample.AccAddress(), + PrimarySpApprovalSignature: []byte(""), + }, + err: ErrInvalidBucketName, + }, { + name: "invalid bucket name", + msg: MsgCreateBucket{ + Creator: sample.AccAddress(), + BucketName: string(testInvalidBucketNameWithLongLength[:]), + IsPublic: true, + PaymentAddress: sample.AccAddress(), + PrimarySpAddress: sample.AccAddress(), + PrimarySpApprovalSignature: []byte(""), + }, + err: ErrInvalidBucketName, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteBucket_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteBucket + err error + }{ + { + name: "normal", + msg: MsgDeleteBucket{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + }, + }, { + name: "invalid bucket name", + msg: MsgDeleteBucket{ + Operator: sample.AccAddress(), + BucketName: "testBucket", + }, + err: ErrInvalidBucketName, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgCreateObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateObject + err error + }{ + { + name: "normal", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + PayloadSize: 1024, + IsPublic: false, + ContentType: "content-type", + PrimarySpApprovalSignature: sample.Checksum(), + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + ExpectSecondarySpAddresses: []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress()}, + }, + }, { + name: "invalid object name", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "", + PayloadSize: 1024, + IsPublic: false, + ContentType: "content-type", + PrimarySpApprovalSignature: sample.Checksum(), + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + ExpectSecondarySpAddresses: []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress()}, + }, + err: ErrInvalidObjectName, + }, { + name: "invalid object name", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "../object", + PayloadSize: 1024, + IsPublic: false, + ContentType: "content-type", + PrimarySpApprovalSignature: sample.Checksum(), + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + ExpectSecondarySpAddresses: []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress()}, + }, + err: ErrInvalidObjectName, + }, { + name: "invalid object name", + msg: MsgCreateObject{ + Creator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: "//object", + PayloadSize: 1024, + IsPublic: false, + ContentType: "content-type", + PrimarySpApprovalSignature: sample.Checksum(), + ExpectChecksums: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + ExpectSecondarySpAddresses: []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress()}, + }, + err: ErrInvalidObjectName, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteObject + err error + }{ + { + name: "normal", + msg: MsgDeleteObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgCopyObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCopyObject + err error + }{ + { + name: "valid address", + msg: MsgCopyObject{ + Operator: sample.AccAddress(), + SrcBucketName: testBucketName, + SrcObjectName: testObjectName, + DstBucketName: "dst" + testBucketName, + DstObjectName: "dst" + testObjectName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgSealObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSealObject + err error + }{ + { + name: "normal", + msg: MsgSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + SecondarySpAddresses: []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), sample.AccAddress()}, + SecondarySpSignatures: [][]byte{sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum(), sample.Checksum()}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgRejectSealObject_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgRejectSealObject + err error + }{ + { + name: "normal", + msg: MsgRejectSealObject{ + Operator: sample.AccAddress(), + BucketName: testBucketName, + ObjectName: testObjectName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgCreateGroup_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateGroup + err error + }{ + { + name: "normal", + msg: MsgCreateGroup{ + Creator: sample.AccAddress(), + GroupName: testGroupName, + Members: []string{sample.AccAddress(), sample.AccAddress()}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteGroup_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteGroup + err error + }{ + { + name: "normal", + msg: MsgDeleteGroup{ + Operator: sample.AccAddress(), + GroupName: testGroupName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgLeaveGroup_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgLeaveGroup + err error + }{ + { + name: "normal", + msg: MsgLeaveGroup{ + Member: sample.AccAddress(), + GroupOwner: sample.AccAddress(), + GroupName: testGroupName, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUpdateGroupMember_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateGroupMember + err error + }{ + { + name: "normal", + msg: MsgUpdateGroupMember{ + Operator: sample.AccAddress(), + GroupName: testGroupName, + MembersToAdd: []string{sample.AccAddress(), sample.AccAddress()}, + MembersToDelete: []string{sample.AccAddress(), sample.AccAddress()}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/storage/types/params.go b/x/storage/types/params.go new file mode 100644 index 000000000..76f7a20d3 --- /dev/null +++ b/x/storage/types/params.go @@ -0,0 +1,131 @@ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +// storage params default values +const ( + DefaultMaxSegmentSize uint64 = 16 * 1024 * 1024 // 16M + DefaultRedundantDataChunkNum uint32 = 4 + DefaultRedundantParityChunkNum uint32 = 2 + DefaultMaxPayloadSize uint64 = 2 * 1024 * 1024 * 1024 +) + +var ( + KeyMaxSegmentSize = []byte("MaxSegmentSize") + KeyRedundantDataChunkNum = []byte("RedundantDataChunkNum") + KeyRedundantParityChunkNum = []byte("RedundantParityChunkNum") + KeyMaxPayloadSize = []byte("MaxPayloadSize") +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams( + maxSegmentSize uint64, redundantDataChunkNum uint32, + redundantParityChunkNum uint32, maxPayloadSize uint64) Params { + return Params{ + MaxSegmentSize: maxSegmentSize, + RedundantDataChunkNum: redundantDataChunkNum, + RedundantParityChunkNum: redundantParityChunkNum, + MaxPayloadSize: maxPayloadSize, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams(DefaultMaxSegmentSize, DefaultRedundantDataChunkNum, + DefaultRedundantParityChunkNum, DefaultMaxPayloadSize) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMaxSegmentSize, &p.MaxSegmentSize, validateMaxSegmentSize), + paramtypes.NewParamSetPair(KeyRedundantDataChunkNum, &p.RedundantDataChunkNum, validateRedundantDataChunkNum), + paramtypes.NewParamSetPair(KeyRedundantParityChunkNum, &p.RedundantParityChunkNum, validateRedundantParityChunkNum), + paramtypes.NewParamSetPair(KeyMaxPayloadSize, &p.MaxPayloadSize, validateMaxPayloadSize), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := validateMaxSegmentSize(p.MaxSegmentSize); err != nil { + return err + } + if err := validateRedundantDataChunkNum(p.RedundantDataChunkNum); err != nil { + return err + } + if err := validateRedundantParityChunkNum(p.RedundantParityChunkNum); err != nil { + return err + } + if err := validateMaxPayloadSize(p.MaxPayloadSize); err != nil { + return err + } + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +func validateMaxSegmentSize(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("max segment size must be positive: %d", v) + } + + return nil +} +func validateMaxPayloadSize(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("max payload size must be positive: %d", v) + } + + return nil +} + +func validateRedundantDataChunkNum(i interface{}) error { + v, ok := i.(uint32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("redundant data chunk num must be positive: %d", v) + } + + return nil +} +func validateRedundantParityChunkNum(i interface{}) error { + v, ok := i.(uint32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("redundant parity size chunk num must be positive: %d", v) + } + + return nil +} diff --git a/x/storage/types/params.pb.go b/x/storage/types/params.pb.go new file mode 100644 index 000000000..3e0fa6dc7 --- /dev/null +++ b/x/storage/types/params.pb.go @@ -0,0 +1,417 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: greenfield/storage/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/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 + +// Params defines the parameters for the module. +type Params struct { + // max_segment_size is the maximum size of a segment. default: 16M + MaxSegmentSize uint64 `protobuf:"varint,1,opt,name=max_segment_size,json=maxSegmentSize,proto3" json:"max_segment_size,omitempty"` + // redundant_data_check_num is the num of data chunks of EC redundancy algorithm + RedundantDataChunkNum uint32 `protobuf:"varint,2,opt,name=redundant_data_chunk_num,json=redundantDataChunkNum,proto3" json:"redundant_data_chunk_num,omitempty"` + // redundant_data_check_num is the num of parity chunks of EC redundancy algorithm + RedundantParityChunkNum uint32 `protobuf:"varint,3,opt,name=redundant_parity_chunk_num,json=redundantParityChunkNum,proto3" json:"redundant_parity_chunk_num,omitempty"` + // max_payload_size is the maximum size of the payload, default: 2G + MaxPayloadSize uint64 `protobuf:"varint,4,opt,name=max_payload_size,json=maxPayloadSize,proto3" json:"max_payload_size,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_127b8b1511d84eca, []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 + +func (m *Params) GetMaxSegmentSize() uint64 { + if m != nil { + return m.MaxSegmentSize + } + return 0 +} + +func (m *Params) GetRedundantDataChunkNum() uint32 { + if m != nil { + return m.RedundantDataChunkNum + } + return 0 +} + +func (m *Params) GetRedundantParityChunkNum() uint32 { + if m != nil { + return m.RedundantParityChunkNum + } + return 0 +} + +func (m *Params) GetMaxPayloadSize() uint64 { + if m != nil { + return m.MaxPayloadSize + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "bnbchain.greenfield.storage.Params") +} + +func init() { proto.RegisterFile("greenfield/storage/params.proto", fileDescriptor_127b8b1511d84eca) } + +var fileDescriptor_127b8b1511d84eca = []byte{ + // 291 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x18, 0x85, 0xe3, 0x7b, 0xab, 0x0e, 0x91, 0x40, 0x28, 0x02, 0x51, 0x15, 0xc9, 0xad, 0x98, 0xba, + 0x10, 0x0f, 0x0c, 0x48, 0xb0, 0x01, 0x0b, 0x0b, 0x8a, 0xda, 0x8d, 0x25, 0xfa, 0x9d, 0x18, 0xc7, + 0xa2, 0xb6, 0x23, 0xc7, 0x91, 0x92, 0x3e, 0x05, 0x23, 0x23, 0x8f, 0xc3, 0xd8, 0xb1, 0x23, 0x4a, + 0x5e, 0x04, 0xc5, 0xa9, 0xd2, 0x6e, 0xd6, 0x7f, 0xbe, 0xcf, 0x3a, 0x3a, 0xfe, 0x8c, 0x1b, 0xc6, + 0xd4, 0xbb, 0x60, 0xeb, 0x94, 0x14, 0x56, 0x1b, 0xe0, 0x8c, 0xe4, 0x60, 0x40, 0x16, 0x61, 0x6e, + 0xb4, 0xd5, 0xc1, 0x15, 0x55, 0x34, 0xc9, 0x40, 0xa8, 0xf0, 0x40, 0x86, 0x7b, 0x72, 0x7a, 0xce, + 0x35, 0xd7, 0x8e, 0x23, 0xdd, 0xab, 0x57, 0xae, 0x77, 0xc8, 0x1f, 0x47, 0xee, 0x8f, 0x60, 0xe1, + 0x9f, 0x49, 0xa8, 0xe2, 0x82, 0x71, 0xc9, 0x94, 0x8d, 0x0b, 0xb1, 0x61, 0x13, 0x34, 0x47, 0x8b, + 0xd1, 0xf2, 0x54, 0x42, 0xb5, 0xea, 0xcf, 0x2b, 0xb1, 0x61, 0xc1, 0x9d, 0x3f, 0x31, 0x2c, 0x2d, + 0x55, 0x0a, 0xca, 0xc6, 0x29, 0x58, 0x88, 0x93, 0xac, 0x54, 0x1f, 0xb1, 0x2a, 0xe5, 0xe4, 0xdf, + 0x1c, 0x2d, 0x4e, 0x96, 0x17, 0x43, 0xfe, 0x0c, 0x16, 0x9e, 0xba, 0xf4, 0xb5, 0x94, 0xc1, 0x83, + 0x3f, 0x3d, 0x88, 0x39, 0x18, 0x61, 0xeb, 0x23, 0xf5, 0xbf, 0x53, 0x2f, 0x07, 0x22, 0x72, 0xc0, + 0x20, 0xef, 0xfb, 0xe5, 0x50, 0xaf, 0x35, 0xa4, 0x7d, 0xbf, 0xd1, 0xd0, 0x2f, 0xea, 0xcf, 0x5d, + 0xbf, 0xfb, 0xd1, 0xd7, 0xf7, 0xcc, 0x7b, 0x7c, 0xf9, 0x69, 0x30, 0xda, 0x36, 0x18, 0xfd, 0x36, + 0x18, 0x7d, 0xb6, 0xd8, 0xdb, 0xb6, 0xd8, 0xdb, 0xb5, 0xd8, 0x7b, 0x23, 0x5c, 0xd8, 0xac, 0xa4, + 0x61, 0xa2, 0x25, 0xa1, 0x8a, 0xde, 0xb8, 0xcd, 0xc8, 0xd1, 0xba, 0xd5, 0xb0, 0xaf, 0xad, 0x73, + 0x56, 0xd0, 0xb1, 0x1b, 0xeb, 0xf6, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x98, 0x6b, 0x00, 0xbf, 0x82, + 0x01, 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 + if m.MaxPayloadSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxPayloadSize)) + i-- + dAtA[i] = 0x20 + } + if m.RedundantParityChunkNum != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RedundantParityChunkNum)) + i-- + dAtA[i] = 0x18 + } + if m.RedundantDataChunkNum != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RedundantDataChunkNum)) + i-- + dAtA[i] = 0x10 + } + if m.MaxSegmentSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxSegmentSize)) + i-- + dAtA[i] = 0x8 + } + 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 + if m.MaxSegmentSize != 0 { + n += 1 + sovParams(uint64(m.MaxSegmentSize)) + } + if m.RedundantDataChunkNum != 0 { + n += 1 + sovParams(uint64(m.RedundantDataChunkNum)) + } + if m.RedundantParityChunkNum != 0 { + n += 1 + sovParams(uint64(m.RedundantParityChunkNum)) + } + if m.MaxPayloadSize != 0 { + n += 1 + sovParams(uint64(m.MaxPayloadSize)) + } + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxSegmentSize", wireType) + } + m.MaxSegmentSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxSegmentSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RedundantDataChunkNum", wireType) + } + m.RedundantDataChunkNum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RedundantDataChunkNum |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RedundantParityChunkNum", wireType) + } + m.RedundantParityChunkNum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RedundantParityChunkNum |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxPayloadSize", wireType) + } + m.MaxPayloadSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxPayloadSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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/storage/types/query.pb.go b/x/storage/types/query.pb.go new file mode 100644 index 000000000..946a9c0e4 --- /dev/null +++ b/x/storage/types/query.pb.go @@ -0,0 +1,1375 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: greenfield/storage/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/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 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_b1b80b580af04cb0, []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 response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this 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_b1b80b580af04cb0, []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{} +} + +// this line is used by starport scaffolding # 3 +type QueryBucketRequest struct { + BucketName string `protobuf:"bytes,1,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` +} + +func (m *QueryBucketRequest) Reset() { *m = QueryBucketRequest{} } +func (m *QueryBucketRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBucketRequest) ProtoMessage() {} +func (*QueryBucketRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{2} +} +func (m *QueryBucketRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBucketRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBucketRequest.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 *QueryBucketRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBucketRequest.Merge(m, src) +} +func (m *QueryBucketRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBucketRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBucketRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBucketRequest proto.InternalMessageInfo + +func (m *QueryBucketRequest) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +type QueryBucketResponse struct { + BucketInfo *BucketInfo `protobuf:"bytes,1,opt,name=bucket_info,json=bucketInfo,proto3" json:"bucket_info,omitempty"` +} + +func (m *QueryBucketResponse) Reset() { *m = QueryBucketResponse{} } +func (m *QueryBucketResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBucketResponse) ProtoMessage() {} +func (*QueryBucketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{3} +} +func (m *QueryBucketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBucketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBucketResponse.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 *QueryBucketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBucketResponse.Merge(m, src) +} +func (m *QueryBucketResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBucketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBucketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBucketResponse proto.InternalMessageInfo + +func (m *QueryBucketResponse) GetBucketInfo() *BucketInfo { + if m != nil { + return m.BucketInfo + } + return nil +} + +type QueryObjectRequest struct { + BucketName string `protobuf:"bytes,1,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + ObjectName string `protobuf:"bytes,2,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` +} + +func (m *QueryObjectRequest) Reset() { *m = QueryObjectRequest{} } +func (m *QueryObjectRequest) String() string { return proto.CompactTextString(m) } +func (*QueryObjectRequest) ProtoMessage() {} +func (*QueryObjectRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{4} +} +func (m *QueryObjectRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryObjectRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryObjectRequest.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 *QueryObjectRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryObjectRequest.Merge(m, src) +} +func (m *QueryObjectRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryObjectRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryObjectRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryObjectRequest proto.InternalMessageInfo + +func (m *QueryObjectRequest) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *QueryObjectRequest) GetObjectName() string { + if m != nil { + return m.ObjectName + } + return "" +} + +type QueryObjectResponse struct { + ObjectInfo *ObjectInfo `protobuf:"bytes,1,opt,name=object_info,json=objectInfo,proto3" json:"object_info,omitempty"` +} + +func (m *QueryObjectResponse) Reset() { *m = QueryObjectResponse{} } +func (m *QueryObjectResponse) String() string { return proto.CompactTextString(m) } +func (*QueryObjectResponse) ProtoMessage() {} +func (*QueryObjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b1b80b580af04cb0, []int{5} +} +func (m *QueryObjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryObjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryObjectResponse.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 *QueryObjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryObjectResponse.Merge(m, src) +} +func (m *QueryObjectResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryObjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryObjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryObjectResponse proto.InternalMessageInfo + +func (m *QueryObjectResponse) GetObjectInfo() *ObjectInfo { + if m != nil { + return m.ObjectInfo + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "bnbchain.greenfield.storage.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "bnbchain.greenfield.storage.QueryParamsResponse") + proto.RegisterType((*QueryBucketRequest)(nil), "bnbchain.greenfield.storage.QueryBucketRequest") + proto.RegisterType((*QueryBucketResponse)(nil), "bnbchain.greenfield.storage.QueryBucketResponse") + proto.RegisterType((*QueryObjectRequest)(nil), "bnbchain.greenfield.storage.QueryObjectRequest") + proto.RegisterType((*QueryObjectResponse)(nil), "bnbchain.greenfield.storage.QueryObjectResponse") +} + +func init() { proto.RegisterFile("greenfield/storage/query.proto", fileDescriptor_b1b80b580af04cb0) } + +var fileDescriptor_b1b80b580af04cb0 = []byte{ + // 485 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xbf, 0x6e, 0x14, 0x31, + 0x10, 0xc6, 0x6f, 0x03, 0xac, 0x84, 0xd3, 0x99, 0x14, 0xe8, 0x88, 0xf6, 0x90, 0x29, 0x88, 0x22, + 0xb1, 0x4e, 0x82, 0x40, 0x54, 0x48, 0x5c, 0x45, 0x1a, 0xfe, 0x5c, 0x81, 0x10, 0x4d, 0x64, 0x2f, + 0x3e, 0x67, 0x21, 0xeb, 0xd9, 0xac, 0x7d, 0x88, 0x28, 0x4a, 0xc3, 0x0b, 0x80, 0x44, 0xcd, 0x13, + 0xf0, 0x22, 0x29, 0x23, 0xd1, 0x50, 0x21, 0x74, 0x87, 0xc4, 0x6b, 0xa0, 0xf3, 0xf8, 0x92, 0xb3, + 0xb8, 0x9c, 0xb6, 0x1b, 0x8d, 0xe7, 0xfb, 0xe6, 0x67, 0xcf, 0x98, 0x64, 0xba, 0x51, 0xca, 0x0c, + 0x4b, 0x75, 0xf0, 0x96, 0x5b, 0x07, 0x8d, 0xd0, 0x8a, 0x1f, 0x8e, 0x54, 0x73, 0x94, 0xd7, 0x0d, + 0x38, 0xa0, 0xb7, 0xa4, 0x91, 0xc5, 0xbe, 0x28, 0x4d, 0x7e, 0x51, 0x98, 0x87, 0xc2, 0xee, 0x66, + 0x01, 0xb6, 0x02, 0xcb, 0xa5, 0xb0, 0x41, 0xc5, 0x3f, 0x6c, 0x4b, 0xe5, 0xc4, 0x36, 0xaf, 0x85, + 0x2e, 0x8d, 0x70, 0x25, 0x18, 0x34, 0xea, 0xae, 0x69, 0xd0, 0xe0, 0x43, 0x3e, 0x8d, 0x42, 0x76, + 0x5d, 0x03, 0xe8, 0x03, 0xc5, 0x45, 0x5d, 0x72, 0x61, 0x0c, 0x38, 0x2f, 0xb1, 0xe1, 0xb4, 0xb7, + 0x00, 0xae, 0x16, 0x8d, 0xa8, 0x66, 0x05, 0x8b, 0xe8, 0xdd, 0x51, 0xad, 0xc2, 0x39, 0x5b, 0x23, + 0xf4, 0xe5, 0x14, 0xeb, 0x85, 0x17, 0x0d, 0xd4, 0xe1, 0x48, 0x59, 0xc7, 0x5e, 0x93, 0x1b, 0x51, + 0xd6, 0xd6, 0x60, 0xac, 0xa2, 0x4f, 0x48, 0x8a, 0xe6, 0x37, 0x93, 0xdb, 0xc9, 0xc6, 0xea, 0xce, + 0x9d, 0x7c, 0xc9, 0xdd, 0x73, 0x14, 0xf7, 0xaf, 0x9e, 0xfe, 0xea, 0x75, 0x06, 0x41, 0xc8, 0x1e, + 0x84, 0x7e, 0xfd, 0x51, 0xf1, 0x5e, 0xb9, 0xd0, 0x8f, 0xf6, 0xc8, 0xaa, 0xf4, 0x89, 0x3d, 0x23, + 0x2a, 0xe5, 0xdd, 0xaf, 0x0f, 0x08, 0xa6, 0x9e, 0x89, 0x4a, 0xb1, 0xbd, 0x00, 0x34, 0x93, 0x05, + 0xa0, 0xa7, 0xe7, 0xba, 0xd2, 0x0c, 0x21, 0x50, 0xdd, 0x5d, 0x4a, 0x85, 0x0e, 0xbb, 0x66, 0x08, + 0xb3, 0x06, 0xd3, 0x98, 0xbd, 0x0a, 0x5c, 0xcf, 0xe5, 0x3b, 0x55, 0xb4, 0xe6, 0x9a, 0x16, 0x80, + 0x57, 0x60, 0xc1, 0x0a, 0x16, 0x60, 0x2a, 0x02, 0x9f, 0xf9, 0x5e, 0x80, 0x07, 0x5d, 0x6b, 0x70, + 0x74, 0x40, 0x70, 0x38, 0x8f, 0x77, 0xfe, 0x5e, 0x21, 0xd7, 0x7c, 0x07, 0xfa, 0x39, 0x21, 0x29, + 0xbe, 0x39, 0xe5, 0x4b, 0x9d, 0xfe, 0x1f, 0x78, 0x77, 0xab, 0xbd, 0x00, 0x6f, 0xc0, 0xd8, 0xa7, + 0x1f, 0x7f, 0xbe, 0xae, 0xac, 0xd3, 0x2e, 0xbf, 0x74, 0x05, 0xe9, 0xb7, 0x84, 0xa4, 0xf8, 0xde, + 0x6d, 0x88, 0xa2, 0x95, 0x68, 0x43, 0x14, 0x2f, 0x03, 0xdb, 0xf2, 0x44, 0x9b, 0x74, 0x63, 0x11, + 0x11, 0xce, 0x8c, 0x1f, 0xcf, 0x8d, 0xf3, 0x84, 0x7e, 0x4f, 0x48, 0x8a, 0xcf, 0xda, 0x86, 0x2f, + 0x5a, 0x8d, 0x36, 0x7c, 0xf1, 0xcc, 0xd9, 0x63, 0xcf, 0xf7, 0x88, 0x3e, 0x5c, 0xc4, 0x87, 0x13, + 0x8d, 0xf9, 0xf8, 0xf1, 0xdc, 0x6e, 0x9d, 0xf4, 0x77, 0x4f, 0xc7, 0x59, 0x72, 0x36, 0xce, 0x92, + 0xdf, 0xe3, 0x2c, 0xf9, 0x32, 0xc9, 0x3a, 0x67, 0x93, 0xac, 0xf3, 0x73, 0x92, 0x75, 0xde, 0x70, + 0x5d, 0xba, 0xfd, 0x91, 0xcc, 0x0b, 0xa8, 0xb8, 0x34, 0xf2, 0x9e, 0xc7, 0x9a, 0xef, 0xf2, 0x31, + 0xfe, 0xfb, 0x32, 0xf5, 0x9f, 0xff, 0xfe, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x16, 0xae, 0x75, + 0x37, 0xdc, 0x04, 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 { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of Bucket items. + Bucket(ctx context.Context, in *QueryBucketRequest, opts ...grpc.CallOption) (*QueryBucketResponse, error) + // Queries a list of Object items. + Object(ctx context.Context, in *QueryObjectRequest, opts ...grpc.CallOption) (*QueryObjectResponse, 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, "/bnbchain.greenfield.storage.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Bucket(ctx context.Context, in *QueryBucketRequest, opts ...grpc.CallOption) (*QueryBucketResponse, error) { + out := new(QueryBucketResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Query/Bucket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Object(ctx context.Context, in *QueryObjectRequest, opts ...grpc.CallOption) (*QueryObjectResponse, error) { + out := new(QueryObjectResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Query/Object", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a list of Bucket items. + Bucket(context.Context, *QueryBucketRequest) (*QueryBucketResponse, error) + // Queries a list of Object items. + Object(context.Context, *QueryObjectRequest) (*QueryObjectResponse, 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) Bucket(ctx context.Context, req *QueryBucketRequest) (*QueryBucketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Bucket not implemented") +} +func (*UnimplementedQueryServer) Object(ctx context.Context, req *QueryObjectRequest) (*QueryObjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Object 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: "/bnbchain.greenfield.storage.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_Bucket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBucketRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Bucket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Query/Bucket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Bucket(ctx, req.(*QueryBucketRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Object_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryObjectRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Object(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Query/Object", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Object(ctx, req.(*QueryObjectRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "bnbchain.greenfield.storage.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Bucket", + Handler: _Query_Bucket_Handler, + }, + { + MethodName: "Object", + Handler: _Query_Object_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "greenfield/storage/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 *QueryBucketRequest) 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 *QueryBucketRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBucketRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBucketResponse) 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 *QueryBucketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBucketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BucketInfo != nil { + { + size, err := m.BucketInfo.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 *QueryObjectRequest) 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 *QueryObjectRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryObjectRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ObjectName) > 0 { + i -= len(m.ObjectName) + copy(dAtA[i:], m.ObjectName) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ObjectName))) + i-- + dAtA[i] = 0x12 + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryObjectResponse) 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 *QueryObjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryObjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ObjectInfo != nil { + { + size, err := m.ObjectInfo.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 *QueryBucketRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBucketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BucketInfo != nil { + l = m.BucketInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryObjectRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ObjectName) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryObjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ObjectInfo != nil { + l = m.ObjectInfo.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 *QueryBucketRequest) 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: QueryBucketRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBucketRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = 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 *QueryBucketResponse) 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: QueryBucketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBucketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketInfo", 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.BucketInfo == nil { + m.BucketInfo = &BucketInfo{} + } + if err := m.BucketInfo.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 *QueryObjectRequest) 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: QueryObjectRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryObjectRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectName", 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.ObjectName = 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 *QueryObjectResponse) 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: QueryObjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryObjectResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectInfo", 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.ObjectInfo == nil { + m.ObjectInfo = &ObjectInfo{} + } + if err := m.ObjectInfo.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/storage/types/query.pb.gw.go b/x/storage/types/query.pb.gw.go new file mode 100644 index 000000000..1fe5f95c8 --- /dev/null +++ b/x/storage/types/query.pb.gw.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: greenfield/storage/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 + +} + +func request_Query_Bucket_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBucketRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["bucket_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bucket_name") + } + + protoReq.BucketName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bucket_name", err) + } + + msg, err := client.Bucket(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Bucket_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBucketRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["bucket_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bucket_name") + } + + protoReq.BucketName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bucket_name", err) + } + + msg, err := server.Bucket(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Object_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryObjectRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["bucket_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bucket_name") + } + + protoReq.BucketName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bucket_name", err) + } + + val, ok = pathParams["object_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "object_name") + } + + protoReq.ObjectName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "object_name", err) + } + + msg, err := client.Object(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Object_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryObjectRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["bucket_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bucket_name") + } + + protoReq.BucketName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bucket_name", err) + } + + val, ok = pathParams["object_name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "object_name") + } + + protoReq.ObjectName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "object_name", err) + } + + msg, err := server.Object(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_Bucket_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_Bucket_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_Bucket_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Object_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_Object_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_Object_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_Bucket_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_Bucket_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_Bucket_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Object_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_Object_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_Object_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}, []string{"greenfield", "storage", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Bucket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "storage", "bucket", "bucket_name"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Object_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"greenfield", "storage", "object", "bucket_name", "object_name"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Bucket_0 = runtime.ForwardResponseMessage + + forward_Query_Object_0 = runtime.ForwardResponseMessage +) diff --git a/x/storage/types/tx.pb.go b/x/storage/types/tx.pb.go new file mode 100644 index 000000000..3413904a5 --- /dev/null +++ b/x/storage/types/tx.pb.go @@ -0,0 +1,5663 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: greenfield/storage/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + 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 + +type MsgCreateBucket struct { + // creator is the account address of bucket creator, it is also the bucket owner. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // bucket_name is a globally unique name of bucket + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // is_public means the bucket is private or public. if private, only bucket owner or grantee can read it, + // otherwise every greenfield user can read it. + IsPublic bool `protobuf:"varint,3,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"` + // payment_address is an account address specified by bucket owner to pay the read fee. Default: creator + PaymentAddress string `protobuf:"bytes,4,opt,name=payment_address,json=paymentAddress,proto3" json:"payment_address,omitempty"` + // primary_sp_address is the address of primary sp. + PrimarySpAddress string `protobuf:"bytes,6,opt,name=primary_sp_address,json=primarySpAddress,proto3" json:"primary_sp_address,omitempty"` + // primary_sp_approval_signature is the signature of the primary SP which indicates that primary sp confirm the user's request. + PrimarySpApprovalSignature []byte `protobuf:"bytes,7,opt,name=primary_sp_approval_signature,json=primarySpApprovalSignature,proto3" json:"primary_sp_approval_signature,omitempty"` +} + +func (m *MsgCreateBucket) Reset() { *m = MsgCreateBucket{} } +func (m *MsgCreateBucket) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBucket) ProtoMessage() {} +func (*MsgCreateBucket) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{0} +} +func (m *MsgCreateBucket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBucket.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 *MsgCreateBucket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBucket.Merge(m, src) +} +func (m *MsgCreateBucket) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBucket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBucket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBucket proto.InternalMessageInfo + +func (m *MsgCreateBucket) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreateBucket) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *MsgCreateBucket) GetIsPublic() bool { + if m != nil { + return m.IsPublic + } + return false +} + +func (m *MsgCreateBucket) GetPaymentAddress() string { + if m != nil { + return m.PaymentAddress + } + return "" +} + +func (m *MsgCreateBucket) GetPrimarySpAddress() string { + if m != nil { + return m.PrimarySpAddress + } + return "" +} + +func (m *MsgCreateBucket) GetPrimarySpApprovalSignature() []byte { + if m != nil { + return m.PrimarySpApprovalSignature + } + return nil +} + +type MsgCreateBucketResponse struct { +} + +func (m *MsgCreateBucketResponse) Reset() { *m = MsgCreateBucketResponse{} } +func (m *MsgCreateBucketResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBucketResponse) ProtoMessage() {} +func (*MsgCreateBucketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{1} +} +func (m *MsgCreateBucketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBucketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBucketResponse.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 *MsgCreateBucketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBucketResponse.Merge(m, src) +} +func (m *MsgCreateBucketResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBucketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBucketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBucketResponse proto.InternalMessageInfo + +type MsgDeleteBucket struct { + // creator is the account address of the grantee who has the DeleteBucket permission of the bucket to be deleted. + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // bucket_name is the name of the bucket to be deleted. + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` +} + +func (m *MsgDeleteBucket) Reset() { *m = MsgDeleteBucket{} } +func (m *MsgDeleteBucket) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteBucket) ProtoMessage() {} +func (*MsgDeleteBucket) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{2} +} +func (m *MsgDeleteBucket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteBucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteBucket.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 *MsgDeleteBucket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteBucket.Merge(m, src) +} +func (m *MsgDeleteBucket) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteBucket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteBucket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteBucket proto.InternalMessageInfo + +func (m *MsgDeleteBucket) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgDeleteBucket) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +type MsgDeleteBucketResponse struct { +} + +func (m *MsgDeleteBucketResponse) Reset() { *m = MsgDeleteBucketResponse{} } +func (m *MsgDeleteBucketResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteBucketResponse) ProtoMessage() {} +func (*MsgDeleteBucketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{3} +} +func (m *MsgDeleteBucketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteBucketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteBucketResponse.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 *MsgDeleteBucketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteBucketResponse.Merge(m, src) +} +func (m *MsgDeleteBucketResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteBucketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteBucketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteBucketResponse proto.InternalMessageInfo + +type MsgCreateObject struct { + // creator is the account address of object uploader + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // bucket_name is the name of the bucket where the object is stored. + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // object_name is the name of object + ObjectName string `protobuf:"bytes,3,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` + // payload_size is size of the object's payload + PayloadSize uint64 `protobuf:"varint,4,opt,name=payload_size,json=payloadSize,proto3" json:"payload_size,omitempty"` + // is_public means the bucket is private or public. if private, only bucket owner or grantee can access it, + // otherwise every greenfield user can access it. + IsPublic bool `protobuf:"varint,5,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"` + // content_type is a standard MIME type describing the format of the object. + ContentType string `protobuf:"bytes,6,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` + // primary_sp_approval_signature is the signature of the primary SP with its signature + // which indicates that primary sp confirm the user's creation request. + PrimarySpApprovalSignature []byte `protobuf:"bytes,7,opt,name=primary_sp_approval_signature,json=primarySpApprovalSignature,proto3" json:"primary_sp_approval_signature,omitempty"` + // expect_checksums is a list of hashes which was generate by redundancy algorithm. + ExpectChecksums [][]byte `protobuf:"bytes,8,rep,name=expect_checksums,json=expectChecksums,proto3" json:"expect_checksums,omitempty"` + // expect_secondarySPs is a list of StorageProvider address, which is optional + ExpectSecondarySpAddresses []string `protobuf:"bytes,9,rep,name=expect_secondary_sp_addresses,json=expectSecondarySpAddresses,proto3" json:"expect_secondary_sp_addresses,omitempty"` +} + +func (m *MsgCreateObject) Reset() { *m = MsgCreateObject{} } +func (m *MsgCreateObject) String() string { return proto.CompactTextString(m) } +func (*MsgCreateObject) ProtoMessage() {} +func (*MsgCreateObject) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{4} +} +func (m *MsgCreateObject) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateObject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateObject.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 *MsgCreateObject) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateObject.Merge(m, src) +} +func (m *MsgCreateObject) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateObject) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateObject.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateObject proto.InternalMessageInfo + +func (m *MsgCreateObject) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreateObject) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *MsgCreateObject) GetObjectName() string { + if m != nil { + return m.ObjectName + } + return "" +} + +func (m *MsgCreateObject) GetPayloadSize() uint64 { + if m != nil { + return m.PayloadSize + } + return 0 +} + +func (m *MsgCreateObject) GetIsPublic() bool { + if m != nil { + return m.IsPublic + } + return false +} + +func (m *MsgCreateObject) GetContentType() string { + if m != nil { + return m.ContentType + } + return "" +} + +func (m *MsgCreateObject) GetPrimarySpApprovalSignature() []byte { + if m != nil { + return m.PrimarySpApprovalSignature + } + return nil +} + +func (m *MsgCreateObject) GetExpectChecksums() [][]byte { + if m != nil { + return m.ExpectChecksums + } + return nil +} + +func (m *MsgCreateObject) GetExpectSecondarySpAddresses() []string { + if m != nil { + return m.ExpectSecondarySpAddresses + } + return nil +} + +type MsgCreateObjectResponse struct { +} + +func (m *MsgCreateObjectResponse) Reset() { *m = MsgCreateObjectResponse{} } +func (m *MsgCreateObjectResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateObjectResponse) ProtoMessage() {} +func (*MsgCreateObjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{5} +} +func (m *MsgCreateObjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateObjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateObjectResponse.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 *MsgCreateObjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateObjectResponse.Merge(m, src) +} +func (m *MsgCreateObjectResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateObjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateObjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateObjectResponse proto.InternalMessageInfo + +type MsgSealObject struct { + // operator is the account address of primary SP + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // bucket_name is the name of the bucket where the object is stored. + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // object_name is the name of object to be sealed. + ObjectName string `protobuf:"bytes,3,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` + // secondary_sp_addresses is a list of storage provider which store the redundant data. + SecondarySpAddresses []string `protobuf:"bytes,4,rep,name=secondary_sp_addresses,json=secondarySpAddresses,proto3" json:"secondary_sp_addresses,omitempty"` + // secondary_sp_signatures is the signature of the secondary sp that can + // acknowledge that the payload data has received and stored. + SecondarySpSignatures [][]byte `protobuf:"bytes,5,rep,name=secondary_sp_signatures,json=secondarySpSignatures,proto3" json:"secondary_sp_signatures,omitempty"` +} + +func (m *MsgSealObject) Reset() { *m = MsgSealObject{} } +func (m *MsgSealObject) String() string { return proto.CompactTextString(m) } +func (*MsgSealObject) ProtoMessage() {} +func (*MsgSealObject) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{6} +} +func (m *MsgSealObject) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSealObject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSealObject.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 *MsgSealObject) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSealObject.Merge(m, src) +} +func (m *MsgSealObject) XXX_Size() int { + return m.Size() +} +func (m *MsgSealObject) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSealObject.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSealObject proto.InternalMessageInfo + +func (m *MsgSealObject) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgSealObject) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *MsgSealObject) GetObjectName() string { + if m != nil { + return m.ObjectName + } + return "" +} + +func (m *MsgSealObject) GetSecondarySpAddresses() []string { + if m != nil { + return m.SecondarySpAddresses + } + return nil +} + +func (m *MsgSealObject) GetSecondarySpSignatures() [][]byte { + if m != nil { + return m.SecondarySpSignatures + } + return nil +} + +type MsgSealObjectResponse struct { +} + +func (m *MsgSealObjectResponse) Reset() { *m = MsgSealObjectResponse{} } +func (m *MsgSealObjectResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSealObjectResponse) ProtoMessage() {} +func (*MsgSealObjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{7} +} +func (m *MsgSealObjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSealObjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSealObjectResponse.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 *MsgSealObjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSealObjectResponse.Merge(m, src) +} +func (m *MsgSealObjectResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSealObjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSealObjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSealObjectResponse proto.InternalMessageInfo + +type MsgRejectSealObject struct { + // operator is the account address of the object owner + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // bucket_name is the name of the bucket where the object is stored. + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // object_name is the name of unsealed object to be reject. + ObjectName string `protobuf:"bytes,3,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` +} + +func (m *MsgRejectSealObject) Reset() { *m = MsgRejectSealObject{} } +func (m *MsgRejectSealObject) String() string { return proto.CompactTextString(m) } +func (*MsgRejectSealObject) ProtoMessage() {} +func (*MsgRejectSealObject) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{8} +} +func (m *MsgRejectSealObject) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRejectSealObject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRejectSealObject.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 *MsgRejectSealObject) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRejectSealObject.Merge(m, src) +} +func (m *MsgRejectSealObject) XXX_Size() int { + return m.Size() +} +func (m *MsgRejectSealObject) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRejectSealObject.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRejectSealObject proto.InternalMessageInfo + +func (m *MsgRejectSealObject) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgRejectSealObject) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *MsgRejectSealObject) GetObjectName() string { + if m != nil { + return m.ObjectName + } + return "" +} + +type MsgRejectSealObjectResponse struct { +} + +func (m *MsgRejectSealObjectResponse) Reset() { *m = MsgRejectSealObjectResponse{} } +func (m *MsgRejectSealObjectResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRejectSealObjectResponse) ProtoMessage() {} +func (*MsgRejectSealObjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{9} +} +func (m *MsgRejectSealObjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRejectSealObjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRejectSealObjectResponse.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 *MsgRejectSealObjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRejectSealObjectResponse.Merge(m, src) +} +func (m *MsgRejectSealObjectResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRejectSealObjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRejectSealObjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRejectSealObjectResponse proto.InternalMessageInfo + +type MsgCopyObject struct { + // operator is the account address of the operator who has the CopyObject permission of the object to be deleted. + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // src_bucket_name is the name of the bucket where the object to be copied is located + SrcBucketName string `protobuf:"bytes,2,opt,name=src_bucket_name,json=srcBucketName,proto3" json:"src_bucket_name,omitempty"` + // dst_bucket_name is the name of the bucket where the object is copied to. + DstBucketName string `protobuf:"bytes,3,opt,name=dst_bucket_name,json=dstBucketName,proto3" json:"dst_bucket_name,omitempty"` + // src_object_name is the name of the object which to be copied + SrcObjectName string `protobuf:"bytes,4,opt,name=src_object_name,json=srcObjectName,proto3" json:"src_object_name,omitempty"` + // dst_object_name is the name of the object which is copied to + DstObjectName string `protobuf:"bytes,5,opt,name=dst_object_name,json=dstObjectName,proto3" json:"dst_object_name,omitempty"` + // dst_primary_sp_approval_signature is a approval signature of primary sp + DstPrimarySpApprovalSignature []byte `protobuf:"bytes,6,opt,name=dst_primary_sp_approval_signature,json=dstPrimarySpApprovalSignature,proto3" json:"dst_primary_sp_approval_signature,omitempty"` +} + +func (m *MsgCopyObject) Reset() { *m = MsgCopyObject{} } +func (m *MsgCopyObject) String() string { return proto.CompactTextString(m) } +func (*MsgCopyObject) ProtoMessage() {} +func (*MsgCopyObject) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{10} +} +func (m *MsgCopyObject) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCopyObject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCopyObject.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 *MsgCopyObject) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCopyObject.Merge(m, src) +} +func (m *MsgCopyObject) XXX_Size() int { + return m.Size() +} +func (m *MsgCopyObject) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCopyObject.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCopyObject proto.InternalMessageInfo + +func (m *MsgCopyObject) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgCopyObject) GetSrcBucketName() string { + if m != nil { + return m.SrcBucketName + } + return "" +} + +func (m *MsgCopyObject) GetDstBucketName() string { + if m != nil { + return m.DstBucketName + } + return "" +} + +func (m *MsgCopyObject) GetSrcObjectName() string { + if m != nil { + return m.SrcObjectName + } + return "" +} + +func (m *MsgCopyObject) GetDstObjectName() string { + if m != nil { + return m.DstObjectName + } + return "" +} + +func (m *MsgCopyObject) GetDstPrimarySpApprovalSignature() []byte { + if m != nil { + return m.DstPrimarySpApprovalSignature + } + return nil +} + +type MsgCopyObjectResponse struct { +} + +func (m *MsgCopyObjectResponse) Reset() { *m = MsgCopyObjectResponse{} } +func (m *MsgCopyObjectResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCopyObjectResponse) ProtoMessage() {} +func (*MsgCopyObjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{11} +} +func (m *MsgCopyObjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCopyObjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCopyObjectResponse.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 *MsgCopyObjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCopyObjectResponse.Merge(m, src) +} +func (m *MsgCopyObjectResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCopyObjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCopyObjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCopyObjectResponse proto.InternalMessageInfo + +type MsgDeleteObject struct { + // operator is the account address of the operator who has the DeleteObject permission of the object to be deleted. + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // bucket_name is the name of the bucket where the object which to be deleted is stored. + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // object_name is the name of the object which to be deleted. + ObjectName string `protobuf:"bytes,3,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` +} + +func (m *MsgDeleteObject) Reset() { *m = MsgDeleteObject{} } +func (m *MsgDeleteObject) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteObject) ProtoMessage() {} +func (*MsgDeleteObject) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{12} +} +func (m *MsgDeleteObject) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteObject) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteObject.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 *MsgDeleteObject) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteObject.Merge(m, src) +} +func (m *MsgDeleteObject) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteObject) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteObject.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteObject proto.InternalMessageInfo + +func (m *MsgDeleteObject) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgDeleteObject) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *MsgDeleteObject) GetObjectName() string { + if m != nil { + return m.ObjectName + } + return "" +} + +type MsgDeleteObjectResponse struct { +} + +func (m *MsgDeleteObjectResponse) Reset() { *m = MsgDeleteObjectResponse{} } +func (m *MsgDeleteObjectResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteObjectResponse) ProtoMessage() {} +func (*MsgDeleteObjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{13} +} +func (m *MsgDeleteObjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteObjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteObjectResponse.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 *MsgDeleteObjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteObjectResponse.Merge(m, src) +} +func (m *MsgDeleteObjectResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteObjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteObjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteObjectResponse proto.InternalMessageInfo + +type MsgCreateGroup struct { + // owner is the account address of group owner who create the group + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // group_name is the name of the group. it's not globally unique. + GroupName string `protobuf:"bytes,2,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + // member_request is a list of member which to be add or remove + Members []string `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"` +} + +func (m *MsgCreateGroup) Reset() { *m = MsgCreateGroup{} } +func (m *MsgCreateGroup) String() string { return proto.CompactTextString(m) } +func (*MsgCreateGroup) ProtoMessage() {} +func (*MsgCreateGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{14} +} +func (m *MsgCreateGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateGroup.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 *MsgCreateGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateGroup.Merge(m, src) +} +func (m *MsgCreateGroup) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateGroup proto.InternalMessageInfo + +func (m *MsgCreateGroup) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreateGroup) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +func (m *MsgCreateGroup) GetMembers() []string { + if m != nil { + return m.Members + } + return nil +} + +type MsgCreateGroupResponse struct { +} + +func (m *MsgCreateGroupResponse) Reset() { *m = MsgCreateGroupResponse{} } +func (m *MsgCreateGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateGroupResponse) ProtoMessage() {} +func (*MsgCreateGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{15} +} +func (m *MsgCreateGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateGroupResponse.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 *MsgCreateGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateGroupResponse.Merge(m, src) +} +func (m *MsgCreateGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateGroupResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateGroupResponse proto.InternalMessageInfo + +type MsgDeleteGroup struct { + // operator is the account address of the operator who has the DeleteGroup permission of the group to be deleted. + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // group_name is the name of the group which to be deleted + GroupName string `protobuf:"bytes,2,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` +} + +func (m *MsgDeleteGroup) Reset() { *m = MsgDeleteGroup{} } +func (m *MsgDeleteGroup) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteGroup) ProtoMessage() {} +func (*MsgDeleteGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{16} +} +func (m *MsgDeleteGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteGroup.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 *MsgDeleteGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteGroup.Merge(m, src) +} +func (m *MsgDeleteGroup) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteGroup proto.InternalMessageInfo + +func (m *MsgDeleteGroup) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgDeleteGroup) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +type MsgDeleteGroupResponse struct { +} + +func (m *MsgDeleteGroupResponse) Reset() { *m = MsgDeleteGroupResponse{} } +func (m *MsgDeleteGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteGroupResponse) ProtoMessage() {} +func (*MsgDeleteGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{17} +} +func (m *MsgDeleteGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteGroupResponse.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 *MsgDeleteGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteGroupResponse.Merge(m, src) +} +func (m *MsgDeleteGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteGroupResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteGroupResponse proto.InternalMessageInfo + +type MsgUpdateGroupMember struct { + // operator is the account address of the operator who has the UpdateGroupMember permission of the group. + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // group_name is the name of the group which to be updated + GroupName string `protobuf:"bytes,2,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + // members_to_add is a list of members account address which will be add to the group + MembersToAdd []string `protobuf:"bytes,3,rep,name=members_to_add,json=membersToAdd,proto3" json:"members_to_add,omitempty"` + // members_to_delete is a list of members account address which will be remove from the group + MembersToDelete []string `protobuf:"bytes,4,rep,name=members_to_delete,json=membersToDelete,proto3" json:"members_to_delete,omitempty"` +} + +func (m *MsgUpdateGroupMember) Reset() { *m = MsgUpdateGroupMember{} } +func (m *MsgUpdateGroupMember) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupMember) ProtoMessage() {} +func (*MsgUpdateGroupMember) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{18} +} +func (m *MsgUpdateGroupMember) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupMember.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 *MsgUpdateGroupMember) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupMember.Merge(m, src) +} +func (m *MsgUpdateGroupMember) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupMember) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupMember.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupMember proto.InternalMessageInfo + +func (m *MsgUpdateGroupMember) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *MsgUpdateGroupMember) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +func (m *MsgUpdateGroupMember) GetMembersToAdd() []string { + if m != nil { + return m.MembersToAdd + } + return nil +} + +func (m *MsgUpdateGroupMember) GetMembersToDelete() []string { + if m != nil { + return m.MembersToDelete + } + return nil +} + +type MsgUpdateGroupMemberResponse struct { +} + +func (m *MsgUpdateGroupMemberResponse) Reset() { *m = MsgUpdateGroupMemberResponse{} } +func (m *MsgUpdateGroupMemberResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupMemberResponse) ProtoMessage() {} +func (*MsgUpdateGroupMemberResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{19} +} +func (m *MsgUpdateGroupMemberResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupMemberResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupMemberResponse.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 *MsgUpdateGroupMemberResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupMemberResponse.Merge(m, src) +} +func (m *MsgUpdateGroupMemberResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupMemberResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupMemberResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupMemberResponse proto.InternalMessageInfo + +type MsgLeaveGroup struct { + // member is the account address of the member who want to leave the group + Member string `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` + // group_owner is the owner of the group you want to leave + GroupOwner string `protobuf:"bytes,2,opt,name=group_owner,json=groupOwner,proto3" json:"group_owner,omitempty"` + // group_name is the name of the group you want to leave + GroupName string `protobuf:"bytes,3,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` +} + +func (m *MsgLeaveGroup) Reset() { *m = MsgLeaveGroup{} } +func (m *MsgLeaveGroup) String() string { return proto.CompactTextString(m) } +func (*MsgLeaveGroup) ProtoMessage() {} +func (*MsgLeaveGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{20} +} +func (m *MsgLeaveGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLeaveGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLeaveGroup.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 *MsgLeaveGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLeaveGroup.Merge(m, src) +} +func (m *MsgLeaveGroup) XXX_Size() int { + return m.Size() +} +func (m *MsgLeaveGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLeaveGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLeaveGroup proto.InternalMessageInfo + +func (m *MsgLeaveGroup) GetMember() string { + if m != nil { + return m.Member + } + return "" +} + +func (m *MsgLeaveGroup) GetGroupOwner() string { + if m != nil { + return m.GroupOwner + } + return "" +} + +func (m *MsgLeaveGroup) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +type MsgLeaveGroupResponse struct { +} + +func (m *MsgLeaveGroupResponse) Reset() { *m = MsgLeaveGroupResponse{} } +func (m *MsgLeaveGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgLeaveGroupResponse) ProtoMessage() {} +func (*MsgLeaveGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ddb71b028305a3cc, []int{21} +} +func (m *MsgLeaveGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLeaveGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLeaveGroupResponse.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 *MsgLeaveGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLeaveGroupResponse.Merge(m, src) +} +func (m *MsgLeaveGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgLeaveGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLeaveGroupResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLeaveGroupResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateBucket)(nil), "bnbchain.greenfield.storage.MsgCreateBucket") + proto.RegisterType((*MsgCreateBucketResponse)(nil), "bnbchain.greenfield.storage.MsgCreateBucketResponse") + proto.RegisterType((*MsgDeleteBucket)(nil), "bnbchain.greenfield.storage.MsgDeleteBucket") + proto.RegisterType((*MsgDeleteBucketResponse)(nil), "bnbchain.greenfield.storage.MsgDeleteBucketResponse") + proto.RegisterType((*MsgCreateObject)(nil), "bnbchain.greenfield.storage.MsgCreateObject") + proto.RegisterType((*MsgCreateObjectResponse)(nil), "bnbchain.greenfield.storage.MsgCreateObjectResponse") + proto.RegisterType((*MsgSealObject)(nil), "bnbchain.greenfield.storage.MsgSealObject") + proto.RegisterType((*MsgSealObjectResponse)(nil), "bnbchain.greenfield.storage.MsgSealObjectResponse") + proto.RegisterType((*MsgRejectSealObject)(nil), "bnbchain.greenfield.storage.MsgRejectSealObject") + proto.RegisterType((*MsgRejectSealObjectResponse)(nil), "bnbchain.greenfield.storage.MsgRejectSealObjectResponse") + proto.RegisterType((*MsgCopyObject)(nil), "bnbchain.greenfield.storage.MsgCopyObject") + proto.RegisterType((*MsgCopyObjectResponse)(nil), "bnbchain.greenfield.storage.MsgCopyObjectResponse") + proto.RegisterType((*MsgDeleteObject)(nil), "bnbchain.greenfield.storage.MsgDeleteObject") + proto.RegisterType((*MsgDeleteObjectResponse)(nil), "bnbchain.greenfield.storage.MsgDeleteObjectResponse") + proto.RegisterType((*MsgCreateGroup)(nil), "bnbchain.greenfield.storage.MsgCreateGroup") + proto.RegisterType((*MsgCreateGroupResponse)(nil), "bnbchain.greenfield.storage.MsgCreateGroupResponse") + proto.RegisterType((*MsgDeleteGroup)(nil), "bnbchain.greenfield.storage.MsgDeleteGroup") + proto.RegisterType((*MsgDeleteGroupResponse)(nil), "bnbchain.greenfield.storage.MsgDeleteGroupResponse") + proto.RegisterType((*MsgUpdateGroupMember)(nil), "bnbchain.greenfield.storage.MsgUpdateGroupMember") + proto.RegisterType((*MsgUpdateGroupMemberResponse)(nil), "bnbchain.greenfield.storage.MsgUpdateGroupMemberResponse") + proto.RegisterType((*MsgLeaveGroup)(nil), "bnbchain.greenfield.storage.MsgLeaveGroup") + proto.RegisterType((*MsgLeaveGroupResponse)(nil), "bnbchain.greenfield.storage.MsgLeaveGroupResponse") +} + +func init() { proto.RegisterFile("greenfield/storage/tx.proto", fileDescriptor_ddb71b028305a3cc) } + +var fileDescriptor_ddb71b028305a3cc = []byte{ + // 1106 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0x8e, 0xb3, 0xf9, 0xf9, 0x76, 0x93, 0x4d, 0x4d, 0xda, 0xb8, 0x0e, 0xd9, 0x6c, 0x72, 0xa8, + 0x42, 0x4b, 0x77, 0xdb, 0xb4, 0x42, 0xb4, 0x07, 0xa4, 0x24, 0x15, 0x3f, 0x24, 0xb6, 0xa9, 0x76, + 0xcb, 0x05, 0x0e, 0x2b, 0xff, 0x18, 0x1c, 0xb7, 0x6b, 0x8f, 0xe5, 0xf1, 0xa6, 0xd9, 0x1e, 0x10, + 0x20, 0x71, 0xe7, 0xc8, 0x01, 0x71, 0x02, 0x89, 0x23, 0x07, 0xfe, 0x03, 0x2e, 0x1c, 0x2b, 0x4e, + 0xdc, 0x40, 0xc9, 0x81, 0x7f, 0x03, 0x79, 0x66, 0x3c, 0x9e, 0xf5, 0x6e, 0xd7, 0x4e, 0x45, 0x44, + 0x4f, 0x91, 0x27, 0xdf, 0xfb, 0xde, 0xf7, 0xbe, 0xf7, 0xfc, 0x76, 0x64, 0x58, 0x77, 0x42, 0x84, + 0xfc, 0xcf, 0x5d, 0xd4, 0xb3, 0x9b, 0x24, 0xc2, 0xa1, 0xe1, 0xa0, 0x66, 0x74, 0xd2, 0x08, 0x42, + 0x1c, 0x61, 0x75, 0xdd, 0xf4, 0x4d, 0xeb, 0xc8, 0x70, 0xfd, 0x46, 0x8a, 0x6a, 0x70, 0x94, 0xbe, + 0x66, 0x61, 0xe2, 0x61, 0xd2, 0xf4, 0x88, 0xd3, 0x3c, 0xbe, 0x1d, 0xff, 0x61, 0x51, 0xfa, 0x55, + 0xf6, 0x8f, 0x2e, 0x7d, 0x6a, 0xb2, 0x07, 0xfe, 0xaf, 0xcd, 0x31, 0xd9, 0x2c, 0xec, 0x79, 0xd8, + 0x67, 0x80, 0xed, 0xbf, 0xa6, 0xa1, 0xda, 0x22, 0xce, 0x41, 0x88, 0x8c, 0x08, 0xed, 0xf7, 0xad, + 0xa7, 0x28, 0x52, 0x77, 0x61, 0xde, 0x8a, 0x9f, 0x71, 0xa8, 0x29, 0x75, 0x65, 0x67, 0x71, 0x5f, + 0xfb, 0xe3, 0xd7, 0x9b, 0xab, 0x9c, 0x77, 0xcf, 0xb6, 0x43, 0x44, 0x48, 0x27, 0x0a, 0x5d, 0xdf, + 0x69, 0x27, 0x40, 0x75, 0x13, 0xca, 0x26, 0x8d, 0xee, 0xfa, 0x86, 0x87, 0xb4, 0xe9, 0x38, 0xae, + 0x0d, 0xec, 0xe8, 0xa1, 0xe1, 0x21, 0x75, 0x1d, 0x16, 0x5d, 0xd2, 0x0d, 0xfa, 0x66, 0xcf, 0xb5, + 0xb4, 0x52, 0x5d, 0xd9, 0x59, 0x68, 0x2f, 0xb8, 0xe4, 0x11, 0x7d, 0x56, 0xf7, 0xa0, 0x1a, 0x18, + 0x03, 0x0f, 0xf9, 0x51, 0xd7, 0x60, 0xfc, 0xda, 0x4c, 0x4e, 0xe6, 0x65, 0x1e, 0xc0, 0x4f, 0xd5, + 0xf7, 0x41, 0x0d, 0x42, 0xd7, 0x33, 0xc2, 0x41, 0x97, 0x04, 0x82, 0x65, 0x2e, 0x87, 0x65, 0x85, + 0xc7, 0x74, 0x82, 0x84, 0x67, 0x0f, 0x36, 0x64, 0x9e, 0x20, 0x08, 0xf1, 0xb1, 0xd1, 0xeb, 0x12, + 0xd7, 0xf1, 0x8d, 0xa8, 0x1f, 0x22, 0x6d, 0xbe, 0xae, 0xec, 0x54, 0xda, 0x7a, 0x1a, 0xc8, 0x21, + 0x9d, 0x04, 0x71, 0xbf, 0xf2, 0xf5, 0x3f, 0xbf, 0x5c, 0x4f, 0x9c, 0xd9, 0xbe, 0x0a, 0x6b, 0x19, + 0x83, 0xdb, 0x88, 0x04, 0xd8, 0x27, 0x68, 0xfb, 0x19, 0xf5, 0xfe, 0x01, 0xea, 0x21, 0xe1, 0xfd, + 0x5d, 0x58, 0xc0, 0x01, 0x0a, 0x0b, 0x99, 0x2f, 0x90, 0xb9, 0xee, 0xdf, 0x5f, 0x8a, 0x25, 0x09, + 0x3c, 0xd7, 0x24, 0x27, 0x16, 0x9a, 0x7e, 0x2b, 0x49, 0x03, 0x71, 0x68, 0x3e, 0x41, 0xd6, 0x05, + 0x0d, 0xc4, 0x26, 0x94, 0x31, 0xa5, 0x67, 0x80, 0x12, 0x03, 0xb0, 0x23, 0x0a, 0xd8, 0x82, 0x4a, + 0x60, 0x0c, 0x7a, 0xd8, 0xb0, 0xbb, 0xc4, 0x7d, 0x8e, 0xe8, 0x44, 0xcc, 0xb4, 0xcb, 0xfc, 0xac, + 0xe3, 0x3e, 0xcf, 0x0c, 0xd5, 0x6c, 0x66, 0xa8, 0xb6, 0xa0, 0x62, 0x61, 0x3f, 0x8a, 0x87, 0x2a, + 0x1a, 0x04, 0x88, 0xcd, 0x42, 0xbb, 0xcc, 0xcf, 0x1e, 0x0f, 0x02, 0xf4, 0x1f, 0x34, 0x5b, 0x7d, + 0x0b, 0x56, 0xd0, 0x49, 0x10, 0x97, 0x61, 0x1d, 0x21, 0xeb, 0x29, 0xe9, 0x7b, 0x44, 0x5b, 0xa8, + 0x97, 0x76, 0x2a, 0xed, 0x2a, 0x3b, 0x3f, 0x48, 0x8e, 0xd5, 0xcf, 0x60, 0x83, 0x43, 0x09, 0xb2, + 0xb0, 0x6f, 0x0f, 0xcf, 0x2a, 0x22, 0xda, 0x62, 0xbd, 0x34, 0xd1, 0x5c, 0x9d, 0x85, 0x77, 0x92, + 0x68, 0x31, 0xb5, 0x88, 0x4c, 0x18, 0x3a, 0xd6, 0x44, 0xd1, 0xe0, 0x1f, 0xa6, 0x61, 0xa9, 0x45, + 0x9c, 0x0e, 0x32, 0x7a, 0xbc, 0xbd, 0x17, 0x33, 0x73, 0xf9, 0x0d, 0x7e, 0x08, 0x57, 0x5e, 0x62, + 0xc4, 0x4c, 0x8e, 0x11, 0xab, 0x64, 0x8c, 0x05, 0xea, 0x3b, 0xb0, 0x36, 0xc4, 0x27, 0xda, 0x48, + 0xb4, 0x59, 0xda, 0x91, 0xcb, 0x52, 0x98, 0xe8, 0x20, 0xc9, 0xbe, 0x1c, 0x6b, 0x70, 0x79, 0xc8, + 0x1f, 0xe1, 0xdc, 0xf7, 0x0a, 0xbc, 0xd1, 0x22, 0x4e, 0x1b, 0x3d, 0xa1, 0x4d, 0xf8, 0xbf, 0xfd, + 0xcb, 0xea, 0xde, 0x80, 0xf5, 0x31, 0xea, 0x84, 0xfa, 0x1f, 0x59, 0xdf, 0x0f, 0x70, 0x30, 0xe0, + 0xba, 0xf5, 0xac, 0x6e, 0x49, 0xdd, 0x35, 0xa8, 0x92, 0xd0, 0xea, 0x8e, 0x2a, 0x5c, 0x22, 0xa1, + 0xb5, 0x9f, 0x8a, 0xbc, 0x06, 0x55, 0x9b, 0x44, 0x43, 0x38, 0x26, 0x74, 0xc9, 0x26, 0xd1, 0x30, + 0x2e, 0xe6, 0x93, 0x0b, 0x9a, 0x11, 0x7c, 0x87, 0xe9, 0x4c, 0x70, 0x3e, 0x19, 0x37, 0x2b, 0xf8, + 0x24, 0xdc, 0x87, 0xb0, 0x15, 0xe3, 0x26, 0xbf, 0xbd, 0x73, 0xf4, 0xed, 0xdd, 0xb0, 0x49, 0xf4, + 0xe8, 0xe5, 0xdb, 0x7a, 0x6c, 0xf7, 0x53, 0x97, 0x84, 0x7f, 0xdf, 0x29, 0xd2, 0xb6, 0x7e, 0xbd, + 0x3a, 0x2f, 0xaf, 0xf3, 0x8c, 0xea, 0x9f, 0x14, 0x58, 0x16, 0x9b, 0xe0, 0x83, 0x10, 0xf7, 0x83, + 0x57, 0xda, 0xe6, 0x1b, 0x00, 0x4e, 0x1c, 0x2c, 0x2b, 0x5e, 0xa4, 0x27, 0x54, 0xf0, 0x2e, 0xcc, + 0x7b, 0xc8, 0x33, 0x51, 0x48, 0xb4, 0x52, 0xce, 0xab, 0x9b, 0x00, 0x33, 0x0b, 0x4b, 0x83, 0x2b, + 0xc3, 0x32, 0x45, 0x05, 0x11, 0x2d, 0x80, 0x15, 0xc7, 0x0a, 0x78, 0x35, 0xd7, 0x27, 0x97, 0x90, + 0xb5, 0x94, 0xe9, 0x91, 0xb2, 0x0a, 0x3d, 0x5f, 0x4e, 0xc3, 0x6a, 0x8b, 0x38, 0x9f, 0x04, 0x76, + 0x22, 0xb5, 0x45, 0x2b, 0xba, 0x10, 0x59, 0xea, 0x7b, 0xb0, 0xcc, 0x0d, 0xeb, 0x46, 0x38, 0xde, + 0x90, 0xb9, 0x06, 0x57, 0x38, 0xfe, 0x31, 0xde, 0xb3, 0x6d, 0xf5, 0x01, 0x5c, 0x92, 0xe2, 0x6d, + 0x5a, 0x4f, 0xee, 0x7a, 0xad, 0x0a, 0x0a, 0x66, 0x40, 0xd6, 0x9c, 0x1a, 0xbc, 0x39, 0xce, 0x01, + 0x61, 0xd1, 0xcf, 0x0a, 0x5d, 0x35, 0x1f, 0x23, 0xe3, 0x98, 0xb7, 0xec, 0x16, 0xcc, 0x31, 0xce, + 0x5c, 0x67, 0x38, 0x4e, 0xbd, 0x07, 0x65, 0xe6, 0x0b, 0x7e, 0xe6, 0xa3, 0x90, 0x19, 0x33, 0x21, + 0x8c, 0x99, 0x78, 0x18, 0x63, 0x33, 0x96, 0x96, 0xb2, 0x9d, 0x2e, 0xc7, 0xc5, 0xf0, 0x34, 0xfc, + 0x75, 0x4f, 0x95, 0x26, 0x35, 0xec, 0x7e, 0x03, 0x50, 0x6a, 0x11, 0x47, 0x0d, 0xa1, 0x32, 0x74, + 0x39, 0x7e, 0xbb, 0x31, 0xe1, 0x8e, 0xde, 0xc8, 0xdc, 0xf4, 0xf4, 0xbb, 0xe7, 0x41, 0x27, 0xb9, + 0xe3, 0x9c, 0x43, 0x97, 0xc2, 0xdc, 0x9c, 0x32, 0x3a, 0x3f, 0xe7, 0xb8, 0x7b, 0x5f, 0x5a, 0x27, + 0x5f, 0x6d, 0x05, 0xeb, 0x64, 0xe8, 0xa2, 0x75, 0x0e, 0x2f, 0x27, 0xb5, 0x07, 0x20, 0xfd, 0x8c, + 0x5e, 0xcf, 0xe3, 0x48, 0xb1, 0xfa, 0x6e, 0x71, 0xac, 0xc8, 0xf6, 0x05, 0xac, 0x8c, 0xfc, 0x74, + 0xdf, 0xca, 0xe3, 0xc9, 0x46, 0xe8, 0xef, 0x9e, 0x37, 0x62, 0xb4, 0xab, 0x45, 0x1d, 0x96, 0xd1, + 0x45, 0xbb, 0x9a, 0xc9, 0x89, 0xa1, 0x2c, 0xaf, 0xfe, 0x1b, 0xc5, 0xda, 0x44, 0xc1, 0xfa, 0x9d, + 0x73, 0x80, 0xe5, 0x84, 0xf2, 0xaa, 0xbe, 0x51, 0x4c, 0x75, 0xc1, 0x84, 0x63, 0xd6, 0xb1, 0xfa, + 0x95, 0x02, 0x97, 0x46, 0x77, 0xf1, 0xed, 0x3c, 0xaa, 0x91, 0x10, 0xfd, 0xde, 0xb9, 0x43, 0xe4, + 0x39, 0x96, 0x76, 0x5d, 0xee, 0x1c, 0xa7, 0xd8, 0xfc, 0x39, 0x1e, 0xdd, 0x4c, 0x71, 0x36, 0xe9, + 0x12, 0x97, 0x9b, 0x2d, 0xc5, 0xe6, 0x67, 0x1b, 0xbd, 0xf6, 0xec, 0x7f, 0xf4, 0xfb, 0x69, 0x4d, + 0x79, 0x71, 0x5a, 0x53, 0xfe, 0x3e, 0xad, 0x29, 0xdf, 0x9e, 0xd5, 0xa6, 0x5e, 0x9c, 0xd5, 0xa6, + 0xfe, 0x3c, 0xab, 0x4d, 0x7d, 0xda, 0x74, 0xdc, 0xe8, 0xa8, 0x6f, 0x36, 0x2c, 0xec, 0x35, 0x4d, + 0xdf, 0xbc, 0x49, 0x89, 0x9b, 0xd2, 0x07, 0x87, 0x93, 0xf4, 0x03, 0xc7, 0x20, 0x40, 0xc4, 0x9c, + 0xa3, 0x9f, 0x1c, 0xee, 0xfc, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x40, 0x57, 0x32, 0x80, 0x03, 0x11, + 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 { + CreateBucket(ctx context.Context, in *MsgCreateBucket, opts ...grpc.CallOption) (*MsgCreateBucketResponse, error) + DeleteBucket(ctx context.Context, in *MsgDeleteBucket, opts ...grpc.CallOption) (*MsgDeleteBucketResponse, error) + CreateObject(ctx context.Context, in *MsgCreateObject, opts ...grpc.CallOption) (*MsgCreateObjectResponse, error) + SealObject(ctx context.Context, in *MsgSealObject, opts ...grpc.CallOption) (*MsgSealObjectResponse, error) + RejectSealObject(ctx context.Context, in *MsgRejectSealObject, opts ...grpc.CallOption) (*MsgRejectSealObjectResponse, error) + DeleteObject(ctx context.Context, in *MsgDeleteObject, opts ...grpc.CallOption) (*MsgDeleteObjectResponse, error) + CreateGroup(ctx context.Context, in *MsgCreateGroup, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) + DeleteGroup(ctx context.Context, in *MsgDeleteGroup, opts ...grpc.CallOption) (*MsgDeleteGroupResponse, error) + UpdateGroupMember(ctx context.Context, in *MsgUpdateGroupMember, opts ...grpc.CallOption) (*MsgUpdateGroupMemberResponse, error) + LeaveGroup(ctx context.Context, in *MsgLeaveGroup, opts ...grpc.CallOption) (*MsgLeaveGroupResponse, error) + CopyObject(ctx context.Context, in *MsgCopyObject, opts ...grpc.CallOption) (*MsgCopyObjectResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateBucket(ctx context.Context, in *MsgCreateBucket, opts ...grpc.CallOption) (*MsgCreateBucketResponse, error) { + out := new(MsgCreateBucketResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/CreateBucket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeleteBucket(ctx context.Context, in *MsgDeleteBucket, opts ...grpc.CallOption) (*MsgDeleteBucketResponse, error) { + out := new(MsgDeleteBucketResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/DeleteBucket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreateObject(ctx context.Context, in *MsgCreateObject, opts ...grpc.CallOption) (*MsgCreateObjectResponse, error) { + out := new(MsgCreateObjectResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/CreateObject", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SealObject(ctx context.Context, in *MsgSealObject, opts ...grpc.CallOption) (*MsgSealObjectResponse, error) { + out := new(MsgSealObjectResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/SealObject", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RejectSealObject(ctx context.Context, in *MsgRejectSealObject, opts ...grpc.CallOption) (*MsgRejectSealObjectResponse, error) { + out := new(MsgRejectSealObjectResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/RejectSealObject", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeleteObject(ctx context.Context, in *MsgDeleteObject, opts ...grpc.CallOption) (*MsgDeleteObjectResponse, error) { + out := new(MsgDeleteObjectResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/DeleteObject", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreateGroup(ctx context.Context, in *MsgCreateGroup, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) { + out := new(MsgCreateGroupResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/CreateGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeleteGroup(ctx context.Context, in *MsgDeleteGroup, opts ...grpc.CallOption) (*MsgDeleteGroupResponse, error) { + out := new(MsgDeleteGroupResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/DeleteGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupMember(ctx context.Context, in *MsgUpdateGroupMember, opts ...grpc.CallOption) (*MsgUpdateGroupMemberResponse, error) { + out := new(MsgUpdateGroupMemberResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/UpdateGroupMember", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) LeaveGroup(ctx context.Context, in *MsgLeaveGroup, opts ...grpc.CallOption) (*MsgLeaveGroupResponse, error) { + out := new(MsgLeaveGroupResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/LeaveGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CopyObject(ctx context.Context, in *MsgCopyObject, opts ...grpc.CallOption) (*MsgCopyObjectResponse, error) { + out := new(MsgCopyObjectResponse) + err := c.cc.Invoke(ctx, "/bnbchain.greenfield.storage.Msg/CopyObject", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + CreateBucket(context.Context, *MsgCreateBucket) (*MsgCreateBucketResponse, error) + DeleteBucket(context.Context, *MsgDeleteBucket) (*MsgDeleteBucketResponse, error) + CreateObject(context.Context, *MsgCreateObject) (*MsgCreateObjectResponse, error) + SealObject(context.Context, *MsgSealObject) (*MsgSealObjectResponse, error) + RejectSealObject(context.Context, *MsgRejectSealObject) (*MsgRejectSealObjectResponse, error) + DeleteObject(context.Context, *MsgDeleteObject) (*MsgDeleteObjectResponse, error) + CreateGroup(context.Context, *MsgCreateGroup) (*MsgCreateGroupResponse, error) + DeleteGroup(context.Context, *MsgDeleteGroup) (*MsgDeleteGroupResponse, error) + UpdateGroupMember(context.Context, *MsgUpdateGroupMember) (*MsgUpdateGroupMemberResponse, error) + LeaveGroup(context.Context, *MsgLeaveGroup) (*MsgLeaveGroupResponse, error) + CopyObject(context.Context, *MsgCopyObject) (*MsgCopyObjectResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateBucket(ctx context.Context, req *MsgCreateBucket) (*MsgCreateBucketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateBucket not implemented") +} +func (*UnimplementedMsgServer) DeleteBucket(ctx context.Context, req *MsgDeleteBucket) (*MsgDeleteBucketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteBucket not implemented") +} +func (*UnimplementedMsgServer) CreateObject(ctx context.Context, req *MsgCreateObject) (*MsgCreateObjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateObject not implemented") +} +func (*UnimplementedMsgServer) SealObject(ctx context.Context, req *MsgSealObject) (*MsgSealObjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SealObject not implemented") +} +func (*UnimplementedMsgServer) RejectSealObject(ctx context.Context, req *MsgRejectSealObject) (*MsgRejectSealObjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RejectSealObject not implemented") +} +func (*UnimplementedMsgServer) DeleteObject(ctx context.Context, req *MsgDeleteObject) (*MsgDeleteObjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteObject not implemented") +} +func (*UnimplementedMsgServer) CreateGroup(ctx context.Context, req *MsgCreateGroup) (*MsgCreateGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateGroup not implemented") +} +func (*UnimplementedMsgServer) DeleteGroup(ctx context.Context, req *MsgDeleteGroup) (*MsgDeleteGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteGroup not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupMember(ctx context.Context, req *MsgUpdateGroupMember) (*MsgUpdateGroupMemberResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupMember not implemented") +} +func (*UnimplementedMsgServer) LeaveGroup(ctx context.Context, req *MsgLeaveGroup) (*MsgLeaveGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LeaveGroup not implemented") +} +func (*UnimplementedMsgServer) CopyObject(ctx context.Context, req *MsgCopyObject) (*MsgCopyObjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CopyObject not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateBucket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateBucket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateBucket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/CreateBucket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateBucket(ctx, req.(*MsgCreateBucket)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeleteBucket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteBucket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteBucket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/DeleteBucket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteBucket(ctx, req.(*MsgDeleteBucket)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreateObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateObject) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateObject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/CreateObject", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateObject(ctx, req.(*MsgCreateObject)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SealObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSealObject) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SealObject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/SealObject", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SealObject(ctx, req.(*MsgSealObject)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RejectSealObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRejectSealObject) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RejectSealObject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/RejectSealObject", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RejectSealObject(ctx, req.(*MsgRejectSealObject)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeleteObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteObject) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteObject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/DeleteObject", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteObject(ctx, req.(*MsgDeleteObject)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreateGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/CreateGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateGroup(ctx, req.(*MsgCreateGroup)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeleteGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/DeleteGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteGroup(ctx, req.(*MsgDeleteGroup)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupMember) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupMember(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/UpdateGroupMember", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupMember(ctx, req.(*MsgUpdateGroupMember)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_LeaveGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgLeaveGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).LeaveGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/LeaveGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).LeaveGroup(ctx, req.(*MsgLeaveGroup)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CopyObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCopyObject) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CopyObject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bnbchain.greenfield.storage.Msg/CopyObject", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CopyObject(ctx, req.(*MsgCopyObject)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "bnbchain.greenfield.storage.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateBucket", + Handler: _Msg_CreateBucket_Handler, + }, + { + MethodName: "DeleteBucket", + Handler: _Msg_DeleteBucket_Handler, + }, + { + MethodName: "CreateObject", + Handler: _Msg_CreateObject_Handler, + }, + { + MethodName: "SealObject", + Handler: _Msg_SealObject_Handler, + }, + { + MethodName: "RejectSealObject", + Handler: _Msg_RejectSealObject_Handler, + }, + { + MethodName: "DeleteObject", + Handler: _Msg_DeleteObject_Handler, + }, + { + MethodName: "CreateGroup", + Handler: _Msg_CreateGroup_Handler, + }, + { + MethodName: "DeleteGroup", + Handler: _Msg_DeleteGroup_Handler, + }, + { + MethodName: "UpdateGroupMember", + Handler: _Msg_UpdateGroupMember_Handler, + }, + { + MethodName: "LeaveGroup", + Handler: _Msg_LeaveGroup_Handler, + }, + { + MethodName: "CopyObject", + Handler: _Msg_CopyObject_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "greenfield/storage/tx.proto", +} + +func (m *MsgCreateBucket) 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 *MsgCreateBucket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBucket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PrimarySpApprovalSignature) > 0 { + i -= len(m.PrimarySpApprovalSignature) + copy(dAtA[i:], m.PrimarySpApprovalSignature) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrimarySpApprovalSignature))) + i-- + dAtA[i] = 0x3a + } + if len(m.PrimarySpAddress) > 0 { + i -= len(m.PrimarySpAddress) + copy(dAtA[i:], m.PrimarySpAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrimarySpAddress))) + i-- + dAtA[i] = 0x32 + } + if len(m.PaymentAddress) > 0 { + i -= len(m.PaymentAddress) + copy(dAtA[i:], m.PaymentAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.PaymentAddress))) + i-- + dAtA[i] = 0x22 + } + if m.IsPublic { + i-- + if m.IsPublic { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateBucketResponse) 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 *MsgCreateBucketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBucketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeleteBucket) 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 *MsgDeleteBucket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteBucket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeleteBucketResponse) 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 *MsgDeleteBucketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteBucketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateObject) 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 *MsgCreateObject) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateObject) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ExpectSecondarySpAddresses) > 0 { + for iNdEx := len(m.ExpectSecondarySpAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ExpectSecondarySpAddresses[iNdEx]) + copy(dAtA[i:], m.ExpectSecondarySpAddresses[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.ExpectSecondarySpAddresses[iNdEx]))) + i-- + dAtA[i] = 0x4a + } + } + if len(m.ExpectChecksums) > 0 { + for iNdEx := len(m.ExpectChecksums) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ExpectChecksums[iNdEx]) + copy(dAtA[i:], m.ExpectChecksums[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.ExpectChecksums[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + if len(m.PrimarySpApprovalSignature) > 0 { + i -= len(m.PrimarySpApprovalSignature) + copy(dAtA[i:], m.PrimarySpApprovalSignature) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrimarySpApprovalSignature))) + i-- + dAtA[i] = 0x3a + } + if len(m.ContentType) > 0 { + i -= len(m.ContentType) + copy(dAtA[i:], m.ContentType) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContentType))) + i-- + dAtA[i] = 0x32 + } + if m.IsPublic { + i-- + if m.IsPublic { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.PayloadSize != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PayloadSize)) + i-- + dAtA[i] = 0x20 + } + if len(m.ObjectName) > 0 { + i -= len(m.ObjectName) + copy(dAtA[i:], m.ObjectName) + i = encodeVarintTx(dAtA, i, uint64(len(m.ObjectName))) + i-- + dAtA[i] = 0x1a + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateObjectResponse) 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 *MsgCreateObjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateObjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSealObject) 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 *MsgSealObject) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSealObject) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SecondarySpSignatures) > 0 { + for iNdEx := len(m.SecondarySpSignatures) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SecondarySpSignatures[iNdEx]) + copy(dAtA[i:], m.SecondarySpSignatures[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.SecondarySpSignatures[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.SecondarySpAddresses) > 0 { + for iNdEx := len(m.SecondarySpAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SecondarySpAddresses[iNdEx]) + copy(dAtA[i:], m.SecondarySpAddresses[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.SecondarySpAddresses[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.ObjectName) > 0 { + i -= len(m.ObjectName) + copy(dAtA[i:], m.ObjectName) + i = encodeVarintTx(dAtA, i, uint64(len(m.ObjectName))) + i-- + dAtA[i] = 0x1a + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSealObjectResponse) 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 *MsgSealObjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSealObjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRejectSealObject) 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 *MsgRejectSealObject) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRejectSealObject) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ObjectName) > 0 { + i -= len(m.ObjectName) + copy(dAtA[i:], m.ObjectName) + i = encodeVarintTx(dAtA, i, uint64(len(m.ObjectName))) + i-- + dAtA[i] = 0x1a + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRejectSealObjectResponse) 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 *MsgRejectSealObjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRejectSealObjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCopyObject) 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 *MsgCopyObject) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCopyObject) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DstPrimarySpApprovalSignature) > 0 { + i -= len(m.DstPrimarySpApprovalSignature) + copy(dAtA[i:], m.DstPrimarySpApprovalSignature) + i = encodeVarintTx(dAtA, i, uint64(len(m.DstPrimarySpApprovalSignature))) + i-- + dAtA[i] = 0x32 + } + if len(m.DstObjectName) > 0 { + i -= len(m.DstObjectName) + copy(dAtA[i:], m.DstObjectName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DstObjectName))) + i-- + dAtA[i] = 0x2a + } + if len(m.SrcObjectName) > 0 { + i -= len(m.SrcObjectName) + copy(dAtA[i:], m.SrcObjectName) + i = encodeVarintTx(dAtA, i, uint64(len(m.SrcObjectName))) + i-- + dAtA[i] = 0x22 + } + if len(m.DstBucketName) > 0 { + i -= len(m.DstBucketName) + copy(dAtA[i:], m.DstBucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DstBucketName))) + i-- + dAtA[i] = 0x1a + } + if len(m.SrcBucketName) > 0 { + i -= len(m.SrcBucketName) + copy(dAtA[i:], m.SrcBucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.SrcBucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCopyObjectResponse) 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 *MsgCopyObjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCopyObjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeleteObject) 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 *MsgDeleteObject) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteObject) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ObjectName) > 0 { + i -= len(m.ObjectName) + copy(dAtA[i:], m.ObjectName) + i = encodeVarintTx(dAtA, i, uint64(len(m.ObjectName))) + i-- + dAtA[i] = 0x1a + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTx(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeleteObjectResponse) 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 *MsgDeleteObjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteObjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateGroup) 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 *MsgCreateGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Members[iNdEx]) + copy(dAtA[i:], m.Members[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Members[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateGroupResponse) 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 *MsgCreateGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeleteGroup) 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 *MsgDeleteGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeleteGroupResponse) 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 *MsgDeleteGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupMember) 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 *MsgUpdateGroupMember) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MembersToDelete) > 0 { + for iNdEx := len(m.MembersToDelete) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MembersToDelete[iNdEx]) + copy(dAtA[i:], m.MembersToDelete[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.MembersToDelete[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.MembersToAdd) > 0 { + for iNdEx := len(m.MembersToAdd) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MembersToAdd[iNdEx]) + copy(dAtA[i:], m.MembersToAdd[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.MembersToAdd[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupMemberResponse) 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 *MsgUpdateGroupMemberResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupMemberResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgLeaveGroup) 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 *MsgLeaveGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLeaveGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x1a + } + if len(m.GroupOwner) > 0 { + i -= len(m.GroupOwner) + copy(dAtA[i:], m.GroupOwner) + i = encodeVarintTx(dAtA, i, uint64(len(m.GroupOwner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Member) > 0 { + i -= len(m.Member) + copy(dAtA[i:], m.Member) + i = encodeVarintTx(dAtA, i, uint64(len(m.Member))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgLeaveGroupResponse) 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 *MsgLeaveGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLeaveGroupResponse) 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 *MsgCreateBucket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.IsPublic { + n += 2 + } + l = len(m.PaymentAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrimarySpAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrimarySpApprovalSignature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateBucketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteBucket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDeleteBucketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateObject) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ObjectName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PayloadSize != 0 { + n += 1 + sovTx(uint64(m.PayloadSize)) + } + if m.IsPublic { + n += 2 + } + l = len(m.ContentType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrimarySpApprovalSignature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.ExpectChecksums) > 0 { + for _, b := range m.ExpectChecksums { + l = len(b) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.ExpectSecondarySpAddresses) > 0 { + for _, s := range m.ExpectSecondarySpAddresses { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgCreateObjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSealObject) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ObjectName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.SecondarySpAddresses) > 0 { + for _, s := range m.SecondarySpAddresses { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.SecondarySpSignatures) > 0 { + for _, b := range m.SecondarySpSignatures { + l = len(b) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSealObjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRejectSealObject) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ObjectName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRejectSealObjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCopyObject) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SrcBucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DstBucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SrcObjectName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DstObjectName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DstPrimarySpApprovalSignature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCopyObjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteObject) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ObjectName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDeleteObjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Members) > 0 { + for _, s := range m.Members { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgCreateGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDeleteGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupMember) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.MembersToAdd) > 0 { + for _, s := range m.MembersToAdd { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.MembersToDelete) > 0 { + for _, s := range m.MembersToDelete { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUpdateGroupMemberResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgLeaveGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Member) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupOwner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgLeaveGroupResponse) 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 *MsgCreateBucket) 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: MsgCreateBucket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBucket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPublic", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPublic = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PaymentAddress", 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.PaymentAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrimarySpAddress", 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.PrimarySpAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrimarySpApprovalSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrimarySpApprovalSignature = append(m.PrimarySpApprovalSignature[:0], dAtA[iNdEx:postIndex]...) + if m.PrimarySpApprovalSignature == nil { + m.PrimarySpApprovalSignature = []byte{} + } + 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 *MsgCreateBucketResponse) 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: MsgCreateBucketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBucketResponse: 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 *MsgDeleteBucket) 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: MsgDeleteBucket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteBucket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = 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 *MsgDeleteBucketResponse) 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: MsgDeleteBucketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteBucketResponse: 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 *MsgCreateObject) 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: MsgCreateObject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateObject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectName", 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.ObjectName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadSize", wireType) + } + m.PayloadSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PayloadSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPublic", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPublic = bool(v != 0) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContentType", 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.ContentType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrimarySpApprovalSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrimarySpApprovalSignature = append(m.PrimarySpApprovalSignature[:0], dAtA[iNdEx:postIndex]...) + if m.PrimarySpApprovalSignature == nil { + m.PrimarySpApprovalSignature = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpectChecksums", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExpectChecksums = append(m.ExpectChecksums, make([]byte, postIndex-iNdEx)) + copy(m.ExpectChecksums[len(m.ExpectChecksums)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpectSecondarySpAddresses", 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.ExpectSecondarySpAddresses = append(m.ExpectSecondarySpAddresses, 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 *MsgCreateObjectResponse) 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: MsgCreateObjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateObjectResponse: 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 *MsgSealObject) 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: MsgSealObject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSealObject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectName", 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.ObjectName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecondarySpAddresses", 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.SecondarySpAddresses = append(m.SecondarySpAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecondarySpSignatures", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecondarySpSignatures = append(m.SecondarySpSignatures, make([]byte, postIndex-iNdEx)) + copy(m.SecondarySpSignatures[len(m.SecondarySpSignatures)-1], 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 *MsgSealObjectResponse) 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: MsgSealObjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSealObjectResponse: 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 *MsgRejectSealObject) 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: MsgRejectSealObject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRejectSealObject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectName", 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.ObjectName = 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 *MsgRejectSealObjectResponse) 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: MsgRejectSealObjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRejectSealObjectResponse: 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 *MsgCopyObject) 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: MsgCopyObject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCopyObject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SrcBucketName", 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.SrcBucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DstBucketName", 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.DstBucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SrcObjectName", 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.SrcObjectName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DstObjectName", 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.DstObjectName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DstPrimarySpApprovalSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DstPrimarySpApprovalSignature = append(m.DstPrimarySpApprovalSignature[:0], dAtA[iNdEx:postIndex]...) + if m.DstPrimarySpApprovalSignature == nil { + m.DstPrimarySpApprovalSignature = []byte{} + } + 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 *MsgCopyObjectResponse) 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: MsgCopyObjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCopyObjectResponse: 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 *MsgDeleteObject) 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: MsgDeleteObject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteObject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BucketName", 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.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectName", 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.ObjectName = 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 *MsgDeleteObjectResponse) 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: MsgDeleteObjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteObjectResponse: 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 *MsgCreateGroup) 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: MsgCreateGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupName", 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.GroupName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", 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.Members = append(m.Members, 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 *MsgCreateGroupResponse) 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: MsgCreateGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroupResponse: 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 *MsgDeleteGroup) 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: MsgDeleteGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupName", 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.GroupName = 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 *MsgDeleteGroupResponse) 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: MsgDeleteGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteGroupResponse: 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 *MsgUpdateGroupMember) 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: MsgUpdateGroupMember: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", 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.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupName", 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.GroupName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MembersToAdd", 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.MembersToAdd = append(m.MembersToAdd, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MembersToDelete", 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.MembersToDelete = append(m.MembersToDelete, 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 *MsgUpdateGroupMemberResponse) 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: MsgUpdateGroupMemberResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMemberResponse: 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 *MsgLeaveGroup) 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: MsgLeaveGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLeaveGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Member", 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.Member = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupOwner", 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.GroupOwner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupName", 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.GroupName = 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 *MsgLeaveGroupResponse) 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: MsgLeaveGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLeaveGroupResponse: 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/storage/types/types.go b/x/storage/types/types.go new file mode 100644 index 000000000..cdc4dd590 --- /dev/null +++ b/x/storage/types/types.go @@ -0,0 +1,33 @@ +package types + +import ( + sdkmath "cosmossdk.io/math" +) + +// Type aliases to the SDK's math sub-module +// +// Deprecated: Functionality of this package has been moved to it's own module: +// cosmossdk.io/math +// +// Please use the above module instead of this package. +type ( + Int = sdkmath.Int + Uint = sdkmath.Uint +) + +func MustMarshalUint(n sdkmath.Uint) []byte { + nb, err := n.Marshal() + if err != nil { + panic(err) + } + return nb +} + +func MustUnmarshalUint(data []byte) sdkmath.Uint { + n := sdkmath.ZeroUint() + err := n.Unmarshal(data) + if err != nil { + panic(err) + } + return n +} diff --git a/x/storage/types/types.pb.go b/x/storage/types/types.pb.go new file mode 100644 index 000000000..a4c9f734b --- /dev/null +++ b/x/storage/types/types.pb.go @@ -0,0 +1,1986 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: greenfield/storage/types.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/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 ReadQuota int32 + +const ( + READ_QUOTA_FREE ReadQuota = 0 +) + +var ReadQuota_name = map[int32]string{ + 0: "READ_QUOTA_FREE", +} + +var ReadQuota_value = map[string]int32{ + "READ_QUOTA_FREE": 0, +} + +func (x ReadQuota) String() string { + return proto.EnumName(ReadQuota_name, int32(x)) +} + +func (ReadQuota) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{0} +} + +type RedundancyType int32 + +const ( + REDUNDANCY_REPLICA_TYPE RedundancyType = 0 + REDUNDANCY_EC_TYPE RedundancyType = 1 + REDUNDANCY_INLINE_TYPE RedundancyType = 2 +) + +var RedundancyType_name = map[int32]string{ + 0: "REDUNDANCY_REPLICA_TYPE", + 1: "REDUNDANCY_EC_TYPE", + 2: "REDUNDANCY_INLINE_TYPE", +} + +var RedundancyType_value = map[string]int32{ + "REDUNDANCY_REPLICA_TYPE": 0, + "REDUNDANCY_EC_TYPE": 1, + "REDUNDANCY_INLINE_TYPE": 2, +} + +func (x RedundancyType) String() string { + return proto.EnumName(RedundancyType_name, int32(x)) +} + +func (RedundancyType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{1} +} + +type ObjectStatus int32 + +const ( + OBJECT_STATUS_INIT ObjectStatus = 0 + OBJECT_STATUS_IN_SERVICE ObjectStatus = 1 +) + +var ObjectStatus_name = map[int32]string{ + 0: "OBJECT_STATUS_INIT", + 1: "OBJECT_STATUS_IN_SERVICE", +} + +var ObjectStatus_value = map[string]int32{ + "OBJECT_STATUS_INIT": 0, + "OBJECT_STATUS_IN_SERVICE": 1, +} + +func (x ObjectStatus) String() string { + return proto.EnumName(ObjectStatus_name, int32(x)) +} + +func (ObjectStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{2} +} + +type BucketInfo struct { + // owner is the account address of bucket creator, it is also the bucket owner. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // bucket_name is a globally unique name of bucket + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // is_public define the highest permissions for bucket. When the bucket is public, everyone can get the object in it. + IsPublic bool `protobuf:"varint,3,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"` + // id is the unique identification for bucket. + Id Uint `protobuf:"bytes,4,opt,name=id,proto3,customtype=Uint" json:"id"` + // create_at define the block number when the bucket created. + CreateAt int64 `protobuf:"varint,5,opt,name=create_at,json=createAt,proto3" json:"create_at,omitempty"` + // payment_address is the address of the payment account + PaymentAddress string `protobuf:"bytes,6,opt,name=payment_address,json=paymentAddress,proto3" json:"payment_address,omitempty"` + // primary_sp_address is the address of the primary sp. Objects belongs to this bucket will never + // leave this SP, unless you explicitly shift them to another SP. + PrimarySpAddress string `protobuf:"bytes,7,opt,name=primary_sp_address,json=primarySpAddress,proto3" json:"primary_sp_address,omitempty"` + // read_quota defines the traffic quota for read + ReadQuota ReadQuota `protobuf:"varint,8,opt,name=read_quota,json=readQuota,proto3,enum=bnbchain.greenfield.storage.ReadQuota" json:"read_quota,omitempty"` +} + +func (m *BucketInfo) Reset() { *m = BucketInfo{} } +func (m *BucketInfo) String() string { return proto.CompactTextString(m) } +func (*BucketInfo) ProtoMessage() {} +func (*BucketInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{0} +} +func (m *BucketInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BucketInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BucketInfo.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 *BucketInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_BucketInfo.Merge(m, src) +} +func (m *BucketInfo) XXX_Size() int { + return m.Size() +} +func (m *BucketInfo) XXX_DiscardUnknown() { + xxx_messageInfo_BucketInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_BucketInfo proto.InternalMessageInfo + +func (m *BucketInfo) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *BucketInfo) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *BucketInfo) GetIsPublic() bool { + if m != nil { + return m.IsPublic + } + return false +} + +func (m *BucketInfo) GetCreateAt() int64 { + if m != nil { + return m.CreateAt + } + return 0 +} + +func (m *BucketInfo) GetPaymentAddress() string { + if m != nil { + return m.PaymentAddress + } + return "" +} + +func (m *BucketInfo) GetPrimarySpAddress() string { + if m != nil { + return m.PrimarySpAddress + } + return "" +} + +func (m *BucketInfo) GetReadQuota() ReadQuota { + if m != nil { + return m.ReadQuota + } + return READ_QUOTA_FREE +} + +type ObjectInfo struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // bucket_name is the name of the bucket + BucketName string `protobuf:"bytes,2,opt,name=bucket_name,json=bucketName,proto3" json:"bucket_name,omitempty"` + // object_name is the name of object + ObjectName string `protobuf:"bytes,3,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` + // id is the unique identifier of object + Id Uint `protobuf:"bytes,4,opt,name=id,proto3,customtype=Uint" json:"id"` + // payloadSize is the total size of the object payload + PayloadSize uint64 `protobuf:"varint,5,opt,name=payload_size,json=payloadSize,proto3" json:"payload_size,omitempty"` + // is_public define the highest permissions for object. When the object is public, everyone can access it. + IsPublic bool `protobuf:"varint,6,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"` + // content_type define the format of the object which should be a standard MIME type. + ContentType string `protobuf:"bytes,7,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` + // create_at define the block number when the object created + CreateAt int64 `protobuf:"varint,8,opt,name=create_at,json=createAt,proto3" json:"create_at,omitempty"` + // object_status define the upload status of the object. + ObjectStatus ObjectStatus `protobuf:"varint,9,opt,name=object_status,json=objectStatus,proto3,enum=bnbchain.greenfield.storage.ObjectStatus" json:"object_status,omitempty"` + // redundancy_type define the type of the redundancy which can be multi-replication or EC. + RedundancyType RedundancyType `protobuf:"varint,10,opt,name=redundancy_type,json=redundancyType,proto3,enum=bnbchain.greenfield.storage.RedundancyType" json:"redundancy_type,omitempty"` + // source_type define the source of the object. + SourceType SourceType `protobuf:"varint,11,opt,name=source_type,json=sourceType,proto3,enum=bnbchain.greenfield.storage.SourceType" json:"source_type,omitempty"` + // checksums define the root hash of the pieces which stored in a SP. + Checksums [][]byte `protobuf:"bytes,12,rep,name=checksums,proto3" json:"checksums,omitempty"` + // secondary_sp_addresses define the addresses of secondary_sps + SecondarySpAddresses []string `protobuf:"bytes,13,rep,name=secondary_sp_addresses,json=secondarySpAddresses,proto3" json:"secondary_sp_addresses,omitempty"` +} + +func (m *ObjectInfo) Reset() { *m = ObjectInfo{} } +func (m *ObjectInfo) String() string { return proto.CompactTextString(m) } +func (*ObjectInfo) ProtoMessage() {} +func (*ObjectInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{1} +} +func (m *ObjectInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectInfo.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 *ObjectInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectInfo.Merge(m, src) +} +func (m *ObjectInfo) XXX_Size() int { + return m.Size() +} +func (m *ObjectInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectInfo proto.InternalMessageInfo + +func (m *ObjectInfo) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *ObjectInfo) GetBucketName() string { + if m != nil { + return m.BucketName + } + return "" +} + +func (m *ObjectInfo) GetObjectName() string { + if m != nil { + return m.ObjectName + } + return "" +} + +func (m *ObjectInfo) GetPayloadSize() uint64 { + if m != nil { + return m.PayloadSize + } + return 0 +} + +func (m *ObjectInfo) GetIsPublic() bool { + if m != nil { + return m.IsPublic + } + return false +} + +func (m *ObjectInfo) GetContentType() string { + if m != nil { + return m.ContentType + } + return "" +} + +func (m *ObjectInfo) GetCreateAt() int64 { + if m != nil { + return m.CreateAt + } + return 0 +} + +func (m *ObjectInfo) GetObjectStatus() ObjectStatus { + if m != nil { + return m.ObjectStatus + } + return OBJECT_STATUS_INIT +} + +func (m *ObjectInfo) GetRedundancyType() RedundancyType { + if m != nil { + return m.RedundancyType + } + return REDUNDANCY_REPLICA_TYPE +} + +func (m *ObjectInfo) GetSourceType() SourceType { + if m != nil { + return m.SourceType + } + return SOURCE_TYPE_ORIGIN +} + +func (m *ObjectInfo) GetChecksums() [][]byte { + if m != nil { + return m.Checksums + } + return nil +} + +func (m *ObjectInfo) GetSecondarySpAddresses() []string { + if m != nil { + return m.SecondarySpAddresses + } + return nil +} + +type GroupInfo struct { + // owner is the owner of the group. It can not changed once it created. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // group_name is the name of group which is unique under an account. + GroupName string `protobuf:"bytes,2,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + // id is the unique identifier of group + Id Uint `protobuf:"bytes,3,opt,name=id,proto3,customtype=Uint" json:"id"` +} + +func (m *GroupInfo) Reset() { *m = GroupInfo{} } +func (m *GroupInfo) String() string { return proto.CompactTextString(m) } +func (*GroupInfo) ProtoMessage() {} +func (*GroupInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{2} +} +func (m *GroupInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupInfo.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 *GroupInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupInfo.Merge(m, src) +} +func (m *GroupInfo) XXX_Size() int { + return m.Size() +} +func (m *GroupInfo) XXX_DiscardUnknown() { + xxx_messageInfo_GroupInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupInfo proto.InternalMessageInfo + +func (m *GroupInfo) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *GroupInfo) GetGroupName() string { + if m != nil { + return m.GroupName + } + return "" +} + +type GroupMemberInfo struct { + Member string `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` + Id Uint `protobuf:"bytes,2,opt,name=id,proto3,customtype=Uint" json:"id"` + ExpireTime uint64 `protobuf:"varint,3,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"` +} + +func (m *GroupMemberInfo) Reset() { *m = GroupMemberInfo{} } +func (m *GroupMemberInfo) String() string { return proto.CompactTextString(m) } +func (*GroupMemberInfo) ProtoMessage() {} +func (*GroupMemberInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_bf95fa2efdc74d97, []int{3} +} +func (m *GroupMemberInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupMemberInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupMemberInfo.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 *GroupMemberInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupMemberInfo.Merge(m, src) +} +func (m *GroupMemberInfo) XXX_Size() int { + return m.Size() +} +func (m *GroupMemberInfo) XXX_DiscardUnknown() { + xxx_messageInfo_GroupMemberInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupMemberInfo proto.InternalMessageInfo + +func (m *GroupMemberInfo) GetMember() string { + if m != nil { + return m.Member + } + return "" +} + +func (m *GroupMemberInfo) GetExpireTime() uint64 { + if m != nil { + return m.ExpireTime + } + return 0 +} + +func init() { + proto.RegisterEnum("bnbchain.greenfield.storage.ReadQuota", ReadQuota_name, ReadQuota_value) + proto.RegisterEnum("bnbchain.greenfield.storage.RedundancyType", RedundancyType_name, RedundancyType_value) + proto.RegisterEnum("bnbchain.greenfield.storage.ObjectStatus", ObjectStatus_name, ObjectStatus_value) + proto.RegisterType((*BucketInfo)(nil), "bnbchain.greenfield.storage.BucketInfo") + proto.RegisterType((*ObjectInfo)(nil), "bnbchain.greenfield.storage.ObjectInfo") + proto.RegisterType((*GroupInfo)(nil), "bnbchain.greenfield.storage.GroupInfo") + proto.RegisterType((*GroupMemberInfo)(nil), "bnbchain.greenfield.storage.GroupMemberInfo") +} + +func init() { proto.RegisterFile("greenfield/storage/types.proto", fileDescriptor_bf95fa2efdc74d97) } + +var fileDescriptor_bf95fa2efdc74d97 = []byte{ + // 815 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xd1, 0x6e, 0x1b, 0x45, + 0x14, 0xf5, 0xda, 0x4e, 0xb0, 0xaf, 0xdd, 0xc4, 0x1a, 0xa2, 0xb0, 0x24, 0xc5, 0x76, 0xf3, 0x50, + 0x4c, 0xab, 0xd8, 0x08, 0xbe, 0xc0, 0x71, 0xb6, 0xe0, 0xaa, 0x38, 0xe9, 0x78, 0x83, 0x54, 0x5e, + 0x56, 0xb3, 0xbb, 0xd3, 0xcd, 0xd0, 0xec, 0xce, 0x32, 0x33, 0x2b, 0xea, 0xfe, 0x00, 0xf0, 0x06, + 0x2f, 0xfc, 0x00, 0xbf, 0xd0, 0x8f, 0xe8, 0x63, 0xd5, 0x27, 0xc4, 0x43, 0x85, 0x92, 0x1f, 0x41, + 0x3b, 0xb3, 0x71, 0xed, 0x08, 0xc5, 0x01, 0xa9, 0x6f, 0x73, 0xcf, 0x9e, 0x7b, 0xee, 0xdd, 0x7b, + 0xcf, 0x68, 0xa0, 0x1d, 0x09, 0x4a, 0x93, 0xa7, 0x8c, 0x9e, 0x85, 0x03, 0xa9, 0xb8, 0x20, 0x11, + 0x1d, 0xa8, 0x59, 0x4a, 0x65, 0x3f, 0x15, 0x5c, 0x71, 0xb4, 0xeb, 0x27, 0x7e, 0x70, 0x4a, 0x58, + 0xd2, 0x7f, 0x47, 0xec, 0x17, 0xc4, 0x9d, 0x8f, 0x03, 0x2e, 0x63, 0x2e, 0x3d, 0x4d, 0x1d, 0x98, + 0xc0, 0xe4, 0xed, 0x6c, 0x45, 0x3c, 0xe2, 0x06, 0xcf, 0x4f, 0x05, 0xda, 0xf9, 0x97, 0x6a, 0x01, + 0x8f, 0x63, 0x9e, 0x18, 0xc2, 0xde, 0xef, 0x15, 0x80, 0x83, 0x2c, 0x78, 0x46, 0xd5, 0x38, 0x79, + 0xca, 0x51, 0x1f, 0xd6, 0xf8, 0x8f, 0x09, 0x15, 0xb6, 0xd5, 0xb5, 0x7a, 0xf5, 0x03, 0xfb, 0xcd, + 0xcb, 0xfd, 0xad, 0xa2, 0xcc, 0x30, 0x0c, 0x05, 0x95, 0x72, 0xaa, 0x04, 0x4b, 0x22, 0x6c, 0x68, + 0xa8, 0x03, 0x0d, 0x5f, 0x67, 0x7b, 0x09, 0x89, 0xa9, 0x5d, 0xce, 0xb3, 0x30, 0x18, 0x68, 0x42, + 0x62, 0x8a, 0x76, 0xa1, 0xce, 0xa4, 0x97, 0x66, 0xfe, 0x19, 0x0b, 0xec, 0x4a, 0xd7, 0xea, 0xd5, + 0x70, 0x8d, 0xc9, 0x63, 0x1d, 0xa3, 0xfb, 0x50, 0x66, 0xa1, 0x5d, 0xd5, 0xa5, 0x76, 0x5f, 0xbd, + 0xed, 0x94, 0xfe, 0x7a, 0xdb, 0xa9, 0x9e, 0xb0, 0x44, 0xbd, 0x79, 0xb9, 0xdf, 0x28, 0xca, 0xe6, + 0x21, 0x2e, 0xb3, 0x30, 0x57, 0x0a, 0x04, 0x25, 0x8a, 0x7a, 0x44, 0xd9, 0x6b, 0x5d, 0xab, 0x57, + 0xc1, 0x35, 0x03, 0x0c, 0x15, 0x1a, 0xc2, 0x66, 0x4a, 0x66, 0x31, 0x4d, 0x94, 0x47, 0x4c, 0x9f, + 0xf6, 0xfa, 0x8a, 0x3f, 0xd8, 0x28, 0x12, 0x0a, 0x14, 0x3d, 0x00, 0x94, 0x0a, 0x16, 0x13, 0x31, + 0xf3, 0x64, 0x3a, 0x57, 0xf9, 0x60, 0x85, 0x4a, 0xab, 0xc8, 0x99, 0xa6, 0x97, 0x3a, 0x0e, 0x80, + 0xa0, 0x24, 0xf4, 0x7e, 0xc8, 0xb8, 0x22, 0x76, 0xad, 0x6b, 0xf5, 0x36, 0xbe, 0xb8, 0xdb, 0xbf, + 0x66, 0xab, 0x7d, 0x4c, 0x49, 0xf8, 0x38, 0x67, 0xe3, 0xba, 0xb8, 0x3c, 0xee, 0xfd, 0xb2, 0x06, + 0x70, 0xe4, 0x7f, 0x4f, 0x83, 0xf7, 0xb4, 0x98, 0x0e, 0x34, 0xb8, 0x96, 0x37, 0x84, 0x8a, 0x21, + 0x18, 0x48, 0x13, 0xfe, 0xd3, 0x72, 0xee, 0x40, 0x33, 0x25, 0xb3, 0x33, 0x4e, 0x42, 0x4f, 0xb2, + 0x17, 0x54, 0xef, 0xa7, 0x8a, 0x1b, 0x05, 0x36, 0x65, 0x2f, 0xae, 0x38, 0x61, 0xfd, 0x8a, 0x13, + 0xee, 0x40, 0x33, 0xe0, 0x89, 0xca, 0xf7, 0x97, 0x5f, 0x06, 0x33, 0x76, 0xdc, 0x28, 0x30, 0x77, + 0x96, 0xd2, 0xe5, 0xfd, 0xd7, 0xae, 0xec, 0x7f, 0x02, 0xb7, 0x8a, 0xbf, 0x91, 0x8a, 0xa8, 0x4c, + 0xda, 0x75, 0x3d, 0xf7, 0xcf, 0xae, 0x9d, 0xbb, 0x19, 0xef, 0x54, 0x27, 0xe0, 0x26, 0x5f, 0x88, + 0x90, 0x0b, 0x9b, 0x82, 0x86, 0x59, 0x12, 0x92, 0x24, 0x98, 0x99, 0x96, 0x40, 0x2b, 0xde, 0x5f, + 0xb1, 0xc9, 0xcb, 0x9c, 0xbc, 0x65, 0xbc, 0x21, 0x96, 0x62, 0xf4, 0x35, 0x34, 0x24, 0xcf, 0x44, + 0x40, 0x8d, 0x62, 0x43, 0x2b, 0x7e, 0x7a, 0xad, 0xe2, 0x54, 0xf3, 0xb5, 0x1a, 0xc8, 0xf9, 0x19, + 0xdd, 0x86, 0x7a, 0x70, 0x4a, 0x83, 0x67, 0x32, 0x8b, 0xa5, 0xdd, 0xec, 0x56, 0x7a, 0x4d, 0xfc, + 0x0e, 0x40, 0x13, 0xd8, 0x96, 0x34, 0xe0, 0x49, 0xb8, 0x6c, 0x66, 0x2a, 0xed, 0x5b, 0xdd, 0xca, + 0xb5, 0xee, 0xd9, 0x9a, 0xe7, 0xcd, 0x0d, 0x4d, 0xe5, 0xde, 0x4f, 0x16, 0xd4, 0xbf, 0x12, 0x3c, + 0x4b, 0xff, 0x97, 0x15, 0x3f, 0x01, 0x88, 0xf2, 0xe4, 0x45, 0x27, 0xd6, 0x35, 0xb2, 0xe0, 0xb3, + 0xca, 0x8d, 0x7c, 0xb6, 0xf7, 0x9b, 0x05, 0x9b, 0xba, 0x93, 0x6f, 0x68, 0xec, 0x53, 0xa1, 0xfb, + 0xf9, 0x1c, 0xd6, 0x63, 0x1d, 0xad, 0x6c, 0xa8, 0xe0, 0x15, 0x25, 0xcb, 0x37, 0xb3, 0x76, 0x07, + 0x1a, 0xf4, 0x79, 0xca, 0x04, 0xf5, 0x14, 0x2b, 0x2e, 0x4a, 0x15, 0x83, 0x81, 0x5c, 0x16, 0xd3, + 0x7b, 0x77, 0xa1, 0x3e, 0xbf, 0xc1, 0xe8, 0x43, 0xd8, 0xc4, 0xce, 0xf0, 0xd0, 0x7b, 0x7c, 0x72, + 0xe4, 0x0e, 0xbd, 0x07, 0xd8, 0x71, 0x5a, 0xa5, 0x9d, 0xea, 0xcf, 0x7f, 0xb4, 0x4b, 0xf7, 0x22, + 0xd8, 0x58, 0xf6, 0x07, 0xda, 0x85, 0x8f, 0xb0, 0x73, 0x78, 0x32, 0x39, 0x1c, 0x4e, 0x46, 0x4f, + 0x3c, 0xec, 0x1c, 0x3f, 0x1a, 0x8f, 0x86, 0x9e, 0xfb, 0xe4, 0xd8, 0x69, 0x95, 0xd0, 0x36, 0xa0, + 0x85, 0x8f, 0xce, 0xc8, 0xe0, 0x16, 0xda, 0x81, 0xed, 0x05, 0x7c, 0x3c, 0x79, 0x34, 0x9e, 0x38, + 0xe6, 0x5b, 0xb9, 0x28, 0xf4, 0x10, 0x9a, 0x8b, 0xd6, 0xce, 0x95, 0x8e, 0x0e, 0x1e, 0x3a, 0x23, + 0xd7, 0x9b, 0xba, 0x43, 0xf7, 0x64, 0xea, 0x8d, 0x27, 0x63, 0xb7, 0x55, 0x42, 0xb7, 0xc1, 0xbe, + 0x8a, 0x7b, 0x53, 0x07, 0x7f, 0x3b, 0x1e, 0x39, 0x2d, 0xcb, 0x68, 0x1d, 0x8c, 0x5f, 0x9d, 0xb7, + 0xad, 0xd7, 0xe7, 0x6d, 0xeb, 0xef, 0xf3, 0xb6, 0xf5, 0xeb, 0x45, 0xbb, 0xf4, 0xfa, 0xa2, 0x5d, + 0xfa, 0xf3, 0xa2, 0x5d, 0xfa, 0x6e, 0x10, 0x31, 0x75, 0x9a, 0xf9, 0xfd, 0x80, 0xc7, 0x03, 0x3f, + 0xf1, 0xf7, 0xb5, 0x85, 0x07, 0x0b, 0xef, 0xcd, 0xf3, 0xe5, 0xf7, 0xcd, 0x5f, 0xd7, 0x2f, 0xce, + 0x97, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x74, 0xab, 0x2f, 0xcc, 0x02, 0x07, 0x00, 0x00, +} + +func (m *BucketInfo) 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 *BucketInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BucketInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ReadQuota != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ReadQuota)) + i-- + dAtA[i] = 0x40 + } + if len(m.PrimarySpAddress) > 0 { + i -= len(m.PrimarySpAddress) + copy(dAtA[i:], m.PrimarySpAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PrimarySpAddress))) + i-- + dAtA[i] = 0x3a + } + if len(m.PaymentAddress) > 0 { + i -= len(m.PaymentAddress) + copy(dAtA[i:], m.PaymentAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PaymentAddress))) + i-- + dAtA[i] = 0x32 + } + if m.CreateAt != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.CreateAt)) + i-- + dAtA[i] = 0x28 + } + { + size := m.Id.Size() + i -= size + if _, err := m.Id.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.IsPublic { + i-- + if m.IsPublic { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTypes(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ObjectInfo) 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 *ObjectInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SecondarySpAddresses) > 0 { + for iNdEx := len(m.SecondarySpAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SecondarySpAddresses[iNdEx]) + copy(dAtA[i:], m.SecondarySpAddresses[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SecondarySpAddresses[iNdEx]))) + i-- + dAtA[i] = 0x6a + } + } + if len(m.Checksums) > 0 { + for iNdEx := len(m.Checksums) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Checksums[iNdEx]) + copy(dAtA[i:], m.Checksums[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Checksums[iNdEx]))) + i-- + dAtA[i] = 0x62 + } + } + if m.SourceType != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.SourceType)) + i-- + dAtA[i] = 0x58 + } + if m.RedundancyType != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.RedundancyType)) + i-- + dAtA[i] = 0x50 + } + if m.ObjectStatus != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ObjectStatus)) + i-- + dAtA[i] = 0x48 + } + if m.CreateAt != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.CreateAt)) + i-- + dAtA[i] = 0x40 + } + if len(m.ContentType) > 0 { + i -= len(m.ContentType) + copy(dAtA[i:], m.ContentType) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ContentType))) + i-- + dAtA[i] = 0x3a + } + if m.IsPublic { + i-- + if m.IsPublic { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if m.PayloadSize != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.PayloadSize)) + i-- + dAtA[i] = 0x28 + } + { + size := m.Id.Size() + i -= size + if _, err := m.Id.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ObjectName) > 0 { + i -= len(m.ObjectName) + copy(dAtA[i:], m.ObjectName) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ObjectName))) + i-- + dAtA[i] = 0x1a + } + if len(m.BucketName) > 0 { + i -= len(m.BucketName) + copy(dAtA[i:], m.BucketName) + i = encodeVarintTypes(dAtA, i, uint64(len(m.BucketName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GroupInfo) 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 *GroupInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Id.Size() + i -= size + if _, err := m.Id.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.GroupName) > 0 { + i -= len(m.GroupName) + copy(dAtA[i:], m.GroupName) + i = encodeVarintTypes(dAtA, i, uint64(len(m.GroupName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GroupMemberInfo) 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 *GroupMemberInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupMemberInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExpireTime != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ExpireTime)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Id.Size() + i -= size + if _, err := m.Id.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Member) > 0 { + i -= len(m.Member) + copy(dAtA[i:], m.Member) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Member))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BucketInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.IsPublic { + n += 2 + } + l = m.Id.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.CreateAt != 0 { + n += 1 + sovTypes(uint64(m.CreateAt)) + } + l = len(m.PaymentAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.PrimarySpAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.ReadQuota != 0 { + n += 1 + sovTypes(uint64(m.ReadQuota)) + } + return n +} + +func (m *ObjectInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.BucketName) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ObjectName) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Id.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.PayloadSize != 0 { + n += 1 + sovTypes(uint64(m.PayloadSize)) + } + if m.IsPublic { + n += 2 + } + l = len(m.ContentType) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.CreateAt != 0 { + n += 1 + sovTypes(uint64(m.CreateAt)) + } + if m.ObjectStatus != 0 { + n += 1 + sovTypes(uint64(m.ObjectStatus)) + } + if m.RedundancyType != 0 { + n += 1 + sovTypes(uint64(m.RedundancyType)) + } + if m.SourceType != 0 { + n += 1 + sovTypes(uint64(m.SourceType)) + } + if len(m.Checksums) > 0 { + for _, b := range m.Checksums { + l = len(b) + n += 1 + l + sovTypes(uint64(l)) + } + } + if len(m.SecondarySpAddresses) > 0 { + for _, s := range m.SecondarySpAddresses { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *GroupInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.GroupName) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Id.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *GroupMemberInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Member) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Id.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ExpireTime != 0 { + n += 1 + sovTypes(uint64(m.ExpireTime)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *BucketInfo) 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 ErrIntOverflowTypes + } + 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: BucketInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BucketInfo: 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + 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 BucketName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPublic", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPublic = bool(v != 0) + case 4: + 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateAt", wireType) + } + m.CreateAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreateAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PaymentAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PaymentAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrimarySpAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrimarySpAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadQuota", wireType) + } + m.ReadQuota = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReadQuota |= ReadQuota(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ObjectInfo) 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 ErrIntOverflowTypes + } + 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: ObjectInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectInfo: 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + 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 BucketName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BucketName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ObjectName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadSize", wireType) + } + m.PayloadSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PayloadSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPublic", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPublic = bool(v != 0) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContentType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContentType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateAt", wireType) + } + m.CreateAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreateAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectStatus", wireType) + } + m.ObjectStatus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ObjectStatus |= ObjectStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RedundancyType", wireType) + } + m.RedundancyType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RedundancyType |= RedundancyType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceType", wireType) + } + m.SourceType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SourceType |= SourceType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checksums", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Checksums = append(m.Checksums, make([]byte, postIndex-iNdEx)) + copy(m.Checksums[len(m.Checksums)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecondarySpAddresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecondarySpAddresses = append(m.SecondarySpAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupInfo) 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 ErrIntOverflowTypes + } + 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: GroupInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupInfo: 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + 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 GroupName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupMemberInfo) 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 ErrIntOverflowTypes + } + 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: GroupMemberInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupMemberInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Member = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpireTime", wireType) + } + m.ExpireTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpireTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(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, ErrIntOverflowTypes + } + 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, ErrIntOverflowTypes + } + 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, ErrIntOverflowTypes + } + 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, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/storage/types/util.go b/x/storage/types/util.go new file mode 100644 index 000000000..f9db06063 --- /dev/null +++ b/x/storage/types/util.go @@ -0,0 +1,130 @@ +package types + +import ( + "crypto/sha256" + "strings" + "unicode/utf8" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/crypto/secp256k1" +) + +// CheckValidBucketName - checks if we have a valid input bucket name. +// This is a stricter version. +// - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html +func CheckValidBucketName(bucketName string) (err error) { + if len(bucketName) == 0 || strings.TrimSpace(bucketName) == "" { + return errors.Wrap(ErrInvalidBucketName, "Bucket name cannot be empty") + } + if len(bucketName) < 3 { + return errors.Wrap(ErrInvalidBucketName, "Bucket name cannot be shorter than 3 characters") + } + if len(bucketName) > 63 { + return errors.Wrap(ErrInvalidBucketName, "Bucket name cannot be longer than 63 characters") + } + if ipAddress.MatchString(bucketName) { + return errors.Wrap(ErrInvalidBucketName, "Bucket name cannot be an ip address") + } + if strings.Contains(bucketName, "..") || strings.Contains(bucketName, ".-") || strings.Contains(bucketName, "-.") { + return errors.Wrap(ErrInvalidBucketName, "Bucket name contains invalid characters") + } + if !validBucketName.MatchString(bucketName) { + return errors.Wrap(ErrInvalidBucketName, "Bucket name contains invalid characters") + } + + return nil +} + +const ( + // Bad path components to be rejected by the path validity handler. + dotdotComponent = ".." + dotComponent = "." + + // SlashSeparator - slash separator. + SlashSeparator = "/" +) + +/// CheckValidObjectName - checks if we have a valid input object name. +// - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html +func CheckValidObjectName(objectName string) error { + // check the length of objectname + if len(objectName) == 0 || strings.TrimSpace(objectName) == "" { + return errors.Wrap(ErrInvalidObjectName, "Object name cannot be empty") + } + if len(objectName) > 1024 { + return errors.Wrap(ErrInvalidObjectName, "Object name cannot be longer than 1024 characters") + } + + // check bad path component + if hasBadPathComponent(objectName) { + return errors.Wrap(ErrInvalidObjectName, "Object name with a bad path component are not supported") + } + // check UTF-8 strings + if !utf8.ValidString(objectName) { + return errors.Wrap(ErrInvalidObjectName, "Object name with non UTF-8 strings are not supported") + } + + if strings.Contains(objectName, `//`) { + return errors.Wrap(ErrInvalidObjectName, "Object name with a \"//\" prefix are not supported") + } + + return nil +} + +func CheckValidGroupName(groupName string) error { + if !utf8.ValidString(groupName) { + return errors.Wrap(ErrInvalidGroupName, "Group name with non UTF-8 strings are not supported") + } + return nil +} + +// Check if the incoming path has bad path components, +// such as ".." and "." +func hasBadPathComponent(path string) bool { + path = strings.TrimSpace(path) + for _, p := range strings.Split(path, SlashSeparator) { + switch strings.TrimSpace(p) { + case dotdotComponent: + return true + case dotComponent: + return true + } + } + return false +} + +// CheckValidExpectChecksums checks if the MSG have a valid SHA256 checksum. +func CheckValidExpectChecksums(expectChecksums [][]byte) error { + // TODO(fynn): hard code here. will be replaced by module params. + if len(expectChecksums) != 7 { + return ErrInvalidChcecksum + } + for _, checksum := range expectChecksums { + if len(checksum) != sha256.Size { + return errors.Wrap(ErrInvalidChcecksum, "Invalid SHA256 checksum size.") + } + } + return nil +} + +func CheckValidContentType(contentType string) error { + // TODO(fynn): check validity of the contentType + return nil +} + +func VerifySignature(sigAcc sdk.AccAddress, sigData []byte, sig []byte) error { + if len(sig) != ethcrypto.SignatureLength { + return errors.Wrap(sdkerrors.ErrorInvalidSigner, "signature length doesn't match typical [R||S||V] signature 65 bytes") + } + + // VerifySignature of ethsecp256k1 accepts 64 byte signature [R||S] + // WARNING! Under NO CIRCUMSTANCES try to use pubKey.VerifySignature there + if !secp256k1.VerifySignature(sigAcc.Bytes(), sigData, sig[:len(sig)-1]) { + return errors.Wrap(sdkerrors.ErrorInvalidSigner, "unable to verify signer signature of EIP712 typed data") + } + + return nil +}