Skip to content

Commit

Permalink
feat!: integrate with ibc v10 rc.2
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Mar 2, 2025
1 parent 794456a commit 3f2509d
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 92 deletions.
2 changes: 0 additions & 2 deletions ignite/templates/app/files/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
icacontrollerkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/keeper"
icahostkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/keeper"
ibcfeekeeper "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
Expand Down Expand Up @@ -91,7 +90,6 @@ type App struct {

// ibc keepers
IBCKeeper *ibckeeper.Keeper
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
Expand Down
3 changes: 0 additions & 3 deletions ignite/templates/app/files/app/app_config.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import (
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"
ibcfeetypes "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
)
Expand All @@ -80,7 +79,6 @@ var (
{Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: nft.ModuleName},
{Account: ibctransfertypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: ibcfeetypes.ModuleName},
{Account: icatypes.ModuleName},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
Expand Down Expand Up @@ -165,7 +163,6 @@ var (
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
// chain modules
// this line is used by starport scaffolding # stargate/app/initGenesis
},
Expand Down
36 changes: 0 additions & 36 deletions ignite/templates/app/files/app/ibc.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import (
icahostkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v10/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v10/modules/apps/29-fee/types"
ibctransfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
Expand All @@ -40,7 +37,6 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
if err := app.RegisterStores(
storetypes.NewKVStoreKey(ibcexported.StoreKey),
storetypes.NewKVStoreKey(ibctransfertypes.StoreKey),
storetypes.NewKVStoreKey(ibcfeetypes.StoreKey),
storetypes.NewKVStoreKey(icahosttypes.StoreKey),
storetypes.NewKVStoreKey(icacontrollertypes.StoreKey),
); err != nil {
Expand All @@ -66,21 +62,11 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
govModuleAddr,
)

app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
app.appCodec,
runtime.NewKVStoreService(app.GetKey(ibcfeetypes.StoreKey)),
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
app.AuthKeeper,
app.BankKeeper,
)

// Create IBC transfer keeper
app.TransferKeeper = ibctransferkeeper.NewKeeper(
app.appCodec,
runtime.NewKVStoreService(app.GetKey(ibctransfertypes.StoreKey)),
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper,
app.IBCKeeper.ChannelKeeper,
app.AuthKeeper,
app.BankKeeper,
Expand All @@ -104,33 +90,13 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
app.appCodec,
runtime.NewKVStoreService(app.GetKey(icacontrollertypes.StoreKey)),
app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.MsgServiceRouter(),
govModuleAddr,
)

// Create IBC modules with ibcfee middleware
transferIBCModule := ibcfee.NewIBCMiddleware(ibctransfer.NewIBCModule(app.TransferKeeper), app.IBCFeeKeeper)

// integration point for custom authentication modules
icaControllerIBCModule := ibcfee.NewIBCMiddleware(
icacontroller.NewIBCMiddleware(app.ICAControllerKeeper),
app.IBCFeeKeeper,
)

icaHostIBCModule := ibcfee.NewIBCMiddleware(icahost.NewIBCModule(app.ICAHostKeeper), app.IBCFeeKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)

// this line is used by starport scaffolding # ibc/app/module

app.IBCKeeper.SetRouter(ibcRouter)

storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider()
tmLightClientModule := ibctm.NewLightClientModule(app.appCodec, storeProvider)
soloLightClientModule := solomachine.NewLightClientModule(app.appCodec, storeProvider)
Expand All @@ -139,7 +105,6 @@ func (app *App) registerIBCModules(appOpts servertypes.AppOptions) error {
if err := app.RegisterModules(
ibc.NewAppModule(app.IBCKeeper),
ibctransfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
icamodule.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
ibctm.NewAppModule(tmLightClientModule),
solomachine.NewAppModule(soloLightClientModule),
Expand All @@ -157,7 +122,6 @@ func RegisterIBC(cdc codec.Codec, registry cdctypes.InterfaceRegistry) map[strin
modules := map[string]appmodule.AppModule{
ibcexported.ModuleName: ibc.NewAppModule(&ibckeeper.Keeper{}),
ibctransfertypes.ModuleName: ibctransfer.NewAppModule(ibctransferkeeper.Keeper{}),
ibcfeetypes.ModuleName: ibcfee.NewAppModule(ibcfeekeeper.Keeper{}),
icatypes.ModuleName: icamodule.NewAppModule(&icacontrollerkeeper.Keeper{}, &icahostkeeper.Keeper{}),
ibctm.ModuleName: ibctm.NewAppModule(ibctm.NewLightClientModule(cdc, ibcclienttypes.StoreProvider{})),
solomachine.ModuleName: solomachine.NewAppModule(solomachine.NewLightClientModule(cdc, ibcclienttypes.StoreProvider{})),
Expand Down
6 changes: 1 addition & 5 deletions ignite/templates/app/files/go.mod.plush
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ module <%= ModulePath %>

go 1.23.6

replace (
github.com/cosmos/ibc-go/v10 => github.com/cosmos/ibc-go/v10 v10.0.0-beta.0
)

replace (
// fix upstream GHSA-h395-qcrw-5vmq vulnerability.
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
Expand Down Expand Up @@ -36,7 +32,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.12
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-go/v10 v10.0.0-beta.0
github.com/cosmos/ibc-go/v10 v10.0.0-rc.2
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down
4 changes: 1 addition & 3 deletions ignite/templates/module/create/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ func NewAppModify(replacer placeholder.Replacer, opts *CreateOptions) *genny.Gen
g := genny.New()
g.RunFn(appModify(replacer, opts))
g.RunFn(appConfigModify(replacer, opts))
if opts.IsIBC {
g.RunFn(appIBCModify(replacer, opts))
}

return g
}

Expand Down
42 changes: 0 additions & 42 deletions ignite/templates/module/create/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/protoanalysis/protoutil"
"github.com/ignite/cli/v29/ignite/pkg/xast"
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
"github.com/ignite/cli/v29/ignite/pkg/xstrings"
"github.com/ignite/cli/v29/ignite/templates/field/plushhelpers"
"github.com/ignite/cli/v29/ignite/templates/module"
)
Expand Down Expand Up @@ -200,44 +199,3 @@ PortID = "%[1]v"`
return r.File(newFile)
}
}

func appIBCModify(replacer placeholder.Replacer, opts *CreateOptions) genny.RunFn {
return func(r *genny.Runner) error {
path := filepath.Join(opts.AppPath, module.PathIBCConfigGo)
f, err := r.Disk.Find(path)
if err != nil {
return err
}

// Import
content, err := xast.AppendImports(
f.String(),
xast.WithLastNamedImport(
fmt.Sprintf("%[1]vmodule", opts.ModuleName),
fmt.Sprintf("%[1]v/x/%[2]v/module", opts.ModulePath, opts.ModuleName),
),
xast.WithLastNamedImport(
fmt.Sprintf("%[1]vmoduletypes", opts.ModuleName),
fmt.Sprintf("%[1]v/x/%[2]v/types", opts.ModulePath, opts.ModuleName),
),
)
if err != nil {
return err
}

// create IBC module
templateIBCModule := `%[2]vIBCModule := ibcfee.NewIBCMiddleware(%[2]vmodule.NewIBCModule(app.appCodec, app.%[3]vKeeper), app.IBCFeeKeeper)
ibcRouter.AddRoute(%[2]vmoduletypes.ModuleName, %[2]vIBCModule)
%[1]v`
replacementIBCModule := fmt.Sprintf(
templateIBCModule,
module.PlaceholderIBCNewModule,
opts.ModuleName,
xstrings.Title(opts.ModuleName),
)
content = replacer.Replace(content, module.PlaceholderIBCNewModule, replacementIBCModule)

newFile := genny.NewFileS(path, content)
return r.File(newFile)
}
}
1 change: 0 additions & 1 deletion ignite/templates/module/placeholders.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ const (
// Placeholders IBC
PlaceholderIBCKeysName = "// this line is used by starport scaffolding # ibc/keys/name"

Check failure on line 14 in ignite/templates/module/placeholders.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not properly formatted (gofumpt)
PlaceholderIBCKeysPort = "// this line is used by starport scaffolding # ibc/keys/port"
PlaceholderIBCNewModule = "// this line is used by starport scaffolding # ibc/app/module"
)

0 comments on commit 3f2509d

Please sign in to comment.