Skip to content

Commit

Permalink
[CORE-533] - MsgUpdateClobPair, clob pair non nullable (dydxprotocol#194
Browse files Browse the repository at this point in the history
)

* regen protos

* use value for clob pair in MsgUpdateClobPair
  • Loading branch information
jakob-dydx committed Sep 7, 2023
1 parent 8c046a2 commit ea5657e
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export interface MsgCancelOrderResponseSDKType {}
export interface MsgUpdateClobPair {
/** Authority is the address that may send this message. */
authority: string;
/** clob_pair is the ClobPair to write to state. */
/** `clob_pair` is the ClobPair to write to state. */

clobPair?: ClobPair;
}
Expand All @@ -139,7 +139,7 @@ export interface MsgUpdateClobPair {
export interface MsgUpdateClobPairSDKType {
/** Authority is the address that may send this message. */
authority: string;
/** clob_pair is the ClobPair to write to state. */
/** `clob_pair` is the ClobPair to write to state. */

clob_pair?: ClobPairSDKType;
}
Expand Down
4 changes: 2 additions & 2 deletions proto/dydxprotocol/clob/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ message MsgUpdateClobPair {
// Authority is the address that may send this message.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// clob_pair is the ClobPair to write to state.
ClobPair clob_pair = 2;
// `clob_pair` is the ClobPair to write to state.
ClobPair clob_pair = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateClobPairResponse is a response type used for setting a ClobPair's
Expand Down
3 changes: 1 addition & 2 deletions protocol/x/clob/keeper/msg_server_update_clob_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func (k msgServer) UpdateClobPair(
ctx := sdk.UnwrapSDKContext(goCtx)
if err := k.Keeper.UpdateClobPair(
ctx,
// TODO(CORE-533): MsgUpdateClobPair.ClobPair should be non-nullable.
*msg.GetClobPair(),
msg.GetClobPair(),
); err != nil {
return nil, err
}
Expand Down
18 changes: 9 additions & 9 deletions protocol/x/clob/keeper/msg_server_update_clob_pair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Success": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Error: unsupported status transition from active to initializing": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Panic: clob pair not found": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand All @@ -109,7 +109,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Error: invalid authority": {
msg: &types.MsgUpdateClobPair{
Authority: "foobar",
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Error: cannot update metadata with new perpetual id": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Error: cannot update step base quantums": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Error: cannot update subticks per tick": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
"Error: cannot update quantum converstion exponent": {
msg: &types.MsgUpdateClobPair{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ClobPair: &types.ClobPair{
ClobPair: types.ClobPair{
Id: 0,
Metadata: &types.ClobPair_PerpetualClobMetadata{
PerpetualClobMetadata: &types.PerpetualClobMetadata{
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestMsgServerUpdateClobPair(t *testing.T) {
require.NoError(t, err)
clobPair, found := k.GetClobPair(ks.Ctx, types.ClobPairId(tc.msg.ClobPair.Id))
require.True(t, found)
require.Equal(t, clobPair, *tc.msg.ClobPair)
require.Equal(t, clobPair, tc.msg.ClobPair)
}
}
})
Expand Down
16 changes: 8 additions & 8 deletions protocol/x/clob/types/message_update_clob_pair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func TestMsgUpdateClobPair_GetSigners(t *testing.T) {
func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
tests := []struct {
desc string
clobPair *types.ClobPair
clobPair types.ClobPair
expectedErr string
}{
{
desc: "Invalid Metadata (SpotClobMetadata)",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_SpotClobMetadata{},
StepBaseQuantums: 1,
SubticksPerTick: 1,
Expand All @@ -34,7 +34,7 @@ func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
},
{
desc: "UNSPECIFIED Status",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_PerpetualClobMetadata{},
StepBaseQuantums: 1,
SubticksPerTick: 1,
Expand All @@ -44,7 +44,7 @@ func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
},
{
desc: "invalid negative status integer",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_PerpetualClobMetadata{},
StepBaseQuantums: 1,
SubticksPerTick: 1,
Expand All @@ -54,7 +54,7 @@ func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
},
{
desc: "invalid positive status integer",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_PerpetualClobMetadata{},
StepBaseQuantums: 1,
SubticksPerTick: 1,
Expand All @@ -64,7 +64,7 @@ func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
},
{
desc: "StepBaseQuantums <= 0",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_PerpetualClobMetadata{},
StepBaseQuantums: 0,
SubticksPerTick: 1,
Expand All @@ -74,7 +74,7 @@ func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
},
{
desc: "SubticksPerTick <= 0",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_PerpetualClobMetadata{},
StepBaseQuantums: 1,
SubticksPerTick: 0,
Expand All @@ -84,7 +84,7 @@ func TestMsgUpdateClobPair_ValidateBasic(t *testing.T) {
},
{
desc: "Valid ClobPair",
clobPair: &types.ClobPair{
clobPair: types.ClobPair{
Metadata: &types.ClobPair_PerpetualClobMetadata{},
StepBaseQuantums: 1,
SubticksPerTick: 1,
Expand Down
Loading

0 comments on commit ea5657e

Please sign in to comment.