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

refactor(x/ecocredit): migrate ecocredit server to submodules #995

Merged
merged 27 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3fa5ceb
wip: rewire
technicallyty Apr 6, 2022
181efd1
wip
technicallyty Apr 6, 2022
e7bd903
chore: revert double comment
technicallyty Apr 6, 2022
9293ad6
Merge branch 'master' into ty/728-integration_tests
technicallyty Apr 6, 2022
ff1b9e3
chore: imports
technicallyty Apr 6, 2022
3a4b4dc
chore: wip
technicallyty Apr 7, 2022
1aca726
Merge branch 'master' into ty/728-integration_tests
technicallyty Apr 7, 2022
c93651d
refactor: cleanup
technicallyty Apr 7, 2022
3c88f10
chore: switch genesis to only params
technicallyty Apr 7, 2022
396a756
chore: rename
technicallyty Apr 7, 2022
03c5db5
chore: revert genesis deletion
technicallyty Apr 7, 2022
2f89757
chore: imports
technicallyty Apr 7, 2022
5744a9c
chore: comment out genesis
technicallyty Apr 7, 2022
ff786e2
chore: revert genesis..again
technicallyty Apr 7, 2022
9533dc8
chore: cleanup genesis
technicallyty Apr 7, 2022
4139472
fix: make genesis work alongside legacy params
technicallyty Apr 7, 2022
c8066c4
chore: pause cli integration tests
technicallyty Apr 7, 2022
83afc5b
Merge branch 'master' into ty/728-integration_tests
technicallyty Apr 19, 2022
fbe185f
chore: cleanup server initialization
technicallyty Apr 19, 2022
c6e9a51
chore: uncomment blocks
technicallyty Apr 19, 2022
7d03ac6
Merge branch 'master' into ty/728-integration_tests
technicallyty Apr 20, 2022
8d1fb1f
chore: use core.MsgServer
technicallyty Apr 22, 2022
8cfdd55
Merge branch 'master' into ty/728-integration_tests
technicallyty Apr 22, 2022
22ba3c7
fix: require all ecocredit sub-servers
technicallyty Apr 22, 2022
e57bfed
Merge branch 'master' into ty/728-integration_tests
technicallyty Apr 25, 2022
72d20b3
chore: remove msg_server
technicallyty Apr 25, 2022
9d648bf
chore: fix merge conflicts
technicallyty Apr 25, 2022
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
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
app.BankKeeper,
app.DistrKeeper,
)

dataModule := data.NewModule(app.AccountKeeper, app.BankKeeper)
newModules := []moduletypes.Module{ecocreditModule, dataModule}
err := app.smm.RegisterModules(newModules)
Expand Down
5 changes: 2 additions & 3 deletions app/testsuite/modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"github.com/stretchr/testify/suite"

data "github.com/regen-network/regen-ledger/x/data/client/testsuite"
ecocredit "github.com/regen-network/regen-ledger/x/ecocredit/client/testsuite"
"github.com/regen-network/regen-ledger/x/ecocredit/client/testsuite"
)

func TestEcocreditIntegration(t *testing.T) {
technicallyty marked this conversation as resolved.
Show resolved Hide resolved
cfg := DefaultConfig()

ecocredit.RunCLITests(t, cfg)
testsuite.RunCLITests(t, cfg)
}

