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(ecocredit): delete v1alpha2 types #1063

Merged
merged 8 commits into from
May 2, 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
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
Expand Down Expand Up @@ -134,7 +133,6 @@ require (
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gotest.tools/v3 v3.1.0 // indirect
nhooyr.io/websocket v1.8.6 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Expand Down
2 changes: 0 additions & 2 deletions proto/regen/ecocredit/v1alpha2/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

aleem1314 marked this conversation as resolved.
Show resolved Hide resolved
// EventCreateClass is an event emitted when a credit class is created.
message EventCreateClass {

Expand Down
2 changes: 0 additions & 2 deletions proto/regen/ecocredit/v1alpha2/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package regen.ecocredit.v1alpha2;
import "regen/ecocredit/v1alpha2/types.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

// GenesisState defines ecocredit module's genesis state.
message GenesisState {
// Params contains the updateable global parameters for use with the x/params
Expand Down
2 changes: 0 additions & 2 deletions proto/regen/ecocredit/v1alpha2/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "google/api/annotations.proto";
import "regen/ecocredit/v1alpha2/types.proto";
import "cosmos/base/query/v1beta1/pagination.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

// Msg is the regen.ecocredit.v1alpha2 Query service.
service Query {

Expand Down
2 changes: 0 additions & 2 deletions proto/regen/ecocredit/v1alpha2/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
import "regen/ecocredit/v1alpha2/types.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

// Msg is the regen.ecocredit.v1alpha1 Msg service.
service Msg {

Expand Down
2 changes: 0 additions & 2 deletions proto/regen/ecocredit/v1alpha2/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

// ClassInfo represents the high-level on-chain information for a credit class.
message ClassInfo {

Expand Down
9 changes: 4 additions & 5 deletions x/ecocredit/client/testsuite/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/regen-network/regen-ledger/types"
"github.com/regen-network/regen-ledger/types/testutil/cli"
"github.com/regen-network/regen-ledger/x/ecocredit"
coreclient "github.com/regen-network/regen-ledger/x/ecocredit/client"
marketplaceclient "github.com/regen-network/regen-ledger/x/ecocredit/client/marketplace"
"github.com/regen-network/regen-ledger/x/ecocredit/core"
Expand All @@ -26,15 +25,15 @@ func (s *IntegrationTestSuite) TestQueryClassesCmd() {
Issuers: []string{val.Address.String()},
Metadata: "metadata",
CreditTypeAbbrev: validCreditTypeAbbrev,
Fee: &ecocredit.DefaultParams().CreditClassFee[0],
Fee: &core.DefaultParams().CreditClassFee[0],
})
s.Require().NoError(err)
classId2, err := s.createClass(clientCtx, &core.MsgCreateClass{
Admin: val.Address.String(),
Issuers: []string{val.Address.String(), val2.Address.String()},
Metadata: "metadata2",
CreditTypeAbbrev: validCreditTypeAbbrev,
Fee: &ecocredit.DefaultParams().CreditClassFee[0],
Fee: &core.DefaultParams().CreditClassFee[0],
})
s.Require().NoError(err)
classIds := [2]string{classId, classId2}
Expand Down Expand Up @@ -510,7 +509,7 @@ func (s *IntegrationTestSuite) TestQuerySellOrdersCmd() {
args []string
expErr bool
expErrMsg string
expOrders []*ecocredit.SellOrder
expOrders []*marketplace.SellOrder
}{
{
name: "too many args",
Expand Down Expand Up @@ -814,7 +813,7 @@ func (s *IntegrationTestSuite) TestQueryClassIssuersCmd() {
Issuers: []string{val.Address.String(), val2.Address.String()},
Metadata: "metadata",
CreditTypeAbbrev: validCreditTypeAbbrev,
Fee: &ecocredit.DefaultParams().CreditClassFee[0],
Fee: &core.DefaultParams().CreditClassFee[0],
})
require.NoError(err)

Expand Down
5 changes: 2 additions & 3 deletions x/ecocredit/client/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/regen-network/regen-ledger/types"
"github.com/regen-network/regen-ledger/x/ecocredit"
basketcli "github.com/regen-network/regen-ledger/x/ecocredit/client/basket"
corecli "github.com/regen-network/regen-ledger/x/ecocredit/client/core"
marketplacecli "github.com/regen-network/regen-ledger/x/ecocredit/client/marketplace"
Expand Down Expand Up @@ -86,8 +85,8 @@ Parameters:
credit type abbreviation: the name of the credit class type (e.g. carbon, biodiversity, etc)
metadata: arbitrary data attached to the credit class info
fee: fee to pay for the creation of the credit class (e.g. 10uatom, 10uregen)`,
ecocredit.KeyAllowedClassCreators,
ecocredit.KeyCreditClassFee,
core.KeyAllowedClassCreators,
core.KeyCreditClassFee,
),
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/client/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type credits struct {

var (
reCreditAmt = `[[:digit:]]+(?:\.[[:digit:]]+)?|\.[[:digit:]]+`
reCredits = regexp.MustCompile(fmt.Sprintf(`^(%s) (%s)$`, reCreditAmt, ecocredit.ReBatchDenom))
reCredits = regexp.MustCompile(fmt.Sprintf(`^(%s) (%s)$`, reCreditAmt, core.ReBatchDenom))
)

func parseCancelCreditsList(creditsListStr string) ([]*core.MsgCancel_CancelCredits, error) {
Expand Down
26 changes: 0 additions & 26 deletions x/ecocredit/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,9 @@ package ecocredit

import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

// RegisterLegacyAminoCodec registers all the necessary ecocredit module concrete
// types with the provided codec reference.
// These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgCreateClass{}, "regen-ledger/MsgCreateClass", nil)
cdc.RegisterConcrete(&MsgCreateBatch{}, "regen-ledger/MsgCreateBatch", nil)
cdc.RegisterConcrete(&MsgSend{}, "regen-ledger/MsgSend", nil)
cdc.RegisterConcrete(&MsgRetire{}, "regen-ledger/MsgRetire", nil)
cdc.RegisterConcrete(&MsgCancel{}, "regen-ledger/MsgCancel", nil)
cdc.RegisterConcrete(&MsgCreateProject{}, "regen-ledger/MsgCreateProject", nil)
cdc.RegisterConcrete(&MsgAddToBasket{}, "regen-ledger/MsgAddToBasket", nil)
cdc.RegisterConcrete(&MsgPickFromBasket{}, "regen-ledger/MsgPickFromBasket", nil)
cdc.RegisterConcrete(&MsgCreateBasket{}, "regen-ledger/MsgCreateBasket", nil)
cdc.RegisterConcrete(&MsgTakeFromBasket{}, "regen-ledger/MsgTakeFromBasket", nil)
}

func RegisterTypes(registry codectypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
}
4 changes: 2 additions & 2 deletions x/ecocredit/core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func MergeParamsIntoTarget(cdc codec.JSONCodec, message gogoproto.Message, targe

// Validate performs a basic validation of credit class
func (c Class) Validate() error {
if len(c.Metadata) > ecocredit.MaxMetadataLength {
if len(c.Metadata) > MaxMetadataLength {
return ecocredit.ErrMaxLimit.Wrap("credit class metadata")
}

Expand Down Expand Up @@ -392,7 +392,7 @@ func (p Project) Validate() error {
return err
}

if len(p.Metadata) > ecocredit.MaxMetadataLength {
if len(p.Metadata) > MaxMetadataLength {
return ecocredit.ErrMaxLimit.Wrap("project metadata")
}

Expand Down
40 changes: 0 additions & 40 deletions x/ecocredit/data_prefixes_test.go

This file was deleted.

Loading