fix: circ dep by moving proposed markets to app
This commit is contained in:
parent
05b39e2c08
commit
d67c7efb4f
@ -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')}
|
@ -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,13 @@ 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 +29,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 +37,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 +48,10 @@ export const useColumnDefs = () => {
|
||||
primary={value}
|
||||
secondary={
|
||||
<span
|
||||
title={ProposalProductTypeShortName[productType]}
|
||||
title={ProductTypeMapping[productType]}
|
||||
className="uppercase"
|
||||
>
|
||||
{ProposalProductTypeShortName[productType]}
|
||||
{ProductTypeShortName[productType]}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
@ -71,7 +62,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 +70,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 +114,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 = {
|
||||
|
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
@ -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 {
|
||||
|
@ -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}
|
||||
/>
|
||||
);
|
||||
};
|
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user