Skip to content

Commit

Permalink
- fix errors from sdk 0.47
Browse files Browse the repository at this point in the history
  • Loading branch information
StrathCole committed May 14, 2024
1 parent 285d562 commit 45eaff9
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 89 deletions.
2 changes: 1 addition & 1 deletion custom/auth/ante/fee_tax.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func FilterMsgAndComputeTax(ctx sdk.Context, te taxexemptionkeeper.Keeper, tk Tr
case *authz.MsgExec:
messages, err := msg.GetMessages()
if err == nil {
taxes = taxes.Add(FilterMsgAndComputeTax(ctx, tk, messages...)...)
taxes = taxes.Add(FilterMsgAndComputeTax(ctx, te, tk, messages...)...)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions x/taxexemption/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ $ %s tx gov submit-proposal add-tax-exemption-zone zonexyz terra1dczz24r33fwlj0q

sdkMsg := []sdk.Msg{&msg}

submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta))
submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta), proposalTitle, proposalDescr)
if err != nil {
return err
}
Expand Down Expand Up @@ -163,7 +163,7 @@ $ %s tx gov submit-proposal remove-tax-exemption-zone zonexyz --title "remove ta

sdkMsg := []sdk.Msg{&msg}

submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta))
submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta), proposalTitle, proposalDescr)
if err != nil {
return err
}
Expand Down Expand Up @@ -250,7 +250,7 @@ $ %s tx gov submit-proposal modify-tax-exemption-zone zonexyz --exempt-outgoing

sdkMsg := []sdk.Msg{&msg}

submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta))
submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta), proposalTitle, proposalDescr)
if err != nil {
return err
}
Expand Down Expand Up @@ -325,7 +325,7 @@ $ %s tx gov submit-proposal add-tax-exemption-address zonexyz terra1dczz24r33fwl

sdkMsg := []sdk.Msg{&msg}

submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta))
submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta), proposalTitle, proposalDescr)
if err != nil {
return err
}
Expand Down Expand Up @@ -396,7 +396,7 @@ $ %s tx gov submit-proposal remove-tax-exemption-address zonexyz terra1dczz24r33

sdkMsg := []sdk.Msg{&msg}

submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta))
submitMsg, err := govv1.NewMsgSubmitProposal(sdkMsg, deposit, clientCtx.GetFromAddress().String(), string(jsonMeta), proposalTitle, proposalDescr)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions x/taxexemption/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"fmt"

"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand All @@ -11,8 +12,6 @@ import (
accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/tendermint/tendermint/libs/log"

"github.com/classic-terra/core/v3/x/taxexemption/types"
)

Expand Down
2 changes: 1 addition & 1 deletion x/taxexemption/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/cometbft/cometbft/crypto/secp256k1"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down
17 changes: 0 additions & 17 deletions x/taxexemption/keeper/legacy_querier.go

This file was deleted.

62 changes: 23 additions & 39 deletions x/taxexemption/keeper/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,32 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/stretchr/testify/require"

customauth "github.com/classic-terra/core/v2/custom/auth"
custombank "github.com/classic-terra/core/v2/custom/bank"
customdistr "github.com/classic-terra/core/v2/custom/distribution"
customparams "github.com/classic-terra/core/v2/custom/params"
customstaking "github.com/classic-terra/core/v2/custom/staking"
core "github.com/classic-terra/core/v2/types"
"github.com/classic-terra/core/v2/x/market"
"github.com/classic-terra/core/v2/x/oracle"
simappparams "cosmossdk.io/simapp/params"
customauth "github.com/classic-terra/core/v3/custom/auth"
custombank "github.com/classic-terra/core/v3/custom/bank"
customdistr "github.com/classic-terra/core/v3/custom/distribution"
customparams "github.com/classic-terra/core/v3/custom/params"
customstaking "github.com/classic-terra/core/v3/custom/staking"
core "github.com/classic-terra/core/v3/types"
"github.com/classic-terra/core/v3/x/market"
"github.com/classic-terra/core/v3/x/oracle"
"github.com/classic-terra/core/v3/x/taxexemption/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/crypto/secp256k1"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp"
simparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
)
Expand All @@ -54,28 +51,15 @@ func MakeTestCodec(t *testing.T) codec.Codec {
return MakeEncodingConfig(t).Codec
}

func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := codectypes.NewInterfaceRegistry()
codec := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(codec, tx.DefaultSignModes)

std.RegisterInterfaces(interfaceRegistry)
std.RegisterLegacyAminoCodec(amino)

