Skip to content

Commit

Permalink
Add PFM to spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzampolin committed Feb 19, 2024
1 parent a849e02 commit 3e97cb1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
43 changes: 38 additions & 5 deletions simapp/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ import (
globalfee "github.com/reecepbcups/globalfee/x/globalfee"
globalfeekeeper "github.com/reecepbcups/globalfee/x/globalfee/keeper"
globalfeetypes "github.com/reecepbcups/globalfee/x/globalfee/types"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/types"
)

const appName = "CosmWasmApp"
Expand Down Expand Up @@ -242,10 +246,11 @@ type ChainApp struct {
TransferKeeper ibctransferkeeper.Keeper

// Custom
WasmKeeper wasmkeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper
POAKeeper poakeeper.Keeper
GlobalFeeKeeper globalfeekeeper.Keeper
WasmKeeper wasmkeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper
POAKeeper poakeeper.Keeper
GlobalFeeKeeper globalfeekeeper.Keeper
PacketForwardKeeper *packetforwardkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -334,6 +339,7 @@ func NewChainApp(
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)

bApp.SetTxEncoder(txConfig.TxEncoder())

keys := storetypes.NewKVStoreKeys(
Expand All @@ -355,6 +361,7 @@ func NewChainApp(
tokenfactorytypes.StoreKey,
poa.StoreKey,
globalfeetypes.StoreKey,
packetforwardtypes.StoreKey,
)

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -598,6 +605,18 @@ func NewChainApp(
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

// Create the packetfoward keeper
app.PacketForwardKeeper = packetforwardkeeper.NewKeeper(
appCodec,
keys[packetforwardtypes.StoreKey],
nil, // will be zero-value here, reference is set later on with SetTransferKeeper.
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Create the globalfee keeper
app.GlobalFeeKeeper = globalfeekeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -644,7 +663,7 @@ func NewChainApp(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
Expand All @@ -653,6 +672,8 @@ func NewChainApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
Expand Down Expand Up @@ -712,6 +733,13 @@ func NewChainApp(
var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
transferStack = packetforward.NewIBCMiddleware(
transferStack,
app.PacketForwardKeeper,
0, // retries on timeout
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout
)

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
Expand Down Expand Up @@ -786,6 +814,7 @@ func NewChainApp(
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
poamodule.NewAppModule(appCodec, app.POAKeeper),
globalfee.NewAppModule(appCodec, app.GlobalFeeKeeper),
packetforward.NewAppModule(app.PacketForwardKeeper, app.GetSubspace(packetforwardtypes.ModuleName)),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -831,6 +860,7 @@ func NewChainApp(
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
packetforwardtypes.ModuleName,
)

app.ModuleManager.SetOrderEndBlockers(
Expand All @@ -849,6 +879,7 @@ func NewChainApp(
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
packetforwardtypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -876,6 +907,7 @@ func NewChainApp(
poa.ModuleName,
tokenfactorytypes.ModuleName,
globalfeetypes.ModuleName,
packetforwardtypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1298,6 +1330,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(tokenfactorytypes.ModuleName)
paramsKeeper.Subspace(poa.ModuleName)
paramsKeeper.Subspace(globalfee.ModuleName)
paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())

return paramsKeeper
}
2 changes: 2 additions & 0 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.0.1 // indirect
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/creachadair/atomicfile v0.3.1 // indirect
Expand Down Expand Up @@ -151,6 +152,7 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@ github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR
github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y=
github.com/cosmos/iavl v1.0.1 h1:D+mYbcRO2wptYzOM1Hxl9cpmmHU1ZEt9T2Wv5nZTeUw=
github.com/cosmos/iavl v1.0.1/go.mod h1:8xIUkgVvwvVrBu81scdPty+/Dx9GqwHnAvXz4cwF7RY=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0 h1:PqaYuNJDpeqisP3Td5djrvFhuVMnOIWFJeqMJuZPRas=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.0/go.mod h1:82hPO/tRawbuFad2gPwChvpZ0JEIoNi91LwVneAYCeM=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
github.com/cosmos/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg=
Expand Down Expand Up @@ -1355,6 +1357,8 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
Expand Down

0 comments on commit 3e97cb1

Please sign in to comment.