Fix/format price in order confirmation dialog (#102)

This commit is contained in:
Matthew Russell 2022-03-22 11:18:50 -07:00 committed by GitHub
parent ecbcdf57e3
commit 9ced1ce0fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View File

@ -4,7 +4,11 @@ import {
TransactionState,
VegaTxStatus,
} from '../../hooks/use-vega-transaction';
import { OrderEvent_busEvents_event_Order } from '@vegaprotocol/graphql';
import {
OrderEvent_busEvents_event_Order,
OrderStatus,
} from '@vegaprotocol/graphql';
import { formatNumber } from '@vegaprotocol/react-helpers';
interface OrderDialogProps {
transaction: TransactionState;
@ -66,8 +70,17 @@ export const OrderDialog = ({
>
<p>Status: {finalizedOrder.status}</p>
<p>Market: {finalizedOrder.market.name}</p>
<p>Type: {finalizedOrder.type}</p>
<p>Amount: {finalizedOrder.size}</p>
{finalizedOrder.type === 'Limit' && <p>Price: {finalizedOrder.price}</p>}
{finalizedOrder.type === 'Limit' && (
<p>
Price:{' '}
{formatNumber(
finalizedOrder.price,
finalizedOrder.market.decimalPlaces
)}
</p>
)}
</OrderDialogWrapper>
);
};

View File

@ -29,6 +29,7 @@ const ORDER_EVENT_SUB = gql`
price
market {
name
decimalPlaces
}
}
}

View File

@ -19,6 +19,23 @@ export interface OrderEvent_busEvents_event_Order_market {
* Market full name
*/
name: string;
/**
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
* number denominated in the currency of the Market. (uint64)
*
* Examples:
* Currency Balance decimalPlaces Real Balance
* GBP 100 0 GBP 100
* GBP 100 2 GBP 1.00
* GBP 100 4 GBP 0.01
* GBP 1 4 GBP 0.0001 ( 0.01p )
*
* GBX (pence) 100 0 GBP 1.00 (100p )
* GBX (pence) 100 2 GBP 0.01 ( 1p )
* GBX (pence) 100 4 GBP 0.0001 ( 0.01p )
* GBX (pence) 1 4 GBP 0.000001 ( 0.0001p)
*/
decimalPlaces: number;
}
export interface OrderEvent_busEvents_event_Order {