Skip to content

Commit

Permalink
feat: add x/token and x/collection (#138)
Browse files Browse the repository at this point in the history
* Add x/token and x/collection into app

* Update CHANGELOG.md

* Update app_test.go
  • Loading branch information
0Tech authored Feb 10, 2023
1 parent d3b82ce commit e2ee72c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/wasmd) [\#355](https://github.com/line/lbm/pull/355) chore: apply detached x/wasmd
* (build) [\#130](https://github.com/line/lbm/pull/130) Add a release build for the linux/arm64, darwin/amd64, and darwin/arm64 platform
* (lbm-sdk) [\#137](https://github.com/line/lbm/pull/137) Bump line/lbm-sdk to 6c84a4cffa
* (x/collection,token) [\#138](https://github.com/line/lbm/pull/138) Add x/token and x/collection

### Improvements

Expand Down
28 changes: 28 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ 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/collection"
collectionkeeper "github.com/line/lbm-sdk/x/collection/keeper"
collectionmodule "github.com/line/lbm-sdk/x/collection/module"
"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 Down Expand Up @@ -86,6 +89,11 @@ import (
stakingkeeper "github.com/line/lbm-sdk/x/staking/keeper"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
stakingplusmodule "github.com/line/lbm-sdk/x/stakingplus/module"
"github.com/line/lbm-sdk/x/token"
"github.com/line/lbm-sdk/x/token/class"
classkeeper "github.com/line/lbm-sdk/x/token/class/keeper"
tokenkeeper "github.com/line/lbm-sdk/x/token/keeper"
tokenmodule "github.com/line/lbm-sdk/x/token/module"
"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 @@ -135,6 +143,8 @@ var (
evidence.AppModuleBasic{},
authzmodule.AppModuleBasic{},
vesting.AppModuleBasic{},
tokenmodule.AppModuleBasic{},
collectionmodule.AppModuleBasic{},
wasm.AppModuleBasic{},
)

Expand Down Expand Up @@ -192,6 +202,9 @@ type LinkApp struct { // nolint: golint
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
ClassKeeper classkeeper.Keeper
TokenKeeper tokenkeeper.Keeper
CollectionKeeper collectionkeeper.Keeper
WasmKeeper wasm.Keeper

ScopedWasmKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -243,6 +256,9 @@ func NewLinkApp(
capabilitytypes.StoreKey,
feegrant.StoreKey,
foundation.StoreKey,
class.StoreKey,
token.StoreKey,
collection.StoreKey,
wasm.StoreKey,
)

Expand Down Expand Up @@ -308,6 +324,10 @@ func NewLinkApp(
foundationConfig := foundation.DefaultConfig()
app.FoundationKeeper = foundationkeeper.NewKeeper(appCodec, keys[foundation.StoreKey], app.BaseApp.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundationConfig, foundation.DefaultAuthority().String())

app.ClassKeeper = classkeeper.NewKeeper(appCodec, keys[class.StoreKey])
app.TokenKeeper = tokenkeeper.NewKeeper(appCodec, keys[token.StoreKey], app.ClassKeeper)
app.CollectionKeeper = collectionkeeper.NewKeeper(appCodec, keys[collection.StoreKey], app.ClassKeeper)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
Expand Down Expand Up @@ -406,6 +426,8 @@ func NewLinkApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
params.NewAppModule(app.ParamsKeeper),
tokenmodule.NewAppModule(appCodec, app.TokenKeeper),
collectionmodule.NewAppModule(appCodec, app.CollectionKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)

Expand All @@ -431,6 +453,8 @@ func NewLinkApp(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
token.ModuleName,
collection.ModuleName,
wasm.ModuleName,
)
app.mm.SetOrderEndBlockers(
Expand All @@ -451,6 +475,8 @@ func NewLinkApp(
upgradetypes.ModuleName,
vestingtypes.ModuleName,
foundation.ModuleName,
token.ModuleName,
collection.ModuleName,
wasm.ModuleName,
)

Expand Down Expand Up @@ -481,6 +507,8 @@ func NewLinkApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
token.ModuleName,
collection.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
)
Expand Down
3 changes: 3 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/line/lbm-sdk/x/bank"
banktypes "github.com/line/lbm-sdk/x/bank/types"
"github.com/line/lbm-sdk/x/capability"
collectionmodule "github.com/line/lbm-sdk/x/collection/module"
"github.com/line/lbm-sdk/x/crisis"
"github.com/line/lbm-sdk/x/distribution"
"github.com/line/lbm-sdk/x/evidence"
Expand Down Expand Up @@ -177,6 +178,7 @@ func TestRunMigrations(t *testing.T) {
"capability": capability.AppModule{}.ConsensusVersion(),
"foundation": foundationmodule.AppModule{}.ConsensusVersion(),
"token": tokenmodule.AppModule{}.ConsensusVersion(),
"collection": collectionmodule.AppModule{}.ConsensusVersion(),
},
)
if tc.expRunErr {
Expand Down Expand Up @@ -232,6 +234,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"capability": capability.AppModule{}.ConsensusVersion(),
"foundation": foundationmodule.AppModule{}.ConsensusVersion(),
"token": tokenmodule.AppModule{}.ConsensusVersion(),
"collection": collectionmodule.AppModule{}.ConsensusVersion(),
},
)

Expand Down

0 comments on commit e2ee72c

Please sign in to comment.