diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx
index 0a71aa021..12bf52ef3 100644
--- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx
+++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx
@@ -45,7 +45,7 @@ export type DealTicketFormFields = OrderSubmissionBody['orderSubmission'] & {
};
export const DealTicket = ({ market, submit }: DealTicketProps) => {
- const { pubKey } = useVegaWallet();
+ const { pubKey, isReadOnly } = useVegaWallet();
const { getPersistedOrder, setPersistedOrder } = usePersistedOrderStore(
(store) => ({
getPersistedOrder: store.getOrder,
@@ -158,7 +158,11 @@ export const DealTicket = ({ market, submit }: DealTicketProps) => {
);
return (
-
@@ -241,9 +246,10 @@ interface SummaryMessageProps {
errorMessage?: string;
market: MarketDealTicket;
order: OrderSubmissionBody['orderSubmission'];
+ isReadOnly: boolean;
}
const SummaryMessage = memo(
- ({ errorMessage, market, order }: SummaryMessageProps) => {
+ ({ errorMessage, market, order, isReadOnly }: SummaryMessageProps) => {
// Specific error UI for if balance is so we can
// render a deposit dialog
const asset = market.tradableInstrument.instrument.product.settlementAsset;
@@ -251,6 +257,17 @@ const SummaryMessage = memo(
market,
order,
});
+ if (isReadOnly) {
+ return (
+
+
+ {
+ 'You need to connect your own wallet to start trading on this market'
+ }
+
+
+ );
+ }
if (errorMessage === SummaryValidationType.NoCollateral) {
return (
void;
}) => {
- const { pubKey } = useVegaWallet();
+ const { pubKey, isReadOnly } = useVegaWallet();
if (!pubKey) {
return {t('Please connect Vega wallet')};
@@ -21,6 +21,7 @@ export const OrderListContainer = ({
partyId={pubKey}
marketId={marketId}
onMarketClick={onMarketClick}
+ isReadOnly={isReadOnly}
/>
);
};
diff --git a/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx b/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx
index 0cd186fbb..0654d0c77 100644
--- a/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx
+++ b/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx
@@ -13,7 +13,7 @@ const generateJsx = () => {
return (
-
+
);
diff --git a/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx b/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx
index 30dd6b19f..bdab8da54 100644
--- a/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx
+++ b/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx
@@ -31,6 +31,7 @@ export interface OrderListManagerProps {
partyId: string;
marketId?: string;
onMarketClick?: (marketId: string) => void;
+ isReadOnly: boolean;
}
export const TransactionComplete = ({
@@ -72,6 +73,7 @@ export const OrderListManager = ({
partyId,
marketId,
onMarketClick,
+ isReadOnly,
}: OrderListManagerProps) => {
const gridRef = useRef(null);
const scrolledToTop = useRef(true);
@@ -146,6 +148,7 @@ export const OrderListManager = ({
}}
setEditOrder={setEditOrder}
onMarketClick={onMarketClick}
+ isReadOnly={isReadOnly}
/>
{
expect(mockCancel).toHaveBeenCalledWith(order);
});
+ it('does not allow cancelling and editing for permitted orders if read only', async () => {
+ const mockEdit = jest.fn();
+ const mockCancel = jest.fn();
+ const order = generateOrder({
+ type: Schema.OrderType.TYPE_LIMIT,
+ timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
+ liquidityProvision: null,
+ peggedOrder: null,
+ });
+ await act(async () => {
+ render(
+ generateJsx({
+ rowData: [order],
+ setEditOrder: mockEdit,
+ cancel: mockCancel,
+ isReadOnly: true,
+ })
+ );
+ });
+ const amendCell = getAmendCell();
+ expect(amendCell.queryAllByRole('button')).toHaveLength(0);
+ });
+
it('shows if an order is a liquidity provision order and does not show order actions', async () => {
const order = generateOrder({
type: Schema.OrderType.TYPE_LIMIT,
diff --git a/libs/orders/src/lib/components/order-list/order-list.stories.tsx b/libs/orders/src/lib/components/order-list/order-list.stories.tsx
index 38545af52..df53dfcce 100644
--- a/libs/orders/src/lib/components/order-list/order-list.stories.tsx
+++ b/libs/orders/src/lib/components/order-list/order-list.stories.tsx
@@ -22,6 +22,7 @@ const Template: Story = (args) => {
setEditOrder={() => {
return;
}}
+ isReadOnly={false}
/>
);
@@ -48,6 +49,7 @@ const Template2: Story = (args) => {
rowData={args.data}
cancel={cancel}
setEditOrder={setEditOrder}
+ isReadOnly={false}
/>