Skip to content

Commit

Permalink
V1.4.1 update.
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelkulpa committed Sep 4, 2024
1 parent 6269f35 commit 4247f5b
Showing 1 changed file with 72 additions and 61 deletions.
133 changes: 72 additions & 61 deletions app/upgrades/v141/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,74 +29,85 @@ func CreateUpgradeHandler(
appKeepers upgrades.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
for _, subspace := range appKeepers.GetC4eParamsKeeper().GetSubspaces() {
subspace := subspace
if mm.Modules["wasm"] == nil {
ctx.Logger().Info("wasm not exist")
for _, subspace := range appKeepers.GetC4eParamsKeeper().GetSubspaces() {
subspace := subspace

var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable()
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
case distrtypes.ModuleName:
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
case crisistypes.ModuleName:
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
// ibc types
case ibctransfertypes.ModuleName:
keyTable = ibctransfertypes.ParamKeyTable()
case icahosttypes.SubModuleName:
keyTable = icahosttypes.ParamKeyTable()
case icacontrollertypes.SubModuleName:
keyTable = icacontrollertypes.ParamKeyTable()
// wasm
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable() //nolint:staticcheck
default:
continue
}
var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable()
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
case distrtypes.ModuleName:
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
case crisistypes.ModuleName:
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
// ibc types
case ibctransfertypes.ModuleName:
keyTable = ibctransfertypes.ParamKeyTable()
case icahosttypes.SubModuleName:
keyTable = icahosttypes.ParamKeyTable()
case icacontrollertypes.SubModuleName:
keyTable = icacontrollertypes.ParamKeyTable()
// wasm
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable() //nolint:staticcheck
default:
continue
}

if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
}
}

baseAppLegacySS := appKeepers.GetC4eParamsKeeper().Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, appKeepers.GetC4eConsensusParamsKeeper())
vmResult, err := mm.RunMigrations(ctx, configurator, vm)
baseAppLegacySS := appKeepers.GetC4eParamsKeeper().Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, appKeepers.GetC4eConsensusParamsKeeper())
vmResult, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vmResult, err
}

// Set permission for uploading new Wasm code with specific addresses
wasmParams := wasmtypes.Params{
CodeUploadAccess: wasmtypes.AccessConfig{
Permission: wasmtypes.AccessTypeAnyOfAddresses,
Addresses: []string{
"c4e1r2ennr6ywv567lks3q5gujt4def726fe3t2tus",
"c4e1e0ddzmhw2ze2glszkgjk6tfvcfzv68cmnfrnaq",
"c4e19473sdmlkkvcdh6z3tqedtqsdqj4jjv7htsuaa",
"c4e1psaq0n2lzh84lzgh39kghuy0n256xltlcmea52",
"c4e1jr0ft7p2fgqxjrqxsakz9re0ae5499uz2cfmra",
"c4e1tw2crl23vluafhcvydhpnkejwth70y9knpsht7",
"c4e19x0fmrjnhqgze4c0c0st5jdpqgu3t4a2zn9t8r",
"c4e183f5fu67gagckux336kmjw75qw7dha5ycn5f6r",
"c4e10qfgech3v82uztzl20tl7uldsq8nk9gl92mm55",
"c4e16cwpandmj9np4huguzs32g0htm58p0cp9df8gj",
// Set permission for uploading new Wasm code with specific addresses
wasmParams := wasmtypes.Params{
CodeUploadAccess: wasmtypes.AccessConfig{
Permission: wasmtypes.AccessTypeAnyOfAddresses,
Addresses: []string{
"c4e1r2ennr6ywv567lks3q5gujt4def726fe3t2tus",
"c4e1e0ddzmhw2ze2glszkgjk6tfvcfzv68cmnfrnaq",
"c4e19473sdmlkkvcdh6z3tqedtqsdqj4jjv7htsuaa",
"c4e1psaq0n2lzh84lzgh39kghuy0n256xltlcmea52",
"c4e1jr0ft7p2fgqxjrqxsakz9re0ae5499uz2cfmra",
"c4e1tw2crl23vluafhcvydhpnkejwth70y9knpsht7",
"c4e19x0fmrjnhqgze4c0c0st5jdpqgu3t4a2zn9t8r",
"c4e183f5fu67gagckux336kmjw75qw7dha5ycn5f6r",
"c4e10qfgech3v82uztzl20tl7uldsq8nk9gl92mm55",
"c4e16cwpandmj9np4huguzs32g0htm58p0cp9df8gj",
},
},
},
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
}
err = appKeepers.GetWasmKeeper().SetParams(ctx, wasmParams)
if err != nil {
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
}

err = appKeepers.GetWasmKeeper().SetParams(ctx, wasmParams)
if err != nil {
return vmResult, err
}

return vmResult, nil

} else {
vmResult, err := mm.RunMigrations(ctx, configurator, vm)
return vmResult, err
}

return vmResult, nil
}
}

0 comments on commit 4247f5b

Please sign in to comment.