Skip to content

Commit

Permalink
Merge pull request #6692 from vegaprotocol/chore/release-v0.26.19
Browse files Browse the repository at this point in the history
chore(trading,governance,explorer): release v0.26.19
  • Loading branch information
mattrussell36 authored Jul 16, 2024
2 parents 172cc70 + 60b82b7 commit 5fe5077
Show file tree
Hide file tree
Showing 61 changed files with 1,451 additions and 1,513 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { MemoryRouter } from 'react-router-dom';
import { render } from '@testing-library/react';
import PriceInAsset from './price-in-asset';

function renderComponent(price: string, decimals: number, symbol: string) {
return (
<MemoryRouter>
<PriceInAsset price={price} decimals={decimals} symbol={symbol} />
</MemoryRouter>
);
}
describe('Price in Market component', () => {
it('Renders the raw price before there is no market data', () => {
const res = render(renderComponent('100', 8, 'USDT'));
expect(res.getByText('0.000001')).toBeInTheDocument();
});
});
29 changes: 29 additions & 0 deletions apps/explorer/src/app/components/price-in-asset/price-in-asset.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';

export type DecimalSource = 'MARKET' | 'SETTLEMENT_ASSET';

export type PriceInMarketProps = {
price: string;
decimals: number;
symbol: string;
};

/**
* An alternative to PriceInMarket for when you need the price
* with an asset's decimal places.
*/
export const PriceInAsset = ({
price,
decimals,
symbol,
}: PriceInMarketProps) => {
const label = addDecimalsFormatNumber(price, decimals);

return (
<label>
<span>{label}</span> <span>{symbol}</span>
</label>
);
};

