-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ica): ICA Host / Controller integration (#1820)
* ICA Host / Controller integration. Added upgrade constants. Added make format command * Fixed required message URLs * Code import fix * Fixed upgrade name * Fixed upgrade target * Changed version number * Update CHANGELOG.md --------- Co-authored-by: Jonathan Gimeno <[email protected]> Co-authored-by: Kevin Yang <[email protected]>
- Loading branch information
1 parent
6b7a97d
commit c60c806
Showing
5 changed files
with
124 additions
and
4 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
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
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,66 @@ | ||
package v1_3_0 | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/cosmos/cosmos-sdk/x/authz" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" | ||
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" | ||
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" | ||
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" | ||
|
||
"github.com/NibiruChain/nibiru/app/upgrades" | ||
) | ||
|
||
const UpgradeName = "v1.3.0" | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
// set the ICS27 consensus version so InitGenesis is not run | ||
fromVM[icatypes.ModuleName] = mm.GetVersionMap()[icatypes.ModuleName] | ||
|
||
// create ICS27 Controller submodule params, controller module not enabled. | ||
controllerParams := icacontrollertypes.Params{ | ||
ControllerEnabled: true, | ||
} | ||
|
||
// create ICS27 Host submodule params | ||
hostParams := icahosttypes.Params{ | ||
HostEnabled: true, | ||
AllowMessages: []string{ | ||
sdk.MsgTypeURL(&banktypes.MsgSend{}), | ||
sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), | ||
sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), | ||
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), | ||
sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), | ||
sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), | ||
sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), | ||
sdk.MsgTypeURL(&authz.MsgExec{}), | ||
sdk.MsgTypeURL(&authz.MsgGrant{}), | ||
sdk.MsgTypeURL(&authz.MsgRevoke{}), | ||
sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}), | ||
}, | ||
} | ||
|
||
// initialize ICS27 module | ||
icamodule, correctTypecast := mm.Modules[icatypes.ModuleName].(ica.AppModule) | ||
if !correctTypecast { | ||
panic("mm.Modules[icatypes.ModuleName] is not of type ica.AppModule") | ||
} | ||
icamodule.InitModule(ctx, controllerParams, hostParams) | ||
|
||
return mm.RunMigrations(ctx, cfg, fromVM) | ||
} | ||
}, | ||
StoreUpgrades: types.StoreUpgrades{ | ||
Added: []string{icacontrollertypes.StoreKey, icahosttypes.StoreKey}, | ||
}, | ||
} |
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,4 @@ | ||
format: | ||
@echo "--> Formating code and ordering imports" | ||
@goimports -local github.com/NibiruChain -w . | ||
@gofmt -w . |