From f11f66e14f2d681ba0e9a4759063543d75037e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Thu, 5 Oct 2023 12:38:35 +0200 Subject: [PATCH 1/3] 112 direct call to issue2liquid (#121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * removed IssueResponseHandler * added asset-registration endpoint config * added methods to locally issue the asset and register it * added issue_service directory configuration * removed obsolete configuration options Signed-off-by: Jürgen Eckel --------- Signed-off-by: Jürgen Eckel --- app/app.go | 1 - config/config.go | 45 ++++---- x/machine/keeper/issue_response.go | 29 ----- x/machine/keeper/msg_server_attest_machine.go | 108 +++++++++++++++--- x/machine/types/errors.go | 5 + 5 files changed, 117 insertions(+), 71 deletions(-) delete mode 100644 x/machine/keeper/issue_response.go diff --git a/app/app.go b/app/app.go index f720489..06734de 100644 --- a/app/app.go +++ b/app/app.go @@ -550,7 +550,6 @@ func New( app.GetSubspace(machinemoduletypes.ModuleName), ) machineModule := machinemodule.NewAppModule(appCodec, app.MachineKeeper, app.AccountKeeper, app.BankKeeper) - go app.MachineKeeper.IssueResponseHandler(logger) app.AssetKeeper = *assetmodulekeeper.NewKeeper( appCodec, diff --git a/config/config.go b/config/config.go index d3c3af2..05d74d2 100644 --- a/config/config.go +++ b/config/config.go @@ -13,9 +13,8 @@ const DefaultConfigTemplate = ` ############################################################################### [planetmint] -osc-service-port = {{ .PlmntConfig.OSCServicePort }} -watchmen-endpoint = "{{ .PlmntConfig.WatchmenEndpoint }}" -watchmen-port = {{ .PlmntConfig.WatchmenPort }} + +asset-registry-endpoint = "{{ .PlmntConfig.AssetRegistryEndpoint }}" token-denom = "{{ .PlmntConfig.TokenDenom }}" stake-denom = "{{ .PlmntConfig.StakeDenom }}" fee-denom = "{{ .PlmntConfig.FeeDenom }}" @@ -23,20 +22,21 @@ config-root-dir = "{{ .PlmntConfig.ConfigRootDir }}" pop-epochs = {{ .PlmntConfig.PoPEpochs }} issuance-endpoint = "{{ .PlmntConfig.IssuanceEndpoint }}" issuance-port = {{ .PlmntConfig.IssuancePort }} +issuance-service-dir = {{ .PlmntConfig.IssuanceServiceDir }} + ` // Config defines Planetmint's top level configuration type Config struct { - OSCServicePort int `mapstructure:"osc-service-port" json:"osc-service-port"` - WatchmenEndpoint string `mapstructure:"watchmen-endpoint" json:"watchmen-endpoint"` - WatchmenPort int `mapstructure:"watchmen-port" json:"watchmen-port"` - TokenDenom string `mapstructure:"token-denom" json:"token-denom"` - StakeDenom string `mapstructure:"stake-denom" json:"stake-denom"` - FeeDenom string `mapstructure:"fee-denom" json:"fee-denom"` - ConfigRootDir string `mapstructure:"config-root-dir" json:"config-root-dir"` - PoPEpochs int `mapstructure:"pop-epochs" json:"pop-epochs"` - IssuanceEndpoint string `mapstructure:"issuance-endpoint" json:"issuance-endpoint"` - IssuancePort int `mapstructure:"issuance-port" json:"issuance-port"` + AssetRegistryEndpoint string `mapstructure:"asset-registry-endpoint " json:"asset-registry-endpoint "` + TokenDenom string `mapstructure:"token-denom" json:"token-denom"` + StakeDenom string `mapstructure:"stake-denom" json:"stake-denom"` + FeeDenom string `mapstructure:"fee-denom" json:"fee-denom"` + ConfigRootDir string `mapstructure:"config-root-dir" json:"config-root-dir"` + PoPEpochs int `mapstructure:"pop-epochs" json:"pop-epochs"` + IssuanceEndpoint string `mapstructure:"issuance-endpoint" json:"issuance-endpoint"` + IssuancePort int `mapstructure:"issuance-port" json:"issuance-port"` + IssuanceServiceDir string `mapstructure:"issuance-service-dir" json:"issuance-service-dir"` } // cosmos-sdk wide global singleton @@ -53,16 +53,15 @@ func DefaultConfig() *Config { } return &Config{ - OSCServicePort: 8766, - WatchmenEndpoint: "lab.r3c.network", - WatchmenPort: 7401, - TokenDenom: "plmnt", - StakeDenom: "plmntstake", - FeeDenom: "plmnt", - ConfigRootDir: filepath.Join(currentUser.HomeDir, ".planetmint-go"), - PoPEpochs: 24, // 24 CometBFT epochs of 5s equate 120s - IssuanceEndpoint: "lab.r3c.network", - IssuancePort: 7401, + AssetRegistryEndpoint: "https://assets.rddl.io/register_asset", + TokenDenom: "plmnt", + StakeDenom: "plmntstake", + FeeDenom: "plmnt", + ConfigRootDir: filepath.Join(currentUser.HomeDir, ".planetmint-go"), + PoPEpochs: 24, // 24 CometBFT epochs of 5s equate 120s + IssuanceEndpoint: "lab.r3c.network", + IssuancePort: 7401, + IssuanceServiceDir: "/opt/issuer_service", } } diff --git a/x/machine/keeper/issue_response.go b/x/machine/keeper/issue_response.go deleted file mode 100644 index 66a9ae8..0000000 --- a/x/machine/keeper/issue_response.go +++ /dev/null @@ -1,29 +0,0 @@ -package keeper - -import ( - config "github.com/planetmint/planetmint-go/config" - "strconv" - - "github.com/cometbft/cometbft/libs/log" - "github.com/hypebeast/go-osc/osc" -) - -func (k Keeper) IssueResponseHandler(logger log.Logger) { - conf := config.GetConfig() - addr := "0.0.0.0:" + strconv.FormatInt(int64(conf.OSCServicePort), 10) - d := osc.NewStandardDispatcher() - err := d.AddMsgHandler("/rddl/resp", func(msg *osc.Message) { - logger.Info("Issue Response: " + msg.String()) - }) - if err != nil { - logger.Error("Unable to add handler to OSC service.") - } - server := &osc.Server{ - Addr: addr, - Dispatcher: d, - } - err = server.ListenAndServe() - if err != nil { - logger.Error("Unable to start the OSC service.") - } -} diff --git a/x/machine/keeper/msg_server_attest_machine.go b/x/machine/keeper/msg_server_attest_machine.go index 1e8bdad..c066ba7 100644 --- a/x/machine/keeper/msg_server_attest_machine.go +++ b/x/machine/keeper/msg_server_attest_machine.go @@ -1,8 +1,15 @@ package keeper import ( + "bytes" "context" + "encoding/json" + "io" + "log" + "net/http" + "os/exec" "strconv" + "strings" config "github.com/planetmint/planetmint-go/config" "github.com/planetmint/planetmint-go/util" @@ -10,7 +17,6 @@ import ( "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/chaincfg" - "github.com/crgimenes/go-osc" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -72,24 +78,90 @@ func validateExtendedPublicKey(issuer string, cfg chaincfg.Params) bool { return isValidExtendedPublicKey } -func (k msgServer) issueMachineNFT(machine *types.Machine) error { +func (k msgServer) issueNFTAsset(name string, machine_address string) (asset_id string, contract string, err error) { conf := config.GetConfig() - client := osc.NewClient(conf.WatchmenEndpoint, conf.WatchmenPort) - machine_precision := strconv.FormatInt(int64(machine.Precision), 10) - machine_amount := strconv.FormatInt(int64(machine.Amount), 10) - machine_type := strconv.FormatUint(uint64(machine.GetType()), 10) - msg := osc.NewMessage("/rddl/issue") - msg.Append(machine.Name) - msg.Append(machine.Ticker) - msg.Append(machine.Domain) - msg.Append(machine_amount) - msg.Append("1") - msg.Append(machine_precision) - msg.Append(machine.Metadata.GetAdditionalDataCID()) - msg.Append(machine.GetIssuerPlanetmint()) - msg.Append(machine_type) - err := client.Send(msg) + cmdName := "poetry" + cmdArgs := []string{"run", "python", "issuer_service/issue2liquid.py", name, machine_address} - return err + // Create a new command + cmd := exec.Command(cmdName, cmdArgs...) + + // If you want to set the working directory + cmd.Dir = conf.IssuanceServiceDir + + // Capture the output + var stdout, stderr bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stderr + + // Execute the command + err = cmd.Run() + if err != nil { + log.Fatalf("cmd.Run() failed with %s\n", err) + err = errorsmod.Wrap(types.ErrMachineNFTIssuance, stderr.String()) + } + lines := strings.Split(stdout.String(), "\n") + if len(lines) == 3 { + asset_id = lines[0] + contract = lines[1] + } else { + err = errorsmod.Wrap(types.ErrMachineNFTIssuanceNoOutput, stderr.String()) + } + return asset_id, contract, err +} +func (k msgServer) registerAsset(asset_id string, contract string) error { + + conf := config.GetConfig() + + // Create your request payload + data := map[string]interface{}{ + "asset_id": asset_id, + "contract": contract, + } + + jsonData, err := json.Marshal(data) + if err != nil { + return errorsmod.Wrap(types.ErrAssetRegistryReqFailure, "Marshall "+err.Error()) + } + + req, err := http.NewRequest("POST", conf.AssetRegistryEndpoint, bytes.NewBuffer(jsonData)) + if err != nil { + return errorsmod.Wrap(types.ErrAssetRegistryReqFailure, "Request creation: "+err.Error()) + } + + // Set headers + req.Header.Set("Content-Type", "application/json") + req.Header.Set("accept", "application/json") + + // Send request + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return errorsmod.Wrap(types.ErrAssetRegistryReqSending, err.Error()) + } + defer resp.Body.Close() + + // Read response + if resp.StatusCode > 299 { + return errorsmod.Wrap(types.ErrAssetRegistryRepsonse, "Error reading response body:"+strconv.Itoa(resp.StatusCode)) + } + body, err := io.ReadAll(resp.Body) + if err != nil { + return errorsmod.Wrap(types.ErrAssetRegistryRepsonse, "Error reading response body:"+err.Error()) + } + result_obj := string(body) + if strings.Contains(result_obj, asset_id) { + return nil + } else { + return errorsmod.Wrap(types.ErrAssetRegistryRepsonse, "does not confirm asset registration") + } +} + +func (k msgServer) issueMachineNFT(machine *types.Machine) error { + asset_id, contract, err := k.issueNFTAsset(machine.Name, machine.Address) + if err != nil { + return err + } + return k.registerAsset(asset_id, contract) } diff --git a/x/machine/types/errors.go b/x/machine/types/errors.go index 08557f2..3dea164 100644 --- a/x/machine/types/errors.go +++ b/x/machine/types/errors.go @@ -17,4 +17,9 @@ var ( ErrMachineTypeUndefined = errorsmod.Register(ModuleName, 8, "the machine type has to be defined") ErrInvalidTrustAnchorKey = errorsmod.Register(ModuleName, 9, "invalid trust anchor pubkey") ErrTrustAnchorAlreadyRegistered = errorsmod.Register(ModuleName, 10, "trust anchor is already registered") + ErrMachineNFTIssuance = errorsmod.Register(ModuleName, 11, "the machine NFT could not be issued") + ErrMachineNFTIssuanceNoOutput = errorsmod.Register(ModuleName, 12, "the machine NFT issuing process derivated") + ErrAssetRegistryReqFailure = errorsmod.Register(ModuleName, 13, "request to asset registry could not be created") + ErrAssetRegistryReqSending = errorsmod.Register(ModuleName, 14, "request to asset registry could not be sent") + ErrAssetRegistryRepsonse = errorsmod.Register(ModuleName, 15, "request response issue") ) From 3fa4ab3adbace5af0b152046a17c20888365f58c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:39:14 +0200 Subject: [PATCH 2/3] Bump github.com/btcsuite/btcd from 0.23.0 to 0.23.2 (#113) Bumps [github.com/btcsuite/btcd](https://github.com/btcsuite/btcd) from 0.23.0 to 0.23.2. - [Release notes](https://github.com/btcsuite/btcd/releases) - [Changelog](https://github.com/btcsuite/btcd/blob/master/CHANGES) - [Commits](https://github.com/btcsuite/btcd/compare/v0.23.0...v0.23.2) --- updated-dependencies: - dependency-name: github.com/btcsuite/btcd dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 83d8e25..02051db 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.3.1 cosmossdk.io/errors v1.0.0 cosmossdk.io/math v1.1.2 - github.com/btcsuite/btcd v0.23.0 + github.com/btcsuite/btcd v0.23.2 github.com/btcsuite/btcd/btcutil v1.1.2 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 diff --git a/go.sum b/go.sum index c64303a..7395927 100644 --- a/go.sum +++ b/go.sum @@ -258,8 +258,9 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2 github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.0 h1:V2/ZgjfDFIygAX3ZapeigkVBoVUtOJKSwrhZdlpSvaA= github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd v0.23.2 h1:/YOgUp25sdCnP5ho6Hl3s0E438zlX+Kak7E6TgBgoT0= +github.com/btcsuite/btcd v0.23.2/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= From 7a3ccccc7a611bdbc5f067ae92da72f09db44cff Mon Sep 17 00:00:00 2001 From: Lorenz Herzberger <64837895+LaurentMontBlanc@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:38:53 +0200 Subject: [PATCH 3/3] 119 create dao msg to mint plmnt on demand (#122) * add mint address to config file * ignite scaffold type mint-request beneficiary amount liquid-tx-hash --module dao * add mintrequest stores * rename mint_request.go * add unit tests for mint request store * ignite scaffold message mint-token mint-request:MintRequest --module dao * add ante handler for mint address * add msg validation for mint request * fix staticcheck error * ignite scaffold query get-mint-requests-by-hash hash --response mint-request:MintRequest --module dao * add a query for mint request and additional validation for msg server * add mock for mint unit testing * add unit test for mint token msg server * add unit tests for query mint requests by hash * ignite scaffold query mint-requests-by-address address --response mint-requests:MintRequests --module dao * implement query mint requests by address and unit tests * add e2e test for token mint --------- Signed-off-by: Lorenz Herzberger --- app/ante/ante.go | 1 + app/ante/check_mint_address_decorator.go | 32 + app/app.go | 4 +- config/config.go | 4 +- docs/static/openapi.yml | 153 ++++ proto/planetmintgo/dao/mint_request.proto | 11 + proto/planetmintgo/dao/mint_requests.proto | 11 + proto/planetmintgo/dao/query.proto | 40 +- proto/planetmintgo/dao/tx.proto | 14 +- tests/e2e/dao/suite.go | 62 ++ testutil/keeper/dao.go | 29 +- testutil/sample/sample.go | 12 + x/dao/client/cli/query.go | 4 + .../cli/query_get_mint_requests_by_hash.go | 46 + .../cli/query_mint_requests_by_address.go | 46 + x/dao/client/cli/tx.go | 1 + x/dao/client/cli/tx_mint_token.go | 47 + x/dao/keeper/keeper.go | 26 +- x/dao/keeper/mint_request.go | 45 + x/dao/keeper/mint_request_test.go | 51 ++ x/dao/keeper/msg_server_mint_token.go | 43 + x/dao/keeper/msg_server_test.go | 35 + .../keeper/query_get_mint_requests_by_hash.go | 25 + .../query_get_mint_requests_by_hash_test.go | 46 + .../keeper/query_mint_requests_by_address.go | 25 + .../query_mint_requests_by_address_test.go | 51 ++ x/dao/module_simulation.go | 25 +- x/dao/simulation/mint_token.go | 29 + x/dao/testutil/expected_keepers_mocks.go | 155 ++++ x/dao/types/codec.go | 6 +- x/dao/types/errors.go | 6 +- x/dao/types/keys.go | 4 + x/dao/types/message_mint_token.go | 47 + x/dao/types/message_mint_token_test.go | 34 + x/dao/types/mint_request.pb.go | 405 +++++++++ x/dao/types/mint_requests.pb.go | 328 +++++++ x/dao/types/query.pb.go | 827 +++++++++++++++++- x/dao/types/query.pb.gw.go | 202 +++++ x/dao/types/tx.pb.go | 523 ++++++++++- 39 files changed, 3403 insertions(+), 52 deletions(-) create mode 100644 app/ante/check_mint_address_decorator.go create mode 100644 proto/planetmintgo/dao/mint_request.proto create mode 100644 proto/planetmintgo/dao/mint_requests.proto create mode 100644 x/dao/client/cli/query_get_mint_requests_by_hash.go create mode 100644 x/dao/client/cli/query_mint_requests_by_address.go create mode 100644 x/dao/client/cli/tx_mint_token.go create mode 100644 x/dao/keeper/mint_request.go create mode 100644 x/dao/keeper/mint_request_test.go create mode 100644 x/dao/keeper/msg_server_mint_token.go create mode 100644 x/dao/keeper/query_get_mint_requests_by_hash.go create mode 100644 x/dao/keeper/query_get_mint_requests_by_hash_test.go create mode 100644 x/dao/keeper/query_mint_requests_by_address.go create mode 100644 x/dao/keeper/query_mint_requests_by_address_test.go create mode 100644 x/dao/simulation/mint_token.go create mode 100644 x/dao/testutil/expected_keepers_mocks.go create mode 100644 x/dao/types/message_mint_token.go create mode 100644 x/dao/types/message_mint_token_test.go create mode 100644 x/dao/types/mint_request.pb.go create mode 100644 x/dao/types/mint_requests.pb.go diff --git a/app/ante/ante.go b/app/ante/ante.go index 7527424..a8d67c9 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -49,6 +49,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), NewCheckMachineDecorator(options.MachineKeeper), + NewCheckMintAddressDecorator(), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators diff --git a/app/ante/check_mint_address_decorator.go b/app/ante/check_mint_address_decorator.go new file mode 100644 index 0000000..2e2a90f --- /dev/null +++ b/app/ante/check_mint_address_decorator.go @@ -0,0 +1,32 @@ +package ante + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/config" + daotypes "github.com/planetmint/planetmint-go/x/dao/types" +) + +type CheckMintAddressDecorator struct { + MintAddress string +} + +func NewCheckMintAddressDecorator() CheckMintAddressDecorator { + return CheckMintAddressDecorator{} +} + +func (cmad CheckMintAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + for _, msg := range tx.GetMsgs() { + if sdk.MsgTypeURL(msg) == "/planetmintgo.dao.MsgMintToken" { + mintMsg, ok := msg.(*daotypes.MsgMintToken) + if ok { + cfg := config.GetConfig() + if mintMsg.Creator != cfg.MintAddress { + return ctx, errorsmod.Wrapf(daotypes.ErrInvalidMintAddress, "expected: %s; got: %s", cmad.MintAddress, mintMsg.Creator) + } + } + } + } + + return next(ctx, tx, simulate) +} diff --git a/app/app.go b/app/app.go index 06734de..23e3b77 100644 --- a/app/app.go +++ b/app/app.go @@ -315,7 +315,7 @@ func New( machinemoduletypes.StoreKey, machinemoduletypes.TAIndexKey, machinemoduletypes.IssuerPlanetmintIndexKey, machinemoduletypes.IssuerLiquidIndexKey, machinemoduletypes.TrustAnchorKey, machinemoduletypes.AddressIndexKey, assetmoduletypes.StoreKey, - daomoduletypes.StoreKey, daomoduletypes.ChallengeKey, + daomoduletypes.StoreKey, daomoduletypes.ChallengeKey, daomoduletypes.MintRequestHashKey, daomoduletypes.MintRequestAddressKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -566,6 +566,8 @@ func New( keys[daomoduletypes.StoreKey], keys[daomoduletypes.MemStoreKey], keys[daomoduletypes.ChallengeKey], + keys[daomoduletypes.MintRequestHashKey], + keys[daomoduletypes.MintRequestAddressKey], app.GetSubspace(daomoduletypes.ModuleName), app.BankKeeper, diff --git a/config/config.go b/config/config.go index 05d74d2..5c0122c 100644 --- a/config/config.go +++ b/config/config.go @@ -22,8 +22,8 @@ config-root-dir = "{{ .PlmntConfig.ConfigRootDir }}" pop-epochs = {{ .PlmntConfig.PoPEpochs }} issuance-endpoint = "{{ .PlmntConfig.IssuanceEndpoint }}" issuance-port = {{ .PlmntConfig.IssuancePort }} +mint-address = "{{ .PlmntConfig.MintAddress }}" issuance-service-dir = {{ .PlmntConfig.IssuanceServiceDir }} - ` // Config defines Planetmint's top level configuration @@ -37,6 +37,7 @@ type Config struct { IssuanceEndpoint string `mapstructure:"issuance-endpoint" json:"issuance-endpoint"` IssuancePort int `mapstructure:"issuance-port" json:"issuance-port"` IssuanceServiceDir string `mapstructure:"issuance-service-dir" json:"issuance-service-dir"` + MintAddress string `mapstructure:"mint-address" json:"mint-address"` } // cosmos-sdk wide global singleton @@ -62,6 +63,7 @@ func DefaultConfig() *Config { IssuanceEndpoint: "lab.r3c.network", IssuancePort: 7401, IssuanceServiceDir: "/opt/issuer_service", + MintAddress: "default", } } diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index a6b155f..6c4eace 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -46676,6 +46676,101 @@ paths: additionalProperties: {} tags: - Query + /planetmint/planetmint-go/dao/get_mint_requests_by_hash/{hash}: + get: + summary: Queries a list of GetMintRequestsByHash items. + operationId: PlanetmintgoDaoGetMintRequestsByHash + responses: + '200': + description: A successful response. + schema: + type: object + properties: + mintRequest: + type: object + properties: + beneficiary: + type: string + amount: + type: string + format: uint64 + liquidTxHash: + 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: hash + in: path + required: true + type: string + tags: + - Query + /planetmint/planetmint-go/dao/mint_requests_by_address/{address}: + get: + summary: Queries a list of MintRequestsByAddress items. + operationId: PlanetmintgoDaoMintRequestsByAddress + responses: + '200': + description: A successful response. + schema: + type: object + properties: + mintRequests: + type: object + properties: + mintRequest: + type: array + items: + type: object + properties: + beneficiary: + type: string + amount: + type: string + format: uint64 + liquidTxHash: + 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: address + in: path + required: true + type: string + tags: + - Query /github.com/planetmint/planetmint-go/machine/get_machine_by_public_key/{publicKey}: get: summary: Queries a list of GetMachineByPublicKey items. @@ -75694,9 +75789,67 @@ definitions: description: params holds all the parameters of this module. type: object description: QueryParamsResponse is response type for the Query/Params RPC method. + planetmintgo.dao.MintRequest: + type: object + properties: + beneficiary: + type: string + amount: + type: string + format: uint64 + liquidTxHash: + type: string + planetmintgo.dao.MintRequests: + type: object + properties: + mintRequest: + type: array + items: + type: object + properties: + beneficiary: + type: string + amount: + type: string + format: uint64 + liquidTxHash: + type: string + planetmintgo.dao.MsgMintTokenResponse: + type: object planetmintgo.dao.Params: type: object description: Params defines the parameters for the module. + planetmintgo.dao.QueryGetMintRequestsByHashResponse: + type: object + properties: + mintRequest: + type: object + properties: + beneficiary: + type: string + amount: + type: string + format: uint64 + liquidTxHash: + type: string + planetmintgo.dao.QueryMintRequestsByAddressResponse: + type: object + properties: + mintRequests: + type: object + properties: + mintRequest: + type: array + items: + type: object + properties: + beneficiary: + type: string + amount: + type: string + format: uint64 + liquidTxHash: + type: string planetmintgo.dao.QueryParamsResponse: type: object properties: diff --git a/proto/planetmintgo/dao/mint_request.proto b/proto/planetmintgo/dao/mint_request.proto new file mode 100644 index 0000000..85a53ee --- /dev/null +++ b/proto/planetmintgo/dao/mint_request.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package planetmintgo.dao; + +option go_package = "github.com/planetmint/planetmint-go/x/dao/types"; + +message MintRequest { + + string beneficiary = 1; + uint64 amount = 2; + string liquidTxHash = 3; +} diff --git a/proto/planetmintgo/dao/mint_requests.proto b/proto/planetmintgo/dao/mint_requests.proto new file mode 100644 index 0000000..7ec5d09 --- /dev/null +++ b/proto/planetmintgo/dao/mint_requests.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package planetmintgo.dao; + +import "planetmintgo/dao/mint_request.proto"; + +option go_package = "github.com/planetmint/planetmint-go/x/dao/types"; + +message MintRequests { + repeated MintRequest Requests = 1; +} \ No newline at end of file diff --git a/proto/planetmintgo/dao/query.proto b/proto/planetmintgo/dao/query.proto index f27bb69..d9a82cc 100644 --- a/proto/planetmintgo/dao/query.proto +++ b/proto/planetmintgo/dao/query.proto @@ -1,26 +1,60 @@ syntax = "proto3"; + package planetmintgo.dao; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "planetmintgo/dao/params.proto"; +import "planetmintgo/dao/mint_request.proto"; +import "planetmintgo/dao/mint_requests.proto"; option go_package = "github.com/planetmint/planetmint-go/x/dao/types"; // Query defines the gRPC querier service. service Query { + // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/github.com/planetmint/planetmint-go/dao/params"; + + } + + // Queries a list of GetMintRequestsByHash items. + rpc GetMintRequestsByHash (QueryGetMintRequestsByHashRequest) returns (QueryGetMintRequestsByHashResponse) { + option (google.api.http).get = "/planetmint/planetmint-go/dao/get_mint_requests_by_hash/{hash}"; + + } + + // Queries a list of MintRequestsByAddress items. + rpc MintRequestsByAddress (QueryMintRequestsByAddressRequest) returns (QueryMintRequestsByAddressResponse) { + option (google.api.http).get = "/planetmint/planetmint-go/dao/mint_requests_by_address/{address}"; + } } - // 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]; -} \ No newline at end of file +} + +message QueryGetMintRequestsByHashRequest { + string hash = 1; +} + +message QueryGetMintRequestsByHashResponse { + MintRequest mintRequest = 1; +} + +message QueryMintRequestsByAddressRequest { + string address = 1; +} + +message QueryMintRequestsByAddressResponse { + MintRequests mintRequests = 1; +} + diff --git a/proto/planetmintgo/dao/tx.proto b/proto/planetmintgo/dao/tx.proto index 8d411b8..dbcaf00 100644 --- a/proto/planetmintgo/dao/tx.proto +++ b/proto/planetmintgo/dao/tx.proto @@ -1,7 +1,19 @@ syntax = "proto3"; + package planetmintgo.dao; +import "planetmintgo/dao/mint_request.proto"; + option go_package = "github.com/planetmint/planetmint-go/x/dao/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg { + rpc MintToken (MsgMintToken) returns (MsgMintTokenResponse); +} +message MsgMintToken { + string creator = 1; + MintRequest mintRequest = 2; +} + +message MsgMintTokenResponse {} + diff --git a/tests/e2e/dao/suite.go b/tests/e2e/dao/suite.go index 1cc8562..b73f5d0 100644 --- a/tests/e2e/dao/suite.go +++ b/tests/e2e/dao/suite.go @@ -1,6 +1,7 @@ package dao import ( + "encoding/json" "fmt" "github.com/planetmint/planetmint-go/config" @@ -18,6 +19,8 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" + + daocli "github.com/planetmint/planetmint-go/x/dao/client/cli" ) var ( @@ -136,3 +139,62 @@ func (s *E2ETestSuite) TestDistributeCollectedFees() { assert.Contains(s.T(), out.String(), "13") s.Require().NoError(err) } + +func (s *E2ETestSuite) TestMintToken() { + conf := config.GetConfig() + val := s.network.Validators[0] + + // val.Address.String() + + mintRequest := sample.MintRequest(aliceAddr.String(), 1000, "hash") + mrJSON, err := json.Marshal(&mintRequest) + s.Require().NoError(err) + + // send mint token request from non mint address + args := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Moniker), + fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("10%s", conf.FeeDenom)), + "--yes", + string(mrJSON), + } + + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdMintToken(), args) + s.Require().NoError(err) + + txResponse, err := clitestutil.GetTxResponseFromOut(out) + s.Require().NoError(err) + s.Require().Equal(int(txResponse.Code), int(2)) + + // set mint address to val.address + conf.MintAddress = val.Address.String() + conf.SetPlanetmintConfig(conf) + + // send mint token request from mint address + args = []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Moniker), + fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("10%s", conf.FeeDenom)), + "--yes", + string(mrJSON), + } + + out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdMintToken(), args) + s.Require().NoError(err) + + txResponse, err = clitestutil.GetTxResponseFromOut(out) + s.Require().NoError(err) + s.Require().Equal(int(txResponse.Code), int(0)) + + s.Require().NoError(s.network.WaitForNextBlock()) + rawLog, err := clitestutil.GetRawLogFromTxResponse(val, txResponse) + s.Require().NoError(err) + + assert.Contains(s.T(), rawLog, "planetmintgo.dao.MsgMintToken") + + // assert that alice has actually received the minted tokens 10000 (initial supply) + 1000 (minted) = 11000 (total) + out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, bank.GetBalancesCmd(), []string{ + aliceAddr.String(), + }) + assert.Contains(s.T(), out.String(), "plmnt") + assert.Contains(s.T(), out.String(), "11000") + s.Require().NoError(err) +} diff --git a/testutil/keeper/dao.go b/testutil/keeper/dao.go index 916fa78..fde7587 100644 --- a/testutil/keeper/dao.go +++ b/testutil/keeper/dao.go @@ -12,21 +12,32 @@ import ( 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/golang/mock/gomock" + "github.com/planetmint/planetmint-go/config" + "github.com/planetmint/planetmint-go/testutil/sample" "github.com/planetmint/planetmint-go/x/dao/keeper" "github.com/planetmint/planetmint-go/x/dao/types" "github.com/stretchr/testify/require" + + daotestutil "github.com/planetmint/planetmint-go/x/dao/testutil" ) func DaoKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + cfg := config.GetConfig() + storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) challengeStoreKey := storetypes.NewMemoryStoreKey(types.ChallengeKey) + mintRequestHashStoreKey := storetypes.NewMemoryStoreKey(types.MintRequestHashKey) + mintRequestAddressStoreKey := storetypes.NewMemoryStoreKey(types.MintRequestAddressKey) db := tmdb.NewMemDB() stateStore := store.NewCommitMultiStore(db) stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) stateStore.MountStoreWithDB(challengeStoreKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(mintRequestHashStoreKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(mintRequestAddressStoreKey, storetypes.StoreTypeIAVL, db) require.NoError(t, stateStore.LoadLatestVersion()) @@ -39,18 +50,30 @@ func DaoKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { memStoreKey, "DaoParams", ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + ctrl := gomock.NewController(t) + bk := daotestutil.NewMockBankKeeper(ctrl) + + amt := sdk.NewCoins(sdk.NewCoin(cfg.TokenDenom, sdk.NewIntFromUint64(1000))) + beneficiaryAddr, _ := sdk.AccAddressFromBech32(sample.ConstBech32Addr) + + bk.EXPECT().MintCoins(ctx, types.ModuleName, amt).Return(nil).AnyTimes() + bk.EXPECT().SendCoinsFromModuleToAccount(ctx, types.ModuleName, beneficiaryAddr, amt).Return(nil).AnyTimes() + k := keeper.NewKeeper( cdc, storeKey, memStoreKey, challengeStoreKey, + mintRequestHashStoreKey, + mintRequestAddressStoreKey, paramsSubspace, - nil, + bk, nil, ) - ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - // Initialize params k.SetParams(ctx, types.DefaultParams()) diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index d97089a..5cdad5f 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/planetmint/planetmint-go/config" + daotypes "github.com/planetmint/planetmint-go/x/dao/types" machinetypes "github.com/planetmint/planetmint-go/x/machine/types" "github.com/btcsuite/btcd/btcutil/hdkeychain" @@ -34,6 +35,9 @@ const Fees = "1stake" // DefaultDerivationPath is the BIP44Prefix for PLMNT (see https://github.com/satoshilabs/slips/blob/master/slip-0044.md) const DefaultDerivationPath = "m/44'/8680'/0'/0/0" +// ConstantBech32Addr for mocks +const ConstBech32Addr = "cosmos1fkmmfvjf39hurp2ls3whtv73266jhh2n49202g" + // KeyPair returns a sample private / public keypair func KeyPair(optional ...int) (string, string) { secret := "Don't tell anybody" @@ -136,3 +140,11 @@ func TrustAnchor(pubkey string) machinetypes.TrustAnchor { Pubkey: pubkey, } } + +func MintRequest(beneficiaryAddr string, amount uint64, txhash string) daotypes.MintRequest { + return daotypes.MintRequest{ + Beneficiary: beneficiaryAddr, + Amount: amount, + LiquidTxHash: txhash, + } +} diff --git a/x/dao/client/cli/query.go b/x/dao/client/cli/query.go index d19c29d..d505972 100644 --- a/x/dao/client/cli/query.go +++ b/x/dao/client/cli/query.go @@ -22,6 +22,10 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdGetMintRequestsByHash()) + + cmd.AddCommand(CmdMintRequestsByAddress()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/dao/client/cli/query_get_mint_requests_by_hash.go b/x/dao/client/cli/query_get_mint_requests_by_hash.go new file mode 100644 index 0000000..2d90869 --- /dev/null +++ b/x/dao/client/cli/query_get_mint_requests_by_hash.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/dao/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdGetMintRequestsByHash() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-mint-requests-by-hash [hash]", + Short: "Query get-mint-requests-by-hash", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqHash := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetMintRequestsByHashRequest{ + + Hash: reqHash, + } + + res, err := queryClient.GetMintRequestsByHash(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dao/client/cli/query_mint_requests_by_address.go b/x/dao/client/cli/query_mint_requests_by_address.go new file mode 100644 index 0000000..bbc2ad6 --- /dev/null +++ b/x/dao/client/cli/query_mint_requests_by_address.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/dao/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdMintRequestsByAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint-requests-by-address [address]", + Short: "Query mint-requests-by-address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryMintRequestsByAddressRequest{ + + Address: reqAddress, + } + + res, err := queryClient.MintRequestsByAddress(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dao/client/cli/tx.go b/x/dao/client/cli/tx.go index 3b2b9ae..250cb58 100644 --- a/x/dao/client/cli/tx.go +++ b/x/dao/client/cli/tx.go @@ -25,6 +25,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdMintToken()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/dao/client/cli/tx_mint_token.go b/x/dao/client/cli/tx_mint_token.go new file mode 100644 index 0000000..27c2c43 --- /dev/null +++ b/x/dao/client/cli/tx_mint_token.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/dao/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdMintToken() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint-token [mint-request]", + Short: "Broadcast message mint-token", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argMintRequest := new(types.MintRequest) + err = json.Unmarshal([]byte(args[0]), argMintRequest) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgMintToken( + clientCtx.GetFromAddress().String(), + argMintRequest, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dao/keeper/keeper.go b/x/dao/keeper/keeper.go index e62255e..0866633 100644 --- a/x/dao/keeper/keeper.go +++ b/x/dao/keeper/keeper.go @@ -18,11 +18,13 @@ import ( type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - challengeKey storetypes.StoreKey - paramstore paramtypes.Subspace + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + challengeKey storetypes.StoreKey + mintRequestHashKey storetypes.StoreKey + mintRequestAddressKey storetypes.StoreKey + paramstore paramtypes.Subspace bankKeeper types.BankKeeper accountKeeper types.AccountKeeper @@ -34,6 +36,8 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, challengeKey storetypes.StoreKey, + mintRequestHashKey storetypes.StoreKey, + mintRequestAddressKey storetypes.StoreKey, ps paramtypes.Subspace, bankKeeper types.BankKeeper, @@ -45,11 +49,13 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - challengeKey: challengeKey, - paramstore: ps, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + challengeKey: challengeKey, + mintRequestHashKey: mintRequestHashKey, + mintRequestAddressKey: mintRequestAddressKey, + paramstore: ps, bankKeeper: bankKeeper, accountKeeper: accountKeeper, diff --git a/x/dao/keeper/mint_request.go b/x/dao/keeper/mint_request.go new file mode 100644 index 0000000..d876ca4 --- /dev/null +++ b/x/dao/keeper/mint_request.go @@ -0,0 +1,45 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func (k Keeper) StoreMintRequest(ctx sdk.Context, mintRequest types.MintRequest) { + hashStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MintRequestHashKey)) + hashAppendValue := k.cdc.MustMarshal(&mintRequest) + hashStore.Set(getMintRequestKeyBytes(mintRequest.LiquidTxHash), hashAppendValue) + + addressStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MintRequestAddressKey)) + mintRequests, _ := k.GetMintRequestsByAddress(ctx, mintRequest.Beneficiary) + mintRequests.Requests = append(mintRequests.Requests, &mintRequest) + addressAppendValue := k.cdc.MustMarshal(&mintRequests) + addressStore.Set(getMintRequestKeyBytes(mintRequest.Beneficiary), addressAppendValue) + +} + +func (k Keeper) GetMintRequestsByAddress(ctx sdk.Context, address string) (val types.MintRequests, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MintRequestAddressKey)) + mintRequests := store.Get(getMintRequestKeyBytes(address)) + if mintRequests == nil { + return val, false + } + k.cdc.MustUnmarshal(mintRequests, &val) + return val, true +} + +func (k Keeper) GetMintRequestByHash(ctx sdk.Context, hash string) (val types.MintRequest, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MintRequestHashKey)) + mintRequest := store.Get(getMintRequestKeyBytes(hash)) + if mintRequest == nil { + return val, false + } + k.cdc.MustUnmarshal(mintRequest, &val) + return val, true +} + +func getMintRequestKeyBytes(key string) []byte { + bz := []byte(key) + return bz +} diff --git a/x/dao/keeper/mint_request_test.go b/x/dao/keeper/mint_request_test.go new file mode 100644 index 0000000..c38ef84 --- /dev/null +++ b/x/dao/keeper/mint_request_test.go @@ -0,0 +1,51 @@ +package keeper_test + +import ( + "fmt" + "testing" + + keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/stretchr/testify/assert" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/keeper" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func createNMintRequests(keeper *keeper.Keeper, ctx sdk.Context, beneficiary string, n int) []types.MintRequest { + items := make([]types.MintRequest, n) + for i := range items { + items[i].Amount = uint64(i) + items[i].LiquidTxHash = fmt.Sprintf("hash%v", i) + items[i].Beneficiary = beneficiary + keeper.StoreMintRequest(ctx, items[i]) + } + return items +} + +func TestGetMintRequestByHash(t *testing.T) { + keeper, ctx := keepertest.DaoKeeper(t) + items := createNMintRequests(keeper, ctx, "beneficiary", 10) + for _, item := range items { + mintRequest, found := keeper.GetMintRequestByHash(ctx, item.LiquidTxHash) + assert.True(t, found) + assert.Equal(t, item, mintRequest) + } +} + +func TestGetMintRequestByAddress(t *testing.T) { + keeper, ctx := keepertest.DaoKeeper(t) + items := createNMintRequests(keeper, ctx, "beneficiary", 10) + mintRequests, found := keeper.GetMintRequestsByAddress(ctx, "beneficiary") + assert.True(t, found) + assert.Equal(t, items[0], *mintRequests.Requests[0]) + assert.Equal(t, items[1], *mintRequests.Requests[1]) + assert.Equal(t, items[2], *mintRequests.Requests[2]) + assert.Equal(t, items[3], *mintRequests.Requests[3]) + assert.Equal(t, items[4], *mintRequests.Requests[4]) + assert.Equal(t, items[5], *mintRequests.Requests[5]) + assert.Equal(t, items[6], *mintRequests.Requests[6]) + assert.Equal(t, items[7], *mintRequests.Requests[7]) + assert.Equal(t, items[8], *mintRequests.Requests[8]) + assert.Equal(t, items[9], *mintRequests.Requests[9]) +} diff --git a/x/dao/keeper/msg_server_mint_token.go b/x/dao/keeper/msg_server_mint_token.go new file mode 100644 index 0000000..3fd54ee --- /dev/null +++ b/x/dao/keeper/msg_server_mint_token.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/config" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func (k msgServer) MintToken(goCtx context.Context, msg *types.MsgMintToken) (*types.MsgMintTokenResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + cfg := config.GetConfig() + + _, found := k.GetMintRequestByHash(ctx, msg.GetMintRequest().GetLiquidTxHash()) + if found { + return nil, errorsmod.Wrapf(types.ErrAlreadyMinted, "liquid tx hash %s has already been minted", msg.GetMintRequest().GetLiquidTxHash()) + } + + amt := msg.GetMintRequest().GetAmount() + beneficiary := msg.GetMintRequest().GetBeneficiary() + beneficiaryAddr, err := sdk.AccAddressFromBech32(beneficiary) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidAddress, "for provided address %s", beneficiary) + } + + coin := sdk.NewCoin(cfg.TokenDenom, sdk.NewIntFromUint64(amt)) + coins := sdk.NewCoins(coin) + err = k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrMintFailed, "error while minting %v token for address %s", amt, beneficiary) + } + + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, beneficiaryAddr, coins) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrTransferFailed, "error while transferring %v token to address %s", amt, beneficiary) + } + + k.StoreMintRequest(ctx, *msg.MintRequest) + + return &types.MsgMintTokenResponse{}, nil +} diff --git a/x/dao/keeper/msg_server_test.go b/x/dao/keeper/msg_server_test.go index 0036e8e..aaeb44b 100644 --- a/x/dao/keeper/msg_server_test.go +++ b/x/dao/keeper/msg_server_test.go @@ -2,12 +2,15 @@ package keeper_test import ( "context" + "fmt" "testing" sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/sample" "github.com/planetmint/planetmint-go/x/dao/keeper" "github.com/planetmint/planetmint-go/x/dao/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -21,3 +24,35 @@ func TestMsgServer(t *testing.T) { require.NotNil(t, ms) require.NotNil(t, ctx) } + +func TestMsgServerMintToken(t *testing.T) { + minter := sample.AccAddress() + beneficiary := sample.ConstBech32Addr + mintRequest := sample.MintRequest(beneficiary, 1000, "hash") + + msg := types.NewMsgMintToken(minter, &mintRequest) + msgServer, ctx := setupMsgServer(t) + res, err := msgServer.MintToken(ctx, msg) + if assert.NoError(t, err) { + assert.Equal(t, &types.MsgMintTokenResponse{}, res) + } + + // should throw error because hash has already been used + _, err = msgServer.MintToken(ctx, msg) + if assert.Error(t, err) { + assert.EqualError(t, err, fmt.Sprintf("liquid tx hash %s has already been minted: already minted", "hash")) + } +} + +func TestMsgServerMintTokenInvalidAddress(t *testing.T) { + minter := sample.AccAddress() + beneficiary := "invalid address" + mintRequest := sample.MintRequest(beneficiary, 1000, "hash") + + msg := types.NewMsgMintToken(minter, &mintRequest) + msgServer, ctx := setupMsgServer(t) + _, err := msgServer.MintToken(ctx, msg) + if assert.Error(t, err) { + assert.EqualError(t, err, fmt.Sprintf("for provided address %s: invalid address", beneficiary)) + } +} diff --git a/x/dao/keeper/query_get_mint_requests_by_hash.go b/x/dao/keeper/query_get_mint_requests_by_hash.go new file mode 100644 index 0000000..9e1c718 --- /dev/null +++ b/x/dao/keeper/query_get_mint_requests_by_hash.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetMintRequestsByHash(goCtx context.Context, req *types.QueryGetMintRequestsByHashRequest) (*types.QueryGetMintRequestsByHashResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + mintRequest, found := k.GetMintRequestByHash(ctx, req.GetHash()) + if !found { + return nil, status.Error(codes.NotFound, "mint request not found") + } + + return &types.QueryGetMintRequestsByHashResponse{MintRequest: &mintRequest}, nil +} diff --git a/x/dao/keeper/query_get_mint_requests_by_hash_test.go b/x/dao/keeper/query_get_mint_requests_by_hash_test.go new file mode 100644 index 0000000..79ad4d0 --- /dev/null +++ b/x/dao/keeper/query_get_mint_requests_by_hash_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/x/dao/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestQueryGetMintRequestByHash(t *testing.T) { + keeper, ctx := keepertest.DaoKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + items := createNMintRequests(keeper, ctx, sample.ConstBech32Addr, 1) + + for _, tc := range []struct { + desc string + request *types.QueryGetMintRequestsByHashRequest + response *types.QueryGetMintRequestsByHashResponse + err error + }{ + { + desc: "mint request found", + request: &types.QueryGetMintRequestsByHashRequest{Hash: "hash0"}, + response: &types.QueryGetMintRequestsByHashResponse{MintRequest: &items[0]}, + }, + { + desc: "mint request not found", + request: &types.QueryGetMintRequestsByHashRequest{Hash: "invalid hash"}, + err: status.Error(codes.NotFound, "mint request not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + res, err := keeper.GetMintRequestsByHash(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.Equal(t, tc.response, res) + } + }) + } +} diff --git a/x/dao/keeper/query_mint_requests_by_address.go b/x/dao/keeper/query_mint_requests_by_address.go new file mode 100644 index 0000000..5c1b294 --- /dev/null +++ b/x/dao/keeper/query_mint_requests_by_address.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) MintRequestsByAddress(goCtx context.Context, req *types.QueryMintRequestsByAddressRequest) (*types.QueryMintRequestsByAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + mintRequests, found := k.GetMintRequestsByAddress(ctx, req.GetAddress()) + if !found { + return nil, status.Error(codes.NotFound, "mint requests not found") + } + + return &types.QueryMintRequestsByAddressResponse{MintRequests: &mintRequests}, nil +} diff --git a/x/dao/keeper/query_mint_requests_by_address_test.go b/x/dao/keeper/query_mint_requests_by_address_test.go new file mode 100644 index 0000000..1ccea6c --- /dev/null +++ b/x/dao/keeper/query_mint_requests_by_address_test.go @@ -0,0 +1,51 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/x/dao/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestQueryMintRequestByAddress(t *testing.T) { + keeper, ctx := keepertest.DaoKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + items := createNMintRequests(keeper, ctx, sample.ConstBech32Addr, 10) + + var mintRequests types.MintRequests + for i := range items { + mintRequests.Requests = append(mintRequests.Requests, &items[i]) + } + + for _, tc := range []struct { + desc string + request *types.QueryMintRequestsByAddressRequest + response *types.QueryMintRequestsByAddressResponse + err error + }{ + { + desc: "mint requests found", + request: &types.QueryMintRequestsByAddressRequest{Address: sample.ConstBech32Addr}, + response: &types.QueryMintRequestsByAddressResponse{MintRequests: &mintRequests}, + }, + { + desc: "mint requests not found", + request: &types.QueryMintRequestsByAddressRequest{Address: "invalid hash"}, + err: status.Error(codes.NotFound, "mint requests not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + res, err := keeper.MintRequestsByAddress(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.Equal(t, tc.response, res) + } + }) + } +} diff --git a/x/dao/module_simulation.go b/x/dao/module_simulation.go index ea4b046..5553a4d 100644 --- a/x/dao/module_simulation.go +++ b/x/dao/module_simulation.go @@ -24,7 +24,11 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgMintToken = "op_weight_msg_mint_token" + // TODO: Determine the simulation weight value + defaultWeightMsgMintToken int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module. @@ -52,6 +56,17 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgMintToken int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgMintToken, &weightMsgMintToken, nil, + func(_ *rand.Rand) { + weightMsgMintToken = defaultWeightMsgMintToken + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgMintToken, + daosimulation.SimulateMsgMintToken(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -60,6 +75,14 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // ProposalMsgs returns msgs used for governance proposals for simulations. func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgMintToken, + defaultWeightMsgMintToken, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + daosimulation.SimulateMsgMintToken(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/dao/simulation/mint_token.go b/x/dao/simulation/mint_token.go new file mode 100644 index 0000000..29ae9e5 --- /dev/null +++ b/x/dao/simulation/mint_token.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/dao/keeper" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func SimulateMsgMintToken( + 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.MsgMintToken{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the MintToken simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "MintToken simulation not implemented"), nil, nil + } +} diff --git a/x/dao/testutil/expected_keepers_mocks.go b/x/dao/testutil/expected_keepers_mocks.go new file mode 100644 index 0000000..ab198a4 --- /dev/null +++ b/x/dao/testutil/expected_keepers_mocks.go @@ -0,0 +1,155 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/dao/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" +) + +// MockAccountKeeper is a mock of AccountKeeper interface. +type MockAccountKeeper struct { + ctrl *gomock.Controller + recorder *MockAccountKeeperMockRecorder +} + +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. +type MockAccountKeeperMockRecorder struct { + mock *MockAccountKeeper +} + +// NewMockAccountKeeper creates a new mock instance. +func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { + mock := &MockAccountKeeper{ctrl: ctrl} + mock.recorder = &MockAccountKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { + return m.recorder +} + +// GetAccount mocks base method. +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAccount", ctx, addr) + ret0, _ := ret[0].(types0.AccountI) + return ret0 +} + +// GetAccount indicates an expected call of GetAccount. +func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr) +} + +// GetModuleAddress mocks base method. +func (m *MockAccountKeeper) GetModuleAddress(module string) types.AccAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAddress", module) + ret0, _ := ret[0].(types.AccAddress) + return ret0 +} + +// GetModuleAddress indicates an expected call of GetModuleAddress. +func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(module interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), module) +} + +// IterateAccounts mocks base method. +func (m *MockAccountKeeper) IterateAccounts(arg0 types.Context, arg1 func(types0.AccountI) bool) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IterateAccounts", arg0, arg1) +} + +// IterateAccounts indicates an expected call of IterateAccounts. +func (mr *MockAccountKeeperMockRecorder) IterateAccounts(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateAccounts", reflect.TypeOf((*MockAccountKeeper)(nil).IterateAccounts), arg0, arg1) +} + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// BlockedAddr mocks base method. +func (m *MockBankKeeper) BlockedAddr(addr types.AccAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BlockedAddr", addr) + ret0, _ := ret[0].(bool) + return ret0 +} + +// BlockedAddr indicates an expected call of BlockedAddr. +func (mr *MockBankKeeperMockRecorder) BlockedAddr(addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockedAddr", reflect.TypeOf((*MockBankKeeper)(nil).BlockedAddr), addr) +} + +// MintCoins mocks base method. +func (m *MockBankKeeper) MintCoins(ctx types.Context, moduleName string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MintCoins", ctx, moduleName, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// MintCoins indicates an expected call of MintCoins. +func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MintCoins", reflect.TypeOf((*MockBankKeeper)(nil).MintCoins), ctx, moduleName, amt) +} + +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) +} + +// SpendableCoins mocks base method. +func (m *MockBankKeeper) SpendableCoins(ctx types.Context, addr types.AccAddress) types.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) + ret0, _ := ret[0].(types.Coins) + return ret0 +} + +// SpendableCoins indicates an expected call of SpendableCoins. +func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) +} diff --git a/x/dao/types/codec.go b/x/dao/types/codec.go index 844157a..46f0e3e 100644 --- a/x/dao/types/codec.go +++ b/x/dao/types/codec.go @@ -3,15 +3,19 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgMintToken{}, "dao/MintToken", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgMintToken{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/dao/types/errors.go b/x/dao/types/errors.go index 4ebceb6..41807f4 100644 --- a/x/dao/types/errors.go +++ b/x/dao/types/errors.go @@ -8,5 +8,9 @@ import ( // x/dao module sentinel errors var ( - ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") + ErrInvalidMintAddress = errorsmod.Register(ModuleName, 2, "invalid mint address") + ErrMintFailed = errorsmod.Register(ModuleName, 3, "minting failed") + ErrTransferFailed = errorsmod.Register(ModuleName, 4, "transfer failed") + ErrInvalidAddress = errorsmod.Register(ModuleName, 5, "invalid address") + ErrAlreadyMinted = errorsmod.Register(ModuleName, 6, "already minted") ) diff --git a/x/dao/types/keys.go b/x/dao/types/keys.go index 00989dd..876d29c 100644 --- a/x/dao/types/keys.go +++ b/x/dao/types/keys.go @@ -14,6 +14,10 @@ const ( MemStoreKey = "mem_dao" ChallengeKey = "Dao/Challenge" + + MintRequestAddressKey = "Dao/MintRequestAddress" + + MintRequestHashKey = "Dao/MintRequestHash" ) func KeyPrefix(p string) []byte { diff --git a/x/dao/types/message_mint_token.go b/x/dao/types/message_mint_token.go new file mode 100644 index 0000000..27b56a0 --- /dev/null +++ b/x/dao/types/message_mint_token.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 TypeMsgMintToken = "mint_token" + +var _ sdk.Msg = &MsgMintToken{} + +func NewMsgMintToken(creator string, mintRequest *MintRequest) *MsgMintToken { + return &MsgMintToken{ + Creator: creator, + MintRequest: mintRequest, + } +} + +func (msg *MsgMintToken) Route() string { + return RouterKey +} + +func (msg *MsgMintToken) Type() string { + return TypeMsgMintToken +} + +func (msg *MsgMintToken) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgMintToken) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgMintToken) 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/dao/types/message_mint_token_test.go b/x/dao/types/message_mint_token_test.go new file mode 100644 index 0000000..58de1d4 --- /dev/null +++ b/x/dao/types/message_mint_token_test.go @@ -0,0 +1,34 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgMintToken_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgMintToken + err error + }{ + { + name: "invalid address", + msg: MsgMintToken{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + } + 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/dao/types/mint_request.pb.go b/x/dao/types/mint_request.pb.go new file mode 100644 index 0000000..1e69250 --- /dev/null +++ b/x/dao/types/mint_request.pb.go @@ -0,0 +1,405 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/dao/mint_request.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 MintRequest struct { + Beneficiary string `protobuf:"bytes,1,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` + Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` + LiquidTxHash string `protobuf:"bytes,3,opt,name=liquidTxHash,proto3" json:"liquidTxHash,omitempty"` +} + +func (m *MintRequest) Reset() { *m = MintRequest{} } +func (m *MintRequest) String() string { return proto.CompactTextString(m) } +func (*MintRequest) ProtoMessage() {} +func (*MintRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_dc5c152bf52708dc, []int{0} +} +func (m *MintRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MintRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MintRequest.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 *MintRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MintRequest.Merge(m, src) +} +func (m *MintRequest) XXX_Size() int { + return m.Size() +} +func (m *MintRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MintRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MintRequest proto.InternalMessageInfo + +func (m *MintRequest) GetBeneficiary() string { + if m != nil { + return m.Beneficiary + } + return "" +} + +func (m *MintRequest) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *MintRequest) GetLiquidTxHash() string { + if m != nil { + return m.LiquidTxHash + } + return "" +} + +func init() { + proto.RegisterType((*MintRequest)(nil), "planetmintgo.dao.MintRequest") +} + +func init() { + proto.RegisterFile("planetmintgo/dao/mint_request.proto", fileDescriptor_dc5c152bf52708dc) +} + +var fileDescriptor_dc5c152bf52708dc = []byte{ + // 205 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2e, 0xc8, 0x49, 0xcc, + 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0xcc, 0xd7, 0x07, 0x31, 0xe3, + 0x8b, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x90, + 0x15, 0xe9, 0xa5, 0x24, 0xe6, 0x2b, 0x65, 0x73, 0x71, 0xfb, 0x66, 0xe6, 0x95, 0x04, 0x41, 0x94, + 0x09, 0x29, 0x70, 0x71, 0x27, 0xa5, 0xe6, 0xa5, 0xa6, 0x65, 0x26, 0x67, 0x26, 0x16, 0x55, 0x4a, + 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x21, 0x0b, 0x09, 0x89, 0x71, 0xb1, 0x25, 0xe6, 0xe6, 0x97, + 0xe6, 0x95, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xb0, 0x04, 0x41, 0x79, 0x42, 0x4a, 0x5c, 0x3c, 0x39, + 0x99, 0x85, 0xa5, 0x99, 0x29, 0x21, 0x15, 0x1e, 0x89, 0xc5, 0x19, 0x12, 0xcc, 0x60, 0xad, 0x28, + 0x62, 0x4e, 0x9e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, + 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9f, 0x9e, + 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0x70, 0x23, 0x12, 0x53, 0x37, 0x3d, + 0x5f, 0xbf, 0x02, 0xec, 0xad, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x87, 0x8c, 0x01, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xca, 0x8a, 0xc6, 0x1d, 0xf7, 0x00, 0x00, 0x00, +} + +func (m *MintRequest) 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 *MintRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MintRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.LiquidTxHash) > 0 { + i -= len(m.LiquidTxHash) + copy(dAtA[i:], m.LiquidTxHash) + i = encodeVarintMintRequest(dAtA, i, uint64(len(m.LiquidTxHash))) + i-- + dAtA[i] = 0x1a + } + if m.Amount != 0 { + i = encodeVarintMintRequest(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Beneficiary) > 0 { + i -= len(m.Beneficiary) + copy(dAtA[i:], m.Beneficiary) + i = encodeVarintMintRequest(dAtA, i, uint64(len(m.Beneficiary))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMintRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovMintRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MintRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Beneficiary) + if l > 0 { + n += 1 + l + sovMintRequest(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovMintRequest(uint64(m.Amount)) + } + l = len(m.LiquidTxHash) + if l > 0 { + n += 1 + l + sovMintRequest(uint64(l)) + } + return n +} + +func sovMintRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMintRequest(x uint64) (n int) { + return sovMintRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MintRequest) 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 ErrIntOverflowMintRequest + } + 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: MintRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MintRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMintRequest + } + 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 ErrInvalidLengthMintRequest + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMintRequest + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beneficiary = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMintRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidTxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMintRequest + } + 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 ErrInvalidLengthMintRequest + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMintRequest + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMintRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMintRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMintRequest(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, ErrIntOverflowMintRequest + } + 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, ErrIntOverflowMintRequest + } + 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, ErrIntOverflowMintRequest + } + 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, ErrInvalidLengthMintRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMintRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMintRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMintRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMintRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMintRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/mint_requests.pb.go b/x/dao/types/mint_requests.pb.go new file mode 100644 index 0000000..816e904 --- /dev/null +++ b/x/dao/types/mint_requests.pb.go @@ -0,0 +1,328 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/dao/mint_requests.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 MintRequests struct { + Requests []*MintRequest `protobuf:"bytes,1,rep,name=Requests,proto3" json:"Requests,omitempty"` +} + +func (m *MintRequests) Reset() { *m = MintRequests{} } +func (m *MintRequests) String() string { return proto.CompactTextString(m) } +func (*MintRequests) ProtoMessage() {} +func (*MintRequests) Descriptor() ([]byte, []int) { + return fileDescriptor_d28f1f28907eeede, []int{0} +} +func (m *MintRequests) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MintRequests) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MintRequests.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 *MintRequests) XXX_Merge(src proto.Message) { + xxx_messageInfo_MintRequests.Merge(m, src) +} +func (m *MintRequests) XXX_Size() int { + return m.Size() +} +func (m *MintRequests) XXX_DiscardUnknown() { + xxx_messageInfo_MintRequests.DiscardUnknown(m) +} + +var xxx_messageInfo_MintRequests proto.InternalMessageInfo + +func (m *MintRequests) GetRequests() []*MintRequest { + if m != nil { + return m.Requests + } + return nil +} + +func init() { + proto.RegisterType((*MintRequests)(nil), "planetmintgo.dao.MintRequests") +} + +func init() { + proto.RegisterFile("planetmintgo/dao/mint_requests.proto", fileDescriptor_d28f1f28907eeede) +} + +var fileDescriptor_d28f1f28907eeede = []byte{ + // 170 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x29, 0xc8, 0x49, 0xcc, + 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0xcc, 0xd7, 0x07, 0x31, 0xe3, + 0x8b, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x8a, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, + 0x90, 0x55, 0xe9, 0xa5, 0x24, 0xe6, 0x4b, 0x29, 0xe3, 0xd5, 0x07, 0xd1, 0xa6, 0xe4, 0xc9, 0xc5, + 0xe3, 0x9b, 0x99, 0x57, 0x12, 0x04, 0x35, 0x4c, 0xc8, 0x92, 0x8b, 0x03, 0xc6, 0x96, 0x60, 0x54, + 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xd5, 0x43, 0x37, 0x59, 0x0f, 0x49, 0x47, 0x10, 0x5c, 0xb9, 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, 0x0c, 0x43, 0x62, 0xea, 0xa6, 0xe7, 0xeb, 0x57, + 0x80, 0x9d, 0x58, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x9c, 0x31, 0x20, 0x00, 0x00, + 0xff, 0xff, 0xa8, 0xa9, 0x35, 0x0f, 0xfb, 0x00, 0x00, 0x00, +} + +func (m *MintRequests) 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 *MintRequests) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MintRequests) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Requests) > 0 { + for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMintRequests(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintMintRequests(dAtA []byte, offset int, v uint64) int { + offset -= sovMintRequests(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MintRequests) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Requests) > 0 { + for _, e := range m.Requests { + l = e.Size() + n += 1 + l + sovMintRequests(uint64(l)) + } + } + return n +} + +func sovMintRequests(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMintRequests(x uint64) (n int) { + return sovMintRequests(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MintRequests) 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 ErrIntOverflowMintRequests + } + 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: MintRequests: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MintRequests: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMintRequests + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMintRequests + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMintRequests + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Requests = append(m.Requests, &MintRequest{}) + if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMintRequests(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMintRequests + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMintRequests(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, ErrIntOverflowMintRequests + } + 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, ErrIntOverflowMintRequests + } + 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, ErrIntOverflowMintRequests + } + 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, ErrInvalidLengthMintRequests + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMintRequests + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMintRequests + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMintRequests = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMintRequests = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMintRequests = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/query.pb.go b/x/dao/types/query.pb.go index 3b7670a..e0da443 100644 --- a/x/dao/types/query.pb.go +++ b/x/dao/types/query.pb.go @@ -113,34 +113,227 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +type QueryGetMintRequestsByHashRequest struct { + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *QueryGetMintRequestsByHashRequest) Reset() { *m = QueryGetMintRequestsByHashRequest{} } +func (m *QueryGetMintRequestsByHashRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetMintRequestsByHashRequest) ProtoMessage() {} +func (*QueryGetMintRequestsByHashRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_07bad0eeb5b27724, []int{2} +} +func (m *QueryGetMintRequestsByHashRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetMintRequestsByHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetMintRequestsByHashRequest.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 *QueryGetMintRequestsByHashRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetMintRequestsByHashRequest.Merge(m, src) +} +func (m *QueryGetMintRequestsByHashRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetMintRequestsByHashRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetMintRequestsByHashRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetMintRequestsByHashRequest proto.InternalMessageInfo + +func (m *QueryGetMintRequestsByHashRequest) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +type QueryGetMintRequestsByHashResponse struct { + MintRequest *MintRequest `protobuf:"bytes,1,opt,name=mintRequest,proto3" json:"mintRequest,omitempty"` +} + +func (m *QueryGetMintRequestsByHashResponse) Reset() { *m = QueryGetMintRequestsByHashResponse{} } +func (m *QueryGetMintRequestsByHashResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetMintRequestsByHashResponse) ProtoMessage() {} +func (*QueryGetMintRequestsByHashResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_07bad0eeb5b27724, []int{3} +} +func (m *QueryGetMintRequestsByHashResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetMintRequestsByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetMintRequestsByHashResponse.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 *QueryGetMintRequestsByHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetMintRequestsByHashResponse.Merge(m, src) +} +func (m *QueryGetMintRequestsByHashResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetMintRequestsByHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetMintRequestsByHashResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetMintRequestsByHashResponse proto.InternalMessageInfo + +func (m *QueryGetMintRequestsByHashResponse) GetMintRequest() *MintRequest { + if m != nil { + return m.MintRequest + } + return nil +} + +type QueryMintRequestsByAddressRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryMintRequestsByAddressRequest) Reset() { *m = QueryMintRequestsByAddressRequest{} } +func (m *QueryMintRequestsByAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryMintRequestsByAddressRequest) ProtoMessage() {} +func (*QueryMintRequestsByAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_07bad0eeb5b27724, []int{4} +} +func (m *QueryMintRequestsByAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryMintRequestsByAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMintRequestsByAddressRequest.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 *QueryMintRequestsByAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMintRequestsByAddressRequest.Merge(m, src) +} +func (m *QueryMintRequestsByAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryMintRequestsByAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMintRequestsByAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMintRequestsByAddressRequest proto.InternalMessageInfo + +func (m *QueryMintRequestsByAddressRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryMintRequestsByAddressResponse struct { + MintRequests *MintRequests `protobuf:"bytes,1,opt,name=mintRequests,proto3" json:"mintRequests,omitempty"` +} + +func (m *QueryMintRequestsByAddressResponse) Reset() { *m = QueryMintRequestsByAddressResponse{} } +func (m *QueryMintRequestsByAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryMintRequestsByAddressResponse) ProtoMessage() {} +func (*QueryMintRequestsByAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_07bad0eeb5b27724, []int{5} +} +func (m *QueryMintRequestsByAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryMintRequestsByAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMintRequestsByAddressResponse.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 *QueryMintRequestsByAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMintRequestsByAddressResponse.Merge(m, src) +} +func (m *QueryMintRequestsByAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryMintRequestsByAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMintRequestsByAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMintRequestsByAddressResponse proto.InternalMessageInfo + +func (m *QueryMintRequestsByAddressResponse) GetMintRequests() *MintRequests { + if m != nil { + return m.MintRequests + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "planetmintgo.dao.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "planetmintgo.dao.QueryParamsResponse") + proto.RegisterType((*QueryGetMintRequestsByHashRequest)(nil), "planetmintgo.dao.QueryGetMintRequestsByHashRequest") + proto.RegisterType((*QueryGetMintRequestsByHashResponse)(nil), "planetmintgo.dao.QueryGetMintRequestsByHashResponse") + proto.RegisterType((*QueryMintRequestsByAddressRequest)(nil), "planetmintgo.dao.QueryMintRequestsByAddressRequest") + proto.RegisterType((*QueryMintRequestsByAddressResponse)(nil), "planetmintgo.dao.QueryMintRequestsByAddressResponse") } func init() { proto.RegisterFile("planetmintgo/dao/query.proto", fileDescriptor_07bad0eeb5b27724) } var fileDescriptor_07bad0eeb5b27724 = []byte{ - // 301 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x31, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x2f, 0xa2, 0x1d, 0xe2, 0x22, 0xb1, 0x43, 0x29, 0x35, 0xca, 0xa1, 0x20, 0x82, 0x17, - 0xae, 0x82, 0xee, 0xdd, 0x1c, 0x04, 0xed, 0xe8, 0x96, 0x6b, 0x43, 0x3c, 0xe8, 0xe5, 0xa5, 0x97, - 0x9c, 0xd8, 0xd5, 0x0f, 0x20, 0x82, 0x8b, 0x1f, 0xa9, 0x63, 0xc1, 0xc5, 0x49, 0xe4, 0xce, 0x0f, - 0x22, 0x4d, 0x0e, 0x6c, 0xbd, 0x41, 0xb7, 0xf0, 0xde, 0xef, 0xff, 0xe3, 0x9f, 0x87, 0x7b, 0x7a, - 0xc2, 0x95, 0xb0, 0x59, 0xaa, 0xac, 0x04, 0x36, 0xe6, 0xc0, 0xa6, 0x85, 0xc8, 0x67, 0x91, 0xce, - 0xc1, 0x02, 0xd9, 0x59, 0xdd, 0x46, 0x63, 0x0e, 0xdd, 0xb6, 0x04, 0x09, 0x6e, 0xc9, 0x96, 0x2f, - 0xcf, 0x75, 0x7b, 0x12, 0x40, 0x4e, 0x04, 0xe3, 0x3a, 0x65, 0x5c, 0x29, 0xb0, 0xdc, 0xa6, 0xa0, - 0x4c, 0xbd, 0x3d, 0x19, 0x81, 0xc9, 0xc0, 0xb0, 0x84, 0x1b, 0xe1, 0xf5, 0xec, 0x3e, 0x4e, 0x84, - 0xe5, 0x31, 0xd3, 0x5c, 0xa6, 0xca, 0xc1, 0x35, 0xbb, 0xd7, 0xe8, 0xa3, 0x79, 0xce, 0xb3, 0x5a, - 0x15, 0xb6, 0x31, 0xb9, 0x59, 0x0a, 0xae, 0xdd, 0x70, 0x28, 0xa6, 0x85, 0x30, 0x36, 0xbc, 0xc2, - 0xbb, 0x6b, 0x53, 0xa3, 0x41, 0x19, 0x41, 0xce, 0x71, 0xcb, 0x87, 0x3b, 0xe8, 0x00, 0x1d, 0x6f, - 0xf7, 0x3b, 0xd1, 0xef, 0xef, 0x44, 0x3e, 0x31, 0xd8, 0x9c, 0x7f, 0xec, 0x07, 0xc3, 0x9a, 0xee, - 0xbf, 0x22, 0xbc, 0xe5, 0x7c, 0xe4, 0x09, 0xe1, 0x96, 0x47, 0xc8, 0x61, 0x33, 0xdc, 0x6c, 0xd2, - 0x3d, 0xfa, 0x83, 0xf2, 0xcd, 0xc2, 0x8b, 0xc7, 0xb7, 0xaf, 0x97, 0x8d, 0x98, 0x30, 0x26, 0x53, - 0x7b, 0x57, 0x24, 0xd1, 0x08, 0x32, 0xf6, 0x93, 0x5c, 0x79, 0x9e, 0xae, 0x5d, 0x61, 0x70, 0x39, - 0x2f, 0x29, 0x5a, 0x94, 0x14, 0x7d, 0x96, 0x14, 0x3d, 0x57, 0x34, 0x58, 0x54, 0x34, 0x78, 0xaf, - 0x68, 0x70, 0xfb, 0x2f, 0xd3, 0x83, 0x73, 0xd9, 0x99, 0x16, 0x26, 0x69, 0xb9, 0x8b, 0x9e, 0x7d, - 0x07, 0x00, 0x00, 0xff, 0xff, 0x20, 0xd5, 0xef, 0x17, 0x02, 0x02, 0x00, 0x00, + // 508 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x37, 0xb2, 0xae, 0x38, 0xf5, 0x20, 0x63, 0x0b, 0xcb, 0xd2, 0x46, 0x1d, 0x2b, 0x88, + 0x60, 0x86, 0x6d, 0xc5, 0x9e, 0xd4, 0x9a, 0x83, 0xd6, 0x43, 0x41, 0x73, 0xf4, 0xb2, 0x4c, 0xba, + 0x43, 0x12, 0x68, 0x66, 0xd2, 0xcc, 0xac, 0xb8, 0x94, 0x5e, 0xfc, 0x03, 0x44, 0xf0, 0x5f, 0xf1, + 0x8f, 0x28, 0xe2, 0xa1, 0xe0, 0xc5, 0x93, 0xc8, 0xae, 0x7f, 0x88, 0x64, 0xe6, 0x2d, 0x4d, 0x4c, + 0x77, 0xd4, 0xcb, 0xf2, 0x92, 0xf7, 0xde, 0xf7, 0x7d, 0xde, 0x8f, 0x0d, 0x5a, 0x2f, 0x0e, 0x99, + 0xe0, 0x3a, 0xcf, 0x84, 0x4e, 0x24, 0x1d, 0x33, 0x49, 0x8f, 0x26, 0xbc, 0x9c, 0x06, 0x45, 0x29, + 0xb5, 0xc4, 0xd7, 0xeb, 0xde, 0x60, 0xcc, 0xe4, 0x60, 0x35, 0x91, 0x89, 0x34, 0x4e, 0x5a, 0x59, + 0x36, 0x6e, 0xb0, 0x9e, 0x48, 0x99, 0x1c, 0x72, 0xca, 0x8a, 0x8c, 0x32, 0x21, 0xa4, 0x66, 0x3a, + 0x93, 0x42, 0x81, 0xf7, 0xfe, 0x81, 0x54, 0xb9, 0x54, 0x34, 0x66, 0x8a, 0x5b, 0x79, 0xfa, 0x76, + 0x18, 0x73, 0xcd, 0x86, 0xb4, 0x60, 0x49, 0x26, 0x4c, 0x30, 0xc4, 0x6e, 0xb4, 0x78, 0x0a, 0x56, + 0xb2, 0x7c, 0x21, 0x75, 0xa7, 0xe5, 0xae, 0xcc, 0x51, 0xc9, 0x8f, 0x26, 0x5c, 0x69, 0x08, 0xda, + 0x74, 0x06, 0x81, 0x14, 0x59, 0x45, 0xf8, 0x75, 0xc5, 0xf2, 0xca, 0xe8, 0x47, 0xd6, 0x49, 0xf6, + 0xd1, 0x8d, 0xc6, 0x5b, 0x55, 0x48, 0xa1, 0x38, 0x7e, 0x84, 0x7a, 0x96, 0xa3, 0xef, 0xdd, 0xf2, + 0xee, 0xad, 0x6c, 0xf5, 0x83, 0x3f, 0x27, 0x13, 0xd8, 0x8c, 0xb0, 0x7b, 0xfa, 0xe3, 0x66, 0x27, + 0x82, 0x68, 0xb2, 0x83, 0x6e, 0x1b, 0xb9, 0x17, 0x5c, 0xef, 0x67, 0x42, 0x43, 0x15, 0x15, 0x4e, + 0xf7, 0x98, 0x4a, 0xe1, 0x09, 0x63, 0xd4, 0x4d, 0x99, 0x4a, 0x8d, 0xf4, 0xd5, 0xc8, 0xd8, 0x84, + 0x23, 0xe2, 0x4a, 0x04, 0xac, 0xa7, 0x68, 0x25, 0x3f, 0xf7, 0x02, 0xdb, 0x46, 0x9b, 0xad, 0x26, + 0x11, 0xd5, 0x33, 0xc8, 0x63, 0xe0, 0x6b, 0xd6, 0x78, 0x36, 0x1e, 0x97, 0x5c, 0x2d, 0x66, 0x82, + 0xfb, 0xe8, 0x0a, 0xb3, 0x6f, 0x00, 0x71, 0xf1, 0x48, 0x52, 0xa0, 0x5c, 0x92, 0x0e, 0x94, 0x21, + 0xba, 0x56, 0xab, 0xb9, 0x18, 0xa1, 0xef, 0xc4, 0x54, 0x51, 0x23, 0x67, 0xeb, 0x73, 0x17, 0x5d, + 0x36, 0xa5, 0xf0, 0x07, 0x0f, 0xf5, 0xec, 0xac, 0xf1, 0x66, 0x5b, 0xa2, 0xbd, 0xd2, 0xc1, 0xdd, + 0xbf, 0x44, 0x59, 0x4a, 0xb2, 0xf3, 0xfe, 0xdb, 0xaf, 0x4f, 0x97, 0x86, 0x98, 0xd2, 0x24, 0xd3, + 0xe9, 0x24, 0x0e, 0x0e, 0x64, 0x4e, 0xcf, 0x33, 0x6b, 0xe6, 0x83, 0xc6, 0x65, 0xe2, 0x2f, 0x1e, + 0x5a, 0xbb, 0x70, 0x4d, 0x78, 0x7b, 0x49, 0x65, 0xd7, 0x35, 0x0c, 0x1e, 0xfe, 0x5f, 0x12, 0xd0, + 0x3f, 0x37, 0xf4, 0xbb, 0xf8, 0x89, 0x1b, 0x39, 0xe1, 0x7a, 0xd4, 0xf8, 0x33, 0x8c, 0xe2, 0xe9, + 0xa8, 0x3a, 0x38, 0x7a, 0x5c, 0xfd, 0x9e, 0xe0, 0xaf, 0x1e, 0x5a, 0xbb, 0x70, 0x9b, 0x4b, 0x9b, + 0x71, 0x9d, 0xce, 0xd2, 0x66, 0x9c, 0x07, 0x43, 0xf6, 0x4c, 0x33, 0x21, 0xde, 0x75, 0x37, 0xd3, + 0x6a, 0x04, 0xce, 0x92, 0x1e, 0x83, 0x71, 0x12, 0xbe, 0x3c, 0x9d, 0xf9, 0xde, 0xd9, 0xcc, 0xf7, + 0x7e, 0xce, 0x7c, 0xef, 0xe3, 0xdc, 0xef, 0x9c, 0xcd, 0xfd, 0xce, 0xf7, 0xb9, 0xdf, 0x79, 0xf3, + 0x4f, 0x5b, 0x7e, 0x67, 0xea, 0xe8, 0x69, 0xc1, 0x55, 0xdc, 0x33, 0x9f, 0x8d, 0xed, 0xdf, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x4a, 0x7b, 0x5d, 0xc7, 0x32, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -157,6 +350,10 @@ const _ = grpc.SupportPackageIsVersion4 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 GetMintRequestsByHash items. + GetMintRequestsByHash(ctx context.Context, in *QueryGetMintRequestsByHashRequest, opts ...grpc.CallOption) (*QueryGetMintRequestsByHashResponse, error) + // Queries a list of MintRequestsByAddress items. + MintRequestsByAddress(ctx context.Context, in *QueryMintRequestsByAddressRequest, opts ...grpc.CallOption) (*QueryMintRequestsByAddressResponse, error) } type queryClient struct { @@ -176,10 +373,32 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) GetMintRequestsByHash(ctx context.Context, in *QueryGetMintRequestsByHashRequest, opts ...grpc.CallOption) (*QueryGetMintRequestsByHashResponse, error) { + out := new(QueryGetMintRequestsByHashResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.dao.Query/GetMintRequestsByHash", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) MintRequestsByAddress(ctx context.Context, in *QueryMintRequestsByAddressRequest, opts ...grpc.CallOption) (*QueryMintRequestsByAddressResponse, error) { + out := new(QueryMintRequestsByAddressResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.dao.Query/MintRequestsByAddress", 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 GetMintRequestsByHash items. + GetMintRequestsByHash(context.Context, *QueryGetMintRequestsByHashRequest) (*QueryGetMintRequestsByHashResponse, error) + // Queries a list of MintRequestsByAddress items. + MintRequestsByAddress(context.Context, *QueryMintRequestsByAddressRequest) (*QueryMintRequestsByAddressResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -189,6 +408,12 @@ 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) GetMintRequestsByHash(ctx context.Context, req *QueryGetMintRequestsByHashRequest) (*QueryGetMintRequestsByHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMintRequestsByHash not implemented") +} +func (*UnimplementedQueryServer) MintRequestsByAddress(ctx context.Context, req *QueryMintRequestsByAddressRequest) (*QueryMintRequestsByAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintRequestsByAddress not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -212,6 +437,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_GetMintRequestsByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetMintRequestsByHashRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetMintRequestsByHash(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.dao.Query/GetMintRequestsByHash", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetMintRequestsByHash(ctx, req.(*QueryGetMintRequestsByHashRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_MintRequestsByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryMintRequestsByAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).MintRequestsByAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.dao.Query/MintRequestsByAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).MintRequestsByAddress(ctx, req.(*QueryMintRequestsByAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "planetmintgo.dao.Query", HandlerType: (*QueryServer)(nil), @@ -220,6 +481,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "GetMintRequestsByHash", + Handler: _Query_GetMintRequestsByHash_Handler, + }, + { + MethodName: "MintRequestsByAddress", + Handler: _Query_MintRequestsByAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "planetmintgo/dao/query.proto", @@ -281,6 +550,136 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryGetMintRequestsByHashRequest) 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 *QueryGetMintRequestsByHashRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetMintRequestsByHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetMintRequestsByHashResponse) 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 *QueryGetMintRequestsByHashResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetMintRequestsByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MintRequest != nil { + { + size, err := m.MintRequest.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 *QueryMintRequestsByAddressRequest) 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 *QueryMintRequestsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMintRequestsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryMintRequestsByAddressResponse) 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 *QueryMintRequestsByAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMintRequestsByAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MintRequests != nil { + { + size, err := m.MintRequests.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 @@ -312,6 +711,58 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryGetMintRequestsByHashRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetMintRequestsByHashResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MintRequest != nil { + l = m.MintRequest.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryMintRequestsByAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryMintRequestsByAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MintRequests != nil { + l = m.MintRequests.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -451,6 +902,342 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetMintRequestsByHashRequest) 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: QueryGetMintRequestsByHashRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetMintRequestsByHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", 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.Hash = 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 *QueryGetMintRequestsByHashResponse) 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: QueryGetMintRequestsByHashResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetMintRequestsByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintRequest", 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.MintRequest == nil { + m.MintRequest = &MintRequest{} + } + if err := m.MintRequest.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 *QueryMintRequestsByAddressRequest) 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: QueryMintRequestsByAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMintRequestsByAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Address = 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 *QueryMintRequestsByAddressResponse) 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: QueryMintRequestsByAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMintRequestsByAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintRequests", 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.MintRequests == nil { + m.MintRequests = &MintRequests{} + } + if err := m.MintRequests.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 diff --git a/x/dao/types/query.pb.gw.go b/x/dao/types/query.pb.gw.go index e840581..b36390d 100644 --- a/x/dao/types/query.pb.gw.go +++ b/x/dao/types/query.pb.gw.go @@ -51,6 +51,114 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_GetMintRequestsByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetMintRequestsByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.GetMintRequestsByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetMintRequestsByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetMintRequestsByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.GetMintRequestsByHash(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_MintRequestsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMintRequestsByAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.MintRequestsByAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_MintRequestsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMintRequestsByAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.MintRequestsByAddress(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. @@ -80,6 +188,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetMintRequestsByHash_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_GetMintRequestsByHash_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_GetMintRequestsByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_MintRequestsByAddress_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_MintRequestsByAddress_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_MintRequestsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +295,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetMintRequestsByHash_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_GetMintRequestsByHash_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_GetMintRequestsByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_MintRequestsByAddress_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_MintRequestsByAddress_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_MintRequestsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"github.com", "planetmint", "planetmint-go", "dao", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetMintRequestsByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"planetmint", "planetmint-go", "dao", "get_mint_requests_by_hash", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_MintRequestsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"planetmint", "planetmint-go", "dao", "mint_requests_by_address", "address"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_GetMintRequestsByHash_0 = runtime.ForwardResponseMessage + + forward_Query_MintRequestsByAddress_0 = runtime.ForwardResponseMessage ) diff --git a/x/dao/types/tx.pb.go b/x/dao/types/tx.pb.go index 3289fbe..f389a19 100644 --- a/x/dao/types/tx.pb.go +++ b/x/dao/types/tx.pb.go @@ -9,7 +9,11 @@ import ( 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. @@ -23,18 +27,118 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgMintToken struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + MintRequest *MintRequest `protobuf:"bytes,2,opt,name=mintRequest,proto3" json:"mintRequest,omitempty"` +} + +func (m *MsgMintToken) Reset() { *m = MsgMintToken{} } +func (m *MsgMintToken) String() string { return proto.CompactTextString(m) } +func (*MsgMintToken) ProtoMessage() {} +func (*MsgMintToken) Descriptor() ([]byte, []int) { + return fileDescriptor_7117c47dbc1828c7, []int{0} +} +func (m *MsgMintToken) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintToken.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 *MsgMintToken) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintToken.Merge(m, src) +} +func (m *MsgMintToken) XXX_Size() int { + return m.Size() +} +func (m *MsgMintToken) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintToken.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintToken proto.InternalMessageInfo + +func (m *MsgMintToken) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgMintToken) GetMintRequest() *MintRequest { + if m != nil { + return m.MintRequest + } + return nil +} + +type MsgMintTokenResponse struct { +} + +func (m *MsgMintTokenResponse) Reset() { *m = MsgMintTokenResponse{} } +func (m *MsgMintTokenResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintTokenResponse) ProtoMessage() {} +func (*MsgMintTokenResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7117c47dbc1828c7, []int{1} +} +func (m *MsgMintTokenResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintTokenResponse.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 *MsgMintTokenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintTokenResponse.Merge(m, src) +} +func (m *MsgMintTokenResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintTokenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintTokenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintTokenResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgMintToken)(nil), "planetmintgo.dao.MsgMintToken") + proto.RegisterType((*MsgMintTokenResponse)(nil), "planetmintgo.dao.MsgMintTokenResponse") +} + func init() { proto.RegisterFile("planetmintgo/dao/tx.proto", fileDescriptor_7117c47dbc1828c7) } var fileDescriptor_7117c47dbc1828c7 = []byte{ - // 127 bytes of a gzipped FileDescriptorProto + // 239 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xc8, 0x49, 0xcc, 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x49, 0xcc, 0xd7, 0x2f, 0xa9, 0xd0, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x96, 0xd2, 0x4b, 0x49, 0xcc, 0x37, 0x62, 0xe5, - 0x62, 0xf6, 0x2d, 0x4e, 0x77, 0xf2, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, - 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, - 0x28, 0xfd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x84, 0x6e, 0x24, - 0xa6, 0x6e, 0x7a, 0xbe, 0x7e, 0x05, 0xc4, 0x9a, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x55, - 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, 0xd4, 0x79, 0xef, 0x87, 0x00, 0x00, 0x00, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x96, 0xd2, 0x4b, 0x49, 0xcc, 0x97, 0x52, 0xc6, + 0x50, 0x0c, 0x62, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x40, 0xb4, 0x29, 0x65, 0x72, + 0xf1, 0xf8, 0x16, 0xa7, 0xfb, 0x66, 0xe6, 0x95, 0x84, 0xe4, 0x67, 0xa7, 0xe6, 0x09, 0x49, 0x70, + 0xb1, 0x27, 0x17, 0xa5, 0x26, 0x96, 0xe4, 0x17, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, + 0xb8, 0x42, 0xf6, 0x5c, 0xdc, 0x20, 0xfd, 0x41, 0x10, 0xed, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, + 0x46, 0xb2, 0x7a, 0xe8, 0xd6, 0xea, 0xf9, 0x22, 0x14, 0x05, 0x21, 0xeb, 0x50, 0x12, 0xe3, 0x12, + 0x41, 0xb6, 0x2a, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x8a, 0x8b, 0xd9, 0xb7, + 0x38, 0x5d, 0x28, 0x98, 0x8b, 0x13, 0xe1, 0x0c, 0x39, 0x2c, 0xe6, 0x22, 0xe9, 0x95, 0x52, 0xc3, + 0x2f, 0x0f, 0x33, 0xdb, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, + 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, + 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, 0x66, 0x21, 0x31, + 0x75, 0xd3, 0xf3, 0xf5, 0x2b, 0x20, 0x61, 0x5c, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x30, + 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x28, 0x27, 0x19, 0xcf, 0x84, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +153,7 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { + MintToken(ctx context.Context, in *MsgMintToken, opts ...grpc.CallOption) (*MsgMintTokenResponse, error) } type msgClient struct { @@ -59,22 +164,420 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) MintToken(ctx context.Context, in *MsgMintToken, opts ...grpc.CallOption) (*MsgMintTokenResponse, error) { + out := new(MsgMintTokenResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.dao.Msg/MintToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + MintToken(context.Context, *MsgMintToken) (*MsgMintTokenResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) MintToken(ctx context.Context, req *MsgMintToken) (*MsgMintTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintToken not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_MintToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintToken) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.dao.Msg/MintToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintToken(ctx, req.(*MsgMintToken)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "planetmintgo.dao.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "planetmintgo/dao/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "MintToken", + Handler: _Msg_MintToken_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "planetmintgo/dao/tx.proto", } + +func (m *MsgMintToken) 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 *MsgMintToken) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MintRequest != nil { + { + size, err := m.MintRequest.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 *MsgMintTokenResponse) 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 *MsgMintTokenResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintTokenResponse) 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 *MsgMintToken) 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.MintRequest != nil { + l = m.MintRequest.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintTokenResponse) 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 *MsgMintToken) 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: MsgMintToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintToken: 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 MintRequest", 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.MintRequest == nil { + m.MintRequest = &MintRequest{} + } + if err := m.MintRequest.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 *MsgMintTokenResponse) 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: MsgMintTokenResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintTokenResponse: 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") +)