From 5ce8e9e6d97bde09e507d4a4a718f03531e76507 Mon Sep 17 00:00:00 2001 From: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Date: Thu, 21 Jul 2022 10:46:13 -0700 Subject: [PATCH] refactor(x/ecocredit): clean up commands and examples (#1288) * refactor(x/ecocredit): clean up commands and command examples * refactor(x/ecocredit): clean up commands and command examples * fix format and import * update credit types query * Apply suggestions from code review Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> * update changelog * improve basket query examples and update test batch denom Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> --- CHANGELOG.md | 7 + x/ecocredit/client/basket/query.go | 10 +- x/ecocredit/client/basket/tx.go | 104 +++-- x/ecocredit/client/marketplace/query.go | 53 +-- x/ecocredit/client/marketplace/tx.go | 99 +++-- x/ecocredit/client/query.go | 217 +++++----- x/ecocredit/client/testsuite/query.go | 4 +- x/ecocredit/client/testsuite/suite.go | 2 +- x/ecocredit/client/testsuite/tx_basket.go | 6 +- .../client/testsuite/tx_marketplace.go | 2 +- x/ecocredit/client/tx.go | 378 ++++++++---------- x/ecocredit/server/core/keeper_test.go | 2 +- .../server/core/query_balances_test.go | 4 +- .../core/query_batches_by_class_test.go | 2 +- .../core/query_batches_by_issuer_test.go | 2 +- .../marketplace/query_sell_orders_test.go | 2 +- 16 files changed, 414 insertions(+), 480 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ccfad4fab..0c15077289 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1274](https://github.com/regen-network/regen-ledger/pull/1274) Add `cancel-sell-order` command +#### Changed + +- [#1288](https://github.com/regen-network/regen-ledger/pull/1288) Rename `types` query command to `credit-types` +- [#1288](https://github.com/regen-network/regen-ledger/pull/1288) Rename `balance` query command to `batch-balance` +- [#1288](https://github.com/regen-network/regen-ledger/pull/1288) Rename `supply` query command to `batch-supply` +- [#1288](https://github.com/regen-network/regen-ledger/pull/1288) Rename `buy-direct-batch` transaction command to `buy-direct-bulk` + #### Fixed - [#1278](https://github.com/regen-network/regen-ledger/pull/1278) Fix `open` not set in `Msg/CreateBatch` diff --git a/x/ecocredit/client/basket/query.go b/x/ecocredit/client/basket/query.go index 80233c9822..cd02d8dea5 100644 --- a/x/ecocredit/client/basket/query.go +++ b/x/ecocredit/client/basket/query.go @@ -15,7 +15,7 @@ func QueryBasketCmd() *cobra.Command { Use: "basket [basket-denom]", Short: "Gets the info for a basket", Long: "Retrieves the information for a basket given a specific basket denom", - Example: "regen q ecocredit basket SOMEBASKET", + Example: "regen q ecocredit basket eco.uC.NCT", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientQueryContext(cmd) @@ -46,7 +46,7 @@ func QueryBasketsCmd() *cobra.Command { Long: "Retrieves all baskets currently in state, with optional pagination", Example: ` regen q ecocredit baskets -regen q ecocredit baskets --offset 1 --limit 10 +regen q ecocredit baskets --limit 10 --offset 10 `, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { @@ -82,7 +82,7 @@ func QueryBasketBalanceCmd() *cobra.Command { Short: "Retrieves the balance of a credit batch in the basket", Long: "Retrieves the balance of a credit batch in the basket", Example: ` -regen q ecocredit basket-balance BASKET C01-20210101-20220101-001 +regen q ecocredit basket-balance eco.uC.NCT C01-001-20210101-20220101-001 `, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -116,8 +116,8 @@ func QueryBasketBalancesCmd() *cobra.Command { Short: "Retrieves the balance of each credit batch for the given basket denom", Long: "Retrieves the balance of each credit batch for the given basket denom", Example: ` -regen q ecocredit basket-balances BASKET1 -regen q ecocredit basket-balances BASKET1 --offset 1 --limit 10 +regen q ecocredit basket-balances eco.uC.NCT +regen q ecocredit basket-balances eco.uC.NCT --limit 10 --offset 10 `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/ecocredit/client/basket/tx.go b/x/ecocredit/client/basket/tx.go index 2f351479ec..dfb08e2c9d 100644 --- a/x/ecocredit/client/basket/tx.go +++ b/x/ecocredit/client/basket/tx.go @@ -19,7 +19,7 @@ import ( const ( FlagDisableAutoRetire = "disable-auto-retire" - FlagCreditTypeAbbreviation = "credit-type-abbreviation" + FlagCreditTypeAbbrev = "credit-type-abbrev" FlagAllowedClasses = "allowed-classes" FlagMinimumStartDate = "minimum-start-date" FlagStartDateWindow = "start-date-window" @@ -36,33 +36,28 @@ func TxCreateBasketCmd() *cobra.Command { Long: strings.TrimSpace(`Creates a bank denom that wraps credits Parameters: - name: the name used to create a bank denom for this basket token. + +- name: the name used to create a bank denom for this basket token Flags: - disable-auto-retire: disables the auto-retirement of credits upon taking credits - 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-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. - start-date-window: the duration of time (in seconds) measured into the past which sets a - cutoff for batch start dates when adding new credits to the basket. - basket-fee: 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. - description: the description to be used in the basket coin's bank denom metadata.`), - Example: ` - $regen tx ecocredit create-basket HEAED - --from regen... - --credit-type-abbreviation=FOO - --allowed_classes="class1,class2" - --basket-fee=100regen - --description="any description" - `, - Args: cobra.ExactArgs(1), + +- disable-auto-retire: disables the auto-retirement of credits upon taking credits + 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-abbrev: 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. +- start-date-window: the duration of time (in seconds) measured into the past which sets a + cutoff for batch start dates when adding new credits to the basket. +- basket-fee: 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 they + paid a big fee and didn't know beforehand. +- description: the description to be used in the basket coin's bank denom metadata.`), + Example: `regen tx ecocredit create-basket NCT --credit-type-abbrev C --allowed_classes C01,C02 basket-fee 100000000uregen description "NCT basket"`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -74,7 +69,7 @@ Flags: return err } - creditTypeName, err := cmd.Flags().GetString(FlagCreditTypeAbbreviation) + creditTypeName, err := cmd.Flags().GetString(FlagCreditTypeAbbrev) if err != nil { return err } @@ -158,7 +153,7 @@ Flags: // command flags cmd.Flags().Bool(FlagDisableAutoRetire, false, "dictates whether credits will be auto-retired upon taking") - cmd.Flags().String(FlagCreditTypeAbbreviation, "", "filters against credits from this credit type abbreviation (e.g. \"C\")") + cmd.Flags().String(FlagCreditTypeAbbrev, "", "filters against credits from this credit type abbreviation (e.g. \"C\")") cmd.Flags().StringSlice(FlagAllowedClasses, []string{}, "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().Uint64(FlagStartDateWindow, 0, "sets a cutoff for batch start dates when adding new credits to the basket (e.g. 1325404800)") @@ -166,7 +161,7 @@ Flags: cmd.Flags().String(FlagDenomDescription, "", "the description to be used in the bank denom metadata.") // required flags - cmd.MarkFlagRequired(FlagCreditTypeAbbreviation) + cmd.MarkFlagRequired(FlagCreditTypeAbbrev) cmd.MarkFlagRequired(FlagAllowedClasses) return txFlags(cmd) @@ -174,19 +169,17 @@ Flags: func TxPutInBasketCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "put-in-basket [basket_denom] [credits]", - Short: "add credits to the basket", - Long: strings.TrimSpace(`add credits to the basket. + Use: "put-in-basket [basket-denom] [credits-json]", + Short: "Add credits to a basket", + Long: strings.TrimSpace(`Add credits to a basket. + Parameters: - basket_denom: basket identifier - credits: path to JSON file containing credits to put in the basket -Flags: - from: account address of the owner - `), - Example: ` -regen tx ecocredit put-in-basket eco.uC.NCT credits.json -Where the credits.json file contains: +- basket-denom: basket identifier +- credits-json: path to JSON file containing credits to put in the basket`), + Example: `regen tx ecocredit put-in-basket eco.uC.NCT credits.json + +Example JSON: [ { @@ -197,8 +190,7 @@ Where the credits.json file contains: "batch_denom": "C01-001-20210101-20220101-001", "amount": "10.5" } -] - `, +]`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -230,25 +222,25 @@ Where the credits.json file contains: func TxTakeFromBasketCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "take-from-basket [basket_denom] [amount]", + Use: "take-from-basket [basket-denom] [amount]", Short: "Takes credits from a basket", - Long: strings.TrimSpace(`takes credits from a basket starting from the oldest credits first. + Long: strings.TrimSpace(`Takes credits from a basket starting from the oldest credits first. + Parameters: - basket_denom: denom identifying basket from which we redeem credits. - amount: amount is a positive integer number of basket tokens to convert into credits. + +- basket-denom: denom identifying basket from which we redeem credits. +- amount: number of basket tokens to convert into credits. + Flags: - from: account address of the owner of the basket. - retirement-jurisdiction: retirement jurisdiction is the optional retirement jurisdiction for the credits - which will be used only if --retire-on-take flag is true. - retire-on-take: retire on take is a boolean that dictates whether the ecocredits - received in exchange for the basket tokens will be received as - retired or tradable credits. + +- retirement-jurisdiction: optional retirement jurisdiction + for the credits which will be used only if --retire-on-take flag is true. +- retire-on-take: boolean that dictates whether the ecocredits received + in exchange for the basket tokens will be received as retired or tradable credits. `), - Example: ` -regen tx ecocredit take-from-basket eco.uC.NCT 1000 -regen tx ecocredit take-from-basket eco.uC.NCT 1000 --retire-on-take true --retirement-jurisdiction AQ - `, + Example: `regen tx ecocredit take-from-basket eco.uC.NCT 1000 +regen tx ecocredit take-from-basket eco.uC.NCT 1000 --retire-on-take=true --retirement-jurisdiction "US-WA 98225"`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/x/ecocredit/client/marketplace/query.go b/x/ecocredit/client/marketplace/query.go index fe31829795..3567992f08 100644 --- a/x/ecocredit/client/marketplace/query.go +++ b/x/ecocredit/client/marketplace/query.go @@ -14,14 +14,11 @@ import ( // QuerySellOrderCmd returns a query command that retrieves information for a given sell order. func QuerySellOrderCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "sell-order [sell_order_id]", - Short: "Retrieve information for a given sell order", - Long: `Retrieve information for a given sell order`, - Example: ` -regen q ecocredit sell-order 1 -regen q ecocredit sell-order 1 --output json - `, - Args: cobra.ExactArgs(1), + Use: "sell-order [sell-order-id]", + Short: "Retrieve information for a given sell order", + Long: "Retrieve information for a given sell order.", + Example: "regen q ecocredit sell-order 1", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := sdkclient.GetClientQueryContext(cmd) if err != nil { @@ -52,12 +49,10 @@ regen q ecocredit sell-order 1 --output json func QuerySellOrdersCmd() *cobra.Command { cmd := &cobra.Command{ Use: "sell-orders", - Short: "List all sell orders with pagination", - Long: `Retrieve sell orders with pagination`, - Example: ` -regen q sell-orders -regen q sell-orders --limit 10 --offset 2 - `, + Short: "List all sell orders", + Long: `List all sell orders with optional pagination flags.`, + Example: `regen q sell-orders +regen q sell-orders --limit 10 --offset 10`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := sdkclient.GetClientQueryContext(cmd) @@ -90,12 +85,10 @@ regen q sell-orders --limit 10 --offset 2 func QuerySellOrdersBySellerCmd() *cobra.Command { cmd := &cobra.Command{ Use: "sell-orders-by-seller [seller]", - Short: "List all sell orders by seller address with pagination", - Long: `Retrieve sell orders by seller address with pagination`, - Example: ` -regen q ecocredit sell-orders-by-seller regen1fv85...zkfu -regen q ecocredit sell-orders-by-seller regen1fv85...zkfu --limit 10 --offset 2 - `, + Short: "List all sell orders by seller", + Long: `List all sell orders by seller with optional pagination flags.`, + Example: `regen q ecocredit sell-orders-by-seller regen18xvpj53vaupyfejpws5sktv5lnas5xj2phm3cf +regen q ecocredit sell-orders-by-seller regen18xvpj53vaupyfejpws5sktv5lnas5xj2phm3cf --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := sdkclient.GetClientQueryContext(cmd) @@ -129,12 +122,10 @@ regen q ecocredit sell-orders-by-seller regen1fv85...zkfu --limit 10 --offset 2 func QuerySellOrdersByBatchCmd() *cobra.Command { cmd := &cobra.Command{ Use: "sell-orders-by-batch [batch_denom]", - Short: "List all sell orders by batch denom with pagination", - Long: "Retrieve sell orders by batch by denom with pagination", - Example: ` -regen q ecocredit sell-orders-by-batch C01-001-20210101-20210201-001 -regen q ecocredit sell-orders-by-batch C01-001-20210101-20210201-001 --limit 10 --offset 2 - `, + Short: "List all sell orders by batch denom", + Long: "List all sell orders by batch by denom with optional pagination flags.", + Example: `regen q ecocredit sell-orders-by-batch C01-001-20200101-20210101-001 +regen q ecocredit sell-orders-by-batch C01-001-20200101-20210101-001 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := sdkclient.GetClientQueryContext(cmd) @@ -167,12 +158,10 @@ regen q ecocredit sell-orders-by-batch C01-001-20210101-20210201-001 --limit 10 func QueryAllowedDenomsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "allowed-denoms", - Short: "List all allowed denoms with pagination", - Long: "Retrieve allowed denoms with pagination", - Example: ` -regen q ecocredit allowed-denoms -regen q ecocredit allowed-denoms --limit 10 --offset 2 - `, + Short: "List all allowed denoms", + Long: "List all allowed denoms with optional pagination flags.", + Example: `regen q ecocredit allowed-denoms +regen q ecocredit allowed-denoms --limit 10 --offset 10`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := sdkclient.GetClientQueryContext(cmd) diff --git a/x/ecocredit/client/marketplace/tx.go b/x/ecocredit/client/marketplace/tx.go index b784aa0149..48862e8fec 100644 --- a/x/ecocredit/client/marketplace/tx.go +++ b/x/ecocredit/client/marketplace/tx.go @@ -21,30 +21,37 @@ const ( // TxSellCmd returns a transaction command that creates sell orders. func TxSellCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "sell [orders]", + Use: "sell [orders-json]", Short: "Creates new sell orders with transaction author (--from) as seller", Long: `Creates new sell orders with transaction author (--from) as seller. Parameters: - orders: path to JSON file containing orders to create + +- orders-json: path to JSON file containing orders to create Example JSON: + [ { - "batch_denom": "C01-20210101-20210201-001", + "batch_denom": "C01-001-20200101-20210101-001", "quantity": "5", - "ask_price": "100regen", + "ask_price": { + "denom": "uregen", + "amount" "100000000" + }, "disable_auto_retire": "true" }, { - "batch_denom": "C01-20210101-20210201-002", + "batch_denom": "C01-001-20200101-20210101-002", "quantity": "10", - "ask_price": "80regen", + "ask_price": { + "denom": "uregen", + "amount" "100000000" + }, "disable_auto_retire": false, - "expiration": "2024-01-01" + "expiration": "2024-01-01T00:00:00Z" } -] - `, +]`, Args: cobra.ExactArgs(1), Example: "regen tx ecocredit sell orders.json", RunE: func(cmd *cobra.Command, args []string) error { @@ -75,30 +82,37 @@ Example JSON: // TxUpdateSellOrdersCmd returns a transaction command that creates sell orders. func TxUpdateSellOrdersCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "update-sell-orders [updates]", + Use: "update-sell-orders [updates-json]", Short: "Updates existing sell orders with transaction author (--from) as seller", Long: `Updates existing sell orders with transaction author (--from) as seller. Parameters: - updates: path to JSON file containing orders to update + +- updates-json: path to JSON file containing orders to update Example JSON: + [ { "sell_order_id": 1, - "quantity": "5", - "ask_price": "100regen", - "disable_auto_retire": "true" + "new_quantity": "5", + "new_ask_price": { + "denom": "uregen", + "amount" "100000000" + }, + "disable_auto_retire": true }, { "sell_order_id": 2, - "quantity": "10", - "ask_price": "80regen", + "new_quantity": "10", + "new_ask_price": { + "denom": "uregen", + "amount" "100000000" + }, "disable_auto_retire": false, - "expiration": "2024-01-01" + "new_expiration": "2024-01-01T00:00:00Z" } -] - `, +]`, Args: cobra.ExactArgs(1), Example: "regen tx ecocredit update-sell-orders updates.json", RunE: func(cmd *cobra.Command, args []string) error { @@ -129,12 +143,16 @@ Example JSON: // TxBuyDirectCmd returns a transaction command for a single direct buy order. func TxBuyDirectCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "buy-direct [sell_order_id] [quantity] [bid_price] [disable_auto_retire] [flags]", + Use: "buy-direct [sell-order-id] [quantity] [bid-price] [disable-auto-retire] [flags]", Short: "Buy ecocredits from a specific sell order", - Long: "Purchase ecocredits from a specific sell order. DisableAutoRetire can be set to false to retire the credits immediately upon purchase." + - "When set to true, credits will be received in a tradable state, IF AND ONLY IF the sell order also has auto retire disabled. " + - "NOTE: The bid price is the price paid PER credit. The total cost will be quantity * bid_price.", - Example: "regen tx ecocredit buy-direct 194 300 40regen true --retirement-jurisdiction=US-NY", + Long: `Purchase ecocredits from a specific sell order. + +DisableAutoRetire can be set to false to retire the credits immediately +upon purchase. When set to true, credits will be received in a tradable +state, IF AND ONLY IF the sell order also has auto retire disabled. + +NOTE: The bid price is the price paid PER credit. The total cost will be quantity * bid_price.`, + Example: `regen tx ecocredit buy-direct 1 300 10000000uregen true --retirement-jurisdiction "US-WA 98225"`, Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -185,17 +203,19 @@ func TxBuyDirectCmd() *cobra.Command { return txFlags(cmd) } -// TxBuyDirectBatchCmd returns a transaction command for a batch direct buy order using a json file. -func TxBuyDirectBatchCmd() *cobra.Command { +// TxBuyDirectBulkCmd returns a transaction command for a batch direct buy order using a json file. +func TxBuyDirectBulkCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "buy-direct-batch [orders]", + Use: "buy-direct-bulk [orders-json]", Short: "Buy ecocredits from multiple sell orders", - Long: "Batch purchase ecocredits using a json file. DisableAutoRetire can be set to false to " + - "retire the credits immediately upon purchase. When set to true, credits will be received in a tradable state, " + - "IF AND ONLY IF the sell order also has auto retire disabled. NOTE: The bid price is the price paid PER credit. " + - "The total cost will be quantity * bid_price.", - Example: ` -regen tx ecocredit buy-direct-batch orders.json + Long: `Purchase ecocredits from multiple sell orders. + +DisableAutoRetire can be set to false to retire the credits immediately +upon purchase. When set to true, credits will be received in a tradable +state, IF AND ONLY IF the sell order also has auto retire disabled. + +NOTE: The bid price is the price paid PER credit. The total cost will be quantity * bid_price.`, + Example: `regen tx ecocredit buy-direct-bulk orders.json Example JSON: [ @@ -219,8 +239,7 @@ Example JSON: "disable_auto_retire": false, "retirement_jurisdiction": "US-NY" } -] - `, +]`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -248,11 +267,11 @@ Example JSON: // TxCancelSellOrderCmd returns a transaction command that cancels sell order. func TxCancelSellOrderCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "cancel-sell-order [order-id]", - Short: "Cancel existing sell orders with transaction author (--from) as seller", - Long: "Cancel existing sell orders with transaction author (--from) as seller", - Example: `regen tx ecocredit cancel-sell-order 1`, - Args: cobra.ExactArgs(1), + Use: "cancel-sell-order [order-id]", + Short: "Cancel existing sell orders with transaction author (--from) as seller", + Long: "Cancel existing sell orders with transaction author (--from) as seller", + Example: "regen tx ecocredit cancel-sell-order 1", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/ecocredit/client/query.go b/x/ecocredit/client/query.go index 0d99bd3baa..373162c2ca 100644 --- a/x/ecocredit/client/query.go +++ b/x/ecocredit/client/query.go @@ -30,8 +30,8 @@ func QueryCmd(name string) *cobra.Command { QueryBatchesByClassCmd(), QueryBatchesByProjectCmd(), QueryBatchCmd(), - QueryBalanceCmd(), - QuerySupplyCmd(), + QueryBatchBalanceCmd(), + QueryBatchSupplyCmd(), QueryCreditTypesCmd(), QueryProjectsCmd(), QueryProjectsByClassCmd(), @@ -57,11 +57,10 @@ func QueryCmd(name string) *cobra.Command { func QueryClassesCmd() *cobra.Command { cmd := &cobra.Command{ Use: "classes", - Short: "List all credit classes with pagination flags", - Example: ` -regen q ecocredit classes -regen q ecocredit classes --limit 10 - `, + Short: "List all credit classes", + Long: "List all credit classes with optional pagination flags.", + Example: `regen q ecocredit classes +regen q ecocredit classes --limit 10 --offset 10`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -88,12 +87,11 @@ regen q ecocredit classes --limit 10 // given credit class. func QueryClassCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "class [class_id]", - Short: "Retrieve credit class info", - Example: ` -regen q ecocredit class C01 - `, - Args: cobra.ExactArgs(1), + Use: "class [class-id]", + Short: "Retrieve credit class information", + Long: "Retrieve credit class information.", + Example: "regen q ecocredit class C01", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -112,16 +110,10 @@ regen q ecocredit class C01 func QueryClassIssuersCmd() *cobra.Command { cmd := &cobra.Command{ Use: "class-issuers [class-id]", - Short: "Retrieve addresses of the issuers for a credit class", - Long: `Retrieve addresses of the issuers for a credit class. - -Args: - class-id: credit class id - `, - Example: ` -regen q ecocredit class-issuers C01 -regen q ecocredit class-issuers C01 --limit 10 - `, + Short: "Retrieve issuer addresses for a credit class", + Long: "Retrieve issuer addresses for a credit class with optional pagination flags.", + Example: `regen q ecocredit class-issuers C01 +regen q ecocredit class-issuers C01 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -154,12 +146,10 @@ regen q ecocredit class-issuers C01 --limit 10 func QueryProjectsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "projects", - Short: "Query all projects", - Long: "Query all projects with optional pagination flags.", - Example: ` -regen q ecocredit projects -regen q ecocredit projects --limit 10 --count-total - `, + Short: "List all projects", + Long: "List all projects with optional pagination flags.", + Example: `regen q ecocredit projects +regen q ecocredit projects --limit 10 --offset 10`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -188,13 +178,11 @@ regen q ecocredit projects --limit 10 --count-total // QueryProjectsByClassCmd returns a query command that retrieves projects by credit class. func QueryProjectsByClassCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "projects-by-class [class_id]", - Short: "Query projects by credit class", - Long: "Query projects by credit class with optional pagination flags.", - Example: ` -regen q ecocredit projects-by-class C01 -regen q ecocredit projects-by-class C01 --limit 10 --count-total - `, + Use: "projects-by-class [class-id]", + Short: "List projects by credit class", + Long: "List projects by credit class with optional pagination flags.", + Example: `regen q ecocredit projects-by-class C01 +regen q ecocredit projects-by-class C01 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -221,12 +209,11 @@ regen q ecocredit projects-by-class C01 --limit 10 --count-total // QueryProjectCmd returns a query command that retrieves project information. func QueryProjectCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "project [project_id]", - Short: "Retrieve project info", - Example: ` -regen q ecocredit project C01-001 - `, - Args: cobra.ExactArgs(1), + Use: "project [project-id]", + Short: "Retrieve project information", + Long: "Retrieve project information.", + Example: `regen q ecocredit project C01-001`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -248,12 +235,10 @@ regen q ecocredit project C01-001 func QueryBatchesCmd() *cobra.Command { cmd := &cobra.Command{ Use: "batches", - Short: "Query all credit batches with pagination flags", - Long: "Query all credit batches with pagination flags.", - Example: ` -regen q ecocredit batches -regen q ecocredit batches --limit 10 - `, + Short: "List all credit batches", + Long: "List all credit batches with optional pagination flags.", + Example: `regen q ecocredit batches +regen q ecocredit batches --limit 10 --offset 10`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -279,16 +264,14 @@ regen q ecocredit batches --limit 10 return qflags(cmd) } -// QueryBatchesByIssuerCmd returns a query command that retrieves credit batches based on issuer. +// QueryBatchesByIssuerCmd returns a query command that retrieves credit batches by issuer. func QueryBatchesByIssuerCmd() *cobra.Command { cmd := &cobra.Command{ Use: "batches-by-issuer [issuer]", - Short: "Query all credit batches based on issuer", - Long: "Query all credit batches based on issuer with pagination flags.", - Example: ` -regen q ecocredit batches-by-issuer regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38 -regen q ecocredit batches-by-issuer regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38 --limit 10 - `, + Short: "List all credit batches by issuer", + Long: "List all credit batches by issuer with optional pagination flags.", + Example: `regen q ecocredit batches-by-issuer regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38 +regen q ecocredit batches-by-issuer regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -319,13 +302,11 @@ regen q ecocredit batches-by-issuer regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38 // given credit class. func QueryBatchesByClassCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "batches-by-class [class_id]", - Short: "Query all credit batches based on credit class", - Long: "Query all credit batches based on credit class with pagination flags.", - Example: ` -regen q ecocredit batches-by-class C01 -regen q ecocredit batches-by-class C01 --limit 10 - `, + Use: "batches-by-class [class-id]", + Short: "List all credit batches by credit class", + Long: "List all credit batches by credit class with pagination flags.", + Example: `regen q ecocredit batches-by-class C01 +regen q ecocredit batches-by-class C01 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -356,13 +337,11 @@ regen q ecocredit batches-by-class C01 --limit 10 // given project. func QueryBatchesByProjectCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "batches-by-project [project_id]", - Short: "Query all credit batches based on project", - Long: "Query all credit batches based on project with pagination flags.", - Example: ` -regen q ecocredit batches-by-project C01 -regen q ecocredit batches-by-project C01 --limit 10 - `, + Use: "batches-by-project [project-id]", + Short: "List all credit batches by project", + Long: "List all credit batches by project with optional pagination flags.", + Example: `regen q ecocredit batches-by-project C01-001 +regen q ecocredit batches-by-project C01-001 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -393,14 +372,11 @@ regen q ecocredit batches-by-project C01 --limit 10 // given credit batch. func QueryBatchCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "batch [batch_denom]", - Short: "Retrieve the credit issuance batch info", - Long: "Retrieve the credit issuance batch info based on the batch denom.", - Example: ` -regen q ecocredit batch C01-001-20200101-20210101-001 -regen q ecocredit batch C01-001-20200101-20210101-001 --limit 10 - `, - Args: cobra.ExactArgs(1), + Use: "batch [batch-denom]", + Short: "Retrieve credit batch information", + Long: "Retrieve credit batch information.", + Example: "regen q ecocredit batch C01-001-20200101-20210101-001", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -415,17 +391,15 @@ regen q ecocredit batch C01-001-20200101-20210101-001 --limit 10 }) } -// QueryBalanceCmd returns a query command that retrieves the tradable and +// QueryBatchBalanceCmd returns a query command that retrieves the tradable and // retired balances for a given credit batch and account address. -func QueryBalanceCmd() *cobra.Command { +func QueryBatchBalanceCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "balance [batch_denom] [account]", - Short: "Retrieve the tradable and retired balances of the credit batch", - Long: "Retrieve the tradable and retired balances of the credit batch for a given account address", - Example: ` -regen q ecocredit balance C01-001-20200101-20210101-001 regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38 - `, - Args: cobra.ExactArgs(2), + Use: "batch-balance [batch-denom] [account]", + Short: "Retrieve the batch balance of an account", + Long: "Retrieve the batch balance of an account.", + Example: "regen q ecocredit batch-balance C01-001-20200101-20210101-001 regen1r9pl9gvr56kmclgkpjg3ynh4rm5am66f2a6y38", + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -439,17 +413,15 @@ regen q ecocredit balance C01-001-20200101-20210101-001 regen1r9pl9gvr56kmclgkpj }) } -// QuerySupplyCmd returns a query command that retrieves the tradable and +// QueryBatchSupplyCmd returns a query command that retrieves the tradable and // retired supply of credits for a given credit batch. -func QuerySupplyCmd() *cobra.Command { +func QueryBatchSupplyCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "supply [batch_denom]", - Short: "Retrieve the tradable and retired supply of the credit batch", - Long: "Retrieve the tradable and retired supply of the credit batch", - Example: ` -regen q ecocredit supply C01-001-20200101-20210101-001 - `, - Args: cobra.ExactArgs(1), + Use: "batch-supply [batch-denom]", + Short: "Retrieve the supply of a credit batch", + Long: "Retrieve the supply of a credit batch.", + Example: "regen q ecocredit batch-supply C01-001-20200101-20210101-001", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -467,14 +439,11 @@ regen q ecocredit supply C01-001-20200101-20210101-001 // approved credit types. func QueryCreditTypesCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "types", - Short: "Retrieve the list of credit types", - Long: "Retrieve the list of credit types that contains the type name, measurement unit and precision", - Example: ` -regen q ecocredit types -regen query ecocredit types - `, - Args: cobra.ExactArgs(0), + Use: "credit-types", + Short: "List all credit types", + Long: "List all credit types.", + Example: "regen q ecocredit types", + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -489,13 +458,10 @@ regen query ecocredit types // QueryParamsCmd returns ecocredit module parameters. func QueryParamsCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "params", - Short: "Query the current ecocredit module parameters", - Long: "Query the current ecocredit module parameters", - Example: ` -regen q ecocredit params -regen query ecocredit params - `, + Use: "params", + Short: "List the current ecocredit module parameters", + Long: "List the current ecocredit module parameters.", + Example: "regen q ecocredit params", RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { @@ -511,12 +477,10 @@ regen query ecocredit params func QueryProjectsByReferenceIdCmd() *cobra.Command { cmd := &cobra.Command{ Use: "projects-by-reference-id [reference-id]", - Short: "Retrieve list of projects by reference-id with pagination flags", - Long: "Retrieve list of projects by reference-id with pagination flags", - Example: ` -regen q ecocredit projects-by-reference-id R1 -regen q ecocredit projects-by-reference-id --limit 10 - `, + Short: "List all projects by reference ID", + Long: "List all projects by reference ID with optional pagination flags.", + Example: `regen q ecocredit projects-by-reference-id VCS-001 +regen q ecocredit projects-by-reference-id VCS-001 --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -546,11 +510,10 @@ regen q ecocredit projects-by-reference-id --limit 10 func QueryProjectsByAdminCmd() *cobra.Command { cmd := &cobra.Command{ Use: "projects-by-admin [admin]", - Short: "Retrieve list of projects by admin with pagination flags", - Example: ` -regen query ecocredit projects-by-admin regenx1v44... -regen q ecocredit projects-by-admin regenx1v44.. --limit 10 - `, + Short: "List projects by admin", + Long: "List projects by admin with optional pagination flags.", + Example: `regen q ecocredit projects-by-admin regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw +regen q ecocredit projects-by-admin regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw --limit 10 --offset 10`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) @@ -580,13 +543,11 @@ regen q ecocredit projects-by-admin regenx1v44.. --limit 10 // information by abbreviation. func QueryCreditTypeCmd() *cobra.Command { return qflags(&cobra.Command{ - Use: "credit-type [abbreviation]", - Short: "Retrieve credit type info", - Example: ` -regen q ecocredit credit-type BIO -regen query ecocredit credit-type BIO - `, - Args: cobra.ExactArgs(1), + Use: "credit-type [abbreviation]", + Short: "Retrieve credit type information", + Long: "Retrieve credit type information.", + Example: "regen q ecocredit credit-type C", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, ctx, err := mkQueryClient(cmd) if err != nil { diff --git a/x/ecocredit/client/testsuite/query.go b/x/ecocredit/client/testsuite/query.go index 97e30d302d..0983f4adc2 100644 --- a/x/ecocredit/client/testsuite/query.go +++ b/x/ecocredit/client/testsuite/query.go @@ -459,7 +459,7 @@ func (s *IntegrationTestSuite) TestQueryBalanceCmd() { for _, tc := range testCases { s.Run(tc.name, func() { - cmd := coreclient.QueryBalanceCmd() + cmd := coreclient.QueryBatchBalanceCmd() out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErr { s.Require().Error(err) @@ -509,7 +509,7 @@ func (s *IntegrationTestSuite) TestQuerySupplyCmd() { for _, tc := range testCases { s.Run(tc.name, func() { - cmd := coreclient.QuerySupplyCmd() + cmd := coreclient.QueryBatchSupplyCmd() out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErr { s.Require().Error(err) diff --git a/x/ecocredit/client/testsuite/suite.go b/x/ecocredit/client/testsuite/suite.go index 80ce572d60..96e8181776 100644 --- a/x/ecocredit/client/testsuite/suite.go +++ b/x/ecocredit/client/testsuite/suite.go @@ -396,7 +396,7 @@ func (s *IntegrationTestSuite) createBasket(clientCtx client.Context, msg *baske cmd := basketclient.TxCreateBasketCmd() args := []string{ msg.Name, - fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbreviation, msg.CreditTypeAbbrev), + fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbrev, msg.CreditTypeAbbrev), fmt.Sprintf("--%s=%s", basketclient.FlagAllowedClasses, strings.Join(msg.AllowedClasses, ",")), fmt.Sprintf("--%s=%s", basketclient.FlagBasketFee, msg.Fee), fmt.Sprintf("--%s=%s", flags.FlagFrom, msg.Curator), diff --git a/x/ecocredit/client/testsuite/tx_basket.go b/x/ecocredit/client/testsuite/tx_basket.go index 160e828bb0..6cc69623a9 100644 --- a/x/ecocredit/client/testsuite/tx_basket.go +++ b/x/ecocredit/client/testsuite/tx_basket.go @@ -47,7 +47,7 @@ func (s *IntegrationTestSuite) TestTxCreateBasketCmd() { args: []string{ "NCT1", fmt.Sprintf("--%s=%s", basketclient.FlagAllowedClasses, s.classId), - fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbreviation, s.creditTypeAbbrev), + fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbrev, s.creditTypeAbbrev), fmt.Sprintf("--%s=%s", basketclient.FlagBasketFee, s.basketFee), fmt.Sprintf("--%s=%s", flags.FlagFrom, curator), }, @@ -57,7 +57,7 @@ func (s *IntegrationTestSuite) TestTxCreateBasketCmd() { args: []string{ "NCT2", fmt.Sprintf("--%s=%s", basketclient.FlagAllowedClasses, s.classId), - fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbreviation, s.creditTypeAbbrev), + fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbrev, s.creditTypeAbbrev), fmt.Sprintf("--%s=%s", basketclient.FlagBasketFee, s.basketFee), fmt.Sprintf("--%s=%s", flags.FlagFrom, s.val.Moniker), }, @@ -67,7 +67,7 @@ func (s *IntegrationTestSuite) TestTxCreateBasketCmd() { args: []string{ "NCT3", fmt.Sprintf("--%s=%s", basketclient.FlagAllowedClasses, s.classId), - fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbreviation, s.creditTypeAbbrev), + fmt.Sprintf("--%s=%s", basketclient.FlagCreditTypeAbbrev, s.creditTypeAbbrev), fmt.Sprintf("--%s=%s", basketclient.FlagBasketFee, s.basketFee), fmt.Sprintf("--%s=%s", flags.FlagFrom, curator), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), diff --git a/x/ecocredit/client/testsuite/tx_marketplace.go b/x/ecocredit/client/testsuite/tx_marketplace.go index 41bfb7916b..f960137e9c 100644 --- a/x/ecocredit/client/testsuite/tx_marketplace.go +++ b/x/ecocredit/client/testsuite/tx_marketplace.go @@ -465,7 +465,7 @@ func (s *IntegrationTestSuite) TestTxBuyDirectBatchCmd() { } for _, tc := range testCases { s.Run(tc.name, func() { - cmd := marketplaceclient.TxBuyDirectBatchCmd() + cmd := marketplaceclient.TxBuyDirectBulkCmd() args := append(tc.args, s.commonTxFlags()...) out, err := cli.ExecTestCLICmd(s.val.ClientCtx, cmd, args) if tc.expErr { diff --git a/x/ecocredit/client/tx.go b/x/ecocredit/client/tx.go index 83055b3e9c..9507b2eaad 100644 --- a/x/ecocredit/client/tx.go +++ b/x/ecocredit/client/tx.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "strconv" "strings" "github.com/spf13/cobra" @@ -20,15 +21,9 @@ import ( ) const ( - FlagProjectId string = "project-id" - FlagIssuances string = "issuances" - FlagStartDate string = "start-date" - FlagEndDate string = "end-date" - FlagMetadata string = "metadata" FlagAddIssuers string = "add-issuers" FlagRemoveIssuers string = "remove-issuers" FlagReferenceId string = "reference-id" - FlagIssuer string = "issuer" FlagRetirementJurisdiction string = "retirement-jurisdiction" ) @@ -44,6 +39,7 @@ func TxCmd(name string) *cobra.Command { } cmd.AddCommand( TxCreateClassCmd(), + TxCreateProjectCmd(), TxGenBatchJSONCmd(), TxCreateBatchCmd(), TxSendCmd(), @@ -53,7 +49,6 @@ func TxCmd(name string) *cobra.Command { TxUpdateClassMetadataCmd(), TxUpdateClassIssuersCmd(), TxUpdateClassAdminCmd(), - TxCreateProjectCmd(), TxUpdateProjectAdminCmd(), TxUpdateProjectMetadataCmd(), basketcli.TxCreateBasketCmd(), @@ -62,7 +57,7 @@ func TxCmd(name string) *cobra.Command { marketplacecli.TxSellCmd(), marketplacecli.TxUpdateSellOrdersCmd(), marketplacecli.TxBuyDirectCmd(), - marketplacecli.TxBuyDirectBatchCmd(), + marketplacecli.TxBuyDirectBulkCmd(), marketplacecli.TxCancelSellOrderCmd(), ) return cmd @@ -71,29 +66,28 @@ func TxCmd(name string) *cobra.Command { // TxCreateClassCmd returns a transaction command that creates a credit class. func TxCreateClassCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-class [issuer[,issuer]*] [credit type abbreviation] [metadata] [fee]", + Use: "create-class [issuers] [credit-type-abbrev] [metadata] [fee] [flags]", Short: "Creates a new credit class with transaction author (--from) as admin", - Long: fmt.Sprintf( - `Creates a new credit class with transaction author (--from) as admin. + Long: fmt.Sprintf(`Creates a new credit class with transaction author (--from) as admin. The transaction author must have permission to create a new credit class by -being a member of the %s allowlist. This is a governance parameter, so can be -queried via the command line. +being on the list of %s. This is a governance parameter, which +can be queried via the command line. -They must also pay the fee associated with creating a new credit class, defined -by the %s parameter, so should make sure they have enough funds to cover that. +They must also pay a fee (separate from the transaction fee) to create a credit +class. The list of accepted fees is defined by the %s parameter. Parameters: - issuer: comma separated (no spaces) list of issuer account addresses. Example: "addr1,addr2" - credit type abbreviation: the abbreviation of a credit type (e.g. "C", "BIO") - metadata: arbitrary data attached to the credit class info - fee: fee to pay for the creation of the credit class (e.g. 10uatom, 10uregen)`, + +- issuers: comma separated (no spaces) list of issuer account addresses +- credit-type-abbrev: the abbreviation of a credit type +- metadata: arbitrary data attached to the credit class info +- fee: fee to pay for the creation of the credit class`, core.KeyAllowedClassCreators, core.KeyCreditClassFee, ), - Example: ` -regen tx ecocredit create-class regen1el...xmgqelsw,regen2tl...xsgqdlhy C "metadata" 10uregen - `, + Example: `regen tx ecocredit create-class regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw C regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf 20000000uregen +regen tx ecocredit create-class regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw,regen1depk54cuajgkzea6zpgkq36tnjwdzv4ak663u6 C regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf 20000000uregen`, Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -131,84 +125,102 @@ regen tx ecocredit create-class regen1el...xmgqelsw,regen2tl...xsgqdlhy C "metad return txFlags(cmd) } -// TxGenBatchJSONCmd returns a transaction command that generates JSON to -// represent a new credit batch. -func TxGenBatchJSONCmd() *cobra.Command { +// TxCreateProjectCmd returns a transaction command that creates a new project. +func TxCreateProjectCmd() *cobra.Command { cmd := &cobra.Command{ - Use: `gen-batch-json --project-id [project_id] --issuances [issuances] --start-date [start_date] --end-date [end_date] - --metadata [metadata] --issuer [issuer]`, - Short: "Generates JSON to represent a new credit batch for use with create-batch command", - Long: `Generates JSON to represent a new credit batch for use with create-batch command. + Use: "create-project [class-id] [jurisdiction] [metadata] [flags]", + Short: "Create a new project within a credit class", + Long: `Create a new project within a credit class. + +Parameters: + +- class-id: the ID of the credit class +- jurisdiction: the jurisdiction of the project +- metadata: any arbitrary metadata to attach to the project -Required Flags: - project_id: id of the project - issuances: the amount of issuances to generate - start-date: The beginning of the period during which this credit batch was - quantified and verified. Format: yyyy-mm-dd. - end-date: The end of the period during which this credit batch was - quantified and verified. Format: yyyy-mm-dd. - metadata: issuance metadata - issuer: account address of the batch issuer - `, - Args: cobra.ExactArgs(0), +Optional Flags: + +- reference-id: a reference ID for the project`, + Example: `regen tx ecocredit create-project C01 "US-WA 98225" regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf +regen tx ecocredit create-project C01 "US-WA 98225" regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf --reference-id VCS-001`, + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - projectId, err := cmd.Flags().GetString(FlagProjectId) + clientCtx, err := sdkclient.GetClientTxContext(cmd) if err != nil { return err } - templateIssuance := &core.BatchIssuance{ - Recipient: "recipient-address", - TradableAmount: "tradable-amount", - RetiredAmount: "retired-amount", - RetirementJurisdiction: "retirement-jurisdiction", - } - - numIssuances, err := cmd.Flags().GetUint32(FlagIssuances) + referenceId, err := cmd.Flags().GetString(FlagReferenceId) if err != nil { return err } - issuances := make([]*core.BatchIssuance, numIssuances) - for i := range issuances { - issuances[i] = templateIssuance + msg := core.MsgCreateProject{ + Admin: clientCtx.GetFromAddress().String(), + ClassId: args[0], + Jurisdiction: args[1], + Metadata: args[2], + ReferenceId: referenceId, } - startDateStr, err := cmd.Flags().GetString(FlagStartDate) - if err != nil { - return err - } - startDate, err := types.ParseDate("start_date", startDateStr) - if err != nil { - return err - } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + + }, + } + + cmd.Flags().String(FlagReferenceId, "", "a reference ID for the project") - endDateStr, err := cmd.Flags().GetString(FlagEndDate) + return txFlags(cmd) +} + +// TxGenBatchJSONCmd returns a transaction command that generates JSON to +// represent a new credit batch. +func TxGenBatchJSONCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: `gen-batch-json [issuer] [project-id] [issuance-count] [metadata] [start-date] [end-date]`, + Short: "Generates JSON to represent a new credit batch for use with create-batch command", + Long: `Generates JSON to represent a new credit batch for use with create-batch command. + +Parameters: + +- issuer: the account address of the credit batch issuer +- project-id: the ID of the project +- issuance-count: the number of issuance items to generate +- metadata: any arbitrary metadata to attach to the credit batch +- start-date: the beginning of the period during which this credit batch was + quantified and verified (format: yyyy-mm-dd) +- end-date: the end of the period during which this credit batch was + quantified and verified (format: yyyy-mm-dd)`, + Example: "regen tx ecocredit gen-batch-json regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw C01-001 2 regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf 2020-01-01 2021-01-01", + Args: cobra.ExactArgs(6), + RunE: func(cmd *cobra.Command, args []string) error { + issuanceCount, err := strconv.ParseUint(args[2], 10, 8) if err != nil { return err } - endDate, err := types.ParseDate("end_date", endDateStr) - if err != nil { - return err + + issuance := make([]*core.BatchIssuance, issuanceCount) + for i := range issuance { + issuance[i] = &core.BatchIssuance{} } - metadata, err := cmd.Flags().GetString(FlagMetadata) + startDate, err := types.ParseDate("start date", args[4]) if err != nil { return err } - issuer, err := cmd.Flags().GetString(FlagIssuer) + endDate, err := types.ParseDate("end date", args[5]) if err != nil { return err } msg := &core.MsgCreateBatch{ - ProjectId: projectId, - Issuance: issuances, - Metadata: metadata, + Issuer: args[0], + ProjectId: args[1], + Issuance: issuance, + Metadata: args[3], StartDate: &startDate, EndDate: &endDate, - Issuer: issuer, } // Marshal and output JSON of message @@ -219,25 +231,13 @@ Required Flags: } var formattedJson bytes.Buffer - json.Indent(&formattedJson, msgJson, "", " ") + json.Indent(&formattedJson, msgJson, "", " ") fmt.Println(formattedJson.String()) return nil }, } - cmd.Flags().String(FlagProjectId, "", "project id") - cmd.MarkFlagRequired(FlagProjectId) - cmd.Flags().Uint32(FlagIssuances, 0, "The number of template issuances to generate") - cmd.MarkFlagRequired(FlagIssuances) - cmd.Flags().String(FlagStartDate, "", "The beginning of the period during which this credit batch was quantified and verified. Format: yyyy-mm-dd.") - cmd.MarkFlagRequired(FlagStartDate) - cmd.Flags().String(FlagEndDate, "", "The end of the period during which this credit batch was quantified and verified. Format: yyyy-mm-dd.") - cmd.MarkFlagRequired(FlagEndDate) - cmd.Flags().String(FlagMetadata, "", "arbitrary string attached to the credit batch") - cmd.Flags().String(FlagIssuer, "", "account address of the batch issuer") - cmd.MarkFlagRequired(FlagIssuer) - return cmd } @@ -249,9 +249,12 @@ func TxCreateBatchCmd() *cobra.Command { Long: `Issues a new credit batch. Parameters: - batch-json: path to JSON file containing credit batch information + +- batch-json: path to JSON file containing credit batch information`, + Example: `regen tx ecocredit create-batch batch.json Example JSON: + { "project_id": "C01-001", "issuer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw", @@ -263,17 +266,17 @@ Example JSON: "retirement_jurisdiction": "US-WA" }, { - "recipient": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw", + "recipient": "regen1depk54cuajgkzea6zpgkq36tnjwdzv4ak663u6", "tradable_amount": "1000", "retired_amount": "500", - "retirement_jurisdiction": "US-WA" + "retirement_jurisdiction": "US-OR" } ], - "metadata": "metadata", - "start_date": "1990-01-01", - "end_date": "1995-10-31" -} - `, + "metadata": "regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf", + "start_date": "2020-01-01T00:00:00Z", + "end_date": "2021-01-01T00:00:00Z", + "open": false +}`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -301,17 +304,18 @@ Example JSON: // to another. func TxSendCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "send [amount] [batch_denom] [recipient]", + Use: "send [amount] [batch-denom] [recipient] [flags]", Short: "Sends credits from a single batch from the transaction author (--from) to the recipient", Long: `Sends credits from a single batch from the transaction author (--from) to the recipient. -By default, the credits will be sent as tradeable. Use the --retirement-jurisdiction flag to retire the credits to the recipient address. +By default, the credits will be sent as tradable. Use the --retirement-jurisdiction flag to retire the credits to the recipient address. Parameters: - amount: amount to send - batch_denom: batch denomination - recipient: recipient address`, - Example: "regen tx ecocredit send 20 regen18xvpj53vaupyfejpws5sktv5lnas5xj2phm3cf C01-001-20200403-20210405-001 --from myKey", + +- amount: the amount of credits to send +- batch-denom: the denomination of the credit batch +- recipient: the recipient account address`, + Example: "regen tx ecocredit send 20 C01-001-20200101-20210101-001 regen18xvpj53vaupyfejpws5sktv5lnas5xj2phm3cf --from myKey", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -350,30 +354,30 @@ Parameters: // to another func TxSendBulkCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "send-bulk [recipient] [credits]", + Use: "send-bulk [recipient] [credits-json]", Short: "Sends credits from multiple batches from the transaction author (--from) to the recipient", Long: `Sends credits from multiple batches from the transaction author (--from) to the recipient. Parameters: - recipient: recipient address - credits: path to JSON file containing credits to send + +- recipient: the recipient account address +- credits-json: path to JSON file containing credits to send`, + Example: `regen tx ecocredit send-bulk regen18xvpj53vaupyfejpws5sktv5lnas5xj2phm3cf credits.json Example JSON: + [ { - "batch_denom": "C01-001-20210101-20210201-001", + "batch_denom": "C01-001-20200101-20210101-001", "tradable_amount": "500" }, { - "batch_denom": "C01-001-20210101-20210201-002", + "batch_denom": "C01-001-20200101-20210101-002", "tradable_amount": "50", "retired_amount": "100", "retirement_jurisdiction": "YY-ZZ 12345" } -] - -Note: "retirement_jurisdiction" is only required when "retired_amount" is positive. - `, +]`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -403,31 +407,28 @@ Note: "retirement_jurisdiction" is only required when "retired_amount" is positi // TxRetireCmd returns a transaction command that retires credits. func TxRetireCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "retire [credits] [retirement_jurisdiction]", + Use: "retire [credits] [retirement-jurisdiction]", Short: "Retires a specified amount of credits from the account of the transaction author (--from)", Long: `Retires a specified amount of credits from the account of the transaction author (--from) Parameters: - credits: path to JSON file containing credits to retire - retirement_jurisdiction: A string representing the jurisdiction of the buyer or - beneficiary of retired credits. It has the form - [-[ ]], where - country-code and region-code are taken from ISO 3166, and - postal-code being up to 64 alphanumeric characters. - eg: 'AA-BB 12345' + +- credits: path to JSON file containing credits to retire +- retirement-jurisdiction: the jurisdiction in which the credit will be retired`, + Example: ` +regen tx ecocredit retire credits.json "US-WA 98225" Example JSON: [ { - "batch_denom": "C01-20210101-20210201-001", + "batch_denom": "C01-001-20200101-20210101-001", "amount": "5" }, { - "batch_denom": "C01-20210101-20210201-002", + "batch_denom": "C01-001-20200101-20210101-002", "amount": "10" } -] - `, +]`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -457,29 +458,28 @@ Example JSON: // TxCancelCmd returns a transaction command that cancels credits. func TxCancelCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "cancel [credits] [reason]", + Use: "cancel [credits-json] [reason]", Short: "Cancels a specified amount of credits from the account of the transaction author (--from)", Long: `Cancels a specified amount of credits from the account of the transaction author (--from) Parameters: - credits: path to JSON file containing credits to retire - reason: reason is any arbitrary string that specifies the reason for cancelling credits. + +- credits-json: path to JSON file containing credits to retire +- reason: any arbitrary string that specifies the reason for cancelling credits`, + Example: `regen tx ecocredit cancel credits.json "transferring credits to another registry" Example JSON: + [ { - "batch_denom": "C01-20210101-20210201-001", + "batch_denom": "C01-001-20200101-20210101-001", "amount": "5" }, { - "batch_denom": "C01-20210101-20210201-002", + "batch_denom": "C01-001-20200101-20210101-002", "amount": "10" } -] - `, - Example: ` -regen tx ecocredit cancel credits.json "transferring credits to another registry" - `, +]`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -508,17 +508,18 @@ regen tx ecocredit cancel credits.json "transferring credits to another registry func TxUpdateClassMetadataCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "update-class-metadata [class-id] [metadata]", + Use: "update-class-metadata [class-id] [new-metadata]", Short: "Updates the metadata for a specific credit class", - Long: `Updates the metadata for a specific credit class. the '--from' flag must equal the credit class admin. + Long: `Updates the metadata for a specific credit class. + +The '--from' flag must equal the credit class admin. Parameters: - class-id: the class id that corresponds with the credit class you want to update - metadata: credit class metadata`, - Args: cobra.ExactArgs(2), - Example: ` -regen tx ecocredit update-class-metadata C01 "some metadata" - `, + +- class-id: the class id that corresponds with the credit class you want to update +- new-metadata: any arbitrary metadata to attach to the credit class`, + Args: cobra.ExactArgs(2), + Example: `regen tx ecocredit update-class-metadata C01 regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf`, RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) if err != nil { @@ -540,18 +541,20 @@ regen tx ecocredit update-class-metadata C01 "some metadata" func TxUpdateClassAdminCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "update-class-admin [class-id] [admin]", + Use: "update-class-admin [class-id] [new-admin]", Short: "Updates the admin for a specific credit class", - Long: `Updates the admin for a specific credit class. the '--from' flag must equal the current credit class admin. - WARNING: Updating the admin replaces the current admin. Be sure the address entered is correct. + Long: `Updates the admin for a specific credit class. + +The '--from' flag must equal the current credit class admin. + +WARNING: Updating the admin replaces the current admin. Be sure the new admin account address is entered correctly. Parameters: - class-id: the class id that corresponds with the credit class you want to update - new-admin: the address to overwrite the current admin address`, - Example: ` -regen tx ecocredit update-class-admin C01 regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw - `, - Args: cobra.ExactArgs(2), + +- class-id: the ID of the credit class to update +- new-admin: the new admin account address that will overwrite the current admin account address`, + Example: "regen tx ecocredit update-class-admin C01 regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw", + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) if err != nil { @@ -575,17 +578,20 @@ func TxUpdateClassIssuersCmd() *cobra.Command { cmd := &cobra.Command{ Use: "update-class-issuers [class-id]", Short: "Update the list of issuers for a specific credit class", - Long: `Update the list of issuers for a specific credit class. the '--from' flag must equal the current credit class admin. + Long: `Update the list of issuers for a specific credit class. + +The '--from' flag must equal the current credit class admin. Parameters: - class-id: the class id that corresponds with the credit class you want to update -Flags: - add-issuers: the new list of issuers to add to the class issuers list - remove-issuers: the new list of issuers to remove from the class issuers list`, - Example: ` -regen tx ecocredit update-class-issuers C01 --add-issuers addr1,addr2,addr3 -regen tx ecocredit update-class-issuers C01 --add-issuers addr1,addr2 --remove-issuers addr3,addr4 - `, + +- class-id: the ID of the credit class to update + +Flags: + +- add-issuers: the new list of issuers to add to the class issuers list +- remove-issuers: the new list of issuers to remove from the class issuers list`, + Example: `regen tx ecocredit update-class-issuers C01 --add-issuers addr1,addr2,addr3 +regen tx ecocredit update-class-issuers C01 --add-issuers addr1,addr2 --remove-issuers addr3,addr4`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -629,61 +635,21 @@ regen tx ecocredit update-class-issuers C01 --add-issuers addr1,addr2 --remove-i return txFlags(cmd) } -// TxCreateProjectCmd returns a transaction command that creates a new project. -func TxCreateProjectCmd() *cobra.Command { +func TxUpdateProjectAdminCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-project [class-id] [project-jurisdiction] [metadata]", - Short: "Create a new project within a credit class", - Long: `Create a new project within a credit class. - - Parameters: - class-id: id of the class - project-jurisdiction: the jurisdiction of the project (see documentation for proper project-jurisdiction formats). - metadata: any arbitrary metadata attached to the project. - Flags: - reference-id: project reference id - `, - Example: ` -regen tx ecocredit create-project C01 "AA-BB 12345" metadata -regen tx ecocredit create-project C01 "AA-BB 12345" metadata --reference-id R01 - `, - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := sdkclient.GetClientTxContext(cmd) - if err != nil { - return err - } - - referenceId, err := cmd.Flags().GetString(FlagReferenceId) - if err != nil { - return err - } - - msg := core.MsgCreateProject{ - Admin: clientCtx.GetFromAddress().String(), - ClassId: args[0], - Jurisdiction: args[1], - Metadata: args[2], - ReferenceId: referenceId, - } + Use: "update-project-admin [project-id] [new-admin] [flags]", + Short: "Update the project admin address", + Long: `Update the project admin to the provided new_admin_address. - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) +The '--from' flag must equal the current credit class admin. - }, - } +WARNING: Updating the admin replaces the current admin. Be sure the new admin account address is entered correctly. - cmd.Flags().String(FlagReferenceId, "", "project reference id") - - return txFlags(cmd) -} +Parameters: -func TxUpdateProjectAdminCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-project-admin [project_id] [new_admin_address] [flags]", - Short: "Update the project admin address", - Long: "Update the project admin to the provided new_admin_address. Please double check the address as " + - "this will forfeit control of the project. Passing an invalid address could cause loss of control of the project.", - Example: "regen tx ecocredit update-project-admin VERRA1 regen1ynugxwpp4lfpy0epvfqwqkpuzkz62htnex3op", +- project-id: the ID of the project to update +- new-admin: the new admin account address that will overwrite the current admin account address`, + Example: "regen tx ecocredit update-project-admin C01-001 regen1ynugxwpp4lfpy0epvfqwqkpuzkz62htnex3op", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) @@ -706,10 +672,10 @@ func TxUpdateProjectAdminCmd() *cobra.Command { func TxUpdateProjectMetadataCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "update-project-metadata [project-id] [new_metadata]", + Use: "update-project-metadata [project-id] [new-metadata]", Short: "Update the project metadata", Long: "Update the project metadata, overwriting the project's current metadata.", - Example: `regen tx ecocredit update-project-metadata VERRA1 "some metadata"`, + Example: "regen tx ecocredit update-project-metadata C01-001 regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := sdkclient.GetClientTxContext(cmd) diff --git a/x/ecocredit/server/core/keeper_test.go b/x/ecocredit/server/core/keeper_test.go index 5dce4f01ea..4ad076ee1b 100644 --- a/x/ecocredit/server/core/keeper_test.go +++ b/x/ecocredit/server/core/keeper_test.go @@ -74,7 +74,7 @@ func setupBase(t gocuke.TestingT) *baseSuite { return s } -// setupClassProjectBatch setups a class "C01", a project "C01-001", a batch "C01-20200101-20210101-01", and a +// setupClassProjectBatch setups a class "C01", a project "C01-001", a batch "C01-001-20200101-20210101-01", and a // supply/balance of "10.5" for both retired and tradable. func (s baseSuite) setupClassProjectBatch(t gocuke.TestingT) (classId, projectId, batchDenom string) { var err error diff --git a/x/ecocredit/server/core/query_balances_test.go b/x/ecocredit/server/core/query_balances_test.go index d98962236f..9eec618aad 100644 --- a/x/ecocredit/server/core/query_balances_test.go +++ b/x/ecocredit/server/core/query_balances_test.go @@ -18,9 +18,9 @@ func TestQuery_Balances(t *testing.T) { t.Parallel() s := setupBase(t) - bKey1, err := s.stateStore.BatchTable().InsertReturningID(s.ctx, &api.Batch{Denom: "C01-20200101-20220101-001"}) + bKey1, err := s.stateStore.BatchTable().InsertReturningID(s.ctx, &api.Batch{Denom: "C01-001-20200101-20220101-001"}) assert.NilError(t, err) - bKey2, err := s.stateStore.BatchTable().InsertReturningID(s.ctx, &api.Batch{Denom: "C02-20200101-20220101-001"}) + bKey2, err := s.stateStore.BatchTable().InsertReturningID(s.ctx, &api.Batch{Denom: "C02-001-20200101-20220101-001"}) assert.NilError(t, err) balance1 := &api.BatchBalance{Address: s.addr, BatchKey: bKey1, TradableAmount: "15", RetiredAmount: "15", EscrowedAmount: "15"} diff --git a/x/ecocredit/server/core/query_batches_by_class_test.go b/x/ecocredit/server/core/query_batches_by_class_test.go index 28b587b797..0acf3b10ee 100644 --- a/x/ecocredit/server/core/query_batches_by_class_test.go +++ b/x/ecocredit/server/core/query_batches_by_class_test.go @@ -50,7 +50,7 @@ func TestQuery_BatchesByClass(t *testing.T) { // insert two batches that are "C01" credit batches assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, batch1)) - assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, &api.Batch{Denom: "C01-20200101-20210101-002"})) + assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, &api.Batch{Denom: "C01-001-20200101-20210101-002"})) // insert two batches that are not "C01" credit batches assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, &api.Batch{Denom: "C011-001-20200101-20210101-001"})) diff --git a/x/ecocredit/server/core/query_batches_by_issuer_test.go b/x/ecocredit/server/core/query_batches_by_issuer_test.go index 3c1890a0de..1ea3c5f8e2 100644 --- a/x/ecocredit/server/core/query_batches_by_issuer_test.go +++ b/x/ecocredit/server/core/query_batches_by_issuer_test.go @@ -48,7 +48,7 @@ func TestQueryBatchesByIssuer(t *testing.T) { assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, batch1)) assert.NilError(t, s.stateStore.BatchTable().Insert(s.ctx, &api.Batch{ Issuer: s.addr, - Denom: "C01-20200101-20210101-002", + Denom: "C01-001-20200101-20210101-002", })) // query batches by issuer s.addr diff --git a/x/ecocredit/server/marketplace/query_sell_orders_test.go b/x/ecocredit/server/marketplace/query_sell_orders_test.go index 0ad9678651..33a91467c9 100644 --- a/x/ecocredit/server/marketplace/query_sell_orders_test.go +++ b/x/ecocredit/server/marketplace/query_sell_orders_test.go @@ -18,7 +18,7 @@ import ( var ( classId = "C01" - batchDenom = "C01-20200101-20200201-001" + batchDenom = "C01-001-20200101-20200201-001" start, end = timestamppb.Now(), timestamppb.Now() validAskDenom = sdk.DefaultBondDenom ask = sdk.NewInt64Coin(validAskDenom, 10)