Skip to content

Commit

Permalink
Merge pull request #474 from ComposableFi/rustdev/upgrade-handler-v6.5.0
Browse files Browse the repository at this point in the history
add chain upgrade handler v6.5.0
  • Loading branch information
RustNinja authored Mar 26, 2024
2 parents 6bef6f9 + ef1cfd5 commit 40b1a4d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"

"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades/v6_4_91"
"github.com/notional-labs/composable/v6/app/upgrades/v6_5_0"

// bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

Expand Down Expand Up @@ -147,7 +147,7 @@ var (
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v6_4_91.Upgrade}
Upgrades = []upgrades.Upgrade{v6_5_0.Upgrade}
Forks = []upgrades.Fork{}
)

Expand Down
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
"centauri1r2zlh2xn85v8ljmwymnfrnsmdzjl7k6w6lytan",
"centauri10556m38z4x6pqalr9rl5ytf3cff8q46nk85k9m",

"centauri1wkjvpgkuchq0r8425g4z4sf6n85zj5wtmqzjv9",
// "centauri1wkjvpgkuchq0r8425g4z4sf6n85zj5wtmqzjv9",

// "centauri1hj5fveer5cjtn4wd6wstzugjfdxzl0xpzxlwgs",
})
Expand Down
21 changes: 21 additions & 0 deletions app/upgrades/v6_5_0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package v6_5_0

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/notional-labs/composable/v6/app/upgrades"
ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

const (
// UpgradeName defines the on-chain upgrade name for the composable upgrade.
UpgradeName = "v6_5_0"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{ibctransfermiddleware.StoreKey},
Deleted: []string{},
},
}
47 changes: 47 additions & 0 deletions app/upgrades/v6_5_0/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package v6_5_0

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades"
ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
_ codec.Codec,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
custommiddlewareparams := ibctransfermiddleware.DefaultGenesisState()
keepers.IbcTransferMiddlewareKeeper.SetParams(ctx, custommiddlewareparams.Params)

// remove broken proposals
BrokenProposals := [3]uint64{2, 6, 11}
for _, proposal_id := range BrokenProposals {
_, ok := keepers.GovKeeper.GetProposal(ctx, proposal_id)
if ok {
keepers.GovKeeper.DeleteProposal(ctx, proposal_id)
}

}

// burn extra ppica in escrow account
// this ppica is unused because it is a native token stored in escrow account
// it was unnecessarily minted to match pica escrowed on picasso to ppica minted
// in genesis, to make initial native ppica transferrable to picasso
amount, ok := sdk.NewIntFromString("1066669217167120000000")
if ok {
coins := sdk.Coins{sdk.NewCoin("ppica", amount)}
keepers.BankKeeper.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32("centauri12k2pyuylm9t7ugdvz67h9pg4gmmvhn5vmvgw48"), "gov", coins)
keepers.BankKeeper.BurnCoins(ctx, "gov", coins)
}
return mm.RunMigrations(ctx, configurator, vm)
}
}

0 comments on commit 40b1a4d

Please sign in to comment.