From 26cb432c298245804dd56360437f7f96977cd39b Mon Sep 17 00:00:00 2001 From: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Date: Tue, 25 Jan 2022 09:13:48 -0800 Subject: [PATCH] feat(x/ecocredit): add buy/sell expiration (#671) * feat(x/ecocredit): add buy/sell expiration * feat(x/ecocredit): add buy/sell expiration * feat(x/ecocredit): add buy/sell expiration * prune orders unit tests v1 * update expiration test * fix expiration index * address review comments * address review comment * adding parseAndSetDate * organize tests * address review comments * cleanup Co-authored-by: Robert Zaremba --- app/app.go | 2 +- proto/regen/ecocredit/v1alpha2/events.proto | 14 + proto/regen/ecocredit/v1alpha2/tx.proto | 12 + proto/regen/ecocredit/v1alpha2/types.proto | 8 + x/ecocredit/abci.go | 19 + x/ecocredit/client/testsuite/query.go | 14 +- x/ecocredit/client/testsuite/tx.go | 125 ++++-- x/ecocredit/client/tx.go | 56 ++- x/ecocredit/client/util.go | 10 + x/ecocredit/client/util_test.go | 26 ++ x/ecocredit/events.pb.go | 298 ++++++++++--- x/ecocredit/expected_keepers.go | 5 + x/ecocredit/module/module.go | 12 +- x/ecocredit/msgs.go | 29 +- x/ecocredit/msgs_test.go | 66 +-- x/ecocredit/server/expiration.go | 59 +++ x/ecocredit/server/expiration_test.go | 133 ++++++ x/ecocredit/server/msg_server.go | 67 ++- x/ecocredit/server/server.go | 44 +- x/ecocredit/server/testsuite/suite.go | 13 +- x/ecocredit/server/testsuite/tx.go | 111 +++++ x/ecocredit/spec/protobuf.md | 8 + x/ecocredit/tx.pb.go | 451 ++++++++++++++------ x/ecocredit/types.pb.go | 307 +++++++++---- 24 files changed, 1472 insertions(+), 417 deletions(-) create mode 100644 x/ecocredit/abci.go create mode 100644 x/ecocredit/server/expiration.go create mode 100644 x/ecocredit/server/expiration_test.go diff --git a/app/app.go b/app/app.go index c7c2792749..7243b737aa 100644 --- a/app/app.go +++ b/app/app.go @@ -406,7 +406,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.mm.SetOrderBeginBlockers( upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, - evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, + evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, /* ecocredit.ModuleName, */ ) app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName) // NOTE: The genutils module must occur after staking so that pools are diff --git a/proto/regen/ecocredit/v1alpha2/events.proto b/proto/regen/ecocredit/v1alpha2/events.proto index 67b4df090a..b7adbecf24 100644 --- a/proto/regen/ecocredit/v1alpha2/events.proto +++ b/proto/regen/ecocredit/v1alpha2/events.proto @@ -2,7 +2,9 @@ syntax = "proto3"; package regen.ecocredit.v1alpha2; +import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "google/protobuf/timestamp.proto"; option go_package = "github.com/regen-network/regen-ledger/x/ecocredit"; @@ -147,6 +149,10 @@ message EventSell { // buyer to disable auto-retirement in their buy order enabling them to // resell the credits to another buyer. bool disable_auto_retire = 5; + + // 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 = 6 [ (gogoproto.stdtime) = true ]; } // EventUpdateSellOrder is an event emitted when a sell order is updated. @@ -170,6 +176,10 @@ message EventUpdateSellOrder { // disable_auto_retire updates the disable_auto_retire field in the sell order. bool disable_auto_retire = 6; + + // new_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 new_expiration = 7 [ (gogoproto.stdtime) = true ]; } // EventBuyOrderCreated is an event emitted when a buy order is created. @@ -206,6 +216,10 @@ message EventBuyOrderCreated { // retirement_location is the optional retirement location for the credits // which will be used only if disable_auto_retire is false. string retirement_location = 7; + + // expiration is the optional timestamp when the buy order expires. When the + // expiration time is reached, the buy order is removed from state. + google.protobuf.Timestamp expiration = 8 [ (gogoproto.stdtime) = true ]; } // EventBuyOrderFilled is an event emitted when a buy order is filled. diff --git a/proto/regen/ecocredit/v1alpha2/tx.proto b/proto/regen/ecocredit/v1alpha2/tx.proto index 36a6ef1214..9086f99687 100644 --- a/proto/regen/ecocredit/v1alpha2/tx.proto +++ b/proto/regen/ecocredit/v1alpha2/tx.proto @@ -381,6 +381,10 @@ message MsgSell { // buyer to disable auto-retirement in their buy order enabling them to // resell the credits to another buyer. bool disable_auto_retire = 4; + + // 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 = 5 [ (gogoproto.stdtime) = true ]; } } @@ -415,6 +419,10 @@ message MsgUpdateSellOrders { // disable_auto_retire updates the disable_auto_retire field in the sell order. bool disable_auto_retire = 4; + + // new_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 new_expiration = 5 [ (gogoproto.stdtime) = true ]; } } @@ -479,6 +487,10 @@ message MsgBuy { // retirement_location is the optional retirement location for the credits // which will be used only if disable_auto_retire is false. string retirement_location = 6; + + // expiration is the optional timestamp when the buy order expires. When the + // expiration time is reached, the buy order is removed from state. + google.protobuf.Timestamp expiration = 7 [ (gogoproto.stdtime) = true ]; } } diff --git a/proto/regen/ecocredit/v1alpha2/types.proto b/proto/regen/ecocredit/v1alpha2/types.proto index ce7f89c9e0..ffe7a8374c 100644 --- a/proto/regen/ecocredit/v1alpha2/types.proto +++ b/proto/regen/ecocredit/v1alpha2/types.proto @@ -156,6 +156,10 @@ message SellOrder { // buyer to disable auto-retirement in their buy order enabling them to // resell the credits to another buyer. bool disable_auto_retire = 6; + + // 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 = 7 [ (gogoproto.stdtime) = true ]; } // BuyOrder represents the information for a buy order. @@ -209,6 +213,10 @@ message BuyOrder { // disable_partial_fill disables the default behavior of partially filling // buy orders if the requested quantity is not available. bool disable_partial_fill = 7; + + // expiration is the optional timestamp when the buy order expires. When the + // expiration time is reached, the buy order is removed from state. + google.protobuf.Timestamp expiration = 8 [ (gogoproto.stdtime) = true ]; } // AskDenom represents the information for an ask denom. diff --git a/x/ecocredit/abci.go b/x/ecocredit/abci.go new file mode 100644 index 0000000000..c0a8e75061 --- /dev/null +++ b/x/ecocredit/abci.go @@ -0,0 +1,19 @@ +package ecocredit + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// BeginBlocker checks if there are any expired sell or buy orders and removes them from state. +func BeginBlocker(ctx sdk.Context, k Keeper) error { + defer telemetry.ModuleMeasureSince(ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + if err := k.PruneOrders(ctx); err != nil { + return err + } + + return nil +} diff --git a/x/ecocredit/client/testsuite/query.go b/x/ecocredit/client/testsuite/query.go index fa5e4044d7..94f3b1e2df 100644 --- a/x/ecocredit/client/testsuite/query.go +++ b/x/ecocredit/client/testsuite/query.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/client/flags" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/regen-network/regen-ledger/types/testutil/cli" "github.com/regen-network/regen-ledger/x/ecocredit" "github.com/regen-network/regen-ledger/x/ecocredit/client" @@ -482,7 +482,8 @@ func (s *IntegrationTestSuite) TestQueryParams() { require.NoError(err) var params ecocredit.QueryParamsResponse - json.Unmarshal(out.Bytes(), ¶ms) + err = json.Unmarshal(out.Bytes(), ¶ms) + require.NoError(err) require.Equal(ecocredit.DefaultParams(), *params.Params) } @@ -521,14 +522,7 @@ func (s *IntegrationTestSuite) TestQuerySellOrder() { args: []string{"1"}, expErr: false, expErrMsg: "", - expOrder: &ecocredit.SellOrder{ - OrderId: 1, - Owner: val.Address.String(), - BatchDenom: batchDenom, - Quantity: "1", - AskPrice: &sdk.Coin{Denom: "regen", Amount: sdk.NewInt(100)}, - DisableAutoRetire: false, - }, + expOrder: s.sellOrders[0], }, } diff --git a/x/ecocredit/client/testsuite/tx.go b/x/ecocredit/client/testsuite/tx.go index d10e0260af..b808d3011e 100644 --- a/x/ecocredit/client/testsuite/tx.go +++ b/x/ecocredit/client/testsuite/tx.go @@ -14,13 +14,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/regen-network/regen-ledger/types/testutil/cli" "github.com/regen-network/regen-ledger/types/testutil/network" "github.com/regen-network/regen-ledger/x/ecocredit" "github.com/regen-network/regen-ledger/x/ecocredit/client" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - tmcli "github.com/tendermint/tendermint/libs/cli" ) type IntegrationTestSuite struct { @@ -1418,12 +1419,16 @@ func (s *IntegrationTestSuite) TestTxSell() { val0 := s.network.Validators[0] clientCtx := val0.ClientCtx + expiration, err := client.ParseDate("expiration", "2024-01-01") + s.Require().NoError(err) + testCases := []struct { - name string - args []string - expErr bool - expErrMsg string - expOrder *ecocredit.SellOrder + name string + args []string + sellOrderId string + expErr bool + expErrMsg string + expOrder *ecocredit.SellOrder }{ { name: "missing args", @@ -1518,7 +1523,8 @@ func (s *IntegrationTestSuite) TestTxSell() { }, s.commonTxFlags()..., ), - expErr: false, + sellOrderId: "4", + expErr: false, expOrder: &ecocredit.SellOrder{ OrderId: 4, Owner: val0.Address.String(), @@ -1528,6 +1534,27 @@ func (s *IntegrationTestSuite) TestTxSell() { DisableAutoRetire: false, }, }, + { + name: "valid with expiration", + args: append( + []string{ + "[{batch_denom: \"C01-20210101-20210201-001\", quantity: \"5\", ask_price: \"100regen\", disable_auto_retire: false, expiration: \"2024-01-01\"}]", + makeFlagFrom(val0.Address.String()), + }, + s.commonTxFlags()..., + ), + sellOrderId: "5", + expErr: false, + expOrder: &ecocredit.SellOrder{ + OrderId: 5, + Owner: val0.Address.String(), + BatchDenom: batchDenom, + Quantity: "5", + AskPrice: &sdk.Coin{Denom: "regen", Amount: sdk.NewInt(100)}, + DisableAutoRetire: false, + Expiration: &expiration, + }, + }, } for _, tc := range testCases { @@ -1542,7 +1569,10 @@ func (s *IntegrationTestSuite) TestTxSell() { // query sell order query := client.QuerySellOrderCmd() - out, err := cli.ExecTestCLICmd(clientCtx, query, []string{"4", flagOutputJSON}) + out, err := cli.ExecTestCLICmd(clientCtx, query, []string{ + tc.sellOrderId, + flagOutputJSON, + }) s.Require().NoError(err, out.String()) // unmarshal query response @@ -1561,12 +1591,16 @@ func (s *IntegrationTestSuite) TestTxUpdateSellOrders() { val0 := s.network.Validators[0] clientCtx := val0.ClientCtx + expiration, err := client.ParseDate("expiration", "2026-01-01") + s.Require().NoError(err) + testCases := []struct { - name string - args []string - expErr bool - expErrMsg string - expOrder *ecocredit.SellOrder + name string + args []string + sellOrderId string + expErr bool + expErrMsg string + expOrder *ecocredit.SellOrder }{ { name: "missing args", @@ -1661,7 +1695,8 @@ func (s *IntegrationTestSuite) TestTxUpdateSellOrders() { }, s.commonTxFlags()..., ), - expErr: false, + sellOrderId: "4", + expErr: false, expOrder: &ecocredit.SellOrder{ OrderId: 4, Owner: val0.Address.String(), @@ -1671,6 +1706,27 @@ func (s *IntegrationTestSuite) TestTxUpdateSellOrders() { DisableAutoRetire: false, }, }, + { + name: "valid with expiration", + args: append( + []string{ + "[{sell_order_id: \"5\", new_quantity: \"5\", new_ask_price: \"200regen\", disable_auto_retire: false, new_expiration: \"2026-01-01\"}]", + makeFlagFrom(val0.Address.String()), + }, + s.commonTxFlags()..., + ), + sellOrderId: "5", + expErr: false, + expOrder: &ecocredit.SellOrder{ + OrderId: 5, + Owner: val0.Address.String(), + BatchDenom: batchDenom, + Quantity: "5", + AskPrice: &sdk.Coin{Denom: "regen", Amount: sdk.NewInt(200)}, + DisableAutoRetire: false, + Expiration: &expiration, + }, + }, } for _, tc := range testCases { @@ -1685,7 +1741,10 @@ func (s *IntegrationTestSuite) TestTxUpdateSellOrders() { // query sell order query := client.QuerySellOrderCmd() - out, err := cli.ExecTestCLICmd(clientCtx, query, []string{"4", flagOutputJSON}) + out, err := cli.ExecTestCLICmd(clientCtx, query, []string{ + tc.sellOrderId, + flagOutputJSON, + }) s.Require().NoError(err, out.String()) // unmarshal query response @@ -1705,10 +1764,11 @@ func (s *IntegrationTestSuite) TestTxBuy() { clientCtx := val0.ClientCtx testCases := []struct { - name string - args []string - expErr bool - expErrMsg string + name string + args []string + sellOrderId string + expErr bool + expErrMsg string }{ { name: "missing args", @@ -1803,8 +1863,22 @@ func (s *IntegrationTestSuite) TestTxBuy() { }, s.commonTxFlags()..., ), - expErr: false, - expErrMsg: "", + sellOrderId: "4", + expErr: false, + expErrMsg: "", + }, + { + name: "valid with expiration", + args: append( + []string{ + "[{sell_order_id: \"5\", quantity: \"5\", bid_price: \"100regen\", disable_auto_retire: false, expiration: \"2024-01-01\"}]", + makeFlagFrom(val0.Address.String()), + }, + s.commonTxFlags()..., + ), + sellOrderId: "5", + expErr: false, + expErrMsg: "", }, } @@ -1820,7 +1894,10 @@ func (s *IntegrationTestSuite) TestTxBuy() { // query sell order (should no longer exist) query := client.QuerySellOrderCmd() - _, err := cli.ExecTestCLICmd(clientCtx, query, []string{"4", flagOutputJSON}) + _, err := cli.ExecTestCLICmd(clientCtx, query, []string{ + tc.sellOrderId, + flagOutputJSON, + }) s.Require().Error(err) s.Require().Contains(err.Error(), "not found") } diff --git a/x/ecocredit/client/tx.go b/x/ecocredit/client/tx.go index 02a68fb031..282061b1e5 100644 --- a/x/ecocredit/client/tx.go +++ b/x/ecocredit/client/tx.go @@ -514,7 +514,8 @@ func TxSellCmd() *cobra.Command { Parameters: orders: YAML encoded order list. Note: numerical values must be written in strings. - eg: '[{batch_denom: "C01-20210101-20210201-001", quantity: "5", ask_price: "100regen", disable_auto_retire: false}]'`, + eg: '[{batch_denom: "C01-20210101-20210201-001", quantity: "5", ask_price: "100regen", disable_auto_retire: false}]' + eg: '[{batch_denom: "C01-20210101-20210201-001", quantity: "5", ask_price: "100regen", disable_auto_retire: false, expiration: "2024-01-01"}]'`, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -523,7 +524,6 @@ Parameters: return err } - // get the order owner from the --from flag owner := clientCtx.GetFromAddress() // declare orders array with ask price as string @@ -532,6 +532,7 @@ Parameters: Quantity string `json:"quantity"` AskPrice string `json:"ask_price"` DisableAutoRetire bool `json:"disable_auto_retire"` + Expiration string `json:"expiration"` } // unmarshal YAML encoded orders with ask price as string @@ -539,24 +540,28 @@ Parameters: return err } - // declare orders array with ask price as sdk.Coin orders := make([]*ecocredit.MsgSell_Order, len(strOrders)) // loop through orders with ask price as string - for i, order := range strOrders { + for i, o := range strOrders { - // parse and normalize ask price as sdk.Coin - askPrice, err := sdk.ParseCoinNormalized(order.AskPrice) + askPrice, err := sdk.ParseCoinNormalized(o.AskPrice) if err != nil { return err } // set order with ask price as sdk.Coin orders[i] = &ecocredit.MsgSell_Order{ - BatchDenom: order.BatchDenom, + BatchDenom: o.BatchDenom, AskPrice: &askPrice, - Quantity: order.Quantity, - DisableAutoRetire: order.DisableAutoRetire, + Quantity: o.Quantity, + DisableAutoRetire: o.DisableAutoRetire, + } + + if o.Expiration != "" { + if err := parseAndSetDate(&orders[i].Expiration, "expiration", o.Expiration); err != nil { + return err + } } } @@ -582,7 +587,8 @@ func TxUpdateSellOrdersCmd() *cobra.Command { Parameters: updates: YAML encoded update list. Note: numerical values must be written in strings. - eg: '[{sell_order_id: "1", new_quantity: "5", new_ask_price: "200regen", disable_auto_retire: false}]'`, + eg: '[{sell_order_id: "1", new_quantity: "5", new_ask_price: "200regen", disable_auto_retire: false}]' + eg: '[{sell_order_id: "1", new_quantity: "5", new_ask_price: "200regen", disable_auto_retire: false, new_expiration: "2026-01-01"}]'`, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -600,6 +606,7 @@ Parameters: NewQuantity string `json:"new_quantity"` NewAskPrice string `json:"new_ask_price"` DisableAutoRetire bool `json:"disable_auto_retire"` + NewExpiration string `json:"new_expiration"` } // unmarshal YAML encoded updates with new ask price as string @@ -611,16 +618,16 @@ Parameters: updates := make([]*ecocredit.MsgUpdateSellOrders_Update, len(strUpdates)) // loop through updates with new ask price as string - for i, update := range strUpdates { + for i, u := range strUpdates { // parse sell order id - sellOrderId, err := strconv.ParseUint(update.SellOrderId, 10, 64) + sellOrderId, err := strconv.ParseUint(u.SellOrderId, 10, 64) if err != nil { return ecocredit.ErrInvalidSellOrder.Wrap(err.Error()) } // parse and normalize new ask price as sdk.Coin - askPrice, err := sdk.ParseCoinNormalized(update.NewAskPrice) + askPrice, err := sdk.ParseCoinNormalized(u.NewAskPrice) if err != nil { return err } @@ -629,8 +636,14 @@ Parameters: updates[i] = &ecocredit.MsgUpdateSellOrders_Update{ SellOrderId: sellOrderId, NewAskPrice: &askPrice, - NewQuantity: update.NewQuantity, - DisableAutoRetire: update.DisableAutoRetire, + NewQuantity: u.NewQuantity, + DisableAutoRetire: u.DisableAutoRetire, + } + + if u.NewExpiration != "" { + if err := parseAndSetDate(&updates[i].NewExpiration, "expiration", u.NewExpiration); err != nil { + return err + } } } @@ -656,7 +669,8 @@ func TxBuyCmd() *cobra.Command { Parameters: orders: YAML encoded order list. Note: numerical values must be written in strings. - eg: '[{sell_order_id: "1", quantity: "5", bid_price: "100regen", disable_auto_retire: false}]'`, + eg: '[{sell_order_id: "1", quantity: "5", bid_price: "100regen", disable_auto_retire: false}]' + eg: '[{sell_order_id: "1", quantity: "5", bid_price: "100regen", disable_auto_retire: false, expiration: "2024-01-01"}]'`, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -674,6 +688,7 @@ Parameters: Quantity string `json:"quantity"` BidPrice string `json:"bid_price"` DisableAutoRetire bool `json:"disable_auto_retire"` + Expiration string `json:"expiration"` } // unmarshal YAML encoded orders with new bid price as string @@ -711,6 +726,15 @@ Parameters: Quantity: order.Quantity, DisableAutoRetire: order.DisableAutoRetire, } + + // parse and set expiration + if order.Expiration != "" { + expiration, err := ParseDate("expiration", order.Expiration) + if err != nil { + return err + } + orders[i].Expiration = &expiration + } } // create buy message diff --git a/x/ecocredit/client/util.go b/x/ecocredit/client/util.go index 0962889c95..82a3e90b6a 100644 --- a/x/ecocredit/client/util.go +++ b/x/ecocredit/client/util.go @@ -118,6 +118,16 @@ func ParseDate(field string, date string) (time.Time, error) { return t, nil } +// parseAndSetDate is as helper function which sets the time do the provided argument if +// the ParseDate was successful. +func parseAndSetDate(dest **time.Time, field string, date string) error { + t, err := ParseDate(field, date) + if err == nil { + *dest = &t + } + return err +} + // checkDuplicateKey checks duplicate keys in a JSON func checkDuplicateKey(d *json.Decoder, path []string) error { // Get next token from JSON diff --git a/x/ecocredit/client/util_test.go b/x/ecocredit/client/util_test.go index 42fad6015b..a8cbed61bb 100644 --- a/x/ecocredit/client/util_test.go +++ b/x/ecocredit/client/util_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "time" ) func TestParseCredits(t *testing.T) { @@ -189,3 +190,28 @@ func TestJSONDupliteKeys(t *testing.T) { }) } } + +func TestParseAndSetDate(t *testing.T) { + tcs := []struct { + name string + date string + hasErr bool + }{ + {"good", "2022-01-20", false}, + {"bad", "01-2021-20", true}, + } + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + require := require.New(t) + var tm *time.Time + err := parseAndSetDate(&tm, tc.date, tc.date) + if tc.hasErr { + require.Error(err) + require.Nil(tm) + } else { + require.NoError(err) + require.NotNil(tm) + } + }) + } +} diff --git a/x/ecocredit/events.pb.go b/x/ecocredit/events.pb.go index 637b4b4a1b..3abad26f41 100644 --- a/x/ecocredit/events.pb.go +++ b/x/ecocredit/events.pb.go @@ -6,16 +6,21 @@ package ecocredit import ( fmt "fmt" types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -514,6 +519,9 @@ type EventSell struct { // buyer to disable auto-retirement in their buy order enabling them to // resell the credits to another buyer. DisableAutoRetire bool `protobuf:"varint,5,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` + // expiration is an optional timestamp when the sell order expires. When the + // expiration time is reached, the sell order is removed from state. + Expiration *time.Time `protobuf:"bytes,6,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` } func (m *EventSell) Reset() { *m = EventSell{} } @@ -584,6 +592,13 @@ func (m *EventSell) GetDisableAutoRetire() bool { return false } +func (m *EventSell) GetExpiration() *time.Time { + if m != nil { + return m.Expiration + } + return nil +} + // EventUpdateSellOrder is an event emitted when a sell order is updated. type EventUpdateSellOrder struct { // owner is the owner of the sell orders. @@ -599,6 +614,9 @@ type EventUpdateSellOrder struct { NewAskPrice *types.Coin `protobuf:"bytes,5,opt,name=new_ask_price,json=newAskPrice,proto3" json:"new_ask_price,omitempty"` // disable_auto_retire updates the disable_auto_retire field in the sell order. DisableAutoRetire bool `protobuf:"varint,6,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` + // new_expiration is an optional timestamp when the sell order expires. When the + // expiration time is reached, the sell order is removed from state. + NewExpiration *time.Time `protobuf:"bytes,7,opt,name=new_expiration,json=newExpiration,proto3,stdtime" json:"new_expiration,omitempty"` } func (m *EventUpdateSellOrder) Reset() { *m = EventUpdateSellOrder{} } @@ -676,6 +694,13 @@ func (m *EventUpdateSellOrder) GetDisableAutoRetire() bool { return false } +func (m *EventUpdateSellOrder) GetNewExpiration() *time.Time { + if m != nil { + return m.NewExpiration + } + return nil +} + // EventBuyOrderCreated is an event emitted when a buy order is created. type EventBuyOrderCreated struct { // buy_order_id is the unique ID of buy order. @@ -703,6 +728,9 @@ type EventBuyOrderCreated struct { // retirement_location is the optional retirement location for the credits // which will be used only if disable_auto_retire is false. RetirementLocation string `protobuf:"bytes,7,opt,name=retirement_location,json=retirementLocation,proto3" json:"retirement_location,omitempty"` + // expiration is the optional timestamp when the buy order expires. When the + // expiration time is reached, the buy order is removed from state. + Expiration *time.Time `protobuf:"bytes,8,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` } func (m *EventBuyOrderCreated) Reset() { *m = EventBuyOrderCreated{} } @@ -787,6 +815,13 @@ func (m *EventBuyOrderCreated) GetRetirementLocation() string { return "" } +func (m *EventBuyOrderCreated) GetExpiration() *time.Time { + if m != nil { + return m.Expiration + } + return nil +} + // EventBuyOrderFilled is an event emitted when a buy order is filled. type EventBuyOrderFilled struct { // buy_order_id is the unique ID of the buy order. @@ -953,60 +988,65 @@ func init() { } var fileDescriptor_532d83e215c82e56 = []byte{ - // 848 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6e, 0xe4, 0x44, - 0x10, 0x8e, 0x67, 0xf3, 0x33, 0x53, 0x33, 0xb3, 0xbb, 0x74, 0x22, 0x34, 0x1b, 0xc1, 0xb0, 0x6b, - 0xb4, 0x02, 0x0e, 0xd8, 0x64, 0x91, 0x38, 0x20, 0x71, 0x48, 0x66, 0x41, 0x8a, 0x40, 0x22, 0x0c, - 0xe2, 0xc2, 0xc5, 0x6a, 0xbb, 0x8b, 0xa4, 0x49, 0x4f, 0xb7, 0x69, 0xb7, 0x93, 0x8d, 0xc4, 0x8d, - 0x33, 0x12, 0x3c, 0x0c, 0x4f, 0xc0, 0x05,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f6, 0xf7, 0xd5, 0x78, 0xed, 0xdb, - 0xbd, 0x63, 0x6e, 0x4e, 0xea, 0x3c, 0x29, 0xd4, 0x2c, 0x75, 0x37, 0x88, 0xf7, 0x25, 0x9a, 0x73, - 0xa5, 0x4f, 0x83, 0x25, 0x90, 0x1d, 0xa3, 0x4e, 0x9f, 0xcd, 0xef, 0x1f, 0xf9, 0xa6, 0xbb, 0x36, - 0x7c, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xfa, 0x07, 0x5a, 0x99, 0x08, 0x00, 0x00, + // 928 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4b, 0x6f, 0x23, 0x45, + 0x10, 0xc7, 0x63, 0x27, 0xf1, 0xa3, 0x6c, 0x67, 0x97, 0x89, 0x85, 0xbc, 0x16, 0x38, 0xbb, 0x46, + 0x2b, 0xe0, 0xc0, 0x0c, 0x59, 0x24, 0x0e, 0x48, 0x48, 0x24, 0xde, 0x05, 0x45, 0x20, 0x11, 0x0c, + 0x5c, 0xb8, 0x8c, 0x7a, 0xa6, 0x6b, 0x9d, 0x26, 0xed, 0xee, 0xa1, 0xa7, 0x9d, 0x87, 0xc4, 0x95, + 0x23, 0xd2, 0xf2, 0x61, 0xf8, 0x0e, 0x1c, 0x38, 0xec, 0x81, 0x03, 0x37, 0x50, 0xf2, 0x45, 0x50, + 0x3f, 0x66, 0x1c, 0x3b, 0x1b, 0x62, 0x45, 0x7b, 0x9b, 0x7a, 0x4c, 0x57, 0xf5, 0xaf, 0xfe, 0x53, + 0x36, 0x3c, 0x56, 0x38, 0x41, 0x11, 0x61, 0x2a, 0x53, 0x85, 0x94, 0xe9, 0xe8, 0x64, 0x97, 0xf0, + 0xec, 0x88, 0x3c, 0x89, 0xf0, 0x04, 0x85, 0xce, 0xc3, 0x4c, 0x49, 0x2d, 0x83, 0x9e, 0x4d, 0x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, 0xf9, 0xc7, 0xc5, 0xa0, 0xf2, 0xf2, 0x62, 0x50, 0xf9, + 0xf7, 0x62, 0x50, 0x79, 0x71, 0x39, 0x58, 0x7b, 0x79, 0x39, 0x58, 0xfb, 0xfb, 0x72, 0xb0, 0xf6, + 0xc3, 0xee, 0x84, 0xe9, 0xa3, 0x59, 0x12, 0xa6, 0x72, 0x1a, 0xd9, 0x7f, 0x51, 0x1f, 0x08, 0xd4, + 0xa7, 0x52, 0x1d, 0x7b, 0x8b, 0x23, 0x9d, 0xa0, 0x8a, 0xce, 0xe6, 0xff, 0xc1, 0x92, 0x9a, 0x1d, + 0xdb, 0x47, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x09, 0x8b, 0xbd, 0x9d, 0x09, 0x00, 0x00, } func (m *EventCreateClass) Marshal() (dAtA []byte, err error) { @@ -1349,6 +1389,16 @@ func (m *EventSell) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Expiration != nil { + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintEvents(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x32 + } if m.DisableAutoRetire { i-- if m.DisableAutoRetire { @@ -1413,6 +1463,16 @@ func (m *EventUpdateSellOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NewExpiration != nil { + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.NewExpiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.NewExpiration):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintEvents(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x3a + } if m.DisableAutoRetire { i-- if m.DisableAutoRetire { @@ -1484,6 +1544,16 @@ func (m *EventBuyOrderCreated) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Expiration != nil { + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintEvents(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x42 + } if len(m.RetirementLocation) > 0 { i -= len(m.RetirementLocation) copy(dAtA[i:], m.RetirementLocation) @@ -1837,6 +1907,10 @@ func (m *EventSell) Size() (n int) { if m.DisableAutoRetire { n += 2 } + if m.Expiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration) + n += 1 + l + sovEvents(uint64(l)) + } return n } @@ -1868,6 +1942,10 @@ func (m *EventUpdateSellOrder) Size() (n int) { if m.DisableAutoRetire { n += 2 } + if m.NewExpiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.NewExpiration) + n += 1 + l + sovEvents(uint64(l)) + } return n } @@ -1901,6 +1979,10 @@ func (m *EventBuyOrderCreated) Size() (n int) { if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + if m.Expiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration) + n += 1 + l + sovEvents(uint64(l)) + } return n } @@ -3275,6 +3357,42 @@ func (m *EventSell) Unmarshal(dAtA []byte) error { } } m.DisableAutoRetire = bool(v != 0) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expiration == nil { + m.Expiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -3499,6 +3617,42 @@ func (m *EventUpdateSellOrder) Unmarshal(dAtA []byte) error { } } m.DisableAutoRetire = bool(v != 0) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewExpiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NewExpiration == nil { + m.NewExpiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.NewExpiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -3730,6 +3884,42 @@ func (m *EventBuyOrderCreated) Unmarshal(dAtA []byte) error { } m.RetirementLocation = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expiration == nil { + m.Expiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/ecocredit/expected_keepers.go b/x/ecocredit/expected_keepers.go index 578649addd..9b8ac4a742 100644 --- a/x/ecocredit/expected_keepers.go +++ b/x/ecocredit/expected_keepers.go @@ -27,3 +27,8 @@ type BankKeeper interface { SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error } + +// Keeper defines the expected interface needed to prune expired buy and sell orders. +type Keeper interface { + PruneOrders(ctx sdk.Context) error +} diff --git a/x/ecocredit/module/module.go b/x/ecocredit/module/module.go index e9c54ea9e7..9602444088 100644 --- a/x/ecocredit/module/module.go +++ b/x/ecocredit/module/module.go @@ -17,6 +17,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" restmodule "github.com/regen-network/regen-ledger/types/module/client/grpc_gateway" "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" climodule "github.com/regen-network/regen-ledger/types/module/client/cli" servermodule "github.com/regen-network/regen-ledger/types/module/server" @@ -30,6 +31,7 @@ type Module struct { paramSpace paramtypes.Subspace accountKeeper ecocredit.AccountKeeper bankKeeper ecocredit.BankKeeper + keeper ecocredit.Keeper } // NewModule returns a new Module object. @@ -60,7 +62,7 @@ func (a Module) RegisterInterfaces(registry types.InterfaceRegistry) { } func (a Module) RegisterServices(configurator servermodule.Configurator) { - server.RegisterServices(configurator, a.paramSpace, a.accountKeeper, a.bankKeeper) + a.keeper = server.RegisterServices(configurator, a.paramSpace, a.accountKeeper, a.bankKeeper) } //nolint:errcheck @@ -126,3 +128,11 @@ func (Module) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { func (Module) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return nil } + +// BeginBlock checks if there are any expired sell or buy orders and removes them from state. +func (a Module) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + err := ecocredit.BeginBlocker(ctx, a.keeper) + if err != nil { + panic(err) + } +} diff --git a/x/ecocredit/msgs.go b/x/ecocredit/msgs.go index aca8800e7f..d833376ffc 100644 --- a/x/ecocredit/msgs.go +++ b/x/ecocredit/msgs.go @@ -390,29 +390,28 @@ func (m MsgSell) GetSignBytes() []byte { // ValidateBasic does a sanity check on the provided data. func (m *MsgSell) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Owner); err != nil { return sdkerrors.ErrInvalidAddress } - for i := range m.Orders { - if err := ValidateDenom(m.Orders[i].BatchDenom); err != nil { + for _, order := range m.Orders { + if err := ValidateDenom(order.BatchDenom); err != nil { return err } - if _, err := math.NewPositiveDecFromString(m.Orders[i].Quantity); err != nil { - return sdkerrors.Wrapf(err, "quantity must be positive decimal: %s", m.Orders[i].Quantity) + if _, err := math.NewPositiveDecFromString(order.Quantity); err != nil { + return sdkerrors.Wrapf(err, "quantity must be positive decimal: %s", order.Quantity) } - if m.Orders[i].AskPrice == nil { + if order.AskPrice == nil { return sdkerrors.ErrInvalidRequest.Wrap("ask price cannot be empty") } - if err := m.Orders[i].AskPrice.Validate(); err != nil { + if err := order.AskPrice.Validate(); err != nil { return err } - if !m.Orders[i].AskPrice.Amount.IsPositive() { + if !order.AskPrice.Amount.IsPositive() { return sdkerrors.ErrInvalidRequest.Wrap("ask price must be positive amount") } } @@ -439,26 +438,25 @@ func (m MsgUpdateSellOrders) GetSignBytes() []byte { // ValidateBasic does a sanity check on the provided data. func (m *MsgUpdateSellOrders) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Owner); err != nil { return sdkerrors.ErrInvalidAddress } - for i := range m.Updates { + for _, update := range m.Updates { - if _, err := math.NewPositiveDecFromString(m.Updates[i].NewQuantity); err != nil { - return sdkerrors.Wrapf(err, "quantity must be positive decimal: %s", m.Updates[i].NewQuantity) + if _, err := math.NewPositiveDecFromString(update.NewQuantity); err != nil { + return sdkerrors.Wrapf(err, "quantity must be positive decimal: %s", update.NewQuantity) } - if m.Updates[i].NewAskPrice == nil { + if update.NewAskPrice == nil { return sdkerrors.ErrInvalidRequest.Wrap("new ask price cannot be empty") } - if err := m.Updates[i].NewAskPrice.Validate(); err != nil { + if err := update.NewAskPrice.Validate(); err != nil { return err } - if !m.Updates[i].NewAskPrice.Amount.IsPositive() { + if !update.NewAskPrice.Amount.IsPositive() { return sdkerrors.ErrInvalidRequest.Wrap("ask price must be positive amount") } } @@ -485,7 +483,6 @@ func (m MsgBuy) GetSignBytes() []byte { // ValidateBasic does a sanity check on the provided data. func (m *MsgBuy) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Buyer); err != nil { return sdkerrors.ErrInvalidAddress } diff --git a/x/ecocredit/msgs_test.go b/x/ecocredit/msgs_test.go index f55d9240ff..0caf350722 100644 --- a/x/ecocredit/msgs_test.go +++ b/x/ecocredit/msgs_test.go @@ -970,6 +970,8 @@ func TestMsgUpdateClassMetadata(t *testing.T) { func TestMsgSell(t *testing.T) { _, _, a1 := testdata.KeyTestPubAddr() + validExpiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) + tests := map[string]struct { src MsgSell expErr bool @@ -986,6 +988,7 @@ func TestMsgSell(t *testing.T) { Amount: sdk.NewInt(20), }, DisableAutoRetire: true, + Expiration: &validExpiration, }, }, }, @@ -1076,6 +1079,8 @@ func TestMsgSell(t *testing.T) { func TestMsgUpdateSellOrders(t *testing.T) { _, _, a1 := testdata.KeyTestPubAddr() + validExpiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) + tests := map[string]struct { src MsgUpdateSellOrders expErr bool @@ -1091,6 +1096,7 @@ func TestMsgUpdateSellOrders(t *testing.T) { Amount: sdk.NewInt(20), }, DisableAutoRetire: true, + NewExpiration: &validExpiration, }, }, }, @@ -1161,6 +1167,8 @@ func TestMsgUpdateSellOrders(t *testing.T) { func TestMsgBuy(t *testing.T) { _, _, a1 := testdata.KeyTestPubAddr() + validExpiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) + tests := map[string]struct { src MsgBuy expErr bool @@ -1177,6 +1185,7 @@ func TestMsgBuy(t *testing.T) { }, DisableAutoRetire: true, DisablePartialFill: true, + Expiration: &validExpiration, }, }, }, @@ -1269,57 +1278,24 @@ func TestMsgAllowAskDenom(t *testing.T) { _, _, a1 := testdata.KeyTestPubAddr() tests := map[string]struct { - src MsgBuy + src MsgAllowAskDenom expErr bool }{ "valid": { - src: MsgBuy{ - Buyer: a1.String(), - Orders: []*MsgBuy_Order{ - { - Quantity: "1.5", - BidPrice: &sdk.Coin{ - Denom: "uregen", - Amount: sdk.NewInt(20), - }, - DisableAutoRetire: true, - DisablePartialFill: true, - }, - }, + src: MsgAllowAskDenom{ + RootAddress: a1.String(), + Denom: "uregen", + DisplayDenom: "regen", + Exponent: 6, }, expErr: false, }, - "invalid: bad owner address": { - src: MsgBuy{ - Buyer: "foobar", - Orders: []*MsgBuy_Order{ - { - Quantity: "1.5", - BidPrice: &sdk.Coin{ - Denom: "uregen", - Amount: sdk.NewInt(20), - }, - DisableAutoRetire: true, - DisablePartialFill: true, - }, - }, - }, - expErr: true, - }, - "invalid: bad denom": { - src: MsgBuy{ - Buyer: a1.String(), - Orders: []*MsgBuy_Order{ - { - Quantity: "1.5", - BidPrice: &sdk.Coin{ - Denom: "$$$$$", - Amount: sdk.NewInt(20), - }, - DisableAutoRetire: true, - DisablePartialFill: true, - }, - }, + "invalid address": { + src: MsgAllowAskDenom{ + RootAddress: "foobar", + Denom: "uregen", + DisplayDenom: "regen", + Exponent: 6, }, expErr: true, }, diff --git a/x/ecocredit/server/expiration.go b/x/ecocredit/server/expiration.go new file mode 100644 index 0000000000..c0c4528e28 --- /dev/null +++ b/x/ecocredit/server/expiration.go @@ -0,0 +1,59 @@ +package server + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/regen-network/regen-ledger/orm" + "github.com/regen-network/regen-ledger/x/ecocredit" +) + +// PruneOrders checks if there are any expired sell or buy orders and removes them from state. +func (s serverImpl) PruneOrders(ctx sdk.Context) error { + blockTime := uint64(ctx.BlockTime().Add(time.Nanosecond).UnixNano()) + minTime := uint64(0) + + sellOrdersIter, err := s.sellOrderByExpirationIndex.PrefixScan(ctx, minTime, blockTime) + if err != nil { + return err + } + defer sellOrdersIter.Close() + + var sellOrder ecocredit.SellOrder + for { + _, err := sellOrdersIter.LoadNext(&sellOrder) + if err != nil { + if orm.ErrIteratorDone.Is(err) { + break + } + return err + } + err = s.sellOrderTable.Delete(ctx, sellOrder.OrderId) + if err != nil { + return err + } + } + + buyOrdersIter, err := s.buyOrderByExpirationIndex.PrefixScan(ctx, minTime, blockTime) + if err != nil { + return err + } + defer buyOrdersIter.Close() + + var buyOrder ecocredit.BuyOrder + for { + _, err := buyOrdersIter.LoadNext(&buyOrder) + if err != nil { + if orm.ErrIteratorDone.Is(err) { + break + } + return err + } + err = s.buyOrderTable.Delete(ctx, buyOrder.BuyOrderId) + if err != nil { + return err + } + } + + return nil +} diff --git a/x/ecocredit/server/expiration_test.go b/x/ecocredit/server/expiration_test.go new file mode 100644 index 0000000000..8156c4a847 --- /dev/null +++ b/x/ecocredit/server/expiration_test.go @@ -0,0 +1,133 @@ +package server + +import ( + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store/mem" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/regen-network/regen-ledger/types" + "github.com/regen-network/regen-ledger/x/ecocredit" + "github.com/stretchr/testify/suite" +) + +func TestUSuite(t *testing.T) { + s := new(USuite) + s.sctx, s.storeKey = setupStore(t) + + suite.Run(t, s) +} + +type USuite struct { + suite.Suite + storeKey *sdk.KVStoreKey + cdc codec.Codec + db *mem.Store + server serverImpl + sctx sdk.Context + startTime time.Time + owner sdk.AccAddress +} + +func (s *USuite) SetupSuite() { + registry := codectypes.NewInterfaceRegistry() + ecocredit.RegisterTypes(registry) + s.cdc = codec.NewProtoCodec(registry) + s.server = newServer(s.storeKey, paramtypes.Subspace{} /* paramSpace types.Subspace */, nil, nil, s.cdc) + + s.startTime = time.Unix(0, 0) + s.owner = sdk.AccAddress([]byte("owner")) +} + +func (s *USuite) SetupTest() { + s.sctx = s.sctx.WithBlockTime(s.startTime) +} + +func (s *USuite) TestExpiration() { + require := s.Require() + + before := s.startTime.Add(time.Hour * 24) + expiration := s.startTime.Add(time.Hour * 48) + expiration2 := s.startTime.Add(time.Hour * 50) + after := s.startTime.Add(time.Hour * 72) + owner := s.owner.String() + + s1 := s.createSellOrder(&expiration, owner) + s2 := s.createSellOrder(&expiration2, owner) + s3 := s.createSellOrder(nil, owner) + + b1 := s.createBuyOrder(&expiration, owner) + b2 := s.createBuyOrder(&expiration2, owner) + b3 := s.createBuyOrder(nil, owner) + + /* + * TEST1: set blockchain before the expiration time. + * prunning shouldn't remove anything */ + + s.sctx = s.sctx.WithBlockTime(before) + s.server.PruneOrders(s.sctx) + + require.True(s.server.sellOrderTable.Has(s.sctx, s1)) + require.True(s.server.sellOrderTable.Has(s.sctx, s2)) + require.True(s.server.sellOrderTable.Has(s.sctx, s3)) + require.True(s.server.buyOrderTable.Has(s.sctx, b1)) + require.True(s.server.buyOrderTable.Has(s.sctx, b2)) + require.True(s.server.buyOrderTable.Has(s.sctx, b3)) + + /* + * TEST2: set blockchain at expiration time. + * prunning remove orders <= expiration */ + + s.sctx = s.sctx.WithBlockTime(expiration) + s.server.PruneOrders(s.sctx) + + require.False(s.server.sellOrderTable.Has(s.sctx, s1)) + require.True(s.server.sellOrderTable.Has(s.sctx, s2)) + require.True(s.server.sellOrderTable.Has(s.sctx, s3)) + require.False(s.server.buyOrderTable.Has(s.sctx, b1)) + require.True(s.server.buyOrderTable.Has(s.sctx, b2)) + require.True(s.server.buyOrderTable.Has(s.sctx, b3)) + + s.sctx = s.sctx.WithBlockTime(after) + + /* + * TEST3: set blockchain at "after". + * prunning remove all orders those with no expiration */ + + s.sctx = s.sctx.WithBlockTime(after) + s.server.PruneOrders(s.sctx) + + require.False(s.server.sellOrderTable.Has(s.sctx, s2)) + require.True(s.server.sellOrderTable.Has(s.sctx, s3)) + require.False(s.server.buyOrderTable.Has(s.sctx, b2)) + require.True(s.server.buyOrderTable.Has(s.sctx, b3)) +} + +func (s *USuite) createSellOrder(expiration *time.Time, owner string) uint64 { + o := &ecocredit.MsgSell_Order{ + BatchDenom: "C", + Quantity: "1", + AskPrice: &sdk.Coin{"token", sdk.NewInt(1)}, + DisableAutoRetire: false, + Expiration: expiration, + } + id, err := s.server.createSellOrder(types.Context{s.sctx}, owner, o) + s.Require().NoError(err) + return id +} + +func (s *USuite) createBuyOrder(expiration *time.Time, owner string) uint64 { + o := &ecocredit.MsgBuy_Order{ + Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: 1}}, + Quantity: "1", + BidPrice: &sdk.Coin{"token", sdk.NewInt(1)}, + DisableAutoRetire: false, + Expiration: expiration, + } + id, err := s.server.createBuyOrder(types.Context{s.sctx}, owner, o) + s.Require().NoError(err) + return id +} diff --git a/x/ecocredit/server/msg_server.go b/x/ecocredit/server/msg_server.go index af0798061e..ca9b1b7c75 100644 --- a/x/ecocredit/server/msg_server.go +++ b/x/ecocredit/server/msg_server.go @@ -581,6 +581,11 @@ func (s serverImpl) Sell(goCtx context.Context, req *ecocredit.MsgSell) (*ecocre for i, order := range req.Orders { + // verify expiration is in the future + if order.Expiration != nil && order.Expiration.Before(ctx.BlockTime()) { + return nil, sdkerrors.ErrInvalidRequest.Wrapf("expiration must be in the future: %s", order.Expiration) + } + err = verifyCreditBalance(store, ownerAddr, order.BatchDenom, order.Quantity) if err != nil { return nil, err @@ -588,28 +593,19 @@ func (s serverImpl) Sell(goCtx context.Context, req *ecocredit.MsgSell) (*ecocre // TODO: Verify that AskPrice.Denom is in AllowAskDenom #624 - orderID := s.sellOrderTable.Sequence().PeekNextVal(ctx) - - sellOrderIds[i] = orderID - - _, err = s.sellOrderTable.Create(ctx, &ecocredit.SellOrder{ - Owner: owner, - OrderId: orderID, - BatchDenom: order.BatchDenom, - Quantity: order.Quantity, - AskPrice: order.AskPrice, - DisableAutoRetire: order.DisableAutoRetire, - }) + orderID, err := s.createSellOrder(ctx, owner, order) if err != nil { return nil, err } + sellOrderIds[i] = orderID err = ctx.EventManager().EmitTypedEvent(&ecocredit.EventSell{ OrderId: orderID, BatchDenom: order.BatchDenom, Quantity: order.Quantity, AskPrice: order.AskPrice, DisableAutoRetire: order.DisableAutoRetire, + Expiration: order.Expiration, }) if err != nil { return nil, err @@ -621,6 +617,20 @@ func (s serverImpl) Sell(goCtx context.Context, req *ecocredit.MsgSell) (*ecocre return &ecocredit.MsgSellResponse{SellOrderIds: sellOrderIds}, nil } +func (s serverImpl) createSellOrder(ctx types.Context, owner string, o *ecocredit.MsgSell_Order) (uint64, error) { + orderID := s.sellOrderTable.Sequence().PeekNextVal(ctx) + _, err := s.sellOrderTable.Create(ctx, &ecocredit.SellOrder{ + Owner: owner, + OrderId: orderID, + BatchDenom: o.BatchDenom, + Quantity: o.Quantity, + AskPrice: o.AskPrice, + DisableAutoRetire: o.DisableAutoRetire, + Expiration: o.Expiration, + }) + return orderID, err +} + // UpdateSellOrders updates existing sell orders for credits func (s serverImpl) UpdateSellOrders(goCtx context.Context, req *ecocredit.MsgUpdateSellOrders) (*ecocredit.MsgUpdateSellOrdersResponse, error) { ctx := types.UnwrapSDKContext(goCtx) @@ -634,6 +644,11 @@ func (s serverImpl) UpdateSellOrders(goCtx context.Context, req *ecocredit.MsgUp for _, update := range req.Updates { + // verify expiration is in the future + if update.NewExpiration != nil && update.NewExpiration.Before(ctx.BlockTime()) { + return nil, sdkerrors.ErrInvalidRequest.Wrapf("expiration must be in the future: %s", update.NewExpiration) + } + sellOrder, err := s.getSellOrder(ctx, update.SellOrderId) if err != nil { return nil, ecocredit.ErrInvalidSellOrder.Wrapf("sell order id %d not found", update.SellOrderId) @@ -653,6 +668,7 @@ func (s serverImpl) UpdateSellOrders(goCtx context.Context, req *ecocredit.MsgUp sellOrder.Quantity = update.NewQuantity sellOrder.AskPrice = update.NewAskPrice sellOrder.DisableAutoRetire = update.DisableAutoRetire + sellOrder.Expiration = update.NewExpiration err = s.sellOrderTable.Update(ctx, sellOrder.OrderId, sellOrder) if err != nil { @@ -666,6 +682,7 @@ func (s serverImpl) UpdateSellOrders(goCtx context.Context, req *ecocredit.MsgUp NewQuantity: sellOrder.Quantity, NewAskPrice: sellOrder.AskPrice, DisableAutoRetire: sellOrder.DisableAutoRetire, + NewExpiration: sellOrder.Expiration, }) if err != nil { return nil, err @@ -693,6 +710,11 @@ func (s serverImpl) Buy(goCtx context.Context, req *ecocredit.MsgBuy) (*ecocredi for i, order := range req.Orders { + // verify expiration is in the future + if order.Expiration != nil && order.Expiration.Before(ctx.BlockTime()) { + return nil, sdkerrors.ErrInvalidRequest.Wrapf("expiration must be in the future: %s", order.Expiration) + } + balances := s.bankKeeper.SpendableCoins(sdkCtx, buyerAddr) bidPrice := order.BidPrice balanceAmount := balances.AmountOf(bidPrice.Denom) @@ -843,6 +865,7 @@ func (s serverImpl) Buy(goCtx context.Context, req *ecocredit.MsgBuy) (*ecocredi DisableAutoRetire: order.DisableAutoRetire, DisablePartialFill: order.DisablePartialFill, RetirementLocation: order.RetirementLocation, + Expiration: order.Expiration, }) if err != nil { return nil, err @@ -872,6 +895,26 @@ func (s serverImpl) Buy(goCtx context.Context, req *ecocredit.MsgBuy) (*ecocredi return &ecocredit.MsgBuyResponse{BuyOrderIds: buyOrderIds}, nil } +func (s serverImpl) createBuyOrder(ctx types.Context, buyer string, o *ecocredit.MsgBuy_Order) (uint64, error) { + orderID := s.buyOrderTable.Sequence().PeekNextVal(ctx) + selection := ecocredit.BuyOrder_Selection{ + Sum: &ecocredit.BuyOrder_Selection_SellOrderId{ + SellOrderId: o.Selection.GetSellOrderId(), + }, + } + _, err := s.buyOrderTable.Create(ctx, &ecocredit.BuyOrder{ + Buyer: buyer, + BuyOrderId: orderID, + Selection: &selection, + Quantity: o.Quantity, + BidPrice: o.BidPrice, + DisableAutoRetire: o.DisableAutoRetire, + DisablePartialFill: o.DisablePartialFill, + Expiration: o.Expiration, + }) + return orderID, err +} + // AllowAskDenom adds a new ask denom func (s serverImpl) AllowAskDenom(goCtx context.Context, req *ecocredit.MsgAllowAskDenom) (*ecocredit.MsgAllowAskDenomResponse, error) { ctx := types.UnwrapSDKContext(goCtx) diff --git a/x/ecocredit/server/server.go b/x/ecocredit/server/server.go index aca0e398f9..40f1ac8e89 100644 --- a/x/ecocredit/server/server.go +++ b/x/ecocredit/server/server.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/regen-network/regen-ledger/orm" "github.com/regen-network/regen-ledger/types/module/server" "github.com/regen-network/regen-ledger/x/ecocredit" @@ -30,11 +29,13 @@ const ( SellOrderTableSeqPrefix byte = 0x11 SellOrderByAddressIndexPrefix byte = 0x12 SellOrderByBatchDenomIndexPrefix byte = 0x13 + SellOrderByExpirationIndexPrefix byte = 0x14 // buy order table - BuyOrderTablePrefix byte = 0x20 - BuyOrderTableSeqPrefix byte = 0x21 - BuyOrderByAddressIndexPrefix byte = 0x22 + BuyOrderTablePrefix byte = 0x20 + BuyOrderTableSeqPrefix byte = 0x21 + BuyOrderByAddressIndexPrefix byte = 0x22 + BuyOrderByExpirationIndexPrefix byte = 0x23 AskDenomTablePrefix byte = 0x30 ) @@ -56,10 +57,12 @@ type serverImpl struct { sellOrderTable orm.AutoUInt64Table sellOrderByAddressIndex orm.Index sellOrderByBatchDenomIndex orm.Index + sellOrderByExpirationIndex orm.Index // buy order table - buyOrderTable orm.AutoUInt64Table - buyOrderByAddressIndex orm.Index + buyOrderTable orm.AutoUInt64Table + buyOrderByAddressIndex orm.Index + buyOrderByExpirationIndex orm.Index askDenomTable orm.PrimaryKeyTable @@ -137,6 +140,19 @@ func newServer(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, if err != nil { panic(err.Error()) } + s.sellOrderByExpirationIndex, err = orm.NewIndex(sellOrderTableBuilder, SellOrderByExpirationIndexPrefix, func(value interface{}) ([]interface{}, error) { + order, ok := value.(*ecocredit.SellOrder) + if !ok { + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T got %T", ecocredit.SellOrder{}, value) + } + if order.Expiration == nil { + return nil, nil + } + return []interface{}{uint64(order.Expiration.UnixNano())}, nil + }, uint64(0)) + if err != nil { + panic(err.Error()) + } s.sellOrderTable = sellOrderTableBuilder.Build() buyOrderTableBuilder, err := orm.NewAutoUInt64TableBuilder(BuyOrderTablePrefix, BuyOrderTableSeqPrefix, storeKey, &ecocredit.BuyOrder{}, cdc) @@ -157,6 +173,19 @@ func newServer(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, if err != nil { panic(err.Error()) } + s.buyOrderByExpirationIndex, err = orm.NewIndex(buyOrderTableBuilder, BuyOrderByExpirationIndexPrefix, func(value interface{}) ([]interface{}, error) { + order, ok := value.(*ecocredit.BuyOrder) + if !ok { + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T got %T", ecocredit.BuyOrder{}, value) + } + if order.Expiration == nil { + return nil, nil + } + return []interface{}{uint64(order.Expiration.UnixNano())}, nil + }, uint64(0)) + if err != nil { + panic(err.Error()) + } s.buyOrderTable = buyOrderTableBuilder.Build() askDenomTableBuilder, err := orm.NewPrimaryKeyTableBuilder(AskDenomTablePrefix, storeKey, &ecocredit.AskDenom{}, cdc) @@ -188,11 +217,12 @@ func newServer(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, } func RegisterServices(configurator server.Configurator, paramSpace paramtypes.Subspace, accountKeeper ecocredit.AccountKeeper, - bankKeeper ecocredit.BankKeeper) { + bankKeeper ecocredit.BankKeeper) ecocredit.Keeper { impl := newServer(configurator.ModuleKey(), paramSpace, accountKeeper, bankKeeper, configurator.Marshaler()) ecocredit.RegisterMsgServer(configurator.MsgServer(), impl) ecocredit.RegisterQueryServer(configurator.QueryServer(), impl) configurator.RegisterGenesisHandlers(impl.InitGenesis, impl.ExportGenesis) configurator.RegisterWeightedOperationsHandler(impl.WeightedOperations) configurator.RegisterInvariantsHandler(impl.RegisterInvariants) + return impl } diff --git a/x/ecocredit/server/testsuite/suite.go b/x/ecocredit/server/testsuite/suite.go index ae29344e06..70d0856885 100644 --- a/x/ecocredit/server/testsuite/suite.go +++ b/x/ecocredit/server/testsuite/suite.go @@ -987,22 +987,26 @@ func (s *IntegrationTestSuite) TestScenario() { // reset the space to avoid corrupting other tests s.paramSpace.Set(s.sdkCtx, ecocredit.KeyCreditTypes, ecocredit.DefaultParams().CreditTypes) - askPrice := sdk.NewInt64Coin("stake", 1) + coinPrice := sdk.NewInt64Coin("stake", 1000000) + expiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) expectedSellOrderIds := []uint64{1, 2} + createSellOrder, err := s.msgClient.Sell(s.ctx, &ecocredit.MsgSell{ Owner: addr3, Orders: []*ecocredit.MsgSell_Order{ { BatchDenom: batchDenom, Quantity: "1.0", - AskPrice: &askPrice, + AskPrice: &coinPrice, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: batchDenom, Quantity: "1.0", - AskPrice: &askPrice, + AskPrice: &coinPrice, DisableAutoRetire: true, + Expiration: &expiration, }, }, }) @@ -1019,9 +1023,10 @@ func (s *IntegrationTestSuite) TestScenario() { { Selection: selection, Quantity: "1.0", - BidPrice: &askPrice, + BidPrice: &coinPrice, DisableAutoRetire: true, DisablePartialFill: true, + Expiration: &expiration, }, }, }) diff --git a/x/ecocredit/server/testsuite/tx.go b/x/ecocredit/server/testsuite/tx.go index b677e17ea2..947b37c0f6 100644 --- a/x/ecocredit/server/testsuite/tx.go +++ b/x/ecocredit/server/testsuite/tx.go @@ -17,6 +17,9 @@ func (s *IntegrationTestSuite) TestScenarioCreateSellOrders() { // TODO: Verify that AskPrice.Denom is in AllowAskDenom #624 //askPrice2 := sdk.NewInt64Coin("token", 1000000) + expiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) + invalidExpiration := time.Date(2020, 01, 01, 0, 0, 0, 0, time.UTC) + // create sell orders testCases := []struct { name string @@ -34,12 +37,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateSellOrders() { Quantity: "1.0", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: "A00-00000000-00000000-000", Quantity: "1.0", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "insufficient credit balance", @@ -54,17 +59,41 @@ func (s *IntegrationTestSuite) TestScenarioCreateSellOrders() { Quantity: "99", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: createBatchRes.BatchDenom, Quantity: "99", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "insufficient credit balance", wantErr: true, }, + { + name: "invalid expiration", + owner: addr1, + orders: []*ecocredit.MsgSell_Order{ + { + BatchDenom: createBatchRes.BatchDenom, + Quantity: "1.0", + AskPrice: &askPrice1, + DisableAutoRetire: true, + Expiration: &invalidExpiration, + }, + { + BatchDenom: createBatchRes.BatchDenom, + Quantity: "1.0", + AskPrice: &askPrice1, + DisableAutoRetire: true, + Expiration: &invalidExpiration, + }, + }, + expErr: "expiration must be in the future", + wantErr: true, + }, // TODO: Verify that AskPrice.Denom is in AllowAskDenom #624 //{ // name: "denom not allowed", @@ -75,12 +104,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateSellOrders() { // Quantity: "1.0", // AskPrice: &askPrice2, // DisableAutoRetire: true, + // Expiration: &expiration, // }, // { // BatchDenom: createBatchRes.BatchDenom, // Quantity: "1.0", // AskPrice: &askPrice2, // DisableAutoRetire: true, + // Expiration: &expiration, // }, // }, // expErr: "denom not allowed", @@ -95,12 +126,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateSellOrders() { Quantity: "1.0", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: createBatchRes.BatchDenom, Quantity: "1.0", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "", @@ -154,6 +187,9 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { // TODO: Verify that NewAskPrice.Denom is in AllowAskDenom #624 //askPrice2 := sdk.NewInt64Coin("token", 2000000) + expiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) + invalidExpiration := time.Date(2020, 01, 01, 0, 0, 0, 0, time.UTC) + // create sell order sellRes, err := s.msgClient.Sell(s.ctx, &ecocredit.MsgSell{ Owner: addr1, @@ -163,12 +199,14 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { Quantity: "1.0", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: createBatchRes.BatchDenom, Quantity: "1.0", AskPrice: &askPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, }) @@ -191,12 +229,14 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { NewQuantity: "1.0", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, { SellOrderId: 100, NewQuantity: "1.0", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, }, expErr: "invalid sell order", @@ -211,12 +251,14 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { NewQuantity: "1.0", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, { SellOrderId: sellRes.SellOrderIds[1], NewQuantity: "1.0", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, }, expErr: "unauthorized", @@ -231,17 +273,41 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { NewQuantity: "99", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, { SellOrderId: sellRes.SellOrderIds[1], NewQuantity: "99", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, }, expErr: "insufficient credit balance", wantErr: true, }, + { + name: "invalid expiration", + owner: addr1, + updates: []*ecocredit.MsgUpdateSellOrders_Update{ + { + SellOrderId: sellRes.SellOrderIds[0], + NewQuantity: "1.0", + NewAskPrice: &askPrice1, + DisableAutoRetire: true, + NewExpiration: &invalidExpiration, + }, + { + SellOrderId: sellRes.SellOrderIds[1], + NewQuantity: "1.0", + NewAskPrice: &askPrice1, + DisableAutoRetire: true, + NewExpiration: &invalidExpiration, + }, + }, + expErr: "expiration must be in the future", + wantErr: true, + }, // TODO: Verify that NewAskPrice.Denom is in AllowAskDenom #624 //{ // name: "denom not allowed", @@ -252,12 +318,14 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { // NewQuantity: "1.0", // NewAskPrice: &askPrice2, // DisableAutoRetire: true, + // NewExpiration: &expiration, // }, // { // SellOrderId: sellRes.SellOrderIds[1], // NewQuantity: "1.0", // NewAskPrice: &askPrice2, // DisableAutoRetire: true, + // NewExpiration: &expiration, // }, // }, // expErr: "denom not allowed", @@ -272,12 +340,14 @@ func (s *IntegrationTestSuite) TestScenarioUpdateSellOrders() { NewQuantity: "1.0", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, { SellOrderId: sellRes.SellOrderIds[1], NewQuantity: "1.0", NewAskPrice: &askPrice1, DisableAutoRetire: true, + NewExpiration: &expiration, }, }, expErr: "", @@ -333,6 +403,9 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { // TODO: Verify that BidPrice.Denom is in AllowAskDenom #624 //bidPrice3 := sdk.NewInt64Coin("token", 1000000) + expiration := time.Date(2030, 01, 01, 0, 0, 0, 0, time.UTC) + invalidExpiration := time.Date(2020, 01, 01, 0, 0, 0, 0, time.UTC) + // fund buyer account s.Require().NoError(s.fundAccount(addr2, sdk.NewCoins(sdk.NewInt64Coin("stake", 5000000)))) @@ -345,12 +418,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "1.0", AskPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: createBatchRes.BatchDenom, Quantity: "1.0", AskPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: createBatchRes.BatchDenom, @@ -369,12 +444,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "1.0", AskPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { BatchDenom: createBatchRes.BatchDenom, Quantity: "1.0", AskPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, }) @@ -400,12 +477,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "1.0", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: 100}}, Quantity: "1.0", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "not found", @@ -420,12 +499,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "99.99", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[1]}}, Quantity: "99.99", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "insufficient balance", @@ -440,17 +521,41 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "1.0", BidPrice: &bidPrice2, DisableAutoRetire: true, + Expiration: &expiration, }, { Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[1]}}, Quantity: "1.0", BidPrice: &bidPrice2, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "insufficient balance", wantErr: true, }, + { + name: "invalid expiration", + buyer: addr2.String(), + orders: []*ecocredit.MsgBuy_Order{ + { + Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[0]}}, + Quantity: "1.0", + BidPrice: &bidPrice1, + DisableAutoRetire: true, + Expiration: &invalidExpiration, + }, + { + Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[1]}}, + Quantity: "1.0", + BidPrice: &bidPrice1, + DisableAutoRetire: true, + Expiration: &invalidExpiration, + }, + }, + expErr: "expiration must be in the future", + wantErr: true, + }, // TODO: Verify that BidPrice.Denom is in AllowAskDenom #624 //{ // name: "denom not allowed", @@ -461,12 +566,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { // Quantity: "1.0", // BidPrice: &bidPrice3, // DisableAutoRetire: true, + // Expiration: &expiration, // }, // { // Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[1]}}, // Quantity: "1.0", // BidPrice: &bidPrice3, // DisableAutoRetire: true, + // Expiration: &expiration, // }, // }, // expErr: "denom not allowed", @@ -521,12 +628,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "1.0", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[1]}}, Quantity: "1.0", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "", @@ -575,12 +684,14 @@ func (s *IntegrationTestSuite) TestScenarioCreateBuyOrders() { Quantity: "0.5", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, { Selection: &ecocredit.MsgBuy_Order_Selection{Sum: &ecocredit.MsgBuy_Order_Selection_SellOrderId{SellOrderId: sellRes.SellOrderIds[5]}}, Quantity: "0.5", BidPrice: &bidPrice1, DisableAutoRetire: true, + Expiration: &expiration, }, }, expErr: "", diff --git a/x/ecocredit/spec/protobuf.md b/x/ecocredit/spec/protobuf.md index 8aea0e0cc5..c78e504058 100644 --- a/x/ecocredit/spec/protobuf.md +++ b/x/ecocredit/spec/protobuf.md @@ -176,6 +176,7 @@ EventBuyOrderCreated is an event emitted when a buy order is created. | disable_auto_retire | [bool](#bool) | | disable_auto_retire allows auto-retirement to be disabled. If it is set to true the credits will not auto-retire and can be resold assuming that the corresponding sell order has auto-retirement disabled. If the sell order hasn't disabled auto-retirement and the buy order tries to disable it, that buy order will fail. | | disable_partial_fill | [bool](#bool) | | disable_partial_fill disables the default behavior of partially filling buy orders if the requested quantity is not available. | | retirement_location | [string](#string) | | retirement_location is the optional retirement location for the credits which will be used only if disable_auto_retire is false. | +| expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | expiration is the optional timestamp when the buy order expires. When the expiration time is reached, the buy order is removed from state. | @@ -330,6 +331,7 @@ EventSell is an event emitted when a sell order is created. | quantity | [string](#string) | | quantity is the quantity of credits being sold. | | ask_price | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | ask_price is the price 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. | | disable_auto_retire | [bool](#bool) | | 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. | +| expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | expiration is an optional timestamp when the sell order expires. When the expiration time is reached, the sell order is removed from state. | @@ -350,6 +352,7 @@ EventUpdateSellOrder is an event emitted when a sell order is updated. | new_quantity | [string](#string) | | new_quantity is the updated quantity of credits available to sell, if it is set to zero then the order is cancelled. | | new_ask_price | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | new_ask_price is the new ask price for this sell order | | disable_auto_retire | [bool](#bool) | | disable_auto_retire updates the disable_auto_retire field in the sell order. | +| new_expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | new_expiration is an optional timestamp when the sell order expires. When the expiration time is reached, the sell order is removed from state. | @@ -457,6 +460,7 @@ BuyOrder represents the information for a buy order. | bid_price | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | bid price is the bid price for this buy order. A credit unit will be settled at a purchase price that is no more than the bid price. The buy order will fail if the buyer does not have enough funds available to complete the purchase. | | disable_auto_retire | [bool](#bool) | | disable_auto_retire allows auto-retirement to be disabled. If it is set to true the credits will not auto-retire and can be resold assuming that the corresponding sell order has auto-retirement disabled. If the sell order hasn't disabled auto-retirement and the buy order tries to disable it, that buy order will fail. | | disable_partial_fill | [bool](#bool) | | disable_partial_fill disables the default behavior of partially filling buy orders if the requested quantity is not available. | +| expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | expiration is the optional timestamp when the buy order expires. When the expiration time is reached, the buy order is removed from state. | @@ -659,6 +663,7 @@ SellOrder represents the information for a sell order. | quantity | [string](#string) | | quantity is the quantity of credits being sold. | | ask_price | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | ask_price is the price 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. | | disable_auto_retire | [bool](#bool) | | 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. | +| expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | expiration is an optional timestamp when the sell order expires. When the expiration time is reached, the sell order is removed from state. | @@ -1551,6 +1556,7 @@ Order is a buy order. | disable_auto_retire | [bool](#bool) | | disable_auto_retire allows auto-retirement to be disabled. If it is set to true the credits will not auto-retire and can be resold assuming that the corresponding sell order has auto-retirement disabled. If the sell order hasn't disabled auto-retirement and the buy order tries to disable it, that buy order will fail. | | disable_partial_fill | [bool](#bool) | | disable_partial_fill disables the default behavior of partially filling buy orders if the requested quantity is not available. | | retirement_location | [string](#string) | | retirement_location is the optional retirement location for the credits which will be used only if disable_auto_retire is false. | +| expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | expiration is the optional timestamp when the buy order expires. When the expiration time is reached, the buy order is removed from state. | @@ -1885,6 +1891,7 @@ Order is the content of a new sell order. | quantity | [string](#string) | | quantity is the quantity of credits being sold from this batch. If it is less then the balance of credits the owner has available at the time this sell order is matched, the quantity will be adjusted downwards to the owner's balance. However, if the balance of credits is less than this quantity at the time the sell order is created, the operation will fail. | | ask_price | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | ask_price is the price 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. | | disable_auto_retire | [bool](#bool) | | 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. | +| expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | expiration is an optional timestamp when the sell order expires. When the expiration time is reached, the sell order is removed from state. | @@ -2095,6 +2102,7 @@ Update is an update to an existing sell order. | new_quantity | [string](#string) | | new_quantity is the updated quantity of credits available to sell, if it is set to zero then the order is cancelled. | | new_ask_price | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | new_ask_price is the new ask price for this sell order | | disable_auto_retire | [bool](#bool) | | disable_auto_retire updates the disable_auto_retire field in the sell order. | +| new_expiration | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | new_expiration is an optional timestamp when the sell order expires. When the expiration time is reached, the sell order is removed from state. | diff --git a/x/ecocredit/tx.pb.go b/x/ecocredit/tx.pb.go index b524f775ba..3ee2c03b48 100644 --- a/x/ecocredit/tx.pb.go +++ b/x/ecocredit/tx.pb.go @@ -1384,6 +1384,9 @@ type MsgSell_Order struct { // buyer to disable auto-retirement in their buy order enabling them to // resell the credits to another buyer. DisableAutoRetire bool `protobuf:"varint,4,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` + // expiration is an optional timestamp when the sell order expires. When the + // expiration time is reached, the sell order is removed from state. + Expiration *time.Time `protobuf:"bytes,5,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` } func (m *MsgSell_Order) Reset() { *m = MsgSell_Order{} } @@ -1447,6 +1450,13 @@ func (m *MsgSell_Order) GetDisableAutoRetire() bool { return false } +func (m *MsgSell_Order) GetExpiration() *time.Time { + if m != nil { + return m.Expiration + } + return nil +} + // MsgSellResponse is the Msg/Sell response type. type MsgSellResponse struct { // sell_order_ids are the sell order IDs of the newly created sell orders. @@ -1559,6 +1569,9 @@ type MsgUpdateSellOrders_Update struct { NewAskPrice *types1.Coin `protobuf:"bytes,3,opt,name=new_ask_price,json=newAskPrice,proto3" json:"new_ask_price,omitempty"` // disable_auto_retire updates the disable_auto_retire field in the sell order. DisableAutoRetire bool `protobuf:"varint,4,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` + // new_expiration is an optional timestamp when the sell order expires. When the + // expiration time is reached, the sell order is removed from state. + NewExpiration *time.Time `protobuf:"bytes,5,opt,name=new_expiration,json=newExpiration,proto3,stdtime" json:"new_expiration,omitempty"` } func (m *MsgUpdateSellOrders_Update) Reset() { *m = MsgUpdateSellOrders_Update{} } @@ -1622,6 +1635,13 @@ func (m *MsgUpdateSellOrders_Update) GetDisableAutoRetire() bool { return false } +func (m *MsgUpdateSellOrders_Update) GetNewExpiration() *time.Time { + if m != nil { + return m.NewExpiration + } + return nil +} + // MsgUpdateSellOrdersResponse is the Msg/UpdateSellOrders response type. type MsgUpdateSellOrdersResponse struct { } @@ -1739,6 +1759,9 @@ type MsgBuy_Order struct { // retirement_location is the optional retirement location for the credits // which will be used only if disable_auto_retire is false. RetirementLocation string `protobuf:"bytes,6,opt,name=retirement_location,json=retirementLocation,proto3" json:"retirement_location,omitempty"` + // expiration is the optional timestamp when the buy order expires. When the + // expiration time is reached, the buy order is removed from state. + Expiration *time.Time `protobuf:"bytes,7,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` } func (m *MsgBuy_Order) Reset() { *m = MsgBuy_Order{} } @@ -1816,6 +1839,13 @@ func (m *MsgBuy_Order) GetRetirementLocation() string { return "" } +func (m *MsgBuy_Order) GetExpiration() *time.Time { + if m != nil { + return m.Expiration + } + return nil +} + // Selection defines a buy order selection. type MsgBuy_Order_Selection struct { // sum defines the type of selection. @@ -2598,122 +2628,125 @@ func init() { func init() { proto.RegisterFile("regen/ecocredit/v1alpha2/tx.proto", fileDescriptor_e82815fbf9298ddc) } var fileDescriptor_e82815fbf9298ddc = []byte{ - // 1840 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0x0f, 0x25, 0x5b, 0xb6, 0x9e, 0x2c, 0x39, 0x19, 0xa7, 0xa9, 0xc2, 0x34, 0x8e, 0xcd, 0xa4, - 0x1b, 0xa5, 0x45, 0xa8, 0xd8, 0xd9, 0xee, 0x07, 0xfa, 0xb1, 0x95, 0xbd, 0xd8, 0xc6, 0xd8, 0x3a, - 0x4d, 0x18, 0xf7, 0xb2, 0x40, 0x41, 0x8c, 0xc8, 0x59, 0x85, 0x35, 0xc5, 0x51, 0x39, 0x54, 0x1c, - 0x5d, 0x0a, 0xf4, 0xd2, 0x4b, 0x0b, 0x74, 0x2f, 0xfd, 0x17, 0x7a, 0xe9, 0xd7, 0x7d,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x0c, 0x87, 0x9a, 0x7b, 0x85, 0xa1, 0xd9, 0xc2, 0x97, 0xed, 0x3f, 0xe6, 0xe7, 0x25, 0x83, 0x5c, - 0x50, 0xf8, 0xa6, 0xb5, 0x11, 0x31, 0x34, 0x26, 0x3a, 0x83, 0xf9, 0x95, 0x22, 0x0f, 0x36, 0xef, - 0x2f, 0x01, 0xce, 0xee, 0x39, 0x71, 0x2d, 0xcf, 0xdf, 0x33, 0x0f, 0x5e, 0xb0, 0xe7, 0xf4, 0xfb, - 0xf2, 0xe0, 0xe3, 0xbf, 0xbf, 0xd8, 0x36, 0xbe, 0x78, 0xb1, 0x6d, 0xfc, 0xe7, 0xc5, 0xb6, 0xf1, - 0xd9, 0xcb, 0xed, 0x0b, 0x5f, 0xbc, 0xdc, 0xbe, 0xf0, 0xcf, 0x97, 0xdb, 0x17, 0x3e, 0xd9, 0xeb, - 0x05, 0xc9, 0xd3, 0x61, 0xd7, 0xf6, 0x68, 0xbf, 0x2d, 0x0c, 0xdf, 0x8d, 0x48, 0x72, 0x46, 0xe3, - 0x53, 0xb5, 0x0a, 0x89, 0xdf, 0x23, 0x71, 0xfb, 0xf9, 0xf8, 0x5f, 0x2e, 0xdd, 0x8a, 0xf8, 0x42, - 0x7d, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x0c, 0x11, 0xa3, 0x20, 0x1a, 0x00, 0x00, + // 1873 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x19, 0x4d, 0x73, 0x1b, 0x49, + 0x35, 0x23, 0xd9, 0xb2, 0xf4, 0x64, 0xc9, 0x49, 0x3b, 0x04, 0x65, 0x42, 0x1c, 0x7b, 0x12, 0x36, + 0x0a, 0x54, 0x46, 0xb1, 0xb3, 0xec, 0x47, 0xf1, 0xb1, 0x2b, 0x7b, 0xd9, 0x8d, 0x6b, 0x71, 0x48, + 0x26, 0xe6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4, 0x55, 0xde, + 0x2e, 0xb7, 0xeb, 0x7b, 0xef, 0x98, 0xf3, 0x52, 0xd3, 0xcc, 0x5e, 0x69, 0xf2, 0x9f, 0x87, 0x92, + 0xdb, 0x52, 0x72, 0x32, 0xee, 0x5b, 0x99, 0x72, 0xdf, 0x07, 0x00, 0x34, 0xc6, 0x51, 0x6c, 0xbb, + 0x38, 0x26, 0xdc, 0x27, 0xf5, 0x3d, 0xdd, 0x14, 0xc9, 0x6d, 0x26, 0xc9, 0x6d, 0x1e, 0x27, 0xc9, + 0xbd, 0xbf, 0xf2, 0xc5, 0xbf, 0x6f, 0x68, 0x56, 0x8d, 0xf3, 0x7c, 0x84, 0x63, 0x82, 0xbe, 0x0b, + 0x55, 0x12, 0xb8, 0x82, 0xbd, 0x52, 0x90, 0x7d, 0x8d, 0x04, 0x2e, 0x63, 0xd6, 0xff, 0xa2, 0x41, + 0x23, 0xa3, 0x35, 0xfa, 0x06, 0xd4, 0x22, 0xe2, 0x78, 0x43, 0x8f, 0x04, 0x71, 0xe2, 0x67, 0x85, + 0x40, 0xb7, 0x61, 0x23, 0x8e, 0xb0, 0x8b, 0x7b, 0x3e, 0xb1, 0xf1, 0x20, 0x1c, 0x05, 0xb1, 0xf4, + 0x60, 0x33, 0x41, 0x77, 0x39, 0x16, 0x7d, 0x13, 0x9a, 0x11, 0x89, 0xbd, 0x88, 0xb8, 0x09, 0x5d, + 0x99, 0xd3, 0x35, 0x24, 0x56, 0x92, 0x75, 0x60, 0x53, 0x20, 0x06, 0x24, 0x38, 0x97, 0x3f, 0x68, + 0x72, 0x94, 0xa4, 0x90, 0xf1, 0x7e, 0xaa, 0x0c, 0xb8, 0xe2, 0x2a, 0x43, 0x6e, 0x40, 0xbd, 0xc7, + 0x10, 0xb6, 0x4b, 0x82, 0x70, 0x20, 0x55, 0x07, 0x8e, 0xfa, 0x88, 0x61, 0x8c, 0xe7, 0x25, 0x58, + 0x3b, 0xa2, 0xfd, 0x27, 0x24, 0x70, 0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// Reference imports to suppress errors if they are not otherwise used. @@ -4393,6 +4426,16 @@ func (m *MsgSell_Order) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Expiration != nil { + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintTx(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x2a + } if m.DisableAutoRetire { i-- if m.DisableAutoRetire { @@ -4453,20 +4496,20 @@ func (m *MsgSellResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.SellOrderIds) > 0 { - dAtA5 := make([]byte, len(m.SellOrderIds)*10) - var j4 int + dAtA6 := make([]byte, len(m.SellOrderIds)*10) + var j5 int for _, num := range m.SellOrderIds { for num >= 1<<7 { - dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) + dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j4++ + j5++ } - dAtA5[j4] = uint8(num) - j4++ + dAtA6[j5] = uint8(num) + j5++ } - i -= j4 - copy(dAtA[i:], dAtA5[:j4]) - i = encodeVarintTx(dAtA, i, uint64(j4)) + i -= j5 + copy(dAtA[i:], dAtA6[:j5]) + i = encodeVarintTx(dAtA, i, uint64(j5)) i-- dAtA[i] = 0xa } @@ -4537,6 +4580,16 @@ func (m *MsgUpdateSellOrders_Update) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l + if m.NewExpiration != nil { + n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.NewExpiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.NewExpiration):]) + if err7 != nil { + return 0, err7 + } + i -= n7 + i = encodeVarintTx(dAtA, i, uint64(n7)) + i-- + dAtA[i] = 0x2a + } if m.DisableAutoRetire { i-- if m.DisableAutoRetire { @@ -4661,6 +4714,16 @@ func (m *MsgBuy_Order) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Expiration != nil { + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintTx(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0x3a + } if len(m.RetirementLocation) > 0 { i -= len(m.RetirementLocation) copy(dAtA[i:], m.RetirementLocation) @@ -4787,20 +4850,20 @@ func (m *MsgBuyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.BuyOrderIds) > 0 { - dAtA10 := make([]byte, len(m.BuyOrderIds)*10) - var j9 int + dAtA13 := make([]byte, len(m.BuyOrderIds)*10) + var j12 int for _, num := range m.BuyOrderIds { for num >= 1<<7 { - dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j9++ + j12++ } - dAtA10[j9] = uint8(num) - j9++ + dAtA13[j12] = uint8(num) + j12++ } - i -= j9 - copy(dAtA[i:], dAtA10[:j9]) - i = encodeVarintTx(dAtA, i, uint64(j9)) + i -= j12 + copy(dAtA[i:], dAtA13[:j12]) + i = encodeVarintTx(dAtA, i, uint64(j12)) i-- dAtA[i] = 0xa } @@ -5691,6 +5754,10 @@ func (m *MsgSell_Order) Size() (n int) { if m.DisableAutoRetire { n += 2 } + if m.Expiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration) + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -5749,6 +5816,10 @@ func (m *MsgUpdateSellOrders_Update) Size() (n int) { if m.DisableAutoRetire { n += 2 } + if m.NewExpiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.NewExpiration) + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -5808,6 +5879,10 @@ func (m *MsgBuy_Order) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.Expiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration) + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -9010,6 +9085,42 @@ func (m *MsgSell_Order) Unmarshal(dAtA []byte) error { } } m.DisableAutoRetire = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expiration == nil { + m.Expiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -9418,6 +9529,42 @@ func (m *MsgUpdateSellOrders_Update) Unmarshal(dAtA []byte) error { } } m.DisableAutoRetire = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewExpiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NewExpiration == nil { + m.NewExpiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.NewExpiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -9819,6 +9966,42 @@ func (m *MsgBuy_Order) Unmarshal(dAtA []byte) error { } m.RetirementLocation = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expiration == nil { + m.Expiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/ecocredit/types.pb.go b/x/ecocredit/types.pb.go index 78219b6d7d..33252ec1c0 100644 --- a/x/ecocredit/types.pb.go +++ b/x/ecocredit/types.pb.go @@ -537,6 +537,9 @@ type SellOrder struct { // buyer to disable auto-retirement in their buy order enabling them to // resell the credits to another buyer. DisableAutoRetire bool `protobuf:"varint,6,opt,name=disable_auto_retire,json=disableAutoRetire,proto3" json:"disable_auto_retire,omitempty"` + // expiration is an optional timestamp when the sell order expires. When the + // expiration time is reached, the sell order is removed from state. + Expiration *time.Time `protobuf:"bytes,7,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` } func (m *SellOrder) Reset() { *m = SellOrder{} } @@ -614,6 +617,13 @@ func (m *SellOrder) GetDisableAutoRetire() bool { return false } +func (m *SellOrder) GetExpiration() *time.Time { + if m != nil { + return m.Expiration + } + return nil +} + // BuyOrder represents the information for a buy order. type BuyOrder struct { // buy_order_id is the unique ID of buy order. @@ -640,6 +650,9 @@ type BuyOrder struct { // disable_partial_fill disables the default behavior of partially filling // buy orders if the requested quantity is not available. DisablePartialFill bool `protobuf:"varint,7,opt,name=disable_partial_fill,json=disablePartialFill,proto3" json:"disable_partial_fill,omitempty"` + // expiration is the optional timestamp when the buy order expires. When the + // expiration time is reached, the buy order is removed from state. + Expiration *time.Time `protobuf:"bytes,8,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` } func (m *BuyOrder) Reset() { *m = BuyOrder{} } @@ -724,6 +737,13 @@ func (m *BuyOrder) GetDisablePartialFill() bool { return false } +func (m *BuyOrder) GetExpiration() *time.Time { + if m != nil { + return m.Expiration + } + return nil +} + // Selection defines a buy order selection. type BuyOrder_Selection struct { // sum defines the type of selection. @@ -1375,89 +1395,90 @@ func init() { } var fileDescriptor_d49f179dcaefe4e9 = []byte{ - // 1303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x4f, 0x73, 0xdb, 0xb6, - 0x12, 0x17, 0x25, 0x59, 0x12, 0x57, 0x72, 0xfe, 0xe0, 0x79, 0x32, 0x8c, 0xde, 0x8b, 0xa4, 0x28, - 0x9e, 0x79, 0x6e, 0xd2, 0x50, 0xb1, 0xfb, 0x67, 0x32, 0xed, 0xa1, 0x95, 0x9c, 0xa4, 0x76, 0xd3, - 0x49, 0x3c, 0x4c, 0x0e, 0x9d, 0x5e, 0x38, 0x20, 0x09, 0x2b, 0x88, 0x49, 0x42, 0x06, 0x40, 0x27, - 0x3a, 0xf6, 0xd8, 0x5b, 0x3e, 0x45, 0x0f, 0xed, 0xb1, 0x5f, 0x22, 0xc7, 0x1c, 0x3b, 0x3d, 0x34, - 0x6d, 0xf2, 0x3d, 0x3a, 0x1d, 0x02, 0xa0, 0x64, 0xd9, 0x71, 0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, 0x40, 0x08, 0x2a, 0x12, 0x8f, 0x9d, 0x96, 0x09, 0x96, 0x0b, 0xed, 0x21, 0x54, - 0x86, 0x69, 0x84, 0x3e, 0x81, 0xba, 0x26, 0x87, 0x30, 0xd7, 0xec, 0xe9, 0x6c, 0x2a, 0x1c, 0xda, - 0x9f, 0x43, 0xf9, 0x21, 0xff, 0x47, 0x3b, 0x7c, 0x67, 0x81, 0x3d, 0x3b, 0xf3, 0xbf, 0xfb, 0x08, - 0x31, 0xc3, 0x62, 0x74, 0xff, 0xe5, 0x9b, 0x8e, 0xf5, 0xea, 0x4d, 0xc7, 0xfa, 0xed, 0x4d, 0xc7, - 0x7a, 0xf1, 0xb6, 0x53, 0x7a, 0xf5, 0xb6, 0x53, 0xfa, 0xf9, 0x6d, 0xa7, 0xf4, 0xcd, 0xfa, 0xa1, - 0xd7, 0x85, 0xca, 0xf0, 0x66, 0x4a, 0xe4, 0x33, 0xc6, 0xf7, 0x8c, 0x14, 0x93, 0x68, 0x4c, 0xf8, - 0xe0, 0xf9, 0xfc, 0xaf, 0x41, 0x50, 0x53, 0x61, 0x3f, 0xf8, 0x33, 0x00, 0x00, 0xff, 0xff, 0xfe, - 0x24, 0xb6, 0xc6, 0x34, 0x0c, 0x00, 0x00, + // 1325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcd, 0x72, 0x1b, 0x45, + 0x10, 0xd6, 0x4a, 0xb2, 0xac, 0x6d, 0xc9, 0xf9, 0x19, 0x5c, 0xa9, 0x8d, 0x20, 0x92, 0xa2, 0xb8, + 0x0a, 0x93, 0x90, 0x55, 0x6c, 0x7e, 0x2a, 0x05, 0x07, 0x22, 0x39, 0x09, 0x36, 0xa1, 0x12, 0xd7, + 0x26, 0x07, 0x8a, 0xcb, 0xd6, 0xec, 0xee, 0x58, 0x99, 0x78, 0x77, 0x47, 0x9e, 0x99, 0x75, 0xa2, + 0x23, 0x47, 0x6e, 0x79, 0x07, 0xaa, 0x38, 0xc0, 0x91, 0x17, 0xe0, 0x98, 0x63, 0x8e, 0x14, 0x07, + 0x42, 0x25, 0x2f, 0x42, 0xed, 0xcc, 0xac, 0x64, 0xd9, 0x31, 0x36, 0x70, 0xe0, 0xa4, 0xed, 0xaf, + 0xbb, 0xa7, 0xa7, 0x7b, 0xfa, 0x9b, 0x1e, 0xc1, 0x0a, 0x27, 0x23, 0x92, 0xf6, 0x49, 0xc8, 0x42, + 0x4e, 0x22, 0x2a, 0xfb, 0xfb, 0x6b, 0x38, 0x1e, 0x3f, 0xc6, 0xeb, 0x7d, 0x39, 0x19, 0x13, 0xe1, + 0x8e, 0x39, 0x93, 0x0c, 0x39, 0xca, 0xca, 0x9d, 0x5a, 0xb9, 0x85, 0x55, 0xab, 0x1d, 0x32, 0x91, + 0x30, 0xd1, 0x0f, 0xb0, 0x20, 0xfd, 0xfd, 0xb5, 0x80, 0x48, 0xbc, 0xd6, 0x0f, 0x19, 0x4d, 0xb5, + 0x67, 0x6b, 0x79, 0xc4, 0x46, 0x4c, 0x7d, 0xf6, 0xf3, 0x2f, 0x83, 0x76, 0x46, 0x8c, 0x8d, 0x62, + 0xd2, 0x57, 0x52, 0x90, 0xed, 0xf4, 0x25, 0x4d, 0x88, 0x90, 0x38, 0x19, 0x6b, 0x83, 0xde, 0xef, + 0x16, 0xd8, 0x1b, 0x31, 0x16, 0x62, 0x2b, 0xdd, 0x61, 0xe8, 0x22, 0xd4, 0xc3, 0x5c, 0xf0, 0x69, + 0xe4, 0x58, 0x5d, 0x6b, 0xd5, 0xf6, 0x16, 0x95, 0xbc, 0x15, 0xa1, 0x65, 0x58, 0xc0, 0x51, 0x42, + 0x53, 0xa7, 0xac, 0x70, 0x2d, 0x20, 0x07, 0x16, 0xa9, 0x10, 0x19, 0xe1, 0xc2, 0xa9, 0x74, 0x2b, + 0xb9, 0xbd, 0x11, 0x51, 0x0b, 0xea, 0x09, 0x91, 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x55, 0xf7, 0xce, 0x1b, 0xd5, 0x20, 0x93, + 0xcc, 0x53, 0x0a, 0x74, 0x0b, 0x80, 0x3c, 0x1b, 0x53, 0xae, 0x8b, 0x74, 0x5a, 0x6e, 0x1d, 0xf0, + 0xe9, 0xfd, 0x5a, 0x81, 0xfa, 0x30, 0x9b, 0xe8, 0x22, 0x75, 0xa1, 0x19, 0x64, 0x13, 0xff, 0x50, + 0xa1, 0x20, 0x30, 0x7a, 0x5d, 0xab, 0x20, 0x9b, 0xcc, 0x6a, 0xa5, 0x04, 0xf4, 0x15, 0xd8, 0x82, + 0xc4, 0x24, 0x54, 0xbb, 0xa8, 0xa8, 0x5d, 0x7c, 0x78, 0x7c, 0xf3, 0x15, 0xe1, 0xdc, 0x87, 0x85, + 0x8f, 0x37, 0x73, 0x3f, 0xa9, 0xac, 0x01, 0x8d, 0x4e, 0x5d, 0xd6, 0x80, 0x46, 0xff, 0xae, 0xac, + 0x37, 0x60, 0xb9, 0xb0, 0x1f, 0x63, 0x2e, 0x29, 0x8e, 0xfd, 0x1d, 0x1a, 0xc7, 0xaa, 0xc0, 0x75, + 0x0f, 0x19, 0xdd, 0xb6, 0x56, 0xdd, 0xa5, 0x71, 0x7c, 0xe8, 0x20, 0xea, 0xff, 0xfc, 0x20, 0x5a, + 0x37, 0x55, 0xb7, 0x9a, 0x22, 0xac, 0xc0, 0x92, 0x20, 0x71, 0x7c, 0xe8, 0x24, 0x36, 0x4b, 0x5e, + 0x43, 0x14, 0x1d, 0xbd, 0x15, 0x0d, 0x17, 0xa0, 0x22, 0xb2, 0xa4, 0x87, 0xa1, 0x3e, 0x10, 0xbb, + 0xba, 0x29, 0x97, 0x61, 0x41, 0xf7, 0xab, 0x26, 0x8c, 0x16, 0xd0, 0x15, 0x58, 0x8a, 0xa8, 0x18, + 0xc7, 0x78, 0x32, 0x37, 0x0f, 0x9a, 0x06, 0x9c, 0xf6, 0x33, 0x79, 0x36, 0x66, 0x29, 0x49, 0x35, + 0x73, 0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0xe2, 0x31, 0x53, 0x37, 0xda, 0xe2, 0x39, 0x73, 0xa1, 0xb8, + 0x2e, 0x6d, 0xa3, 0x30, 0x17, 0xe6, 0xb5, 0xb7, 0x3c, 0x73, 0xc0, 0x98, 0x1c, 0x79, 0xe8, 0xdc, + 0x03, 0xc8, 0xe7, 0xb9, 0xcf, 0x71, 0x3a, 0x22, 0x4e, 0x43, 0x55, 0xf3, 0xea, 0x89, 0xd5, 0xcc, + 0x27, 0xba, 0x97, 0x7b, 0xe4, 0x19, 0x47, 0x85, 0x80, 0x10, 0x54, 0x24, 0x1e, 0x39, 0x4d, 0x13, + 0x2c, 0x17, 0x5a, 0x03, 0xa8, 0x0c, 0xd2, 0x08, 0x7d, 0x06, 0x8b, 0xba, 0x39, 0x84, 0x19, 0xf5, + 0x27, 0x77, 0x53, 0xe1, 0xd0, 0xba, 0x05, 0xe5, 0x07, 0xfc, 0x3f, 0xad, 0xf0, 0xbd, 0x05, 0xf6, + 0x74, 0xcf, 0xff, 0xef, 0x43, 0xc8, 0x5c, 0x16, 0xc3, 0x7b, 0x2f, 0x5e, 0xb7, 0xad, 0x97, 0xaf, + 0xdb, 0xd6, 0x9f, 0xaf, 0xdb, 0xd6, 0xf3, 0x37, 0xed, 0xd2, 0xcb, 0x37, 0xed, 0xd2, 0x6f, 0x6f, + 0xda, 0xa5, 0x6f, 0xd7, 0x0e, 0xbc, 0x70, 0x54, 0x86, 0xd7, 0x53, 0x22, 0x9f, 0x32, 0xbe, 0x6b, + 0xa4, 0x98, 0x44, 0x23, 0xc2, 0xfb, 0xcf, 0x66, 0x7f, 0x4f, 0x82, 0x9a, 0x0a, 0xfb, 0xd1, 0x5f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x4d, 0xde, 0xd7, 0xb8, 0x0c, 0x00, 0x00, } func (m *ClassInfo) Marshal() (dAtA []byte, err error) { @@ -1840,6 +1861,16 @@ func (m *SellOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Expiration != nil { + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintTypes(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x3a + } if m.DisableAutoRetire { i-- if m.DisableAutoRetire { @@ -1911,6 +1942,16 @@ func (m *BuyOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Expiration != nil { + n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintTypes(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0x42 + } if m.DisablePartialFill { i-- if m.DisablePartialFill { @@ -2458,22 +2499,22 @@ func (m *Filter_DateRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.EndDate != nil { - n11, err11 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.EndDate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.EndDate):]) - if err11 != nil { - return 0, err11 + n13, err13 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.EndDate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.EndDate):]) + if err13 != nil { + return 0, err13 } - i -= n11 - i = encodeVarintTypes(dAtA, i, uint64(n11)) + i -= n13 + i = encodeVarintTypes(dAtA, i, uint64(n13)) i-- dAtA[i] = 0x42 } if m.StartDate != nil { - n12, err12 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.StartDate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.StartDate):]) - if err12 != nil { - return 0, err12 + n14, err14 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.StartDate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.StartDate):]) + if err14 != nil { + return 0, err14 } - i -= n12 - i = encodeVarintTypes(dAtA, i, uint64(n12)) + i -= n14 + i = encodeVarintTypes(dAtA, i, uint64(n14)) i-- dAtA[i] = 0x3a } @@ -2689,6 +2730,10 @@ func (m *SellOrder) Size() (n int) { if m.DisableAutoRetire { n += 2 } + if m.Expiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration) + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -2723,6 +2768,10 @@ func (m *BuyOrder) Size() (n int) { if m.DisablePartialFill { n += 2 } + if m.Expiration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.Expiration) + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -4377,6 +4426,42 @@ func (m *SellOrder) Unmarshal(dAtA []byte) error { } } m.DisableAutoRetire = bool(v != 0) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expiration == nil { + m.Expiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -4625,6 +4710,42 @@ func (m *BuyOrder) Unmarshal(dAtA []byte) error { } } m.DisablePartialFill = bool(v != 0) + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expiration == nil { + m.Expiration = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:])