Compare commits
9 Commits
develop
...
fix/propos
Author | SHA1 | Date | |
---|---|---|---|
|
b363e9561f | ||
|
de42caa2a3 | ||
|
42079206b4 | ||
|
4f5ad8b087 | ||
|
d41b1769d9 | ||
|
3ed6522bf4 | ||
|
d67c7efb4f | ||
|
05b39e2c08 | ||
|
654dd1e7b0 |
@ -0,0 +1 @@
|
||||
export { ProposalsList } from './proposals-list';
|
@ -6,7 +6,7 @@ import {
|
||||
ActionsDropdown,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { DApp, TOKEN_PROPOSAL, useLinks } from '@vegaprotocol/environment';
|
||||
import { useT } from '../use-t';
|
||||
import { useT } from '../../../lib/use-t';
|
||||
|
||||
export const ProposalActionsDropdown = ({ id }: { id: string }) => {
|
||||
const t = useT();
|
||||
@ -18,6 +18,7 @@ export const ProposalActionsDropdown = ({ id }: { id: string }) => {
|
||||
<Link
|
||||
href={linkCreator(TOKEN_PROPOSAL.replace(':id', id))}
|
||||
target="_blank"
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} size={16} />
|
||||
{t('View proposal')}
|
@ -1,75 +1,42 @@
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import merge from 'lodash/merge';
|
||||
import type { MockedResponse } from '@apollo/client/testing';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { ProposalsList } from './proposals-list';
|
||||
import * as Types from '@vegaprotocol/types';
|
||||
import { createProposalListFieldsFragment } from '../../lib/proposals-data-provider/proposals.mock';
|
||||
import type { ProposalsListQuery } from '../../lib';
|
||||
import { ProposalsListDocument } from '../../lib';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import { createMarketFragment } from '@vegaprotocol/mock';
|
||||
import {
|
||||
type MarketsQuery,
|
||||
MarketsDocument,
|
||||
type MarketsQueryVariables,
|
||||
} from '@vegaprotocol/markets';
|
||||
|
||||
const parentMarketName = 'Parent Market Name';
|
||||
const ParentMarketCell = () => <span>{parentMarketName}</span>;
|
||||
|
||||
describe('ProposalsList', () => {
|
||||
const rowContainerSelector = '.ag-center-cols-container';
|
||||
|
||||
const createProposalsMock = (override?: PartialDeep<ProposalsListQuery>) => {
|
||||
const defaultProposalEdges = [
|
||||
{
|
||||
__typename: 'ProposalEdge' as const,
|
||||
node: createProposalListFieldsFragment({
|
||||
id: 'id-1',
|
||||
state: Types.ProposalState.STATE_OPEN,
|
||||
}),
|
||||
},
|
||||
{
|
||||
__typename: 'ProposalEdge' as const,
|
||||
node: createProposalListFieldsFragment({
|
||||
id: 'id-2',
|
||||
state: Types.ProposalState.STATE_PASSED,
|
||||
}),
|
||||
},
|
||||
{
|
||||
__typename: 'ProposalEdge' as const,
|
||||
node: createProposalListFieldsFragment({
|
||||
id: 'id-3',
|
||||
state: Types.ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
||||
}),
|
||||
},
|
||||
];
|
||||
const data = merge(
|
||||
{
|
||||
proposalsConnection: {
|
||||
__typename: 'ProposalsConnection' as const,
|
||||
edges: defaultProposalEdges,
|
||||
},
|
||||
},
|
||||
override
|
||||
);
|
||||
|
||||
const mock: MockedResponse<ProposalsListQuery> = {
|
||||
request: {
|
||||
query: ProposalsListDocument,
|
||||
variables: {
|
||||
proposalType: Types.ProposalType.TYPE_NEW_MARKET,
|
||||
},
|
||||
},
|
||||
result: {
|
||||
data,
|
||||
},
|
||||
};
|
||||
|
||||
return mock;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
const market = createMarketFragment({
|
||||
state: MarketState.STATE_PROPOSED,
|
||||
});
|
||||
|
||||
it('should be properly rendered', async () => {
|
||||
const mock = createProposalsMock();
|
||||
const mock: MockedResponse<MarketsQuery, MarketsQueryVariables> = {
|
||||
request: {
|
||||
query: MarketsDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
marketsConnection: {
|
||||
edges: [
|
||||
{
|
||||
node: market,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
render(
|
||||
<MockedProvider mocks={[mock]}>
|
||||
<ProposalsList cellRenderers={{ ParentMarketCell }} />
|
||||
@ -102,30 +69,25 @@ describe('ProposalsList', () => {
|
||||
|
||||
expect(await container.findAllByRole('row')).toHaveLength(
|
||||
// @ts-ignore data is mocked
|
||||
mock?.result?.data.proposalsConnection.edges.length
|
||||
mock?.result?.data.marketsConnection.edges.length
|
||||
);
|
||||
|
||||
expect(
|
||||
container.getAllByRole('gridcell', {
|
||||
name: (_, element) =>
|
||||
element.getAttribute('col-id') ===
|
||||
'terms.change.successorConfiguration.parentMarketId',
|
||||
element.getAttribute('col-id') === 'parentMarketID',
|
||||
})[0]
|
||||
).toHaveTextContent(parentMarketName);
|
||||
});
|
||||
|
||||
it('empty response should causes no data message display', async () => {
|
||||
const mock: MockedResponse<ProposalsListQuery> = {
|
||||
const mock: MockedResponse<MarketsQuery, MarketsQueryVariables> = {
|
||||
request: {
|
||||
query: ProposalsListDocument,
|
||||
variables: {
|
||||
proposalType: Types.ProposalType.TYPE_NEW_MARKET,
|
||||
},
|
||||
query: MarketsDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
proposalsConnection: {
|
||||
__typename: 'ProposalsConnection',
|
||||
marketsConnection: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
@ -0,0 +1,37 @@
|
||||
import type { FC } from 'react';
|
||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
||||
import { useProposedMarketsList } from '@vegaprotocol/markets';
|
||||
import { type ProposalListFieldsFragment } from '@vegaprotocol/proposals';
|
||||
import { useColumnDefs } from './use-column-defs';
|
||||
import { useT } from '../../../lib/use-t';
|
||||
|
||||
const defaultColDef = {
|
||||
sortable: true,
|
||||
filter: true,
|
||||
resizable: true,
|
||||
filterParams: { buttons: ['reset'] },
|
||||
};
|
||||
|
||||
interface ProposalListProps {
|
||||
cellRenderers: {
|
||||
[name: string]: FC<{ value: string; data: ProposalListFieldsFragment }>;
|
||||
};
|
||||
}
|
||||
|
||||
export const ProposalsList = ({ cellRenderers }: ProposalListProps) => {
|
||||
const t = useT();
|
||||
const { data } = useProposedMarketsList();
|
||||
const columnDefs = useColumnDefs();
|
||||
|
||||
return (
|
||||
<AgGrid
|
||||
columnDefs={columnDefs}
|
||||
rowData={data}
|
||||
defaultColDef={defaultColDef}
|
||||
getRowId={({ data }) => data.id}
|
||||
overlayNoRowsTemplate={t('No proposed markets')}
|
||||
components={cellRenderers}
|
||||
rowHeight={45}
|
||||
/>
|
||||
);
|
||||
};
|
@ -13,12 +13,16 @@ import type {
|
||||
VegaValueFormatterParams,
|
||||
} from '@vegaprotocol/datagrid';
|
||||
import {
|
||||
ProposalProductTypeShortName,
|
||||
ProposalStateMapping,
|
||||
MarketStateMapping,
|
||||
ProductTypeMapping,
|
||||
ProductTypeShortName,
|
||||
} from '@vegaprotocol/types';
|
||||
import type { ProposalListFieldsFragment } from '../../lib/proposals-data-provider/__generated__/Proposals';
|
||||
import { ProposalActionsDropdown } from '../proposal-actions-dropdown';
|
||||
import { useT } from '../../use-t';
|
||||
import { ProposalActionsDropdown } from './proposal-actions-dropdown';
|
||||
import {
|
||||
type MarketFieldsFragment,
|
||||
getProductType,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { useT } from '../../../lib/use-t';
|
||||
|
||||
export const useColumnDefs = () => {
|
||||
const t = useT();
|
||||
@ -28,7 +32,7 @@ export const useColumnDefs = () => {
|
||||
{
|
||||
colId: 'market',
|
||||
headerName: t('Market'),
|
||||
field: 'terms.change.instrument.code',
|
||||
field: 'tradableInstrument.instrument.code',
|
||||
pinned: true,
|
||||
cellStyle: { lineHeight: '14px' },
|
||||
cellRenderer: ({
|
||||
@ -36,20 +40,10 @@ export const useColumnDefs = () => {
|
||||
data,
|
||||
}: {
|
||||
value: string;
|
||||
data: ProposalListFieldsFragment;
|
||||
data: MarketFieldsFragment;
|
||||
}) => {
|
||||
if (!value || !data) return '-';
|
||||
|
||||
const getProductType = (data: ProposalListFieldsFragment) => {
|
||||
if (
|
||||
data.terms.__typename === 'ProposalTerms' &&
|
||||
data.terms.change.__typename === 'NewMarket'
|
||||
) {
|
||||
return data.terms.change.instrument.product?.__typename;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const productType = getProductType(data);
|
||||
return (
|
||||
productType && (
|
||||
@ -57,10 +51,10 @@ export const useColumnDefs = () => {
|
||||
primary={value}
|
||||
secondary={
|
||||
<span
|
||||
title={ProposalProductTypeShortName[productType]}
|
||||
title={ProductTypeMapping[productType]}
|
||||
className="uppercase"
|
||||
>
|
||||
{ProposalProductTypeShortName[productType]}
|
||||
{ProductTypeShortName[productType]}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
@ -71,7 +65,7 @@ export const useColumnDefs = () => {
|
||||
{
|
||||
colId: 'asset',
|
||||
headerName: t('Settlement asset'),
|
||||
field: 'terms.change.instrument.product.settlementAsset.symbol',
|
||||
field: 'tradableInstrument.instrument.product.settlementAsset.symbol',
|
||||
},
|
||||
{
|
||||
colId: 'state',
|
||||
@ -79,39 +73,42 @@ export const useColumnDefs = () => {
|
||||
field: 'state',
|
||||
valueFormatter: ({
|
||||
value,
|
||||
}: VegaValueFormatterParams<ProposalListFieldsFragment, 'state'>) =>
|
||||
value ? ProposalStateMapping[value] : '-',
|
||||
}: VegaValueFormatterParams<MarketFieldsFragment, 'state'>) => {
|
||||
return value ? MarketStateMapping[value] : '-';
|
||||
},
|
||||
filter: SetFilter,
|
||||
filterParams: {
|
||||
set: ProposalStateMapping,
|
||||
set: MarketStateMapping,
|
||||
},
|
||||
},
|
||||
{
|
||||
headerName: t('Parent market'),
|
||||
field: 'terms.change.successorConfiguration.parentMarketId',
|
||||
field: 'parentMarketID',
|
||||
cellRenderer: 'ParentMarketCell',
|
||||
},
|
||||
{
|
||||
colId: 'closing-date',
|
||||
headerName: t('Closing date'),
|
||||
field: 'terms.closingDatetime',
|
||||
field: 'marketTimestamps.pending',
|
||||
valueFormatter: ({
|
||||
value,
|
||||
}: VegaValueFormatterParams<
|
||||
ProposalListFieldsFragment,
|
||||
'terms.closingDatetime'
|
||||
>) => (value ? getDateTimeFormat().format(new Date(value)) : '-'),
|
||||
MarketFieldsFragment,
|
||||
'marketTimestamps.pending'
|
||||
>) => {
|
||||
return value ? getDateTimeFormat().format(new Date(value)) : '-';
|
||||
},
|
||||
filter: DateRangeFilter,
|
||||
},
|
||||
{
|
||||
colId: 'enactment-date',
|
||||
headerName: t('Enactment date'),
|
||||
field: 'terms.enactmentDatetime',
|
||||
field: 'marketTimestamps.open',
|
||||
valueFormatter: ({
|
||||
value,
|
||||
}: VegaValueFormatterParams<
|
||||
ProposalListFieldsFragment,
|
||||
'terms.enactmentDatetime'
|
||||
MarketFieldsFragment,
|
||||
'marketTimestamps.open'
|
||||
>) => (value ? getDateTimeFormat().format(new Date(value)) : '-'),
|
||||
filter: DateRangeFilter,
|
||||
},
|
||||
@ -120,10 +117,10 @@ export const useColumnDefs = () => {
|
||||
...COL_DEFS.actions,
|
||||
cellRenderer: ({
|
||||
data,
|
||||
}: VegaICellRendererParams<ProposalListFieldsFragment>) => {
|
||||
if (!data?.id) return null;
|
||||
}: VegaICellRendererParams<MarketFieldsFragment>) => {
|
||||
if (!data?.marketProposal?.id) return null;
|
||||
|
||||
return <ProposalActionsDropdown id={data.id} />;
|
||||
return <ProposalActionsDropdown id={data.marketProposal.id} />;
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,4 +1,4 @@
|
||||
import { ProposalsList } from '@vegaprotocol/proposals';
|
||||
import { ProposalsList } from './proposals-list';
|
||||
import { ParentMarketCell } from './parent-market-cell';
|
||||
|
||||
const cellRenderers = {
|
||||
|
@ -30,8 +30,6 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => {
|
||||
setStudies,
|
||||
setStudySizes,
|
||||
setOverlays,
|
||||
state,
|
||||
setState,
|
||||
} = useChartSettings();
|
||||
|
||||
const pennantChart = (
|
||||
@ -68,10 +66,6 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => {
|
||||
onIntervalChange={(newInterval) => {
|
||||
setInterval(fromTradingViewResolution(newInterval));
|
||||
}}
|
||||
onAutoSaveNeeded={(data) => {
|
||||
setState(data);
|
||||
}}
|
||||
state={state}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ type StudySizes = { [S in Study]?: number };
|
||||
export type Chartlib = 'pennant' | 'tradingview';
|
||||
|
||||
interface StoredSettings {
|
||||
state: object | undefined; // Don't see a better type provided from TradingView type definitions
|
||||
chartlib: Chartlib;
|
||||
// For interval we use the enum from @vegaprotocol/types, this is to make mapping between different
|
||||
// chart types easier and more consistent
|
||||
@ -30,7 +29,6 @@ const STUDY_ORDER: Study[] = [
|
||||
];
|
||||
|
||||
export const DEFAULT_CHART_SETTINGS = {
|
||||
state: undefined,
|
||||
chartlib: 'pennant' as const,
|
||||
interval: Interval.INTERVAL_I15M,
|
||||
type: ChartType.CANDLE,
|
||||
@ -47,7 +45,6 @@ export const useChartSettingsStore = create<
|
||||
setStudies: (studies?: Study[]) => void;
|
||||
setStudySizes: (sizes: number[]) => void;
|
||||
setChartlib: (lib: Chartlib) => void;
|
||||
setState: (state: object) => void;
|
||||
}
|
||||
>()(
|
||||
persist(
|
||||
@ -95,9 +92,6 @@ export const useChartSettingsStore = create<
|
||||
state.chartlib = lib;
|
||||
});
|
||||
},
|
||||
setState: (state) => {
|
||||
set({ state });
|
||||
},
|
||||
})),
|
||||
{
|
||||
name: 'vega_candles_chart_store',
|
||||
@ -151,7 +145,5 @@ export const useChartSettings = () => {
|
||||
setOverlays: settings.setOverlays,
|
||||
setStudySizes: settings.setStudySizes,
|
||||
setChartlib: settings.setChartlib,
|
||||
state: settings.state,
|
||||
setState: settings.setState,
|
||||
};
|
||||
};
|
||||
|
@ -63,9 +63,9 @@ def test_renders_markets_correctly(proposed_market, page: Page):
|
||||
|
||||
# 6001-MARK-052
|
||||
# 6001-MARK-053
|
||||
expect(row.locator('[col-id="state"]')).to_have_text("Open")
|
||||
expect(row.locator('[col-id="state"]')).to_have_text("Proposed")
|
||||
expect(
|
||||
row.locator('[col-id="terms.change.successorConfiguration.parentMarketId"]')
|
||||
row.locator('[col-id="parentMarketID"]')
|
||||
).to_have_text("-")
|
||||
|
||||
# 6001-MARK-056
|
||||
|
@ -62,3 +62,10 @@ export const DENY_LIST: Record<string, string[]> = {
|
||||
'fdf0ec118d98393a7702cf72e46fc87ad680b152f64b2aac59e093ac2d688fbb',
|
||||
],
|
||||
};
|
||||
|
||||
// We need a record of USDT on mainnet as it needs special handling for
|
||||
// deposits and approvals due to the contract not conforming exactly
|
||||
// to ERC20
|
||||
export const USDT_ID = {
|
||||
MAINNET: 'bf1e88d19db4b3ca0d1d5bdb73718a01686b18cf731ca26adedf3c8b83802bba',
|
||||
} as const;
|
||||
|
@ -13,6 +13,8 @@ export function generateMarket(override?: PartialDeep<Market>): Market {
|
||||
state: Schema.MarketState.STATE_ACTIVE,
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2024-01-02',
|
||||
pending: '2024-01-01',
|
||||
close: '',
|
||||
open: '',
|
||||
},
|
||||
|
@ -1,5 +1,9 @@
|
||||
import type { Asset } from '@vegaprotocol/assets';
|
||||
import { EtherscanLink } from '@vegaprotocol/environment';
|
||||
import { USDT_ID, type Asset } from '@vegaprotocol/assets';
|
||||
import {
|
||||
EtherscanLink,
|
||||
Networks,
|
||||
useEnvironment,
|
||||
} from '@vegaprotocol/environment';
|
||||
import { Intent, Notification } from '@vegaprotocol/ui-toolkit';
|
||||
import {
|
||||
formatNumber,
|
||||
@ -15,7 +19,7 @@ import { useT } from './use-t';
|
||||
interface ApproveNotificationProps {
|
||||
isActive: boolean;
|
||||
selectedAsset?: Asset;
|
||||
onApprove: () => void;
|
||||
onApprove: (amount?: string) => void;
|
||||
approved: boolean;
|
||||
balances: DepositBalances | null;
|
||||
amount: string;
|
||||
@ -33,6 +37,7 @@ export const ApproveNotification = ({
|
||||
approveTxId,
|
||||
intent = Intent.Warning,
|
||||
}: ApproveNotificationProps) => {
|
||||
const { VEGA_ENV } = useEnvironment();
|
||||
const t = useT();
|
||||
const tx = useEthTransactionStore((state) => {
|
||||
return state.transactions.find((t) => t?.id === approveTxId);
|
||||
@ -64,28 +69,45 @@ export const ApproveNotification = ({
|
||||
text: t('Approve {{assetSymbol}}', {
|
||||
assetSymbol: selectedAsset?.symbol,
|
||||
}),
|
||||
action: onApprove,
|
||||
action: () => onApprove(),
|
||||
dataTestId: 'approve-submit',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
let message = t('Approve again to deposit more than {{allowance}}', {
|
||||
allowance: formatNumber(balances.allowance.toString()),
|
||||
});
|
||||
const buttonProps = {
|
||||
size: 'small' as const,
|
||||
text: t('Approve {{assetSymbol}}', {
|
||||
assetSymbol: selectedAsset?.symbol,
|
||||
}),
|
||||
action: () => onApprove(),
|
||||
dataTestId: 'reapprove-submit',
|
||||
};
|
||||
|
||||
if (VEGA_ENV === Networks.MAINNET && selectedAsset.id === USDT_ID[VEGA_ENV]) {
|
||||
message = t(
|
||||
'USDT approved amount cannot be changed, only revoked. Revoke and reapprove to deposit more than {{allowance}}.',
|
||||
{
|
||||
allowance: formatNumber(balances.allowance.toString()),
|
||||
}
|
||||
);
|
||||
buttonProps.text = t('Revoke {{assetSymbol}} approval', {
|
||||
assetSymbol: selectedAsset?.symbol,
|
||||
});
|
||||
buttonProps.action = () => onApprove('0');
|
||||
}
|
||||
|
||||
const reApprovePrompt = (
|
||||
<div className="mb-4">
|
||||
<Notification
|
||||
intent={intent}
|
||||
testId="reapprove-default"
|
||||
message={t('Approve again to deposit more than {{allowance}}', {
|
||||
allowance: formatNumber(balances.allowance.toString()),
|
||||
})}
|
||||
buttonProps={{
|
||||
size: 'small',
|
||||
text: t('Approve {{assetSymbol}}', {
|
||||
assetSymbol: selectedAsset?.symbol,
|
||||
}),
|
||||
action: onApprove,
|
||||
dataTestId: 'reapprove-submit',
|
||||
}}
|
||||
message={message}
|
||||
buttonProps={buttonProps}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -58,7 +58,7 @@ export interface DepositFormProps {
|
||||
onSelectAsset: (assetId: string) => void;
|
||||
handleAmountChange: (amount: string) => void;
|
||||
onDisconnect: () => void;
|
||||
submitApprove: () => void;
|
||||
submitApprove: (amount?: string) => void;
|
||||
approveTxId: number | null;
|
||||
submitFaucet: () => void;
|
||||
faucetTxId: number | null;
|
||||
@ -423,8 +423,8 @@ export const DepositForm = ({
|
||||
isActive={isActive}
|
||||
approveTxId={approveTxId}
|
||||
selectedAsset={selectedAsset}
|
||||
onApprove={() => {
|
||||
submitApprove();
|
||||
onApprove={(amount) => {
|
||||
submitApprove(amount);
|
||||
setApproveNotificationIntent(Intent.Warning);
|
||||
}}
|
||||
balances={balances}
|
||||
|
@ -35,11 +35,11 @@ export const useSubmitApproval = (
|
||||
reset: () => {
|
||||
setId(null);
|
||||
},
|
||||
perform: () => {
|
||||
perform: (amount?: string) => {
|
||||
if (!asset || !config) return;
|
||||
const id = createEthTransaction(contract, 'approve', [
|
||||
config?.collateral_bridge_contract.address,
|
||||
MaxUint256.toString(),
|
||||
amount ? amount : MaxUint256.toString(),
|
||||
]);
|
||||
setId(id);
|
||||
},
|
||||
|
@ -65,6 +65,8 @@ export const generateFill = (override?: PartialDeep<Trade>) => {
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2005-03-31T19:37:00.000Z',
|
||||
pending: '2005-04-01T19:37:00.000Z',
|
||||
open: '2005-04-02T19:37:00.000Z',
|
||||
close: '2005-04-02T19:37:00.000Z',
|
||||
},
|
||||
|
@ -34,6 +34,8 @@ export const generateFundingPayment = (
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2005-03-31T19:37:00.000Z',
|
||||
pending: '2005-04-01T19:37:00.000Z',
|
||||
open: '2005-04-02T19:37:00.000Z',
|
||||
close: '2005-04-02T19:37:00.000Z',
|
||||
},
|
||||
|
@ -4,6 +4,7 @@
|
||||
"Approval failed": "Approval failed",
|
||||
"Approve {{assetSymbol}}": "Approve {{assetSymbol}}",
|
||||
"Approve again to deposit more than {{allowance}}": "Approve again to deposit more than {{allowance}}",
|
||||
"USDT approved amount cannot be changed, only revoked. Revoke and reapprove to deposit more than {{allowance}}.": "USDT approved amount cannot be changed, only revoked. Revoke and reapprove to deposit more than {{allowance}}.",
|
||||
"Asset": "Asset",
|
||||
"Balance available": "Balance available",
|
||||
"Before you can make a deposit of your chosen asset, {{assetSymbol}}, you need to approve its use in your Ethereum wallet": "Before you can make a deposit of your chosen asset, {{assetSymbol}}, you need to approve its use in your Ethereum wallet",
|
||||
@ -23,6 +24,7 @@
|
||||
"Please select": "Please select",
|
||||
"Please select an asset": "Please select an asset",
|
||||
"Remaining deposit allowance": "Remaining deposit allowance",
|
||||
"Revoke {{assetSymbol}} approval": "Revoke {{assetSymbol}} approval",
|
||||
"Select from wallet": "Select from wallet",
|
||||
"The {{symbol}} faucet is not available at this time": "The {{symbol}} faucet is not available at this time",
|
||||
"The deposit cap is set when you approve an asset for use with this app. To increase this cap, approve {{assetSymbol}} again and choose a higher cap. Check the documentation for your Ethereum wallet app for details.": "The deposit cap is set when you approve an asset for use with this app. To increase this cap, approve {{assetSymbol}} again and choose a higher cap. Check the documentation for your Ethereum wallet app for details.",
|
||||
|
@ -5,19 +5,14 @@
|
||||
"blocks": "blocks",
|
||||
"Changes have been proposed for this asset.": "Changes have been proposed for this asset.",
|
||||
"Changes have been proposed for this market.": "Changes have been proposed for this market.",
|
||||
"Closing date": "Closing date",
|
||||
"Confirm transaction in wallet": "Confirm transaction in wallet",
|
||||
"Enactment date": "Enactment date",
|
||||
"Enactment date: {{date}}": "Enactment date: {{date}}",
|
||||
"estimated time to protocol upgrade": "estimated time to protocol upgrade",
|
||||
"estimating...": "estimating...",
|
||||
"Market": "Market",
|
||||
"Network upgrade in {{countdown}}": "Network upgrade in {{countdown}}",
|
||||
"No proposed markets": "No proposed markets",
|
||||
"numberOfBlocks": "<0>{{count}}</0> blocks",
|
||||
"numberOfBlocks_one": "<0>{{count}}</0> block",
|
||||
"numberOfBlocks_other": "<0>{{count}}</0> blocks",
|
||||
"Parent market": "Parent market",
|
||||
"Please open your wallet application and confirm or reject the transaction": "Please open your wallet application and confirm or reject the transaction",
|
||||
"Please wait for your transaction to be confirmed": "Please wait for your transaction to be confirmed",
|
||||
"Proposal declined": "Proposal declined",
|
||||
@ -28,8 +23,6 @@
|
||||
"Proposal submitted": "Proposal submitted",
|
||||
"Proposal waiting for node vote": "Proposal waiting for node vote",
|
||||
"Rejection reason: {{reason}}": "Rejection reason: {{reason}}",
|
||||
"Settlement asset": "Settlement asset",
|
||||
"State": "State",
|
||||
"Submission failed": "Submission failed",
|
||||
"The network is being upgraded to {{vegaReleaseTag}}": "The network is being upgraded to {{vegaReleaseTag}}",
|
||||
"The network will upgrade to {{vegaReleaseTag}} in {{countdown}}": "The network will upgrade to {{vegaReleaseTag}} in {{countdown}}",
|
||||
@ -41,7 +34,6 @@
|
||||
"Update <0>{{key}}</0> to {{value}}": "Update <0>{{key}}</0> to {{value}}",
|
||||
"View details": "View details",
|
||||
"View in block explorer": "View in block explorer",
|
||||
"View proposal": "View proposal",
|
||||
"View proposal details": "View proposal details",
|
||||
"Voting": "Voting",
|
||||
"Your transaction has been confirmed": "Your transaction has been confirmed"
|
||||
|
@ -40,6 +40,7 @@
|
||||
"Close menu": "Close menu",
|
||||
"Closed": "Closed",
|
||||
"Closed markets": "Closed markets",
|
||||
"Closing date": "Closing date",
|
||||
"Code must be 64 characters in length": "Code must be 64 characters in length",
|
||||
"Code must be be valid hex": "Code must be be valid hex",
|
||||
"Collateral": "Collateral",
|
||||
@ -90,6 +91,7 @@
|
||||
"Earned by me": "Earned by me",
|
||||
"Eligible teams": "Eligible teams",
|
||||
"Enactment date reached and usual auction exit checks pass": "Enactment date reached and usual auction exit checks pass",
|
||||
"Enactment date": "Enactment date",
|
||||
"[empty]": "[empty]",
|
||||
"Ends in": "Ends in",
|
||||
"Entity scope": "Entity scope",
|
||||
@ -211,6 +213,7 @@
|
||||
"No orders": "No orders",
|
||||
"No party accepts any liability for any losses whatsoever.": "No party accepts any liability for any losses whatsoever.",
|
||||
"No perpetual markets.": "No perpetual markets.",
|
||||
"No proposed markets": "No proposed markets",
|
||||
"No referral program active": "No referral program active",
|
||||
"No rejected orders": "No rejected orders",
|
||||
"No rewards": "No rewards",
|
||||
@ -238,6 +241,7 @@
|
||||
"PRNT": "PRNT",
|
||||
"Page not found": "Page not found",
|
||||
"Parent of a market": "Parent of a market",
|
||||
"Parent market": "Parent market",
|
||||
"Pennant": "Pennant",
|
||||
"Perpetuals": "Perpetuals",
|
||||
"place_ordinal_one": "{{count}}st",
|
||||
@ -307,6 +311,7 @@
|
||||
"Staking multiplier": "Staking multiplier",
|
||||
"Start trading": "Start trading",
|
||||
"Start trading on the worlds most advanced decentralised exchange.": "Start trading on the worlds most advanced decentralised exchange.",
|
||||
"State": "State",
|
||||
"Status": "Status",
|
||||
"Stop": "Stop",
|
||||
"Stop orders": "Stop orders",
|
||||
@ -387,6 +392,7 @@
|
||||
"View oracle specification": "View oracle specification",
|
||||
"View parent market": "View parent market",
|
||||
"View proposals": "View proposals",
|
||||
"View proposal": "View proposal",
|
||||
"View settlement asset details": "View settlement asset details",
|
||||
"View successor market": "View successor market",
|
||||
"View team": "View team",
|
||||
|
14
libs/markets/src/lib/__generated__/markets.ts
generated
14
libs/markets/src/lib/__generated__/markets.ts
generated
File diff suppressed because one or more lines are too long
@ -152,6 +152,8 @@ query MarketInfo($marketId: ID!) {
|
||||
}
|
||||
}
|
||||
marketTimestamps {
|
||||
proposed
|
||||
pending
|
||||
open
|
||||
close
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -26,6 +26,8 @@ export const marketInfoQuery = (
|
||||
linearSlippageFactor: '0.01',
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-11-13T02:15:24.543614154Z',
|
||||
pending: '2022-11-14T02:15:24.543614154Z',
|
||||
open: '2022-11-15T02:15:24.543614154Z',
|
||||
close: null,
|
||||
},
|
||||
|
@ -13,6 +13,8 @@ const MARKET_A: Partial<Market> = {
|
||||
id: '1',
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-05-11T13:08:27.693537312Z',
|
||||
pending: '2022-05-12T13:08:27.693537312Z',
|
||||
open: '2022-05-18T13:08:27.693537312Z',
|
||||
close: null,
|
||||
},
|
||||
@ -24,6 +26,8 @@ const MARKET_B: Partial<Market> = {
|
||||
id: '2',
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-05-11T13:08:27.693537312Z',
|
||||
pending: '2022-05-12T13:08:27.693537312Z',
|
||||
open: '2022-05-18T13:00:39.328347732Z',
|
||||
close: null,
|
||||
},
|
||||
@ -35,6 +39,8 @@ const MARKET_C: Partial<Market> = {
|
||||
id: '3',
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-05-11T13:08:27.693537312Z',
|
||||
pending: '2022-05-12T13:08:27.693537312Z',
|
||||
open: '2022-05-17T13:00:39.328347732Z',
|
||||
close: null,
|
||||
},
|
||||
@ -46,6 +52,8 @@ const MARKET_D: Partial<Market> = {
|
||||
id: '4',
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-05-11T13:08:27.693537312Z',
|
||||
pending: '2022-05-12T13:08:27.693537312Z',
|
||||
open: '2022-05-16T13:00:39.328347732Z',
|
||||
close: null,
|
||||
},
|
||||
|
@ -123,6 +123,16 @@ export const filterAndSortClosedMarkets = (markets: MarketMaybeWithData[]) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const filterAndSortProposedMarkets = (
|
||||
markets: MarketMaybeWithData[]
|
||||
) => {
|
||||
return markets.filter((m) => {
|
||||
return [MarketState.STATE_PROPOSED].includes(
|
||||
m.data?.marketState || m.state
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export const calcCandleLow = (candles: Candle[]): string | undefined => {
|
||||
return candles
|
||||
?.reduce((acc: BigNumber, c) => {
|
||||
|
@ -27,6 +27,7 @@ import * as Schema from '@vegaprotocol/types';
|
||||
import {
|
||||
filterAndSortClosedMarkets,
|
||||
filterAndSortMarkets,
|
||||
filterAndSortProposedMarkets,
|
||||
} from './market-utils';
|
||||
import type { Candle } from './market-candles-provider';
|
||||
|
||||
@ -114,6 +115,11 @@ export const closedMarketsProvider = makeDerivedDataProvider<Market[], never>(
|
||||
([markets]) => filterAndSortClosedMarkets(markets)
|
||||
);
|
||||
|
||||
export const proposedMarketsProvider = makeDerivedDataProvider<Market[], never>(
|
||||
[marketsProvider],
|
||||
([markets]) => filterAndSortProposedMarkets(markets)
|
||||
);
|
||||
|
||||
export type MarketMaybeWithCandles = Market & { candles?: Candle[] };
|
||||
|
||||
const addCandles = <T extends Market>(
|
||||
@ -241,3 +247,10 @@ export const useMarketList = () => {
|
||||
reload,
|
||||
};
|
||||
};
|
||||
|
||||
export const useProposedMarketsList = () => {
|
||||
return useDataProvider({
|
||||
dataProvider: proposedMarketsProvider,
|
||||
variables: undefined,
|
||||
});
|
||||
};
|
||||
|
@ -36,9 +36,19 @@ fragment MarketFields on Market {
|
||||
}
|
||||
}
|
||||
marketTimestamps {
|
||||
proposed
|
||||
pending
|
||||
open
|
||||
close
|
||||
}
|
||||
marketProposal {
|
||||
... on Proposal {
|
||||
id
|
||||
}
|
||||
... on BatchProposal {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query Markets {
|
||||
|
@ -39,8 +39,10 @@ export const createMarketFragment = (
|
||||
state: Schema.MarketState.STATE_ACTIVE,
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
close: null,
|
||||
proposed: '2022-08-23T11:36:32.252490405Z',
|
||||
pending: '2022-08-24T11:36:32.252490405Z',
|
||||
open: null,
|
||||
close: null,
|
||||
},
|
||||
successorMarketID: null,
|
||||
parentMarketID: null,
|
||||
@ -189,6 +191,9 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
|
||||
tradingMode: Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||
state: Schema.MarketState.STATE_SUSPENDED,
|
||||
marketTimestamps: {
|
||||
proposed: '2022-08-23T11:36:32.252490405Z',
|
||||
pending: '2022-08-24T11:36:32.252490405Z',
|
||||
open: '2022-08-25T11:36:32.252490405Z',
|
||||
close: '2022-08-26T11:36:32.252490405Z',
|
||||
},
|
||||
fees: {
|
||||
@ -219,6 +224,9 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
|
||||
createMarketFragment({
|
||||
id: 'market-3',
|
||||
marketTimestamps: {
|
||||
proposed: '2022-08-23T11:36:32.252490405Z',
|
||||
pending: '2022-08-24T11:36:32.252490405Z',
|
||||
open: '2022-08-25T11:36:32.252490405Z',
|
||||
close: '2022-08-26T11:36:32.252490405Z',
|
||||
},
|
||||
fees: {
|
||||
|
@ -22,8 +22,10 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
close: '',
|
||||
open: '',
|
||||
proposed: '2022-08-23T11:36:32.252490405Z',
|
||||
pending: '2022-08-24T11:36:32.252490405Z',
|
||||
open: null,
|
||||
close: null,
|
||||
},
|
||||
positionDecimalPlaces: 2,
|
||||
state: Schema.MarketState.STATE_ACTIVE,
|
||||
|
@ -32,6 +32,8 @@ export const generateStopOrder = (
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2005-04-02T19:37:00.000Z',
|
||||
pending: '2005-04-03T19:37:00.000Z',
|
||||
close: '',
|
||||
open: '',
|
||||
},
|
||||
|
@ -116,6 +116,8 @@ describe('OrderViewDialog', () => {
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2023-07-17T12:05:25.822854221Z',
|
||||
pending: '2023-07-18T12:05:25.822854221Z',
|
||||
open: '2023-07-19T12:05:25.822854221Z',
|
||||
close: null,
|
||||
},
|
||||
|
@ -1,6 +1,5 @@
|
||||
export * from './asset-proposal-notification';
|
||||
export * from './market-proposal-notification';
|
||||
export * from './proposals-list';
|
||||
export * from './protocol-upgrade-countdown';
|
||||
export * from './protocol-upgrade-in-progress-notification';
|
||||
export * from './protocol-upgrade-proposal-notification';
|
||||
|
@ -1 +0,0 @@
|
||||
export * from './proposals-list';
|
@ -1,56 +0,0 @@
|
||||
import type { FC } from 'react';
|
||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
||||
import * as Types from '@vegaprotocol/types';
|
||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||
import type { ProposalListFieldsFragment } from '../../lib/proposals-data-provider/__generated__/Proposals';
|
||||
import { useProposalsListQuery } from '../../lib/proposals-data-provider/__generated__/Proposals';
|
||||
import { useColumnDefs } from './use-column-defs';
|
||||
import { useT } from '../../use-t';
|
||||
|
||||
export const getNewMarketProposals = (data: ProposalListFieldsFragment[]) =>
|
||||
data.filter((proposal) =>
|
||||
[
|
||||
Types.ProposalState.STATE_OPEN,
|
||||
Types.ProposalState.STATE_PASSED,
|
||||
Types.ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
||||
].includes(proposal.state)
|
||||
);
|
||||
|
||||
const defaultColDef = {
|
||||
sortable: true,
|
||||
filter: true,
|
||||
resizable: true,
|
||||
filterParams: { buttons: ['reset'] },
|
||||
};
|
||||
|
||||
interface ProposalListProps {
|
||||
cellRenderers: {
|
||||
[name: string]: FC<{ value: string; data: ProposalListFieldsFragment }>;
|
||||
};
|
||||
}
|
||||
|
||||
export const ProposalsList = ({ cellRenderers }: ProposalListProps) => {
|
||||
const t = useT();
|
||||
const { data } = useProposalsListQuery({
|
||||
variables: {
|
||||
proposalType: Types.ProposalType.TYPE_NEW_MARKET,
|
||||
},
|
||||
errorPolicy: 'all', // currently there are some proposals failing due to proposals existing without settlement asset ids
|
||||
});
|
||||
const filteredData = getNewMarketProposals(
|
||||
removePaginationWrapper(data?.proposalsConnection?.edges)
|
||||
);
|
||||
const columnDefs = useColumnDefs();
|
||||
|
||||
return (
|
||||
<AgGrid
|
||||
columnDefs={columnDefs}
|
||||
rowData={filteredData}
|
||||
defaultColDef={defaultColDef}
|
||||
getRowId={({ data }) => data.id}
|
||||
overlayNoRowsTemplate={t('No proposed markets')}
|
||||
components={cellRenderers}
|
||||
rowHeight={45}
|
||||
/>
|
||||
);
|
||||
};
|
@ -1,2 +1,3 @@
|
||||
export * from './proposals-data-provider';
|
||||
export * from './__generated__/Proposals';
|
||||
export * from './proposals.mock';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useScript } from '@vegaprotocol/react-helpers';
|
||||
import { Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { useT } from './use-t';
|
||||
import { TradingView, type OnAutoSaveNeededCallback } from './trading-view';
|
||||
import { TradingView } from './trading-view';
|
||||
import { CHARTING_LIBRARY_FILE, type ResolutionString } from './constants';
|
||||
|
||||
export const TradingViewContainer = ({
|
||||
@ -10,16 +10,12 @@ export const TradingViewContainer = ({
|
||||
marketId,
|
||||
interval,
|
||||
onIntervalChange,
|
||||
onAutoSaveNeeded,
|
||||
state,
|
||||
}: {
|
||||
libraryPath: string;
|
||||
libraryHash: string;
|
||||
marketId: string;
|
||||
interval: ResolutionString;
|
||||
onIntervalChange: (interval: string) => void;
|
||||
onAutoSaveNeeded: OnAutoSaveNeededCallback;
|
||||
state: object | undefined;
|
||||
}) => {
|
||||
const t = useT();
|
||||
const scriptState = useScript(
|
||||
@ -49,8 +45,6 @@ export const TradingViewContainer = ({
|
||||
marketId={marketId}
|
||||
interval={interval}
|
||||
onIntervalChange={onIntervalChange}
|
||||
onAutoSaveNeeded={onAutoSaveNeeded}
|
||||
state={state}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -25,15 +25,11 @@ export const TradingView = ({
|
||||
libraryPath,
|
||||
interval,
|
||||
onIntervalChange,
|
||||
onAutoSaveNeeded,
|
||||
state,
|
||||
}: {
|
||||
marketId: string;
|
||||
libraryPath: string;
|
||||
interval: ResolutionString;
|
||||
onIntervalChange: (interval: string) => void;
|
||||
onAutoSaveNeeded: OnAutoSaveNeededCallback;
|
||||
state: object | undefined;
|
||||
}) => {
|
||||
const { isMobile } = useScreenDimensions();
|
||||
const { theme } = useThemeSwitcher();
|
||||
@ -108,7 +104,6 @@ export const TradingView = ({
|
||||
backgroundColor: overrides['paneProperties.background'],
|
||||
},
|
||||
auto_save_delay: 1,
|
||||
saved_data: state,
|
||||
};
|
||||
|
||||
widgetRef.current = new window.TradingView.widget(widgetOptions);
|
||||
@ -117,25 +112,12 @@ export const TradingView = ({
|
||||
if (!widgetRef.current) return;
|
||||
|
||||
const activeChart = widgetRef.current.activeChart();
|
||||
|
||||
if (!state) {
|
||||
// If chart has loaded with no state, create a volume study
|
||||
activeChart.createStudy('Volume');
|
||||
}
|
||||
activeChart.createStudy('Volume');
|
||||
|
||||
// Subscribe to interval changes so it can be persisted in chart settings
|
||||
activeChart.onIntervalChanged().subscribe(null, onIntervalChange);
|
||||
});
|
||||
|
||||
widgetRef.current.subscribe('onAutoSaveNeeded', () => {
|
||||
if (!widgetRef.current) return;
|
||||
|
||||
widgetRef.current.save((newState) => {
|
||||
onAutoSaveNeeded(newState);
|
||||
});
|
||||
});
|
||||
}, [
|
||||
state,
|
||||
datafeed,
|
||||
interval,
|
||||
prevTheme,
|
||||
@ -145,7 +127,6 @@ export const TradingView = ({
|
||||
language,
|
||||
libraryPath,
|
||||
isMobile,
|
||||
onAutoSaveNeeded,
|
||||
onIntervalChange,
|
||||
]);
|
||||
|
||||
|
2
libs/types/src/__generated__/types.ts
generated
2
libs/types/src/__generated__/types.ts
generated
@ -256,6 +256,8 @@ export type AggregatedLedgerEntry = {
|
||||
toAccountPartyId?: Maybe<Scalars['ID']>;
|
||||
/** Account type, if query was grouped by receiver account type - else null */
|
||||
toAccountType?: Maybe<AccountType>;
|
||||
/** Transfer ID associated with this aggregated ledger entry */
|
||||
transferId: Scalars['ID'];
|
||||
/** Type of the transfer for this ledger entry */
|
||||
transferType?: Maybe<TransferType>;
|
||||
/** RFC3339Nano time from at which this ledger entries records were relevant */
|
||||
|
@ -27,6 +27,7 @@ export const useEthTransactionManager = () => {
|
||||
confirmations: 0,
|
||||
notify: true,
|
||||
});
|
||||
|
||||
const {
|
||||
contract,
|
||||
methodName,
|
||||
@ -44,6 +45,7 @@ export const useEthTransactionManager = () => {
|
||||
) {
|
||||
throw new Error('method not found on contract');
|
||||
}
|
||||
|
||||
await contract.contract.callStatic[methodName](...args);
|
||||
} catch (err) {
|
||||
update(transaction.id, {
|
||||
|
@ -216,6 +216,8 @@ describe('WithdrawFormContainer', () => {
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-10-23T18:17:59.149283671Z',
|
||||
pending: '2022-10-24T18:17:59.149283671Z',
|
||||
open: '2022-10-25T18:17:59.149283671Z',
|
||||
close: null,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user