Skip to content

Commit 7af3dff

Browse files
committed
re-gen
1 parent f6eaa10 commit 7af3dff

File tree

2 files changed

+394
-132
lines changed

2 files changed

+394
-132
lines changed

chain/exchange/types/msgs.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -971,22 +971,31 @@ func (msg MsgBatchUpdateOrders) ValidateBasic() error {
971971
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender)
972972
}
973973

974-
subaccountAddress, ok := IsValidSubaccountID(msg.SubaccountId)
975-
if !ok {
976-
return sdkerrors.Wrap(ErrBadSubaccountID, msg.SubaccountId)
977-
}
978-
if !bytes.Equal(subaccountAddress.Bytes(), sender.Bytes()) {
979-
return sdkerrors.Wrap(ErrBadSubaccountID, msg.Sender)
980-
}
974+
hasCancelAllMarketId := len(msg.SpotMarketIdsToCancelAll) > 0 || len(msg.DerivativeMarketIdsToCancelAll) > 0
975+
hasSubaccountIdForCancelAll := msg.SubaccountId != ""
981976

982-
hasDuplicateSpotMarketIds := HasDuplicatesHexHash(msg.SpotMarketIdsToCancelAll)
983-
if hasDuplicateSpotMarketIds {
984-
return sdkerrors.Wrap(ErrInvalidBatchMsgUpdate, "msg contains duplicate cancel all spot market ids")
977+
if hasCancelAllMarketId && !hasSubaccountIdForCancelAll {
978+
return sdkerrors.Wrap(ErrInvalidBatchMsgUpdate, "msg contains cancel all market id but no subaccount id")
985979
}
986980

987-
hasDuplicateDerivativesMarketIds := HasDuplicatesHexHash(msg.DerivativeMarketIdsToCancelAll)
988-
if hasDuplicateDerivativesMarketIds {
989-
return sdkerrors.Wrap(ErrInvalidBatchMsgUpdate, "msg contains duplicate cancel all derivative market ids")
981+
if hasSubaccountIdForCancelAll {
982+
subaccountAddress, ok := IsValidSubaccountID(msg.SubaccountId)
983+
if !ok {
984+
return sdkerrors.Wrap(ErrBadSubaccountID, msg.SubaccountId)
985+
}
986+
if !bytes.Equal(subaccountAddress.Bytes(), sender.Bytes()) {
987+
return sdkerrors.Wrap(ErrBadSubaccountID, msg.Sender)
988+
}
989+
990+
hasDuplicateSpotMarketIds := HasDuplicatesHexHash(msg.SpotMarketIdsToCancelAll)
991+
if hasDuplicateSpotMarketIds {
992+
return sdkerrors.Wrap(ErrInvalidBatchMsgUpdate, "msg contains duplicate cancel all spot market ids")
993+
}
994+
995+
hasDuplicateDerivativesMarketIds := HasDuplicatesHexHash(msg.DerivativeMarketIdsToCancelAll)
996+
if hasDuplicateDerivativesMarketIds {
997+
return sdkerrors.Wrap(ErrInvalidBatchMsgUpdate, "msg contains duplicate cancel all derivative market ids")
998+
}
990999
}
9911000

9921001
hasDuplicateSpotOrderToCancel := HasDuplicatesOrder(msg.SpotOrdersToCancel)

0 commit comments

Comments
 (0)