export default PriceInAsset;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const PriceInMarket = ({
marketId,
price,
decimalSource = 'MARKET',
assetIcon = true,
}: PriceInMarketProps) => {
const { data } = useExplorerMarketQuery({
variables: { id: marketId },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ type ProposalTermsDialog = {
content: unknown;
};
type ProposalsTableProps = {
data: ProposalListFieldsFragment[] | null;
data: Array<
ProposalListFieldsFragment | BatchproposalListFieldsFragment
> | null;
};
export const ProposalsTable = ({ data }: ProposalsTableProps) => {
const tokenLink = useLinks(DApp.Governance);
Expand Down
8 changes: 7 additions & 1 deletion apps/explorer/src/app/routes/assets/asset-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export const AssetPage = () => {
>
<div className="relative h-full max-w-2xl">
<AssetDetailsTable asset={data as AssetFieldsFragment} />
{assetId && <AssetMarkets asset={assetId} />}
{data && assetId && data.decimals && data.symbol && (
<AssetMarkets
asset={assetId}
decimals={data.decimals}
symbol={data.symbol}
/>
)}
</div>
</AsyncRenderer>
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
query AssetMarkets {
marketsConnection(includeSettled: false) {
marketsConnection(includeSettled: true) {
edges {
node {
id
state
tradableInstrument {
instrument {
name
Expand All @@ -14,6 +15,8 @@ query AssetMarkets {
type
asset {
id
decimals
symbol
}
balance
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AssetMarkets, transformAssetMarketsQuery } from './asset-markets';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import type { AssetMarketsQuery } from './__generated__/Asset-Markets';
import { AccountType } from '@vegaprotocol/types';
import { AccountType, MarketState } from '@vegaprotocol/types';
import { MockAssetMarkets } from '../../../mocks/links';

jest.mock('../../../components/links');
Expand Down Expand Up @@ -34,6 +34,7 @@ describe('transformAssetMarketsQuery', () => {
name: 'instrument1',
},
},
state: MarketState.STATE_ACTIVE,
id: 'market1',
accountsConnection: {
edges: [],
Expand All @@ -59,13 +60,16 @@ describe('transformAssetMarketsQuery', () => {
name: 'instrument1',
},
},
state: MarketState.STATE_ACTIVE,
accountsConnection: {
edges: [
{
node: {
type: AccountType.ACCOUNT_TYPE_INSURANCE,
asset: {
id: 'assetId',
decimals: 8,
symbol: 'ASSET',
},
balance: '100',
},
Expand All @@ -75,6 +79,8 @@ describe('transformAssetMarketsQuery', () => {
type: AccountType.ACCOUNT_TYPE_GLOBAL_INSURANCE,
asset: {
id: 'assetId',
decimals: 8,
symbol: 'ASSET',
},
balance: '200',
},
Expand All @@ -91,13 +97,16 @@ describe('transformAssetMarketsQuery', () => {
name: 'instrument1',
},
},
state: MarketState.STATE_ACTIVE,
accountsConnection: {
edges: [
{
node: {
type: AccountType.ACCOUNT_TYPE_INSURANCE,
asset: {
id: 'assetId',
decimals: 8,
symbol: 'ASSET',
},
balance: '300',
},
Expand All @@ -114,13 +123,16 @@ describe('transformAssetMarketsQuery', () => {
name: 'instrument1',
},
},
state: MarketState.STATE_ACTIVE,
accountsConnection: {
edges: [
{
node: {
type: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
asset: {
id: 'any-other-asset-id',
decimals: 8,
symbol: 'ASSET',
},
balance: '300',
},
Expand All @@ -134,13 +146,15 @@ describe('transformAssetMarketsQuery', () => {
};
const result = transformAssetMarketsQuery(data, 'assetId');
expect(result).toEqual([
{
marketId: 'market1',
balance: '100',
},
{
marketId: 'market2',
balance: '300',
state: MarketState.STATE_ACTIVE,
},
{
marketId: 'market1',
balance: '100',
state: MarketState.STATE_ACTIVE,
},
]);
});
Expand All @@ -151,7 +165,7 @@ describe('AssetMarkets', () => {
render(
<MockedProvider mocks={[MockAssetMarkets]}>
<MemoryRouter>
<AssetMarkets asset="assetId" />
<AssetMarkets asset="assetId" symbol="ASSET" decimals={8} />
</MemoryRouter>
</MockedProvider>
);
Expand All @@ -163,7 +177,7 @@ describe('AssetMarkets', () => {
render(
<MockedProvider mocks={[MockAssetMarkets]}>
<MemoryRouter>
<AssetMarkets asset="assetId" />
<AssetMarkets asset="assetId" symbol="ASSET" decimals={8} />
</MemoryRouter>
</MockedProvider>
);
Expand Down
58 changes: 35 additions & 23 deletions apps/explorer/src/app/routes/assets/components/asset-markets.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { MarketLink } from '../../../components/links';
import { PriceInMarket } from '../../../components/price-in-market/price-in-market';
import PriceInAsset from '../../../components/price-in-asset/price-in-asset';
import { Table, TableCell, TableRow } from '../../../components/table';
import type { AssetMarketsQuery } from './__generated__/Asset-Markets';
import { useAssetMarketsQuery } from './__generated__/Asset-Markets';
import { t } from '@vegaprotocol/i18n';
import { MarketState, MarketStateMapping } from '@vegaprotocol/types';

type AssetMarketProps = {
asset: string;
symbol: string;
decimals: number;
};

/**
Expand All @@ -16,7 +19,7 @@ type AssetMarketProps = {
* @param param0
* @returns
*/
export const AssetMarkets = ({ asset }: AssetMarketProps) => {
export const AssetMarkets = ({ asset, decimals, symbol }: AssetMarketProps) => {
const { data } = useAssetMarketsQuery();

const markets = transformAssetMarketsQuery(data, asset);
Expand All @@ -31,26 +34,30 @@ export const AssetMarkets = ({ asset }: AssetMarketProps) => {
)}
</p>
) : (
<KeyValueTable>
<Table>
{markets.map((market) => {
return (
market.marketId &&
market.balance !== '0' && (
<KeyValueTableRow>
<div>
<TableRow className="py-1 border-b border-neutral-300 dark:border-neutral-700">
<TableCell className="py-1">
<MarketLink id={market.marketId} />
</div>
<div>
<PriceInMarket
marketId={market.marketId}
</TableCell>
<TableCell className="py-1">
{market.state ? MarketStateMapping[market.state] : ''}
</TableCell>
<TableCell align="right" className="py-1">
<PriceInAsset
price={market.balance}
symbol={symbol}
decimals={decimals}
/>
</div>
</KeyValueTableRow>
</TableCell>
</TableRow>
)
);
})}
</KeyValueTable>
</Table>
)}
</div>
);
Expand All @@ -59,6 +66,7 @@ export const AssetMarkets = ({ asset }: AssetMarketProps) => {
export type AssetMarketInsuranceAccount = {
marketId: string;
balance: string;
state: MarketState;
};

/**
Expand Down Expand Up @@ -86,15 +94,19 @@ export function transformAssetMarketsQuery(
: [];

// Now reshape the data to only include the market ID and the balance of the insurance account
return marketsWithAsset.map((market) => {
const accountsWithAsset = market.node?.accountsConnection?.edges?.filter(
(e) =>
e?.node.type === 'ACCOUNT_TYPE_INSURANCE' && e?.node.asset?.id === asset
);
return marketsWithAsset
.map((market) => {
const accountsWithAsset = market.node?.accountsConnection?.edges?.filter(
(e) =>
e?.node.type === 'ACCOUNT_TYPE_INSURANCE' &&
e?.node.asset?.id === asset
);

return {
marketId: market.node?.id || '',
balance: accountsWithAsset?.[0]?.node?.balance || '0',
};
});
return {
marketId: market.node?.id || '',
balance: accountsWithAsset?.[0]?.node?.balance || '0',
state: market.node?.state || null,
};
})
.sort((a, b) => (a.state === MarketState.STATE_ACTIVE ? -1 : 1));
}
4 changes: 2 additions & 2 deletions apps/governance-e2e/src/integration/view/wallet-eth.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ context(
cy.get(vegaInVesting).within(() => {
cy.get(currencyTitle)
.should('be.visible')
.and('have.text', 'VEGAIn vesting contract');
.and('contain.text', 'VEGAIn vesting contract');
});
});

Expand Down Expand Up @@ -214,7 +214,7 @@ context(
cy.get(vegaInWallet).within(() => {
cy.get(currencyTitle)
.should('be.visible')
.and('have.text', 'VEGAIn Wallet');
.and('contain.text', 'VEGAIn Wallet');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ query Delegations($partyId: ID!, $delegationsPagination: Pagination) {
__typename
... on ERC20 {
contractAddress
chainId
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5fe5077

Please sign in to comment.