fix(trading): when order is rejected change tx toast intent (#2851)
This commit is contained in:
parent
536859e067
commit
73de2fed43
@ -50,6 +50,15 @@ const intentMap: { [s in VegaTxStatus]: Intent } = {
|
|||||||
Complete: Intent.Success,
|
Complete: Intent.Success,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getIntent = (tx: VegaStoredTxState) => {
|
||||||
|
// Transaction can be successful
|
||||||
|
// But the order can be rejected by the network
|
||||||
|
if (tx.order?.rejectionReason) {
|
||||||
|
return Intent.Danger;
|
||||||
|
}
|
||||||
|
return intentMap[tx.status];
|
||||||
|
};
|
||||||
|
|
||||||
const isClosePositionTransaction = (tx: VegaStoredTxState) => {
|
const isClosePositionTransaction = (tx: VegaStoredTxState) => {
|
||||||
if (isBatchMarketInstructionsTransaction(tx.body)) {
|
if (isBatchMarketInstructionsTransaction(tx.body)) {
|
||||||
const amendments =
|
const amendments =
|
||||||
@ -461,6 +470,26 @@ const VegaTxCompleteToastsContent = ({ tx }: VegaTxToastContentProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOrderSubmissionTransaction(tx.body) && tx.order?.rejectionReason) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h3 className="font-bold">{t('Order rejected')}</h3>
|
||||||
|
<p>{t('Your order was rejected.')}</p>
|
||||||
|
{tx.txHash && (
|
||||||
|
<p className="break-all">
|
||||||
|
<ExternalLink
|
||||||
|
href={explorerLink(EXPLORER_TX.replace(':hash', tx.txHash))}
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
{t('View in block explorer')}
|
||||||
|
</ExternalLink>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<VegaTransactionDetails tx={tx} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-bold">{t('Confirmed')}</h3>
|
<h3 className="font-bold">{t('Confirmed')}</h3>
|
||||||
@ -545,7 +574,7 @@ export const useVegaTransactionToasts = () => {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: `vega-${tx.id}`,
|
id: `vega-${tx.id}`,
|
||||||
intent: intentMap[tx.status],
|
intent: getIntent(tx),
|
||||||
onClose: () => dismissVegaTransaction(tx.id),
|
onClose: () => dismissVegaTransaction(tx.id),
|
||||||
loader: tx.status === VegaTxStatus.Pending,
|
loader: tx.status === VegaTxStatus.Pending,
|
||||||
content,
|
content,
|
||||||
|
@ -19,7 +19,6 @@ import {
|
|||||||
signedNumberCssClassRules,
|
signedNumberCssClassRules,
|
||||||
DateRangeFilter,
|
DateRangeFilter,
|
||||||
addDecimalsFormatNumber,
|
addDecimalsFormatNumber,
|
||||||
PriceCell,
|
|
||||||
} from '@vegaprotocol/react-helpers';
|
} from '@vegaprotocol/react-helpers';
|
||||||
import { AgGridDynamic as AgGrid, Link } from '@vegaprotocol/ui-toolkit';
|
import { AgGridDynamic as AgGrid, Link } from '@vegaprotocol/ui-toolkit';
|
||||||
import { AgGridColumn } from 'ag-grid-react';
|
import { AgGridColumn } from 'ag-grid-react';
|
||||||
@ -85,7 +84,7 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
|
|||||||
filterParams: { buttons: ['reset'] },
|
filterParams: { buttons: ['reset'] },
|
||||||
tooltipComponent: TooltipCellComponent,
|
tooltipComponent: TooltipCellComponent,
|
||||||
}}
|
}}
|
||||||
components={{ AmountCell, PriceFlashCell, PriceCell, ProgressBarCell }}
|
components={{ AmountCell, PriceFlashCell, ProgressBarCell }}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<AgGridColumn
|
<AgGridColumn
|
||||||
@ -336,7 +335,6 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
|
|||||||
? undefined
|
? undefined
|
||||||
: addDecimalsFormatNumber(data.realisedPNL, data.decimals);
|
: addDecimalsFormatNumber(data.realisedPNL, data.decimals);
|
||||||
}}
|
}}
|
||||||
cellRenderer="PriceCell"
|
|
||||||
headerTooltip={t(
|
headerTooltip={t(
|
||||||
'Profit or loss is realised whenever your position is reduced to zero and the margin is released back to your collateral balance. P&L excludes any fees paid.'
|
'Profit or loss is realised whenever your position is reduced to zero and the margin is released back to your collateral balance. P&L excludes any fees paid.'
|
||||||
)}
|
)}
|
||||||
@ -361,7 +359,6 @@ export const PositionsTable = forwardRef<AgGridReact, Props>(
|
|||||||
? undefined
|
? undefined
|
||||||
: addDecimalsFormatNumber(data.unrealisedPNL, data.decimals)
|
: addDecimalsFormatNumber(data.unrealisedPNL, data.decimals)
|
||||||
}
|
}
|
||||||
cellRenderer="PriceCell"
|
|
||||||
headerTooltip={t(
|
headerTooltip={t(
|
||||||
'Unrealised profit is the current profit on your open position. Margin is still allocated to your position.'
|
'Unrealised profit is the current profit on your open position. Margin is still allocated to your position.'
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user