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

feat(x/ecocredit): buy/sell query server #645

Merged
merged 12 commits into from
Dec 1, 2021
Prev Previous commit
Next Next commit
revert basket proto
  • Loading branch information
ryanchristo committed Nov 17, 2021
commit a33e20009a3bebcd12c4e4912ef19dc167ca7b74
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/stretchr/testify v1.7.0
github.com/tendermint/tendermint v0.34.13
github.com/tendermint/tm-db v0.6.4
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 // indirect
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211117155847-120650a500bb // indirect
)
Expand Down Expand Up @@ -122,7 +122,7 @@ require (
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
google.golang.org/grpc v1.40.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,8 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 h1:5QRxNnVsaJP6NAse0UdkRgL3zHMvCRRkrDVLNdNpdy4=
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI=
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1228,8 +1228,9 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg=
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
175 changes: 0 additions & 175 deletions x/ecocredit/spec/protobuf.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
- [Query](#regen.ecocredit.v1alpha1.Query)

- [regen/ecocredit/v1alpha1/tx.proto](#regen/ecocredit/v1alpha1/tx.proto)
- [BasketCredit](#regen.ecocredit.v1alpha1.BasketCredit)
- [BasketCriteria](#regen.ecocredit.v1alpha1.BasketCriteria)
- [MsgAddToBasket](#regen.ecocredit.v1alpha1.MsgAddToBasket)
- [MsgAddToBasketResponse](#regen.ecocredit.v1alpha1.MsgAddToBasketResponse)
- [MsgAllowAskDenom](#regen.ecocredit.v1alpha1.MsgAllowAskDenom)
- [MsgAllowAskDenomResponse](#regen.ecocredit.v1alpha1.MsgAllowAskDenomResponse)
- [MsgBuy](#regen.ecocredit.v1alpha1.MsgBuy)
Expand All @@ -86,15 +82,11 @@
- [MsgCancel](#regen.ecocredit.v1alpha1.MsgCancel)
- [MsgCancel.CancelCredits](#regen.ecocredit.v1alpha1.MsgCancel.CancelCredits)
- [MsgCancelResponse](#regen.ecocredit.v1alpha1.MsgCancelResponse)
- [MsgCreateBasket](#regen.ecocredit.v1alpha1.MsgCreateBasket)
- [MsgCreateBasketResponse](#regen.ecocredit.v1alpha1.MsgCreateBasketResponse)
- [MsgCreateBatch](#regen.ecocredit.v1alpha1.MsgCreateBatch)
- [MsgCreateBatch.BatchIssuance](#regen.ecocredit.v1alpha1.MsgCreateBatch.BatchIssuance)
- [MsgCreateBatchResponse](#regen.ecocredit.v1alpha1.MsgCreateBatchResponse)
- [MsgCreateClass](#regen.ecocredit.v1alpha1.MsgCreateClass)
- [MsgCreateClassResponse](#regen.ecocredit.v1alpha1.MsgCreateClassResponse)
- [MsgPickFromBasket](#regen.ecocredit.v1alpha1.MsgPickFromBasket)
- [MsgPickFromBasketResponse](#regen.ecocredit.v1alpha1.MsgPickFromBasketResponse)
- [MsgRetire](#regen.ecocredit.v1alpha1.MsgRetire)
- [MsgRetire.RetireCredits](#regen.ecocredit.v1alpha1.MsgRetire.RetireCredits)
- [MsgRetireResponse](#regen.ecocredit.v1alpha1.MsgRetireResponse)
Expand All @@ -104,8 +96,6 @@
- [MsgSend](#regen.ecocredit.v1alpha1.MsgSend)
- [MsgSend.SendCredits](#regen.ecocredit.v1alpha1.MsgSend.SendCredits)
- [MsgSendResponse](#regen.ecocredit.v1alpha1.MsgSendResponse)
- [MsgTakeFromBasket](#regen.ecocredit.v1alpha1.MsgTakeFromBasket)
- [MsgTakeFromBasketResponse](#regen.ecocredit.v1alpha1.MsgTakeFromBasketResponse)
- [MsgUpdateClassAdmin](#regen.ecocredit.v1alpha1.MsgUpdateClassAdmin)
- [MsgUpdateClassAdminResponse](#regen.ecocredit.v1alpha1.MsgUpdateClassAdminResponse)
- [MsgUpdateClassIssuers](#regen.ecocredit.v1alpha1.MsgUpdateClassIssuers)
Expand Down Expand Up @@ -1194,70 +1184,6 @@ Msg is the regen.ecocredit.v1alpha1 Query service.



<a name="regen.ecocredit.v1alpha1.BasketCredit"></a>

### BasketCredit



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| batch_denom | [string](#string) | | batch_denom is the unique ID of the credit batch. |
| tradable_amount | [string](#string) | | tradable_amount is the number of credits in this transfer that can be traded by the recipient. Decimal values are acceptable within the precision returned by Query/Precision. |






<a name="regen.ecocredit.v1alpha1.BasketCriteria"></a>

### BasketCriteria



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| filter | [Filter](#regen.ecocredit.v1alpha1.Filter) | | |
| multiplier | [string](#string) | | multiplier is an integer number which is applied to credit units when converting to basket units. For example if the multiplier is 2000, then 1.1 credits will result in 2200 basket tokens. If there are any fractional amounts left over in this calculation when adding credits to a basket, those fractional amounts will not get added to the basket. |






<a name="regen.ecocredit.v1alpha1.MsgAddToBasket"></a>

### MsgAddToBasket



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| owner | [string](#string) | | owner is the owner of credits being added to the basket. |
| basket_denom | [string](#string) | | basket_denom is the basket denom to add credits to. |
| credits | [BasketCredit](#regen.ecocredit.v1alpha1.BasketCredit) | repeated | credits are credits to add to the basket. If they do not match the basket's admission criteria the operation will fail. |






<a name="regen.ecocredit.v1alpha1.MsgAddToBasketResponse"></a>

### MsgAddToBasketResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| amount_received | [string](#string) | | amount_received is the amount of basket tokens received. |






<a name="regen.ecocredit.v1alpha1.MsgAllowAskDenom"></a>

### MsgAllowAskDenom
Expand Down Expand Up @@ -1393,42 +1319,6 @@ MsgCancelResponse is the Msg/Cancel response type.



<a name="regen.ecocredit.v1alpha1.MsgCreateBasket"></a>

### MsgCreateBasket



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| curator | [string](#string) | | curator is the address of the basket curator who is able to change certain basket settings. |
| name | [string](#string) | | name will be used to create a bank denom for this basket token of the form ecocredit:{curator}:{name}. |
| display_name | [string](#string) | | display_name will be used to create a bank Metadata display name for this basket token of the form ecocredit:{curator}:{display_name}. |
| exponent | [uint32](#uint32) | | exponent is the exponent that will be used for denom metadata. An exponent of 6 will mean that 10^6 units of a basket token should be displayed as one unit in user interfaces. |
| basket_criteria | [BasketCriteria](#regen.ecocredit.v1alpha1.BasketCriteria) | repeated | basket_criteria is the criteria by which credits can be added to the basket. Basket criteria will be applied in order and the first criteria which applies to a credit will determine its multiplier in the basket. |
| disable_auto_retire | [bool](#bool) | | |
| allow_picking | [bool](#bool) | | |






<a name="regen.ecocredit.v1alpha1.MsgCreateBasketResponse"></a>

### MsgCreateBasketResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| basket_denom | [string](#string) | | |






<a name="regen.ecocredit.v1alpha1.MsgCreateBatch"></a>

### MsgCreateBatch
Expand Down Expand Up @@ -1517,34 +1407,6 @@ MsgCreateClassResponse is the Msg/CreateClass response type.



<a name="regen.ecocredit.v1alpha1.MsgPickFromBasket"></a>

### MsgPickFromBasket



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| owner | [string](#string) | | owner is the owner of the basket tokens. |
| basket_denom | [string](#string) | | basket_denom is the denom to pick from. |
| credits | [BasketCredit](#regen.ecocredit.v1alpha1.BasketCredit) | repeated | credits are the units of credits being picked from the basket |
| retirement_location | [string](#string) | | retirement_location is the optional retirement location for the credits which will be used only if retire_on_take is true for this basket. |






<a name="regen.ecocredit.v1alpha1.MsgPickFromBasketResponse"></a>

### MsgPickFromBasketResponse







<a name="regen.ecocredit.v1alpha1.MsgRetire"></a>

### MsgRetire
Expand Down Expand Up @@ -1684,39 +1546,6 @@ MsgSendResponse is the Msg/Send response type.



<a name="regen.ecocredit.v1alpha1.MsgTakeFromBasket"></a>

### MsgTakeFromBasket



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| owner | [string](#string) | | |
| basket_denom | [string](#string) | | |
| amount | [string](#string) | | |
| retirement_location | [string](#string) | | retirement_location is the optional retirement location for the credits which will be used only if retire_on_take is true for this basket. |






<a name="regen.ecocredit.v1alpha1.MsgTakeFromBasketResponse"></a>

### MsgTakeFromBasketResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| credits | [BasketCredit](#regen.ecocredit.v1alpha1.BasketCredit) | repeated | credits are the credits taken out of the basket. |






<a name="regen.ecocredit.v1alpha1.MsgUpdateClassAdmin"></a>

### MsgUpdateClassAdmin
Expand Down Expand Up @@ -1867,10 +1696,6 @@ Msg is the regen.ecocredit.v1alpha1 Msg service.
| UpdateSellOrders | [MsgUpdateSellOrders](#regen.ecocredit.v1alpha1.MsgUpdateSellOrders) | [MsgUpdateSellOrdersResponse](#regen.ecocredit.v1alpha1.MsgUpdateSellOrdersResponse) | UpdateSellOrders updates existing sell orders. |
| Buy | [MsgBuy](#regen.ecocredit.v1alpha1.MsgBuy) | [MsgBuyResponse](#regen.ecocredit.v1alpha1.MsgBuyResponse) | Buy creates credit buy orders. |
| AllowAskDenom | [MsgAllowAskDenom](#regen.ecocredit.v1alpha1.MsgAllowAskDenom) | [MsgAllowAskDenomResponse](#regen.ecocredit.v1alpha1.MsgAllowAskDenomResponse) | AllowAskDenom is a governance operation which authorizes a new ask denom to be used in sell orders |
| CreateBasket | [MsgCreateBasket](#regen.ecocredit.v1alpha1.MsgCreateBasket) | [MsgCreateBasketResponse](#regen.ecocredit.v1alpha1.MsgCreateBasketResponse) | CreateBasket creates a bank denom which wraps credits. |
| AddToBasket | [MsgAddToBasket](#regen.ecocredit.v1alpha1.MsgAddToBasket) | [MsgAddToBasketResponse](#regen.ecocredit.v1alpha1.MsgAddToBasketResponse) | AddToBasket adds credits to a basket in return for basket tokens. |
| TakeFromBasket | [MsgTakeFromBasket](#regen.ecocredit.v1alpha1.MsgTakeFromBasket) | [MsgTakeFromBasketResponse](#regen.ecocredit.v1alpha1.MsgTakeFromBasketResponse) | TakeFromBasket takes credits from a basket without regard for which credits they are. The credits will be auto-retired if retire_on_take is true. Credits will be chosen randomly using the previous block hash as a consensus source of randomness. More concretely, the implementation is as follows: - take the previous block hash and convert it into an uint64, - given the total number of different credits within the basket `n`, the first credits that will get picked correspond to: hash modulo n (in terms of order), - then if we need to take more credits, we get some from the next one and so on. |
| PickFromBasket | [MsgPickFromBasket](#regen.ecocredit.v1alpha1.MsgPickFromBasket) | [MsgPickFromBasketResponse](#regen.ecocredit.v1alpha1.MsgPickFromBasketResponse) | PickFromBasket picks specific credits from a basket. If allow_picking is set to false, then only an address which deposited credits in the basket can pick those credits. All other addresses will be blocked from picking those credits. The credits will be auto-retired if retire_on_take is true unless the credits were previously put into the basket by the address picking them from the basket, in which case they will remain tradable. This functionality allows the owner of a credit to have more control over the credits they are putting in baskets then ordinary users to deal with the scenario where basket tokens end up being worth significantly less than the credits on their own. |

<!-- end services -->

Expand Down
Loading