Merge branch 'develop' of github.com:vegaprotocol/frontend-monorepo into feat/oracle-basic-profile

This commit is contained in:
Madalina Raicu
2023-04-28 20:53:13 +03:00
15 changed files with 264 additions and 104 deletions
+18 -46
View File
@@ -9,21 +9,22 @@ context('Home Page', function () {
it('should show connected environment stats', function () {
const statTitles = {
0: 'Status',
1: 'Block height',
2: 'Uptime',
3: 'Total nodes',
4: 'Total staked',
5: 'Backlog',
6: 'Trades / second',
7: 'Orders / block',
8: 'Orders / second',
9: 'Transactions / block',
10: 'Block time',
11: 'Time',
12: 'App',
13: 'Tendermint',
14: 'Up since',
15: 'Chain ID',
1: 'Epoch',
2: 'Block height',
3: 'Uptime',
4: 'Total nodes',
5: 'Total staked',
6: 'Backlog',
7: 'Trades / second',
8: 'Orders / block',
9: 'Orders / second',
10: 'Transactions / block',
11: 'Block time',
12: 'Time',
13: 'App',
14: 'Tendermint',
15: 'Up since',
16: 'Chain ID',
};
cy.get('[data-testid="stats-title"]')
@@ -31,42 +32,13 @@ context('Home Page', function () {
cy.wrap($list).should('contain.text', statTitles[index]);
})
.then(($list) => {
cy.wrap($list).should('have.length', 16);
cy.wrap($list).should('have.length', 17);
});
cy.get(statsValue).eq(0).should('contain.text', 'CONNECTED');
cy.get(statsValue).eq(1).should('not.be.empty');
cy.get(statsValue)
.eq(2)
.invoke('text')
.should('match', /\d+d \d+h \d+m \d+s/i);
cy.get(statsValue).eq(3).should('contain.text', '2');
cy.get(statsValue)
.eq(4)
.invoke('text')
.should('match', /\d+\.\d\d(?!\d)/i);
cy.get(statsValue).eq(5).should('contain.text', '0');
cy.get(statsValue).eq(6).should('contain.text', '0');
cy.get(statsValue).eq(7).should('contain.text', '0');
cy.get(statsValue).eq(8).should('contain.text', '0');
cy.get(statsValue).eq(9).should('not.be.empty');
cy.get(statsValue).eq(10).should('not.be.empty');
cy.get(statsValue).eq(11).should('not.be.empty');
cy.get(statsValue)
.eq(12)
.invoke('text')
.should('match', /v\d+\.\d+\.\d+/i);
cy.get(statsValue)
.eq(13)
.invoke('text')
.should('match', /\d+\.\d+\.\d+/i);
cy.get(statsValue).eq(14).should('not.be.empty');
cy.get(statsValue).eq(15).should('not.be.empty');
});
it('Block height should be updating', function () {
cy.get(statsValue)
.eq(1)
.eq(2)
.invoke('text')
.then((blockHeightTxt) => {
cy.get(statsValue)
@@ -43,7 +43,7 @@ export const AssetLink = ({
if (asDialog) {
open(assetId, e.target as HTMLElement);
} else {
navigate(`${Routes.ASSETS}/${asset?.id}`);
navigate(`/${Routes.ASSETS}/${asset?.id}`);
}
}}
{...props}
@@ -9,7 +9,7 @@ import SizeInMarket from '../size-in-market/size-in-market';
export interface DeterministicOrderDetailsProps {
id: string;
// Version to fetch, with 0 being 'latest' and 1 being 'first'. Defaults to 0
version?: number;
version?: number | null;
}
export const wrapperClasses =
@@ -28,7 +28,7 @@ export const wrapperClasses =
*/
const DeterministicOrderDetails = ({
id,
version = 0,
version = null,
}: DeterministicOrderDetailsProps) => {
const { data, error } = useExplorerDeterministicOrderQuery({
variables: { orderId: id, version },
@@ -71,7 +71,7 @@ export const PartyAccounts = ({ accounts }: PartyAccountsProps) => {
/>
</td>
<td className="text-md">
<AssetLink assetId={account.asset.id} />
<AssetLink assetId={account.asset.id} asDialog={true} />
</td>
</TableRow>
);
@@ -14,7 +14,7 @@ export const AppLayout = ({ children }: AppLayoutProps) => {
const { isReadOnly } = useVegaWallet();
const AppLayoutClasses = classNames(
'app w-full max-w-[1500px] mx-auto grid',
'lg:text-body-large',
'font-alpha lg:text-body-large',
{
'grid-rows-[repeat(2,min-content)_1fr_min-content]': !isReadOnly,
'grid-rows-[repeat(3,min-content)_1fr_min-content]': isReadOnly,
@@ -14,13 +14,17 @@ import { ContractsContext } from './contracts-context';
import { createDefaultProvider } from '../../lib/web3-connectors';
import { useEthereumConfig } from '@vegaprotocol/web3';
import { useEnvironment } from '@vegaprotocol/environment';
import { ENV } from '../../config/env';
import { ENV } from '../../config';
/**
* Provides Vega Ethereum contract instances to its children.
*/
export const ContractsProvider = ({ children }: { children: JSX.Element }) => {
const { provider: activeProvider, account } = useWeb3React();
const {
provider: activeProvider,
account,
chainId: activeChainId,
} = useWeb3React();
const { config } = useEthereumConfig();
const { VEGA_ENV, ETHEREUM_PROVIDER_URL } = useEnvironment();
const [contracts, setContracts] =
@@ -39,7 +43,11 @@ export const ContractsProvider = ({ children }: { children: JSX.Element }) => {
ETHEREUM_PROVIDER_URL,
Number(config.chain_id)
);
const provider = activeProvider ? activeProvider : defaultProvider;
const provider =
activeProvider && activeChainId === Number(config.chain_id)
? activeProvider
: defaultProvider;
if (
account &&
@@ -84,7 +92,14 @@ export const ContractsProvider = ({ children }: { children: JSX.Element }) => {
// TODO: hacky quick fix for release to prevent race condition, find a better fix for this.
cancelled = true;
};
}, [activeProvider, account, config, VEGA_ENV, ETHEREUM_PROVIDER_URL]);
}, [
activeProvider,
activeChainId,
account,
config,
VEGA_ENV,
ETHEREUM_PROVIDER_URL,
]);
if (!contracts) {
return (
+103 -35
View File
@@ -37,8 +37,8 @@
"tranche_start": "2023-04-20T00:00:00.000Z",
"tranche_end": "2023-05-20T00:00:00.000Z",
"total_added": "19242.125",
"total_removed": "494.628795994665",
"locked_amount": "14427.42907711226823345",
"total_removed": "537.22112238579",
"locked_amount": "13786.0174867862645531375",
"deposits": [
{
"amount": "188",
@@ -226,6 +226,11 @@
"amount": "96.6447222258",
"user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756",
"tx": "0x13b160a21d48eab98cc304bbb46cd675da08afbf6e0ad261c67c10ba34dc4d74"
},
{
"amount": "42.592326391125",
"user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756",
"tx": "0x5f544a659ae728cc7b1a29dcda14740425cadf1f47aa74bae92bf2ade3c8093d"
}
],
"users": [
@@ -281,11 +286,17 @@
"user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756",
"tranche_id": 56,
"tx": "0x13b160a21d48eab98cc304bbb46cd675da08afbf6e0ad261c67c10ba34dc4d74"
},
{
"amount": "42.592326391125",
"user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756",
"tranche_id": 56,
"tx": "0x5f544a659ae728cc7b1a29dcda14740425cadf1f47aa74bae92bf2ade3c8093d"
}
],
"total_tokens": "1207.5",
"withdrawn_tokens": "298.738388303775",
"remaining_tokens": "908.761611696225"
"withdrawn_tokens": "341.3307146949",
"remaining_tokens": "866.1692853051"
},
{
"address": "0x33Ce1D9E53AFb7367E34749517C086405a651a95",
@@ -822,7 +833,7 @@
"tranche_end": "2023-05-06T00:00:00.000Z",
"total_added": "8976",
"total_removed": "596.64743517951",
"locked_amount": "2541.2572777777773456",
"locked_amount": "2242.0538148148150032",
"deposits": [
{
"amount": "111",
@@ -1594,7 +1605,7 @@
"tranche_start": "2023-03-06T00:00:00.000Z",
"tranche_end": "2023-04-06T00:00:00.000Z",
"total_added": "14099",
"total_removed": "3112.49002352036",
"total_removed": "3142.49002352036",
"locked_amount": "0",
"deposits": [
{
@@ -2359,6 +2370,11 @@
}
],
"withdrawals": [
{
"amount": "30",
"user": "0xBe9F912Ad481C61B653463E8F1D2b2b310D49861",
"tx": "0x191a1901917ada560c9c30efd3d24c0ec116b9dc131a6966cc67ad7e3701df3b"
},
{
"amount": "30",
"user": "0x8499411Bff99ddE9A02903008F917EEa0E27B42A",
@@ -2593,10 +2609,17 @@
"tx": "0x20d505a766d3d8e376509ed8003a5b9f35fd0524f0979a5a57c7d3714d01d3e5"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "30",
"user": "0xBe9F912Ad481C61B653463E8F1D2b2b310D49861",
"tranche_id": 53,
"tx": "0x191a1901917ada560c9c30efd3d24c0ec116b9dc131a6966cc67ad7e3701df3b"
}
],
"total_tokens": "30",
"withdrawn_tokens": "0",
"remaining_tokens": "30"
"withdrawn_tokens": "30",
"remaining_tokens": "0"
},
{
"address": "0xA9821681fEF27Ed817DF77E476DDDAf0aDac4443",
@@ -4605,7 +4628,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "86666.297",
"total_removed": "0",
"locked_amount": "52591.8412504624188046894",
"locked_amount": "52354.396592703131652297",
"deposits": [
{
"amount": "86666.297",
@@ -4671,7 +4694,7 @@
"tranche_end": "2023-06-01T00:00:00.000Z",
"total_added": "2500",
"total_removed": "0",
"locked_amount": "473.811908577533575",
"locked_amount": "460.07548585673575",
"deposits": [
{
"amount": "2500",
@@ -4792,7 +4815,7 @@
"tranche_end": "2023-09-01T00:00:00.000Z",
"total_added": "17500",
"total_removed": "0",
"locked_amount": "12030.63245395531275",
"locked_amount": "11935.52265750805275",
"deposits": [
{
"amount": "12500",
@@ -5058,8 +5081,8 @@
"tranche_start": "2023-02-01T00:00:00.000Z",
"tranche_end": "2023-08-01T00:00:00.000Z",
"total_added": "37500",
"total_removed": "12704.026146825",
"locked_amount": "19784.56635589318875",
"total_removed": "17678.335539225",
"locked_amount": "19577.381637507675",
"deposits": [
{
"amount": "7500",
@@ -5078,6 +5101,11 @@
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tx": "0x4dc6eefb43f5b1704894582aa926f0c6ecd94550ac354b7d5b5f49b0f17261fd"
},
{
"amount": "4974.3093924",
"user": "0x0B4e6fcE839B01ef43DA6F890FAC7B1Afb004600",
"tx": "0xfce75d8b6bf0d20cbdb1ef29cfabcae4f4504c30b30ca166b4e66d37f7f04339"
},
{
"amount": "126.30064455",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
@@ -5420,6 +5448,12 @@
}
],
"withdrawals": [
{
"amount": "4974.3093924",
"user": "0x0B4e6fcE839B01ef43DA6F890FAC7B1Afb004600",
"tranche_id": 34,
"tx": "0xfce75d8b6bf0d20cbdb1ef29cfabcae4f4504c30b30ca166b4e66d37f7f04339"
},
{
"amount": "6960.3360957",
"user": "0x0B4e6fcE839B01ef43DA6F890FAC7B1Afb004600",
@@ -5434,8 +5468,8 @@
}
],
"total_tokens": "30000",
"withdrawn_tokens": "9235.4492784",
"remaining_tokens": "20764.5507216"
"withdrawn_tokens": "14209.7586708",
"remaining_tokens": "15790.2413292"
}
]
},
@@ -5445,7 +5479,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45",
"total_removed": "0",
"locked_amount": "52543.857812680580054667",
"locked_amount": "52306.629793295059806393",
"deposits": [
{
"amount": "129999.45",
@@ -5478,7 +5512,7 @@
"tranche_end": "2024-04-01T00:00:00.000Z",
"total_added": "54144.7663",
"total_removed": "0",
"locked_amount": "50223.4879614053898767713",
"locked_amount": "50075.54972923179337511559",
"deposits": [
{
"amount": "54144.7663",
@@ -5511,7 +5545,7 @@
"tranche_end": "2023-09-03T00:00:00.000Z",
"total_added": "62600",
"total_removed": "0",
"locked_amount": "22037.516533485537",
"locked_amount": "21866.007699137490576",
"deposits": [
{
"amount": "10000",
@@ -5704,7 +5738,7 @@
"tranche_end": "2023-09-17T00:00:00.000Z",
"total_added": "5000",
"total_removed": "0",
"locked_amount": "1951.96584855403365",
"locked_amount": "1938.26705986808735",
"deposits": [
{
"amount": "5000",
@@ -6245,7 +6279,7 @@
"tranche_end": "2023-05-01T00:00:00.000Z",
"total_added": "22500",
"total_removed": "7280.725809525",
"locked_amount": "434.275725138121845",
"locked_amount": "309.9648941068150575",
"deposits": [
{
"amount": "7500",
@@ -6751,7 +6785,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38",
"total_removed": "1709370.7872515768348",
"locked_amount": "188643.4559650818349440268",
"locked_amount": "183328.522176383808038828",
"deposits": [
{
"amount": "1852091.69",
@@ -12251,7 +12285,7 @@
"tranche_start": "2021-09-03T00:00:00.000Z",
"tranche_end": "2022-09-03T00:00:00.000Z",
"total_added": "57278.000000000000000003",
"total_removed": "48182.21518131551",
"total_removed": "50196.35141572991",
"locked_amount": "0",
"deposits": [
{
@@ -22836,6 +22870,16 @@
}
],
"withdrawals": [
{
"amount": "725",
"user": "0x52Dd36AB8e8eec8f6bE968E93679838dc73b19D3",
"tx": "0xbc67aa993d42656a84c7da90e6abcc0a3c00e7e9e21da4013251b0f8582567ca"
},
{
"amount": "1289.1362344144",
"user": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1",
"tx": "0x9e6077e2dc83701a70b2a04028ab533e89cd7f1bb757ea4fe45e1388cfee600d"
},
{
"amount": "25",
"user": "0x363D3d06d70761c34D6EfEB25E409A9549E6970D",
@@ -32345,10 +32389,17 @@
"tx": "0x1a0e42b837a8f3908bc4e36e9b024f48c371b98f066a0db36fd98793cd178f57"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "725",
"user": "0x52Dd36AB8e8eec8f6bE968E93679838dc73b19D3",
"tranche_id": 11,
"tx": "0xbc67aa993d42656a84c7da90e6abcc0a3c00e7e9e21da4013251b0f8582567ca"
}
],
"total_tokens": "725",
"withdrawn_tokens": "0",
"remaining_tokens": "725"
"withdrawn_tokens": "725",
"remaining_tokens": "0"
},
{
"address": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1",
@@ -33051,6 +33102,12 @@
}
],
"withdrawals": [
{
"amount": "1289.1362344144",
"user": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1",
"tranche_id": 11,
"tx": "0x9e6077e2dc83701a70b2a04028ab533e89cd7f1bb757ea4fe45e1388cfee600d"
},
{
"amount": "842.29689345648",
"user": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1",
@@ -33095,8 +33152,8 @@
}
],
"total_tokens": "3439",
"withdrawn_tokens": "2149.8637655856",
"remaining_tokens": "1289.1362344144"
"withdrawn_tokens": "3439",
"remaining_tokens": "0"
},
{
"address": "0x23E18CBa049393DFebC5a17e3b5ec9aF584CAE04",
@@ -40578,7 +40635,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671",
"total_removed": "715655.108029600523393",
"locked_amount": "314380.63787207732811164918",
"locked_amount": "306213.435102254068923605253",
"deposits": [
{
"amount": "1998.95815",
@@ -41971,7 +42028,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15870102.715470999700000001",
"total_removed": "864782.86597041115934852",
"locked_amount": "6414461.14236901907061884390331141365044606",
"locked_amount": "6385500.76573176443723552685141297101162474",
"deposits": [
{
"amount": "16249.93",
@@ -48527,7 +48584,7 @@
"tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999",
"total_removed": "6130217.967403708954663132",
"locked_amount": "200344.3436236687041787785927410316",
"locked_amount": "173608.308825906440421784938704799",
"deposits": [
{
"amount": "129284.449",
@@ -58559,8 +58616,8 @@
"tranche_start": "2022-06-05T00:00:00.000Z",
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996",
"total_removed": "43935.8732690563416",
"locked_amount": "49815.409147170801381683055403356",
"total_removed": "43997.0543192803416",
"locked_amount": "48521.26918257097251294495027906",
"deposits": [
{
"amount": "3000",
@@ -65204,6 +65261,11 @@
"user": "0x0a6A5e1da768709A2bF17b2E58B2B73120051D03",
"tx": "0x097e43cb4f64f1cb502f321eceb8b91e6378cac0b3b6fe558fc1d543aec597e2"
},
{
"amount": "61.181050224",
"user": "0xe7770271d882C54C46B9f00137e96a3BbfFD4d94",
"tx": "0x3c7d0394e431000fa5c733213116dc39b0f87a9a32a40e75cec3c2fce7795b0b"
},
{
"amount": "168.502276762",
"user": "0x38A292CB98Dc602ECAFF94E8E5fADD9800e4bA13",
@@ -78209,6 +78271,12 @@
}
],
"withdrawals": [
{
"amount": "61.181050224",
"user": "0xe7770271d882C54C46B9f00137e96a3BbfFD4d94",
"tranche_id": 5,
"tx": "0x3c7d0394e431000fa5c733213116dc39b0f87a9a32a40e75cec3c2fce7795b0b"
},
{
"amount": "101.521461192",
"user": "0xe7770271d882C54C46B9f00137e96a3BbfFD4d94",
@@ -78247,8 +78315,8 @@
}
],
"total_tokens": "600",
"withdrawn_tokens": "476.48491248",
"remaining_tokens": "123.51508752"
"withdrawn_tokens": "537.665962704",
"remaining_tokens": "62.334037296"
},
{
"address": "0x79D8ff1699911f065fD97a95a6B47216925C4B0e",
@@ -1,17 +1,23 @@
import { checkSorting } from '@vegaprotocol/cypress';
describe('accounts', { tags: '@smoke' }, () => {
before(() => {
cy.clearAllLocalStorage();
beforeEach(() => {
cy.mockTradingPage();
cy.mockWeb3Provider();
cy.mockSubscription();
cy.setVegaWallet();
cy.visit('/#/markets/market-0');
cy.wait('@Assets');
});
it('renders accounts', () => {
// 7001-COLL-001
// 7001-COLL-002
// 7001-COLL-003
// 7001-COLL-004
// 7001-COLL-005
// 7001-COLL-006
// 7001-COLL-007
const tradingAccountRowId = '[row-id="t-0"]';
cy.getByTestId('Collateral').click();
@@ -22,6 +28,21 @@ describe('accounts', { tags: '@smoke' }, () => {
.find('[col-id="asset.symbol"]')
.should('have.text', 'AST0');
cy.getByTestId('tab-accounts')
.get(tradingAccountRowId)
.find('[col-id="used"]')
.should('have.text', '1.010.00%');
cy.getByTestId('tab-accounts')
.get(tradingAccountRowId)
.find('[col-id="available"]')
.should('have.text', '100,000.00');
cy.getByTestId('tab-accounts')
.get(tradingAccountRowId)
.find('[col-id="total"]')
.should('have.text', '100,001.01');
cy.getByTestId('tab-accounts')
.get(tradingAccountRowId)
.find('[col-id="accounts-actions"]')
@@ -31,12 +52,63 @@ describe('accounts', { tags: '@smoke' }, () => {
.get(tradingAccountRowId)
.find('[col-id="total"]')
.should('have.text', '100,001.01');
cy.getByTestId('tab-accounts')
.get('[col-id="accounts-actions"]')
.find('[data-testid="dropdown-menu"]')
.eq(1)
.click();
cy.getByTestId('deposit').should('be.visible');
cy.getByTestId('withdraw').should('be.visible');
cy.getByTestId('breakdown').should('be.visible');
cy.getByTestId('Collateral').click({ force: true });
});
it('should open asset details dialog when clicked on symbol', () => {
// 7001-COLL-008
cy.getByTestId('asset').contains('tEURO').click();
cy.get('[data-testid="dialog-content"]:visible').should('exist');
cy.get('[data-testid="dialog-close"]:visible').click();
cy.get('[data-testid$="_label"]').should('have.length', 16);
cy.get('[data-testid="dialog-close"]').click();
});
it('should open asset details dialog when clicked on symbol', () => {
// 7001-COLL-008
cy.getByTestId('asset').contains('tEURO').click();
cy.get('[data-testid$="_label"]').should('have.length', 16);
cy.get('[data-testid="dialog-close"]').click();
});
it('should open usage breakdown dialog when clicked on used', () => {
// 7001-COLL-009
cy.getByTestId('breakdown').contains('1.01').click();
const headers = ['Market', 'Account type', 'Balance'];
cy.getByTestId('usage-breakdown').within(($headers) => {
cy.wrap($headers)
.get('.ag-header-cell-text')
.each(($header, i) => {
cy.wrap($header).should('have.text', headers[i]);
});
});
cy.get('[data-testid="dialog-close"]').click();
});
it('sorting usage breakdown columns should work well', () => {
// 7001-COLL-010
cy.getByTestId('breakdown').contains('1.01').click();
cy.getByTestId('usage-breakdown')
.find('[col-id="type"]')
.eq(1)
.should('have.text', 'Margin');
cy.getByTestId('usage-breakdown')
.find('[col-id="type"]')
.eq(2)
.should('have.text', 'Margin');
cy.getByTestId('usage-breakdown')
.find('[col-id="type"]')
.eq(3)
.should('have.text', 'General');
cy.get('[data-testid="dialog-close"]').click();
});
describe('sorting by ag-grid columns should work well', () => {
@@ -88,5 +88,18 @@ describe('deal ticker order validation', { tags: '@smoke' }, () => {
'Size cannot be lower than 1'
);
});
it('must have total margin available', () => {
// 7001-COLL-011
cy.getByTestId('tab-ticket')
.find('.text-xs')
.eq(5)
.within(() => {
cy.get('[data-state="closed"]').should(
'have.text',
'Total margin available'
);
cy.get('.text-neutral-500').should('have.text', '~100,000.01 tDAI');
});
});
});
});
@@ -455,7 +455,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => {
});
});
it('must be warned (pre-submit) if the input price has too many digits after the decimal place for the market', () => {
// 7003-MORD-016
// 7003-MORD-013
updateOrder({
id: orderId,
status: Schema.OrderStatus.STATUS_ACTIVE,
+5 -1
View File
@@ -301,6 +301,7 @@ export const AccountTable = forwardRef<AgGridReact, AccountTableProps>(
<DropdownMenuTrigger
iconName="more"
className="hover:bg-vega-light-200 dark:hover:bg-vega-dark-200 p-0.5 focus:rounded-full hover:rounded-full"
data-testid="dropdown-menu"
></DropdownMenuTrigger>
}
>
@@ -361,7 +362,10 @@ export const AccountTable = forwardRef<AgGridReact, AccountTableProps>(
}
</AgGrid>
<Dialog size="medium" open={openBreakdown} onChange={setOpenBreakdown}>
<div className="h-[35vh] w-full m-auto flex flex-col">
<div
className="h-[35vh] w-full m-auto flex flex-col"
data-testid="usage-breakdown"
>
<h1 className="text-xl mb-4">
{row?.asset?.symbol} {t('usage breakdown')}
</h1>
@@ -1,4 +1,7 @@
query Stats {
epoch {
id
}
nodeData {
stakedTotal
totalNodes
@@ -6,11 +6,14 @@ const defaultOptions = {} as const;
export type StatsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type StatsQuery = { __typename?: 'Query', nodeData?: { __typename?: 'NodeData', stakedTotal: string, totalNodes: number, inactiveNodes: number } | null, statistics: { __typename?: 'Statistics', status: string, blockHeight: string, blockDuration: string, backlogLength: string, txPerBlock: string, tradesPerSecond: string, ordersPerSecond: string, averageOrdersPerBlock: string, vegaTime: any, appVersion: string, chainVersion: string, chainId: string, genesisTime: any } };
export type StatsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, nodeData?: { __typename?: 'NodeData', stakedTotal: string, totalNodes: number, inactiveNodes: number } | null, statistics: { __typename?: 'Statistics', status: string, blockHeight: string, blockDuration: string, backlogLength: string, txPerBlock: string, tradesPerSecond: string, ordersPerSecond: string, averageOrdersPerBlock: string, vegaTime: any, appVersion: string, chainVersion: string, chainId: string, genesisTime: any } };
export const StatsDocument = gql`
query Stats {
epoch {
id
}
nodeData {
stakedTotal
totalNodes
@@ -19,10 +19,14 @@ export const StatsManager = ({ className }: StatsManagerProps) => {
return () => stopPolling();
}, [startPolling, stopPolling]);
const getValue = (field: keyof NodeData | keyof Statistics) =>
['stakedTotal', 'totalNodes', 'inactiveNodes'].includes(field)
? data?.nodeData?.[field as keyof NodeData]
: data?.statistics?.[field as keyof Statistics];
const getValue = (field: keyof NodeData | keyof Statistics | 'epoch') => {
if (['stakedTotal', 'totalNodes', 'inactiveNodes'].includes(field)) {
return data?.nodeData?.[field as keyof NodeData];
} else if (field === 'epoch') {
return data?.epoch.id;
}
return data?.statistics?.[field as keyof Statistics];
};
const panels = fieldsDefinition.map(
({ field, title, description, formatter, goodThreshold }) => ({
@@ -50,7 +54,7 @@ export const StatsManager = ({ className }: StatsManagerProps) => {
className={classNames(
'border rounded p-2 relative border-vega-light-200 dark:border-vega-dark-200',
{
'col-span-2': field === 'chainId' || field === 'status',
'col-span-2': field === 'chainId',
},
{
'bg-transparent border-vega-light-200 dark:border-vega-dark-200':
@@ -20,7 +20,7 @@ export type FieldValue = any;
export type GoodThreshold = (...args: FieldValue[]) => boolean;
export interface Stats {
field: keyof NodeData | keyof Statistics;
field: keyof NodeData | keyof Statistics | 'epoch';
title: string;
goodThreshold?: GoodThreshold;
// eslint-disable-next-line
@@ -161,6 +161,11 @@ const VEGA_TIME: Stats = {
description: t('The time on the blockchain'),
};
const EPOCH: Stats = {
field: 'epoch',
title: 'Epoch',
};
const APP_VERSION: Stats = {
field: 'appVersion',
title: t('App'),
@@ -217,6 +222,7 @@ const CHAIN_ID: Stats = {
export const fieldsDefinition: Stats[] = [
STATUS,
EPOCH,
BLOCK_HEIGHT,
UPTIME,
TOTAL_NODES,