From 1cb37286b4e81e67f7ef360a387b307a1ade6a0d Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Tue, 15 Feb 2022 21:26:56 +0100 Subject: [PATCH] feat: backport basket proto updates (#772) * backporting proto * gen proto update * wip * update msg_create * add basket.name checks * add description check * chore: update msgs,tests * fix: cli and test * fix: put tests/impl * use ValidateCreditTypeAbbreviation * add ExponentToPrefix * compute prefix from exponent * update denom format * update prefix * update tests * extract denom creation to separate function * Update x/ecocredit/basket/msg_create.go Co-authored-by: Aaron Craelius Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com> Co-authored-by: Aaron Craelius --- go.mod | 2 +- go.sum | 4 +- proto/regen/ecocredit/basket/v1/events.proto | 52 +++++ proto/regen/ecocredit/basket/v1/query.proto | 97 ++++++++ proto/regen/ecocredit/basket/v1/tx.proto | 42 ++-- proto/regen/ecocredit/basket/v1/types.proto | 5 +- x/ecocredit/basket/msg_create.go | 60 +++-- x/ecocredit/basket/msg_create_test.go | 60 +++-- x/ecocredit/basket/state.pb.go | 92 ++++---- x/ecocredit/basket/tx.pb.go | 234 ++++++++++++------- x/ecocredit/client/basket/tx.go | 52 +++-- x/ecocredit/denom.go | 38 +++ x/ecocredit/go.mod | 2 +- x/ecocredit/go.sum | 4 +- x/ecocredit/params.go | 9 +- x/ecocredit/server/basket/create.go | 44 ++-- x/ecocredit/server/basket/create_test.go | 81 ++++--- x/ecocredit/server/basket/put.go | 4 +- x/ecocredit/server/basket/put_test.go | 8 +- x/ecocredit/server/basket/take_test.go | 4 +- 20 files changed, 600 insertions(+), 294 deletions(-) create mode 100644 proto/regen/ecocredit/basket/v1/events.proto create mode 100644 proto/regen/ecocredit/basket/v1/query.proto diff --git a/go.mod b/go.mod index c415008206..51a2604be5 100644 --- a/go.mod +++ b/go.mod @@ -111,7 +111,7 @@ require ( github.com/prometheus/procfs v0.6.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect - github.com/regen-network/regen-ledger/api v0.3.0 // indirect + github.com/regen-network/regen-ledger/api v0.4.0 // indirect github.com/regen-network/regen-ledger/orm v1.0.0-beta1 // indirect github.com/rs/cors v1.7.0 // indirect github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect diff --git a/go.sum b/go.sum index 2df591afa8..c04b47164f 100644 --- a/go.sum +++ b/go.sum @@ -916,8 +916,8 @@ github.com/regen-network/cosmos-sdk v0.44.2-regen-1/go.mod h1:fwQJdw+aECatpTvQTo github.com/regen-network/protobuf v1.3.2-alpha.regen.4 h1:c9jEnU+xm6vqyrQe3M94UFWqiXxRIKKnqBOh2EACmBE= github.com/regen-network/protobuf v1.3.2-alpha.regen.4/go.mod h1:/J8/bR1T/NXyIdQDLUaq15LjNE83nRzkyrLAMcPewig= github.com/regen-network/regen-ledger/api v0.2.0/go.mod h1:kWly2pK0u3fDfyoYYilpEoTEg61pCjV/f5XSY0KzJQY= -github.com/regen-network/regen-ledger/api v0.3.0 h1:gam9DzeklPi9OySQoS2RIwzQhUBwd5UDK8joe0YqHA4= -github.com/regen-network/regen-ledger/api v0.3.0/go.mod h1:kWly2pK0u3fDfyoYYilpEoTEg61pCjV/f5XSY0KzJQY= +github.com/regen-network/regen-ledger/api v0.4.0 h1:klcMljLCHU3MpkRyjrEXL6KKsDGeqFBt2aFUwFdpEH8= +github.com/regen-network/regen-ledger/api v0.4.0/go.mod h1:kWly2pK0u3fDfyoYYilpEoTEg61pCjV/f5XSY0KzJQY= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= diff --git a/proto/regen/ecocredit/basket/v1/events.proto b/proto/regen/ecocredit/basket/v1/events.proto new file mode 100644 index 0000000000..90ce764625 --- /dev/null +++ b/proto/regen/ecocredit/basket/v1/events.proto @@ -0,0 +1,52 @@ +syntax = "proto3"; + +package regen.ecocredit.basket.v1; + +import "regen/ecocredit/basket/v1/types.proto"; + +option go_package = "github.com/regen-network/regen-ledger/x/ecocredit/basket"; + +// EventCreate is an event emitted when a basket is created. +message EventCreate { + + // basket_denom is the basket bank denom. + string basket_denom = 1; + + // curator is the address of the basket curator who is able to change certain + // basket settings. + string curator = 2; +} + +// EventPut is an event emitted when credits are put into a basket in return +// for basket tokens. +message EventPut { + + // owner is the owner of the credits put into the basket. + string owner = 1; + + // basket_denom is the basket bank denom that the credits were added to. + string basket_denom = 2; + + // credits are the credits that were added to the basket. + repeated BasketCredit credits = 3; + + // amount is the integer number of basket tokens converted from credits. + string amount = 4; +} + +// EventTake is an event emitted when credits are taken from a basket starting +// from the oldest credits first. +message EventTake { + + // owner is the owner of the credits taken from the basket. + string owner = 1; + + // basket_denom is the basket bank denom that credits were taken from. + string basket_denom = 2; + + // credits are the credits that were taken from the basket. + repeated BasketCredit credits = 3; + + // amount is the integer number of basket tokens converted to credits. + string amount = 4; +} diff --git a/proto/regen/ecocredit/basket/v1/query.proto b/proto/regen/ecocredit/basket/v1/query.proto new file mode 100644 index 0000000000..6c42331b8b --- /dev/null +++ b/proto/regen/ecocredit/basket/v1/query.proto @@ -0,0 +1,97 @@ +syntax = "proto3"; + +package regen.ecocredit.basket.v1; + +import "google/api/annotations.proto"; +import "regen/ecocredit/basket/v1/state.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/regen-network/regen-ledger/x/ecocredit/basket"; + +// Msg is the regen.ecocredit.basket.v1beta1 Query service. +service Query { + + // Basket queries one basket by denom. + rpc Basket(QueryBasketRequest) returns (QueryBasketResponse) { + option (google.api.http).get = + "/regen/ecocredit/basket/v1/baskets/{basket_denom}"; + } + + // Baskets lists all baskets in the ecocredit module. + rpc Baskets(QueryBasketsRequest) returns (QueryBasketsResponse) { + option (google.api.http).get = + "/regen/ecocredit/basket/v1/baskets"; + } + + // BasketBalances lists the balance of each credit batch in the basket. + rpc BasketBalances(QueryBasketBalancesRequest) returns (QueryBasketBalancesResponse) { + option (google.api.http).get = + "/regen/ecocredit/basket/v1/baskets/{basket_denom}/balances"; + } + + // BasketBalance queries the balance of a specific credit batch in the basket. + rpc BasketBalance(QueryBasketBalanceRequest) returns (QueryBasketBalanceResponse) { + option (google.api.http).get = + "/regen/ecocredit/basket/v1/baskets/{basket_denom}/balances/{batch_denom}"; + } +} + +// QueryBasketRequest is the Query/Basket request type. +message QueryBasketRequest { + // basket_denom represents the denom of the basket to query. + string basket_denom = 1; +} + +// QueryBasketResponse is the Query/Basket response type. +message QueryBasketResponse { + // basket is the queried basket. + Basket basket = 1; +} + +// QueryBasketsRequest is the Query/Baskets request type. +message QueryBasketsRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryBasketsResponse is the Query/Baskets response type. +message QueryBasketsResponse { + // baskets are the fetched baskets. + repeated Basket baskets = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryBasketBalancesRequest is the Query/BasketBalances request type. +message QueryBasketBalancesRequest { + // basket_denom is the denom of the basket. + string basket_denom = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryBasketBalancesResponse is the Query/BasketBalances response type. +message QueryBasketBalancesResponse { + // balances is a list of credit balances in the basket. + repeated BasketBalance balances = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryBasketBalanceRequest is the Query/BasketBalance request type. +message QueryBasketBalanceRequest { + // basket_denom is the denom of the basket. + string basket_denom = 1; + + // batch_denom is the denom of the credit batch. + string batch_denom = 2; +} + +// QueryBasketBalanceResponse is the Query/BasketBalance response type. +message QueryBasketBalanceResponse { + // balance is the amount of the queried credit batch in the basket. + string balance = 1; +} \ No newline at end of file diff --git a/proto/regen/ecocredit/basket/v1/tx.proto b/proto/regen/ecocredit/basket/v1/tx.proto index 15ebca68b4..775a3bf46b 100644 --- a/proto/regen/ecocredit/basket/v1/tx.proto +++ b/proto/regen/ecocredit/basket/v1/tx.proto @@ -28,45 +28,59 @@ message MsgCreate { // basket settings. string curator = 1; - // name will be used to create a bank denom for this basket token. + // name will be used to together with prefix to create a bank denom for this + // basket token. It can be between 3-8 alphanumeric characters, with the + // first character being alphabetic. The bank denom will be + // `eco/` and its display name will be `eco/`. string name = 2; - // display_name will be used to create a bank Metadata display name for this - // basket token. - string display_name = 3; + // prefix is a single alphabetic character that denotes + // the denom prefix and indicates in some way what relationship is between + // the denom and display denom. Standard conventions are that m indicates + // milli (10^3), u indicates micro (10^6), n indicates nano (10^9). + // Typical usage of prefix should correspond with the `exponent` field, + // which is used to convert decimal ecocredit amounts to integral + // basket tokens. + string prefix = 3; + + // description is a human-readable description of the basket denom that should + // be at most 256 characters. + string description = 4; + // exponent is the exponent that will be used for converting credits to basket // tokens and for bank denom metadata. It also limits the precision of // credit amounts when putting credits into a basket. An exponent of 6 will - // mean that 10^6 units of a basket token will be issued for 1.0 credits and - // that this should be displayed as one unit in user interfaces. It also means + // mean that 10^6 units of a basket token will be issued for 1.0 credits and that + // this should be displayed as one unit in user interfaces. It also means // that the maximum precision of credit amounts is 6 decimal places so that // the need to round is eliminated. The exponent must be >= the precision of // the credit type at the time the basket is created. - uint32 exponent = 4; + uint32 exponent = 5; // disable_auto_retire allows auto-retirement to be disabled. // The credits will be auto-retired if disable_auto_retire is // false unless the credits were previously put into the basket by the // address picking them from the basket, in which case they will remain // tradable. - bool disable_auto_retire = 5; + bool disable_auto_retire = 6; - // credit_type_name filters against credits from this credit type name. - string credit_type_name = 6; + // credit_type_abbrev is the abbreviation of the credit type this basket is + // able to hold. + string credit_type_abbrev = 7; // allowed_classes are the credit classes allowed to be put in the basket - repeated string allowed_classes = 7; + repeated string allowed_classes = 8; // date_criteria is the date criteria for batches admitted to the basket. - DateCriteria date_criteria = 8; + DateCriteria date_criteria = 9; // fee is the fee that the curator will pay to create the basket. It must be // >= the required Params.basket_creation_fee. We include the fee explicitly // here so that the curator explicitly acknowledges paying this fee and // is not surprised to learn that the paid a big fee and didn't know // beforehand. - repeated cosmos.base.v1beta1.Coin fee = 9 [ + repeated cosmos.base.v1beta1.Coin fee = 10 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; @@ -108,7 +122,7 @@ message MsgTake { // owner is the owner of the basket tokens. string owner = 1; - // basket_denom is the basket denom to take credits from. + // basket_denom is the basket bank denom to take credits from. string basket_denom = 2; // amount is the integer number of basket tokens to convert into credits. diff --git a/proto/regen/ecocredit/basket/v1/types.proto b/proto/regen/ecocredit/basket/v1/types.proto index b61647b85f..49493e06ac 100644 --- a/proto/regen/ecocredit/basket/v1/types.proto +++ b/proto/regen/ecocredit/basket/v1/types.proto @@ -31,8 +31,7 @@ message DateCriteria { // start_date_window is a duration of time measured into the past which sets // a cutoff for batch start dates when adding new credits to the basket. // Based on the current block timestamp, credits whose start date is before - // `block_timestamp - batch_date_window` will not be allowed into the - // basket. + // `block_timestamp - batch_date_window` will not be allowed into the basket. google.protobuf.Duration start_date_window = 2; } -} +} \ No newline at end of file diff --git a/x/ecocredit/basket/msg_create.go b/x/ecocredit/basket/msg_create.go index 042d6af6c1..7b2435e44b 100644 --- a/x/ecocredit/basket/msg_create.go +++ b/x/ecocredit/basket/msg_create.go @@ -1,6 +1,9 @@ package basket import ( + "fmt" + "regexp" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" @@ -12,39 +15,37 @@ var ( _ legacytx.LegacyMsg = &MsgCreate{} ) -const nameMaxLen = 32 -const displayNameMinLen = 3 -const displayNameMaxLen = 32 -const exponentMax = 32 -const creditNameMaxLen = 32 +const nameMinLen = 3 +const nameMaxLen = 8 +const descrMaxLen = 255 +const creditTypeAbbrMaxLen = 3 var errBadReq = sdkerrors.ErrInvalidRequest +// first character must be alphabetic, the rest can be alphanumeric. We reduce length constraints by one to account for +// the first character being forced to alphabetic. +var reName = regexp.MustCompile(fmt.Sprintf("^[[:alpha:]][[:alnum:]]{%d,%d}$", nameMinLen-1, nameMaxLen-1)) + // ValidateBasic does a stateless sanity check on the provided data. func (m MsgCreate) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Curator); err != nil { return sdkerrors.ErrInvalidAddress.Wrap("malformed curator address " + err.Error()) } - // TODO: add proper validation once we will have proper requirements. - // https://github.com/regen-network/regen-ledger/issues/732 - if m.Name == "" || len(m.Name) > nameMaxLen { - return errBadReq.Wrapf("name must not be empty and must not be longer than %d characters long", nameMaxLen) - } - if len(m.DisplayName) < displayNameMinLen || len(m.DisplayName) > displayNameMaxLen { - return errBadReq.Wrapf("display_name must be between %d and %d characters long", displayNameMinLen, displayNameMaxLen) + if !reName.MatchString(m.Name) { + return errBadReq.Wrapf("name must start with an alphabetic character, and be between %d and %d alphanumeric characters long", nameMinLen, nameMaxLen) } - if m.Exponent > exponentMax { - return errBadReq.Wrapf("exponent must not be bigger than %d", exponentMax) - } - if m.CreditTypeName == "" { - return errBadReq.Wrap("credit_type_name must be defined") + if _, err := ecocredit.ExponentToPrefix(m.Exponent); err != nil { + return err } - if len(m.CreditTypeName) > creditNameMaxLen { - return errBadReq.Wrapf("credit_type_name must not be longer than %d", creditNameMaxLen) + if err := ecocredit.ValidateCreditTypeAbbreviation(m.CreditTypeAbbrev); err != nil { + return err } if err := validateDateCriteria(m.DateCriteria); err != nil { return err } + if len(m.Description) > descrMaxLen { + return errBadReq.Wrapf("description can't be longer than %d characters", descrMaxLen) + } if len(m.AllowedClasses) == 0 { return errBadReq.Wrap("allowed_classes is required") } @@ -56,9 +57,9 @@ func (m MsgCreate) ValidateBasic() error { return m.Fee.Validate() } -// ValidateCreateFee additional validation with access to the state data. +// ValidateMsgCreate additional validation with access to the state data. // minFee must be sorted. -func ValidateCreateFee(m *MsgCreate, minFee sdk.Coins) error { +func ValidateMsgCreate(m *MsgCreate, minFee sdk.Coins) error { if !m.Fee.IsAllGTE(minFee) { return sdkerrors.ErrInsufficientFee.Wrapf("minimum fee %s, got %s", minFee, m.Fee) } @@ -100,3 +101,20 @@ func validateDateCriteria(d *DateCriteria) error { } return nil } + +// MsgCreateDenom formats denom and display denom: +// * denom: eco.. +// * display denom: eco.. +// Returns error if MsgCrete.Exponent is not supported +func MsgCreateDenom(m *MsgCreate) (string, string, error) { + const basketDenomPrefix = "eco." + denomPrefix, err := ecocredit.ExponentToPrefix(m.Exponent) + if err != nil { + return "", "", err + } + + denomTail := m.CreditTypeAbbrev + "." + m.Name + displayDenomName := basketDenomPrefix + denomTail // + denom := basketDenomPrefix + denomPrefix + denomTail // eco.. + return denom, displayDenomName, nil +} diff --git a/x/ecocredit/basket/msg_create_test.go b/x/ecocredit/basket/msg_create_test.go index 002125484b..9eaf3e8f2c 100644 --- a/x/ecocredit/basket/msg_create_test.go +++ b/x/ecocredit/basket/msg_create_test.go @@ -23,9 +23,9 @@ func errorMatches(t *testing.T, err error, expect string) { func TestMsgCreateValidateBasic(t *testing.T) { _, _, addr1 := testdata.KeyTestPubAddr() a := addr1.String() - name := randstr.String(nameMaxLen) - dName := randstr.String((displayNameMaxLen + displayNameMinLen) / 2) - creditName := randstr.String(10) + name := randstr.String((nameMaxLen+nameMinLen)/2, "ABCDEFGHIJKL") + creditAbbr := "FOO" + descr := "my project description" start := &DateCriteria{&DateCriteria_MinStartDate{gogotypes.TimestampNow()}} classes := []string{"eco_class1"} @@ -39,44 +39,54 @@ func TestMsgCreateValidateBasic(t *testing.T) { MsgCreate{Curator: "wrong"}, "malformed curator address"}, {"name-1", - MsgCreate{Curator: a, Name: ""}, "name must not be empty"}, - {"name-2", + MsgCreate{Curator: a, Name: ""}, + "name must start with an alphabetic character"}, + {"name-long", MsgCreate{Curator: a, Name: randstr.String(nameMaxLen + 1)}, - "name must not be empty and must not be longer than"}, - {"name-3", - MsgCreate{Curator: a, Name: name, DisplayName: ""}, - "display_name must be between"}, - {"name-4", - MsgCreate{Curator: a, Name: name, DisplayName: randstr.String(displayNameMaxLen + 1)}, - "display_name must be between"}, + "name must start with an alphabetic character"}, + {"name-short", + MsgCreate{Curator: a, Name: randstr.String(nameMinLen - 1)}, + "name must start with an alphabetic character"}, + {"name-no-alpahnum", + MsgCreate{Curator: a, Name: randstr.String(nameMinLen) + "*"}, + "name must start with an alphabetic character"}, + {"name-no-alpah-prefix", + MsgCreate{Curator: a, Name: "1" + randstr.String(nameMinLen)}, + "name must start with an alphabetic character"}, {"exponent-1", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax + 1}, - "exponent must not be bigger than"}, + MsgCreate{Curator: a, Name: name, Exponent: 4}, + "exponent must be one of"}, + {"exponent-1", + MsgCreate{Curator: a, Name: name, Exponent: 17}, + "exponent must be one of"}, {"credity_type-1", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax}, - "credit_type_name must be defined"}, + MsgCreate{Curator: a, Name: name, Exponent: 3}, + "credit type abbreviation must be 1-3"}, {"credity_type-2", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax, CreditTypeName: randstr.String(creditNameMaxLen + 1)}, - "credit_type_name must not be longer"}, + MsgCreate{Curator: a, Name: name, Exponent: 3, CreditTypeAbbrev: randstr.String(creditTypeAbbrMaxLen + 1)}, + "credit type abbreviation must be 1-3"}, {"date_criteria-1", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax, CreditTypeName: creditName, DateCriteria: &DateCriteria{}}, + MsgCreate{Curator: a, Name: name, Exponent: 3, CreditTypeAbbrev: creditAbbr, DateCriteria: &DateCriteria{}}, "unsupported date_criteria value"}, + {"description", + MsgCreate{Curator: a, Name: name, Exponent: 3, CreditTypeAbbrev: creditAbbr, DateCriteria: start, Description: randstr.String(descrMaxLen + 1)}, + "description can't be longer"}, {"allowed_classes-1", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax, CreditTypeName: creditName, DateCriteria: start}, + MsgCreate{Curator: a, Name: name, Exponent: 3, CreditTypeAbbrev: creditAbbr, DateCriteria: start}, "allowed_classes is required"}, {"allowed_classes-2", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax, CreditTypeName: creditName, DateCriteria: start, AllowedClasses: []string{"class1", ""}}, + MsgCreate{Curator: a, Name: name, Exponent: 3, CreditTypeAbbrev: creditAbbr, DateCriteria: start, AllowedClasses: []string{"class1", ""}}, "allowed_classes[1] must be defined"}, {"fee-1", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax, CreditTypeName: creditName, DateCriteria: start, AllowedClasses: classes, Fee: sdk.Coins{sdk.Coin{Denom: "1a"}}}, + MsgCreate{Curator: a, Prefix: "o", Name: name, Exponent: 3, CreditTypeAbbrev: creditAbbr, DateCriteria: start, AllowedClasses: classes, Fee: sdk.Coins{sdk.Coin{Denom: "1a"}}}, "invalid denom"}, - {"fee-2", MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: exponentMax, CreditTypeName: creditName, DateCriteria: start, AllowedClasses: classes, Fee: sdk.Coins{sdk.Coin{"aa", sdk.NewInt(-1)}}}, + {"fee-2", MsgCreate{Curator: a, Prefix: "o", Name: name, Exponent: 3, CreditTypeAbbrev: creditAbbr, DateCriteria: start, AllowedClasses: classes, Fee: sdk.Coins{sdk.Coin{"aa", sdk.NewInt(-1)}}}, "invalid denom"}, {"good-1-fees-not-required", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: 0, CreditTypeName: creditName, DateCriteria: start, AllowedClasses: classes}, ""}, + MsgCreate{Curator: a, Prefix: "o", Name: name, Exponent: 0, CreditTypeAbbrev: creditAbbr, DateCriteria: start, AllowedClasses: classes, Description: descr}, ""}, {"good-date-criteria-not-required", - MsgCreate{Curator: a, Name: name, DisplayName: dName, Exponent: 6, CreditTypeName: creditName, DateCriteria: nil, AllowedClasses: classes, Fee: sdk.Coins{sdk.NewInt64Coin("regen", 1)}}, ""}, + MsgCreate{Curator: a, Prefix: "o", Name: name, Exponent: 18, CreditTypeAbbrev: creditAbbr, DateCriteria: nil, AllowedClasses: classes, Fee: sdk.Coins{sdk.NewInt64Coin("regen", 1)}}, ""}, } for _, tc := range tcs { diff --git a/x/ecocredit/basket/state.pb.go b/x/ecocredit/basket/state.pb.go index ae585a4f59..7639347f25 100644 --- a/x/ecocredit/basket/state.pb.go +++ b/x/ecocredit/basket/state.pb.go @@ -33,8 +33,8 @@ type Basket struct { BasketDenom string `protobuf:"bytes,2,opt,name=basket_denom,json=basketDenom,proto3" json:"basket_denom,omitempty"` // disable_auto_retire indicates whether or not the credits will be retired upon withdraw from the basket. DisableAutoRetire bool `protobuf:"varint,3,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` - // credit_type_name is the name of the credit type this basket is able to hold. - CreditTypeName string `protobuf:"bytes,4,opt,name=credit_type_name,json=creditTypeName,proto3" json:"credit_type_name,omitempty"` + // credit_type_abbrev is the abbreviation of the credit type this basket is able to hold. + CreditTypeAbbrev string `protobuf:"bytes,4,opt,name=credit_type_abbrev,json=creditTypeAbbrev,proto3" json:"credit_type_abbrev,omitempty"` // date_criteria is the date criteria for batches admitted to the basket. DateCriteria *DateCriteria `protobuf:"bytes,5,opt,name=date_criteria,json=dateCriteria,proto3" json:"date_criteria,omitempty"` // exponent is the exponent for converting credits to/from basket tokens. @@ -95,9 +95,9 @@ func (m *Basket) GetDisableAutoRetire() bool { return false } -func (m *Basket) GetCreditTypeName() string { +func (m *Basket) GetCreditTypeAbbrev() string { if m != nil { - return m.CreditTypeName + return m.CreditTypeAbbrev } return "" } @@ -256,41 +256,41 @@ func init() { } var fileDescriptor_c416a19075224f85 = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xce, 0x26, 0xfd, 0xa5, 0xc9, 0xa4, 0x89, 0xf2, 0x5b, 0x8a, 0x70, 0x83, 0x70, 0x43, 0x04, - 0xc2, 0x07, 0x58, 0x2b, 0xe5, 0x00, 0xca, 0x8d, 0x34, 0x97, 0x4a, 0x88, 0x83, 0xe9, 0x89, 0x8b, - 0xb5, 0xb6, 0x87, 0xc4, 0xaa, 0xed, 0xb5, 0xd6, 0x9b, 0xd0, 0xbe, 0x04, 0xe2, 0x09, 0xb8, 0xf1, - 0x2e, 0x1c, 0x2b, 0x71, 0xe1, 0x88, 0x12, 0x89, 0x07, 0xe0, 0x09, 0x90, 0x77, 0x93, 0xb4, 0x55, - 0x45, 0x8f, 0xdf, 0xcc, 0xf7, 0xcd, 0x9f, 0x6f, 0x06, 0x9e, 0x4a, 0x9c, 0x62, 0xe6, 0x62, 0x28, - 0x42, 0x89, 0x51, 0xac, 0xdc, 0x80, 0x17, 0x67, 0xa8, 0xdc, 0xc5, 0xd0, 0x2d, 0x14, 0x57, 0xc8, - 0x72, 0x29, 0x94, 0xa0, 0x07, 0x9a, 0xc6, 0xb6, 0x34, 0x66, 0x68, 0x6c, 0x31, 0xec, 0x3d, 0x0a, - 0x45, 0x91, 0x8a, 0xc2, 0x15, 0x32, 0x75, 0x17, 0x43, 0x9e, 0xe4, 0x33, 0x3e, 0x2c, 0x81, 0x51, - 0xf6, 0x0e, 0xa7, 0x42, 0x4c, 0x13, 0x74, 0x35, 0x0a, 0xe6, 0x1f, 0x5d, 0x15, 0xa7, 0x58, 0x28, - 0x9e, 0xe6, 0x6b, 0xc2, 0x1d, 0x13, 0xa8, 0x8b, 0x1c, 0x0b, 0x43, 0x1b, 0x7c, 0xab, 0x42, 0x7d, - 0xac, 0x33, 0xb4, 0x03, 0xd5, 0x38, 0xb2, 0x48, 0x9f, 0x38, 0x3b, 0x5e, 0x35, 0x8e, 0xe8, 0x63, - 0xd8, 0x33, 0x1a, 0x3f, 0xc2, 0x4c, 0xa4, 0x56, 0xb5, 0x4f, 0x9c, 0xa6, 0xd7, 0x32, 0xb1, 0x49, - 0x19, 0xa2, 0x0c, 0xee, 0x45, 0x71, 0xc1, 0x83, 0x04, 0x7d, 0x3e, 0x57, 0xc2, 0x97, 0xa8, 0x62, - 0x89, 0x56, 0xad, 0x4f, 0x9c, 0x86, 0xf7, 0xff, 0x3a, 0xf5, 0x66, 0xae, 0x84, 0xa7, 0x13, 0xd4, - 0x81, 0xae, 0x99, 0xc6, 0x2f, 0x67, 0xf0, 0x33, 0x9e, 0xa2, 0xb5, 0xa3, 0xcb, 0x76, 0x4c, 0xfc, - 0xf4, 0x22, 0xc7, 0x77, 0x3c, 0x45, 0xfa, 0x16, 0xda, 0x11, 0x57, 0xe8, 0x87, 0x32, 0x56, 0x28, - 0x63, 0x6e, 0xfd, 0xd7, 0x27, 0x4e, 0xeb, 0xe8, 0x19, 0xfb, 0xa7, 0x63, 0x6c, 0xc2, 0x15, 0x1e, - 0xaf, 0xe9, 0xde, 0x5e, 0x74, 0x0d, 0xd1, 0x1e, 0x34, 0xf0, 0x3c, 0x17, 0x19, 0x66, 0xca, 0xaa, - 0xf7, 0x89, 0xd3, 0xf6, 0xb6, 0x78, 0xf4, 0xe4, 0xcf, 0xd7, 0x1f, 0x9f, 0x6b, 0x36, 0xd4, 0xcb, - 0xf5, 0xbb, 0x84, 0xd2, 0x9b, 0x6b, 0x77, 0x89, 0x45, 0x2c, 0x32, 0x40, 0x68, 0x19, 0x9b, 0x8e, - 0x13, 0x5e, 0x14, 0xf4, 0x21, 0x34, 0xd7, 0xa4, 0xad, 0x65, 0x0d, 0x13, 0x38, 0x89, 0xe8, 0x01, - 0x34, 0xc2, 0x92, 0x55, 0xe6, 0x8c, 0x69, 0xbb, 0x1a, 0x9f, 0x44, 0x23, 0x5b, 0x37, 0xb3, 0x60, - 0x1f, 0xe8, 0x56, 0xff, 0xfc, 0x8a, 0x3c, 0xf8, 0x4d, 0xa0, 0x6d, 0xfa, 0x8c, 0x79, 0xc2, 0xb3, - 0x10, 0xef, 0xee, 0x74, 0x08, 0xad, 0x80, 0xab, 0x70, 0x76, 0xe3, 0x42, 0xa0, 0x43, 0xe6, 0x40, - 0x16, 0xec, 0x06, 0xa6, 0x90, 0x3e, 0x4a, 0xd3, 0xdb, 0x40, 0x3a, 0x81, 0xae, 0x91, 0x16, 0x8a, - 0x4b, 0xe5, 0x97, 0x76, 0xe9, 0x53, 0xb4, 0x8e, 0x7a, 0xcc, 0xfc, 0x16, 0xdb, 0xfc, 0x16, 0x3b, - 0xdd, 0xfc, 0x96, 0xd7, 0xd1, 0x9a, 0xf7, 0xa5, 0xa4, 0xb4, 0x7b, 0xf4, 0x4a, 0xef, 0x33, 0x84, - 0x07, 0x70, 0xff, 0x6a, 0x9f, 0x6b, 0x23, 0xd1, 0xfd, 0xdb, 0x6d, 0xba, 0xc4, 0xaa, 0x8d, 0xbd, - 0xef, 0x4b, 0x9b, 0x5c, 0x2e, 0x6d, 0xf2, 0x6b, 0x69, 0x93, 0x2f, 0x2b, 0xbb, 0x72, 0xb9, 0xb2, - 0x2b, 0x3f, 0x57, 0x76, 0xe5, 0xc3, 0xeb, 0x69, 0xac, 0x66, 0xf3, 0x80, 0x85, 0x22, 0x75, 0xf5, - 0xb1, 0x5f, 0x64, 0xa8, 0x3e, 0x09, 0x79, 0xb6, 0x46, 0x09, 0x46, 0x53, 0x94, 0xee, 0xf9, 0xad, - 0xd7, 0x0e, 0xea, 0x7a, 0xe0, 0x97, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x02, 0xd5, 0xcc, 0x76, - 0x7d, 0x03, 0x00, 0x00, + // 534 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xce, 0x26, 0x25, 0x4d, 0x26, 0x4d, 0x15, 0x16, 0x10, 0x6e, 0x10, 0x6e, 0x88, 0x40, 0xe4, + 0x50, 0xd6, 0x4a, 0xb9, 0xa0, 0x70, 0x4a, 0x9a, 0x4b, 0x25, 0x4e, 0xa6, 0x27, 0x2e, 0xd6, 0xda, + 0x1e, 0x12, 0xab, 0xb6, 0xd7, 0x5a, 0x6f, 0x42, 0xfb, 0x12, 0x88, 0x27, 0xe0, 0xce, 0x9b, 0x70, + 0xac, 0xc4, 0x85, 0x23, 0x4a, 0x5e, 0x00, 0xf1, 0x04, 0xc8, 0xbb, 0xf9, 0x69, 0x41, 0xed, 0xf1, + 0x9b, 0xef, 0xfb, 0x76, 0x66, 0xbf, 0x19, 0x78, 0x21, 0x71, 0x82, 0xa9, 0x83, 0x81, 0x08, 0x24, + 0x86, 0x91, 0x72, 0x7c, 0x9e, 0x9f, 0xa3, 0x72, 0xe6, 0x7d, 0x27, 0x57, 0x5c, 0x21, 0xcb, 0xa4, + 0x50, 0x82, 0x1e, 0x68, 0x19, 0xdb, 0xc8, 0x98, 0x91, 0xb1, 0x79, 0xbf, 0xfd, 0x34, 0x10, 0x79, + 0x22, 0x72, 0x47, 0xc8, 0xc4, 0x99, 0xf7, 0x79, 0x9c, 0x4d, 0x79, 0xbf, 0x00, 0xc6, 0xd9, 0x3e, + 0x9c, 0x08, 0x31, 0x89, 0xd1, 0xd1, 0xc8, 0x9f, 0x7d, 0x74, 0x54, 0x94, 0x60, 0xae, 0x78, 0x92, + 0xad, 0x04, 0x77, 0x4c, 0xa0, 0x2e, 0x33, 0xcc, 0x8d, 0xac, 0xfb, 0xad, 0x0c, 0xd5, 0x91, 0x66, + 0xe8, 0x3e, 0x94, 0xa3, 0xd0, 0x22, 0x1d, 0xd2, 0xdb, 0x71, 0xcb, 0x51, 0x48, 0x9f, 0xc1, 0x9e, + 0xf1, 0x78, 0x21, 0xa6, 0x22, 0xb1, 0xca, 0x1d, 0xd2, 0xab, 0xbb, 0x0d, 0x53, 0x1b, 0x17, 0x25, + 0xca, 0xe0, 0x41, 0x18, 0xe5, 0xdc, 0x8f, 0xd1, 0xe3, 0x33, 0x25, 0x3c, 0x89, 0x2a, 0x92, 0x68, + 0x55, 0x3a, 0xa4, 0x57, 0x73, 0xef, 0xaf, 0xa8, 0xe1, 0x4c, 0x09, 0x57, 0x13, 0xf4, 0x08, 0xa8, + 0x99, 0xc6, 0x2b, 0x66, 0xf0, 0xb8, 0xef, 0x4b, 0x9c, 0x5b, 0x3b, 0xfa, 0xe1, 0x96, 0x61, 0xce, + 0x2e, 0x33, 0x1c, 0xea, 0x3a, 0x7d, 0x07, 0xcd, 0x90, 0x2b, 0xf4, 0x02, 0x19, 0x29, 0x94, 0x11, + 0xb7, 0xee, 0x75, 0x48, 0xaf, 0x71, 0xfc, 0x92, 0xdd, 0x9a, 0x1a, 0x1b, 0x73, 0x85, 0x27, 0x2b, + 0xb9, 0xbb, 0x17, 0x5e, 0x43, 0xb4, 0x0d, 0x35, 0xbc, 0xc8, 0x44, 0x8a, 0xa9, 0xb2, 0xaa, 0x1d, + 0xd2, 0x6b, 0xba, 0x1b, 0x3c, 0x78, 0xfe, 0xe7, 0xeb, 0x8f, 0xcf, 0x15, 0x1b, 0xaa, 0x45, 0x04, + 0x2d, 0x42, 0xe9, 0xcd, 0xaf, 0xb7, 0x88, 0x45, 0x2c, 0xd2, 0x45, 0x68, 0x98, 0xa8, 0x4e, 0x62, + 0x9e, 0xe7, 0xf4, 0x09, 0xd4, 0x57, 0xa2, 0x4d, 0x6c, 0x35, 0x53, 0x38, 0x0d, 0xe9, 0x01, 0xd4, + 0x82, 0x42, 0x55, 0x70, 0x26, 0xb8, 0x5d, 0x8d, 0x4f, 0xc3, 0x81, 0xad, 0x9b, 0x59, 0xf0, 0x10, + 0xe8, 0xc6, 0x7f, 0xb4, 0x15, 0x77, 0x7f, 0x13, 0x68, 0x9a, 0x3e, 0x23, 0x1e, 0xf3, 0x34, 0xc0, + 0xbb, 0x3b, 0x1d, 0x42, 0xc3, 0xe7, 0x2a, 0x98, 0xde, 0xd8, 0x12, 0xe8, 0x92, 0x59, 0x92, 0x05, + 0xbb, 0xbe, 0x79, 0x48, 0x2f, 0xa6, 0xee, 0xae, 0x21, 0x1d, 0x43, 0xcb, 0x58, 0x73, 0xc5, 0xa5, + 0xf2, 0x8a, 0xb8, 0xf4, 0x32, 0x1a, 0xc7, 0x6d, 0x66, 0xee, 0x8b, 0xad, 0xef, 0x8b, 0x9d, 0xad, + 0xef, 0xcb, 0xdd, 0xd7, 0x9e, 0xf7, 0x85, 0xa5, 0x88, 0x7b, 0x30, 0xd4, 0xff, 0x79, 0x0b, 0x8f, + 0xe1, 0xd1, 0xf6, 0x3f, 0xd7, 0x46, 0xa2, 0x36, 0xb4, 0xff, 0x25, 0xb6, 0x0d, 0x5b, 0xc4, 0xaa, + 0x8c, 0xdc, 0xef, 0x0b, 0x9b, 0x5c, 0x2d, 0x6c, 0xf2, 0x6b, 0x61, 0x93, 0x2f, 0x4b, 0xbb, 0x74, + 0xb5, 0xb4, 0x4b, 0x3f, 0x97, 0x76, 0xe9, 0xc3, 0x9b, 0x49, 0xa4, 0xa6, 0x33, 0x9f, 0x05, 0x22, + 0x71, 0xf4, 0xda, 0x5f, 0xa5, 0xa8, 0x3e, 0x09, 0x79, 0xbe, 0x42, 0x31, 0x86, 0x13, 0x94, 0xce, + 0xc5, 0x7f, 0x87, 0xee, 0x57, 0xf5, 0xe8, 0xaf, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe5, 0xb0, + 0xa8, 0xa2, 0x8b, 0x03, 0x00, 0x00, } func (m *Basket) Marshal() (dAtA []byte, err error) { @@ -330,10 +330,10 @@ func (m *Basket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.CreditTypeName) > 0 { - i -= len(m.CreditTypeName) - copy(dAtA[i:], m.CreditTypeName) - i = encodeVarintState(dAtA, i, uint64(len(m.CreditTypeName))) + if len(m.CreditTypeAbbrev) > 0 { + i -= len(m.CreditTypeAbbrev) + copy(dAtA[i:], m.CreditTypeAbbrev) + i = encodeVarintState(dAtA, i, uint64(len(m.CreditTypeAbbrev))) i-- dAtA[i] = 0x22 } @@ -478,7 +478,7 @@ func (m *Basket) Size() (n int) { if m.DisableAutoRetire { n += 2 } - l = len(m.CreditTypeName) + l = len(m.CreditTypeAbbrev) if l > 0 { n += 1 + l + sovState(uint64(l)) } @@ -640,7 +640,7 @@ func (m *Basket) Unmarshal(dAtA []byte) error { m.DisableAutoRetire = bool(v != 0) case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreditTypeName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CreditTypeAbbrev", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -668,7 +668,7 @@ func (m *Basket) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CreditTypeName = string(dAtA[iNdEx:postIndex]) + m.CreditTypeAbbrev = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { diff --git a/x/ecocredit/basket/tx.pb.go b/x/ecocredit/basket/tx.pb.go index 23fb95fc15..7084ff8561 100644 --- a/x/ecocredit/basket/tx.pb.go +++ b/x/ecocredit/basket/tx.pb.go @@ -35,38 +35,47 @@ type MsgCreate struct { // curator is the address of the basket curator who is able to change certain // basket settings. Curator string `protobuf:"bytes,1,opt,name=curator,proto3" json:"curator,omitempty"` - // name will be used to create a bank denom for this basket token. + // name will be used to together with prefix to create a bank denom for this + // basket token. It can be between 3-8 alphanumeric characters, with the + // first character being alphabetic. The bank denom will be + // `eco/` and its display name will be `eco/`. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - // display_name will be used to create a bank Metadata display name for this - // basket token. - DisplayName string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` + // prefix is a single alphabetic character that denotes + // the denom prefix and indicates in some way what relationship is between + // the denom and display denom. Standard conventions are that m indicates + // milli (10^3), u indicates micro (10^6), n indicates nano (10^9). + Prefix string `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix,omitempty"` + // description is a human-readable description of the basket denom that should + // be at most 256 characters. + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` // exponent is the exponent that will be used for converting credits to basket // tokens and for bank denom metadata. It also limits the precision of // credit amounts when putting credits into a basket. An exponent of 6 will - // mean that 10^6 units of a basket token will be issued for 1.0 credits and - // that this should be displayed as one unit in user interfaces. It also means + // mean that 10^6 units of a basket token will be issued for 1.0 credits and that + // this should be displayed as one unit in user interfaces. It also means // that the maximum precision of credit amounts is 6 decimal places so that // the need to round is eliminated. The exponent must be >= the precision of // the credit type at the time the basket is created. - Exponent uint32 `protobuf:"varint,4,opt,name=exponent,proto3" json:"exponent,omitempty"` + Exponent uint32 `protobuf:"varint,5,opt,name=exponent,proto3" json:"exponent,omitempty"` // disable_auto_retire allows auto-retirement to be disabled. // The credits will be auto-retired if disable_auto_retire is // false unless the credits were previously put into the basket by the // address picking them from the basket, in which case they will remain // tradable. - DisableAutoRetire bool `protobuf:"varint,5,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` - // credit_type_name filters against credits from this credit type name. - CreditTypeName string `protobuf:"bytes,6,opt,name=credit_type_name,json=creditTypeName,proto3" json:"credit_type_name,omitempty"` + DisableAutoRetire bool `protobuf:"varint,6,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` + // credit_type_abbrev is the abbreviation of the credit type this basket is + // able to hold. + CreditTypeAbbrev string `protobuf:"bytes,7,opt,name=credit_type_abbrev,json=creditTypeAbbrev,proto3" json:"credit_type_abbrev,omitempty"` // allowed_classes are the credit classes allowed to be put in the basket - AllowedClasses []string `protobuf:"bytes,7,rep,name=allowed_classes,json=allowedClasses,proto3" json:"allowed_classes,omitempty"` + AllowedClasses []string `protobuf:"bytes,8,rep,name=allowed_classes,json=allowedClasses,proto3" json:"allowed_classes,omitempty"` // date_criteria is the date criteria for batches admitted to the basket. - DateCriteria *DateCriteria `protobuf:"bytes,8,opt,name=date_criteria,json=dateCriteria,proto3" json:"date_criteria,omitempty"` + DateCriteria *DateCriteria `protobuf:"bytes,9,opt,name=date_criteria,json=dateCriteria,proto3" json:"date_criteria,omitempty"` // fee is the fee that the curator will pay to create the basket. It must be // >= the required Params.basket_creation_fee. We include the fee explicitly // here so that the curator explicitly acknowledges paying this fee and // is not surprised to learn that the paid a big fee and didn't know // beforehand. - Fee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,9,rep,name=fee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee"` + Fee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,10,rep,name=fee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee"` } func (m *MsgCreate) Reset() { *m = MsgCreate{} } @@ -116,9 +125,16 @@ func (m *MsgCreate) GetName() string { return "" } -func (m *MsgCreate) GetDisplayName() string { +func (m *MsgCreate) GetPrefix() string { if m != nil { - return m.DisplayName + return m.Prefix + } + return "" +} + +func (m *MsgCreate) GetDescription() string { + if m != nil { + return m.Description } return "" } @@ -137,9 +153,9 @@ func (m *MsgCreate) GetDisableAutoRetire() bool { return false } -func (m *MsgCreate) GetCreditTypeName() string { +func (m *MsgCreate) GetCreditTypeAbbrev() string { if m != nil { - return m.CreditTypeName + return m.CreditTypeAbbrev } return "" } @@ -328,7 +344,7 @@ func (m *MsgPutResponse) GetAmountReceived() string { type MsgTake struct { // owner is the owner of the basket tokens. Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - // basket_denom is the basket denom to take credits from. + // basket_denom is the basket bank denom to take credits from. BasketDenom string `protobuf:"bytes,2,opt,name=basket_denom,json=basketDenom,proto3" json:"basket_denom,omitempty"` // amount is the integer number of basket tokens to convert into credits. Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` @@ -469,50 +485,51 @@ func init() { } var fileDescriptor_a60f962a3c61f018 = []byte{ - // 679 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xc1, 0x4e, 0xdb, 0x4c, - 0x10, 0x8e, 0x31, 0x24, 0x64, 0x03, 0xe1, 0x67, 0x41, 0xbf, 0x4c, 0x0e, 0x21, 0x58, 0xfc, 0xc2, - 0x7f, 0x55, 0xec, 0x86, 0x4a, 0x55, 0x7b, 0x84, 0x70, 0x24, 0x2d, 0x72, 0x51, 0x0f, 0x55, 0x2b, - 0x6b, 0x63, 0x4f, 0x5d, 0x2b, 0xce, 0x6e, 0xe4, 0x5d, 0x07, 0xb8, 0xf7, 0x01, 0x78, 0x8c, 0xaa, - 0xb7, 0xbe, 0x05, 0x47, 0x8e, 0x3d, 0xb5, 0x15, 0xbc, 0x48, 0xe5, 0xdd, 0x8d, 0x8b, 0x84, 0x1a, - 0x2a, 0x4e, 0xde, 0xf9, 0xe6, 0x9b, 0xd9, 0x99, 0xf9, 0xc6, 0x8b, 0xec, 0x0c, 0x62, 0xa0, 0x1e, - 0x84, 0x2c, 0xcc, 0x20, 0x4a, 0x84, 0x37, 0x20, 0x7c, 0x08, 0xc2, 0x9b, 0x74, 0x3d, 0x71, 0xe6, - 0x8e, 0x33, 0x26, 0x18, 0xde, 0x90, 0x1c, 0xb7, 0xe4, 0xb8, 0x8a, 0xe3, 0x4e, 0xba, 0xad, 0xf5, - 0x98, 0xc5, 0x4c, 0xb2, 0xbc, 0xe2, 0xa4, 0x02, 0x5a, 0xff, 0xcd, 0x48, 0x7a, 0x3e, 0x06, 0xae, - 0x69, 0xed, 0x90, 0xf1, 0x11, 0xe3, 0x85, 0x17, 0xbc, 0x49, 0x77, 0x00, 0x82, 0x74, 0xbd, 0x90, - 0x25, 0x54, 0xf9, 0xed, 0xcf, 0x26, 0xaa, 0xf7, 0x79, 0xdc, 0xcb, 0x80, 0x08, 0xc0, 0x16, 0xaa, - 0x85, 0x79, 0x46, 0x04, 0xcb, 0x2c, 0xa3, 0x63, 0x38, 0x75, 0x7f, 0x6a, 0x62, 0x8c, 0xe6, 0x29, - 0x19, 0x81, 0x35, 0x27, 0x61, 0x79, 0xc6, 0x5b, 0x68, 0x29, 0x4a, 0xf8, 0x38, 0x25, 0xe7, 0x81, - 0xf4, 0x99, 0xd2, 0xd7, 0xd0, 0xd8, 0xcb, 0x82, 0xd2, 0x42, 0x8b, 0x70, 0x36, 0x66, 0x14, 0xa8, - 0xb0, 0xe6, 0x3b, 0x86, 0xb3, 0xec, 0x97, 0x36, 0x76, 0xd1, 0x5a, 0x94, 0x70, 0x32, 0x48, 0x21, - 0x20, 0xb9, 0x60, 0x41, 0x06, 0x22, 0xc9, 0xc0, 0x5a, 0xe8, 0x18, 0xce, 0xa2, 0xbf, 0xaa, 0x5d, - 0xfb, 0xb9, 0x60, 0xbe, 0x74, 0x60, 0x07, 0xfd, 0xa3, 0x5a, 0x0d, 0x8a, 0x06, 0xd5, 0x95, 0x55, - 0x79, 0x65, 0x53, 0xe1, 0x27, 0xe7, 0x63, 0x90, 0xb7, 0xee, 0xa0, 0x15, 0x92, 0xa6, 0xec, 0x14, - 0xa2, 0x20, 0x4c, 0x09, 0xe7, 0xc0, 0xad, 0x5a, 0xc7, 0x2c, 0x88, 0x1a, 0xee, 0x29, 0x14, 0x1f, - 0xa1, 0xe5, 0x88, 0x08, 0x08, 0xc2, 0x2c, 0x11, 0x90, 0x25, 0xc4, 0x5a, 0xec, 0x18, 0x4e, 0x63, - 0x6f, 0xc7, 0xfd, 0xa3, 0x1a, 0xee, 0x21, 0x11, 0xd0, 0xd3, 0x74, 0x7f, 0x29, 0xba, 0x65, 0xe1, - 0xf7, 0xc8, 0xfc, 0x00, 0x60, 0xd5, 0x3b, 0xa6, 0xd3, 0xd8, 0xdb, 0x70, 0xd5, 0xe4, 0x8b, 0x50, - 0x70, 0xf5, 0xe4, 0xdd, 0x1e, 0x4b, 0xe8, 0xc1, 0x93, 0xcb, 0xef, 0x9b, 0x95, 0x2f, 0x3f, 0x36, - 0x9d, 0x38, 0x11, 0x1f, 0xf3, 0x81, 0x1b, 0xb2, 0x91, 0xa7, 0x65, 0x52, 0x9f, 0x5d, 0x1e, 0x0d, - 0xb5, 0x8a, 0x45, 0x00, 0xf7, 0x8b, 0xbc, 0xf6, 0x33, 0xb4, 0x5a, 0x2a, 0xe5, 0x03, 0x1f, 0x33, - 0xca, 0xa5, 0x06, 0xaa, 0xb6, 0x20, 0x02, 0xca, 0x46, 0x5a, 0xb6, 0x86, 0xc2, 0x0e, 0x0b, 0xc8, - 0xfe, 0x64, 0xa0, 0x6a, 0x9f, 0xc7, 0xc7, 0xb9, 0xc0, 0xeb, 0x68, 0x81, 0x9d, 0x52, 0x98, 0xaa, - 0xab, 0x8c, 0x3b, 0x39, 0xe6, 0xee, 0xe4, 0xc0, 0xfb, 0xa8, 0xa6, 0x26, 0xc1, 0x2d, 0x53, 0xb6, - 0x37, 0x6b, 0x44, 0x07, 0xf2, 0xd4, 0x93, 0xb0, 0x3f, 0x8d, 0xb3, 0x5f, 0xa0, 0xa6, 0xaa, 0xa2, - 0xac, 0xbd, 0x90, 0x69, 0xc4, 0x72, 0x2a, 0x82, 0x0c, 0x42, 0x48, 0x26, 0x10, 0xe9, 0xba, 0x9a, - 0x0a, 0xf6, 0x35, 0x6a, 0x7f, 0x35, 0x50, 0xad, 0xcf, 0xe3, 0x13, 0x32, 0x84, 0x87, 0xb7, 0xf0, - 0x2f, 0xaa, 0xaa, 0xb4, 0x7a, 0x4f, 0xb5, 0x85, 0x3d, 0xb4, 0xa6, 0x36, 0x6f, 0x04, 0x54, 0x04, - 0x29, 0x0b, 0x89, 0x48, 0x18, 0x95, 0xdb, 0x5a, 0xf7, 0xf1, 0x6f, 0xd7, 0x91, 0xf6, 0xe0, 0x6d, - 0xd4, 0x54, 0x68, 0xc0, 0x68, 0x20, 0xc8, 0x70, 0xba, 0xb2, 0x4b, 0x0a, 0x7d, 0x45, 0x8b, 0x3a, - 0xed, 0x13, 0xb4, 0xa2, 0x4b, 0x2e, 0xfb, 0xbd, 0x35, 0x44, 0xe3, 0x61, 0x43, 0xdc, 0xbb, 0x98, - 0x43, 0x66, 0x9f, 0xc7, 0xf8, 0x1d, 0xaa, 0xea, 0x5f, 0x76, 0x7b, 0x46, 0x8e, 0x72, 0x5d, 0x5a, - 0x8f, 0xff, 0x86, 0x55, 0x16, 0xfa, 0x1a, 0x99, 0xc5, 0xb6, 0x6c, 0xcd, 0x0e, 0x3a, 0xce, 0x45, - 0xeb, 0xff, 0x7b, 0x29, 0x65, 0xd2, 0x37, 0x68, 0x5e, 0x0a, 0x68, 0xcf, 0x0e, 0x29, 0x38, 0xad, - 0x47, 0xf7, 0x73, 0xa6, 0x79, 0x0f, 0xfc, 0xcb, 0xeb, 0xb6, 0x71, 0x75, 0xdd, 0x36, 0x7e, 0x5e, - 0xb7, 0x8d, 0x8b, 0x9b, 0x76, 0xe5, 0xea, 0xa6, 0x5d, 0xf9, 0x76, 0xd3, 0xae, 0xbc, 0x7d, 0x7e, - 0xeb, 0xff, 0x92, 0xf9, 0x76, 0x29, 0x88, 0x53, 0x96, 0x0d, 0xb5, 0x95, 0x42, 0x14, 0x43, 0xe6, - 0x9d, 0xdd, 0x79, 0x44, 0x07, 0x55, 0xf9, 0x38, 0x3e, 0xfd, 0x15, 0x00, 0x00, 0xff, 0xff, 0x90, - 0x01, 0x8a, 0x8e, 0xba, 0x05, 0x00, 0x00, + // 698 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcd, 0x4e, 0x1b, 0x49, + 0x10, 0xf6, 0x30, 0xe0, 0x9f, 0x36, 0x98, 0xa5, 0x41, 0x68, 0xf0, 0xc1, 0x98, 0x11, 0x2b, 0xbc, + 0x2b, 0x98, 0x59, 0xb3, 0xd2, 0x6a, 0xf7, 0x08, 0xe6, 0x88, 0xb5, 0x68, 0x16, 0xed, 0x21, 0x4a, + 0x34, 0x6a, 0xcf, 0x14, 0x93, 0x91, 0xed, 0x6e, 0xab, 0xbb, 0x6d, 0xcc, 0x3d, 0x0f, 0xc0, 0x73, + 0xe4, 0x96, 0x67, 0xc8, 0x85, 0x23, 0xc7, 0x9c, 0x92, 0x08, 0x5e, 0x24, 0x9a, 0xee, 0xf6, 0xc4, + 0x12, 0x8a, 0x89, 0x38, 0xb9, 0xeb, 0xab, 0xaf, 0x3e, 0x57, 0xd7, 0x57, 0xd3, 0xc8, 0xe5, 0x90, + 0x00, 0xf5, 0x21, 0x62, 0x11, 0x87, 0x38, 0x95, 0x7e, 0x8f, 0x88, 0x3e, 0x48, 0x7f, 0xd2, 0xf6, + 0xe5, 0xd4, 0x1b, 0x71, 0x26, 0x19, 0xde, 0x51, 0x1c, 0x2f, 0xe7, 0x78, 0x9a, 0xe3, 0x4d, 0xda, + 0xf5, 0xad, 0x84, 0x25, 0x4c, 0xb1, 0xfc, 0xec, 0xa4, 0x0b, 0xea, 0xbf, 0x2e, 0x10, 0xbd, 0x19, + 0x81, 0x30, 0xb4, 0x46, 0xc4, 0xc4, 0x90, 0x89, 0x2c, 0x0b, 0xfe, 0xa4, 0xdd, 0x03, 0x49, 0xda, + 0x7e, 0xc4, 0x52, 0xaa, 0xf3, 0xee, 0x47, 0x1b, 0x55, 0xba, 0x22, 0xe9, 0x70, 0x20, 0x12, 0xb0, + 0x83, 0x4a, 0xd1, 0x98, 0x13, 0xc9, 0xb8, 0x63, 0x35, 0xad, 0x56, 0x25, 0x98, 0x85, 0x18, 0xa3, + 0x65, 0x4a, 0x86, 0xe0, 0x2c, 0x29, 0x58, 0x9d, 0xf1, 0x36, 0x2a, 0x8e, 0x38, 0x5c, 0xa5, 0x53, + 0xc7, 0x56, 0xa8, 0x89, 0x70, 0x13, 0x55, 0x63, 0x10, 0x11, 0x4f, 0x47, 0x32, 0x65, 0xd4, 0x59, + 0x56, 0xc9, 0x79, 0x08, 0xd7, 0x51, 0x19, 0xa6, 0x23, 0x46, 0x81, 0x4a, 0x67, 0xa5, 0x69, 0xb5, + 0xd6, 0x82, 0x3c, 0xc6, 0x1e, 0xda, 0x8c, 0x53, 0x41, 0x7a, 0x03, 0x08, 0xc9, 0x58, 0xb2, 0x90, + 0x83, 0x4c, 0x39, 0x38, 0xc5, 0xa6, 0xd5, 0x2a, 0x07, 0x1b, 0x26, 0x75, 0x32, 0x96, 0x2c, 0x50, + 0x09, 0x7c, 0x88, 0xb0, 0x9e, 0x40, 0x98, 0xdd, 0x3b, 0x24, 0xbd, 0x1e, 0x87, 0x89, 0x53, 0x52, + 0x7f, 0xfa, 0x8b, 0xce, 0x5c, 0xde, 0x8c, 0xe0, 0x44, 0xe1, 0xf8, 0x00, 0xad, 0x93, 0xc1, 0x80, + 0x5d, 0x43, 0x1c, 0x46, 0x03, 0x22, 0x04, 0x08, 0xa7, 0xdc, 0xb4, 0x5b, 0x95, 0xa0, 0x66, 0xe0, + 0x8e, 0x46, 0xf1, 0x39, 0x5a, 0x8b, 0x89, 0x84, 0x30, 0xe2, 0xa9, 0x04, 0x9e, 0x12, 0xa7, 0xd2, + 0xb4, 0x5a, 0xd5, 0xe3, 0x03, 0xef, 0x87, 0x46, 0x79, 0x67, 0x44, 0x42, 0xc7, 0xd0, 0x83, 0xd5, + 0x78, 0x2e, 0xc2, 0x6f, 0x90, 0x7d, 0x05, 0xe0, 0xa0, 0xa6, 0xdd, 0xaa, 0x1e, 0xef, 0x78, 0xda, + 0x94, 0xac, 0x14, 0x3c, 0x63, 0x8a, 0xd7, 0x61, 0x29, 0x3d, 0xfd, 0xe3, 0xee, 0xf3, 0x6e, 0xe1, + 0xfd, 0x97, 0xdd, 0x56, 0x92, 0xca, 0xb7, 0xe3, 0x9e, 0x17, 0xb1, 0xa1, 0x6f, 0x1c, 0xd4, 0x3f, + 0x47, 0x22, 0xee, 0x1b, 0x83, 0xb3, 0x02, 0x11, 0x64, 0xba, 0xee, 0x5f, 0x68, 0x23, 0x37, 0x31, + 0x00, 0x31, 0x62, 0x54, 0x00, 0xde, 0x43, 0xab, 0xba, 0xb7, 0x30, 0x06, 0xca, 0x86, 0xc6, 0xd1, + 0xaa, 0xc6, 0xce, 0x32, 0xc8, 0x7d, 0x67, 0xa1, 0x62, 0x57, 0x24, 0x17, 0x63, 0x89, 0xb7, 0xd0, + 0x0a, 0xbb, 0xa6, 0x30, 0x33, 0x5e, 0x07, 0x4f, 0x34, 0x96, 0x9e, 0x68, 0xe0, 0x13, 0x54, 0xd2, + 0x93, 0x10, 0x8e, 0xad, 0xae, 0xb7, 0x68, 0x44, 0xa7, 0xea, 0xd4, 0x51, 0x70, 0x30, 0xab, 0x73, + 0xff, 0x41, 0x35, 0xdd, 0x45, 0xde, 0x7b, 0x66, 0xd3, 0x90, 0x8d, 0xa9, 0x0c, 0x39, 0x44, 0x90, + 0x4e, 0x20, 0x36, 0x7d, 0xd5, 0x34, 0x1c, 0x18, 0xd4, 0xfd, 0x60, 0xa1, 0x52, 0x57, 0x24, 0x97, + 0xa4, 0x0f, 0x2f, 0xbf, 0xc2, 0x36, 0x2a, 0x6a, 0xd9, 0xd9, 0x22, 0xeb, 0x08, 0xfb, 0x68, 0x53, + 0x6f, 0xdf, 0x10, 0xa8, 0x0c, 0x07, 0x2c, 0x22, 0x73, 0x0b, 0x8d, 0xbf, 0xa7, 0xce, 0x4d, 0x06, + 0xef, 0xa3, 0x9a, 0x46, 0x43, 0x46, 0x43, 0x49, 0xfa, 0xa0, 0xb6, 0xbb, 0x1c, 0xac, 0x6a, 0xf4, + 0x5f, 0x9a, 0xf5, 0xe9, 0x5e, 0xa2, 0x75, 0xd3, 0x72, 0x7e, 0xdf, 0xb9, 0x21, 0x5a, 0x2f, 0x1b, + 0xe2, 0xf1, 0xed, 0x12, 0xb2, 0xbb, 0x22, 0xc1, 0xaf, 0x51, 0xd1, 0x7c, 0xcd, 0xfb, 0x0b, 0x34, + 0xf2, 0x75, 0xa9, 0x1f, 0xfe, 0x0c, 0x2b, 0x6f, 0xf4, 0x3f, 0x64, 0x67, 0xdb, 0xb2, 0xb7, 0xb8, + 0xe8, 0x62, 0x2c, 0xeb, 0xbf, 0x3d, 0x4b, 0xc9, 0x45, 0xff, 0x47, 0xcb, 0xca, 0x40, 0x77, 0x71, + 0x49, 0xc6, 0xa9, 0xff, 0xfe, 0x3c, 0x67, 0xa6, 0x7b, 0x1a, 0xdc, 0x3d, 0x34, 0xac, 0xfb, 0x87, + 0x86, 0xf5, 0xf5, 0xa1, 0x61, 0xdd, 0x3e, 0x36, 0x0a, 0xf7, 0x8f, 0x8d, 0xc2, 0xa7, 0xc7, 0x46, + 0xe1, 0xd5, 0xdf, 0x73, 0xdf, 0x97, 0xd2, 0x3b, 0xa2, 0x20, 0xaf, 0x19, 0xef, 0x9b, 0x68, 0x00, + 0x71, 0x02, 0xdc, 0x9f, 0x3e, 0x79, 0x5f, 0x7b, 0x45, 0xf5, 0x6e, 0xfe, 0xf9, 0x2d, 0x00, 0x00, + 0xff, 0xff, 0xd8, 0xd3, 0xe4, 0x13, 0xd5, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -706,7 +723,7 @@ func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } } if m.DateCriteria != nil { @@ -719,7 +736,7 @@ func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if len(m.AllowedClasses) > 0 { for iNdEx := len(m.AllowedClasses) - 1; iNdEx >= 0; iNdEx-- { @@ -727,15 +744,15 @@ func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AllowedClasses[iNdEx]) i = encodeVarintTx(dAtA, i, uint64(len(m.AllowedClasses[iNdEx]))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 } } - if len(m.CreditTypeName) > 0 { - i -= len(m.CreditTypeName) - copy(dAtA[i:], m.CreditTypeName) - i = encodeVarintTx(dAtA, i, uint64(len(m.CreditTypeName))) + if len(m.CreditTypeAbbrev) > 0 { + i -= len(m.CreditTypeAbbrev) + copy(dAtA[i:], m.CreditTypeAbbrev) + i = encodeVarintTx(dAtA, i, uint64(len(m.CreditTypeAbbrev))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if m.DisableAutoRetire { i-- @@ -745,17 +762,24 @@ func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if m.Exponent != 0 { i = encodeVarintTx(dAtA, i, uint64(m.Exponent)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } - if len(m.DisplayName) > 0 { - i -= len(m.DisplayName) - copy(dAtA[i:], m.DisplayName) - i = encodeVarintTx(dAtA, i, uint64(len(m.DisplayName))) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 + } + if len(m.Prefix) > 0 { + i -= len(m.Prefix) + copy(dAtA[i:], m.Prefix) + i = encodeVarintTx(dAtA, i, uint64(len(m.Prefix))) i-- dAtA[i] = 0x1a } @@ -1010,7 +1034,11 @@ func (m *MsgCreate) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.DisplayName) + l = len(m.Prefix) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1020,7 +1048,7 @@ func (m *MsgCreate) Size() (n int) { if m.DisableAutoRetire { n += 2 } - l = len(m.CreditTypeName) + l = len(m.CreditTypeAbbrev) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1236,7 +1264,7 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DisplayName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1264,9 +1292,41 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DisplayName = string(dAtA[iNdEx:postIndex]) + m.Prefix = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Exponent", wireType) } @@ -1285,7 +1345,7 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DisableAutoRetire", wireType) } @@ -1305,9 +1365,9 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { } } m.DisableAutoRetire = bool(v != 0) - case 6: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreditTypeName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CreditTypeAbbrev", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1335,9 +1395,9 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CreditTypeName = string(dAtA[iNdEx:postIndex]) + m.CreditTypeAbbrev = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AllowedClasses", wireType) } @@ -1369,7 +1429,7 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { } m.AllowedClasses = append(m.AllowedClasses, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DateCriteria", wireType) } @@ -1405,7 +1465,7 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) } diff --git a/x/ecocredit/client/basket/tx.go b/x/ecocredit/client/basket/tx.go index 4ce22f7109..b8c2b0c68f 100644 --- a/x/ecocredit/client/basket/tx.go +++ b/x/ecocredit/client/basket/tx.go @@ -18,14 +18,15 @@ import ( ) const ( - FlagDisplayName = "display-name" - FlagExponent = "exponent" - FlagDisableAutoRetire = "disable-auto-retire" - FlagCreditTypeName = "credit-type-name" - FlagAllowedClasses = "allowed-classes" - FlagMinimumStartDate = "minimum-start-date" - FlagStartDateWindow = "start-date-window" - FlagBasketFee = "basket-fee" + FlagDenomPrefix = "denom-prefix" + FlagExponent = "exponent" + FlagDisableAutoRetire = "disable-auto-retire" + FlagCreditTypeAbbreviation = "credit-type-abbreviation" + FlagAllowedClasses = "allowed-classes" + FlagMinimumStartDate = "minimum-start-date" + FlagStartDateWindow = "start-date-window" + FlagBasketFee = "basket-fee" + FlagDenomDescription = "description-description" ) func TxCreateBasket() *cobra.Command { @@ -38,7 +39,7 @@ Parameters: name: the name used to create a bank denom for this basket token. Flags: - display_name: the name used to create a bank denom display name. + denom_prefix: the prefix to be used in the basket coin's base denom. Must only be one character. exponent: the exponent used for converting credits to basket tokens and for bank denom metadata. The exponent also limits the precision of credit amounts when putting credits into a basket. An exponent of 6 will mean that 10^6 units @@ -51,7 +52,7 @@ Flags: from the basket. The credits will be auto-retired if disable_auto_retire is false unless the credits were previously put into the basket by the address picking them from the basket, in which case they will remain tradable. - credit_type_name: filters against credits from this credit type name (e.g. "carbon"). + credit_type_abbreviation: filters against credits from this credit type abbreviation (e.g. "BIO"). allowed_classes: comma separated (no spaces) list of credit classes allowed to be put in the basket (e.g. "C01,C02"). min_start_date: the earliest start date for batches of credits allowed into the basket. @@ -63,6 +64,7 @@ Flags: required Params.basket_creation_fee. We include the fee explicitly here so that the curator explicitly acknowledges paying this fee and is not surprised to learn that the paid a big fee and didn't know beforehand. + description: the description to be used in the basket coin's bank denom metadata. `), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -71,7 +73,7 @@ Flags: return err } - displayName, err := cmd.Flags().GetString(FlagDisplayName) + denomPrefix, err := cmd.Flags().GetString(FlagDenomPrefix) if err != nil { return err } @@ -90,7 +92,7 @@ Flags: return err } - creditTypeName, err := cmd.Flags().GetString(FlagCreditTypeName) + creditTypeName, err := cmd.Flags().GetString(FlagCreditTypeAbbreviation) if err != nil { return err } @@ -113,6 +115,11 @@ Flags: return err } + denomDescription, err := cmd.Flags().GetString(FlagDenomDescription) + if err != nil { + return err + } + if minStartDateString == "" && startDateWindowString == "" { return fmt.Errorf("either min-start-date or start-date-window required") } else if minStartDateString != "" && startDateWindowString != "" { @@ -141,13 +148,7 @@ Flags: return err } startDateWindowDuration := time.Duration(startDateWindowInt) - if err != nil { - return fmt.Errorf("failed to parse start-date-window: %w", err) - } startDateWindow := types.DurationProto(startDateWindowDuration) - if err != nil { - return fmt.Errorf("failed to parse start-date-window: %w", err) - } dateCriteria.Sum = &basket.DateCriteria_StartDateWindow{ StartDateWindow: startDateWindow, } @@ -168,10 +169,11 @@ Flags: msg := basket.MsgCreate{ Curator: clientCtx.FromAddress.String(), Name: args[0], - DisplayName: displayName, + Prefix: denomPrefix, + Description: denomDescription, Exponent: uint32(exponent), DisableAutoRetire: disableAutoRetire, - CreditTypeName: creditTypeName, + CreditTypeAbbrev: creditTypeName, AllowedClasses: allowedClasses, DateCriteria: &dateCriteria, Fee: fee, @@ -188,20 +190,22 @@ Flags: flags.AddTxFlagsToCmd(cmd) // command flags - cmd.Flags().String(FlagDisplayName, "", "the name used to create a bank denom display name") + cmd.Flags().String(FlagDenomPrefix, "", "the name used to create a bank denom display name") cmd.Flags().String(FlagExponent, "", "the exponent used for converting credits to basket tokens") cmd.Flags().Bool(FlagDisableAutoRetire, false, "dictates whether credits will be auto-retired upon taking") - cmd.Flags().String(FlagCreditTypeName, "", "filters against credits from this credit type name (e.g. \"carbon\")") + cmd.Flags().String(FlagCreditTypeAbbreviation, "", "filters against credits from this credit type name (e.g. \"carbon\")") cmd.Flags().String(FlagAllowedClasses, "", "comma separated (no spaces) list of credit classes allowed to be put in the basket (e.g. \"C01,C02\")") cmd.Flags().String(FlagMinimumStartDate, "", "the earliest start date for batches of credits allowed into the basket (e.g. \"2012-01-01\")") cmd.Flags().String(FlagStartDateWindow, "", "sets a cutoff for batch start dates when adding new credits to the basket (e.g. \"1325404800\")") cmd.Flags().String(FlagBasketFee, "", "the fee that the curator will pay to create the basket (e.g. \"20regen\")") + cmd.Flags().String(FlagDenomDescription, "", "the description to be used in the bank denom metadata.") // required flags - cmd.MarkFlagRequired(FlagDisplayName) + cmd.MarkFlagRequired(FlagDenomPrefix) cmd.MarkFlagRequired(FlagExponent) - cmd.MarkFlagRequired(FlagCreditTypeName) + cmd.MarkFlagRequired(FlagCreditTypeAbbreviation) cmd.MarkFlagRequired(FlagAllowedClasses) + cmd.MarkFlagRequired(FlagDenomPrefix) return cmd } diff --git a/x/ecocredit/denom.go b/x/ecocredit/denom.go index 0622115bae..76f0deb450 100644 --- a/x/ecocredit/denom.go +++ b/x/ecocredit/denom.go @@ -3,7 +3,10 @@ package ecocredit import ( "fmt" "regexp" + "sort" "time" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // Calculate the ID to use for a new credit class, based on the credit type and @@ -76,3 +79,38 @@ func ValidateDenom(denom string) error { } return nil } + +// exponent prefix map https://en.wikipedia.org/wiki/Metric_prefix +var exponentPrefixMap = map[uint32]string{ + 0: "", + 1: "d", + 2: "c", + 3: "m", + 6: "u", + 9: "n", + 12: "p", + 15: "f", + 18: "a", + 21: "z", + 24: "y", +} +var validExponents string + +func init() { + var exponents = make([]uint32, len(exponentPrefixMap)) + for e := range exponentPrefixMap { + exponents = append(exponents, e) + } + sort.Slice(exponents, func(i, j int) bool { return exponents[i] < exponents[j] }) + validExponents = fmt.Sprint(validExponents) +} + +// ExponentToPrefix returns a denom prefix for a given exponent. +// Returns error if the exponent is not supported. +func ExponentToPrefix(exponent uint32) (string, error) { + e, ok := exponentPrefixMap[exponent] + if !ok { + return "", sdkerrors.ErrInvalidRequest.Wrapf("exponent must be one of %s", validExponents) + } + return e, nil +} diff --git a/x/ecocredit/go.mod b/x/ecocredit/go.mod index 1087b3c748..a78f2894ab 100644 --- a/x/ecocredit/go.mod +++ b/x/ecocredit/go.mod @@ -13,7 +13,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/pkg/errors v0.9.1 - github.com/regen-network/regen-ledger/api v0.3.0 + github.com/regen-network/regen-ledger/api v0.4.0 github.com/regen-network/regen-ledger/orm v1.0.0-beta1 github.com/regen-network/regen-ledger/types v1.0.0 github.com/spf13/cobra v1.2.1 diff --git a/x/ecocredit/go.sum b/x/ecocredit/go.sum index 4f144f1aeb..bacde1d620 100644 --- a/x/ecocredit/go.sum +++ b/x/ecocredit/go.sum @@ -911,8 +911,8 @@ github.com/regen-network/cosmos-sdk v0.44.2-regen-1 h1:Sm7rU4rMwLpEpgrQkF/4w/V/y github.com/regen-network/cosmos-sdk v0.44.2-regen-1/go.mod h1:fwQJdw+aECatpTvQTo1tSfHEsxACdZYU80QCZUPnHr4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= -github.com/regen-network/regen-ledger/api v0.3.0 h1:gam9DzeklPi9OySQoS2RIwzQhUBwd5UDK8joe0YqHA4= -github.com/regen-network/regen-ledger/api v0.3.0/go.mod h1:kWly2pK0u3fDfyoYYilpEoTEg61pCjV/f5XSY0KzJQY= +github.com/regen-network/regen-ledger/api v0.4.0 h1:klcMljLCHU3MpkRyjrEXL6KKsDGeqFBt2aFUwFdpEH8= +github.com/regen-network/regen-ledger/api v0.4.0/go.mod h1:kWly2pK0u3fDfyoYYilpEoTEg61pCjV/f5XSY0KzJQY= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= diff --git a/x/ecocredit/params.go b/x/ecocredit/params.go index db12244b6d..18630a3980 100644 --- a/x/ecocredit/params.go +++ b/x/ecocredit/params.go @@ -126,7 +126,7 @@ func validateCreditTypes(i interface{}) error { // Validate abbreviation abbr := creditType.Abbreviation - err := validateCreditTypeAbbreviation(abbr) + err := ValidateCreditTypeAbbreviation(abbr) if err != nil { return err } @@ -153,13 +153,12 @@ func validateCreditTypes(i interface{}) error { return nil } -// Check that CreditType abbreviation is valid, i.e. it consists of 1-3 -// uppercase letters -func validateCreditTypeAbbreviation(abbr string) error { +// ValidateCreditTypeAbbreviation asserts that the argument is 1-3 latin alphabet uppercase letters +func ValidateCreditTypeAbbreviation(abbr string) error { reAbbr := regexp.MustCompile(`^[A-Z]{1,3}$`) matches := reAbbr.FindStringSubmatch(abbr) if matches == nil { - return sdkerrors.ErrInvalidRequest.Wrapf("credit type abbreviation must be 1-3 uppercase letters: got %s", abbr) + return sdkerrors.ErrInvalidRequest.Wrapf("credit type abbreviation must be 1-3 uppercase latin letters: got %s", abbr) } return nil } diff --git a/x/ecocredit/server/basket/create.go b/x/ecocredit/server/basket/create.go index 566d863c78..b99e24ac4f 100644 --- a/x/ecocredit/server/basket/create.go +++ b/x/ecocredit/server/basket/create.go @@ -17,9 +17,8 @@ import ( func (k Keeper) Create(ctx context.Context, msg *basket.MsgCreate) (*basket.MsgCreateResponse, error) { rgCtx := types.UnwrapSDKContext(ctx) fee := k.ecocreditKeeper.GetCreateBasketFee(ctx) - if err := basket.ValidateCreateFee(msg, fee); err != nil { + if err := basket.ValidateMsgCreate(msg, fee); err != nil { return nil, err - } sender, err := sdk.AccAddressFromBech32(msg.Curator) if err != nil { @@ -30,17 +29,18 @@ func (k Keeper) Create(ctx context.Context, msg *basket.MsgCreate) (*basket.MsgC if err != nil { return nil, err } - if err = validateCreditType(ctx, k.ecocreditKeeper, msg.CreditTypeName, msg.Exponent); err != nil { + if err = validateCreditType(ctx, k.ecocreditKeeper, msg.CreditTypeAbbrev, msg.Exponent); err != nil { + return nil, err + } + denom, displayDenomName, err := basket.MsgCreateDenom(msg) + if err != nil { return nil, err } - - // TODO: need to decide about the denom creation - denom := msg.Name id, err := k.stateStore.BasketStore().InsertReturningID(ctx, &basketv1.Basket{ BasketDenom: denom, DisableAutoRetire: msg.DisableAutoRetire, - CreditTypeName: msg.CreditTypeName, + CreditTypeAbbrev: msg.CreditTypeAbbrev, DateCriteria: msg.DateCriteria.ToApi(), Exponent: msg.Exponent, }) @@ -51,18 +51,26 @@ func (k Keeper) Create(ctx context.Context, msg *basket.MsgCreate) (*basket.MsgC return nil, err } + denomUnits := []*banktypes.DenomUnit{{ + Denom: displayDenomName, + Exponent: msg.Exponent, + Aliases: nil, + }} + if msg.Exponent != 0 { + denomUnits = append(denomUnits, &banktypes.DenomUnit{ + Denom: denom, + Exponent: 0, // convertion from base denom to this denom + Aliases: nil, + }) + } + k.bankKeeper.SetDenomMetaData(rgCtx.Context, banktypes.Metadata{ - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: msg.DisplayName, - Exponent: msg.Exponent, - Aliases: nil, - }, - }, - Base: denom, - Display: msg.DisplayName, - Name: msg.DisplayName, - Symbol: msg.DisplayName, + DenomUnits: denomUnits, + Description: msg.Description, + Base: denom, + Display: displayDenomName, + Name: msg.Name, + Symbol: msg.Name, }) err = rgCtx.Context.EventManager().EmitTypedEvent(&basket.EventCreate{ diff --git a/x/ecocredit/server/basket/create_test.go b/x/ecocredit/server/basket/create_test.go index 4451b3db13..8acac2756a 100644 --- a/x/ecocredit/server/basket/create_test.go +++ b/x/ecocredit/server/basket/create_test.go @@ -15,6 +15,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" + "github.com/regen-network/regen-ledger/x/ecocredit/basket" baskettypes "github.com/regen-network/regen-ledger/x/ecocredit/basket" "gotest.tools/v3/assert" ) @@ -51,8 +52,8 @@ func TestBadCreditType(t *testing.T) { }}, nil, ) _, err := s.k.Create(s.ctx, &baskettypes.MsgCreate{ - Curator: s.addr.String(), - CreditTypeName: "F", + Curator: s.addr.String(), + CreditTypeAbbrev: "F", }) assert.ErrorContains(t, err, `credit type abbreviation "F" doesn't exist`) @@ -64,9 +65,9 @@ func TestBadCreditType(t *testing.T) { }}, nil, ) _, err = s.k.Create(s.ctx, &baskettypes.MsgCreate{ - Curator: s.addr.String(), - CreditTypeName: "C", - Exponent: 3, + Curator: s.addr.String(), + CreditTypeAbbrev: "C", + Exponent: 3, }) assert.ErrorContains(t, err, "exponent") } @@ -75,8 +76,16 @@ func TestDuplicateDenom(t *testing.T) { t.Parallel() s := setupBase(t) + mc := baskettypes.MsgCreate{ + Curator: s.addr.String(), + CreditTypeAbbrev: "C", + Exponent: 6, + Name: "foo", + } + denom, _, err := basket.MsgCreateDenom(&mc) + assert.NilError(t, err) assert.NilError(t, s.stateStore.BasketStore().Insert(s.ctx, - &basketv1.Basket{BasketDenom: "foo"}, + &basketv1.Basket{BasketDenom: denom}, )) s.ecocreditKeeper.EXPECT().GetCreateBasketFee(gomock.Any()).Return(nil) // nil fee @@ -86,12 +95,7 @@ func TestDuplicateDenom(t *testing.T) { {Abbreviation: "B", Precision: 3}, {Abbreviation: "C", Precision: 6}, }}, nil, ) - _, err := s.k.Create(s.ctx, &baskettypes.MsgCreate{ - Curator: s.addr.String(), - CreditTypeName: "C", - Exponent: 6, - Name: "foo", - }) + _, err = s.k.Create(s.ctx, &mc) assert.ErrorContains(t, err, "unique") } @@ -108,11 +112,11 @@ func TestMissingClass(t *testing.T) { ) s.ecocreditKeeper.EXPECT().HasClassInfo(gomock.Any(), gomock.Any()).Return(false) _, err := s.k.Create(s.ctx, &baskettypes.MsgCreate{ - Curator: s.addr.String(), - CreditTypeName: "C", - Exponent: 6, - Name: "foo", - AllowedClasses: []string{"bar"}, + Curator: s.addr.String(), + CreditTypeAbbrev: "C", + Exponent: 6, + Name: "foo", + AllowedClasses: []string{"bar"}, }) assert.ErrorContains(t, err, "doesn't exist") } @@ -135,34 +139,37 @@ func TestGoodBasket(t *testing.T) { } s.bankKeeper.EXPECT().SetDenomMetaData(gomock.Any(), banktypes.Metadata{ - Name: "foo", - Display: "foo", - Base: "ufoo", - Symbol: "foo", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: "foo", - Exponent: 6, - }, - }, + Name: "foo", + Display: "eco.C.foo", + Base: "eco.uC.foo", + Symbol: "foo", + Description: "hi", + DenomUnits: []*banktypes.DenomUnit{{ + Denom: "eco.C.foo", + Exponent: 6, + }, { + Denom: "eco.uC.foo", + Exponent: 0, + }}, }, ) _, err := s.k.Create(s.ctx, &baskettypes.MsgCreate{ - Curator: s.addr.String(), - CreditTypeName: "C", - Exponent: 6, - Name: "ufoo", - DisplayName: "foo", - AllowedClasses: []string{"bar"}, - DateCriteria: &baskettypes.DateCriteria{Sum: dateCriteria}, + Curator: s.addr.String(), + Description: "hi", + Name: "foo", + Prefix: "u", + CreditTypeAbbrev: "C", + Exponent: 6, + AllowedClasses: []string{"bar"}, + DateCriteria: &baskettypes.DateCriteria{Sum: dateCriteria}, }) assert.NilError(t, err) - basket, err := s.stateStore.BasketStore().GetByBasketDenom(s.ctx, "ufoo") + basket, err := s.stateStore.BasketStore().GetByBasketDenom(s.ctx, "eco.uC.foo") assert.NilError(t, err) - assert.Equal(t, "ufoo", basket.BasketDenom) + assert.Equal(t, "eco.uC.foo", basket.BasketDenom) assert.Equal(t, uint32(6), basket.Exponent) - assert.Equal(t, "C", basket.CreditTypeName) + assert.Equal(t, "C", basket.CreditTypeAbbrev) assert.Equal(t, fmt.Sprintf("seconds:%.0f", seconds.Seconds()), basket.DateCriteria.Sum.(*basketv1.DateCriteria_StartDateWindow).StartDateWindow.String()) } diff --git a/x/ecocredit/server/basket/put.go b/x/ecocredit/server/basket/put.go index 4547bd3ce9..41f5190f39 100644 --- a/x/ecocredit/server/basket/put.go +++ b/x/ecocredit/server/basket/put.go @@ -121,12 +121,12 @@ func (k Keeper) canBasketAcceptCredit(ctx context.Context, basket *basketv1.Bask } // check credit type match - requiredCreditType := basket.CreditTypeName + requiredCreditType := basket.CreditTypeAbbrev res2, err := k.ecocreditKeeper.ClassInfo(ctx, &ecocredit.QueryClassInfoRequest{ClassId: batchInfo.ClassId}) if err != nil { return err } - gotCreditType := res2.Info.CreditType.Name + gotCreditType := res2.Info.CreditType.Abbreviation if requiredCreditType != gotCreditType { return errInvalidReq.Wrapf("cannot use credit of type %s in a basket that requires credit type %s", gotCreditType, requiredCreditType) } diff --git a/x/ecocredit/server/basket/put_test.go b/x/ecocredit/server/basket/put_test.go index 9fb8d55074..8f6b51b141 100644 --- a/x/ecocredit/server/basket/put_test.go +++ b/x/ecocredit/server/basket/put_test.go @@ -85,7 +85,7 @@ func TestPut(t *testing.T) { err = basketTbl.Insert(ctx, &basketv1.Basket{ BasketDenom: basketDenom, DisableAutoRetire: true, - CreditTypeName: "carbon", + CreditTypeAbbrev: "C", DateCriteria: &basketv1.DateCriteria{Sum: &basketv1.DateCriteria_MinStartDate{MinStartDate: timestamppb.New(startDate)}}, Exponent: 6, }) @@ -96,7 +96,7 @@ func TestPut(t *testing.T) { err = basketTbl.Insert(ctx, &basketv1.Basket{ BasketDenom: basketDenom2, DisableAutoRetire: true, - CreditTypeName: "carbon", + CreditTypeAbbrev: "C", DateCriteria: &basketv1.DateCriteria{Sum: &basketv1.DateCriteria_StartDateWindow{StartDateWindow: durationpb.New(dur)}}, Exponent: 6, }) @@ -274,12 +274,12 @@ func TestPut(t *testing.T) { Return(&batchInfoRes, nil) badClass := *classInfoRes.Info - badClass.CreditType.Name = "BadType" + badClass.CreditType.Abbreviation = "FOO" ecocreditKeeper.EXPECT(). ClassInfo(ctx, &ecocredit.QueryClassInfoRequest{ClassId: classId}). Return(&ecocredit.QueryClassInfoResponse{Info: &badClass}, nil) }, - errMsg: "cannot use credit of type BadType in a basket that requires credit type carbon", + errMsg: "cannot use credit of type FOO in a basket that requires credit type C", }, { name: "batch out of time window", diff --git a/x/ecocredit/server/basket/take_test.go b/x/ecocredit/server/basket/take_test.go index 39c863b3e2..2f3394a5c6 100644 --- a/x/ecocredit/server/basket/take_test.go +++ b/x/ecocredit/server/basket/take_test.go @@ -32,7 +32,7 @@ func setupTake(t *testing.T) *takeSuite { s.fooBasketId, err = s.stateStore.BasketStore().InsertReturningID(s.ctx, &basketv1.Basket{ BasketDenom: "foo", DisableAutoRetire: false, - CreditTypeName: "C", + CreditTypeAbbrev: "C", Exponent: 6, }) assert.NilError(t, err) @@ -56,7 +56,7 @@ func setupTake(t *testing.T) *takeSuite { s.barBasketId, err = s.stateStore.BasketStore().InsertReturningID(s.ctx, &basketv1.Basket{ BasketDenom: "bar", DisableAutoRetire: true, - CreditTypeName: "C", + CreditTypeAbbrev: "C", Exponent: 6, }) assert.NilError(t, err)