Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitelisting (tax exemption) feature according to prop #11824 #388

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func NewTerraApp(
FeegrantKeeper: app.FeeGrantKeeper,
OracleKeeper: app.OracleKeeper,
TreasuryKeeper: app.TreasuryKeeper,
TaxExemptionKeeper: app.TaxExemptionKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
IBCKeeper: *app.IBCKeeper,
Expand Down
10 changes: 10 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import (
markettypes "github.com/classic-terra/core/v2/x/market/types"
oraclekeeper "github.com/classic-terra/core/v2/x/oracle/keeper"
oracletypes "github.com/classic-terra/core/v2/x/oracle/types"
taxexemptionkeeper "github.com/classic-terra/core/v2/x/taxexemption/keeper"
taxexemptiontypes "github.com/classic-terra/core/v2/x/taxexemption/types"
treasurykeeper "github.com/classic-terra/core/v2/x/treasury/keeper"
treasurytypes "github.com/classic-terra/core/v2/x/treasury/types"
)
Expand Down Expand Up @@ -93,6 +95,7 @@ type AppKeepers struct {
OracleKeeper oraclekeeper.Keeper
MarketKeeper marketkeeper.Keeper
TreasuryKeeper treasurykeeper.Keeper
TaxExemptionKeeper taxexemptionkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
DyncommKeeper dyncommkeeper.Keeper

Expand Down Expand Up @@ -139,6 +142,7 @@ func NewAppKeepers(
oracletypes.StoreKey,
markettypes.StoreKey,
treasurytypes.StoreKey,
taxexemptiontypes.StoreKey,
wasmtypes.StoreKey,
dyncommtypes.StoreKey,
)
Expand Down Expand Up @@ -340,6 +344,10 @@ func NewAppKeepers(
appKeepers.StakingKeeper, appKeepers.DistrKeeper,
&appKeepers.WasmKeeper, distrtypes.ModuleName,
)
appKeepers.TaxExemptionKeeper = taxexemptionkeeper.NewKeeper(
appCodec, appKeepers.keys[taxexemptiontypes.StoreKey],
appKeepers.GetSubspace(taxexemptiontypes.ModuleName),
)

wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
Expand All @@ -352,6 +360,7 @@ func NewAppKeepers(
appKeepers.IBCKeeper.ChannelKeeper,
scopedWasmKeeper,
appKeepers.BankKeeper,
appKeepers.TaxExemptionKeeper,
appKeepers.TreasuryKeeper,
appKeepers.AccountKeeper,
appCodec,
Expand Down Expand Up @@ -451,6 +460,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(markettypes.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(taxexemptiontypes.ModuleName)
paramsKeeper.Subspace(treasurytypes.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(dyncommtypes.ModuleName)
Expand Down
14 changes: 14 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ import (
markettypes "github.com/classic-terra/core/v2/x/market/types"
"github.com/classic-terra/core/v2/x/oracle"
oracletypes "github.com/classic-terra/core/v2/x/oracle/types"
"github.com/classic-terra/core/v2/x/taxexemption"
taxexemptionclient "github.com/classic-terra/core/v2/x/taxexemption/client"
taxexemptiontypes "github.com/classic-terra/core/v2/x/taxexemption/types"
"github.com/classic-terra/core/v2/x/treasury"
treasuryclient "github.com/classic-terra/core/v2/x/treasury/client"
treasurytypes "github.com/classic-terra/core/v2/x/treasury/types"
Expand Down Expand Up @@ -106,6 +109,11 @@ var (
ibcclientclient.UpgradeProposalHandler,
treasuryclient.ProposalAddBurnTaxExemptionAddressHandler,
treasuryclient.ProposalRemoveBurnTaxExemptionAddressHandler,
taxexemptionclient.ProposalAddTaxExemptionZoneHandler,
taxexemptionclient.ProposalRemoveTaxExemptionZoneHandler,
taxexemptionclient.ProposalModifyTaxExemptionZoneHandler,
taxexemptionclient.ProposalAddTaxExemptionAddressHandler,
taxexemptionclient.ProposalRemoveTaxExemptionAddressHandler,
),
),
customparams.AppModuleBasic{},
Expand All @@ -121,6 +129,7 @@ var (
oracle.AppModuleBasic{},
market.AppModuleBasic{},
treasury.AppModuleBasic{},
taxexemption.AppModuleBasic{},
customwasm.AppModuleBasic{},
ibcfee.AppModuleBasic{},
dyncomm.AppModuleBasic{},
Expand Down Expand Up @@ -184,6 +193,7 @@ func appModules(
market.NewAppModule(appCodec, app.MarketKeeper, app.AccountKeeper, app.BankKeeper, app.OracleKeeper),
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
treasury.NewAppModule(appCodec, app.TreasuryKeeper),
taxexemption.NewAppModule(appCodec, app.TaxExemptionKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
dyncomm.NewAppModule(appCodec, app.DyncommKeeper, app.StakingKeeper),
}
Expand Down Expand Up @@ -216,6 +226,7 @@ func simulationModules(
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
market.NewAppModule(appCodec, app.MarketKeeper, app.AccountKeeper, app.BankKeeper, app.OracleKeeper),
treasury.NewAppModule(appCodec, app.TreasuryKeeper),
taxexemption.NewAppModule(appCodec, app.TaxExemptionKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
dyncomm.NewAppModule(appCodec, app.DyncommKeeper, app.StakingKeeper),
}
Expand Down Expand Up @@ -246,6 +257,7 @@ func orderBeginBlockers() []string {
// Terra Classic modules
oracletypes.ModuleName,
treasurytypes.ModuleName,
taxexemptiontypes.ModuleName,
markettypes.ModuleName,
wasmtypes.ModuleName,
dyncommtypes.ModuleName,
Expand Down Expand Up @@ -277,6 +289,7 @@ func orderEndBlockers() []string {
// Terra Classic modules
oracletypes.ModuleName,
treasurytypes.ModuleName,
taxexemptiontypes.ModuleName,
markettypes.ModuleName,
wasmtypes.ModuleName,
dyncommtypes.ModuleName,
Expand Down Expand Up @@ -309,6 +322,7 @@ func orderInitGenesis() []string {
markettypes.ModuleName,
oracletypes.ModuleName,
treasurytypes.ModuleName,
taxexemptiontypes.ModuleName,
wasmtypes.ModuleName,
dyncommtypes.ModuleName,
}
Expand Down
19 changes: 19 additions & 0 deletions app/upgrades/v7/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v6

import (
"github.com/classic-terra/core/v2/app/upgrades"
taxexemptiontypes "github.com/classic-terra/core/v2/x/taxexemption/types"
store "github.com/cosmos/cosmos-sdk/store/types"
)

const UpgradeName = "v7"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV7UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
taxexemptiontypes.StoreKey,
},
},
}
41 changes: 41 additions & 0 deletions app/upgrades/v7/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package v6

import (
"github.com/classic-terra/core/v2/app/keepers"
"github.com/classic-terra/core/v2/app/upgrades"
treasurytypes "github.com/classic-terra/core/v2/x/treasury/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateV7UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
k *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(c sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// migrate old treasurykeeper tax exemption to new tax exemption keeper
// tax exemption keeper is now a module

// get old tax exemption keeper
sub := prefix.NewStore(c.KVStore(k.TreasuryKeeper.GetStoreKey()), treasurytypes.BurnTaxExemptionListPrefix)

intoZone := "Binance"

// iterate through all tax exemptions
iterator := sub.Iterator(nil, nil)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
// get tax exemption address
address := string(iterator.Key())

// add tax exemption address to new tax exemption keeper
k.TaxExemptionKeeper.AddTaxExemptionAddress(c, intoZone, address)
}

return mm.RunMigrations(c, cfg, fromVM)
}
}
8 changes: 8 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@
}
}
},
{
"url": "./tmp-swagger-gen/terra/taxexemption/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "TaxExemptionParams"
}
}
},
{
"url": "./tmp-swagger-gen/terra/dyncomm/v1beta1/query.swagger.json",
"operationIds": {
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading
Loading