func TestDataIntegration(t *testing.T) {
Expand Down
15 changes: 8 additions & 7 deletions types/module/server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import (
"fmt"
"testing"

"github.com/regen-network/regen-ledger/types/testutil"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
"google.golang.org/grpc"

regentypes "github.com/regen-network/regen-ledger/types"
"github.com/regen-network/regen-ledger/types/module"
"github.com/regen-network/regen-ledger/types/testutil"
)

type FixtureFactory struct {
Expand Down
1 change: 0 additions & 1 deletion x/data/server/operations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package server


import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand Down
10 changes: 5 additions & 5 deletions x/ecocredit/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/spf13/cobra"
"google.golang.org/protobuf/reflect/protoreflect"

abci "github.com/tendermint/tendermint/abci/types"

sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -22,15 +24,13 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
abci "github.com/tendermint/tendermint/abci/types"

climodule "github.com/regen-network/regen-ledger/types/module/client/cli"
restmodule "github.com/regen-network/regen-ledger/types/module/client/grpc_gateway"
servermodule "github.com/regen-network/regen-ledger/types/module/server"
"github.com/regen-network/regen-ledger/x/ecocredit"
baskettypes "github.com/regen-network/regen-ledger/x/ecocredit/basket"
"github.com/regen-network/regen-ledger/x/ecocredit/client"
"github.com/regen-network/regen-ledger/x/ecocredit/core"
coretypes "github.com/regen-network/regen-ledger/x/ecocredit/core"
marketplacetypes "github.com/regen-network/regen-ledger/x/ecocredit/marketplace"
Comment on lines 32 to 35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use basket, core, and marketplace rather than adding types to each but ok to leave as is.

"github.com/regen-network/regen-ledger/x/ecocredit/server"
Expand All @@ -53,7 +53,7 @@ func NewModule(
distributionKeeper ecocredit.DistributionKeeper,
) *Module {
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(core.ParamKeyTable())
paramSpace = paramSpace.WithKeyTable(coretypes.ParamKeyTable())
}

return &Module{
Expand Down Expand Up @@ -107,7 +107,7 @@ func (a Module) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
}

params := coretypes.DefaultParams()
err = core.MergeParamsIntoTarget(cdc, &params, jsonTarget)
err = coretypes.MergeParamsIntoTarget(cdc, &params, jsonTarget)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func (a Module) ValidateGenesis(cdc codec.JSONCodec, _ sdkclient.TxEncodingConfi
return fmt.Errorf("failed to unmarshal %s params state: %w", ecocredit.ModuleName, err)
}

return core.ValidateGenesis(bz, params)
return coretypes.ValidateGenesis(bz, params)

}

Expand Down
17 changes: 4 additions & 13 deletions x/ecocredit/server/basket/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
ecoApi "github.com/regen-network/regen-ledger/api/regen/ecocredit/v1"
"github.com/regen-network/regen-ledger/x/ecocredit"
baskettypes "github.com/regen-network/regen-ledger/x/ecocredit/basket"

"github.com/cosmos/cosmos-sdk/orm/model/ormdb"
)

// Keeper is the basket keeper.
Expand All @@ -23,24 +21,17 @@ var _ baskettypes.QueryServer = Keeper{}

// NewKeeper returns a new keeper instance.
func NewKeeper(
db ormdb.ModuleDB,
ss api.StateStore,
cs ecoApi.StateStore,
bankKeeper ecocredit.BankKeeper,
distKeeper ecocredit.DistributionKeeper,
pk ecocredit.ParamKeeper,
) Keeper {
basketStore, err := api.NewStateStore(db)
if err != nil {
panic(err)
}
coreStore, err := ecoApi.NewStateStore(db)
if err != nil {
panic(err)
}
return Keeper{
bankKeeper: bankKeeper,
distKeeper: distKeeper,
stateStore: basketStore,
coreStore: coreStore,
stateStore: ss,
coreStore: cs,
paramsKeeper: pk,
}
}
3 changes: 2 additions & 1 deletion x/ecocredit/server/basket/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func setupBase(t gocuke.TestingT) *baseSuite {
s.bankKeeper = mocks2.NewMockBankKeeper(s.ctrl)
s.distKeeper = mocks2.NewMockDistributionKeeper(s.ctrl)
s.paramsKeeper = mocks2.NewMockParamKeeper(s.ctrl)
s.k = basket.NewKeeper(s.db, s.bankKeeper, s.distKeeper, s.paramsKeeper)

s.k = basket.NewKeeper(s.stateStore, s.coreStore, s.bankKeeper, s.distKeeper, s.paramsKeeper)
s.coreStore, err = ecoApi.NewStateStore(s.db)
assert.NilError(t, err)
_, _, s.addr = testdata.KeyTestPubAddr()
Expand Down
70 changes: 0 additions & 70 deletions x/ecocredit/server/credit_type.go

This file was deleted.

33 changes: 0 additions & 33 deletions x/ecocredit/server/fee.go

This file was deleted.

120 changes: 0 additions & 120 deletions x/ecocredit/server/helpers.go

This file was deleted.

Loading