Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrating fairyring/x/pep module #944

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ import (

sgappparams "github.com/public-awesome/stargaze/v13/app/params"
sgstatesync "github.com/public-awesome/stargaze/v13/internal/statesync"

pepmodule "github.com/Fairblock/fairyring/x/pep"
pepmodulekeeper "github.com/Fairblock/fairyring/x/pep/keeper"
pepmoduletypes "github.com/Fairblock/fairyring/x/pep/types"
)

const (
Expand Down Expand Up @@ -210,6 +214,7 @@ var (
ica.AppModuleBasic{},
ibchooks.AppModuleBasic{},
packetforward.AppModuleBasic{},
pepmodule.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -307,6 +312,9 @@ type App struct {
// IBC Packet Forward Middleware
PacketForwardKeeper *packetforwardkeeper.Keeper

ScopedPepKeeper capabilitykeeper.ScopedKeeper
PepKeeper pepmodulekeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// the module manager
Expand Down Expand Up @@ -350,11 +358,12 @@ func NewStargazeApp(
globalfeemoduletypes.StoreKey,
ibchookstypes.StoreKey,
packetforwardtypes.StoreKey,
pepmoduletypes.StoreKey,
crisistypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, pepmoduletypes.MemStoreKey)

app := &App{
BaseApp: bApp,
Expand Down Expand Up @@ -385,6 +394,7 @@ func NewStargazeApp(
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedPepKeeper := app.CapabilityKeeper.ScopeToModule(pepmoduletypes.ModuleName)
app.CapabilityKeeper.Seal()
// this line is used by starport scaffolding # stargate/app/scopedKeeper

Expand Down Expand Up @@ -561,11 +571,12 @@ func NewStargazeApp(
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

// Create static IBC router, add transfer route, then set and seal it

pepIBCModule := pepmodule.NewIBCModule(app.PepKeeper)
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferStack)
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(pepmoduletypes.ModuleName, pepIBCModule)

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

Expand Down Expand Up @@ -617,6 +628,18 @@ func NewStargazeApp(
wasmOpts...,
)

app.PepKeeper = *pepmodulekeeper.NewKeeper(
appCodec,
keys[pepmoduletypes.StoreKey],
keys[pepmoduletypes.MemStoreKey],
app.GetSubspace(pepmoduletypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedPepKeeper,
app.IBCKeeper.ConnectionKeeper,
app.BankKeeper,
)

// set the contract keeper for the Ics20WasmHooks
app.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)
app.Ics20WasmHooks.ContractKeeper = &app.WasmKeeper
Expand Down Expand Up @@ -714,6 +737,7 @@ func NewStargazeApp(
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
packetforward.NewAppModule(app.PacketForwardKeeper, app.GetSubspace(packetforwardtypes.ModuleName)),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
pepmodule.NewAppModule(appCodec, app.PepKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), encodingConfig.TxConfig, app.SimCheck),
// this line is used by starport scaffolding # stargate/app/appModule

crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
Expand All @@ -739,6 +763,7 @@ func NewStargazeApp(
ibchookstypes.ModuleName,
tokenfactorytypes.ModuleName,
packetforwardtypes.ModuleName,
pepmoduletypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand All @@ -757,6 +782,7 @@ func NewStargazeApp(
ibchookstypes.ModuleName,
tokenfactorytypes.ModuleName,
packetforwardtypes.ModuleName,
pepmoduletypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -791,6 +817,7 @@ func NewStargazeApp(
globalfeemoduletypes.ModuleName, // should be after wasm
ibchookstypes.ModuleName,
packetforwardtypes.ModuleName,
pepmoduletypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down Expand Up @@ -874,6 +901,7 @@ func NewStargazeApp(
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedIBCKeeper = scopedWasmKeeper
app.ScopedPepKeeper = scopedPepKeeper
// this line is used by starport scaffolding # stargate/app/beforeInitReturn
return app
}
Expand Down Expand Up @@ -1050,6 +1078,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(globalfeemoduletypes.ModuleName)
paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
paramsKeeper.Subspace(pepmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
17 changes: 12 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
require (
github.com/CosmWasm/wasmd v0.45.0
github.com/CosmWasm/wasmvm v1.5.2
github.com/Fairblock/fairyring v0.3.2
github.com/armon/go-metrics v0.4.1
github.com/cometbft/cometbft v0.37.4
github.com/cosmos/cosmos-proto v1.0.0-beta.4
Expand Down Expand Up @@ -46,16 +47,18 @@ require (
cosmossdk.io/log v1.3.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/tools/rosetta v0.2.1 // indirect
filippo.io/age v1.1.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/FairBlock/DistributedIBE v0.0.0-20230528025616-f58fb2b93eaf // indirect
github.com/aws/aws-sdk-go v1.44.203 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
Expand All @@ -74,12 +77,14 @@ require (
github.com/creachadair/taskgroup v0.4.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/drand/kyber v1.2.0 // indirect
github.com/drand/kyber-bls12381 v0.2.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
Expand All @@ -92,7 +97,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
Expand Down Expand Up @@ -126,10 +131,11 @@ require (
github.com/jhump/protoreflect v1.15.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.7.16 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -153,7 +159,7 @@ require (
github.com/rakyll/statik v0.1.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/rs/zerolog v1.32.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
Expand Down Expand Up @@ -194,6 +200,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 => github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3-0.20240228213828-cce7f56d000b
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
)
Loading
Loading