Skip to content

Commit

Permalink
add upgrade handler and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
StrathCole committed Oct 11, 2024
1 parent 254e6e2 commit 7a73828
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
v8_1 "github.com/classic-terra/core/v3/app/upgrades/v8_1"
v8_2 "github.com/classic-terra/core/v3/app/upgrades/v8_2"
v8_3 "github.com/classic-terra/core/v3/app/upgrades/v8_3"
v9 "github.com/classic-terra/core/v3/app/upgrades/v9"

customante "github.com/classic-terra/core/v3/custom/auth/ante"
custompost "github.com/classic-terra/core/v3/custom/auth/post"
Expand Down Expand Up @@ -91,6 +92,7 @@ var (
v8_1.Upgrade,
v8_2.Upgrade,
v8_3.Upgrade,
v9.Upgrade,
}

// Forks defines forks to be applied to the network
Expand Down
20 changes: 20 additions & 0 deletions app/upgrades/v9/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v9

import (
"github.com/classic-terra/core/v3/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"

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

const UpgradeName = "v9"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV9UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
tax2gastypes.ModuleName,
},
},
}
26 changes: 26 additions & 0 deletions app/upgrades/v9/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package v9

import (
"github.com/classic-terra/core/v3/app/keepers"
"github.com/classic-terra/core/v3/app/upgrades"
taxtypes "github.com/classic-terra/core/v3/x/tax/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateV9UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set default oracle split
keepers.TreasuryKeeper.SetTaxRate(ctx, sdk.ZeroDec())

tax2gasParams := taxtypes.DefaultParams()
keepers.TaxKeeper.SetParams(ctx, tax2gasParams)
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
2 changes: 1 addition & 1 deletion contrib/updates/prepare_cosmovisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# These fields should be fetched automatically in the future
# Need to do more upgrade to see upgrade patterns
OLD_VERSION=v3.1.3
OLD_VERSION=v3.1.6
# this command will retrieve the folder with the largest number in format v<number>
SOFTWARE_UPGRADE_NAME=$(ls -d -- ./app/upgrades/v* | sort -Vr | head -n 1 | xargs basename)
BUILDDIR=$1
Expand Down
6 changes: 3 additions & 3 deletions custom/auth/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFeesMultiSend() {
newCtx, err := antehandler(s.ctx, tx, false)
s.Require().NoError(err, "Decorator should not have errored on missing tax (reverse charge)")
s.Require().Equal(true, newCtx.Value(taxtypes.ContextKeyTaxReverseCharge).(bool))
//s.Require().Error(err, "Decorator should errored on low fee for local gasPrice + tax")
// s.Require().Error(err, "Decorator should errored on low fee for local gasPrice + tax")

// must pass with tax
s.txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, expectedTax.Add(expectedTax))))
Expand Down Expand Up @@ -802,7 +802,7 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec, oracleSplitRa
// Set burn split tax
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)
//taxRate := tk.GetTaxRate(s.ctx)
// taxRate := tk.GetTaxRate(s.ctx)

// Set community tax
dkParams := dk.GetParams(s.ctx)
Expand Down Expand Up @@ -842,7 +842,7 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdk.Dec, oracleSplitRa

// feeCollector := ak.GetModuleAccount(s.ctx, authtypes.FeeCollectorName)

//amountFeeBefore := bk.GetAllBalances(s.ctx, feeCollector.GetAddress())
// amountFeeBefore := bk.GetAllBalances(s.ctx, feeCollector.GetAddress())

totalSupplyBefore, _, err := bk.GetPaginatedTotalSupply(s.ctx, &query.PageRequest{})
require.NoError(err)
Expand Down

0 comments on commit 7a73828

Please sign in to comment.