ModuleBasics.RegisterLegacyAminoCodec(amino)
ModuleBasics.RegisterInterfaces(interfaceRegistry)

return simparams.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: codec,
TxConfig: txCfg,
Amino: amino,
}
func MakeEncodingConfig(_ *testing.T) simappparams.EncodingConfig {
encodingConfig := simappparams.MakeTestEncodingConfig()
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}

var (
ValPubKeys = simapp.CreateTestPubKeys(5)
ValPubKeys = simtestutil.CreateTestPubKeys(5)

PubKeys = []crypto.PubKey{
secp256k1.GenPrivKey().PubKey(),
Expand Down Expand Up @@ -130,10 +114,10 @@ func CreateTestInput(t *testing.T) TestInput {
}

paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, keyParams, tKeyParams)
accountKeeper := authkeeper.NewAccountKeeper(appCodec, aKeyParams, paramsKeeper.Subspace(authtypes.ModuleName),
accountKeeper := authkeeper.NewAccountKeeper(appCodec, aKeyParams,
authtypes.ProtoBaseAccount,
maccPerms,
sdk.GetConfig().GetBech32AccountAddrPrefix())
sdk.GetConfig().GetBech32AccountAddrPrefix(), string(authtypes.NewModuleAddress(govtypes.ModuleName)))

taxexemptionKeeper := NewKeeper(appCodec,
keyTaxExemption, paramsKeeper.Subspace(types.ModuleName),
Expand Down
21 changes: 2 additions & 19 deletions x/taxexemption/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ package taxexemption
import (
"context"
"encoding/json"
"math/rand"

"github.com/classic-terra/core/v2/x/market/simulation"
"github.com/classic-terra/core/v3/x/market/simulation"
"github.com/classic-terra/core/v3/x/taxexemption/client/cli"
"github.com/classic-terra/core/v3/x/taxexemption/keeper"
"github.com/classic-terra/core/v3/x/taxexemption/types"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
abci "github.com/tendermint/tendermint/abci/types"
)

var (
Expand Down Expand Up @@ -112,11 +111,6 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
return nil
}

// LegacyQuerierHandler returns the taxexemption module sdk.Querier.
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return keeper.NewLegacyQuerier(am.keeper, legacyQuerierCdc)
}

// QuerierRoute returns the taxexemption module's querier route name.
func (AppModule) QuerierRoute() string { return types.QuerierRoute }

Expand All @@ -131,11 +125,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
}

// Route returns the message routing key for the taxexemption module.
func (am AppModule) Route() sdk.Route {
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
}

// GenerateGenesisState creates a randomized GenState of the taxexemption module.
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
}
Expand All @@ -146,12 +135,6 @@ func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.Weight
return []simtypes.WeightedProposalContent{}
}

// RandomizedParams creates randomized taxexemption param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
// workaround to make the sim work with staking module
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for taxexemption module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
5 changes: 0 additions & 5 deletions x/taxexemption/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ const (

func init() {
govv1beta1.RegisterProposalType(ProposalTypeAddTaxExemptionZone)
govv1beta1.ModuleCdc.LegacyAmino.RegisterConcrete(&AddTaxExemptionZoneProposal{}, "taxexemption/AddTaxExemptionZoneProposal", nil)
govv1beta1.RegisterProposalType(ProposalTypeRemoveTaxExemptionZone)
govv1beta1.ModuleCdc.LegacyAmino.RegisterConcrete(&RemoveTaxExemptionZoneProposal{}, "taxexemption/RemoveTaxExemptionZoneProposal", nil)
govv1beta1.RegisterProposalType(ProposalTypeModifyTaxExemptionZone)
govv1beta1.ModuleCdc.LegacyAmino.RegisterConcrete(&ModifyTaxExemptionZoneProposal{}, "taxexemption/ModifyTaxExemptionZoneProposal", nil)
govv1beta1.RegisterProposalType(ProposalTypeAddTaxExemptionAddress)
govv1beta1.ModuleCdc.LegacyAmino.RegisterConcrete(&AddTaxExemptionAddressProposal{}, "taxexemption/AddTaxExemptionAddressProposal", nil)
govv1beta1.RegisterProposalType(ProposalTypeRemoveTaxExemptionAddress)
govv1beta1.ModuleCdc.LegacyAmino.RegisterConcrete(&RemoveTaxExemptionAddressProposal{}, "taxexemption/RemoveTaxExemptionAddressProposal", nil)
}

var (
Expand Down

0 comments on commit 45eaff9

Please sign in to comment.