Skip to content

Commit

Permalink
refactor(tradeshield): add v1 to legacy types
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Jan 17, 2025
1 parent a982a31 commit 66153b0
Show file tree
Hide file tree
Showing 17 changed files with 1,021 additions and 1,022 deletions.
446 changes: 223 additions & 223 deletions api/elys/tradeshield/order.pulsar.go

Large diffs are not rendered by default.

738 changes: 369 additions & 369 deletions api/elys/tradeshield/tx.pulsar.go

Large diffs are not rendered by default.

330 changes: 165 additions & 165 deletions api/elys/tradeshield/types.pulsar.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions proto/elys/tradeshield/order.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "cosmos_proto/cosmos.proto";

option go_package = "github.com/elys-network/elys/x/tradeshield/types";

message LegacyOrderPrice {
message LegacyOrderPriceV1 {
string base_denom = 1;
string quote_denom = 2;
string rate = 3 [
Expand All @@ -26,7 +26,7 @@ enum SpotOrderType {
MARKETBUY = 3;
}

message LegacyTriggerPrice {
message LegacyTriggerPriceV1 {
string trading_asset_denom = 1;
string rate = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
Expand Down
10 changes: 5 additions & 5 deletions proto/elys/tradeshield/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ message MsgCreateSpotOrder {
option (cosmos.msg.v1.signer) = "owner_address";
option (amino.name) = "tradeshield/MsgCreateSpotOrder";
SpotOrderType order_type = 1;
LegacyOrderPrice legacy_order_price_v1 = 2 [ (gogoproto.nullable) = false ];
LegacyOrderPriceV1 legacy_order_price_v1 = 2 [ (gogoproto.nullable) = false ];
string order_price = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
Expand All @@ -56,7 +56,7 @@ message MsgUpdateSpotOrder {
option (amino.name) = "tradeshield/MsgUpdateSpotOrder";
string owner_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
uint64 order_id = 2;
LegacyOrderPrice legacy_order_price_v1 = 3 [ (gogoproto.nullable) = false ];
LegacyOrderPriceV1 legacy_order_price_v1 = 3 [ (gogoproto.nullable) = false ];
string order_price = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
Expand Down Expand Up @@ -88,7 +88,7 @@ message MsgCreatePerpetualOpenOrder {
option (cosmos.msg.v1.signer) = "owner_address";
option (amino.name) = "tradeshield/MsgCreatePerpetualOpenOrder";
string owner_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
LegacyTriggerPrice legacy_trigger_price_v1 = 2
LegacyTriggerPriceV1 legacy_trigger_price_v1 = 2
[ (gogoproto.nullable) = false ];
string trigger_price = 10 [
(cosmos_proto.scalar) = "cosmos.Dec",
Expand Down Expand Up @@ -122,7 +122,7 @@ message MsgCreatePerpetualCloseOrder {
option (cosmos.msg.v1.signer) = "owner_address";
option (amino.name) = "tradeshield/CreatePerpetualCloseOrder";
string owner_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
LegacyTriggerPrice legacy_trigger_price_v1 = 2
LegacyTriggerPriceV1 legacy_trigger_price_v1 = 2
[ (gogoproto.nullable) = false ];
string trigger_price = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
Expand All @@ -139,7 +139,7 @@ message MsgUpdatePerpetualOrder {
option (amino.name) = "tradeshield/MsgUpdatePerpetualOrder";
string owner_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
uint64 order_id = 2;
LegacyTriggerPrice legacy_trigger_price_v1 = 3
LegacyTriggerPriceV1 legacy_trigger_price_v1 = 3
[ (gogoproto.nullable) = false ];
string trigger_price = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
Expand Down
4 changes: 2 additions & 2 deletions proto/elys/tradeshield/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ message Date {
message SpotOrder {
SpotOrderType order_type = 1;
uint64 order_id = 2;
LegacyOrderPrice legacy_order_price_v1 = 3 [ (gogoproto.nullable) = false ];
LegacyOrderPriceV1 legacy_order_price_v1 = 3 [ (gogoproto.nullable) = false ];
string order_price = 9 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
Expand All @@ -50,7 +50,7 @@ message PerpetualOrder {
string owner_address = 2;
PerpetualOrderType perpetual_order_type = 3;
PerpetualPosition position = 4;
LegacyTriggerPrice legacy_trigger_price_v1 = 5
LegacyTriggerPriceV1 legacy_trigger_price_v1 = 5
[ (gogoproto.nullable) = false ];
string trigger_price = 14 [
(cosmos_proto.scalar) = "cosmos.Dec",
Expand Down
2 changes: 1 addition & 1 deletion x/tradeshield/keeper/pending_perpetual_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (k Keeper) SetAllLegacyPerpetualTriggerPriceToNewTriggerPriceStructure(ctx
var order types.PerpetualOrder
k.cdc.MustUnmarshal(iterator.Value(), &order)
order.TriggerPrice = order.LegacyTriggerPriceV1.Rate
order.LegacyTriggerPriceV1 = types.LegacyTriggerPrice{}
order.LegacyTriggerPriceV1 = types.LegacyTriggerPriceV1{}
store.Set(iterator.Key(), k.cdc.MustMarshal(&order))

Check warning on line 164 in x/tradeshield/keeper/pending_perpetual_order.go

View check run for this annotation

Codecov / codecov/patch

x/tradeshield/keeper/pending_perpetual_order.go#L160-L164

Added lines #L160 - L164 were not covered by tests
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/tradeshield/keeper/pending_perpetual_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (suite *TradeshieldKeeperTestSuite) createNPendingPerpetualOrder(n int) []t
OwnerAddress: fmt.Sprintf("address%d", i),
PerpetualOrderType: types.PerpetualOrderType_LIMITCLOSE,
Position: types.PerpetualPosition_LONG,
LegacyTriggerPriceV1: types.LegacyTriggerPrice{
LegacyTriggerPriceV1: types.LegacyTriggerPriceV1{
Rate: math.LegacyNewDec(1),
},
TriggerPrice: math.LegacyNewDec(1),
Expand Down
2 changes: 1 addition & 1 deletion x/tradeshield/keeper/pending_spot_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (k Keeper) SetAllLegacySpotOrderPriceToNewOrderPriceStructure(ctx sdk.Conte
var order types.SpotOrder
k.cdc.MustUnmarshal(iterator.Value(), &order)
order.OrderPrice = order.LegacyOrderPriceV1.Rate
order.LegacyOrderPriceV1 = types.LegacyOrderPrice{}
order.LegacyOrderPriceV1 = types.LegacyOrderPriceV1{}
store.Set(iterator.Key(), k.cdc.MustMarshal(&order))
}

Check warning on line 198 in x/tradeshield/keeper/pending_spot_order.go

View check run for this annotation

Codecov / codecov/patch

x/tradeshield/keeper/pending_spot_order.go#L186-L198

Added lines #L186 - L198 were not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion x/tradeshield/keeper/pending_spot_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingSpotOrderGet() {
for _, item := range items {
got, found := suite.app.TradeshieldKeeper.GetPendingSpotOrder(suite.ctx, item.OrderId)
item.OrderPrice = math.LegacyZeroDec()
item.LegacyOrderPriceV1 = types.LegacyOrderPrice{
item.LegacyOrderPriceV1 = types.LegacyOrderPriceV1{
Rate: math.LegacyZeroDec(),
}
suite.Require().True(found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingPerpetualOrderForAddress() {
OwnerAddress: ownerAddress,
PerpetualOrderType: types.PerpetualOrderType_LIMITCLOSE,
Position: types.PerpetualPosition_LONG,
LegacyTriggerPriceV1: types.LegacyTriggerPrice{
LegacyTriggerPriceV1: types.LegacyTriggerPriceV1{
Rate: math.LegacyZeroDec(),
},
TriggerPrice: math.LegacyNewDec(1),
Expand All @@ -61,7 +61,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingPerpetualOrderForAddress() {
PerpetualOrderType: types.PerpetualOrderType_LIMITCLOSE,
Position: types.PerpetualPosition_LONG,
TriggerPrice: math.LegacyNewDec(2),
LegacyTriggerPriceV1: types.LegacyTriggerPrice{
LegacyTriggerPriceV1: types.LegacyTriggerPriceV1{
Rate: math.LegacyZeroDec(),
},
Collateral: sdk.Coin{Denom: "uatom", Amount: math.NewInt(10)},
Expand Down
4 changes: 2 additions & 2 deletions x/tradeshield/keeper/query_pending_perpetual_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingPerpetualtOrder() {
OwnerAddress: "valid_address",
OrderId: 1,
PerpetualOrderType: types.PerpetualOrderType_LIMITOPEN,
LegacyTriggerPriceV1: types.LegacyTriggerPrice{
LegacyTriggerPriceV1: types.LegacyTriggerPriceV1{
Rate: math.LegacyNewDec(1),
},
TriggerPrice: math.LegacyMustNewDecFromStr("10"),
Expand Down Expand Up @@ -78,7 +78,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingPerpetualOrderAll() {
OwnerAddress: "valid_address",
OrderId: 1,
PerpetualOrderType: types.PerpetualOrderType_LIMITOPEN,
LegacyTriggerPriceV1: types.LegacyTriggerPrice{
LegacyTriggerPriceV1: types.LegacyTriggerPriceV1{
Rate: math.LegacyZeroDec(),
},
TriggerPrice: math.LegacyMustNewDecFromStr("10"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingSpotOrderForAddress() {
OrderId: 1,
OwnerAddress: "valid_address",
OrderType: types.SpotOrderType_LIMITBUY,
LegacyOrderPriceV1: types.LegacyOrderPrice{
LegacyOrderPriceV1: types.LegacyOrderPriceV1{
Rate: math.LegacyNewDec(1),
},
OrderPrice: math.LegacyNewDec(1),
Expand All @@ -27,7 +27,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingSpotOrderForAddress() {
OrderId: 2,
OwnerAddress: "valid_address",
OrderType: types.SpotOrderType_LIMITBUY,
LegacyOrderPriceV1: types.LegacyOrderPrice{
LegacyOrderPriceV1: types.LegacyOrderPriceV1{
Rate: math.LegacyNewDec(1),
},
OrderPrice: math.LegacyNewDec(1),
Expand Down
4 changes: 2 additions & 2 deletions x/tradeshield/keeper/query_pending_spot_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingSpotOrder() {
OrderId: 1,
OwnerAddress: "valid_address",
OrderType: types.SpotOrderType_LIMITBUY,
LegacyOrderPriceV1: types.LegacyOrderPrice{
LegacyOrderPriceV1: types.LegacyOrderPriceV1{
Rate: math.LegacyNewDec(1),
},
OrderPrice: math.LegacyNewDec(1),
Expand Down Expand Up @@ -69,7 +69,7 @@ func (suite *TradeshieldKeeperTestSuite) TestPendingSpotOrderAll() {
OrderId: 1,
OwnerAddress: "valid_address",
OrderType: types.SpotOrderType_LIMITBUY,
LegacyOrderPriceV1: types.LegacyOrderPrice{
LegacyOrderPriceV1: types.LegacyOrderPriceV1{
Rate: math.LegacyNewDec(1),
},
OrderPrice: math.LegacyNewDec(1),
Expand Down
Loading

0 comments on commit 66153b0

Please sign in to comment.