Skip to content

Commit

Permalink
feat: add feegrant, consortium and stakingplus module (#34)
Browse files Browse the repository at this point in the history
* build: bump up lbm-sdk

* feat: add x/feegrant

* build: bump up lbm-sdk

* feat: add x/consortium and x/stakingplus

* build: bump up lbm-sdk

* build: update go.sum
  • Loading branch information
0Tech authored Feb 4, 2022
1 parent 9d0e3ee commit 5433bb5
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 32 deletions.
72 changes: 61 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ import (
"github.com/line/lbm-sdk/x/capability"
capabilitykeeper "github.com/line/lbm-sdk/x/capability/keeper"
capabilitytypes "github.com/line/lbm-sdk/x/capability/types"
"github.com/line/lbm-sdk/x/consortium"
consortiumclient "github.com/line/lbm-sdk/x/consortium/client"
consortiumkeeper "github.com/line/lbm-sdk/x/consortium/keeper"
consortiumtypes "github.com/line/lbm-sdk/x/consortium/types"
"github.com/line/lbm-sdk/x/crisis"
crisiskeeper "github.com/line/lbm-sdk/x/crisis/keeper"
crisistypes "github.com/line/lbm-sdk/x/crisis/types"
Expand All @@ -54,6 +58,9 @@ import (
"github.com/line/lbm-sdk/x/evidence"
evidencekeeper "github.com/line/lbm-sdk/x/evidence/keeper"
evidencetypes "github.com/line/lbm-sdk/x/evidence/types"
"github.com/line/lbm-sdk/x/feegrant"
feegrantkeeper "github.com/line/lbm-sdk/x/feegrant/keeper"
feegranttypes "github.com/line/lbm-sdk/x/feegrant/types"
"github.com/line/lbm-sdk/x/genutil"
genutiltypes "github.com/line/lbm-sdk/x/genutil/types"
"github.com/line/lbm-sdk/x/gov"
Expand Down Expand Up @@ -81,6 +88,7 @@ import (
"github.com/line/lbm-sdk/x/staking"
stakingkeeper "github.com/line/lbm-sdk/x/staking/keeper"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
"github.com/line/lbm-sdk/x/stakingplus"
"github.com/line/lbm-sdk/x/upgrade"
upgradeclient "github.com/line/lbm-sdk/x/upgrade/client"
upgradekeeper "github.com/line/lbm-sdk/x/upgrade/keeper"
Expand Down Expand Up @@ -111,13 +119,23 @@ var (
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
consortium.AppModuleBasic{},
gov.NewAppModuleBasic(
append(wasmclient.ProposalHandlers, paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler)...,
),
append(
wasmclient.ProposalHandlers,
consortiumclient.UpdateConsortiumParamsProposalHandler,
consortiumclient.UpdateValidatorAuthsProposalHandler,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
)...
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
feegrant.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand Down Expand Up @@ -170,13 +188,15 @@ type LinkApp struct { // nolint: golint
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
ConsortiumKeeper consortiumkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
WasmKeeper wasm.Keeper

// make scoped keepers public for test purposes
Expand Down Expand Up @@ -215,10 +235,21 @@ func NewLinkApp(
bApp.SetInterfaceRegistry(interfaceRegistry)

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
authtypes.StoreKey,
banktypes.StoreKey,
stakingtypes.StoreKey,
minttypes.StoreKey,
distrtypes.StoreKey,
slashingtypes.StoreKey,
govtypes.StoreKey,
paramstypes.StoreKey,
ibchost.StoreKey,
upgradetypes.StoreKey,
evidencetypes.StoreKey,
ibctransfertypes.StoreKey,
capabilitytypes.StoreKey,
feegranttypes.StoreKey,
consortiumtypes.StoreKey,
wasm.StoreKey,
)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -267,7 +298,9 @@ func NewLinkApp(
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath)
app.ConsortiumKeeper = consortiumkeeper.NewKeeper(appCodec, keys[consortiumtypes.StoreKey], stakingKeeper)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
Expand Down Expand Up @@ -340,6 +373,7 @@ func NewLinkApp(
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(consortiumtypes.RouterKey, consortium.NewProposalHandler(app.ConsortiumKeeper)).
AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, wasm.EnableAllProposals))

app.GovKeeper = govkeeper.NewKeeper(
Expand Down Expand Up @@ -371,11 +405,13 @@ func NewLinkApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
consortium.NewAppModule(appCodec, app.ConsortiumKeeper, app.StakingKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
stakingplus.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsortiumKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
Expand All @@ -402,9 +438,21 @@ func NewLinkApp(
// wasm module should be a the end as it can call other modules functionality direct or via message dispatching during
// genesis phase. For example bank transfer, auth account check, staking, ...
app.mm.SetOrderInitGenesis(
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
feegranttypes.ModuleName,
consortiumtypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
)
Expand All @@ -421,6 +469,7 @@ func NewLinkApp(
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
Expand All @@ -444,7 +493,8 @@ func NewLinkApp(
app.SetBeginBlocker(app.BeginBlocker)
app.SetAnteHandler(
ante.NewAnteHandler(
app.AccountKeeper, app.BankKeeper, ante.DefaultSigVerificationGasConsumer,
app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper,
ante.DefaultSigVerificationGasConsumer,
encodingConfig.TxConfig.SignModeHandler(),
),
)
Expand Down
3 changes: 3 additions & 0 deletions app/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ const (
DefaultWeightCommunitySpendProposal int = 5
DefaultWeightTextProposal int = 5
DefaultWeightParamChangeProposal int = 5

DefaultWeightGrantAllowance int = 100
DefaultWeightRevokeAllowance int = 100
)
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.15

require (
github.com/gorilla/mux v1.8.0
github.com/line/lbm-sdk v1.0.0-init.1.0.20211112024221-e9ec7d238d4b
github.com/line/lbm-sdk v1.0.0-init.1.0.20211223043226-0e7b3cfe190c
github.com/line/ostracon v1.0.2
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210824011847-fcfa67dd3c70
github.com/line/tm-db/v2 v2.0.0-init.1.0.20211202001648-945e88fd2edf
github.com/prometheus/client_golang v1.11.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.9.0
github.com/spf13/cobra v1.3.0
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.7.0
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
)
Expand Down
Loading

0 comments on commit 5433bb5

Please sign in to comment.