From 03211743fcd1683e3d1a1d132e5a25af8e96515c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Mon, 26 May 2025 15:52:33 +0200 Subject: [PATCH] Inspellning registration support (#499) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added DER module * scaffold type --module der DER zigbeeID dirigeraID dirigeraMAC plmntAddress liquidAddress * ./ignite scaffold message registerDER der:DER --module der * changed URL * storing DER * added query * added liquid der asset type * added der asset notarization logic * added nft notarization for DER * added nft query * added query and fixed linter aspects * added store testcases to the der module * added test cases adjusted to the linter requirements * addd ignite generate code changes * added metadata json instead of specific data Signed-off-by: Jürgen Eckel --- .github/workflows/audit.yaml | 2 +- app/app.go | 23 + docs/static/openapi.yml | 186 +++ proto/planetmintgo/der/der.proto | 13 + proto/planetmintgo/der/genesis.proto | 12 + proto/planetmintgo/der/liquid_der_asset.proto | 11 + proto/planetmintgo/der/params.proto | 12 + proto/planetmintgo/der/query.proto | 60 + proto/planetmintgo/der/tx.proto | 28 + tests/e2e/der/cli_test.go | 17 + tests/e2e/der/suite.go | 82 + testutil/keeper/der.go | 54 + util/issue_commands.go | 8 + util/machine_nft.go | 27 + x/der/client/cli/query.go | 36 + x/der/client/cli/query_der.go | 46 + x/der/client/cli/query_nft.go | 46 + x/der/client/cli/query_params.go | 36 + x/der/client/cli/tx.go | 32 + .../cli/tx_notarize_liquid_der_asset.go | 47 + x/der/client/cli/tx_register_der.go | 47 + x/der/genesis.go | 23 + x/der/genesis_test.go | 29 + x/der/keeper/asset_store.go | 20 + x/der/keeper/der_asset.go | 22 + x/der/keeper/der_asset_test.go | 25 + x/der/keeper/keeper.go | 49 + x/der/keeper/liquid_der_asset.go | 22 + x/der/keeper/liquid_der_asset_test.go | 25 + x/der/keeper/msg_server.go | 17 + .../msg_server_notarize_liquid_der_asset.go | 16 + x/der/keeper/msg_server_register_der.go | 46 + x/der/keeper/msg_server_test.go | 23 + x/der/keeper/params.go | 17 + x/der/keeper/params_test.go | 18 + x/der/keeper/query.go | 7 + x/der/keeper/query_der.go | 25 + x/der/keeper/query_nft.go | 25 + x/der/keeper/query_params.go | 19 + x/der/keeper/query_params_test.go | 21 + x/der/keeper/test_helpers.go | 34 + x/der/module.go | 150 ++ x/der/module_simulation.go | 110 ++ x/der/simulation/helpers.go | 15 + x/der/simulation/notarize_liquid_der_asset.go | 29 + x/der/simulation/register_der.go | 29 + x/der/types/codec.go | 31 + x/der/types/der.pb.go | 470 ++++++ x/der/types/errors.go | 12 + x/der/types/expected_keepers.go | 25 + x/der/types/genesis.go | 24 + x/der/types/genesis.pb.go | 320 ++++ x/der/types/genesis_test.go | 41 + x/der/types/keys.go | 23 + x/der/types/liquid_der_asset.pb.go | 421 ++++++ .../message_notarize_liquid_der_asset.go | 47 + .../message_notarize_liquid_der_asset_test.go | 40 + x/der/types/message_register_der.go | 47 + x/der/types/message_register_der_test.go | 40 + x/der/types/params.go | 39 + x/der/types/params.pb.go | 264 ++++ x/der/types/query.pb.go | 1323 +++++++++++++++++ x/der/types/query.pb.gw.go | 355 +++++ x/der/types/tx.pb.go | 975 ++++++++++++ x/der/types/types.go | 1 + 65 files changed, 6138 insertions(+), 1 deletion(-) create mode 100644 proto/planetmintgo/der/der.proto create mode 100644 proto/planetmintgo/der/genesis.proto create mode 100644 proto/planetmintgo/der/liquid_der_asset.proto create mode 100644 proto/planetmintgo/der/params.proto create mode 100644 proto/planetmintgo/der/query.proto create mode 100644 proto/planetmintgo/der/tx.proto create mode 100644 tests/e2e/der/cli_test.go create mode 100644 tests/e2e/der/suite.go create mode 100644 testutil/keeper/der.go create mode 100644 x/der/client/cli/query.go create mode 100644 x/der/client/cli/query_der.go create mode 100644 x/der/client/cli/query_nft.go create mode 100644 x/der/client/cli/query_params.go create mode 100644 x/der/client/cli/tx.go create mode 100644 x/der/client/cli/tx_notarize_liquid_der_asset.go create mode 100644 x/der/client/cli/tx_register_der.go create mode 100644 x/der/genesis.go create mode 100644 x/der/genesis_test.go create mode 100644 x/der/keeper/asset_store.go create mode 100644 x/der/keeper/der_asset.go create mode 100644 x/der/keeper/der_asset_test.go create mode 100644 x/der/keeper/keeper.go create mode 100644 x/der/keeper/liquid_der_asset.go create mode 100644 x/der/keeper/liquid_der_asset_test.go create mode 100644 x/der/keeper/msg_server.go create mode 100644 x/der/keeper/msg_server_notarize_liquid_der_asset.go create mode 100644 x/der/keeper/msg_server_register_der.go create mode 100644 x/der/keeper/msg_server_test.go create mode 100644 x/der/keeper/params.go create mode 100644 x/der/keeper/params_test.go create mode 100644 x/der/keeper/query.go create mode 100644 x/der/keeper/query_der.go create mode 100644 x/der/keeper/query_nft.go create mode 100644 x/der/keeper/query_params.go create mode 100644 x/der/keeper/query_params_test.go create mode 100644 x/der/keeper/test_helpers.go create mode 100644 x/der/module.go create mode 100644 x/der/module_simulation.go create mode 100644 x/der/simulation/helpers.go create mode 100644 x/der/simulation/notarize_liquid_der_asset.go create mode 100644 x/der/simulation/register_der.go create mode 100644 x/der/types/codec.go create mode 100644 x/der/types/der.pb.go create mode 100644 x/der/types/errors.go create mode 100644 x/der/types/expected_keepers.go create mode 100644 x/der/types/genesis.go create mode 100644 x/der/types/genesis.pb.go create mode 100644 x/der/types/genesis_test.go create mode 100644 x/der/types/keys.go create mode 100644 x/der/types/liquid_der_asset.pb.go create mode 100644 x/der/types/message_notarize_liquid_der_asset.go create mode 100644 x/der/types/message_notarize_liquid_der_asset_test.go create mode 100644 x/der/types/message_register_der.go create mode 100644 x/der/types/message_register_der_test.go create mode 100644 x/der/types/params.go create mode 100644 x/der/types/params.pb.go create mode 100644 x/der/types/query.pb.go create mode 100644 x/der/types/query.pb.gw.go create mode 100644 x/der/types/tx.pb.go create mode 100644 x/der/types/types.go diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index a179a0d..1fad2a7 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -214,6 +214,6 @@ jobs: run: | pushd ${{ matrix.directory }} # Exclude generated .pb.go and .pb.gw.go files from test and coverage - go test -coverprofile cover.out -race -vet=off -v $(go list ./... | grep -v types) + go test -coverprofile cover.out -race -vet=off -timeout 15m -v $(go list ./... | grep -v types) # Print coverage by function go tool cover -func=cover.out diff --git a/app/app.go b/app/app.go index a5d397c..d41ab02 100644 --- a/app/app.go +++ b/app/app.go @@ -122,6 +122,10 @@ import ( daomodulekeeper "github.com/planetmint/planetmint-go/x/dao/keeper" daomoduletypes "github.com/planetmint/planetmint-go/x/dao/types" + dermodule "github.com/planetmint/planetmint-go/x/der" + dermodulekeeper "github.com/planetmint/planetmint-go/x/der/keeper" + dermoduletypes "github.com/planetmint/planetmint-go/x/der/types" + // this line is used by starport scaffolding # stargate/app/moduleImport pmante "github.com/planetmint/planetmint-go/app/ante" @@ -186,6 +190,7 @@ var ( machinemodule.AppModuleBasic{}, assetmodule.AppModuleBasic{}, daomodule.AppModuleBasic{}, + dermodule.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -267,6 +272,8 @@ type App struct { AssetKeeper assetmodulekeeper.Keeper DaoKeeper daomodulekeeper.Keeper + + DerKeeper dermodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // mm is the module manager @@ -317,6 +324,7 @@ func New( machinemoduletypes.TrustAnchorKey, machinemoduletypes.AddressIndexKey, assetmoduletypes.StoreKey, daomoduletypes.StoreKey, daomoduletypes.ChallengeKey, daomoduletypes.MintRequestHashKey, daomoduletypes.MintRequestAddressKey, + dermoduletypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -582,6 +590,16 @@ func New( ) daoModule := daomodule.NewAppModule(appCodec, app.DaoKeeper, app.AccountKeeper, app.BankKeeper) + app.DerKeeper = *dermodulekeeper.NewKeeper( + appCodec, + keys[dermoduletypes.StoreKey], + keys[dermoduletypes.MemStoreKey], + app.GetSubspace(dermoduletypes.ModuleName), + app.MachineKeeper, + homePath, + ) + derModule := dermodule.NewAppModule(appCodec, app.DerKeeper, app.AccountKeeper, app.BankKeeper) + // this line is used by starport scaffolding # stargate/app/keeperDefinition /**** IBC Routing ****/ @@ -646,6 +664,7 @@ func New( machineModule, assetModule, daoModule, + derModule, // this line is used by starport scaffolding # stargate/app/appModule crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them @@ -681,6 +700,7 @@ func New( machinemoduletypes.ModuleName, assetmoduletypes.ModuleName, daomoduletypes.ModuleName, + dermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -709,6 +729,7 @@ func New( machinemoduletypes.ModuleName, assetmoduletypes.ModuleName, daomoduletypes.ModuleName, + dermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -742,6 +763,7 @@ func New( machinemoduletypes.ModuleName, assetmoduletypes.ModuleName, daomoduletypes.ModuleName, + dermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } app.mm.SetOrderInitGenesis(genesisModuleOrder...) @@ -982,6 +1004,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(machinemoduletypes.ModuleName) paramsKeeper.Subspace(assetmoduletypes.ModuleName) paramsKeeper.Subspace(daomoduletypes.ModuleName) + paramsKeeper.Subspace(dermoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index f21150e..809986a 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -47663,6 +47663,132 @@ paths: type: boolean tags: - Query + /planetmint/der/der/{zigbeeID}: + get: + summary: Queries a list of Der items. + operationId: PlanetmintgoDerDer + responses: + '200': + description: A successful response. + schema: + type: object + properties: + der: + type: object + properties: + zigbeeID: + type: string + plmntAddress: + type: string + liquidAddress: + type: string + metadataJson: + type: string + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: zigbeeID + in: path + required: true + type: string + tags: + - Query + /planetmint/der/nft/{zigbeeID}: + get: + summary: Queries a list of Nft items. + operationId: PlanetmintgoDerNft + responses: + '200': + description: A successful response. + schema: + type: object + properties: + derNft: + type: object + properties: + zigbeeID: + type: string + plmntAddress: + type: string + assetID: + type: string + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: zigbeeID + in: path + required: true + type: string + tags: + - Query + /planetmint/der/params: + get: + summary: Parameters queries the parameters of the module. + operationId: PlanetmintgoDerParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query /planetmint/machine/activated_trust_anchor_count: get: summary: Queries a list of ActivatedTrustAnchorCount items. @@ -77407,6 +77533,66 @@ definitions: lastIncludedPop: type: string format: int64 + planetmintgo.der.DER: + type: object + properties: + zigbeeID: + type: string + plmntAddress: + type: string + liquidAddress: + type: string + metadataJson: + type: string + planetmintgo.der.LiquidDerAsset: + type: object + properties: + zigbeeID: + type: string + plmntAddress: + type: string + assetID: + type: string + planetmintgo.der.MsgNotarizeLiquidDerAssetResponse: + type: object + planetmintgo.der.MsgRegisterDERResponse: + type: object + planetmintgo.der.Params: + type: object + description: Params defines the parameters for the module. + planetmintgo.der.QueryDerResponse: + type: object + properties: + der: + type: object + properties: + zigbeeID: + type: string + plmntAddress: + type: string + liquidAddress: + type: string + metadataJson: + type: string + planetmintgo.der.QueryNftResponse: + type: object + properties: + derNft: + type: object + properties: + zigbeeID: + type: string + plmntAddress: + type: string + assetID: + type: string + planetmintgo.der.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: QueryParamsResponse is response type for the Query/Params RPC method. planetmintgo.machine.LiquidAsset: type: object properties: diff --git a/proto/planetmintgo/der/der.proto b/proto/planetmintgo/der/der.proto new file mode 100644 index 0000000..074f027 --- /dev/null +++ b/proto/planetmintgo/der/der.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package planetmintgo.der; + +option go_package = "github.com/planetmint/planetmint-go/x/der/types"; + +message DER { + + string zigbeeID = 1; + string plmntAddress = 2; + string liquidAddress = 3; + string metadataJson = 4; + +} diff --git a/proto/planetmintgo/der/genesis.proto b/proto/planetmintgo/der/genesis.proto new file mode 100644 index 0000000..fb05183 --- /dev/null +++ b/proto/planetmintgo/der/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package planetmintgo.der; + +import "gogoproto/gogo.proto"; +import "planetmintgo/der/params.proto"; + +option go_package = "github.com/planetmint/planetmint-go/x/der/types"; + +// GenesisState defines the der module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/planetmintgo/der/liquid_der_asset.proto b/proto/planetmintgo/der/liquid_der_asset.proto new file mode 100644 index 0000000..c6c4047 --- /dev/null +++ b/proto/planetmintgo/der/liquid_der_asset.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package planetmintgo.der; + +option go_package = "github.com/planetmint/planetmint-go/x/der/types"; + +message LiquidDerAsset { + + string zigbeeID = 1; + string plmntAddress = 2; + string assetID = 3; +} diff --git a/proto/planetmintgo/der/params.proto b/proto/planetmintgo/der/params.proto new file mode 100644 index 0000000..912082b --- /dev/null +++ b/proto/planetmintgo/der/params.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package planetmintgo.der; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/planetmint/planetmint-go/x/der/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + +} diff --git a/proto/planetmintgo/der/query.proto b/proto/planetmintgo/der/query.proto new file mode 100644 index 0000000..51e82e0 --- /dev/null +++ b/proto/planetmintgo/der/query.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; + +package planetmintgo.der; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "planetmintgo/der/params.proto"; +import "planetmintgo/der/der.proto"; +import "planetmintgo/der/liquid_der_asset.proto"; + +option go_package = "github.com/planetmint/planetmint-go/x/der/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 = "/planetmint/der/params"; + + } + + // Queries a list of Der items. + rpc Der (QueryDerRequest) returns (QueryDerResponse) { + option (google.api.http).get = "/planetmint/der/der/{zigbeeID}"; + + } + + // Queries a list of Nft items. + rpc Nft (QueryNftRequest) returns (QueryNftResponse) { + option (google.api.http).get = "/planetmint/der/nft/{zigbeeID}"; + + } +} +// 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]; +} + +message QueryDerRequest { + string zigbeeID = 1; +} + +message QueryDerResponse { + DER der = 1; +} + +message QueryNftRequest { + string zigbeeID = 1; +} + +message QueryNftResponse { + LiquidDerAsset derNft = 1; +} + diff --git a/proto/planetmintgo/der/tx.proto b/proto/planetmintgo/der/tx.proto new file mode 100644 index 0000000..4478516 --- /dev/null +++ b/proto/planetmintgo/der/tx.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package planetmintgo.der; + +import "planetmintgo/der/der.proto"; +import "planetmintgo/der/liquid_der_asset.proto"; + +option go_package = "github.com/planetmint/planetmint-go/x/der/types"; + +// Msg defines the Msg service. +service Msg { + rpc RegisterDER (MsgRegisterDER ) returns (MsgRegisterDERResponse ); + rpc NotarizeLiquidDerAsset (MsgNotarizeLiquidDerAsset) returns (MsgNotarizeLiquidDerAssetResponse); +} +message MsgRegisterDER { + string creator = 1; + DER der = 2; +} + +message MsgRegisterDERResponse {} + +message MsgNotarizeLiquidDerAsset { + string creator = 1; + LiquidDerAsset derAsset = 2; +} + +message MsgNotarizeLiquidDerAssetResponse {} + diff --git a/tests/e2e/der/cli_test.go b/tests/e2e/der/cli_test.go new file mode 100644 index 0000000..ae470e2 --- /dev/null +++ b/tests/e2e/der/cli_test.go @@ -0,0 +1,17 @@ +package der + +import ( + "testing" + "time" + + "github.com/planetmint/planetmint-go/testutil/network" + + "github.com/stretchr/testify/suite" +) + +func TestE2EMachineTestSuite(t *testing.T) { + time.Sleep(2 * time.Second) + cfg := network.LoaderDefaultConfig() + cfg.NumValidators = 3 + suite.Run(t, NewE2ETestSuite(cfg)) +} diff --git a/tests/e2e/der/suite.go b/tests/e2e/der/suite.go new file mode 100644 index 0000000..f156834 --- /dev/null +++ b/tests/e2e/der/suite.go @@ -0,0 +1,82 @@ +package der + +import ( + clitestutil "github.com/planetmint/planetmint-go/testutil/cli" + e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" + "github.com/planetmint/planetmint-go/testutil/network" + "github.com/planetmint/planetmint-go/testutil/sample" + dercli "github.com/planetmint/planetmint-go/x/der/client/cli" + dertypes "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +// E2ETestSuite struct definition of machine suite +type E2ETestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network + feeDenom string +} + +// NewE2ETestSuite returns configured machine E2ETestSuite +func NewE2ETestSuite(cfg network.Config) *E2ETestSuite { + return &E2ETestSuite{cfg: cfg} +} + +// SetupSuite initializes machine E2ETestSuite +func (s *E2ETestSuite) SetupSuite() { + s.T().Log("setting up e2e machine test suite") + + s.feeDenom = sample.FeeDenom + s.network = network.Load(s.T(), s.cfg) + + // create machine account for attestation + account, err := e2etestutil.CreateAccount(s.network, sample.Name, sample.Mnemonic) + s.Require().NoError(err) + err = e2etestutil.FundAccount(s.network, account, s.feeDenom) + s.Require().NoError(err) +} + +// TearDownSuite clean up after testing +func (s *E2ETestSuite) TearDownSuite() { + s.T().Log("tearing down e2e machine test suite") +} + +// TestRegisterDER attests a DER and queries the attested DER from the chain +func (s *E2ETestSuite) TestRegisterDER() { + val := s.network.Validators[0] + + der := dertypes.DER{ + ZigbeeID: "0123456789123456", + PlmntAddress: val.Address.String(), + LiquidAddress: "liquidder", + MetadataJson: "{\"dirigeraID\": \"0123456789123456\", \"dirigeraMac\": \"00:00:00:00:00:00\"}", + } + + msg1 := dertypes.NewMsgRegisterDER(val.Address.String(), &der) + out, err := e2etestutil.BuildSignBroadcastTx(s.T(), val.Address, msg1) + s.Require().NoError(err) + + s.Require().NoError(s.network.WaitForNextBlock()) + s.Require().NoError(s.network.WaitForNextBlock()) + rawLog, err := clitestutil.GetRawLogFromTxOut(val, out) + s.Require().NoError(err) + + assert.Contains(s.T(), rawLog, "planetmintgo.der.MsgRegisterDER") + + // Check if DER can be resolved + output, err := clitestutil.ExecTestCLICmd(val.ClientCtx, dercli.CmdDer(), []string{ + der.ZigbeeID, + }) + s.Require().NoError(err) + assert.Contains(s.T(), output.String(), "0123456789123456") + + // Check if the NFT got created + output, err = clitestutil.ExecTestCLICmd(val.ClientCtx, dercli.CmdNft(), []string{ + der.ZigbeeID, + }) + s.Require().NoError(err) + assert.Contains(s.T(), output.String(), "0123456789123456") +} diff --git a/testutil/keeper/der.go b/testutil/keeper/der.go new file mode 100644 index 0000000..a245d29 --- /dev/null +++ b/testutil/keeper/der.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "testing" + + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/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/planetmint/planetmint-go/x/der/keeper" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func DerKeeper(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, + "DerParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + nil, // No need for machine keeper in this test + "", + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/util/issue_commands.go b/util/issue_commands.go index e611aa7..a78aebb 100644 --- a/util/issue_commands.go +++ b/util/issue_commands.go @@ -8,6 +8,7 @@ import ( "github.com/planetmint/planetmint-go/config" "github.com/planetmint/planetmint-go/lib" daotypes "github.com/planetmint/planetmint-go/x/dao/types" + dertypes "github.com/planetmint/planetmint-go/x/der/types" machinetypes "github.com/planetmint/planetmint-go/x/machine/types" "sigs.k8s.io/yaml" ) @@ -87,6 +88,13 @@ func SendLiquidAssetRegistration(goCtx context.Context, notarizedAsset machinety buildSignBroadcastTx(goCtx, loggingContext, sendingValidatorAddress, msg) } +func SendLiquidDerAssetRegistration(goCtx context.Context, notarizedAsset dertypes.LiquidDerAsset) { + sendingValidatorAddress := config.GetConfig().GetNodeAddress() + msg := dertypes.NewMsgNotarizeLiquidDerAsset(sendingValidatorAddress, ¬arizedAsset) + loggingContext := "notarize liquid DER asset" + buildSignBroadcastTx(goCtx, loggingContext, sendingValidatorAddress, msg) +} + func SendInitPoP(goCtx context.Context, challenger string, challengee string, blockHeight int64) { sendingValidatorAddress := config.GetConfig().GetNodeAddress() msg := daotypes.NewMsgInitPop(sendingValidatorAddress, sendingValidatorAddress, challenger, challengee, blockHeight) diff --git a/util/machine_nft.go b/util/machine_nft.go index 4939eb2..2c1325c 100644 --- a/util/machine_nft.go +++ b/util/machine_nft.go @@ -13,6 +13,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/planetmint/planetmint-go/clients/shamir/coordinator" + derTypes "github.com/planetmint/planetmint-go/x/der/types" "github.com/planetmint/planetmint-go/x/machine/types" ) @@ -28,6 +29,32 @@ func init() { RegisterAssetServiceHTTPClient = &http.Client{} } +func IssueDerNFT(goCtx context.Context, der *derTypes.DER, scheme string, domain string, path string) error { + ctx := sdk.UnwrapSDKContext(goCtx) + // asset registration is in order to have the contact published + var notarizedAsset derTypes.LiquidDerAsset + + assetID, contract, hex, err := coordinator.IssueNFTAsset(goCtx, der.ZigbeeID, der.PlmntAddress, domain) + if err != nil { + GetAppLogger().Error(ctx, err, "") + return err + } + assetRegistryEndpoint := fmt.Sprintf("%s://%s/%s", scheme, domain, path) + + GetAppLogger().Info(ctx, "Liquid Token Issuance assetID: "+assetID+" contract: "+contract+" tx: "+hex) + err = RegisterAsset(goCtx, assetID, contract, assetRegistryEndpoint) + if err != nil { + GetAppLogger().Error(ctx, err, "") + } + // issue message with: + notarizedAsset.AssetID = assetID + notarizedAsset.ZigbeeID = der.ZigbeeID + notarizedAsset.PlmntAddress = der.PlmntAddress + + SendLiquidDerAssetRegistration(goCtx, notarizedAsset) + return err +} + func IssueMachineNFT(goCtx context.Context, machine *types.Machine, scheme string, domain string, path string) error { ctx := sdk.UnwrapSDKContext(goCtx) // asset registration is in order to have the contact published diff --git a/x/der/client/cli/query.go b/x/der/client/cli/query.go new file mode 100644 index 0000000..124d344 --- /dev/null +++ b/x/der/client/cli/query.go @@ -0,0 +1,36 @@ +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/planetmint/planetmint-go/x/der/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + _ = queryRoute + // Group der 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(CmdDer()) + + cmd.AddCommand(CmdNft()) + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/der/client/cli/query_der.go b/x/der/client/cli/query_der.go new file mode 100644 index 0000000..f98b862 --- /dev/null +++ b/x/der/client/cli/query_der.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdDer() *cobra.Command { + cmd := &cobra.Command{ + Use: "der [zigbee-id]", + Short: "Query der", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqZigbeeID := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDerRequest{ + + ZigbeeID: reqZigbeeID, + } + + res, err := queryClient.Der(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/der/client/cli/query_nft.go b/x/der/client/cli/query_nft.go new file mode 100644 index 0000000..a7829e7 --- /dev/null +++ b/x/der/client/cli/query_nft.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdNft() *cobra.Command { + cmd := &cobra.Command{ + Use: "nft [zigbee-id]", + Short: "Query nft", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqZigbeeID := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryNftRequest{ + + ZigbeeID: reqZigbeeID, + } + + res, err := queryClient.Nft(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/der/client/cli/query_params.go b/x/der/client/cli/query_params.go new file mode 100644 index 0000000..6d884d8 --- /dev/null +++ b/x/der/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/planetmint/planetmint-go/x/der/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/der/client/cli/tx.go b/x/der/client/cli/tx.go new file mode 100644 index 0000000..76f535a --- /dev/null +++ b/x/der/client/cli/tx.go @@ -0,0 +1,32 @@ +package cli + +import ( + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/planetmint/planetmint-go/x/der/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: types.ModuleName + " transactions subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdRegisterDER()) + cmd.AddCommand(CmdNotarizeLiquidDerAsset()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/der/client/cli/tx_notarize_liquid_der_asset.go b/x/der/client/cli/tx_notarize_liquid_der_asset.go new file mode 100644 index 0000000..57b741a --- /dev/null +++ b/x/der/client/cli/tx_notarize_liquid_der_asset.go @@ -0,0 +1,47 @@ +package cli + +import ( + "strconv" + + "encoding/json" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdNotarizeLiquidDerAsset() *cobra.Command { + cmd := &cobra.Command{ + Use: "notarize-liquid-der-asset [der-asset]", + Short: "Broadcast message notarizeLiquidDerAsset", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argDerAsset := new(types.LiquidDerAsset) + err = json.Unmarshal([]byte(args[0]), argDerAsset) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgNotarizeLiquidDerAsset( + clientCtx.GetFromAddress().String(), + argDerAsset, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/der/client/cli/tx_register_der.go b/x/der/client/cli/tx_register_der.go new file mode 100644 index 0000000..c63d4d6 --- /dev/null +++ b/x/der/client/cli/tx_register_der.go @@ -0,0 +1,47 @@ +package cli + +import ( + "strconv" + + "encoding/json" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdRegisterDER() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-der [der]", + Short: "Broadcast message registerDER", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argDer := new(types.DER) + err = json.Unmarshal([]byte(args[0]), argDer) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRegisterDER( + clientCtx.GetFromAddress().String(), + argDer, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/der/genesis.go b/x/der/genesis.go new file mode 100644 index 0000000..a6b5485 --- /dev/null +++ b/x/der/genesis.go @@ -0,0 +1,23 @@ +package der + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/keeper" + "github.com/planetmint/planetmint-go/x/der/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/der/genesis_test.go b/x/der/genesis_test.go new file mode 100644 index 0000000..a266f82 --- /dev/null +++ b/x/der/genesis_test.go @@ -0,0 +1,29 @@ +package der_test + +import ( + "testing" + + keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/nullify" + "github.com/planetmint/planetmint-go/x/der" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.DerKeeper(t) + der.InitGenesis(ctx, *k, genesisState) + got := der.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/der/keeper/asset_store.go b/x/der/keeper/asset_store.go new file mode 100644 index 0000000..cc52fd6 --- /dev/null +++ b/x/der/keeper/asset_store.go @@ -0,0 +1,20 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/util" +) + +// storeAsset is a helper for storing any asset type. +func (k Keeper) storeAsset(ctx sdk.Context, keyPrefix []byte, zigbeeID string, value []byte) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), keyPrefix) + store.Set(util.SerializeString(zigbeeID), value) +} + +// lookupAsset is a helper for looking up any asset type. +func (k Keeper) lookupAsset(ctx sdk.Context, keyPrefix []byte, zigbeeID string) (bz []byte, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), keyPrefix) + bz = store.Get(util.SerializeString(zigbeeID)) + return bz, bz != nil +} diff --git a/x/der/keeper/der_asset.go b/x/der/keeper/der_asset.go new file mode 100644 index 0000000..2a048a7 --- /dev/null +++ b/x/der/keeper/der_asset.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" +) + +func (k Keeper) StoreDerAsset(ctx sdk.Context, asset types.DER) { + appendValue := k.cdc.MustMarshal(&asset) + k.storeAsset(ctx, types.KeyPrefix(types.DerAssetKey), asset.ZigbeeID, appendValue) +} + +func (k Keeper) LookupDerAsset(ctx sdk.Context, zigbeeID string) (val types.DER, found bool) { + bz, found := k.lookupAsset(ctx, types.KeyPrefix(types.DerAssetKey), zigbeeID) + if !found { + return val, false + } + if err := k.cdc.Unmarshal(bz, &val); err != nil { + return val, false + } + return val, true +} diff --git a/x/der/keeper/der_asset_test.go b/x/der/keeper/der_asset_test.go new file mode 100644 index 0000000..e04b1bc --- /dev/null +++ b/x/der/keeper/der_asset_test.go @@ -0,0 +1,25 @@ +package keeper + +import ( + dertypes "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" + "testing" +) + +func TestStoreDerAssetAndLookupDerAsset(t *testing.T) { + keeper, ctx := CreateTestKeeper(t) + asset := dertypes.DER{ + ZigbeeID: "test-zigbee-id", + } + + keeper.StoreDerAsset(ctx, asset) + result, found := keeper.LookupDerAsset(ctx, "test-zigbee-id") + require.True(t, found) + require.Equal(t, asset.ZigbeeID, result.ZigbeeID) +} + +func TestLookupDerAsset_NotFound(t *testing.T) { + keeper, ctx := CreateTestKeeper(t) + _, found := keeper.LookupDerAsset(ctx, "nonexistent-id") + require.False(t, found) +} diff --git a/x/der/keeper/keeper.go b/x/der/keeper/keeper.go new file mode 100644 index 0000000..80e82e4 --- /dev/null +++ b/x/der/keeper/keeper.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "github.com/cometbft/cometbft/libs/log" + "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/planetmint/planetmint-go/x/der/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + MachineKeeper types.MachineKeeper // reference to machine keeper + rootDir string + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + machineKeeper types.MachineKeeper, // add machineKeeper param + rootDir string, +) *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, + MachineKeeper: machineKeeper, // set field + rootDir: rootDir, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} diff --git a/x/der/keeper/liquid_der_asset.go b/x/der/keeper/liquid_der_asset.go new file mode 100644 index 0000000..bdfab06 --- /dev/null +++ b/x/der/keeper/liquid_der_asset.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" +) + +func (k Keeper) StoreLiquidDerAsset(ctx sdk.Context, asset types.LiquidDerAsset) { + appendValue := k.cdc.MustMarshal(&asset) + k.storeAsset(ctx, types.KeyPrefix(types.LiquidDerAssetKey), asset.ZigbeeID, appendValue) +} + +func (k Keeper) LookupLiquidDerAsset(ctx sdk.Context, zigbeeID string) (val types.LiquidDerAsset, found bool) { + bz, found := k.lookupAsset(ctx, types.KeyPrefix(types.LiquidDerAssetKey), zigbeeID) + if !found { + return val, false + } + if err := k.cdc.Unmarshal(bz, &val); err != nil { + return val, false + } + return val, true +} diff --git a/x/der/keeper/liquid_der_asset_test.go b/x/der/keeper/liquid_der_asset_test.go new file mode 100644 index 0000000..abb128a --- /dev/null +++ b/x/der/keeper/liquid_der_asset_test.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "testing" + + dertypes "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func TestStoreLiquidDerAssetAndLookupLiquidDerAsset(t *testing.T) { + keeper, ctx := CreateTestKeeper(t) + asset := dertypes.LiquidDerAsset{ + ZigbeeID: "liquid-test-zigbee-id", + } + keeper.StoreLiquidDerAsset(ctx, asset) + result, found := keeper.LookupLiquidDerAsset(ctx, "liquid-test-zigbee-id") + require.True(t, found) + require.Equal(t, asset.ZigbeeID, result.ZigbeeID) +} + +func TestLookupLiquidDerAsset_NotFound(t *testing.T) { + keeper, ctx := CreateTestKeeper(t) + _, found := keeper.LookupLiquidDerAsset(ctx, "nonexistent-id") + require.False(t, found) +} diff --git a/x/der/keeper/msg_server.go b/x/der/keeper/msg_server.go new file mode 100644 index 0000000..beece4a --- /dev/null +++ b/x/der/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/planetmint/planetmint-go/x/der/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/der/keeper/msg_server_notarize_liquid_der_asset.go b/x/der/keeper/msg_server_notarize_liquid_der_asset.go new file mode 100644 index 0000000..c6089b3 --- /dev/null +++ b/x/der/keeper/msg_server_notarize_liquid_der_asset.go @@ -0,0 +1,16 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" +) + +func (k msgServer) NotarizeLiquidDerAsset(goCtx context.Context, msg *types.MsgNotarizeLiquidDerAsset) (*types.MsgNotarizeLiquidDerAssetResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + k.StoreLiquidDerAsset(ctx, *msg.DerAsset) + + return &types.MsgNotarizeLiquidDerAssetResponse{}, nil +} diff --git a/x/der/keeper/msg_server_register_der.go b/x/der/keeper/msg_server_register_der.go new file mode 100644 index 0000000..18120c5 --- /dev/null +++ b/x/der/keeper/msg_server_register_der.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/util" + "github.com/planetmint/planetmint-go/x/der/types" + machinesTypes "github.com/planetmint/planetmint-go/x/machine/types" +) + +func (k msgServer) RegisterDER(goCtx context.Context, msg *types.MsgRegisterDER) (*types.MsgRegisterDERResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + k.StoreDerAsset(ctx, *msg.Der) + + // Get machine params from MachineKeeper + params := k.MachineKeeper.GetParams(ctx) + + // Process NFT issuance if validator is block proposer + if util.IsValidatorBlockProposer(ctx, k.rootDir) { + k.handleDERNFTIssuance(goCtx, msg.Der, params) + } else { + util.GetAppLogger().Info(ctx, "Not block proposer: skipping DER NFT issuance") + } + + return &types.MsgRegisterDERResponse{}, nil +} + +func (k msgServer) handleDERNFTIssuance(goCtx context.Context, der *types.DER, params machinesTypes.Params) { + ctx := sdk.UnwrapSDKContext(goCtx) + logger := util.GetAppLogger() + logger.Info(ctx, "Issuing DER NFT: "+der.String()) + + err := util.IssueDerNFT(goCtx, der, + params.AssetRegistryScheme, + params.AssetRegistryDomain, + params.AssetRegistryPath, + ) + + if err != nil { + logger.Error(ctx, err, "DER NFT issuance failed") + } else { + logger.Info(ctx, "DER NFT issuance successful: "+der.ZigbeeID) + } +} diff --git a/x/der/keeper/msg_server_test.go b/x/der/keeper/msg_server_test.go new file mode 100644 index 0000000..a58f224 --- /dev/null +++ b/x/der/keeper/msg_server_test.go @@ -0,0 +1,23 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/x/der/keeper" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.DerKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} + +func TestMsgServer(t *testing.T) { + ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} diff --git a/x/der/keeper/params.go b/x/der/keeper/params.go new file mode 100644 index 0000000..ebb3a8c --- /dev/null +++ b/x/der/keeper/params.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + _ = ctx + 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/der/keeper/params_test.go b/x/der/keeper/params_test.go new file mode 100644 index 0000000..f9f0d59 --- /dev/null +++ b/x/der/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.DerKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/der/keeper/query.go b/x/der/keeper/query.go new file mode 100644 index 0000000..797d7c9 --- /dev/null +++ b/x/der/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/planetmint/planetmint-go/x/der/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/der/keeper/query_der.go b/x/der/keeper/query_der.go new file mode 100644 index 0000000..58da303 --- /dev/null +++ b/x/der/keeper/query_der.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Der(goCtx context.Context, req *types.QueryDerRequest) (*types.QueryDerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + der, found := k.LookupDerAsset(ctx, req.ZigbeeID) + if !found { + return nil, status.Error(codes.NotFound, "error zigbeeID not found: "+req.ZigbeeID) + } + + return &types.QueryDerResponse{Der: &der}, nil +} diff --git a/x/der/keeper/query_nft.go b/x/der/keeper/query_nft.go new file mode 100644 index 0000000..d3eea9c --- /dev/null +++ b/x/der/keeper/query_nft.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Nft(goCtx context.Context, req *types.QueryNftRequest) (*types.QueryNftResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + derNft, found := k.LookupLiquidDerAsset(ctx, req.ZigbeeID) + if !found { + return nil, status.Error(codes.NotFound, "error zigbeeID not found: "+req.ZigbeeID) + } + + return &types.QueryNftResponse{DerNft: &derNft}, nil +} diff --git a/x/der/keeper/query_params.go b/x/der/keeper/query_params.go new file mode 100644 index 0000000..0026812 --- /dev/null +++ b/x/der/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/der/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/der/keeper/query_params_test.go b/x/der/keeper/query_params_test.go new file mode 100644 index 0000000..52ddf40 --- /dev/null +++ b/x/der/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + testkeeper "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.DerKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/der/keeper/test_helpers.go b/x/der/keeper/test_helpers.go new file mode 100644 index 0000000..2b15a0f --- /dev/null +++ b/x/der/keeper/test_helpers.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "testing" + + dbm "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "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" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" +) + +func CreateTestKeeper(t *testing.T) (Keeper, sdk.Context) { + db := dbm.NewMemDB() + cms := store.NewCommitMultiStore(db) + storeKey := sdk.NewKVStoreKey("der") + memKey := storetypes.NewMemoryStoreKey("mem_der") + cms.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + cms.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, nil) + err := cms.LoadLatestVersion() + require.NoError(t, err) + + interfaceRegistry := cdctypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + ps := paramtypes.NewSubspace(cdc, codec.NewLegacyAmino(), storeKey, memKey, "DerParams") + keeper := NewKeeper(cdc, storeKey, memKey, ps, nil, "") + ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger()) + return *keeper, ctx +} diff --git a/x/der/module.go b/x/der/module.go new file mode 100644 index 0000000..4c9af04 --- /dev/null +++ b/x/der/module.go @@ -0,0 +1,150 @@ +package der + +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/cometbft/cometbft/abci/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/planetmint/planetmint-go/x/der/client/cli" + "github.com/planetmint/planetmint-go/x/der/keeper" + "github.com/planetmint/planetmint-go/x/der/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + _ = config + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/der/module_simulation.go b/x/der/module_simulation.go new file mode 100644 index 0000000..acc1e50 --- /dev/null +++ b/x/der/module_simulation.go @@ -0,0 +1,110 @@ +package der + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + 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/planetmint/planetmint-go/testutil/sample" + dersimulation "github.com/planetmint/planetmint-go/x/der/simulation" + "github.com/planetmint/planetmint-go/x/der/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = dersimulation.FindAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace + _ = rand.Rand{} +) + +const ( + opWeightMsgRegisterDER = "op_weight_msg_register_der" + // TODO: Determine the simulation weight value + defaultWeightMsgRegisterDER int = 100 + + opWeightMsgNotarizeLiquidDerAsset = "op_weight_msg_notarize_liquid_der_asset" + // TODO: Determine the simulation weight value + defaultWeightMsgNotarizeLiquidDerAsset 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() + } + derGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&derGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { + return nil +} + +// 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 weightMsgRegisterDER int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgRegisterDER, &weightMsgRegisterDER, nil, + func(_ *rand.Rand) { + weightMsgRegisterDER = defaultWeightMsgRegisterDER + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgRegisterDER, + dersimulation.SimulateMsgRegisterDER(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgNotarizeLiquidDerAsset int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgNotarizeLiquidDerAsset, &weightMsgNotarizeLiquidDerAsset, nil, + func(_ *rand.Rand) { + weightMsgNotarizeLiquidDerAsset = defaultWeightMsgNotarizeLiquidDerAsset + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgNotarizeLiquidDerAsset, + dersimulation.SimulateMsgNotarizeLiquidDerAsset(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgRegisterDER, + defaultWeightMsgRegisterDER, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + dersimulation.SimulateMsgRegisterDER(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), + simulation.NewWeightedProposalMsg( + opWeightMsgNotarizeLiquidDerAsset, + defaultWeightMsgNotarizeLiquidDerAsset, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + dersimulation.SimulateMsgNotarizeLiquidDerAsset(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), + // this line is used by starport scaffolding # simapp/module/OpMsg + } +} diff --git a/x/der/simulation/helpers.go b/x/der/simulation/helpers.go new file mode 100644 index 0000000..92c437c --- /dev/null +++ b/x/der/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/der/simulation/notarize_liquid_der_asset.go b/x/der/simulation/notarize_liquid_der_asset.go new file mode 100644 index 0000000..b8b6dab --- /dev/null +++ b/x/der/simulation/notarize_liquid_der_asset.go @@ -0,0 +1,29 @@ +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/planetmint/planetmint-go/x/der/keeper" + "github.com/planetmint/planetmint-go/x/der/types" +) + +func SimulateMsgNotarizeLiquidDerAsset( + 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.MsgNotarizeLiquidDerAsset{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the NotarizeLiquidDerAsset simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "NotarizeLiquidDerAsset simulation not implemented"), nil, nil + } +} diff --git a/x/der/simulation/register_der.go b/x/der/simulation/register_der.go new file mode 100644 index 0000000..e85b53b --- /dev/null +++ b/x/der/simulation/register_der.go @@ -0,0 +1,29 @@ +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/planetmint/planetmint-go/x/der/keeper" + "github.com/planetmint/planetmint-go/x/der/types" +) + +func SimulateMsgRegisterDER( + 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.MsgRegisterDER{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the RegisterDER simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "RegisterDER simulation not implemented"), nil, nil + } +} diff --git a/x/der/types/codec.go b/x/der/types/codec.go new file mode 100644 index 0000000..60f8550 --- /dev/null +++ b/x/der/types/codec.go @@ -0,0 +1,31 @@ +package types + +import ( + "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/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegisterDER{}, "der/RegisterDER", nil) + cdc.RegisterConcrete(&MsgNotarizeLiquidDerAsset{}, "der/NotarizeLiquidDerAsset", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRegisterDER{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgNotarizeLiquidDerAsset{}, + ) + // 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/der/types/der.pb.go b/x/der/types/der.pb.go new file mode 100644 index 0000000..32fe11f --- /dev/null +++ b/x/der/types/der.pb.go @@ -0,0 +1,470 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/der/der.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/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 DER struct { + ZigbeeID string `protobuf:"bytes,1,opt,name=zigbeeID,proto3" json:"zigbeeID,omitempty"` + PlmntAddress string `protobuf:"bytes,2,opt,name=plmntAddress,proto3" json:"plmntAddress,omitempty"` + LiquidAddress string `protobuf:"bytes,3,opt,name=liquidAddress,proto3" json:"liquidAddress,omitempty"` + MetadataJson string `protobuf:"bytes,4,opt,name=metadataJson,proto3" json:"metadataJson,omitempty"` +} + +func (m *DER) Reset() { *m = DER{} } +func (m *DER) String() string { return proto.CompactTextString(m) } +func (*DER) ProtoMessage() {} +func (*DER) Descriptor() ([]byte, []int) { + return fileDescriptor_6380e8122e200808, []int{0} +} +func (m *DER) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DER) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DER.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 *DER) XXX_Merge(src proto.Message) { + xxx_messageInfo_DER.Merge(m, src) +} +func (m *DER) XXX_Size() int { + return m.Size() +} +func (m *DER) XXX_DiscardUnknown() { + xxx_messageInfo_DER.DiscardUnknown(m) +} + +var xxx_messageInfo_DER proto.InternalMessageInfo + +func (m *DER) GetZigbeeID() string { + if m != nil { + return m.ZigbeeID + } + return "" +} + +func (m *DER) GetPlmntAddress() string { + if m != nil { + return m.PlmntAddress + } + return "" +} + +func (m *DER) GetLiquidAddress() string { + if m != nil { + return m.LiquidAddress + } + return "" +} + +func (m *DER) GetMetadataJson() string { + if m != nil { + return m.MetadataJson + } + return "" +} + +func init() { + proto.RegisterType((*DER)(nil), "planetmintgo.der.DER") +} + +func init() { proto.RegisterFile("planetmintgo/der/der.proto", fileDescriptor_6380e8122e200808) } + +var fileDescriptor_6380e8122e200808 = []byte{ + // 208 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0xc8, 0x49, 0xcc, + 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0x2d, 0x02, 0x61, 0xbd, 0x82, + 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x01, 0x64, 0x39, 0xbd, 0x94, 0xd4, 0x22, 0xa5, 0x7e, 0x46, 0x2e, + 0x66, 0x17, 0xd7, 0x20, 0x21, 0x29, 0x2e, 0x8e, 0xaa, 0xcc, 0xf4, 0xa4, 0xd4, 0x54, 0x4f, 0x17, + 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x38, 0x5f, 0x48, 0x89, 0x8b, 0xa7, 0x20, 0x27, 0x37, + 0xaf, 0xc4, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, 0x82, 0x09, 0x2c, 0x8f, 0x22, 0x26, 0xa4, + 0xc2, 0xc5, 0x9b, 0x93, 0x59, 0x58, 0x9a, 0x99, 0x02, 0x53, 0xc4, 0x0c, 0x56, 0x84, 0x2a, 0x08, + 0x32, 0x29, 0x37, 0xb5, 0x24, 0x31, 0x25, 0xb1, 0x24, 0xd1, 0xab, 0x38, 0x3f, 0x4f, 0x82, 0x05, + 0x62, 0x12, 0xb2, 0x98, 0x93, 0xe7, 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, + 0xe9, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0x3c, 0x82, 0xc4, + 0xd4, 0x4d, 0xcf, 0xd7, 0xaf, 0x00, 0x7b, 0xb9, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, + 0x6b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x13, 0x8b, 0x8b, 0x13, 0x01, 0x00, 0x00, +} + +func (m *DER) 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 *DER) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DER) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MetadataJson) > 0 { + i -= len(m.MetadataJson) + copy(dAtA[i:], m.MetadataJson) + i = encodeVarintDer(dAtA, i, uint64(len(m.MetadataJson))) + i-- + dAtA[i] = 0x22 + } + if len(m.LiquidAddress) > 0 { + i -= len(m.LiquidAddress) + copy(dAtA[i:], m.LiquidAddress) + i = encodeVarintDer(dAtA, i, uint64(len(m.LiquidAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.PlmntAddress) > 0 { + i -= len(m.PlmntAddress) + copy(dAtA[i:], m.PlmntAddress) + i = encodeVarintDer(dAtA, i, uint64(len(m.PlmntAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.ZigbeeID) > 0 { + i -= len(m.ZigbeeID) + copy(dAtA[i:], m.ZigbeeID) + i = encodeVarintDer(dAtA, i, uint64(len(m.ZigbeeID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDer(dAtA []byte, offset int, v uint64) int { + offset -= sovDer(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DER) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ZigbeeID) + if l > 0 { + n += 1 + l + sovDer(uint64(l)) + } + l = len(m.PlmntAddress) + if l > 0 { + n += 1 + l + sovDer(uint64(l)) + } + l = len(m.LiquidAddress) + if l > 0 { + n += 1 + l + sovDer(uint64(l)) + } + l = len(m.MetadataJson) + if l > 0 { + n += 1 + l + sovDer(uint64(l)) + } + return n +} + +func sovDer(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDer(x uint64) (n int) { + return sovDer(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DER) 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 ErrIntOverflowDer + } + 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: DER: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DER: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ZigbeeID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDer + } + 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 ErrInvalidLengthDer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ZigbeeID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlmntAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDer + } + 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 ErrInvalidLengthDer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PlmntAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDer + } + 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 ErrInvalidLengthDer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MetadataJson", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDer + } + 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 ErrInvalidLengthDer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MetadataJson = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDer(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDer + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDer(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, ErrIntOverflowDer + } + 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, ErrIntOverflowDer + } + 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, ErrIntOverflowDer + } + 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, ErrInvalidLengthDer + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDer + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDer + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDer = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDer = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDer = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/der/types/errors.go b/x/der/types/errors.go new file mode 100644 index 0000000..aa39a1f --- /dev/null +++ b/x/der/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/der module sentinel errors +var ( + ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") +) diff --git a/x/der/types/expected_keepers.go b/x/der/types/expected_keepers.go new file mode 100644 index 0000000..0ad7b6c --- /dev/null +++ b/x/der/types/expected_keepers.go @@ -0,0 +1,25 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + machineTypes "github.com/planetmint/planetmint-go/x/machine/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} + +// MachineKeeper defines the expected interface for the machine keeper +// to allow DER module to access machine parameters. +type MachineKeeper interface { + GetParams(ctx sdk.Context) machineTypes.Params +} diff --git a/x/der/types/genesis.go b/x/der/types/genesis.go new file mode 100644 index 0000000..0af9b44 --- /dev/null +++ b/x/der/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/der/types/genesis.pb.go b/x/der/types/genesis.pb.go new file mode 100644 index 0000000..ac28dff --- /dev/null +++ b/x/der/types/genesis.pb.go @@ -0,0 +1,320 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/der/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// GenesisState defines the der module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_2ef77739ae0a7b3c, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "planetmintgo.der.GenesisState") +} + +func init() { proto.RegisterFile("planetmintgo/der/genesis.proto", fileDescriptor_2ef77739ae0a7b3c) } + +var fileDescriptor_2ef77739ae0a7b3c = []byte{ + // 192 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0xc8, 0x49, 0xcc, + 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, + 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x96, 0xd7, 0x4b, + 0x49, 0x2d, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xea, 0x83, 0x58, 0x10, 0x75, 0x52, + 0xb2, 0x18, 0xe6, 0x14, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x8d, 0x51, 0x72, 0xe3, 0xe2, 0x71, 0x87, + 0x98, 0x1b, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc6, 0xc5, 0x06, 0x91, 0x97, 0x60, 0x54, 0x60, + 0xd4, 0xe0, 0x36, 0x92, 0xd0, 0x43, 0xb7, 0x47, 0x2f, 0x00, 0x2c, 0xef, 0xc4, 0x72, 0xe2, 0x9e, + 0x3c, 0x43, 0x10, 0x54, 0xb5, 0x93, 0xe7, 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, 0xe9, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0xcc, 0x42, + 0x62, 0xea, 0xa6, 0xe7, 0xeb, 0x57, 0x80, 0x5d, 0x56, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0x76, 0x99, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x89, 0xba, 0x49, 0x69, 0x02, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/der/types/genesis_test.go b/x/der/types/genesis_test.go new file mode 100644 index 0000000..0603fd9 --- /dev/null +++ b/x/der/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/planetmint/planetmint-go/x/der/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/der/types/keys.go b/x/der/types/keys.go new file mode 100644 index 0000000..a172ad8 --- /dev/null +++ b/x/der/types/keys.go @@ -0,0 +1,23 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "der" + + // 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_der" + + DerAssetKey = "Der/DerAsset/" + + LiquidDerAssetKey = "Der/LiquidDerAsset/" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/der/types/liquid_der_asset.pb.go b/x/der/types/liquid_der_asset.pb.go new file mode 100644 index 0000000..93c32ed --- /dev/null +++ b/x/der/types/liquid_der_asset.pb.go @@ -0,0 +1,421 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/der/liquid_der_asset.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/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 LiquidDerAsset struct { + ZigbeeID string `protobuf:"bytes,1,opt,name=zigbeeID,proto3" json:"zigbeeID,omitempty"` + PlmntAddress string `protobuf:"bytes,2,opt,name=plmntAddress,proto3" json:"plmntAddress,omitempty"` + AssetID string `protobuf:"bytes,3,opt,name=assetID,proto3" json:"assetID,omitempty"` +} + +func (m *LiquidDerAsset) Reset() { *m = LiquidDerAsset{} } +func (m *LiquidDerAsset) String() string { return proto.CompactTextString(m) } +func (*LiquidDerAsset) ProtoMessage() {} +func (*LiquidDerAsset) Descriptor() ([]byte, []int) { + return fileDescriptor_b84c7757e05c3246, []int{0} +} +func (m *LiquidDerAsset) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidDerAsset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidDerAsset.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 *LiquidDerAsset) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidDerAsset.Merge(m, src) +} +func (m *LiquidDerAsset) XXX_Size() int { + return m.Size() +} +func (m *LiquidDerAsset) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidDerAsset.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidDerAsset proto.InternalMessageInfo + +func (m *LiquidDerAsset) GetZigbeeID() string { + if m != nil { + return m.ZigbeeID + } + return "" +} + +func (m *LiquidDerAsset) GetPlmntAddress() string { + if m != nil { + return m.PlmntAddress + } + return "" +} + +func (m *LiquidDerAsset) GetAssetID() string { + if m != nil { + return m.AssetID + } + return "" +} + +func init() { + proto.RegisterType((*LiquidDerAsset)(nil), "planetmintgo.der.LiquidDerAsset") +} + +func init() { + proto.RegisterFile("planetmintgo/der/liquid_der_asset.proto", fileDescriptor_b84c7757e05c3246) +} + +var fileDescriptor_b84c7757e05c3246 = []byte{ + // 205 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2f, 0xc8, 0x49, 0xcc, + 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0x2d, 0xd2, 0xcf, 0xc9, 0x2c, + 0x2c, 0xcd, 0x4c, 0x89, 0x4f, 0x49, 0x2d, 0x8a, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0xd1, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x56, 0xa8, 0x97, 0x92, 0x5a, 0xa4, 0x94, 0xc5, 0xc5, 0xe7, + 0x03, 0x56, 0xeb, 0x92, 0x5a, 0xe4, 0x08, 0x52, 0x29, 0x24, 0xc5, 0xc5, 0x51, 0x95, 0x99, 0x9e, + 0x94, 0x9a, 0xea, 0xe9, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe7, 0x0b, 0x29, 0x71, + 0xf1, 0x14, 0xe4, 0xe4, 0xe6, 0x95, 0x38, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x81, + 0xe5, 0x51, 0xc4, 0x84, 0x24, 0xb8, 0xd8, 0xc1, 0x56, 0x7a, 0xba, 0x48, 0x30, 0x83, 0xa5, 0x61, + 0x5c, 0x27, 0xcf, 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, 0xd2, 0x4f, 0xcf, + 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x38, 0x11, 0x89, 0xa9, 0x9b, 0x9e, + 0xaf, 0x5f, 0x01, 0xf6, 0x59, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x3f, 0xc6, 0x80, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xca, 0x6d, 0xe3, 0xc1, 0xfa, 0x00, 0x00, 0x00, +} + +func (m *LiquidDerAsset) 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 *LiquidDerAsset) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidDerAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintLiquidDerAsset(dAtA, i, uint64(len(m.AssetID))) + i-- + dAtA[i] = 0x1a + } + if len(m.PlmntAddress) > 0 { + i -= len(m.PlmntAddress) + copy(dAtA[i:], m.PlmntAddress) + i = encodeVarintLiquidDerAsset(dAtA, i, uint64(len(m.PlmntAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.ZigbeeID) > 0 { + i -= len(m.ZigbeeID) + copy(dAtA[i:], m.ZigbeeID) + i = encodeVarintLiquidDerAsset(dAtA, i, uint64(len(m.ZigbeeID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintLiquidDerAsset(dAtA []byte, offset int, v uint64) int { + offset -= sovLiquidDerAsset(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *LiquidDerAsset) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ZigbeeID) + if l > 0 { + n += 1 + l + sovLiquidDerAsset(uint64(l)) + } + l = len(m.PlmntAddress) + if l > 0 { + n += 1 + l + sovLiquidDerAsset(uint64(l)) + } + l = len(m.AssetID) + if l > 0 { + n += 1 + l + sovLiquidDerAsset(uint64(l)) + } + return n +} + +func sovLiquidDerAsset(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLiquidDerAsset(x uint64) (n int) { + return sovLiquidDerAsset(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *LiquidDerAsset) 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 ErrIntOverflowLiquidDerAsset + } + 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: LiquidDerAsset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidDerAsset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ZigbeeID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidDerAsset + } + 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 ErrInvalidLengthLiquidDerAsset + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidDerAsset + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ZigbeeID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlmntAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidDerAsset + } + 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 ErrInvalidLengthLiquidDerAsset + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidDerAsset + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PlmntAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidDerAsset + } + 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 ErrInvalidLengthLiquidDerAsset + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidDerAsset + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidDerAsset(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidDerAsset + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLiquidDerAsset(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, ErrIntOverflowLiquidDerAsset + } + 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, ErrIntOverflowLiquidDerAsset + } + 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, ErrIntOverflowLiquidDerAsset + } + 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, ErrInvalidLengthLiquidDerAsset + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLiquidDerAsset + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLiquidDerAsset + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLiquidDerAsset = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLiquidDerAsset = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLiquidDerAsset = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/der/types/message_notarize_liquid_der_asset.go b/x/der/types/message_notarize_liquid_der_asset.go new file mode 100644 index 0000000..30bc45f --- /dev/null +++ b/x/der/types/message_notarize_liquid_der_asset.go @@ -0,0 +1,47 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgNotarizeLiquidDerAsset = "notarize_liquid_der_asset" + +var _ sdk.Msg = &MsgNotarizeLiquidDerAsset{} + +func NewMsgNotarizeLiquidDerAsset(creator string, derAsset *LiquidDerAsset) *MsgNotarizeLiquidDerAsset { + return &MsgNotarizeLiquidDerAsset{ + Creator: creator, + DerAsset: derAsset, + } +} + +func (msg *MsgNotarizeLiquidDerAsset) Route() string { + return RouterKey +} + +func (msg *MsgNotarizeLiquidDerAsset) Type() string { + return TypeMsgNotarizeLiquidDerAsset +} + +func (msg *MsgNotarizeLiquidDerAsset) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgNotarizeLiquidDerAsset) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgNotarizeLiquidDerAsset) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/der/types/message_notarize_liquid_der_asset_test.go b/x/der/types/message_notarize_liquid_der_asset_test.go new file mode 100644 index 0000000..49fc777 --- /dev/null +++ b/x/der/types/message_notarize_liquid_der_asset_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgNotarizeLiquidDerAsset_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgNotarizeLiquidDerAsset + err error + }{ + { + name: "invalid address", + msg: MsgNotarizeLiquidDerAsset{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgNotarizeLiquidDerAsset{ + Creator: 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/der/types/message_register_der.go b/x/der/types/message_register_der.go new file mode 100644 index 0000000..bedbdf8 --- /dev/null +++ b/x/der/types/message_register_der.go @@ -0,0 +1,47 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgRegisterDER = "register_der" + +var _ sdk.Msg = &MsgRegisterDER{} + +func NewMsgRegisterDER(creator string, der *DER) *MsgRegisterDER { + return &MsgRegisterDER{ + Creator: creator, + Der: der, + } +} + +func (msg *MsgRegisterDER) Route() string { + return RouterKey +} + +func (msg *MsgRegisterDER) Type() string { + return TypeMsgRegisterDER +} + +func (msg *MsgRegisterDER) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgRegisterDER) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRegisterDER) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/der/types/message_register_der_test.go b/x/der/types/message_register_der_test.go new file mode 100644 index 0000000..f91948a --- /dev/null +++ b/x/der/types/message_register_der_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgRegisterDER_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgRegisterDER + err error + }{ + { + name: "invalid address", + msg: MsgRegisterDER{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgRegisterDER{ + Creator: 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/der/types/params.go b/x/der/types/params.go new file mode 100644 index 0000000..357196a --- /dev/null +++ b/x/der/types/params.go @@ -0,0 +1,39 @@ +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/der/types/params.pb.go b/x/der/types/params.pb.go new file mode 100644 index 0000000..5675193 --- /dev/null +++ b/x/der/types/params.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/der/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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_a7ccb6615359025e, []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), "planetmintgo.der.Params") +} + +func init() { proto.RegisterFile("planetmintgo/der/params.proto", fileDescriptor_a7ccb6615359025e) } + +var fileDescriptor_a7ccb6615359025e = []byte{ + // 151 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0x49, 0xcc, + 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0x2d, 0xd2, 0x2f, 0x48, 0x2c, + 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x96, 0xd6, 0x4b, 0x49, + 0x2d, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xea, 0x83, 0x58, 0x10, 0x75, 0x4a, 0x7c, + 0x5c, 0x6c, 0x01, 0x60, 0x7d, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 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, 0x3e, 0xc2, 0x70, 0x24, 0xa6, 0x6e, 0x7a, 0xbe, 0x7e, 0x05, 0xd8, 0x25, 0x25, + 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x1b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x35, + 0x07, 0x60, 0xa1, 0xaa, 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/der/types/query.pb.go b/x/der/types/query.pb.go new file mode 100644 index 0000000..c0d3cae --- /dev/null +++ b/x/der/types/query.pb.go @@ -0,0 +1,1323 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/der/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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_44ad24dfc974d8be, []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_44ad24dfc974d8be, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type QueryDerRequest struct { + ZigbeeID string `protobuf:"bytes,1,opt,name=zigbeeID,proto3" json:"zigbeeID,omitempty"` +} + +func (m *QueryDerRequest) Reset() { *m = QueryDerRequest{} } +func (m *QueryDerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDerRequest) ProtoMessage() {} +func (*QueryDerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_44ad24dfc974d8be, []int{2} +} +func (m *QueryDerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDerRequest.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 *QueryDerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDerRequest.Merge(m, src) +} +func (m *QueryDerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDerRequest proto.InternalMessageInfo + +func (m *QueryDerRequest) GetZigbeeID() string { + if m != nil { + return m.ZigbeeID + } + return "" +} + +type QueryDerResponse struct { + Der *DER `protobuf:"bytes,1,opt,name=der,proto3" json:"der,omitempty"` +} + +func (m *QueryDerResponse) Reset() { *m = QueryDerResponse{} } +func (m *QueryDerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDerResponse) ProtoMessage() {} +func (*QueryDerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_44ad24dfc974d8be, []int{3} +} +func (m *QueryDerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDerResponse.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 *QueryDerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDerResponse.Merge(m, src) +} +func (m *QueryDerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDerResponse proto.InternalMessageInfo + +func (m *QueryDerResponse) GetDer() *DER { + if m != nil { + return m.Der + } + return nil +} + +type QueryNftRequest struct { + ZigbeeID string `protobuf:"bytes,1,opt,name=zigbeeID,proto3" json:"zigbeeID,omitempty"` +} + +func (m *QueryNftRequest) Reset() { *m = QueryNftRequest{} } +func (m *QueryNftRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNftRequest) ProtoMessage() {} +func (*QueryNftRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_44ad24dfc974d8be, []int{4} +} +func (m *QueryNftRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNftRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNftRequest.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 *QueryNftRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNftRequest.Merge(m, src) +} +func (m *QueryNftRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNftRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNftRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNftRequest proto.InternalMessageInfo + +func (m *QueryNftRequest) GetZigbeeID() string { + if m != nil { + return m.ZigbeeID + } + return "" +} + +type QueryNftResponse struct { + DerNft *LiquidDerAsset `protobuf:"bytes,1,opt,name=derNft,proto3" json:"derNft,omitempty"` +} + +func (m *QueryNftResponse) Reset() { *m = QueryNftResponse{} } +func (m *QueryNftResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNftResponse) ProtoMessage() {} +func (*QueryNftResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_44ad24dfc974d8be, []int{5} +} +func (m *QueryNftResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNftResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNftResponse.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 *QueryNftResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNftResponse.Merge(m, src) +} +func (m *QueryNftResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNftResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNftResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNftResponse proto.InternalMessageInfo + +func (m *QueryNftResponse) GetDerNft() *LiquidDerAsset { + if m != nil { + return m.DerNft + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "planetmintgo.der.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "planetmintgo.der.QueryParamsResponse") + proto.RegisterType((*QueryDerRequest)(nil), "planetmintgo.der.QueryDerRequest") + proto.RegisterType((*QueryDerResponse)(nil), "planetmintgo.der.QueryDerResponse") + proto.RegisterType((*QueryNftRequest)(nil), "planetmintgo.der.QueryNftRequest") + proto.RegisterType((*QueryNftResponse)(nil), "planetmintgo.der.QueryNftResponse") +} + +func init() { proto.RegisterFile("planetmintgo/der/query.proto", fileDescriptor_44ad24dfc974d8be) } + +var fileDescriptor_44ad24dfc974d8be = []byte{ + // 469 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6b, 0xd4, 0x40, + 0x1c, 0xc5, 0x37, 0xad, 0x2e, 0x3a, 0x1e, 0x2c, 0x63, 0x95, 0x25, 0xd4, 0x71, 0x0d, 0x6a, 0x45, + 0x68, 0x86, 0x56, 0x10, 0xc1, 0x93, 0x25, 0x1e, 0x0a, 0x75, 0xd1, 0x1c, 0xbd, 0x94, 0x49, 0xf3, + 0xdf, 0x71, 0x60, 0x77, 0x26, 0x3b, 0x33, 0x11, 0xab, 0x78, 0xf1, 0x13, 0x08, 0x7e, 0xa9, 0x1e, + 0x0b, 0x5e, 0x3c, 0x89, 0xec, 0x7a, 0xf2, 0x53, 0x48, 0x26, 0xd3, 0x26, 0x36, 0xac, 0xf6, 0x10, + 0x98, 0xe4, 0xbd, 0x79, 0xbf, 0x3f, 0x6f, 0x32, 0x68, 0xa3, 0x98, 0x30, 0x09, 0x76, 0x2a, 0xa4, + 0xe5, 0x8a, 0xe6, 0xa0, 0xe9, 0xac, 0x04, 0x7d, 0x14, 0x17, 0x5a, 0x59, 0x85, 0xd7, 0xda, 0x6a, + 0x9c, 0x83, 0x0e, 0xd7, 0xb9, 0xe2, 0xca, 0x89, 0xb4, 0x5a, 0xd5, 0xbe, 0x70, 0x83, 0x2b, 0xc5, + 0x27, 0x40, 0x59, 0x21, 0x28, 0x93, 0x52, 0x59, 0x66, 0x85, 0x92, 0xc6, 0xab, 0x8f, 0x0e, 0x95, + 0x99, 0x2a, 0x43, 0x33, 0x66, 0xa0, 0x8e, 0xa7, 0xef, 0xb6, 0x33, 0xb0, 0x6c, 0x9b, 0x16, 0x8c, + 0x0b, 0xe9, 0xcc, 0xde, 0x7b, 0xbb, 0x33, 0x4f, 0xc1, 0x34, 0x9b, 0x9e, 0x46, 0x85, 0x1d, 0x39, + 0x07, 0xed, 0xb5, 0xcd, 0x8e, 0x36, 0x11, 0xb3, 0x52, 0xe4, 0x07, 0x39, 0xe8, 0x03, 0x66, 0x0c, + 0xd8, 0xda, 0x18, 0xad, 0x23, 0xfc, 0xba, 0x9a, 0xe2, 0x95, 0x4b, 0x4e, 0x61, 0x56, 0x82, 0xb1, + 0xd1, 0x4b, 0x74, 0xe3, 0xaf, 0xaf, 0xa6, 0x50, 0xd2, 0x00, 0x7e, 0x82, 0xfa, 0xf5, 0x04, 0x83, + 0x60, 0x18, 0x3c, 0xbc, 0xb6, 0x33, 0x88, 0xcf, 0x77, 0x12, 0xd7, 0x3b, 0x76, 0x2f, 0x1d, 0xff, + 0xb8, 0xd3, 0x4b, 0xbd, 0x3b, 0xda, 0x42, 0xd7, 0x5d, 0x5c, 0x02, 0xda, 0x13, 0x70, 0x88, 0xae, + 0x7c, 0x10, 0x3c, 0x03, 0xd8, 0x4b, 0x5c, 0xd8, 0xd5, 0xf4, 0xec, 0x3d, 0x7a, 0x86, 0xd6, 0x1a, + 0xbb, 0x47, 0x6f, 0xa2, 0xd5, 0x1c, 0xb4, 0xe7, 0xde, 0xec, 0x72, 0x93, 0x17, 0x69, 0x5a, 0x39, + 0xce, 0x58, 0xa3, 0xb1, 0xbd, 0x08, 0x6b, 0xdf, 0xb3, 0x9c, 0xdd, 0xb3, 0x9e, 0xa2, 0x7e, 0x0e, + 0x7a, 0x34, 0xb6, 0x1e, 0x37, 0xec, 0xe2, 0xf6, 0x5d, 0x9b, 0x09, 0xe8, 0xe7, 0x55, 0x97, 0xa9, + 0xf7, 0xef, 0xfc, 0x5e, 0x41, 0x97, 0x5d, 0x1c, 0x2e, 0x51, 0xbf, 0xae, 0x02, 0xdf, 0xeb, 0xee, + 0xee, 0x36, 0x1e, 0xde, 0xff, 0x8f, 0xab, 0x1e, 0x2d, 0x22, 0x9f, 0xbf, 0xfd, 0xfa, 0xba, 0x32, + 0xc0, 0xb7, 0x68, 0x63, 0x6f, 0xfd, 0x19, 0xd8, 0xa2, 0xd5, 0x04, 0x34, 0xbe, 0xbb, 0x24, 0xad, + 0x39, 0x80, 0x30, 0xfa, 0x97, 0xc5, 0xd3, 0x1e, 0x38, 0xda, 0x10, 0x93, 0xf3, 0xb4, 0xea, 0xf9, + 0x78, 0xda, 0xe1, 0xa7, 0x8a, 0x3a, 0x1a, 0xdb, 0xa5, 0xd4, 0xe6, 0x28, 0x96, 0x52, 0x5b, 0xf5, + 0x2f, 0xa7, 0xca, 0xb1, 0x6d, 0x51, 0x77, 0xf7, 0x8e, 0xe7, 0x24, 0x38, 0x99, 0x93, 0xe0, 0xe7, + 0x9c, 0x04, 0x5f, 0x16, 0xa4, 0x77, 0xb2, 0x20, 0xbd, 0xef, 0x0b, 0xd2, 0x7b, 0x43, 0xb9, 0xb0, + 0x6f, 0xcb, 0x2c, 0x3e, 0x54, 0xd3, 0x76, 0x46, 0xb3, 0xdc, 0xe2, 0x8a, 0xbe, 0x77, 0x99, 0xf6, + 0xa8, 0x00, 0x93, 0xf5, 0xdd, 0x65, 0x78, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x3b, 0xea, + 0x59, 0x02, 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 Der items. + Der(ctx context.Context, in *QueryDerRequest, opts ...grpc.CallOption) (*QueryDerResponse, error) + // Queries a list of Nft items. + Nft(ctx context.Context, in *QueryNftRequest, opts ...grpc.CallOption) (*QueryNftResponse, 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, "/planetmintgo.der.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Der(ctx context.Context, in *QueryDerRequest, opts ...grpc.CallOption) (*QueryDerResponse, error) { + out := new(QueryDerResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.der.Query/Der", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Nft(ctx context.Context, in *QueryNftRequest, opts ...grpc.CallOption) (*QueryNftResponse, error) { + out := new(QueryNftResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.der.Query/Nft", 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 Der items. + Der(context.Context, *QueryDerRequest) (*QueryDerResponse, error) + // Queries a list of Nft items. + Nft(context.Context, *QueryNftRequest) (*QueryNftResponse, 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) Der(ctx context.Context, req *QueryDerRequest) (*QueryDerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Der not implemented") +} +func (*UnimplementedQueryServer) Nft(ctx context.Context, req *QueryNftRequest) (*QueryNftResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Nft 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: "/planetmintgo.der.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_Der_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Der(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.der.Query/Der", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Der(ctx, req.(*QueryDerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Nft_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNftRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Nft(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.der.Query/Nft", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Nft(ctx, req.(*QueryNftRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var Query_serviceDesc = _Query_serviceDesc +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "planetmintgo.der.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Der", + Handler: _Query_Der_Handler, + }, + { + MethodName: "Nft", + Handler: _Query_Nft_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "planetmintgo/der/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 *QueryDerRequest) 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 *QueryDerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ZigbeeID) > 0 { + i -= len(m.ZigbeeID) + copy(dAtA[i:], m.ZigbeeID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ZigbeeID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDerResponse) 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 *QueryDerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Der != nil { + { + size, err := m.Der.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 *QueryNftRequest) 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 *QueryNftRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNftRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ZigbeeID) > 0 { + i -= len(m.ZigbeeID) + copy(dAtA[i:], m.ZigbeeID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ZigbeeID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNftResponse) 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 *QueryNftResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNftResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DerNft != nil { + { + size, err := m.DerNft.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 *QueryDerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ZigbeeID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Der != nil { + l = m.Der.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNftRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ZigbeeID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNftResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DerNft != nil { + l = m.DerNft.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 *QueryDerRequest) 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: QueryDerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ZigbeeID", 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.ZigbeeID = 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 *QueryDerResponse) 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: QueryDerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Der", 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.Der == nil { + m.Der = &DER{} + } + if err := m.Der.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 *QueryNftRequest) 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: QueryNftRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNftRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ZigbeeID", 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.ZigbeeID = 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 *QueryNftResponse) 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: QueryNftResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNftResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DerNft", 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.DerNft == nil { + m.DerNft = &LiquidDerAsset{} + } + if err := m.DerNft.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/der/types/query.pb.gw.go b/x/der/types/query.pb.gw.go new file mode 100644 index 0000000..231a1d6 --- /dev/null +++ b/x/der/types/query.pb.gw.go @@ -0,0 +1,355 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: planetmintgo/der/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_Der_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["zigbeeID"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "zigbeeID") + } + + protoReq.ZigbeeID, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "zigbeeID", err) + } + + msg, err := client.Der(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Der_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["zigbeeID"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "zigbeeID") + } + + protoReq.ZigbeeID, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "zigbeeID", err) + } + + msg, err := server.Der(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Nft_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNftRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["zigbeeID"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "zigbeeID") + } + + protoReq.ZigbeeID, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "zigbeeID", err) + } + + msg, err := client.Nft(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Nft_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNftRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["zigbeeID"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "zigbeeID") + } + + protoReq.ZigbeeID, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "zigbeeID", err) + } + + msg, err := server.Nft(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_Der_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_Der_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_Der_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Nft_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_Nft_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_Nft_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_Der_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_Der_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_Der_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Nft_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_Nft_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_Nft_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{"planetmint", "der", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Der_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"planetmint", "der", "zigbeeID"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Nft_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"planetmint", "der", "nft", "zigbeeID"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Der_0 = runtime.ForwardResponseMessage + + forward_Query_Nft_0 = runtime.ForwardResponseMessage +) diff --git a/x/der/types/tx.pb.go b/x/der/types/tx.pb.go new file mode 100644 index 0000000..88b4e65 --- /dev/null +++ b/x/der/types/tx.pb.go @@ -0,0 +1,975 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/der/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 MsgRegisterDER struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Der *DER `protobuf:"bytes,2,opt,name=der,proto3" json:"der,omitempty"` +} + +func (m *MsgRegisterDER) Reset() { *m = MsgRegisterDER{} } +func (m *MsgRegisterDER) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterDER) ProtoMessage() {} +func (*MsgRegisterDER) Descriptor() ([]byte, []int) { + return fileDescriptor_15158a087cddc7bd, []int{0} +} +func (m *MsgRegisterDER) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterDER) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterDER.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 *MsgRegisterDER) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterDER.Merge(m, src) +} +func (m *MsgRegisterDER) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterDER) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterDER.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterDER proto.InternalMessageInfo + +func (m *MsgRegisterDER) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgRegisterDER) GetDer() *DER { + if m != nil { + return m.Der + } + return nil +} + +type MsgRegisterDERResponse struct { +} + +func (m *MsgRegisterDERResponse) Reset() { *m = MsgRegisterDERResponse{} } +func (m *MsgRegisterDERResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterDERResponse) ProtoMessage() {} +func (*MsgRegisterDERResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_15158a087cddc7bd, []int{1} +} +func (m *MsgRegisterDERResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterDERResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterDERResponse.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 *MsgRegisterDERResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterDERResponse.Merge(m, src) +} +func (m *MsgRegisterDERResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterDERResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterDERResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterDERResponse proto.InternalMessageInfo + +type MsgNotarizeLiquidDerAsset struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + DerAsset *LiquidDerAsset `protobuf:"bytes,2,opt,name=derAsset,proto3" json:"derAsset,omitempty"` +} + +func (m *MsgNotarizeLiquidDerAsset) Reset() { *m = MsgNotarizeLiquidDerAsset{} } +func (m *MsgNotarizeLiquidDerAsset) String() string { return proto.CompactTextString(m) } +func (*MsgNotarizeLiquidDerAsset) ProtoMessage() {} +func (*MsgNotarizeLiquidDerAsset) Descriptor() ([]byte, []int) { + return fileDescriptor_15158a087cddc7bd, []int{2} +} +func (m *MsgNotarizeLiquidDerAsset) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgNotarizeLiquidDerAsset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgNotarizeLiquidDerAsset.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 *MsgNotarizeLiquidDerAsset) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgNotarizeLiquidDerAsset.Merge(m, src) +} +func (m *MsgNotarizeLiquidDerAsset) XXX_Size() int { + return m.Size() +} +func (m *MsgNotarizeLiquidDerAsset) XXX_DiscardUnknown() { + xxx_messageInfo_MsgNotarizeLiquidDerAsset.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgNotarizeLiquidDerAsset proto.InternalMessageInfo + +func (m *MsgNotarizeLiquidDerAsset) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgNotarizeLiquidDerAsset) GetDerAsset() *LiquidDerAsset { + if m != nil { + return m.DerAsset + } + return nil +} + +type MsgNotarizeLiquidDerAssetResponse struct { +} + +func (m *MsgNotarizeLiquidDerAssetResponse) Reset() { *m = MsgNotarizeLiquidDerAssetResponse{} } +func (m *MsgNotarizeLiquidDerAssetResponse) String() string { return proto.CompactTextString(m) } +func (*MsgNotarizeLiquidDerAssetResponse) ProtoMessage() {} +func (*MsgNotarizeLiquidDerAssetResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_15158a087cddc7bd, []int{3} +} +func (m *MsgNotarizeLiquidDerAssetResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgNotarizeLiquidDerAssetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgNotarizeLiquidDerAssetResponse.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 *MsgNotarizeLiquidDerAssetResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgNotarizeLiquidDerAssetResponse.Merge(m, src) +} +func (m *MsgNotarizeLiquidDerAssetResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgNotarizeLiquidDerAssetResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgNotarizeLiquidDerAssetResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgNotarizeLiquidDerAssetResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterDER)(nil), "planetmintgo.der.MsgRegisterDER") + proto.RegisterType((*MsgRegisterDERResponse)(nil), "planetmintgo.der.MsgRegisterDERResponse") + proto.RegisterType((*MsgNotarizeLiquidDerAsset)(nil), "planetmintgo.der.MsgNotarizeLiquidDerAsset") + proto.RegisterType((*MsgNotarizeLiquidDerAssetResponse)(nil), "planetmintgo.der.MsgNotarizeLiquidDerAssetResponse") +} + +func init() { proto.RegisterFile("planetmintgo/der/tx.proto", fileDescriptor_15158a087cddc7bd) } + +var fileDescriptor_15158a087cddc7bd = []byte{ + // 325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x4b, 0xc3, 0x40, + 0x18, 0xc6, 0x7b, 0x16, 0xfc, 0x73, 0x05, 0x91, 0x80, 0x25, 0xcd, 0x70, 0xd4, 0x38, 0xb4, 0x20, + 0x26, 0xd0, 0xae, 0x2e, 0x4a, 0x3b, 0x08, 0xd6, 0xe1, 0x9c, 0x74, 0x29, 0x69, 0xef, 0xe5, 0x3c, + 0x68, 0x7b, 0xf1, 0xee, 0x0a, 0xb5, 0x9f, 0xc2, 0x8f, 0xe5, 0xd8, 0xd1, 0xc1, 0x41, 0x9a, 0x2f, + 0x22, 0x6d, 0x1a, 0x4d, 0x4c, 0xaa, 0xb8, 0x25, 0xbc, 0xbf, 0x3c, 0xbf, 0xe7, 0x0d, 0x2f, 0xae, + 0x85, 0xa3, 0x60, 0x02, 0x66, 0x2c, 0x26, 0x86, 0x4b, 0x9f, 0x81, 0xf2, 0xcd, 0xcc, 0x0b, 0x95, + 0x34, 0xd2, 0x3a, 0x4a, 0x8f, 0x3c, 0x06, 0xca, 0x71, 0x72, 0x30, 0x03, 0x15, 0xd3, 0x4e, 0x23, + 0x37, 0x1b, 0x89, 0xa7, 0xa9, 0x60, 0x7d, 0x06, 0xaa, 0x1f, 0x68, 0x0d, 0x26, 0x06, 0xdd, 0x3b, + 0x7c, 0xd8, 0xd3, 0x9c, 0x02, 0x17, 0xda, 0x80, 0xea, 0x74, 0xa9, 0x65, 0xe3, 0xbd, 0xa1, 0x82, + 0xc0, 0x48, 0x65, 0xa3, 0x3a, 0x6a, 0x1e, 0xd0, 0xe4, 0xd5, 0x6a, 0xe0, 0x32, 0x03, 0x65, 0xef, + 0xd4, 0x51, 0xb3, 0xd2, 0x3a, 0xf6, 0x7e, 0x16, 0xf2, 0x3a, 0x5d, 0x4a, 0x57, 0x84, 0x6b, 0xe3, + 0x6a, 0x36, 0x94, 0x82, 0x0e, 0xe5, 0x44, 0x83, 0xab, 0x71, 0xad, 0xa7, 0xf9, 0xad, 0x34, 0x81, + 0x12, 0x73, 0xb8, 0x59, 0x77, 0xea, 0x80, 0xba, 0x5c, 0x35, 0xfa, 0xc5, 0x7c, 0x81, 0xf7, 0xd9, + 0x86, 0xda, 0xe8, 0xeb, 0x79, 0x7d, 0x36, 0x8d, 0x7e, 0x7d, 0xe1, 0x9e, 0xe2, 0x93, 0xad, 0xd2, + 0xa4, 0x59, 0xeb, 0x1d, 0xe1, 0x72, 0x4f, 0x73, 0xeb, 0x1e, 0x57, 0xd2, 0x7f, 0xa3, 0xc0, 0x93, + 0x5d, 0xcd, 0x69, 0xfe, 0x45, 0x24, 0x0a, 0x6b, 0x8e, 0xab, 0x5b, 0x36, 0x3f, 0x2b, 0xcc, 0x28, + 0x86, 0x9d, 0xf6, 0x3f, 0xe0, 0xc4, 0x7d, 0x75, 0xfd, 0xba, 0x24, 0x68, 0xb1, 0x24, 0xe8, 0x63, + 0x49, 0xd0, 0x4b, 0x44, 0x4a, 0x8b, 0x88, 0x94, 0xde, 0x22, 0x52, 0x7a, 0xf0, 0xb9, 0x30, 0x8f, + 0xd3, 0x81, 0x37, 0x94, 0x63, 0xff, 0x3b, 0x38, 0xf5, 0x78, 0xce, 0xa5, 0x3f, 0x8b, 0x8f, 0xf1, + 0x39, 0x04, 0x3d, 0xd8, 0x5d, 0x5f, 0x4e, 0xfb, 0x33, 0x00, 0x00, 0xff, 0xff, 0x28, 0x7a, 0x49, + 0xef, 0xad, 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 + +// 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 { + RegisterDER(ctx context.Context, in *MsgRegisterDER, opts ...grpc.CallOption) (*MsgRegisterDERResponse, error) + NotarizeLiquidDerAsset(ctx context.Context, in *MsgNotarizeLiquidDerAsset, opts ...grpc.CallOption) (*MsgNotarizeLiquidDerAssetResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterDER(ctx context.Context, in *MsgRegisterDER, opts ...grpc.CallOption) (*MsgRegisterDERResponse, error) { + out := new(MsgRegisterDERResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.der.Msg/RegisterDER", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) NotarizeLiquidDerAsset(ctx context.Context, in *MsgNotarizeLiquidDerAsset, opts ...grpc.CallOption) (*MsgNotarizeLiquidDerAssetResponse, error) { + out := new(MsgNotarizeLiquidDerAssetResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.der.Msg/NotarizeLiquidDerAsset", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + RegisterDER(context.Context, *MsgRegisterDER) (*MsgRegisterDERResponse, error) + NotarizeLiquidDerAsset(context.Context, *MsgNotarizeLiquidDerAsset) (*MsgNotarizeLiquidDerAssetResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterDER(ctx context.Context, req *MsgRegisterDER) (*MsgRegisterDERResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterDER not implemented") +} +func (*UnimplementedMsgServer) NotarizeLiquidDerAsset(ctx context.Context, req *MsgNotarizeLiquidDerAsset) (*MsgNotarizeLiquidDerAssetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NotarizeLiquidDerAsset not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterDER_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterDER) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterDER(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.der.Msg/RegisterDER", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterDER(ctx, req.(*MsgRegisterDER)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_NotarizeLiquidDerAsset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgNotarizeLiquidDerAsset) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).NotarizeLiquidDerAsset(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.der.Msg/NotarizeLiquidDerAsset", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).NotarizeLiquidDerAsset(ctx, req.(*MsgNotarizeLiquidDerAsset)) + } + return interceptor(ctx, in, info, handler) +} + +var Msg_serviceDesc = _Msg_serviceDesc +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "planetmintgo.der.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterDER", + Handler: _Msg_RegisterDER_Handler, + }, + { + MethodName: "NotarizeLiquidDerAsset", + Handler: _Msg_NotarizeLiquidDerAsset_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "planetmintgo/der/tx.proto", +} + +func (m *MsgRegisterDER) 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 *MsgRegisterDER) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterDER) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Der != nil { + { + size, err := m.Der.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + 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 *MsgRegisterDERResponse) 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 *MsgRegisterDERResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterDERResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgNotarizeLiquidDerAsset) 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 *MsgNotarizeLiquidDerAsset) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgNotarizeLiquidDerAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DerAsset != nil { + { + size, err := m.DerAsset.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + 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 *MsgNotarizeLiquidDerAssetResponse) 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 *MsgNotarizeLiquidDerAssetResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgNotarizeLiquidDerAssetResponse) 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 *MsgRegisterDER) 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)) + } + if m.Der != nil { + l = m.Der.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterDERResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgNotarizeLiquidDerAsset) 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)) + } + if m.DerAsset != nil { + l = m.DerAsset.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgNotarizeLiquidDerAssetResponse) 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 *MsgRegisterDER) 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: MsgRegisterDER: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterDER: 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 Der", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Der == nil { + m.Der = &DER{} + } + if err := m.Der.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterDERResponse) 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: MsgRegisterDERResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterDERResponse: 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 *MsgNotarizeLiquidDerAsset) 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: MsgNotarizeLiquidDerAsset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgNotarizeLiquidDerAsset: 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 DerAsset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DerAsset == nil { + m.DerAsset = &LiquidDerAsset{} + } + if err := m.DerAsset.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgNotarizeLiquidDerAssetResponse) 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: MsgNotarizeLiquidDerAssetResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgNotarizeLiquidDerAssetResponse: 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/der/types/types.go b/x/der/types/types.go new file mode 100644 index 0000000..ab1254f --- /dev/null +++ b/x/der/types/types.go @@ -0,0 +1 @@ +package types