Skip to content

Commit

Permalink
inject ibc keepers
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Jun 21, 2023
1 parent d1eed93 commit 706d4e4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
8 changes: 4 additions & 4 deletions ignite/templates/app/files/app/app.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ func New(
depinject.Supply(
// supply the application options
appOpts,
// ADVANCED CONFIGURATION

// ADVANCED CONFIGURATION
//
// AUTH
//
Expand Down Expand Up @@ -301,15 +301,15 @@ func New(

app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...)

// Register legacy modules
app.RegisterIBCModules()

// load state streaming if enabled
if _, _, err := streaming.LoadStreamingServices(app.App.BaseApp, appOpts, app.appCodec, logger, app.kvStoreKeys()); err != nil {
logger.Error("failed to load state streaming", "err", err)
os.Exit(1)
}

// Register legacy modules
app.RegisterIBCModules()

/**** Module Options ****/

app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,18 @@ func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Cap
// passes to it
func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error {
return k.scopedKeeper.ClaimCapability(ctx, cap, name)
}

// ScopedKeeper returns the ScopedKeeper
func (k Keeper) ScopedKeeper() exported.ScopedKeeper {
return k.scopedKeeper
}

// SetIBCKeepers set IBCKeepers for Keeper
func (k Keeper) SetIBCKeepers(
channelKeeper types.ChannelKeeper,
portKeeper types.PortKeeper,
) {
k.channelKeeper = channelKeeper
k.portKeeper = portKeeper
}<% } %>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
<%= if (isIBC) { %>porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"<% } %>
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"<% } %>

// this line is used by starport scaffolding # 1

Expand Down Expand Up @@ -194,8 +193,7 @@ type <%= title(moduleName) %>Inputs struct {
BankKeeper types.BankKeeper<%= for (dependency) in dependencies { %><%= if (dependency.Name != "Bank" && dependency.Name != "Account") { %>
<%= dependency.KeeperName() %> types.<%= dependency.KeeperName() %><% } %><% } %>

<%= if (isIBC) { %> CapabilityKeeper *capabilitykeeper.Keeper
// IBCKeeper *ibckeeper.Keeper<% } %>
<%= if (isIBC) { %> CapabilityKeeper *capabilitykeeper.Keeper<% } %>
}

type <%= title(moduleName) %>Outputs struct {
Expand All @@ -217,8 +215,8 @@ func ProvideModule(in <%= title(moduleName) %>Inputs) <%= title(moduleName) %>Ou
in.KvStoreKey,
in.MemStoreKey,
authority.String(), <%= if (isIBC) { %>
in.IBCKeeper.ChannelKeeper,
&in.IBCKeeper.PortKeeper,
nil,
nil,
scopedVoteKeeper,<% } %><%= for (dependency) in dependencies { %>
in.<%= dependency.KeeperName() %>,<% } %>
)
Expand Down
7 changes: 4 additions & 3 deletions ignite/templates/module/create/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,16 @@ func appIBCModify(replacer placeholder.Replacer, opts *CreateOptions) genny.RunF
}

// Import
templateImport := `%[2]vmodule "%[3]v/x/%[2]v"
%[2]vmoduletypes "%[3]v/x/%[2]v/types"
%[1]v`
templateImport := `%[1]v
%[2]vmodule "%[3]v/x/%[2]v"
%[2]vmoduletypes "%[3]v/x/%[2]v/types"`
replacementImport := fmt.Sprintf(templateImport, module.PlaceholderIBCImport, opts.ModuleName, opts.ModulePath)
content := replacer.Replace(f.String(), module.PlaceholderIBCImport, replacementImport)

// create IBC module
templateIBCModule := `%[2]vIBCModule := ibcfee.NewIBCMiddleware(%[2]vmodule.NewIBCModule(app.%[3]vKeeper), app.IBCFeeKeeper)
ibcRouter.AddRoute(%[2]vmoduletypes.ModuleName, %[2]vIBCModule)
app.%[3]vKeeper.SetIBCKeepers(app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper)
%[1]v`
replacementIBCModule := fmt.Sprintf(
templateIBCModule,
Expand Down

0 comments on commit 706d4e4

Please sign in to comment.