From 419ce913d1d67144ac2dcad8d2469ea8ef2f6eb3 Mon Sep 17 00:00:00 2001 From: Anh Minh <1phamminh0811@gmail.com> Date: Mon, 24 Jun 2024 11:13:04 +0700 Subject: [PATCH] Add tax2gas module and move all handle fees logic to tax2gas module --- custom/auth/ante/ante.go | 4 +- custom/auth/ante/fee_test.go | 30 +- custom/auth/tx/service.go | 3 +- custom/wasm/keeper/handler_plugin.go | 2 +- proto/terra/tax2gas/v1beta1/genesis.proto | 16 + proto/terra/tax2gas/v1beta1/query.proto | 19 + proto/terra/tax2gas/v1beta1/tx.proto | 18 + scripts/protocgen.sh | 5 +- {custom/auth => x/tax2gas}/ante/fee.go | 18 +- .../auth => x/tax2gas}/ante/fee_burntax.go | 0 {custom/auth => x/tax2gas}/ante/fee_tax.go | 5 +- x/tax2gas/client/cli/query.go | 60 ++ x/tax2gas/client/cli/tx.go | 54 ++ x/tax2gas/keeper/keeper.go | 53 ++ x/tax2gas/module.go | 121 ++++ x/tax2gas/types/codec.go | 39 ++ x/tax2gas/types/errors.go | 1 + x/tax2gas/types/events.go | 5 + x/tax2gas/types/expected_keeper.go | 25 + x/tax2gas/types/genesis.go | 17 + x/tax2gas/types/genesis.pb.go | 448 +++++++++++++++ x/tax2gas/types/keys.go | 14 + x/tax2gas/types/msgs.go | 35 ++ x/tax2gas/types/params.go | 36 ++ x/tax2gas/types/query.pb.go | 532 ++++++++++++++++++ x/tax2gas/types/query.pb.gw.go | 153 +++++ x/tax2gas/types/tx.pb.go | 528 +++++++++++++++++ 27 files changed, 2209 insertions(+), 32 deletions(-) create mode 100644 proto/terra/tax2gas/v1beta1/genesis.proto create mode 100644 proto/terra/tax2gas/v1beta1/query.proto create mode 100644 proto/terra/tax2gas/v1beta1/tx.proto rename {custom/auth => x/tax2gas}/ante/fee.go (90%) rename {custom/auth => x/tax2gas}/ante/fee_burntax.go (100%) rename {custom/auth => x/tax2gas}/ante/fee_tax.go (92%) create mode 100644 x/tax2gas/client/cli/query.go create mode 100644 x/tax2gas/client/cli/tx.go create mode 100644 x/tax2gas/keeper/keeper.go create mode 100644 x/tax2gas/module.go create mode 100644 x/tax2gas/types/codec.go create mode 100644 x/tax2gas/types/errors.go create mode 100644 x/tax2gas/types/events.go create mode 100644 x/tax2gas/types/expected_keeper.go create mode 100644 x/tax2gas/types/genesis.go create mode 100644 x/tax2gas/types/genesis.pb.go create mode 100644 x/tax2gas/types/keys.go create mode 100644 x/tax2gas/types/msgs.go create mode 100644 x/tax2gas/types/params.go create mode 100644 x/tax2gas/types/query.pb.go create mode 100644 x/tax2gas/types/query.pb.gw.go create mode 100644 x/tax2gas/types/tx.pb.go diff --git a/custom/auth/ante/ante.go b/custom/auth/ante/ante.go index 7dabfce5a..b28fbeac6 100644 --- a/custom/auth/ante/ante.go +++ b/custom/auth/ante/ante.go @@ -12,6 +12,8 @@ import ( dyncommante "github.com/classic-terra/core/v3/x/dyncomm/ante" dyncommkeeper "github.com/classic-terra/core/v3/x/dyncomm/keeper" + tax2gasante "github.com/classic-terra/core/v3/x/tax2gas/ante" + "github.com/cosmos/cosmos-sdk/codec" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" @@ -88,7 +90,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { // MinInitialDepositDecorator prevents submitting governance proposal low initial deposit NewMinInitialDepositDecorator(options.GovKeeper, options.TreasuryKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - NewFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TreasuryKeeper), + tax2gasante.NewFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TreasuryKeeper), dyncommante.NewDyncommDecorator(options.Cdc, options.DyncommKeeper, options.StakingKeeper), // Do not add any other decorators below this point unless explicitly explain. diff --git a/custom/auth/ante/fee_test.go b/custom/auth/ante/fee_test.go index 50dcc8c4c..529f89d5f 100644 --- a/custom/auth/ante/fee_test.go +++ b/custom/auth/ante/fee_test.go @@ -18,17 +18,17 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - "github.com/classic-terra/core/v3/custom/auth/ante" core "github.com/classic-terra/core/v3/types" markettypes "github.com/classic-terra/core/v3/x/market/types" oracletypes "github.com/classic-terra/core/v3/x/oracle/types" + tax2gasante "github.com/classic-terra/core/v3/x/tax2gas/ante" ) func (s *AnteTestSuite) TestDeductFeeDecorator_ZeroGas() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -62,7 +62,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -146,7 +146,7 @@ func (s *AnteTestSuite) TestDeductFees() { err = testutil.FundAccount(s.app.BankKeeper, s.ctx, addr1, coins) s.Require().NoError(err) - dfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + dfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(dfd) _, err = antehandler(s.ctx, tx, false) @@ -167,7 +167,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesSend() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -221,7 +221,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesSwapSend() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -274,7 +274,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesMultiSend() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -341,7 +341,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesInstantiateContract() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -400,7 +400,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesExecuteContract() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -458,7 +458,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesAuthzExec() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -697,7 +697,7 @@ func (s *AnteTestSuite) TestTaxExemption() { tk.AddBurnTaxExemptionAddress(s.ctx, addrs[0].String()) tk.AddBurnTaxExemptionAddress(s.ctx, addrs[1].String()) - mfd := ante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) + mfd := tax2gasante.NewFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.TreasuryKeeper) antehandler := sdk.ChainAnteDecorators(mfd) for i := 0; i < 4; i++ { @@ -747,7 +747,7 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec) { ak := s.app.AccountKeeper bk := s.app.BankKeeper tk := s.app.TreasuryKeeper - mfd := ante.NewFeeDecorator(ak, bk, s.app.FeeGrantKeeper, tk) + mfd := tax2gasante.NewFeeDecorator(ak, bk, s.app.FeeGrantKeeper, tk) antehandler := sdk.ChainAnteDecorators(mfd) // Set burn split tax @@ -804,7 +804,7 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec) { tk.BurnCoinsFromBurnAccount(s.ctx) feeCollectorAfter := sdk.NewDecCoinsFromCoins(bk.GetAllBalances(s.ctx, ak.GetModuleAddress(authtypes.FeeCollectorName))...) - taxes := ante.FilterMsgAndComputeTax(s.ctx, tk, msg) + taxes := tax2gasante.FilterMsgAndComputeTax(s.ctx, tk, msg) burnTax := sdk.NewDecCoinsFromCoins(taxes...) if burnSplitRate.IsPositive() { @@ -839,7 +839,7 @@ func (s *AnteTestSuite) TestEnsureIBCUntaxed() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator( + mfd := tax2gasante.NewFeeDecorator( s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, @@ -888,7 +888,7 @@ func (s *AnteTestSuite) TestOracleZeroFee() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewFeeDecorator( + mfd := tax2gasante.NewFeeDecorator( s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, diff --git a/custom/auth/tx/service.go b/custom/auth/tx/service.go index 63710d04e..4338bbba9 100644 --- a/custom/auth/tx/service.go +++ b/custom/auth/tx/service.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc/status" customante "github.com/classic-terra/core/v3/custom/auth/ante" + tax2gasante "github.com/classic-terra/core/v3/x/tax2gas/ante" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -52,7 +53,7 @@ func (ts txServer) ComputeTax(c context.Context, req *ComputeTaxRequest) (*Compu return nil, status.Errorf(codes.InvalidArgument, "empty txBytes is not allowed") } - taxAmount := customante.FilterMsgAndComputeTax(ctx, ts.treasuryKeeper, msgs...) + taxAmount := tax2gasante.FilterMsgAndComputeTax(ctx, ts.treasuryKeeper, msgs...) return &ComputeTaxResponse{ TaxAmount: taxAmount, }, nil diff --git a/custom/wasm/keeper/handler_plugin.go b/custom/wasm/keeper/handler_plugin.go index f3a24801b..3db8e9a00 100644 --- a/custom/wasm/keeper/handler_plugin.go +++ b/custom/wasm/keeper/handler_plugin.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/classic-terra/core/v3/custom/auth/ante" + "github.com/classic-terra/core/v3/x/tax2gas/ante" treasurykeeper "github.com/classic-terra/core/v3/x/treasury/keeper" wasmvmtypes "github.com/CosmWasm/wasmvm/types" diff --git a/proto/terra/tax2gas/v1beta1/genesis.proto b/proto/terra/tax2gas/v1beta1/genesis.proto new file mode 100644 index 000000000..8cb3703fe --- /dev/null +++ b/proto/terra/tax2gas/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package terra.tax2gas.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/classic-terra/core/v3/x/tax2gas/types"; + +message Params {} + +// GenesisState defines the tax2gas module's genesis state. +message GenesisState { + // params is the container of tax2gas parameters. + Params params = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/terra/tax2gas/v1beta1/query.proto b/proto/terra/tax2gas/v1beta1/query.proto new file mode 100644 index 000000000..6fa3165b5 --- /dev/null +++ b/proto/terra/tax2gas/v1beta1/query.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package terra.tax2gas.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "terra/tax2gas/v1beta1/genesis.proto"; +import "terra/tax2gas/v1beta1/tx.proto"; + +option go_package = "github.com/classic-terra/core/v3/x/tax2gas/types"; + +service Query { + rpc Params(ParamsRequest) returns (ParamsResponse) { + option (google.api.http).get = "/terra/tax2gas/Params"; + } +} + +//=============================== Params +message ParamsRequest {} +message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/terra/tax2gas/v1beta1/tx.proto b/proto/terra/tax2gas/v1beta1/tx.proto new file mode 100644 index 000000000..49fd5d14e --- /dev/null +++ b/proto/terra/tax2gas/v1beta1/tx.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package terra.tax2gas.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/classic-terra/core/v3/x/tax2gas/types"; + +service Msg { + rpc Test(MsgTest) returns (MsgTestResponse); +} + +// ===================== MsgTest +message MsgTest { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; +} + +message MsgTestResponse {} \ No newline at end of file diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index bfcae1a32..8d0a493b8 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -1,9 +1,6 @@ #!/usr/bin/env sh -set -eo pipefail - -# get protoc executions -go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null +set -eux pipefail echo "Generating gogo proto code" cd proto diff --git a/custom/auth/ante/fee.go b/x/tax2gas/ante/fee.go similarity index 90% rename from custom/auth/ante/fee.go rename to x/tax2gas/ante/fee.go index 44acc1f4b..5408cd38e 100644 --- a/custom/auth/ante/fee.go +++ b/x/tax2gas/ante/fee.go @@ -8,7 +8,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/classic-terra/core/v3/x/tax2gas/types" ) // FeeDecorator deducts fees from the first signer of the tx @@ -17,12 +19,12 @@ import ( // CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator type FeeDecorator struct { accountKeeper ante.AccountKeeper - bankKeeper BankKeeper + bankKeeper types.BankKeeper feegrantKeeper ante.FeegrantKeeper - treasuryKeeper TreasuryKeeper + treasuryKeeper types.TreasuryKeeper } -func NewFeeDecorator(ak ante.AccountKeeper, bk BankKeeper, fk ante.FeegrantKeeper, tk TreasuryKeeper) FeeDecorator { +func NewFeeDecorator(ak ante.AccountKeeper, bk types.BankKeeper, fk ante.FeegrantKeeper, tk types.TreasuryKeeper) FeeDecorator { return FeeDecorator{ accountKeeper: ak, bankKeeper: bk, @@ -67,8 +69,8 @@ func (fd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, nex } func (fd FeeDecorator) checkDeductFee(ctx sdk.Context, feeTx sdk.FeeTx, taxes sdk.Coins, simulate bool) error { - if addr := fd.accountKeeper.GetModuleAddress(types.FeeCollectorName); addr == nil { - return fmt.Errorf("fee collector module account (%s) has not been set", types.FeeCollectorName) + if addr := fd.accountKeeper.GetModuleAddress(authtypes.FeeCollectorName); addr == nil { + return fmt.Errorf("fee collector module account (%s) has not been set", authtypes.FeeCollectorName) } fee := feeTx.GetFee() @@ -127,12 +129,12 @@ func (fd FeeDecorator) checkDeductFee(ctx sdk.Context, feeTx sdk.FeeTx, taxes sd } // DeductFees deducts fees from the given account. -func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error { +func DeductFees(bankKeeper authtypes.BankKeeper, ctx sdk.Context, acc authtypes.AccountI, fees sdk.Coins) error { if !fees.IsValid() { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) } - err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees) + err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), authtypes.FeeCollectorName, fees) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } diff --git a/custom/auth/ante/fee_burntax.go b/x/tax2gas/ante/fee_burntax.go similarity index 100% rename from custom/auth/ante/fee_burntax.go rename to x/tax2gas/ante/fee_burntax.go diff --git a/custom/auth/ante/fee_tax.go b/x/tax2gas/ante/fee_tax.go similarity index 92% rename from custom/auth/ante/fee_tax.go rename to x/tax2gas/ante/fee_tax.go index 96a0e48d6..9493a1c91 100644 --- a/custom/auth/ante/fee_tax.go +++ b/x/tax2gas/ante/fee_tax.go @@ -11,6 +11,7 @@ import ( marketexported "github.com/classic-terra/core/v3/x/market/exported" oracleexported "github.com/classic-terra/core/v3/x/oracle/exported" + "github.com/classic-terra/core/v3/x/tax2gas/types" ) var IBCRegexp = regexp.MustCompile("^ibc/[a-fA-F0-9]{64}$") @@ -20,7 +21,7 @@ func isIBCDenom(denom string) bool { } // FilterMsgAndComputeTax computes the stability tax on messages. -func FilterMsgAndComputeTax(ctx sdk.Context, tk TreasuryKeeper, msgs ...sdk.Msg) sdk.Coins { +func FilterMsgAndComputeTax(ctx sdk.Context, tk types.TreasuryKeeper, msgs ...sdk.Msg) sdk.Coins { taxes := sdk.Coins{} for _, msg := range msgs { @@ -77,7 +78,7 @@ func FilterMsgAndComputeTax(ctx sdk.Context, tk TreasuryKeeper, msgs ...sdk.Msg) } // computes the stability tax according to tax-rate and tax-cap -func computeTax(ctx sdk.Context, tk TreasuryKeeper, principal sdk.Coins) sdk.Coins { +func computeTax(ctx sdk.Context, tk types.TreasuryKeeper, principal sdk.Coins) sdk.Coins { taxRate := tk.GetTaxRate(ctx) if taxRate.Equal(sdk.ZeroDec()) { return sdk.Coins{} diff --git a/x/tax2gas/client/cli/query.go b/x/tax2gas/client/cli/query.go new file mode 100644 index 000000000..72cd15999 --- /dev/null +++ b/x/tax2gas/client/cli/query.go @@ -0,0 +1,60 @@ +package cli + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/classic-terra/core/v3/x/tax2gas/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd() *cobra.Command { + tax2gasQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + tax2gasQueryCmd.AddCommand( + GetCmdQueryParams(), + ) + + return tax2gasQueryCmd +} + + +// GetCmdQueryParams implements a command to return the current parameters. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current tax2gas module parameters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.ParamsRequest{} + + res, err := queryClient.Params(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/tax2gas/client/cli/tx.go b/x/tax2gas/client/cli/tx.go new file mode 100644 index 000000000..54b4f697b --- /dev/null +++ b/x/tax2gas/client/cli/tx.go @@ -0,0 +1,54 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/classic-terra/core/v3/x/tax2gas/types" +) + +// NewTxCmd returns a root CLI command handler for certain modules transaction commands. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "tax2gas subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand() + return txCmd +} + +// NewCmdTest broadcasts a Test message. +func NewCmdTest() *cobra.Command { + cmd := &cobra.Command{ + Use: "test [flags]", + Short: "test command", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + sender := clientCtx.GetFromAddress() + + msg := &types.MsgTest{ + Sender: sender.String(), + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/tax2gas/keeper/keeper.go b/x/tax2gas/keeper/keeper.go new file mode 100644 index 000000000..d1643a515 --- /dev/null +++ b/x/tax2gas/keeper/keeper.go @@ -0,0 +1,53 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/classic-terra/core/v3/x/tax2gas/types" +) + + +type Keeper struct { + storeKey storetypes.StoreKey + + paramSpace paramtypes.Subspace +} + +func NewKeeper(storeKey storetypes.StoreKey, paramSpace paramtypes.Subspace) *Keeper { + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{storeKey: storeKey, paramSpace: paramSpace} +} + +// GetParams returns the total set of testmodule parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramSpace.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the total set of testmodule parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} + +// InitGenesis initializes the testmodule module's state from a provided genesis +// state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { + if err := genState.Validate(); err != nil { + panic(err) + } + + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the testmodule module's exported genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return &types.GenesisState{ + Params: k.GetParams(ctx), + } +} diff --git a/x/tax2gas/module.go b/x/tax2gas/module.go new file mode 100644 index 000000000..e7c6e045a --- /dev/null +++ b/x/tax2gas/module.go @@ -0,0 +1,121 @@ +package module + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/classic-terra/core/v3/x/tax2gas/client/cli" + "github.com/classic-terra/core/v3/x/tax2gas/keeper" + "github.com/classic-terra/core/v3/x/tax2gas/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +type AppModuleBasic struct{} + +func (AppModuleBasic) Name() string { return types.ModuleName } + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the testmodule module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// --------------------------------------- +// Interfaces. +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// RegisterInterfaces registers interfaces and implementations of the testmodule module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +type AppModule struct { + AppModuleBasic + + k keeper.Keeper +} + +func (am AppModule) RegisterServices(cfg module.Configurator) { + // types.RegisterMsgServer(cfg.MsgServer(), testmodule.NewMsgServerImpl(&am.k)) + // queryproto.RegisterQueryServer(cfg.QueryServer(), grpc.Querier{Q: module.NewQuerier(am.k)}) +} + + +func NewAppModule(testmoduleKeeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + k: testmoduleKeeper, + } +} + +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +// QuerierRoute returns the testmodule module's querier route name. +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// InitGenesis performs genesis initialization for the testmodule module. +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(gs, &genesisState) + + am.k.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the testmodule. +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.k.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// BeginBlock performs TODO. +func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock performs TODO. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } diff --git a/x/tax2gas/types/codec.go b/x/tax2gas/types/codec.go new file mode 100644 index 000000000..3c3402be6 --- /dev/null +++ b/x/tax2gas/types/codec.go @@ -0,0 +1,39 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" +) + +// RegisterLegacyAminoCodec registers the necessary x/tax2gas interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgTest{}, "tax2gas/MsgTest", nil) +} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgTest{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + sdk.RegisterLegacyAminoCodec(amino) + RegisterLegacyAminoCodec(authzcodec.Amino) + + amino.Seal() +} diff --git a/x/tax2gas/types/errors.go b/x/tax2gas/types/errors.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/tax2gas/types/errors.go @@ -0,0 +1 @@ +package types diff --git a/x/tax2gas/types/events.go b/x/tax2gas/types/events.go new file mode 100644 index 000000000..885a885a7 --- /dev/null +++ b/x/tax2gas/types/events.go @@ -0,0 +1,5 @@ +package types + +const ( + AttributeValueCategory = ModuleName +) diff --git a/x/tax2gas/types/expected_keeper.go b/x/tax2gas/types/expected_keeper.go new file mode 100644 index 000000000..945b25a72 --- /dev/null +++ b/x/tax2gas/types/expected_keeper.go @@ -0,0 +1,25 @@ +package types + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// TreasuryKeeper for tax charging & recording +type TreasuryKeeper interface { + RecordEpochTaxProceeds(ctx sdk.Context, delta sdk.Coins) + GetTaxRate(ctx sdk.Context) (taxRate sdk.Dec) + GetTaxCap(ctx sdk.Context, denom string) (taxCap math.Int) + GetBurnSplitRate(ctx sdk.Context) sdk.Dec + HasBurnTaxExemptionAddress(ctx sdk.Context, addresses ...string) bool + HasBurnTaxExemptionContract(ctx sdk.Context, address string) bool + GetMinInitialDepositRatio(ctx sdk.Context) sdk.Dec +} + +// BankKeeper defines the contract needed for supply related APIs (noalias) +type BankKeeper interface { + IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error + SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error +} diff --git a/x/tax2gas/types/genesis.go b/x/tax2gas/types/genesis.go new file mode 100644 index 000000000..964a1a3ea --- /dev/null +++ b/x/tax2gas/types/genesis.go @@ -0,0 +1,17 @@ +package types + +// DefaultGenesis returns the default tax2gas genesis state. +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + if err := gs.Params.Validate(); err != nil { + return err + } + return nil +} diff --git a/x/tax2gas/types/genesis.pb.go b/x/tax2gas/types/genesis.pb.go new file mode 100644 index 000000000..5a47d4eb0 --- /dev/null +++ b/x/tax2gas/types/genesis.pb.go @@ -0,0 +1,448 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: terra/tax2gas/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_589c4ef0e5113034, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +// GenesisState defines the tax2gas module's genesis state. +type GenesisState struct { + // params is the container of tax2gas parameters. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_589c4ef0e5113034, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*Params)(nil), "terra.tax2gas.v1beta1.Params") + proto.RegisterType((*GenesisState)(nil), "terra.tax2gas.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("terra/tax2gas/v1beta1/genesis.proto", fileDescriptor_589c4ef0e5113034) +} + +var fileDescriptor_589c4ef0e5113034 = []byte{ + // 241 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2e, 0x49, 0x2d, 0x2a, + 0x4a, 0xd4, 0x2f, 0x49, 0xac, 0x30, 0x4a, 0x4f, 0x2c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, + 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x05, 0x2b, 0xd2, 0x83, 0x2a, 0xd2, 0x83, 0x2a, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, + 0xab, 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0x24, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, + 0xbc, 0xa4, 0xd2, 0x34, 0xfd, 0xc4, 0xbc, 0x4a, 0x98, 0x54, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, + 0x3c, 0x44, 0x0f, 0x84, 0x03, 0x91, 0x52, 0xe2, 0xe0, 0x62, 0x0b, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, + 0x56, 0xf2, 0xe6, 0xe2, 0x71, 0x87, 0xd8, 0x1e, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xcd, 0xc5, + 0x56, 0x00, 0x96, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd5, 0xc3, 0xea, 0x1a, 0x3d, + 0x88, 0x76, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x5a, 0x9c, 0xbc, 0x4e, 0x3c, 0x92, + 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, + 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, + 0x39, 0x3f, 0x57, 0x3f, 0x39, 0x27, 0xb1, 0xb8, 0x38, 0x33, 0x59, 0x17, 0x12, 0x16, 0xc9, 0xf9, + 0x45, 0xa9, 0xfa, 0x65, 0xc6, 0xfa, 0x15, 0xf0, 0x50, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, + 0x03, 0xbb, 0xd4, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x82, 0x3b, 0x6e, 0x5a, 0x33, 0x01, 0x00, + 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tax2gas/types/keys.go b/x/tax2gas/types/keys.go new file mode 100644 index 000000000..6d701815b --- /dev/null +++ b/x/tax2gas/types/keys.go @@ -0,0 +1,14 @@ +package types + +const ( + ModuleName = "tax2gas" + + StoreKey = ModuleName + + RouterKey = ModuleName +) + +var ( + // Key defines the store key for tax2gas. + Key = []byte{0x01} +) diff --git a/x/tax2gas/types/msgs.go b/x/tax2gas/types/msgs.go new file mode 100644 index 000000000..53f1703ab --- /dev/null +++ b/x/tax2gas/types/msgs.go @@ -0,0 +1,35 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + TypeMsgTest = "test" +) + +var _ sdk.Msg = &MsgTest{} + +func (msg MsgTest) Route() string { return ModuleName } +func (msg MsgTest) Type() string { return TypeMsgTest } +func (msg MsgTest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + return nil +} + +func (msg MsgTest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgTest) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} diff --git a/x/tax2gas/types/params.go b/x/tax2gas/types/params.go new file mode 100644 index 000000000..9d11dd3f4 --- /dev/null +++ b/x/tax2gas/types/params.go @@ -0,0 +1,36 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Parameter store keys. +var ( + KeyParamField = []byte("TODO: CHANGE ME") +) + +// ParamTable for tax2gas module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewParams() Params { + return Params{} +} + +// DefaultParams are the default tax2gas module parameters. +func DefaultParams() Params { + return Params{} +} + +// Validate validates params. +func (p Params) Validate() error { + return nil +} + +// Implements params.ParamSet. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + // paramtypes.NewParamSetPair(KeyParamField, &p.Field, validateFn), + } +} diff --git a/x/tax2gas/types/query.pb.go b/x/tax2gas/types/query.pb.go new file mode 100644 index 000000000..702fa660f --- /dev/null +++ b/x/tax2gas/types/query.pb.go @@ -0,0 +1,532 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: terra/tax2gas/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// =============================== Params +type ParamsRequest struct { +} + +func (m *ParamsRequest) Reset() { *m = ParamsRequest{} } +func (m *ParamsRequest) String() string { return proto.CompactTextString(m) } +func (*ParamsRequest) ProtoMessage() {} +func (*ParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bfce3f3a760d419d, []int{0} +} +func (m *ParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsRequest.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 *ParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsRequest.Merge(m, src) +} +func (m *ParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *ParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsRequest proto.InternalMessageInfo + +type ParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *ParamsResponse) Reset() { *m = ParamsResponse{} } +func (m *ParamsResponse) String() string { return proto.CompactTextString(m) } +func (*ParamsResponse) ProtoMessage() {} +func (*ParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bfce3f3a760d419d, []int{1} +} +func (m *ParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsResponse.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 *ParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsResponse.Merge(m, src) +} +func (m *ParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *ParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsResponse proto.InternalMessageInfo + +func (m *ParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*ParamsRequest)(nil), "terra.tax2gas.v1beta1.ParamsRequest") + proto.RegisterType((*ParamsResponse)(nil), "terra.tax2gas.v1beta1.ParamsResponse") +} + +func init() { proto.RegisterFile("terra/tax2gas/v1beta1/query.proto", fileDescriptor_bfce3f3a760d419d) } + +var fileDescriptor_bfce3f3a760d419d = []byte{ + // 298 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xb1, 0x4b, 0xc3, 0x40, + 0x14, 0xc6, 0x13, 0xd1, 0x0e, 0x27, 0x2a, 0x04, 0x8b, 0x52, 0xec, 0xa9, 0x55, 0xc1, 0xc5, 0x3b, + 0x9b, 0x8e, 0x6e, 0x8e, 0x82, 0xa0, 0x1d, 0xdd, 0x2e, 0xe1, 0x38, 0x03, 0x6d, 0x5e, 0x7a, 0xf7, + 0x52, 0xd2, 0xc1, 0xc5, 0xbf, 0x40, 0xf0, 0x9f, 0xea, 0x58, 0x70, 0x71, 0x12, 0x49, 0xfc, 0x43, + 0xa4, 0xb9, 0xab, 0x20, 0x04, 0xdd, 0x8e, 0xf7, 0x7e, 0xdf, 0x77, 0xdf, 0xf7, 0xc8, 0x31, 0x4a, + 0xad, 0x05, 0x47, 0x51, 0x84, 0x4a, 0x18, 0x3e, 0xed, 0x47, 0x12, 0x45, 0x9f, 0x4f, 0x72, 0xa9, + 0x67, 0x2c, 0xd3, 0x80, 0x10, 0xb4, 0x6b, 0x84, 0x39, 0x84, 0x39, 0xa4, 0xb3, 0xab, 0x40, 0x41, + 0x4d, 0xf0, 0xe5, 0xcb, 0xc2, 0x9d, 0x03, 0x05, 0xa0, 0x46, 0x92, 0x8b, 0x2c, 0xe1, 0x22, 0x4d, + 0x01, 0x05, 0x26, 0x90, 0x1a, 0xb7, 0x3d, 0x69, 0xfe, 0x4d, 0xc9, 0x54, 0x9a, 0x64, 0x05, 0xd1, + 0x66, 0x08, 0x0b, 0xbb, 0xef, 0xed, 0x90, 0xad, 0x3b, 0xa1, 0xc5, 0xd8, 0x0c, 0xe5, 0x24, 0x97, + 0x06, 0x7b, 0xb7, 0x64, 0x7b, 0x35, 0x30, 0x19, 0xa4, 0x46, 0x06, 0x57, 0xa4, 0x95, 0xd5, 0x93, + 0x7d, 0xff, 0xc8, 0x3f, 0xdf, 0x0c, 0xbb, 0xac, 0xb1, 0x03, 0xb3, 0xb2, 0xeb, 0xf5, 0xf9, 0xc7, + 0xa1, 0x37, 0x74, 0x92, 0xf0, 0x89, 0x6c, 0xdc, 0x2f, 0xeb, 0x07, 0x48, 0x5a, 0x16, 0x08, 0x4e, + 0xff, 0xd4, 0xbb, 0x1c, 0x9d, 0xb3, 0x7f, 0x28, 0x1b, 0xae, 0xd7, 0x7d, 0x7e, 0xfb, 0x7a, 0x5d, + 0xdb, 0x0b, 0xda, 0xfc, 0x77, 0x51, 0x17, 0xe6, 0x66, 0x5e, 0x52, 0x7f, 0x51, 0x52, 0xff, 0xb3, + 0xa4, 0xfe, 0x4b, 0x45, 0xbd, 0x45, 0x45, 0xbd, 0xf7, 0x8a, 0x7a, 0x0f, 0x97, 0x2a, 0xc1, 0xc7, + 0x3c, 0x62, 0x31, 0x8c, 0x79, 0x3c, 0x12, 0xc6, 0x24, 0xf1, 0x85, 0xb5, 0x88, 0x41, 0x4b, 0x3e, + 0x1d, 0xf0, 0xe2, 0xc7, 0x0c, 0x67, 0x99, 0x34, 0x51, 0xab, 0xbe, 0xd8, 0xe0, 0x3b, 0x00, 0x00, + 0xff, 0xff, 0x96, 0xe7, 0x47, 0xe5, 0xe6, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) { + out := new(ParamsResponse) + err := c.cc.Invoke(ctx, "/terra.tax2gas.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Params(context.Context, *ParamsRequest) (*ParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *ParamsRequest) (*ParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/terra.tax2gas.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*ParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "terra.tax2gas.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "terra/tax2gas/v1beta1/query.proto", +} + +func (m *ParamsRequest) 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 *ParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ParamsResponse) 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 *ParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ParamsRequest) 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: ParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ParamsResponse) 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: ParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tax2gas/types/query.pb.gw.go b/x/tax2gas/types/query.pb.gw.go new file mode 100644 index 000000000..3214847a9 --- /dev/null +++ b/x/tax2gas/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: terra/tax2gas/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"terra", "tax2gas", "Params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/tax2gas/types/tx.pb.go b/x/tax2gas/types/tx.pb.go new file mode 100644 index 000000000..1abf49490 --- /dev/null +++ b/x/tax2gas/types/tx.pb.go @@ -0,0 +1,528 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: terra/tax2gas/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ===================== MsgTest +type MsgTest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` +} + +func (m *MsgTest) Reset() { *m = MsgTest{} } +func (m *MsgTest) String() string { return proto.CompactTextString(m) } +func (*MsgTest) ProtoMessage() {} +func (*MsgTest) Descriptor() ([]byte, []int) { + return fileDescriptor_a20cba19b3d258de, []int{0} +} +func (m *MsgTest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTest.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 *MsgTest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTest.Merge(m, src) +} +func (m *MsgTest) XXX_Size() int { + return m.Size() +} +func (m *MsgTest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTest proto.InternalMessageInfo + +func (m *MsgTest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +type MsgTestResponse struct { +} + +func (m *MsgTestResponse) Reset() { *m = MsgTestResponse{} } +func (m *MsgTestResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTestResponse) ProtoMessage() {} +func (*MsgTestResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a20cba19b3d258de, []int{1} +} +func (m *MsgTestResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTestResponse.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 *MsgTestResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTestResponse.Merge(m, src) +} +func (m *MsgTestResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTestResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTestResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTestResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgTest)(nil), "terra.tax2gas.v1beta1.MsgTest") + proto.RegisterType((*MsgTestResponse)(nil), "terra.tax2gas.v1beta1.MsgTestResponse") +} + +func init() { proto.RegisterFile("terra/tax2gas/v1beta1/tx.proto", fileDescriptor_a20cba19b3d258de) } + +var fileDescriptor_a20cba19b3d258de = []byte{ + // 258 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x49, 0x2d, 0x2a, + 0x4a, 0xd4, 0x2f, 0x49, 0xac, 0x30, 0x4a, 0x4f, 0x2c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, + 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x05, 0xcb, 0xeb, 0x41, + 0xe5, 0xf5, 0xa0, 0xf2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x15, 0xfa, 0x20, 0x16, 0x44, + 0xb1, 0x94, 0x5c, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x52, 0x62, 0x71, 0x2a, 0xdc, 0xa8, + 0xe4, 0xfc, 0xcc, 0x3c, 0x88, 0xbc, 0x92, 0x09, 0x17, 0xbb, 0x6f, 0x71, 0x7a, 0x48, 0x6a, 0x71, + 0x89, 0x90, 0x26, 0x17, 0x5b, 0x71, 0x6a, 0x5e, 0x4a, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, + 0xa7, 0x93, 0xe0, 0xa7, 0x7b, 0xf2, 0xbc, 0x95, 0x89, 0xb9, 0x39, 0x56, 0x4a, 0x10, 0x71, 0xa5, + 0x20, 0xa8, 0x02, 0x25, 0x41, 0x2e, 0x7e, 0xa8, 0xae, 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, + 0x54, 0xa3, 0x50, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0x21, 0x3f, 0x2e, 0x16, 0xb0, 0x61, 0x72, 0x7a, + 0x58, 0x5d, 0xa9, 0x07, 0xd5, 0x26, 0xa5, 0x86, 0x5f, 0x1e, 0x66, 0xac, 0x93, 0xd7, 0x89, 0x47, + 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, + 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x24, 0x16, 0x17, 0x67, 0x26, 0xeb, 0x42, 0x42, 0x2e, 0x39, + 0xbf, 0x28, 0x55, 0xbf, 0xcc, 0x58, 0xbf, 0x02, 0x1e, 0x86, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, + 0x6c, 0x60, 0x2f, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x43, 0x24, 0x93, 0xa8, 0x61, 0x01, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + Test(ctx context.Context, in *MsgTest, opts ...grpc.CallOption) (*MsgTestResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) Test(ctx context.Context, in *MsgTest, opts ...grpc.CallOption) (*MsgTestResponse, error) { + out := new(MsgTestResponse) + err := c.cc.Invoke(ctx, "/terra.tax2gas.v1beta1.Msg/Test", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + Test(context.Context, *MsgTest) (*MsgTestResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) Test(ctx context.Context, req *MsgTest) (*MsgTestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Test not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Test(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/terra.tax2gas.v1beta1.Msg/Test", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Test(ctx, req.(*MsgTest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "terra.tax2gas.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Test", + Handler: _Msg_Test_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "terra/tax2gas/v1beta1/tx.proto", +} + +func (m *MsgTest) 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 *MsgTest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTestResponse) 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 *MsgTestResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTestResponse) 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 *MsgTest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgTestResponse) 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 *MsgTest) 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: MsgTest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgTestResponse) 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: MsgTestResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTestResponse: 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") +)