forked from ComposableFi/picasso
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop2' of https://github.com/ComposableFi/composable…
…-cosmos into feat/sdk50 # Conflicts: # app/app.go # app/upgrades/v6_5_5/constants.go # app/upgrades/v6_6_4/upgrade.go # app/upgrades/v6_6_4/upgrades_test.go # bech32-migration/gov/gov.go # bech32-migration/ica/ica.go # custom/ibc-transfer/keeper/keeper.go # go.mod # go.sum # scripts/test-upgrade.sh # scripts/upgrade/init-deps.sh # scripts/upgrade/upgrade.sh # x/transfermiddleware/ibc_middleware.go
- Loading branch information
Showing
28 changed files
with
944 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package v6_5_5 | ||
|
||
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" | ||
) | ||
|
||
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) { | ||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package v6_6_1 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/notional-labs/composable/v6/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name for the composable upgrade. | ||
UpgradeName = "v6_6_1" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{}, | ||
Deleted: []string{}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package v6_6_1 | ||
|
||
import ( | ||
"github.com/CosmWasm/wasmd/x/wasm" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" | ||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types" | ||
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" | ||
ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types" | ||
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" | ||
|
||
"github.com/notional-labs/composable/v6/app/keepers" | ||
"github.com/notional-labs/composable/v6/app/upgrades" | ||
bech32authmigration "github.com/notional-labs/composable/v6/bech32-migration/auth" | ||
bech32govmigration "github.com/notional-labs/composable/v6/bech32-migration/gov" | ||
bech32IbcHooksMigration "github.com/notional-labs/composable/v6/bech32-migration/ibchooks" | ||
bench32ibctransfermiddleware "github.com/notional-labs/composable/v6/bech32-migration/ibctransfermiddleware" | ||
bech32icamigration "github.com/notional-labs/composable/v6/bech32-migration/ica" | ||
bech32mintmigration "github.com/notional-labs/composable/v6/bech32-migration/mint" | ||
bech32PfmMigration "github.com/notional-labs/composable/v6/bech32-migration/pfmmiddleware" | ||
bech32slashingmigration "github.com/notional-labs/composable/v6/bech32-migration/slashing" | ||
bech32stakingmigration "github.com/notional-labs/composable/v6/bech32-migration/staking" | ||
bech32transfermiddlewaremigration "github.com/notional-labs/composable/v6/bech32-migration/transfermiddleware" | ||
bech32WasmMigration "github.com/notional-labs/composable/v6/bech32-migration/wasm" | ||
transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
_ upgrades.BaseAppParamManager, | ||
codec codec.Codec, | ||
keepers *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
keys := keepers.GetKVStoreKey() | ||
// Migration prefix | ||
ctx.Logger().Info("First step: Migrate addresses stored in bech32 form to use new prefix") | ||
bech32stakingmigration.MigrateAddressBech32(ctx, keys[stakingtypes.StoreKey], codec) | ||
bech32stakingmigration.MigrateUnbonding(ctx, keys[stakingtypes.StoreKey], codec) | ||
bech32slashingmigration.MigrateAddressBech32(ctx, keys[slashingtypes.StoreKey], codec) | ||
bech32govmigration.MigrateAddressBech32(ctx, keys[govtypes.StoreKey], codec) | ||
bech32authmigration.MigrateAddressBech32(ctx, keys[authtypes.StoreKey], codec) | ||
bech32icamigration.MigrateAddressBech32(ctx, keys[icahosttypes.StoreKey], codec) | ||
bech32mintmigration.MigrateAddressBech32(ctx, keys[minttypes.StoreKey], codec) | ||
bech32transfermiddlewaremigration.MigrateAddressBech32(ctx, keys[transfermiddlewaretypes.StoreKey], codec) | ||
bech32WasmMigration.MigrateAddressBech32(ctx, keys[wasm.StoreKey], codec) | ||
bech32PfmMigration.MigrateAddressBech32(ctx, keys[routertypes.StoreKey], codec, keepers) | ||
bench32ibctransfermiddleware.MigrateAddressBech32(ctx, keys[ibctransfermiddlewaretypes.StoreKey], codec) | ||
bech32IbcHooksMigration.MigrateAddressBech32(ctx, keys[ibchookstypes.StoreKey], codec) | ||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package v6_6_2 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/notional-labs/composable/v6/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name for the composable upgrade. | ||
UpgradeName = "v6_6_2" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{}, | ||
Deleted: []string{}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package v6_6_2 | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types" | ||
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" | ||
|
||
"github.com/notional-labs/composable/v6/app/keepers" | ||
"github.com/notional-labs/composable/v6/app/upgrades" | ||
bech32IbcHooksMigration "github.com/notional-labs/composable/v6/bech32-migration/ibchooks" | ||
bench32ibctransfermiddleware "github.com/notional-labs/composable/v6/bech32-migration/ibctransfermiddleware" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
_ upgrades.BaseAppParamManager, | ||
codec codec.Codec, | ||
keepers *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
keys := keepers.GetKVStoreKey() | ||
// Migration prefix | ||
ctx.Logger().Info("First step: Migrate addresses stored in bech32 form to use new prefix") | ||
bench32ibctransfermiddleware.MigrateAddressBech32(ctx, keys[ibctransfermiddlewaretypes.StoreKey], codec) | ||
bech32IbcHooksMigration.MigrateAddressBech32(ctx, keys[ibchookstypes.StoreKey], codec) | ||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package v6_6_4 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/notional-labs/composable/v6/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name for the composable upgrade. | ||
UpgradeName = "v6_6_4" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{}, | ||
Deleted: []string{}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ibchooks | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/notional-labs/composable/v6/bech32-migration/utils" | ||
) | ||
|
||
func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) { | ||
ctx.Logger().Info("Migration of address bech32 for ibchooks module begin") | ||
totalAddr := uint64(0) | ||
store := ctx.KVStore(storeKey) | ||
channelKey := []byte("channel") | ||
iterator := sdk.KVStorePrefixIterator(store, channelKey) | ||
for ; iterator.Valid(); iterator.Next() { | ||
totalAddr++ | ||
fullKey := iterator.Key() | ||
contract := string(store.Get(fullKey)) | ||
contract = utils.SafeConvertAddress(contract) | ||
totalAddr++ | ||
store.Set(fullKey, []byte(contract)) | ||
} | ||
|
||
ctx.Logger().Info( | ||
"Migration of address bech32 for ibchooks module done", | ||
"totalAddr", totalAddr, | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
bech32-migration/ibctransfermiddleware/ibctransfermiddleware.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ibctransfermiddleware | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/notional-labs/composable/v6/bech32-migration/utils" | ||
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" | ||
) | ||
|
||
func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) { | ||
ctx.Logger().Info("Migration of address bech32 for ibctransfermiddleware module begin") | ||
totalAddr := uint64(0) | ||
store := ctx.KVStore(storeKey) | ||
bz := store.Get(types.ParamsKey) | ||
if bz == nil { | ||
return | ||
} | ||
var params types.Params | ||
cdc.MustUnmarshal(bz, ¶ms) | ||
for i := range params.ChannelFees { | ||
totalAddr++ | ||
params.ChannelFees[i].FeeAddress = utils.SafeConvertAddress(params.ChannelFees[i].FeeAddress) | ||
} | ||
bz = cdc.MustMarshal(¶ms) | ||
store.Set(types.ParamsKey, bz) | ||
|
||
ctx.Logger().Info( | ||
"Migration of address bech32 for ibctransfermiddleware module done", | ||
"totalAddr", totalAddr, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.