Import interTx controller from cosmos/interchain-accounts

This commit is contained in:
Ethan Frey
2022-05-09 16:02:07 +02:00
parent 748d4f7c29
commit db195f610a
3 changed files with 26 additions and 15 deletions

View File

@@ -92,6 +92,9 @@ import (
porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
intertx "github.com/cosmos/interchain-accounts/x/inter-tx"
intertxkeeper "github.com/cosmos/interchain-accounts/x/inter-tx/keeper"
intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
@@ -200,6 +203,7 @@ var (
vesting.AppModuleBasic{},
wasm.AppModuleBasic{},
ica.AppModuleBasic{},
intertx.AppModuleBasic{},
)
// module account permissions
@@ -251,6 +255,7 @@ type WasmApp struct {
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
icaControllerKeeper icacontrollerkeeper.Keeper
icaHostKeeper icahostkeeper.Keeper
interTxKeeper intertxkeeper.Keeper
transferKeeper ibctransferkeeper.Keeper
feeGrantKeeper feegrantkeeper.Keeper
authzKeeper authzkeeper.Keeper
@@ -259,6 +264,7 @@ type WasmApp struct {
scopedIBCKeeper capabilitykeeper.ScopedKeeper
scopedICAHostKeeper capabilitykeeper.ScopedKeeper
scopedICAControllerKeeper capabilitykeeper.ScopedKeeper
scopedInterTxKeeper capabilitykeeper.ScopedKeeper
scopedTransferKeeper capabilitykeeper.ScopedKeeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper
@@ -300,7 +306,7 @@ func NewWasmApp(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, intertxtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
@@ -335,6 +341,7 @@ func NewWasmApp(
scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedICAHostKeeper := app.capabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.capabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedInterTxKeeper := app.capabilityKeeper.ScopeToModule(intertxtypes.ModuleName)
scopedTransferKeeper := app.capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.capabilityKeeper.ScopeToModule(wasm.ModuleName)
app.capabilityKeeper.Seal()
@@ -473,14 +480,11 @@ func NewWasmApp(
icaModule := ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.icaHostKeeper)
// FIXME: this came from PR #793, but I don't like testing "mocks" in a real app
// icaAuthModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp("", scopedICAMockKeeper))
// TODO: clarify how to build icaAuthModule or remove icaController support?
// See https://github.com/cosmos/ibc-go/blob/v3.0.0/docs/apps/interchain-accounts/integration.md
// "Note: No `icaauth` exists, this must be substituted with an actual Interchain Accounts authentication module"
var icaAuthModule porttypes.IBCModule
icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, icaAuthModule)
// Use the "official" demo controller from https://github.com/cosmos/interchain-accounts
app.interTxKeeper = intertxkeeper.NewKeeper(appCodec, keys[intertxtypes.StoreKey], app.icaControllerKeeper, scopedInterTxKeeper)
interTxModule := intertx.NewAppModule(appCodec, app.interTxKeeper)
interTxIBCModule := intertx.NewIBCModule(app.interTxKeeper)
icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, interTxIBCModule)
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
@@ -531,12 +535,8 @@ func NewWasmApp(
AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.ibcKeeper.ChannelKeeper)).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)
// FIXME: these are for ICA later
// AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack)
// AddRoute(ibcmock.ModuleName, mockIBCModule)
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(intertxtypes.ModuleName, icaControllerIBCModule)
app.ibcKeeper.SetRouter(ibcRouter)
app.govKeeper = govkeeper.NewKeeper(
@@ -581,6 +581,7 @@ func NewWasmApp(
params.NewAppModule(app.paramsKeeper),
transferModule,
icaModule,
interTxModule,
crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them
)
@@ -609,6 +610,7 @@ func NewWasmApp(
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
intertxtypes.ModuleName,
wasm.ModuleName,
)
@@ -633,6 +635,7 @@ func NewWasmApp(
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
intertxtypes.ModuleName,
wasm.ModuleName,
)
@@ -664,6 +667,7 @@ func NewWasmApp(
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
intertxtypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
)
@@ -745,6 +749,7 @@ func NewWasmApp(
app.scopedWasmKeeper = scopedWasmKeeper
app.scopedICAHostKeeper = scopedICAHostKeeper
app.scopedICAControllerKeeper = scopedICAControllerKeeper
app.scopedInterTxKeeper = scopedInterTxKeeper
if loadLatest {
if err := app.LoadLatestVersion(); err != nil {

1
go.mod
View File

@@ -7,6 +7,7 @@ require (
github.com/cosmos/cosmos-sdk v0.45.4
github.com/cosmos/iavl v0.17.3
github.com/cosmos/ibc-go/v3 v3.0.0
github.com/cosmos/interchain-accounts v0.1.0
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2

5
go.sum
View File

@@ -1,3 +1,4 @@
bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8=
bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -209,6 +210,7 @@ github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8
github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM=
github.com/containerd/continuity v0.2.1 h1:/EeEo2EtN3umhbbgCveyjifoMYg0pS+nMMEemaYw634=
github.com/containerd/continuity v0.2.1/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@@ -236,6 +238,8 @@ github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y=
github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w=
github.com/cosmos/ibc-go/v3 v3.0.0 h1:XUNplHVS51Q2gMnTFsFsH9QJ7flsovMamnltKbEgPQ4=
github.com/cosmos/ibc-go/v3 v3.0.0/go.mod h1:Mb+1NXiPOLd+CPFlOC6BKeAUaxXlhuWenMmRiUiSmwY=
github.com/cosmos/interchain-accounts v0.1.0 h1:QmuwNsf1Hxl3P5GSGt7Z+JeuHPiZw4Z34R/038P5T6s=
github.com/cosmos/interchain-accounts v0.1.0/go.mod h1:Fv6LXDs+0ng4mIDVWwEJMXbAIMxY4kiq+A7Bw1Fb9AY=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
@@ -1335,6 +1339,7 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=