Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x/ecocredit): readable marketplace query responses #1054

Merged
merged 5 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,448 changes: 1,223 additions & 225 deletions api/regen/ecocredit/marketplace/v1/query.pulsar.go

Large diffs are not rendered by default.

46 changes: 42 additions & 4 deletions proto/regen/ecocredit/marketplace/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package regen.ecocredit.marketplace.v1;

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "regen/ecocredit/marketplace/v1/state.proto";
import "cosmos/base/query/v1beta1/pagination.proto";

Expand Down Expand Up @@ -49,18 +50,21 @@ service Query {

// QuerySellOrderRequest is the Query/SellOrder request type.
message QuerySellOrderRequest {

// sell_order_id is the id of the requested sell order.
uint64 sell_order_id = 1;
}

// QuerySellOrderResponse is the Query/SellOrder response type.
message QuerySellOrderResponse {

// sell_order contains all information related to a sell order.
SellOrder sell_order = 1;
SellOrderInfo sell_order = 1;
}

// QuerySellOrdersRequest is the Query/SellOrders request type.
message QuerySellOrdersRequest {

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
Expand All @@ -69,7 +73,7 @@ message QuerySellOrdersRequest {
message QuerySellOrdersResponse {

// sell_orders is a list of sell orders.
repeated SellOrder sell_orders = 1;
repeated SellOrderInfo sell_orders = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
Expand All @@ -89,7 +93,7 @@ message QuerySellOrdersByBatchDenomRequest {
message QuerySellOrdersByBatchDenomResponse {

// sell_orders is a list of sell orders.
repeated SellOrder sell_orders = 1;
repeated SellOrderInfo sell_orders = 1;

// pagination defines an optional pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
Expand All @@ -111,14 +115,15 @@ message QuerySellOrdersByAddressRequest {
message QuerySellOrdersByAddressResponse {

// sell_orders is a list of sell orders.
repeated SellOrder sell_orders = 1;
repeated SellOrderInfo sell_orders = 1;

// pagination defines an optional pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryAllowedDenomsRequest is the Query/AllowedDenoms request type.
message QueryAllowedDenomsRequest {

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
Expand All @@ -133,3 +138,36 @@ message QueryAllowedDenomsResponse {
// pagination defines an optional pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// SellOrderInfo is the human-readable sell order information.
message SellOrderInfo {

// id is the unique ID of sell order.
uint64 id = 1;

// seller is the account address of the owner of the credits being sold.
string seller = 2;

// batch_denom is denom of the credit batch being sold.
string batch_denom = 3;

// quantity is the decimal quantity of credits being sold.
string quantity = 4;

// ask_denom is the denom used in the ask price of the sell order.
string ask_denom = 5;

// ask_price is the integer price (encoded as a string) the seller is asking
// for each unit of the batch_denom. Each credit unit of the batch will be
// sold for at least the ask_price or more.
string ask_price = 6;

// disable_auto_retire disables auto-retirement of credits which allows a
// buyer to disable auto-retirement in their buy order enabling them to
// resell the credits to another buyer.
bool disable_auto_retire = 7;

// expiration is an optional timestamp when the sell order expires. When the
// expiration time is reached, the sell order is removed from state.
google.protobuf.Timestamp expiration = 9;
}
2 changes: 1 addition & 1 deletion x/ecocredit/client/testsuite/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (s *IntegrationTestSuite) TestQuerySellOrderCmd() {

var res marketplace.QuerySellOrderResponse
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res))
s.Require().True(sdk.AccAddress(res.SellOrder.Seller).Equals(val.Address))
s.Require().Equal(res.SellOrder.Seller, val.Address.String())
s.Require().Equal(res.SellOrder.Quantity, "10")
}
})
Expand Down
3 changes: 2 additions & 1 deletion x/ecocredit/client/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ func (s *IntegrationTestSuite) TestTxSell() {
Quantity: "5",
AskPrice: "100",
DisableAutoRetire: false,
Expiration: &gogotypes.Timestamp{},
},
},
{
Expand Down Expand Up @@ -1092,7 +1093,7 @@ func (s *IntegrationTestSuite) TestTxSell() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(queryOut.Bytes(), &queryRes))
s.Require().Equal(queryRes.SellOrder.Quantity, tc.expOrder.Quantity)
s.Require().Equal(tc.expOrder.DisableAutoRetire, queryRes.SellOrder.DisableAutoRetire)
s.Require().True(tc.expOrder.Expiration.Equal(queryRes.SellOrder.Expiration))
s.Require().Equal(tc.expOrder.Expiration, queryRes.SellOrder.Expiration)
break
}
if found {
Expand Down
Loading