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 abci to module and clean up module #1452

Merged
merged 5 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1337](https://github.com/regen-network/regen-ledger/pull/1337) The `AddCreditType` proposal handler has been removed.
- [#1342](https://github.com/regen-network/regen-ledger/pull/1342) The `NewKeeper` method in `ecocredit/marketplace` requires an `authority` address.
- [#1342](https://github.com/regen-network/regen-ledger/pull/1342) The `AllowedDenom` proposal handler has been removed.

- [#1452](https://github.com/regen-network/regen-ledger/pull/1452) The `NewModule` method in `ecocredit/module` requires an `authority` address and store `key`.
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it might be better to describe what the breaking change was (position of args changed), i was confused at first thinking "i thought we already required those things" 🤔

Copy link
Member Author

@ryanchristo ryanchristo Sep 1, 2022

Choose a reason for hiding this comment

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

These are new since the last release and not recorded anywhere else in the change log.

Copy link
Member Author

Choose a reason for hiding this comment

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

Was not sure whether I should retroactively fix or just add a new entry and went with the latter.

Copy link
Contributor

Choose a reason for hiding this comment

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

works for me 👍🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

I was being lazy. I updated the changelog. No entry for changing the order necessary though if these are new. Added the two pull requests for when they were added. 👍


#### Added

- [#1337](https://github.com/regen-network/regen-ledger/pull/1342) Add `AddAllowedDenom` msg-based gov proposal
- [#1337](https://github.com/regen-network/regen-ledger/pull/1337) Add `AddAllowedDenom` msg-based gov proposal
- [#1337](https://github.com/regen-network/regen-ledger/pull/1337) Add `AddCreditType` msg-based gov proposal
- [#1346](https://github.com/regen-network/regen-ledger/pull/1346) Add `RemoveAllowedDenom` msg-based gov proposal
- [#1349](https://github.com/regen-network/regen-ledger/pull/1349) Add `UpdateBasketFees` msg-based gov proposal
Expand All @@ -94,7 +94,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1423](https://github.com/regen-network/regen-ledger/pull/1423) Add `CreditClassAllowlistEnabled` params query
- [#1450](https://github.com/regen-network/regen-ledger/pull/1450) Add `QueryBalancesByBatch` query


#### Changed

- [#1362](https://github.com/regen-network/regen-ledger/pull/1362) Update `Batch` state validation checks
Expand Down Expand Up @@ -129,6 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1429](https://github.com/regen-network/regen-ledger/pull/1429) Migrated `ecocredit/client` core commands to `ecocredit/base/client`
- [#1429](https://github.com/regen-network/regen-ledger/pull/1429) Migrated `ecocredit/server/core` to `ecocredit/base/keeper`
- [#1429](https://github.com/regen-network/regen-ledger/pull/1429) Migrated `ecocredit/simulation` core operations to `ecocredit/base/simulation`
- [#1452](https://github.com/regen-network/regen-ledger/pull/1452) Migrated `BeginBlocker` to `ecocredit/module`

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
// register custom modules here
ecocreditMod := ecocreditmodule.NewModule(
app.keys[ecocredit.ModuleName],
app.GetSubspace(ecocredit.DefaultParamspace),
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName),
app.GetSubspace(ecocredit.DefaultParamspace),
)
dataMod := datamodule.NewModule(app.keys[data.ModuleName], app.AccountKeeper, app.BankKeeper)

Expand Down
6 changes: 4 additions & 2 deletions x/ecocredit/base/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
types "github.com/regen-network/regen-ledger/x/ecocredit/base/types/v1"
)

var _ types.MsgServer = &Keeper{}
var _ types.QueryServer = &Keeper{}
var (
_ types.MsgServer = &Keeper{}
_ types.QueryServer = &Keeper{}
)

type Keeper struct {
stateStore api.StateStore
Expand Down
8 changes: 5 additions & 3 deletions x/ecocredit/basket/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
types "github.com/regen-network/regen-ledger/x/ecocredit/basket/types/v1"
)

var (
_ types.MsgServer = Keeper{}
_ types.QueryServer = Keeper{}
)

// Keeper is the basket keeper.
type Keeper struct {
stateStore api.StateStore
Expand All @@ -19,9 +24,6 @@ type Keeper struct {
authority sdk.AccAddress
}

var _ types.MsgServer = Keeper{}
var _ types.QueryServer = Keeper{}

// NewKeeper returns a new keeper instance.
func NewKeeper(
ss api.StateStore,
Expand Down
8 changes: 5 additions & 3 deletions x/ecocredit/marketplace/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
types "github.com/regen-network/regen-ledger/x/ecocredit/marketplace/types/v1"
)

var (
_ types.MsgServer = Keeper{}
_ types.QueryServer = Keeper{}
)

type Keeper struct {
stateStore marketapi.StateStore
coreStore ecoApi.StateStore
Expand All @@ -27,6 +32,3 @@ func NewKeeper(ss marketapi.StateStore, cs ecoApi.StateStore, bk ecocredit.BankK
authority: authority,
}
}

var _ types.MsgServer = Keeper{}
var _ types.QueryServer = Keeper{}
7 changes: 4 additions & 3 deletions x/ecocredit/server/abci.go → x/ecocredit/module/abci.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package module

import (
"time"
Expand All @@ -7,10 +7,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/regen-network/regen-ledger/x/ecocredit"
"github.com/regen-network/regen-ledger/x/ecocredit/server"
)

// BeginBlocker checks if there are any expired sell or buy orders and removes them from state.
func BeginBlocker(ctx sdk.Context, k Keeper) error {
// BeginBlocker checks if there are any expired sell orders and removes them from state.
func BeginBlocker(ctx sdk.Context, k server.Keeper) error {
defer telemetry.ModuleMeasureSince(ecocredit.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)

if err := k.PruneOrders(ctx); err != nil {
Expand Down
Loading