Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4466b62ae8 | ||
|
|
50959b4c50 | ||
|
|
a8c2f4e025 | ||
|
|
2cea73c567 | ||
|
|
b0a54be408 | ||
|
|
d1a036e53c |
@@ -1,6 +1,6 @@
|
||||
# Related issues 🔗
|
||||
|
||||
Closes #[Issue number here]
|
||||
Issue: #[Issue number here]
|
||||
|
||||
# Description ℹ️
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ on:
|
||||
- types
|
||||
- utils
|
||||
- i18n
|
||||
- wallet
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import SizeInMarket from '../../../size-in-market/size-in-market';
|
||||
|
||||
export interface TxDetailsOrderIcebergDetailsProps {
|
||||
iceberg: components['schemas']['v1IcebergOpts'];
|
||||
size: components['schemas']['v1OrderSubmission']['size'];
|
||||
marketId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,7 @@ export interface TxDetailsOrderIcebergDetailsProps {
|
||||
export const TxOrderIcebergDetails = ({
|
||||
iceberg,
|
||||
size,
|
||||
marketId,
|
||||
}: TxDetailsOrderIcebergDetailsProps) => {
|
||||
return (
|
||||
<div
|
||||
@@ -36,15 +39,28 @@ export const TxOrderIcebergDetails = ({
|
||||
>
|
||||
<Tooltip description={t('Iceberg: Minimum visible size')}>
|
||||
<span className="align-bottom text-vega-orange-650">
|
||||
{iceberg.minimumVisibleSize || '-'}
|
||||
{marketId ? (
|
||||
<SizeInMarket
|
||||
size={iceberg.minimumVisibleSize}
|
||||
marketId={marketId}
|
||||
/>
|
||||
) : (
|
||||
iceberg.minimumVisibleSize
|
||||
)}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip description={t('Iceberg: Total size')}>
|
||||
<span className="text-sm text-vega-blue-600 mx-3">{size}</span>
|
||||
<span className="text-sm text-vega-blue-600 mx-3">
|
||||
{marketId ? <SizeInMarket size={size} marketId={marketId} /> : size}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip description={t('Iceberg: Visible peak')}>
|
||||
<span className="align-top text-vega-yellow-600">
|
||||
{iceberg.peakSize || '-'}
|
||||
{marketId ? (
|
||||
<SizeInMarket size={iceberg.peakSize} marketId={marketId} />
|
||||
) : (
|
||||
iceberg.peakSize
|
||||
)}
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
@@ -81,7 +81,11 @@ export const TxDetailsOrder = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Iceberg details')}</TableCell>
|
||||
<TableCell>
|
||||
<TxOrderIcebergDetails iceberg={iceberg} size={size} />
|
||||
<TxOrderIcebergDetails
|
||||
iceberg={iceberg}
|
||||
size={size}
|
||||
marketId={marketId}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : null}
|
||||
|
||||
@@ -20,6 +20,10 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
|
||||
#Test configuration variables
|
||||
CYPRESS_FAIRGROUND=false
|
||||
CYPRESS_VEGA_URL=http://localhost:3008/graphql
|
||||
|
||||
@@ -22,6 +22,8 @@ NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
||||
NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.rocks
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
#Test configuration variables
|
||||
CYPRESS_FAIRGROUND=false
|
||||
@@ -29,4 +31,4 @@ LC_ALL="en_US.UTF-8"
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
|
||||
@@ -20,7 +20,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
NX_TENDERMINT_URL=http://localhost:26617
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket
|
||||
@@ -30,4 +30,4 @@ CYPRESS_FAIRGROUND=false
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=false
|
||||
NX_METAMASK_SNAPS=false
|
||||
NX_METAMASK_SNAPS=false
|
||||
|
||||
@@ -15,11 +15,11 @@ NX_VEGA_REST_URL=https://api.n00.devnet1.vega.xyz/api/v2/
|
||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.be.devnet1.vega.xyz/
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.devnet1.vega.xyz/websocket
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
|
||||
@@ -15,7 +15,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-k8s.ops.vega.xyz
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||
NX_VEGA_REST_URL=https://api.vega.community/api/v2/
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet
|
||||
|
||||
NX_TENDERMINT_URL=https://be.vega.community
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket
|
||||
|
||||
@@ -14,7 +14,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-mirror-k8s.ops.vega.xyz
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||
NX_VEGA_REST_URL=https://api.mainnet-mirror.vega.rocks/api/v2/
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet
|
||||
|
||||
NX_TENDERMINT_URL=https://be.mainnet-mirror.vega.rocks
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.mainnet-mirror.vega.rocks/websocket
|
||||
|
||||
@@ -11,7 +11,7 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou
|
||||
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.rocks
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
||||
|
||||
@@ -16,7 +16,7 @@ NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/
|
||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
||||
|
||||
@@ -13,7 +13,7 @@ NX_VEGA_REST_URL=https://api-validators-testnet.vega.rocks/api/v2/
|
||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.be.validators-testnet.vega.rocks
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega.
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
AppFailure,
|
||||
NodeSwitcherDialog,
|
||||
useNodeSwitcherStore,
|
||||
DocsLinks,
|
||||
} from '@vegaprotocol/environment';
|
||||
import { ENV } from './config';
|
||||
import type { InMemoryCacheConfig } from '@apollo/client';
|
||||
@@ -109,8 +110,17 @@ const Web3Container = ({
|
||||
store.connectors,
|
||||
store.initialize,
|
||||
]);
|
||||
const { ETHEREUM_PROVIDER_URL, ETH_LOCAL_PROVIDER_URL, ETH_WALLET_MNEMONIC } =
|
||||
useEnvironment();
|
||||
const {
|
||||
ETHEREUM_PROVIDER_URL,
|
||||
ETH_LOCAL_PROVIDER_URL,
|
||||
ETH_WALLET_MNEMONIC,
|
||||
VEGA_ENV,
|
||||
VEGA_URL,
|
||||
VEGA_EXPLORER_URL,
|
||||
CHROME_EXTENSION_URL,
|
||||
MOZILLA_EXTENSION_URL,
|
||||
VEGA_WALLET_URL,
|
||||
} = useEnvironment();
|
||||
useEffect(() => {
|
||||
if (chainId) {
|
||||
return initializeConnectors(
|
||||
@@ -139,10 +149,33 @@ const Web3Container = ({
|
||||
return <SplashLoader />;
|
||||
}
|
||||
|
||||
if (
|
||||
!VEGA_URL ||
|
||||
!VEGA_WALLET_URL ||
|
||||
!VEGA_EXPLORER_URL ||
|
||||
!DocsLinks ||
|
||||
!CHROME_EXTENSION_URL ||
|
||||
!MOZILLA_EXTENSION_URL
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Web3Provider connectors={connectors}>
|
||||
<Web3Connector connectors={connectors} chainId={Number(chainId)}>
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletProvider
|
||||
config={{
|
||||
network: VEGA_ENV,
|
||||
vegaUrl: VEGA_URL,
|
||||
vegaWalletServiceUrl: VEGA_WALLET_URL,
|
||||
links: {
|
||||
explorer: VEGA_EXPLORER_URL,
|
||||
concepts: DocsLinks?.VEGA_WALLET_CONCEPTS_URL,
|
||||
chromeExtensionUrl: CHROME_EXTENSION_URL,
|
||||
mozillaExtensionUrl: MOZILLA_EXTENSION_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<ContractsProvider>
|
||||
<AppLoader>
|
||||
<BalanceManager>
|
||||
@@ -275,7 +308,7 @@ const AppContainer = () => {
|
||||
<Router>
|
||||
<ScrollToTop />
|
||||
<AppStateProvider>
|
||||
<div className="grid min-h-full text-white">
|
||||
<div className="min-h-full text-white grid">
|
||||
<NodeGuard
|
||||
skeleton={<div>{t('Loading')}</div>}
|
||||
failure={
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ENV } from '@vegaprotocol/environment';
|
||||
import { FLAGS } from '@vegaprotocol/environment';
|
||||
import {
|
||||
JsonRpcConnector,
|
||||
ViewConnector,
|
||||
@@ -13,10 +13,9 @@ export const jsonRpc = new JsonRpcConnector();
|
||||
export const injected = new InjectedConnector();
|
||||
export const view = new ViewConnector(urlParams.get('address'));
|
||||
|
||||
export const snap = new SnapConnector(
|
||||
ENV.VEGA_URL ? new URL(ENV.VEGA_URL).origin : undefined,
|
||||
DEFAULT_SNAP_ID
|
||||
);
|
||||
export const snap = FLAGS.METAMASK_SNAPS
|
||||
? new SnapConnector(DEFAULT_SNAP_ID)
|
||||
: undefined;
|
||||
|
||||
export const Connectors = {
|
||||
injected,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
||||
import type { VegaWalletConfig } from '@vegaprotocol/wallet';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
||||
import { Proposal } from './proposal';
|
||||
@@ -43,11 +44,23 @@ jest.mock('../list-asset', () => ({
|
||||
ListAsset: () => <div data-testid="proposal-list-asset"></div>,
|
||||
}));
|
||||
|
||||
const vegaWalletConfig: VegaWalletConfig = {
|
||||
network: 'TESTNET',
|
||||
vegaUrl: 'https://vega.xyz',
|
||||
vegaWalletServiceUrl: 'https://wallet.vega.xyz',
|
||||
links: {
|
||||
explorer: 'explorer',
|
||||
concepts: 'concepts',
|
||||
chromeExtensionUrl: 'chrome',
|
||||
mozillaExtensionUrl: 'mozilla',
|
||||
},
|
||||
};
|
||||
|
||||
const renderComponent = (proposal: ProposalQuery['proposal']) => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<MockedProvider>
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletProvider config={vegaWalletConfig}>
|
||||
<Proposal
|
||||
restData={{}}
|
||||
proposal={proposal as ProposalQuery['proposal']}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { VoteButtons } from './vote-buttons';
|
||||
import { VoteState } from './use-user-vote';
|
||||
import { ProposalState } from '@vegaprotocol/types';
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
|
||||
import { mockWalletContext } from '../../test-helpers/mocks';
|
||||
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
|
||||
import { MockedProvider } from '@apollo/react-testing';
|
||||
@@ -67,7 +68,7 @@ describe('Vote buttons', () => {
|
||||
disconnect: jest.fn(),
|
||||
selectPubKey: jest.fn(),
|
||||
connector: null,
|
||||
};
|
||||
} as unknown as VegaWalletContextShape;
|
||||
|
||||
render(
|
||||
<AppStateProvider>
|
||||
|
||||
@@ -114,6 +114,7 @@ describe('Raw proposal form', () => {
|
||||
{
|
||||
pubKey,
|
||||
sendTx: mockSendTx,
|
||||
links: { explorer: 'explorer' },
|
||||
} as unknown as VegaWalletContextShape
|
||||
}
|
||||
>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
|
||||
import type { MockedResponse } from '@apollo/client/testing';
|
||||
import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
||||
import type { PubKey } from '@vegaprotocol/wallet';
|
||||
import type { PubKey, VegaWalletContextShape } from '@vegaprotocol/wallet';
|
||||
import type { VoteValue } from '@vegaprotocol/types';
|
||||
import type { UserVoteQuery } from '../components/vote-details/__generated__/Vote';
|
||||
import { UserVoteDocument } from '../components/vote-details/__generated__/Vote';
|
||||
@@ -21,7 +21,7 @@ export const mockWalletContext = {
|
||||
disconnect: jest.fn(),
|
||||
selectPubKey: jest.fn(),
|
||||
connector: null,
|
||||
};
|
||||
} as unknown as VegaWalletContextShape;
|
||||
|
||||
const mockEthereumConfig = {
|
||||
network_id: '3',
|
||||
|
||||
@@ -1,475 +0,0 @@
|
||||
import { aliasGQLQuery } from '@vegaprotocol/cypress';
|
||||
import type { DataSourceDefinition } from '@vegaprotocol/types';
|
||||
import {
|
||||
MarketState,
|
||||
MarketStateMapping,
|
||||
PropertyKeyType,
|
||||
} from '@vegaprotocol/types';
|
||||
import { addDays, subDays } from 'date-fns';
|
||||
import {
|
||||
chainIdQuery,
|
||||
statisticsQuery,
|
||||
createDataConnection,
|
||||
oracleSpecDataConnectionQuery,
|
||||
createMarketFragment,
|
||||
marketsQuery,
|
||||
marketsDataQuery,
|
||||
createMarketsDataFragment,
|
||||
assetQuery,
|
||||
networkParamsQuery,
|
||||
nodeGuardQuery,
|
||||
} from '@vegaprotocol/mock';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
getDateTimeFormat,
|
||||
} from '@vegaprotocol/utils';
|
||||
|
||||
describe('Closed markets', { tags: '@smoke' }, () => {
|
||||
const settlementDataProperty = 'settlement-data-property';
|
||||
const settlementDataPropertyKey = {
|
||||
__typename: 'PropertyKey' as const,
|
||||
name: settlementDataProperty,
|
||||
type: PropertyKeyType.TYPE_INTEGER,
|
||||
numberDecimalPlaces: 2,
|
||||
};
|
||||
const settlementDataSourceData: DataSourceDefinition = {
|
||||
sourceType: {
|
||||
sourceType: {
|
||||
filters: [
|
||||
{
|
||||
__typename: 'Filter',
|
||||
key: settlementDataPropertyKey,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
const rowSelector =
|
||||
'[data-testid="tab-closed-markets"] .ag-center-cols-container .ag-row';
|
||||
|
||||
const assetsResult = assetQuery();
|
||||
// @ts-ignore asset definitely exists
|
||||
const settlementAsset = assetsResult.assetsConnection.edges[0].node;
|
||||
|
||||
const settledMarket = createMarketFragment({
|
||||
id: '0',
|
||||
state: MarketState.STATE_SETTLED,
|
||||
marketTimestamps: {
|
||||
open: subDays(new Date(), 10).toISOString(),
|
||||
close: subDays(new Date(), 4).toISOString(),
|
||||
},
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
product: {
|
||||
dataSourceSpecBinding: {
|
||||
settlementDataProperty,
|
||||
},
|
||||
dataSourceSpecForTradingTermination: {
|
||||
id: 'market-1-trading-termination-oracle-id',
|
||||
},
|
||||
dataSourceSpecForSettlementData: {
|
||||
id: 'market-1-settlement-data-oracle-id',
|
||||
data: settlementDataSourceData,
|
||||
},
|
||||
settlementAsset,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const terminatedMarket = createMarketFragment({
|
||||
id: '1',
|
||||
state: MarketState.STATE_TRADING_TERMINATED,
|
||||
marketTimestamps: {
|
||||
open: subDays(new Date(), 10).toISOString(),
|
||||
close: null, // market
|
||||
},
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
metadata: {
|
||||
tags: [
|
||||
`settlement-expiry-date:${addDays(new Date(), 4).toISOString()}`,
|
||||
],
|
||||
},
|
||||
product: {
|
||||
dataSourceSpecBinding: {
|
||||
settlementDataProperty,
|
||||
},
|
||||
dataSourceSpecForSettlementData: {
|
||||
id: 'market-1-settlement-data-oracle-id',
|
||||
data: settlementDataSourceData,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const delayedSettledMarket = createMarketFragment({
|
||||
id: '2',
|
||||
state: MarketState.STATE_TRADING_TERMINATED,
|
||||
marketTimestamps: {
|
||||
open: subDays(new Date(), 10).toISOString(),
|
||||
close: null, // market
|
||||
},
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
metadata: {
|
||||
tags: [
|
||||
`settlement-expiry-date:${subDays(new Date(), 2).toISOString()}`,
|
||||
],
|
||||
},
|
||||
product: {
|
||||
dataSourceSpecBinding: {
|
||||
settlementDataProperty,
|
||||
},
|
||||
dataSourceSpecForSettlementData: {
|
||||
id: 'market-1-settlement-data-oracle-id',
|
||||
data: settlementDataSourceData,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const unknownMarket = createMarketFragment({
|
||||
id: '3',
|
||||
state: MarketState.STATE_SETTLED,
|
||||
});
|
||||
|
||||
const closedMarketsResult = [
|
||||
{
|
||||
node: settledMarket,
|
||||
},
|
||||
{
|
||||
node: terminatedMarket,
|
||||
},
|
||||
{
|
||||
node: delayedSettledMarket,
|
||||
},
|
||||
{ node: unknownMarket },
|
||||
{
|
||||
node: createMarketFragment({ id: '4', state: MarketState.STATE_PENDING }),
|
||||
},
|
||||
{
|
||||
node: createMarketFragment({ id: '5', state: MarketState.STATE_ACTIVE }),
|
||||
},
|
||||
];
|
||||
|
||||
const settledMarketData = createMarketsDataFragment({
|
||||
market: {
|
||||
id: settledMarket.id,
|
||||
},
|
||||
bestBidPrice: '1000',
|
||||
bestOfferPrice: '2000',
|
||||
markPrice: '1500',
|
||||
});
|
||||
|
||||
const closedMarketsDataResult = [
|
||||
{
|
||||
node: {
|
||||
data: settledMarketData,
|
||||
},
|
||||
},
|
||||
{
|
||||
node: {
|
||||
data: createMarketsDataFragment({
|
||||
market: {
|
||||
id: terminatedMarket.id,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
node: {
|
||||
data: createMarketsDataFragment({
|
||||
market: {
|
||||
id: delayedSettledMarket.id,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
node: {
|
||||
data: createMarketsDataFragment({
|
||||
market: {
|
||||
id: unknownMarket.id,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const specDataConnection = createDataConnection();
|
||||
|
||||
before(() => {
|
||||
cy.setOnBoardingViewed();
|
||||
cy.mockGQL((req) => {
|
||||
aliasGQLQuery(req, 'ChainId', chainIdQuery());
|
||||
aliasGQLQuery(req, 'Statistics', statisticsQuery());
|
||||
aliasGQLQuery(req, 'NodeGuard', nodeGuardQuery());
|
||||
aliasGQLQuery(req, 'NetworkParams', networkParamsQuery());
|
||||
aliasGQLQuery(
|
||||
req,
|
||||
'Markets',
|
||||
marketsQuery({
|
||||
marketsConnection: {
|
||||
edges: closedMarketsResult,
|
||||
},
|
||||
})
|
||||
);
|
||||
aliasGQLQuery(
|
||||
req,
|
||||
'MarketsData',
|
||||
marketsDataQuery({
|
||||
marketsConnection: {
|
||||
edges: closedMarketsDataResult,
|
||||
},
|
||||
})
|
||||
);
|
||||
aliasGQLQuery(
|
||||
req,
|
||||
'OracleSpecDataConnection',
|
||||
oracleSpecDataConnectionQuery()
|
||||
);
|
||||
});
|
||||
|
||||
cy.mockSubscription();
|
||||
|
||||
cy.visit('/#/markets/all');
|
||||
cy.get('[data-testid="Closed markets"]').click();
|
||||
});
|
||||
|
||||
it('renders a settled market', () => {
|
||||
const expectedMarkets = closedMarketsResult.filter((edge) => {
|
||||
return [
|
||||
MarketState.STATE_SETTLED,
|
||||
MarketState.STATE_TRADING_TERMINATED,
|
||||
].includes(edge.node.state);
|
||||
});
|
||||
const product = settledMarket.tradableInstrument.instrument.product;
|
||||
|
||||
// rows should be filtered to only include settled/terminated markets
|
||||
cy.get(rowSelector).should('have.length', expectedMarkets.length);
|
||||
|
||||
// check each column in the first row renders correctly
|
||||
// 6001-MARK-001
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="code"]')
|
||||
.find('[data-testid="market-code"]')
|
||||
.should('have.text', settledMarket.tradableInstrument.instrument.code);
|
||||
|
||||
// 6001-MARK-071
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[title="Future"]')
|
||||
.should('have.text', 'Futr');
|
||||
|
||||
// 6001-MARK-002
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="name"]')
|
||||
.should('have.text', settledMarket.tradableInstrument.instrument.name);
|
||||
|
||||
// 6001-MARK-003
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="state"]')
|
||||
.should('have.text', MarketStateMapping[settledMarket.state]);
|
||||
|
||||
// 6001-MARK-004
|
||||
// 6001-MARK-005
|
||||
// 6001-MARK-009
|
||||
// 6001-MARK-008
|
||||
// 6001-MARK-010
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="settlementDate"]')
|
||||
.find('[data-testid="link"]')
|
||||
.should(($el) => {
|
||||
const href = $el.attr('href');
|
||||
expect(href).to.match(
|
||||
new RegExp(
|
||||
`/oracles/${product.dataSourceSpecForTradingTermination.id}`
|
||||
)
|
||||
);
|
||||
})
|
||||
.should('have.text', '4 days ago')
|
||||
.should(
|
||||
'have.attr',
|
||||
'title',
|
||||
getDateTimeFormat().format(
|
||||
new Date(settledMarket.marketTimestamps.close)
|
||||
)
|
||||
);
|
||||
|
||||
// 6001-MARK-011
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="bestBidPrice"]')
|
||||
.should(
|
||||
'have.text',
|
||||
addDecimalsFormatNumber(
|
||||
settledMarketData.bestBidPrice,
|
||||
settledMarket.decimalPlaces
|
||||
)
|
||||
);
|
||||
|
||||
// 6001-MARK-012
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="bestOfferPrice"]')
|
||||
.should(
|
||||
'have.text',
|
||||
addDecimalsFormatNumber(
|
||||
settledMarketData.bestOfferPrice,
|
||||
settledMarket.decimalPlaces
|
||||
)
|
||||
);
|
||||
|
||||
// 6001-MARK-013
|
||||
cy.get(rowSelector).first().find('[col-id="markPrice"]').should(
|
||||
'have.text',
|
||||
|
||||
addDecimalsFormatNumber(
|
||||
settledMarketData.markPrice,
|
||||
settledMarket.decimalPlaces
|
||||
)
|
||||
);
|
||||
|
||||
// 6001-MARK-014
|
||||
// 6001-MARK-015
|
||||
// 6001-MARK-016
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="settlementDataOracleId"]')
|
||||
.find('[data-testid="link"]')
|
||||
.should(($el) => {
|
||||
const href = $el.attr('href');
|
||||
expect(href).to.match(
|
||||
new RegExp(`/oracles/${product.dataSourceSpecForSettlementData.id}`)
|
||||
);
|
||||
})
|
||||
.should(
|
||||
'have.text',
|
||||
addDecimalsFormatNumber(
|
||||
// @ts-ignore cannot deep un-partial
|
||||
specDataConnection.externalData.data.data[0].value,
|
||||
settlementDataPropertyKey.numberDecimalPlaces
|
||||
)
|
||||
);
|
||||
|
||||
// 6001-MARK-018
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="settlementAsset"]')
|
||||
.should('have.text', product.settlementAsset.symbol);
|
||||
|
||||
// 6001-MARK-020
|
||||
cy.get('.ag-pinned-right-cols-container')
|
||||
.find('[col-id="market-actions"]')
|
||||
.first()
|
||||
.find('button svg')
|
||||
.should('exist');
|
||||
if (Cypress.env('NX_SUCCESSOR_MARKETS')) {
|
||||
cy.get(rowSelector)
|
||||
.find('[col-id="successorMarket"]')
|
||||
.first()
|
||||
.should('have.text', '-');
|
||||
}
|
||||
});
|
||||
|
||||
// test market list for market in terminated state
|
||||
it('renders a terminated market', () => {
|
||||
cy.get(rowSelector)
|
||||
.eq(1)
|
||||
.find('[col-id="state"]')
|
||||
.should('have.text', MarketStateMapping[terminatedMarket.state]);
|
||||
|
||||
// 6001-MARK-006
|
||||
// 6001-MARK-007
|
||||
cy.get(rowSelector)
|
||||
.eq(1)
|
||||
.find('[col-id="settlementDate"]')
|
||||
.find('[data-testid="link"]')
|
||||
.should('have.text', 'Expected in 4 days');
|
||||
});
|
||||
|
||||
it('renders a terminated market which was expected to have settled', () => {
|
||||
cy.get(rowSelector)
|
||||
.eq(2)
|
||||
.find('[col-id="settlementDate"]')
|
||||
.should('have.class', 'text-danger')
|
||||
.find('[data-testid="link"]')
|
||||
.should('have.text', 'Expected 2 days ago');
|
||||
});
|
||||
|
||||
it('renders terminated market which doesnt have settlement date metadata', () => {
|
||||
cy.get(rowSelector)
|
||||
.eq(3)
|
||||
.find('[col-id="settlementDate"]')
|
||||
.find('[data-testid="link"]')
|
||||
.should('have.text', 'Unknown');
|
||||
});
|
||||
|
||||
it('can open asset detail dialog', () => {
|
||||
cy.mockGQL((req) => {
|
||||
aliasGQLQuery(req, 'Asset', assetsResult);
|
||||
});
|
||||
|
||||
cy.get(rowSelector)
|
||||
.first()
|
||||
.find('[col-id="settlementAsset"]')
|
||||
.find('button')
|
||||
.click();
|
||||
|
||||
// 6001-MARK-019
|
||||
cy.get('[data-testid="dialog-title"]').should(
|
||||
'have.text',
|
||||
`Asset details - ${settlementAsset.symbol}`
|
||||
);
|
||||
|
||||
cy.get('[data-testid="dialog-close"]').click();
|
||||
});
|
||||
|
||||
it('can open row actions', () => {
|
||||
cy.get('.ag-pinned-right-cols-container')
|
||||
.find('[col-id="market-actions"]')
|
||||
.first()
|
||||
.find('button')
|
||||
.click();
|
||||
|
||||
const dropdownContent = '[data-testid="market-actions-content"]';
|
||||
const dropdownContentItem = '[role="menuitem"]';
|
||||
cy.get(dropdownContent)
|
||||
.find(dropdownContentItem)
|
||||
.eq(0)
|
||||
// Cannot click the copy button as it falls back to window.prompt, blocking the test.
|
||||
.should('have.text', 'Copy Market ID');
|
||||
|
||||
cy.get(dropdownContent)
|
||||
.find(dropdownContentItem)
|
||||
.eq(1)
|
||||
.find('a')
|
||||
.then(($el) => {
|
||||
const href = $el.attr('href');
|
||||
expect(/\/markets\/0/.test(href || '')).to.equal(true);
|
||||
})
|
||||
.should('have.text', 'View on Explorer');
|
||||
});
|
||||
});
|
||||
|
||||
describe('no closed markets', { tags: '@smoke', testIsolation: true }, () => {
|
||||
before(() => {
|
||||
cy.mockTradingPage();
|
||||
cy.mockSubscription();
|
||||
cy.setOnBoardingViewed();
|
||||
cy.visit('/#/markets/all');
|
||||
cy.get('[data-testid="Closed markets"]').click();
|
||||
});
|
||||
|
||||
it('can see no markets message', () => {
|
||||
// 6001-MARK-034
|
||||
cy.getByTestId('tab-closed-markets').should('contain.text', 'No markets');
|
||||
});
|
||||
});
|
||||
@@ -33,9 +33,7 @@ describe('deal ticker order validation', { tags: '@smoke' }, () => {
|
||||
|
||||
it('must see the price unit', function () {
|
||||
// 7002-SORD-018
|
||||
cy.getByTestId(orderPriceField)
|
||||
.siblings('label')
|
||||
.should('have.text', 'Price (DAI)');
|
||||
cy.getByTestId(orderPriceField).next().should('have.text', 'DAI');
|
||||
});
|
||||
|
||||
it('must see warning when placing an order with expiry date in past', () => {
|
||||
|
||||
@@ -12,6 +12,8 @@ NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||
NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/main/announcements.json
|
||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
|
||||
# Cosmic elevator flags
|
||||
|
||||
@@ -13,7 +13,7 @@ NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||
NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
NX_ETH_LOCAL_PROVIDER_URL=http://localhost:8545/
|
||||
NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supply green clown session"
|
||||
|
||||
@@ -14,7 +14,7 @@ NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega-dev-releases/releases
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||
NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
|
||||
@@ -14,7 +14,7 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou
|
||||
NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_VEGA_CONSOLE_URL=https://console.vega.xyz
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-mainnet/codfcglpplgmmlokgilfkpcjnmkbfiel
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet-mainnet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet
|
||||
# TAG name of the current app version - TODO: bump to the latest upon release
|
||||
NX_APP_VERSION=v0.20.21-core-0.71.6
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou
|
||||
NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_VEGA_CONSOLE_URL=https://console.mainnet-mirror.vega.rocks
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-mainnet/codfcglpplgmmlokgilfkpcjnmkbfiel
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet-mainnet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet
|
||||
# TAG name of the current app version - TODO: bump to the latest upon release
|
||||
NX_APP_VERSION=v0.20.19-core-0.71.6
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||
NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
|
||||
@@ -15,7 +15,7 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou
|
||||
NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_VEGA_CONSOLE_URL=https://console.fairground.wtf
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
|
||||
@@ -16,7 +16,7 @@ NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports
|
||||
NX_VEGA_CONSOLE_URL=https://trading.validators-testnet.vega.rocks
|
||||
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
||||
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=false
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { InMemoryCacheConfig } from '@apollo/client';
|
||||
import {
|
||||
AppFailure,
|
||||
DocsLinks,
|
||||
NetworkLoader,
|
||||
NodeGuard,
|
||||
useEnvironment,
|
||||
@@ -17,16 +18,32 @@ export const DynamicLoader = dynamic(() => import('../preloader/preloader'), {
|
||||
});
|
||||
|
||||
export const AppLoader = ({ children }: { children: ReactNode }) => {
|
||||
const { error, VEGA_URL, MAINTENANCE_PAGE } = useEnvironment((store) => ({
|
||||
error: store.error,
|
||||
VEGA_URL: store.VEGA_URL,
|
||||
MAINTENANCE_PAGE: store.MAINTENANCE_PAGE,
|
||||
}));
|
||||
const {
|
||||
error,
|
||||
VEGA_URL,
|
||||
VEGA_ENV,
|
||||
VEGA_WALLET_URL,
|
||||
VEGA_EXPLORER_URL,
|
||||
MAINTENANCE_PAGE,
|
||||
MOZILLA_EXTENSION_URL,
|
||||
CHROME_EXTENSION_URL,
|
||||
} = useEnvironment();
|
||||
|
||||
if (MAINTENANCE_PAGE) {
|
||||
return <MaintenancePage />;
|
||||
}
|
||||
|
||||
if (
|
||||
!VEGA_URL ||
|
||||
!VEGA_WALLET_URL ||
|
||||
!VEGA_EXPLORER_URL ||
|
||||
!CHROME_EXTENSION_URL ||
|
||||
!MOZILLA_EXTENSION_URL ||
|
||||
!DocsLinks
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<NetworkLoader
|
||||
cache={cacheConfig}
|
||||
@@ -40,7 +57,21 @@ export const AppLoader = ({ children }: { children: ReactNode }) => {
|
||||
failure={<AppFailure title={t(`Node: ${VEGA_URL} is unsuitable`)} />}
|
||||
>
|
||||
<Web3Provider>
|
||||
<VegaWalletProvider>{children}</VegaWalletProvider>
|
||||
<VegaWalletProvider
|
||||
config={{
|
||||
network: VEGA_ENV,
|
||||
vegaUrl: VEGA_URL,
|
||||
vegaWalletServiceUrl: VEGA_WALLET_URL,
|
||||
links: {
|
||||
explorer: VEGA_EXPLORER_URL,
|
||||
concepts: DocsLinks.VEGA_WALLET_CONCEPTS_URL,
|
||||
chromeExtensionUrl: CHROME_EXTENSION_URL,
|
||||
mozillaExtensionUrl: MOZILLA_EXTENSION_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</VegaWalletProvider>
|
||||
</Web3Provider>
|
||||
</NodeGuard>
|
||||
</NetworkLoader>
|
||||
|
||||
@@ -9,7 +9,8 @@ import {
|
||||
} from './sidebar';
|
||||
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
||||
import { VegaIconNames } from '@vegaprotocol/ui-toolkit';
|
||||
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
||||
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
|
||||
jest.mock('../node-health', () => ({
|
||||
NodeHealthContainer: () => <span data-testid="node-health" />,
|
||||
@@ -31,16 +32,20 @@ jest.mock('../welcome-dialog', () => ({
|
||||
GetStarted: () => <div data-testid="get-started" />,
|
||||
}));
|
||||
|
||||
const walletContext = {
|
||||
pubKeys: [{ publicKey: 'pubkey' }],
|
||||
} as VegaWalletContextShape;
|
||||
|
||||
describe('Sidebar', () => {
|
||||
it.each(['/markets/all', '/portfolio'])(
|
||||
'does not render ticket and info',
|
||||
(path) => {
|
||||
render(
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<MemoryRouter initialEntries={[path]}>
|
||||
<Sidebar />
|
||||
</MemoryRouter>
|
||||
</VegaWalletProvider>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId(ViewType.ViewAs)).toBeInTheDocument();
|
||||
@@ -58,11 +63,11 @@ describe('Sidebar', () => {
|
||||
|
||||
it('renders ticket and info on market pages', () => {
|
||||
render(
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<MemoryRouter initialEntries={['/markets/ABC']}>
|
||||
<Sidebar />
|
||||
</MemoryRouter>
|
||||
</VegaWalletProvider>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId(ViewType.ViewAs)).toBeInTheDocument();
|
||||
@@ -79,11 +84,11 @@ describe('Sidebar', () => {
|
||||
|
||||
it('renders selected state', async () => {
|
||||
render(
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<MemoryRouter initialEntries={['/markets/ABC']}>
|
||||
<Sidebar />
|
||||
</MemoryRouter>
|
||||
</VegaWalletProvider>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
|
||||
const settingsButton = screen.getByTestId(ViewType.Settings);
|
||||
@@ -107,13 +112,13 @@ describe('Sidebar', () => {
|
||||
describe('SidebarContent', () => {
|
||||
it('renders the correct content', () => {
|
||||
const { container } = render(
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<MemoryRouter initialEntries={['/markets/ABC']}>
|
||||
<Routes>
|
||||
<Route path="/markets/:marketId" element={<SidebarContent />} />
|
||||
</Routes>
|
||||
</MemoryRouter>
|
||||
</VegaWalletProvider>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
@@ -133,13 +138,13 @@ describe('SidebarContent', () => {
|
||||
|
||||
it('closes sidebar if market id is required but not present', () => {
|
||||
const { container } = render(
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<MemoryRouter initialEntries={['/portfolio']}>
|
||||
<Routes>
|
||||
<Route path="/portfolio" element={<SidebarContent />} />
|
||||
</Routes>
|
||||
</MemoryRouter>
|
||||
</VegaWalletProvider>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
|
||||
act(() => {
|
||||
|
||||
@@ -29,6 +29,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const GetStartedButton = ({ step }: { step: OnboardingStep }) => {
|
||||
const { CHROME_EXTENSION_URL, MOZILLA_EXTENSION_URL } = useEnvironment();
|
||||
const navigate = useNavigate();
|
||||
const [, setOnboardingViewed] = useLocalStorage(
|
||||
constants.ONBOARDING_VIEWED_KEY
|
||||
@@ -46,7 +47,13 @@ const GetStartedButton = ({ step }: { step: OnboardingStep }) => {
|
||||
openVegaWalletDialog();
|
||||
};
|
||||
if (step === OnboardingStep.ONBOARDING_WALLET_STEP) {
|
||||
return <GetWalletButton className="justify-between" />;
|
||||
return (
|
||||
<GetWalletButton
|
||||
className="justify-between"
|
||||
chromeExtensionUrl={CHROME_EXTENSION_URL}
|
||||
mozillaExtensionUrl={MOZILLA_EXTENSION_URL}
|
||||
/>
|
||||
);
|
||||
} else if (step === OnboardingStep.ONBOARDING_CONNECT_STEP) {
|
||||
buttonText = t('Connect');
|
||||
} else if (step === OnboardingStep.ONBOARDING_DEPOSIT_STEP) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ENV } from '@vegaprotocol/environment';
|
||||
import { FLAGS } from '@vegaprotocol/environment';
|
||||
import {
|
||||
JsonRpcConnector,
|
||||
ViewConnector,
|
||||
@@ -18,10 +18,9 @@ if (typeof window !== 'undefined') {
|
||||
view = new ViewConnector();
|
||||
}
|
||||
|
||||
export const snap = new SnapConnector(
|
||||
ENV.VEGA_URL ? new URL(ENV.VEGA_URL).origin : undefined,
|
||||
DEFAULT_SNAP_ID
|
||||
);
|
||||
export const snap = FLAGS.METAMASK_SNAPS
|
||||
? new SnapConnector(DEFAULT_SNAP_ID)
|
||||
: undefined;
|
||||
|
||||
export const Connectors = {
|
||||
injected,
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { Side } from '@vegaprotocol/types';
|
||||
import classNames from 'classnames';
|
||||
|
||||
interface Props {
|
||||
side: Side;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export const DealTicketButton = ({ side, label }: Props) => {
|
||||
const buttonClasses = classNames(
|
||||
'px-10 py-2 uppercase rounded-md text-white w-full',
|
||||
{
|
||||
'bg-market-red': side === Side.SIDE_SELL,
|
||||
'bg-market-green-550': side === Side.SIDE_BUY,
|
||||
}
|
||||
);
|
||||
return (
|
||||
<div className="mb-2">
|
||||
<button type="submit" data-testid="place-order" className={buttonClasses}>
|
||||
{label || t('Place order')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,7 +1,4 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import classnames from 'classnames';
|
||||
import type { ReactNode } from 'react';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { FeesBreakdown } from '@vegaprotocol/markets';
|
||||
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
|
||||
@@ -16,7 +13,6 @@ import { marketMarginDataProvider } from '@vegaprotocol/accounts';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
|
||||
import {
|
||||
NOTIONAL_SIZE_TOOLTIP_TEXT,
|
||||
MARGIN_DIFF_TOOLTIP_TEXT,
|
||||
DEDUCTION_FROM_COLLATERAL_TOOLTIP_TEXT,
|
||||
TOTAL_MARGIN_AVAILABLE,
|
||||
@@ -25,114 +21,54 @@ import {
|
||||
MARGIN_ACCOUNT_TOOLTIP_TEXT,
|
||||
} from '../../constants';
|
||||
import { useEstimateFees } from '../../hooks';
|
||||
import { KeyValue } from './key-value';
|
||||
|
||||
const emptyValue = '-';
|
||||
|
||||
export interface DealTicketFeeDetailPros {
|
||||
label: string;
|
||||
value?: string | null | undefined;
|
||||
symbol: string;
|
||||
indent?: boolean | undefined;
|
||||
labelDescription?: ReactNode;
|
||||
formattedValue?: string;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export const DealTicketFeeDetail = ({
|
||||
label,
|
||||
value,
|
||||
labelDescription,
|
||||
symbol,
|
||||
indent,
|
||||
onClick,
|
||||
formattedValue,
|
||||
}: DealTicketFeeDetailPros) => {
|
||||
const displayValue = `${formattedValue ?? '-'} ${symbol || ''}`;
|
||||
const valueElement = onClick ? (
|
||||
<button onClick={onClick} className="text-muted">
|
||||
{displayValue}
|
||||
</button>
|
||||
) : (
|
||||
<div className="text-muted">{displayValue}</div>
|
||||
);
|
||||
return (
|
||||
<div
|
||||
data-testid={
|
||||
'deal-ticket-fee-' + label.toLocaleLowerCase().replace(/\s/g, '-')
|
||||
}
|
||||
key={typeof label === 'string' ? label : 'value-dropdown'}
|
||||
className={classnames(
|
||||
'text-xs mt-2 flex justify-between items-center gap-4 flex-wrap',
|
||||
{ 'ml-2': indent }
|
||||
)}
|
||||
>
|
||||
<Tooltip description={labelDescription}>
|
||||
<div>{label}</div>
|
||||
</Tooltip>
|
||||
<Tooltip description={`${value ?? '-'} ${symbol || ''}`}>
|
||||
{valueElement}
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export interface DealTicketFeeDetailsProps {
|
||||
assetSymbol: string;
|
||||
order: OrderSubmissionBody['orderSubmission'];
|
||||
market: Market;
|
||||
notionalSize: string | null;
|
||||
}
|
||||
|
||||
export const DealTicketFeeDetails = ({
|
||||
assetSymbol,
|
||||
order,
|
||||
market,
|
||||
notionalSize,
|
||||
}: DealTicketFeeDetailsProps) => {
|
||||
const feeEstimate = useEstimateFees(order);
|
||||
const { settlementAsset: asset } =
|
||||
market.tradableInstrument.instrument.product;
|
||||
const { decimals: assetDecimals, quantum } = asset;
|
||||
const marketDecimals = market.decimalPlaces;
|
||||
const quoteName = market.tradableInstrument.instrument.product.quoteName;
|
||||
|
||||
return (
|
||||
<>
|
||||
<DealTicketFeeDetail
|
||||
label={t('Notional')}
|
||||
value={formatValue(notionalSize, marketDecimals)}
|
||||
formattedValue={formatValue(notionalSize, marketDecimals)}
|
||||
symbol={quoteName}
|
||||
labelDescription={NOTIONAL_SIZE_TOOLTIP_TEXT(quoteName)}
|
||||
/>
|
||||
<DealTicketFeeDetail
|
||||
label={t('Fees')}
|
||||
value={
|
||||
feeEstimate?.totalFeeAmount &&
|
||||
`~${formatValue(feeEstimate?.totalFeeAmount, assetDecimals)}`
|
||||
}
|
||||
formattedValue={
|
||||
feeEstimate?.totalFeeAmount &&
|
||||
`~${formatValue(feeEstimate?.totalFeeAmount, assetDecimals, quantum)}`
|
||||
}
|
||||
labelDescription={
|
||||
<>
|
||||
<span>
|
||||
{t(
|
||||
`An estimate of the most you would be expected to pay in fees, in the market's settlement asset ${assetSymbol}.`
|
||||
)}
|
||||
</span>
|
||||
<FeesBreakdown
|
||||
fees={feeEstimate?.fees}
|
||||
feeFactors={market.fees.factors}
|
||||
symbol={assetSymbol}
|
||||
decimals={assetDecimals}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
symbol={assetSymbol}
|
||||
/>
|
||||
</>
|
||||
<KeyValue
|
||||
label={t('Fees')}
|
||||
value={
|
||||
feeEstimate?.totalFeeAmount &&
|
||||
`~${formatValue(feeEstimate?.totalFeeAmount, assetDecimals)}`
|
||||
}
|
||||
formattedValue={
|
||||
feeEstimate?.totalFeeAmount &&
|
||||
`~${formatValue(feeEstimate?.totalFeeAmount, assetDecimals, quantum)}`
|
||||
}
|
||||
labelDescription={
|
||||
<>
|
||||
<span>
|
||||
{t(
|
||||
`An estimate of the most you would be expected to pay in fees, in the market's settlement asset ${assetSymbol}.`
|
||||
)}
|
||||
</span>
|
||||
<FeesBreakdown
|
||||
fees={feeEstimate?.fees}
|
||||
feeFactors={market.fees.factors}
|
||||
symbol={assetSymbol}
|
||||
decimals={assetDecimals}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
symbol={assetSymbol}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -209,7 +145,7 @@ export const DealTicketMarginDetails = ({
|
||||
BigInt(marginAccountBalance);
|
||||
|
||||
deductionFromCollateral = (
|
||||
<DealTicketFeeDetail
|
||||
<KeyValue
|
||||
indent
|
||||
label={t('Deduction from collateral')}
|
||||
value={formatRange(
|
||||
@@ -236,7 +172,7 @@ export const DealTicketMarginDetails = ({
|
||||
/>
|
||||
);
|
||||
projectedMargin = (
|
||||
<DealTicketFeeDetail
|
||||
<KeyValue
|
||||
label={t('Projected margin')}
|
||||
value={formatRange(
|
||||
marginEstimate?.bestCase.initialLevel,
|
||||
@@ -308,7 +244,7 @@ export const DealTicketMarginDetails = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
<DealTicketFeeDetail
|
||||
<KeyValue
|
||||
label={t('Margin required')}
|
||||
value={formatRange(
|
||||
marginRequiredBestCase,
|
||||
@@ -324,7 +260,7 @@ export const DealTicketMarginDetails = ({
|
||||
labelDescription={MARGIN_DIFF_TOOLTIP_TEXT(assetSymbol)}
|
||||
symbol={assetSymbol}
|
||||
/>
|
||||
<DealTicketFeeDetail
|
||||
<KeyValue
|
||||
label={t('Total margin available')}
|
||||
indent
|
||||
value={formatValue(totalMarginAvailable, assetDecimals)}
|
||||
@@ -342,7 +278,7 @@ export const DealTicketMarginDetails = ({
|
||||
)}
|
||||
/>
|
||||
{deductionFromCollateral}
|
||||
<DealTicketFeeDetail
|
||||
<KeyValue
|
||||
label={t('Current margin allocation')}
|
||||
indent
|
||||
onClick={
|
||||
@@ -358,7 +294,7 @@ export const DealTicketMarginDetails = ({
|
||||
)}
|
||||
/>
|
||||
{projectedMargin}
|
||||
<DealTicketFeeDetail
|
||||
<KeyValue
|
||||
label={t('Liquidation price estimate')}
|
||||
value={liquidationPriceEstimate}
|
||||
formattedValue={liquidationPriceEstimate}
|
||||
|
||||
@@ -32,7 +32,7 @@ export const DealTicketSizeIceberg = ({
|
||||
const renderPeakSizeError = () => {
|
||||
if (peakSizeError) {
|
||||
return (
|
||||
<TradingInputError testId="deal-ticket-peak-error-message-size-limit">
|
||||
<TradingInputError testId="deal-ticket-peak-error-message">
|
||||
{peakSizeError}
|
||||
</TradingInputError>
|
||||
);
|
||||
@@ -44,7 +44,7 @@ export const DealTicketSizeIceberg = ({
|
||||
const renderMinimumSizeError = () => {
|
||||
if (minimumVisibleSizeError) {
|
||||
return (
|
||||
<TradingInputError testId="deal-ticket-minimum-error-message-size-limit">
|
||||
<TradingInputError testId="deal-ticket-minimum-error-message">
|
||||
{minimumVisibleSizeError}
|
||||
</TradingInputError>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { generateMarket } from '../../test-helpers';
|
||||
import { StopOrder } from './deal-ticket-stop-order';
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
useDealTicketFormValues,
|
||||
} from '../../hooks/use-form-values';
|
||||
import type { FeatureFlags } from '@vegaprotocol/environment';
|
||||
import { formatForInput } from '@vegaprotocol/utils';
|
||||
|
||||
jest.mock('zustand');
|
||||
jest.mock('./deal-ticket-fee-details', () => ({
|
||||
@@ -57,7 +58,7 @@ const orderSideBuy = 'order-side-SIDE_BUY';
|
||||
const orderSideSell = 'order-side-SIDE_SELL';
|
||||
|
||||
const triggerDirectionRisesAbove = 'triggerDirection-risesAbove';
|
||||
// const triggerDirectionFallsBelow = 'triggerDirection-fallsBelow';
|
||||
const triggerDirectionFallsBelow = 'triggerDirection-fallsBelow';
|
||||
|
||||
const expiryStrategySubmit = 'expiryStrategy-submit';
|
||||
const expiryStrategyCancel = 'expiryStrategy-cancel';
|
||||
@@ -65,6 +66,7 @@ const expiryStrategyCancel = 'expiryStrategy-cancel';
|
||||
const triggerTypePrice = 'triggerType-price';
|
||||
const triggerTypeTrailingPercentOffset = 'triggerType-trailingPercentOffset';
|
||||
|
||||
const oco = 'oco';
|
||||
const expire = 'expire';
|
||||
const datePicker = 'date-picker-field';
|
||||
const timeInForce = 'order-tif';
|
||||
@@ -76,6 +78,8 @@ const triggerPriceWarningMessage = 'stop-order-warning-message-trigger-price';
|
||||
const triggerTrailingPercentOffsetErrorMessage =
|
||||
'stop-order-error-message-trigger-trailing-percent-offset';
|
||||
|
||||
const ocoPostfix = (id: string, postfix = true) => (postfix ? `${id}-oco` : id);
|
||||
|
||||
describe('StopOrder', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
@@ -107,6 +111,7 @@ describe('StopOrder', () => {
|
||||
'checked'
|
||||
);
|
||||
expect(screen.getByTestId(expire).dataset.state).toEqual('unchecked');
|
||||
expect(screen.getByTestId(oco).dataset.state).toEqual('unchecked');
|
||||
await userEvent.click(screen.getByTestId(expire));
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId(expiryStrategySubmit).dataset.state).toEqual(
|
||||
@@ -115,6 +120,32 @@ describe('StopOrder', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('calculate notional for market limit', async () => {
|
||||
render(generateJsx());
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '10');
|
||||
await userEvent.type(screen.getByTestId(priceInput), '10');
|
||||
expect(screen.getByTestId('deal-ticket-fee-notional')).toHaveTextContent(
|
||||
'Notional100.00 BTC'
|
||||
);
|
||||
});
|
||||
|
||||
it('calculates notional for limit order', async () => {
|
||||
render(generateJsx());
|
||||
await userEvent.click(screen.getByTestId(orderTypeTrigger));
|
||||
await userEvent.click(screen.getByTestId(orderTypeMarket));
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '10');
|
||||
// price trigger is selected but it's empty, calculate base on size and marketPrice prop
|
||||
expect(screen.getByTestId('deal-ticket-fee-notional')).toHaveTextContent(
|
||||
'Notional20.00 BTC'
|
||||
);
|
||||
|
||||
await userEvent.type(screen.getByTestId(triggerPriceInput), '3');
|
||||
// calculate base on size and price trigger
|
||||
expect(screen.getByTestId('deal-ticket-fee-notional')).toHaveTextContent(
|
||||
'Notional30.00 BTC'
|
||||
);
|
||||
});
|
||||
|
||||
it('should use local storage state for initial values', async () => {
|
||||
const values: Partial<StopOrderFormValues> = {
|
||||
type: Schema.OrderType.TYPE_LIMIT,
|
||||
@@ -125,6 +156,11 @@ describe('StopOrder', () => {
|
||||
expire: true,
|
||||
expiryStrategy: Schema.StopOrderExpiryStrategy.EXPIRY_STRATEGY_CANCELS,
|
||||
expiresAt: '2023-07-27T16:43:27.000',
|
||||
oco: true,
|
||||
ocoType: Schema.OrderType.TYPE_LIMIT,
|
||||
ocoSize: '0.2',
|
||||
ocoPrice: '300.23',
|
||||
ocoTimeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK,
|
||||
};
|
||||
|
||||
useDealTicketFormValues.setState({
|
||||
@@ -143,10 +179,22 @@ describe('StopOrder', () => {
|
||||
expect(screen.getByTestId(sizeInput)).toHaveDisplayValue(
|
||||
values.size as string
|
||||
);
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(values.timeInForce);
|
||||
expect(screen.getByTestId(timeInForce)).toHaveValue(values.timeInForce);
|
||||
expect(screen.getByTestId(priceInput)).toHaveDisplayValue(
|
||||
values.price as string
|
||||
);
|
||||
|
||||
expect(screen.getByTestId(ocoPostfix(sizeInput))).toHaveDisplayValue(
|
||||
values.ocoSize as string
|
||||
);
|
||||
expect(screen.getByTestId(ocoPostfix(timeInForce))).toHaveValue(
|
||||
values.ocoTimeInForce
|
||||
);
|
||||
expect(screen.getByTestId(ocoPostfix(priceInput))).toHaveDisplayValue(
|
||||
values.ocoPrice as string
|
||||
);
|
||||
expect(screen.getByTestId('ocoTypeLimit').dataset.state).toEqual('checked');
|
||||
|
||||
expect(screen.getByTestId(expire).dataset.state).toEqual('checked');
|
||||
expect(screen.getByTestId(expiryStrategyCancel).dataset.state).toEqual(
|
||||
'checked'
|
||||
@@ -154,6 +202,9 @@ describe('StopOrder', () => {
|
||||
expect(screen.getByTestId(datePicker)).toHaveDisplayValue(
|
||||
values.expiresAt as string
|
||||
);
|
||||
|
||||
await userEvent.click(screen.getByTestId(orderTypeMarket));
|
||||
expect(screen.getByTestId(oco).dataset.state).toEqual('unchecked');
|
||||
});
|
||||
|
||||
it('does not submit if no wallet connected', async () => {
|
||||
@@ -174,145 +225,239 @@ describe('StopOrder', () => {
|
||||
expect(submit).toBeCalled();
|
||||
});
|
||||
|
||||
it('validates size field', async () => {
|
||||
it.each([
|
||||
{ fieldName: 'size', ocoValue: false },
|
||||
{ fieldName: 'ocoSize', ocoValue: true },
|
||||
])('validates $fieldName field', async ({ ocoValue }) => {
|
||||
render(generateJsx());
|
||||
|
||||
if (ocoValue) {
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
}
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
|
||||
const getByTestId = (id: string) =>
|
||||
screen.getByTestId(ocoPostfix(id, ocoValue));
|
||||
const queryByTestId = (id: string) =>
|
||||
screen.queryByTestId(ocoPostfix(id, ocoValue));
|
||||
// default value should be invalid
|
||||
expect(screen.getByTestId(sizeErrorMessage)).toBeInTheDocument();
|
||||
expect(getByTestId(sizeErrorMessage)).toBeInTheDocument();
|
||||
// to small value should be invalid
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '0.01');
|
||||
expect(screen.getByTestId(sizeErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.type(getByTestId(sizeInput), '0.01');
|
||||
expect(getByTestId(sizeErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// clear and fill using valid value
|
||||
await userEvent.clear(screen.getByTestId(sizeInput));
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '0.1');
|
||||
expect(screen.queryByTestId(sizeErrorMessage)).toBeNull();
|
||||
await userEvent.clear(getByTestId(sizeInput));
|
||||
await userEvent.type(getByTestId(sizeInput), '0.1');
|
||||
expect(queryByTestId(sizeErrorMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('validates price field', async () => {
|
||||
it.each([
|
||||
{ fieldName: 'price', ocoValue: false },
|
||||
{ fieldName: 'ocoPrice', ocoValue: true },
|
||||
])('validates $fieldName field', async ({ ocoValue }) => {
|
||||
render(generateJsx());
|
||||
|
||||
if (ocoValue) {
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
}
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
// price error message should not show if size has error
|
||||
// expect(screen.queryByTestId(priceErrorMessage)).toBeNull();
|
||||
// await userEvent.type(screen.getByTestId(sizeInput), '0.1');
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.type(screen.getByTestId(priceInput), '0.001');
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
const getByTestId = (id: string) =>
|
||||
screen.getByTestId(ocoPostfix(id, ocoValue));
|
||||
const queryByTestId = (id: string) =>
|
||||
screen.queryByTestId(ocoPostfix(id, ocoValue));
|
||||
|
||||
expect(getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.type(getByTestId(priceInput), '0.001');
|
||||
expect(getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// switch to market order type error should disappear
|
||||
await userEvent.click(screen.getByTestId(orderTypeTrigger));
|
||||
await userEvent.click(screen.getByTestId(orderTypeMarket));
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
expect(screen.queryByTestId(priceErrorMessage)).toBeNull();
|
||||
expect(queryByTestId(priceErrorMessage)).toBeNull();
|
||||
|
||||
// switch back to limit type
|
||||
await userEvent.click(screen.getByTestId(orderTypeTrigger));
|
||||
await userEvent.click(screen.getByTestId(orderTypeLimit));
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
expect(getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// to small value should be invalid
|
||||
await userEvent.type(screen.getByTestId(priceInput), '0.001');
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.type(getByTestId(priceInput), '0.001');
|
||||
expect(getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// clear and fill using valid value
|
||||
await userEvent.clear(screen.getByTestId(priceInput));
|
||||
await userEvent.type(screen.getByTestId(priceInput), '0.01');
|
||||
expect(screen.queryByTestId(priceErrorMessage)).toBeNull();
|
||||
await userEvent.clear(getByTestId(priceInput));
|
||||
await userEvent.type(getByTestId(priceInput), '0.01');
|
||||
expect(queryByTestId(priceErrorMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('validates trigger price field', async () => {
|
||||
it.each([
|
||||
{ fieldName: 'triggerPrice', ocoValue: false },
|
||||
{ fieldName: 'ocoTriggerPrice', ocoValue: true },
|
||||
])('validates $fieldName field', async ({ ocoValue }) => {
|
||||
render(generateJsx());
|
||||
|
||||
if (ocoValue) {
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
await userEvent.click(screen.getByTestId(triggerDirectionFallsBelow));
|
||||
}
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
expect(screen.getByTestId(triggerPriceErrorMessage)).toBeInTheDocument();
|
||||
const getByTestId = (id: string) =>
|
||||
screen.getByTestId(ocoPostfix(id, ocoValue));
|
||||
const queryByTestId = (id: string) =>
|
||||
screen.queryByTestId(ocoPostfix(id, ocoValue));
|
||||
expect(getByTestId(triggerPriceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// switch to trailing percentage offset trigger type
|
||||
await userEvent.click(screen.getByTestId(triggerTypeTrailingPercentOffset));
|
||||
expect(screen.queryByTestId(triggerPriceErrorMessage)).toBeNull();
|
||||
await userEvent.click(getByTestId(triggerTypeTrailingPercentOffset));
|
||||
expect(queryByTestId(triggerPriceErrorMessage)).toBeNull();
|
||||
|
||||
// switch back to price trigger type
|
||||
await userEvent.click(screen.getByTestId(triggerTypePrice));
|
||||
expect(screen.getByTestId(triggerPriceErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.click(getByTestId(triggerTypePrice));
|
||||
expect(getByTestId(triggerPriceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// to small value should be invalid
|
||||
await userEvent.type(screen.getByTestId(triggerPriceInput), '0.001');
|
||||
expect(screen.getByTestId(triggerPriceErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.type(getByTestId(triggerPriceInput), '0.001');
|
||||
expect(getByTestId(triggerPriceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// clear and fill using value causing immediate trigger
|
||||
await userEvent.clear(screen.getByTestId(triggerPriceInput));
|
||||
await userEvent.type(screen.getByTestId(triggerPriceInput), '0.01');
|
||||
expect(screen.queryByTestId(triggerPriceErrorMessage)).toBeNull();
|
||||
expect(
|
||||
screen.queryByTestId(triggerPriceWarningMessage)
|
||||
).toBeInTheDocument();
|
||||
await userEvent.clear(getByTestId(triggerPriceInput));
|
||||
await userEvent.type(getByTestId(triggerPriceInput), '0.01');
|
||||
expect(queryByTestId(triggerPriceErrorMessage)).toBeNull();
|
||||
expect(queryByTestId(triggerPriceWarningMessage)).toBeInTheDocument();
|
||||
|
||||
// change to correct value
|
||||
await userEvent.type(screen.getByTestId(triggerPriceInput), '2');
|
||||
expect(screen.queryByTestId(triggerPriceWarningMessage)).toBeNull();
|
||||
await userEvent.type(getByTestId(triggerPriceInput), '2');
|
||||
expect(queryByTestId(triggerPriceWarningMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('validates trigger trailing percentage offset field', async () => {
|
||||
it.each([
|
||||
{ fieldName: 'trailingPercentageOffset', ocoValue: false },
|
||||
{ fieldName: 'ocoTrailingPercentageOffset', ocoValue: true },
|
||||
])('validates $fieldName field', async ({ ocoValue }) => {
|
||||
render(generateJsx());
|
||||
if (ocoValue) {
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
}
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
const getByTestId = (id: string) =>
|
||||
screen.getByTestId(ocoPostfix(id, ocoValue));
|
||||
const queryByTestId = (id: string) =>
|
||||
screen.queryByTestId(ocoPostfix(id, ocoValue));
|
||||
|
||||
// should not show error with default form values
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
expect(
|
||||
screen.queryByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
).toBeNull();
|
||||
expect(queryByTestId(triggerTrailingPercentOffsetErrorMessage)).toBeNull();
|
||||
|
||||
// switch to trailing percentage offset trigger type
|
||||
await userEvent.click(screen.getByTestId(triggerTypeTrailingPercentOffset));
|
||||
await userEvent.click(getByTestId(triggerTypeTrailingPercentOffset));
|
||||
expect(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
getByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
).toBeInTheDocument();
|
||||
|
||||
// to small value should be invalid
|
||||
await userEvent.type(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput),
|
||||
getByTestId(triggerTrailingPercentOffsetInput),
|
||||
'0.09'
|
||||
);
|
||||
expect(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
getByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
).toBeInTheDocument();
|
||||
|
||||
// clear and fill using valid value
|
||||
await userEvent.clear(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput)
|
||||
);
|
||||
await userEvent.type(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput),
|
||||
'0.1'
|
||||
);
|
||||
expect(
|
||||
screen.queryByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
).toBeNull();
|
||||
await userEvent.clear(getByTestId(triggerTrailingPercentOffsetInput));
|
||||
await userEvent.type(getByTestId(triggerTrailingPercentOffsetInput), '0.1');
|
||||
expect(queryByTestId(triggerTrailingPercentOffsetErrorMessage)).toBeNull();
|
||||
|
||||
// to big value should be invalid
|
||||
await userEvent.clear(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput)
|
||||
);
|
||||
await userEvent.clear(getByTestId(triggerTrailingPercentOffsetInput));
|
||||
await userEvent.type(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput),
|
||||
getByTestId(triggerTrailingPercentOffsetInput),
|
||||
'99.91'
|
||||
);
|
||||
expect(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
getByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
).toBeInTheDocument();
|
||||
|
||||
// clear and fill using valid value
|
||||
await userEvent.clear(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput)
|
||||
);
|
||||
await userEvent.clear(getByTestId(triggerTrailingPercentOffsetInput));
|
||||
await userEvent.type(
|
||||
screen.getByTestId(triggerTrailingPercentOffsetInput),
|
||||
getByTestId(triggerTrailingPercentOffsetInput),
|
||||
'99.9'
|
||||
);
|
||||
expect(queryByTestId(triggerTrailingPercentOffsetErrorMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('sync oco trigger', async () => {
|
||||
render(generateJsx());
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
expect(
|
||||
screen.queryByTestId(triggerTrailingPercentOffsetErrorMessage)
|
||||
).toBeNull();
|
||||
screen.getByTestId(triggerDirectionRisesAbove).dataset.state
|
||||
).toEqual('checked');
|
||||
expect(
|
||||
screen.getByTestId(ocoPostfix(triggerDirectionFallsBelow)).dataset.state
|
||||
).toEqual('checked');
|
||||
await userEvent.click(screen.getByTestId(triggerDirectionFallsBelow));
|
||||
expect(
|
||||
screen.getByTestId(triggerDirectionRisesAbove).dataset.state
|
||||
).toEqual('unchecked');
|
||||
expect(
|
||||
screen.getByTestId(ocoPostfix(triggerDirectionFallsBelow)).dataset.state
|
||||
).toEqual('unchecked');
|
||||
await userEvent.click(
|
||||
screen.getByTestId(ocoPostfix(triggerDirectionFallsBelow))
|
||||
);
|
||||
expect(
|
||||
screen.getByTestId(triggerDirectionRisesAbove).dataset.state
|
||||
).toEqual('checked');
|
||||
expect(
|
||||
screen.getByTestId(ocoPostfix(triggerDirectionFallsBelow)).dataset.state
|
||||
).toEqual('checked');
|
||||
});
|
||||
|
||||
it('disables submit expiry strategy when OCO selected', async () => {
|
||||
render(generateJsx());
|
||||
await userEvent.click(screen.getByTestId(expire));
|
||||
await userEvent.click(screen.getByTestId(expiryStrategySubmit));
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
expect(screen.getByTestId(expiryStrategySubmit).dataset.state).toEqual(
|
||||
'unchecked'
|
||||
);
|
||||
expect(screen.getByTestId(expiryStrategySubmit)).toBeDisabled();
|
||||
await userEvent.click(screen.getByTestId(oco));
|
||||
await userEvent.click(screen.getByTestId(expiryStrategySubmit));
|
||||
expect(screen.getByTestId(expiryStrategySubmit).dataset.state).toEqual(
|
||||
'checked'
|
||||
);
|
||||
expect(screen.getByTestId(expiryStrategySubmit)).not.toBeDisabled();
|
||||
});
|
||||
|
||||
it('sets expiry time/date to now if expiry is changed to checked', async () => {
|
||||
const now = Math.round(Date.now() / 1000) * 1000;
|
||||
render(generateJsx());
|
||||
jest.spyOn(global.Date, 'now').mockImplementationOnce(() => now);
|
||||
await userEvent.click(screen.getByTestId(expire));
|
||||
|
||||
// expiry time/date was empty it should be set to now
|
||||
expect(
|
||||
new Date(screen.getByTestId<HTMLInputElement>(datePicker).value).getTime()
|
||||
).toEqual(now);
|
||||
|
||||
// set to the value in the past (now - 1s)
|
||||
fireEvent.change(screen.getByTestId<HTMLInputElement>(datePicker), {
|
||||
target: { value: formatForInput(new Date(now - 1000)) },
|
||||
});
|
||||
expect(
|
||||
new Date(
|
||||
screen.getByTestId<HTMLInputElement>(datePicker).value
|
||||
).getTime() + 1000
|
||||
).toEqual(now);
|
||||
|
||||
// switch expiry off and on
|
||||
await userEvent.click(screen.getByTestId(expire));
|
||||
await userEvent.click(screen.getByTestId(expire));
|
||||
// expiry time/date was in the past it should be set to now
|
||||
expect(
|
||||
new Date(screen.getByTestId<HTMLInputElement>(datePicker).value).getTime()
|
||||
).toEqual(now);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { useRef, useCallback, useEffect } from 'react';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import type { StopOrdersSubmission } from '@vegaprotocol/wallet';
|
||||
import type {
|
||||
OrderSubmissionBody,
|
||||
StopOrdersSubmission,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import {
|
||||
formatForInput,
|
||||
formatValue,
|
||||
removeDecimal,
|
||||
toDecimal,
|
||||
validateAmount,
|
||||
@@ -19,6 +23,9 @@ import {
|
||||
TradingInputError as InputError,
|
||||
TradingSelect as Select,
|
||||
Tooltip,
|
||||
TradingButton as Button,
|
||||
Pill,
|
||||
Intent,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { getDerivedPrice } from '@vegaprotocol/markets';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
@@ -31,6 +38,7 @@ import {
|
||||
REDUCE_ONLY_TOOLTIP,
|
||||
stopSubmit,
|
||||
getNotionalSize,
|
||||
getAssetUnit,
|
||||
} from './deal-ticket';
|
||||
import { TypeToggle } from './type-selector';
|
||||
import {
|
||||
@@ -41,9 +49,10 @@ import {
|
||||
} from '../../hooks/use-form-values';
|
||||
import type { StopOrderFormValues } from '../../hooks/use-form-values';
|
||||
import { mapFormValuesToStopOrdersSubmission } from '../../utils/map-form-values-to-submission';
|
||||
import { DealTicketButton } from './deal-ticket-button';
|
||||
import { DealTicketFeeDetails } from './deal-ticket-fee-details';
|
||||
import { validateExpiration } from '../../utils';
|
||||
import { NOTIONAL_SIZE_TOOLTIP_TEXT } from '../../constants';
|
||||
import { KeyValue } from './key-value';
|
||||
|
||||
export interface StopOrderProps {
|
||||
market: Market;
|
||||
@@ -78,7 +87,7 @@ const Trigger = ({
|
||||
control,
|
||||
watch,
|
||||
priceStep,
|
||||
assetSymbol,
|
||||
quoteName,
|
||||
oco,
|
||||
marketPrice,
|
||||
decimalPlaces,
|
||||
@@ -86,7 +95,7 @@ const Trigger = ({
|
||||
control: Control<StopOrderFormValues>;
|
||||
watch: UseFormWatch<StopOrderFormValues>;
|
||||
priceStep: string;
|
||||
assetSymbol: string;
|
||||
quoteName: string;
|
||||
oco?: boolean;
|
||||
marketPrice?: string | null;
|
||||
decimalPlaces: number;
|
||||
@@ -181,7 +190,7 @@ const Trigger = ({
|
||||
data-testid={`triggerPrice${oco ? '-oco' : ''}`}
|
||||
type="number"
|
||||
step={priceStep}
|
||||
appendElement={assetSymbol}
|
||||
appendElement={<Pill size="xs">{quoteName}</Pill>}
|
||||
value={value || ''}
|
||||
hasError={!!fieldState.error}
|
||||
{...props}
|
||||
@@ -249,7 +258,7 @@ const Trigger = ({
|
||||
<Input
|
||||
type="number"
|
||||
step={trailingPercentOffsetStep}
|
||||
appendElement="%"
|
||||
appendElement={<Pill size="xs">%</Pill>}
|
||||
data-testid={`triggerTrailingPercentOffset${
|
||||
oco ? '-oco' : ''
|
||||
}`}
|
||||
@@ -311,10 +320,14 @@ const Size = ({
|
||||
control,
|
||||
sizeStep,
|
||||
oco,
|
||||
isLimitType,
|
||||
assetUnit,
|
||||
}: {
|
||||
control: Control<StopOrderFormValues>;
|
||||
sizeStep: string;
|
||||
oco?: boolean;
|
||||
isLimitType: boolean;
|
||||
assetUnit?: string;
|
||||
}) => {
|
||||
return (
|
||||
<Controller
|
||||
@@ -332,7 +345,7 @@ const Size = ({
|
||||
const { value, ...props } = field;
|
||||
const id = `order-size${oco ? '-oco' : ''}`;
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<div className={isLimitType ? 'mb-4' : 'mb-2'}>
|
||||
<FormGroup labelFor={id} label={t(`Size`)} compact>
|
||||
<Input
|
||||
id={id}
|
||||
@@ -341,6 +354,7 @@ const Size = ({
|
||||
step={sizeStep}
|
||||
min={sizeStep}
|
||||
onWheel={(e) => e.currentTarget.blur()}
|
||||
appendElement={assetUnit && <Pill size="xs">{assetUnit}</Pill>}
|
||||
data-testid={id}
|
||||
value={value || ''}
|
||||
hasError={!!fieldState.error}
|
||||
@@ -394,12 +408,8 @@ const Price = ({
|
||||
const { value, ...props } = field;
|
||||
const id = `order-price${oco ? '-oco' : ''}`;
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<FormGroup
|
||||
labelFor={id}
|
||||
label={t(`Price (${quoteName})`)}
|
||||
compact={true}
|
||||
>
|
||||
<div className="mb-2">
|
||||
<FormGroup labelFor={id} label={t('Price')} compact={true}>
|
||||
<Input
|
||||
id={id}
|
||||
className="w-full"
|
||||
@@ -409,6 +419,7 @@ const Price = ({
|
||||
onWheel={(e) => e.currentTarget.blur()}
|
||||
value={value || ''}
|
||||
hasError={!!fieldState.error}
|
||||
appendElement={<Pill size="xs">{quoteName}</Pill>}
|
||||
{...props}
|
||||
/>
|
||||
</FormGroup>
|
||||
@@ -434,17 +445,17 @@ const TimeInForce = ({
|
||||
oco?: boolean;
|
||||
}) => (
|
||||
<Controller
|
||||
name="timeInForce"
|
||||
name={oco ? 'ocoTimeInForce' : 'timeInForce'}
|
||||
control={control}
|
||||
render={({ field, fieldState }) => {
|
||||
const id = `select-time-in-force${oco ? '-oco' : ''}`;
|
||||
const id = `order-tif${oco ? '-oco' : ''}`;
|
||||
return (
|
||||
<div className="mb-2">
|
||||
<FormGroup label={t('Time in force')} labelFor={id} compact={true}>
|
||||
<Select
|
||||
id={id}
|
||||
className="w-full"
|
||||
data-testid="order-tif"
|
||||
data-testid={id}
|
||||
hasError={!!fieldState.error}
|
||||
{...field}
|
||||
>
|
||||
@@ -486,6 +497,255 @@ const ReduceOnly = () => (
|
||||
/>
|
||||
);
|
||||
|
||||
const NotionalAndFees = ({
|
||||
market,
|
||||
marketPrice,
|
||||
side,
|
||||
size,
|
||||
price,
|
||||
timeInForce,
|
||||
triggerPrice,
|
||||
triggerType,
|
||||
type,
|
||||
}: Pick<
|
||||
OrderSubmissionBody['orderSubmission'],
|
||||
'side' | 'size' | 'timeInForce' | 'type' | 'price'
|
||||
> &
|
||||
Pick<StopOrderProps, 'market' | 'marketPrice'> &
|
||||
Pick<StopOrderFormValues, 'triggerType' | 'triggerPrice'>) => {
|
||||
const { quoteName, settlementAsset: asset } =
|
||||
market.tradableInstrument.instrument.product;
|
||||
const isPriceTrigger = triggerType === 'price';
|
||||
const derivedPrice = getDerivedPrice(
|
||||
{
|
||||
type,
|
||||
price,
|
||||
},
|
||||
type === Schema.OrderType.TYPE_MARKET && isPriceTrigger && triggerPrice
|
||||
? removeDecimal(triggerPrice, market.decimalPlaces)
|
||||
: marketPrice || '0'
|
||||
);
|
||||
|
||||
const notionalSize = getNotionalSize(
|
||||
derivedPrice,
|
||||
size,
|
||||
market.decimalPlaces,
|
||||
market.positionDecimalPlaces
|
||||
);
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<KeyValue
|
||||
label={t('Notional')}
|
||||
value={formatValue(notionalSize, market.decimalPlaces)}
|
||||
formattedValue={formatValue(notionalSize, market.decimalPlaces)}
|
||||
symbol={quoteName}
|
||||
labelDescription={NOTIONAL_SIZE_TOOLTIP_TEXT(quoteName)}
|
||||
/>
|
||||
<DealTicketFeeDetails
|
||||
order={{
|
||||
marketId: market.id,
|
||||
price: derivedPrice,
|
||||
side,
|
||||
size,
|
||||
timeInForce,
|
||||
type,
|
||||
}}
|
||||
assetSymbol={asset.symbol}
|
||||
market={market}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const formatSizeAtPrice = ({
|
||||
assetUnit,
|
||||
decimalPlaces,
|
||||
positionDecimalPlaces,
|
||||
price,
|
||||
quoteName,
|
||||
side,
|
||||
size,
|
||||
type,
|
||||
}: Pick<StopOrderFormValues, 'price' | 'side' | 'size' | 'type'> & {
|
||||
assetUnit?: string;
|
||||
decimalPlaces: number;
|
||||
positionDecimalPlaces: number;
|
||||
quoteName: string;
|
||||
}) =>
|
||||
`${formatValue(
|
||||
removeDecimal(size, positionDecimalPlaces),
|
||||
positionDecimalPlaces
|
||||
)} ${assetUnit} @ ${
|
||||
type === Schema.OrderType.TYPE_MARKET
|
||||
? 'market'
|
||||
: `${formatValue(
|
||||
removeDecimal(price || '0', decimalPlaces),
|
||||
decimalPlaces
|
||||
)} ${quoteName}`
|
||||
}`;
|
||||
const formatTrigger = ({
|
||||
decimalPlaces,
|
||||
triggerDirection,
|
||||
triggerPrice,
|
||||
triggerTrailingPercentOffset,
|
||||
triggerType,
|
||||
quoteName,
|
||||
}: Pick<
|
||||
StopOrderFormValues,
|
||||
| 'triggerDirection'
|
||||
| 'triggerType'
|
||||
| 'triggerPrice'
|
||||
| 'triggerTrailingPercentOffset'
|
||||
> & {
|
||||
decimalPlaces: number;
|
||||
quoteName: string;
|
||||
}) =>
|
||||
`${
|
||||
triggerDirection ===
|
||||
Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_RISES_ABOVE
|
||||
? t('above')
|
||||
: t('below')
|
||||
} ${
|
||||
triggerType === 'price'
|
||||
? `${formatValue(
|
||||
removeDecimal(triggerPrice || '', decimalPlaces),
|
||||
decimalPlaces
|
||||
)} ${quoteName}`
|
||||
: `${(Number(triggerTrailingPercentOffset) || 0).toFixed(1)}% ${t(
|
||||
'trailing'
|
||||
)}`
|
||||
}`;
|
||||
|
||||
const SubmitButton = ({
|
||||
assetUnit,
|
||||
market,
|
||||
oco,
|
||||
ocoPrice,
|
||||
ocoSize,
|
||||
ocoTriggerPrice,
|
||||
ocoTriggerTrailingPercentOffset,
|
||||
ocoTriggerType,
|
||||
ocoType,
|
||||
price,
|
||||
side,
|
||||
size,
|
||||
triggerDirection,
|
||||
triggerPrice,
|
||||
triggerTrailingPercentOffset,
|
||||
triggerType,
|
||||
type,
|
||||
}: Pick<
|
||||
StopOrderFormValues,
|
||||
| 'oco'
|
||||
| 'ocoPrice'
|
||||
| 'ocoSize'
|
||||
| 'ocoTriggerPrice'
|
||||
| 'ocoTriggerTrailingPercentOffset'
|
||||
| 'ocoTriggerType'
|
||||
| 'ocoType'
|
||||
| 'price'
|
||||
| 'side'
|
||||
| 'size'
|
||||
| 'triggerDirection'
|
||||
| 'triggerPrice'
|
||||
| 'triggerTrailingPercentOffset'
|
||||
| 'triggerType'
|
||||
| 'type'
|
||||
> &
|
||||
Pick<StopOrderProps, 'market'> & { assetUnit?: string }) => {
|
||||
const { quoteName } = market.tradableInstrument.instrument.product;
|
||||
const risesAbove =
|
||||
triggerDirection ===
|
||||
Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_RISES_ABOVE;
|
||||
const subLabel = oco ? (
|
||||
<>
|
||||
{formatSizeAtPrice({
|
||||
assetUnit,
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
positionDecimalPlaces: market.positionDecimalPlaces,
|
||||
price: risesAbove ? price : ocoPrice,
|
||||
quoteName,
|
||||
side,
|
||||
size: risesAbove ? size : ocoSize,
|
||||
type,
|
||||
})}{' '}
|
||||
{formatTrigger({
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
quoteName,
|
||||
triggerDirection:
|
||||
Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_RISES_ABOVE,
|
||||
triggerPrice: risesAbove ? triggerPrice : ocoTriggerPrice,
|
||||
triggerTrailingPercentOffset: risesAbove
|
||||
? triggerTrailingPercentOffset
|
||||
: ocoTriggerTrailingPercentOffset,
|
||||
triggerType: risesAbove ? triggerType : ocoTriggerType,
|
||||
})}
|
||||
<br />
|
||||
{formatSizeAtPrice({
|
||||
assetUnit,
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
positionDecimalPlaces: market.positionDecimalPlaces,
|
||||
price: !risesAbove ? price : ocoPrice,
|
||||
quoteName,
|
||||
side,
|
||||
size: !risesAbove ? size : ocoSize,
|
||||
type: ocoType,
|
||||
})}{' '}
|
||||
{formatTrigger({
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
quoteName,
|
||||
triggerDirection:
|
||||
Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_FALLS_BELOW,
|
||||
triggerPrice: !risesAbove ? triggerPrice : ocoTriggerPrice,
|
||||
triggerTrailingPercentOffset: !risesAbove
|
||||
? triggerTrailingPercentOffset
|
||||
: ocoTriggerTrailingPercentOffset,
|
||||
triggerType: !risesAbove ? triggerType : ocoTriggerType,
|
||||
})}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{formatSizeAtPrice({
|
||||
assetUnit,
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
positionDecimalPlaces: market.positionDecimalPlaces,
|
||||
price,
|
||||
quoteName,
|
||||
side,
|
||||
size,
|
||||
type,
|
||||
})}
|
||||
<br />
|
||||
{t('Trigger')}{' '}
|
||||
{formatTrigger({
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
quoteName,
|
||||
triggerDirection,
|
||||
triggerPrice,
|
||||
triggerTrailingPercentOffset,
|
||||
triggerType,
|
||||
})}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<Button
|
||||
intent={side === Schema.Side.SIDE_BUY ? Intent.Success : Intent.Danger}
|
||||
data-testid="place-order"
|
||||
type="submit"
|
||||
className="w-full"
|
||||
subLabel={subLabel}
|
||||
>
|
||||
{t(
|
||||
oco
|
||||
? 'Place OCO stop order'
|
||||
: type === Schema.OrderType.TYPE_MARKET
|
||||
? 'Place market stop order'
|
||||
: 'Place limit stop order'
|
||||
)}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
const { pubKey, isReadOnly } = useVegaWallet();
|
||||
const setType = useDealTicketFormValues((state) => state.setType);
|
||||
@@ -521,50 +781,40 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
},
|
||||
[market.id, market.decimalPlaces, market.positionDecimalPlaces, submit]
|
||||
);
|
||||
const side = watch('side');
|
||||
const expire = watch('expire');
|
||||
const triggerType = watch('triggerType');
|
||||
const triggerPrice = watch('triggerPrice');
|
||||
const timeInForce = watch('timeInForce');
|
||||
const rawPrice = watch('price');
|
||||
const rawSize = watch('size');
|
||||
const oco = watch('oco');
|
||||
const expiresAt = watch('expiresAt');
|
||||
|
||||
useEffect(() => {
|
||||
const size = storedFormValues?.[dealTicketType]?.size;
|
||||
if (size && rawSize !== size) {
|
||||
setValue('size', size);
|
||||
}
|
||||
}, [storedFormValues, dealTicketType, rawSize, setValue]);
|
||||
|
||||
useEffect(() => {
|
||||
const price = storedFormValues?.[dealTicketType]?.price;
|
||||
if (price && rawPrice !== price) {
|
||||
setValue('price', price);
|
||||
}
|
||||
}, [storedFormValues, dealTicketType, rawPrice, setValue]);
|
||||
|
||||
const isPriceTrigger = triggerType === 'price';
|
||||
const size = removeDecimal(rawSize, market.positionDecimalPlaces);
|
||||
const price =
|
||||
marketPrice &&
|
||||
getDerivedPrice(
|
||||
{
|
||||
type,
|
||||
price: rawPrice && removeDecimal(rawPrice, market.decimalPlaces),
|
||||
},
|
||||
type === Schema.OrderType.TYPE_MARKET && isPriceTrigger && triggerPrice
|
||||
? removeDecimal(triggerPrice, market.decimalPlaces)
|
||||
: marketPrice
|
||||
);
|
||||
|
||||
const notionalSize = getNotionalSize(
|
||||
price,
|
||||
size,
|
||||
market.decimalPlaces,
|
||||
market.positionDecimalPlaces
|
||||
const oco = watch('oco');
|
||||
const ocoPrice = watch('ocoPrice');
|
||||
const ocoSize = watch('ocoSize');
|
||||
const ocoTimeInForce = watch('ocoTimeInForce');
|
||||
const ocoTriggerPrice = watch('ocoTriggerPrice');
|
||||
const ocoTriggerTrailingPercentOffset = watch(
|
||||
'ocoTriggerTrailingPercentOffset'
|
||||
);
|
||||
const ocoTriggerType = watch('ocoTriggerType');
|
||||
const ocoType = watch('ocoType');
|
||||
const price = watch('price');
|
||||
const side = watch('side');
|
||||
const size = watch('size');
|
||||
const timeInForce = watch('timeInForce');
|
||||
const triggerDirection = watch('triggerDirection');
|
||||
const triggerPrice = watch('triggerPrice');
|
||||
const triggerTrailingPercentOffset = watch('triggerTrailingPercentOffset');
|
||||
const triggerType = watch('triggerType');
|
||||
|
||||
useEffect(() => {
|
||||
const storedSize = storedFormValues?.[dealTicketType]?.size;
|
||||
if (storedSize && size !== storedSize) {
|
||||
setValue('size', storedSize);
|
||||
}
|
||||
}, [storedFormValues, dealTicketType, size, setValue]);
|
||||
|
||||
useEffect(() => {
|
||||
const storedPrice = storedFormValues?.[dealTicketType]?.price;
|
||||
if (storedPrice && price !== storedPrice) {
|
||||
setValue('price', storedPrice);
|
||||
}
|
||||
}, [storedFormValues, dealTicketType, price, setValue]);
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = watch((value, { name, type }) => {
|
||||
@@ -573,8 +823,10 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
return () => subscription.unsubscribe();
|
||||
}, [watch, market.id, updateStoredFormValues]);
|
||||
|
||||
const { quoteName, settlementAsset: asset } =
|
||||
market.tradableInstrument.instrument.product;
|
||||
const { quoteName } = market.tradableInstrument.instrument.product;
|
||||
const assetUnit = getAssetUnit(
|
||||
market.tradableInstrument.instrument.metadata.tags
|
||||
);
|
||||
|
||||
const sizeStep = toDecimal(market?.positionDecimalPlaces);
|
||||
const priceStep = toDecimal(market?.decimalPlaces);
|
||||
@@ -584,6 +836,10 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
control,
|
||||
});
|
||||
|
||||
const normalizedPrice = price && removeDecimal(price, market.decimalPlaces);
|
||||
const normalizedSize =
|
||||
size && removeDecimal(size, market.positionDecimalPlaces);
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={isReadOnly || !pubKey ? stopSubmit : handleSubmit(onSubmit)}
|
||||
@@ -620,18 +876,34 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
control={control}
|
||||
watch={watch}
|
||||
priceStep={priceStep}
|
||||
assetSymbol={asset.symbol}
|
||||
quoteName={quoteName}
|
||||
marketPrice={marketPrice}
|
||||
decimalPlaces={market.decimalPlaces}
|
||||
/>
|
||||
<hr className="mb-4 border-vega-clight-500 dark:border-vega-cdark-500" />
|
||||
<Size
|
||||
control={control}
|
||||
sizeStep={sizeStep}
|
||||
isLimitType={type === Schema.OrderType.TYPE_LIMIT}
|
||||
assetUnit={assetUnit}
|
||||
/>
|
||||
<Price
|
||||
control={control}
|
||||
watch={watch}
|
||||
priceStep={priceStep}
|
||||
quoteName={quoteName}
|
||||
/>
|
||||
<Size control={control} sizeStep={sizeStep} />
|
||||
<NotionalAndFees
|
||||
market={market}
|
||||
marketPrice={marketPrice}
|
||||
price={normalizedPrice}
|
||||
side={side}
|
||||
size={normalizedSize}
|
||||
timeInForce={timeInForce}
|
||||
triggerPrice={triggerPrice}
|
||||
triggerType={triggerType}
|
||||
type={type}
|
||||
/>
|
||||
<TimeInForce control={control} />
|
||||
<div className="flex justify-end pb-3 gap-2">
|
||||
<ReduceOnly />
|
||||
@@ -682,12 +954,12 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
>
|
||||
<Radio
|
||||
value={Schema.OrderType.TYPE_MARKET}
|
||||
id={`ocoTypeMarket`}
|
||||
id="ocoTypeMarket"
|
||||
label={'Market'}
|
||||
/>
|
||||
<Radio
|
||||
value={Schema.OrderType.TYPE_LIMIT}
|
||||
id={`ocoTypeLimit`}
|
||||
id="ocoTypeLimit"
|
||||
label={'Limit'}
|
||||
/>
|
||||
</RadioGroup>
|
||||
@@ -699,12 +971,19 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
control={control}
|
||||
watch={watch}
|
||||
priceStep={priceStep}
|
||||
assetSymbol={asset.symbol}
|
||||
quoteName={quoteName}
|
||||
marketPrice={marketPrice}
|
||||
decimalPlaces={market.decimalPlaces}
|
||||
oco
|
||||
/>
|
||||
<hr className="mb-2 border-vega-clight-500 dark:border-vega-cdark-500" />
|
||||
<Size
|
||||
control={control}
|
||||
sizeStep={sizeStep}
|
||||
assetUnit={assetUnit}
|
||||
oco
|
||||
isLimitType={ocoType === Schema.OrderType.TYPE_LIMIT}
|
||||
/>
|
||||
<Price
|
||||
control={control}
|
||||
watch={watch}
|
||||
@@ -712,7 +991,19 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
quoteName={quoteName}
|
||||
oco
|
||||
/>
|
||||
<Size control={control} sizeStep={sizeStep} oco />
|
||||
<NotionalAndFees
|
||||
market={market}
|
||||
marketPrice={marketPrice}
|
||||
price={ocoPrice && removeDecimal(ocoPrice, market.decimalPlaces)}
|
||||
side={side}
|
||||
size={
|
||||
ocoSize && removeDecimal(ocoSize, market.positionDecimalPlaces)
|
||||
}
|
||||
timeInForce={ocoTimeInForce}
|
||||
triggerPrice={ocoTriggerPrice}
|
||||
triggerType={ocoTriggerType}
|
||||
type={ocoType}
|
||||
/>
|
||||
<TimeInForce control={control} oco />
|
||||
<div className="flex justify-end mb-2 gap-2">
|
||||
<ReduceOnly />
|
||||
@@ -728,11 +1019,12 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
return (
|
||||
<Checkbox
|
||||
onCheckedChange={(value) => {
|
||||
const now = Date.now();
|
||||
if (
|
||||
value &&
|
||||
(!expiresAt || new Date(expiresAt).getTime() < Date.now())
|
||||
(!expiresAt || new Date(expiresAt).getTime() < now)
|
||||
) {
|
||||
setValue('expiresAt', formatForInput(new Date()), {
|
||||
setValue('expiresAt', formatForInput(new Date(now)), {
|
||||
shouldValidate: true,
|
||||
});
|
||||
}
|
||||
@@ -803,19 +1095,24 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
|
||||
</>
|
||||
)}
|
||||
<NoWalletWarning isReadOnly={isReadOnly} />
|
||||
<DealTicketButton side={side} label={t('Submit Stop Order')} />
|
||||
<DealTicketFeeDetails
|
||||
order={{
|
||||
marketId: market.id,
|
||||
price: price || undefined,
|
||||
side,
|
||||
size,
|
||||
timeInForce,
|
||||
type,
|
||||
}}
|
||||
notionalSize={notionalSize}
|
||||
assetSymbol={asset.symbol}
|
||||
<SubmitButton
|
||||
assetUnit={assetUnit}
|
||||
market={market}
|
||||
oco={oco}
|
||||
ocoPrice={ocoPrice}
|
||||
ocoSize={ocoSize}
|
||||
ocoTriggerPrice={ocoTriggerPrice}
|
||||
ocoTriggerTrailingPercentOffset={ocoTriggerTrailingPercentOffset}
|
||||
ocoTriggerType={ocoTriggerType}
|
||||
ocoType={ocoType}
|
||||
price={price}
|
||||
side={side}
|
||||
size={size}
|
||||
triggerDirection={triggerDirection}
|
||||
triggerPrice={triggerPrice}
|
||||
triggerTrailingPercentOffset={triggerTrailingPercentOffset}
|
||||
triggerType={triggerType}
|
||||
type={type}
|
||||
/>
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
import { act, render, screen, waitFor } from '@testing-library/react';
|
||||
import {
|
||||
act,
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
} from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { generateMarket, generateMarketData } from '../../test-helpers';
|
||||
import { DealTicket } from './deal-ticket';
|
||||
@@ -14,6 +20,7 @@ import {
|
||||
} from '../../hooks/use-form-values';
|
||||
import * as positionsTools from '@vegaprotocol/positions';
|
||||
import { OrdersDocument } from '@vegaprotocol/orders';
|
||||
import { formatForInput } from '@vegaprotocol/utils';
|
||||
|
||||
jest.mock('zustand');
|
||||
jest.mock('./deal-ticket-fee-details', () => ({
|
||||
@@ -314,7 +321,7 @@ describe('DealTicket', () => {
|
||||
expect(screen.getByTestId('iceberg')).toBeChecked();
|
||||
});
|
||||
|
||||
it('should set values for a non-persistent iceberg order and disable post only checkbox', () => {
|
||||
it('should set values for a non-persistent order and disable post only checkbox', () => {
|
||||
const expectedOrder = {
|
||||
marketId: market.id,
|
||||
type: Schema.OrderType.TYPE_LIMIT,
|
||||
@@ -357,6 +364,7 @@ describe('DealTicket', () => {
|
||||
expect(screen.getByTestId('reduce-only')).not.toBeChecked();
|
||||
expect(screen.getByTestId('post-only')).not.toBeChecked();
|
||||
expect(screen.getByTestId('iceberg')).not.toBeChecked();
|
||||
expect(screen.getByTestId('iceberg')).toBeDisabled();
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
@@ -473,4 +481,150 @@ describe('DealTicket', () => {
|
||||
Object.keys(Schema.OrderTimeInForce).length
|
||||
);
|
||||
});
|
||||
|
||||
it('validates size field', async () => {
|
||||
render(generateJsx());
|
||||
const sizeErrorMessage = 'deal-ticket-error-message-size';
|
||||
const sizeInput = 'order-size';
|
||||
await userEvent.click(screen.getByTestId('place-order'));
|
||||
// default value should be invalid
|
||||
expect(screen.getByTestId(sizeErrorMessage)).toBeInTheDocument();
|
||||
// to small value should be invalid
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '0.01');
|
||||
expect(screen.getByTestId(sizeErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// clear and fill using valid value
|
||||
await userEvent.clear(screen.getByTestId(sizeInput));
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '0.1');
|
||||
expect(screen.queryByTestId(sizeErrorMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('validates price field', async () => {
|
||||
const priceErrorMessage = 'deal-ticket-error-message-price';
|
||||
const priceInput = 'order-price';
|
||||
const submitButton = 'place-order';
|
||||
const orderTypeMarket = 'order-type-Market';
|
||||
const orderTypeLimit = 'order-type-Limit';
|
||||
render(generateJsx());
|
||||
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
await userEvent.type(screen.getByTestId(priceInput), '0.001');
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// switch to market order type error should disappear
|
||||
await userEvent.click(screen.getByTestId(orderTypeMarket));
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
expect(screen.queryByTestId(priceErrorMessage)).toBeNull();
|
||||
|
||||
// switch back to limit type
|
||||
await userEvent.click(screen.getByTestId(orderTypeLimit));
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// to small value should be invalid
|
||||
await userEvent.type(screen.getByTestId(priceInput), '0.001');
|
||||
expect(screen.getByTestId(priceErrorMessage)).toBeInTheDocument();
|
||||
|
||||
// clear and fill using valid value
|
||||
await userEvent.clear(screen.getByTestId(priceInput));
|
||||
await userEvent.type(screen.getByTestId(priceInput), '0.01');
|
||||
expect(screen.queryByTestId(priceErrorMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('validates iceberg field', async () => {
|
||||
const peakSizeErrorMessage = 'deal-ticket-peak-error-message';
|
||||
const minimumSizeErrorMessage = 'deal-ticket-minimum-error-message';
|
||||
const sizeInput = 'order-size';
|
||||
const peakSizeInput = 'order-peak-size';
|
||||
const minimumSizeInput = 'order-minimum-size';
|
||||
const submitButton = 'place-order';
|
||||
|
||||
render(generateJsx());
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('order-tif'),
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GFA
|
||||
);
|
||||
await userEvent.click(screen.getByTestId('iceberg'));
|
||||
await userEvent.click(screen.getByTestId(submitButton));
|
||||
|
||||
// validate empty fields
|
||||
expect(screen.getByTestId(peakSizeErrorMessage)).toBeInTheDocument();
|
||||
expect(screen.getByTestId(minimumSizeErrorMessage)).toBeInTheDocument();
|
||||
|
||||
await userEvent.type(screen.getByTestId(peakSizeInput), '0.01');
|
||||
await userEvent.type(screen.getByTestId(minimumSizeInput), '0.01');
|
||||
|
||||
// validate value smaller than step
|
||||
expect(screen.getByTestId(peakSizeErrorMessage)).toBeInTheDocument();
|
||||
expect(screen.getByTestId(minimumSizeErrorMessage)).toBeInTheDocument();
|
||||
|
||||
await userEvent.clear(screen.getByTestId(peakSizeInput));
|
||||
await userEvent.type(screen.getByTestId(peakSizeInput), '0.5');
|
||||
await userEvent.clear(screen.getByTestId(minimumSizeInput));
|
||||
await userEvent.type(screen.getByTestId(minimumSizeInput), '0.7');
|
||||
|
||||
await userEvent.clear(screen.getByTestId(sizeInput));
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '0.1');
|
||||
|
||||
// validate value higher than size
|
||||
expect(screen.getByTestId(peakSizeErrorMessage)).toBeInTheDocument();
|
||||
expect(screen.getByTestId(minimumSizeErrorMessage)).toBeInTheDocument();
|
||||
|
||||
await userEvent.clear(screen.getByTestId(sizeInput));
|
||||
await userEvent.type(screen.getByTestId(sizeInput), '1');
|
||||
// validate peak higher than minimum
|
||||
expect(screen.queryByTestId(peakSizeErrorMessage)).toBeNull();
|
||||
expect(screen.getByTestId(minimumSizeErrorMessage)).toBeInTheDocument();
|
||||
|
||||
await userEvent.clear(screen.getByTestId(peakSizeInput));
|
||||
await userEvent.type(screen.getByTestId(peakSizeInput), '1');
|
||||
await userEvent.clear(screen.getByTestId(minimumSizeInput));
|
||||
await userEvent.type(screen.getByTestId(minimumSizeInput), '1');
|
||||
|
||||
// validate correct values
|
||||
expect(screen.queryByTestId(peakSizeErrorMessage)).toBeNull();
|
||||
expect(screen.queryByTestId(minimumSizeErrorMessage)).toBeNull();
|
||||
});
|
||||
|
||||
it('sets expiry time/date to now if expiry is changed to checked', async () => {
|
||||
const datePicker = 'date-picker-field';
|
||||
const now = Math.round(Date.now() / 1000) * 1000;
|
||||
render(generateJsx());
|
||||
jest.spyOn(global.Date, 'now').mockImplementationOnce(() => now);
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('order-tif'),
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GTT
|
||||
);
|
||||
|
||||
// expiry time/date was empty it should be set to now
|
||||
expect(
|
||||
new Date(screen.getByTestId<HTMLInputElement>(datePicker).value).getTime()
|
||||
).toEqual(now);
|
||||
|
||||
// set to the value in the past (now - 1s)
|
||||
fireEvent.change(screen.getByTestId<HTMLInputElement>(datePicker), {
|
||||
target: { value: formatForInput(new Date(now - 1000)) },
|
||||
});
|
||||
expect(
|
||||
new Date(
|
||||
screen.getByTestId<HTMLInputElement>(datePicker).value
|
||||
).getTime() + 1000
|
||||
).toEqual(now);
|
||||
|
||||
// switch expiry off and on
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('order-tif'),
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GFA
|
||||
);
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('order-tif'),
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GTT
|
||||
);
|
||||
// expiry time/date was in the past it should be set to now
|
||||
expect(
|
||||
new Date(screen.getByTestId<HTMLInputElement>(datePicker).value).getTime()
|
||||
).toEqual(now);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@ import * as Schema from '@vegaprotocol/types';
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { memo, useCallback, useEffect, useRef, useMemo } from 'react';
|
||||
import { Controller, useController, useForm } from 'react-hook-form';
|
||||
import { DealTicketButton } from './deal-ticket-button';
|
||||
import {
|
||||
DealTicketFeeDetails,
|
||||
DealTicketMarginDetails,
|
||||
@@ -23,6 +22,8 @@ import {
|
||||
Intent,
|
||||
Notification,
|
||||
Tooltip,
|
||||
TradingButton as Button,
|
||||
Pill,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
|
||||
import {
|
||||
@@ -35,6 +36,7 @@ import {
|
||||
validateAmount,
|
||||
toDecimal,
|
||||
formatForInput,
|
||||
formatValue,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { activeOrdersProvider } from '@vegaprotocol/orders';
|
||||
import { getDerivedPrice } from '@vegaprotocol/markets';
|
||||
@@ -46,7 +48,10 @@ import {
|
||||
validateType,
|
||||
} from '../../utils';
|
||||
import { ZeroBalanceError } from '../deal-ticket-validation/zero-balance-error';
|
||||
import { SummaryValidationType } from '../../constants';
|
||||
import {
|
||||
NOTIONAL_SIZE_TOOLTIP_TEXT,
|
||||
SummaryValidationType,
|
||||
} from '../../constants';
|
||||
import type {
|
||||
Market,
|
||||
MarketData,
|
||||
@@ -68,6 +73,7 @@ import { useDealTicketFormValues } from '../../hooks/use-form-values';
|
||||
import { DealTicketSizeIceberg } from './deal-ticket-size-iceberg';
|
||||
import noop from 'lodash/noop';
|
||||
import { isNonPersistentOrder } from '../../utils/time-in-force-persistance';
|
||||
import { KeyValue } from './key-value';
|
||||
|
||||
export const REDUCE_ONLY_TOOLTIP =
|
||||
'"Reduce only" will ensure that this order will not increase the size of an open position. When the order is matched, it will only trade enough volume to bring your open volume towards 0 but never change the direction of your position. If applied to a limit order that is not instantly filled, the order will be stopped.';
|
||||
@@ -118,6 +124,11 @@ const getDefaultValues = (
|
||||
...storedValues,
|
||||
});
|
||||
|
||||
export const getAssetUnit = (tags?: string[] | null) =>
|
||||
tags
|
||||
?.find((tag) => tag.startsWith('base:') || tag.startsWith('ticker:'))
|
||||
?.replace(/^[^:]*:/, '');
|
||||
|
||||
export const DealTicket = ({
|
||||
market,
|
||||
onMarketClick,
|
||||
@@ -257,6 +268,10 @@ export const DealTicket = ({
|
||||
const assetSymbol =
|
||||
market.tradableInstrument.instrument.product.settlementAsset.symbol;
|
||||
|
||||
const assetUnit = getAssetUnit(
|
||||
market.tradableInstrument.instrument.metadata.tags
|
||||
);
|
||||
|
||||
const summaryError = useMemo(() => {
|
||||
if (!pubKey) {
|
||||
return {
|
||||
@@ -338,6 +353,7 @@ export const DealTicket = ({
|
||||
const priceStep = toDecimal(market?.decimalPlaces);
|
||||
const sizeStep = toDecimal(market?.positionDecimalPlaces);
|
||||
const quoteName = market.tradableInstrument.instrument.product.quoteName;
|
||||
const isLimitType = type === Schema.OrderType.TYPE_LIMIT;
|
||||
|
||||
return (
|
||||
<form
|
||||
@@ -384,18 +400,16 @@ export const DealTicket = ({
|
||||
message: t('Size cannot be lower than ' + sizeStep),
|
||||
},
|
||||
validate: validateAmount(sizeStep, 'Size'),
|
||||
deps: ['peakSize', 'minimumVisibleSize'],
|
||||
}}
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="mb-4">
|
||||
<FormGroup
|
||||
label={t('Size')}
|
||||
labelFor="input-order-size-limit"
|
||||
compact
|
||||
>
|
||||
<div className={isLimitType ? 'mb-4' : 'mb-2'}>
|
||||
<FormGroup label={t('Size')} labelFor="order-size" compact>
|
||||
<Input
|
||||
id="input-order-size-limit"
|
||||
id="order-size"
|
||||
className="w-full"
|
||||
type="number"
|
||||
appendElement={assetUnit && <Pill size="xs">{assetUnit}</Pill>}
|
||||
step={sizeStep}
|
||||
min={sizeStep}
|
||||
data-testid="order-size"
|
||||
@@ -411,7 +425,7 @@ export const DealTicket = ({
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
{type === Schema.OrderType.TYPE_LIMIT && (
|
||||
{isLimitType && (
|
||||
<Controller
|
||||
name="price"
|
||||
control={control}
|
||||
@@ -424,14 +438,15 @@ export const DealTicket = ({
|
||||
validate: validateAmount(priceStep, 'Price'),
|
||||
}}
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="mb-4">
|
||||
<div className="mb-2">
|
||||
<FormGroup
|
||||
labelFor="input-price-quote"
|
||||
label={t(`Price (${quoteName})`)}
|
||||
label={t('Price')}
|
||||
compact
|
||||
>
|
||||
<Input
|
||||
id="input-price-quote"
|
||||
appendElement={<Pill size="xs">{quoteName}</Pill>}
|
||||
className="w-full"
|
||||
type="number"
|
||||
step={priceStep}
|
||||
@@ -449,6 +464,22 @@ export const DealTicket = ({
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<div className="mb-4">
|
||||
<KeyValue
|
||||
label={t('Notional')}
|
||||
value={formatValue(notionalSize, market.decimalPlaces)}
|
||||
formattedValue={formatValue(notionalSize, market.decimalPlaces)}
|
||||
symbol={quoteName}
|
||||
labelDescription={NOTIONAL_SIZE_TOOLTIP_TEXT(quoteName)}
|
||||
/>
|
||||
<DealTicketFeeDetails
|
||||
order={
|
||||
normalizedOrder && { ...normalizedOrder, price: price || undefined }
|
||||
}
|
||||
assetSymbol={assetSymbol}
|
||||
market={market}
|
||||
/>
|
||||
</div>
|
||||
<Controller
|
||||
name="timeInForce"
|
||||
control={control}
|
||||
@@ -475,7 +506,7 @@ export const DealTicket = ({
|
||||
}
|
||||
|
||||
// iceberg orders must be persistent orders, so if user
|
||||
// switches to to a non persisten tif value, remove iceberg selection
|
||||
// switches to a non persistent tif value, remove iceberg selection
|
||||
if (iceberg && isNonPersistentOrder(value)) {
|
||||
setValue('iceberg', false);
|
||||
}
|
||||
@@ -487,7 +518,7 @@ export const DealTicket = ({
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{type === Schema.OrderType.TYPE_LIMIT &&
|
||||
{isLimitType &&
|
||||
timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT && (
|
||||
<Controller
|
||||
name="expiresAt"
|
||||
@@ -569,7 +600,7 @@ export const DealTicket = ({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
{type === Schema.OrderType.TYPE_LIMIT && (
|
||||
{isLimitType && (
|
||||
<>
|
||||
<div className="flex justify-between pb-2 gap-2">
|
||||
<Controller
|
||||
@@ -624,15 +655,29 @@ export const DealTicket = ({
|
||||
pubKey={pubKey}
|
||||
onDeposit={onDeposit}
|
||||
/>
|
||||
<DealTicketButton side={side} />
|
||||
<DealTicketFeeDetails
|
||||
order={
|
||||
normalizedOrder && { ...normalizedOrder, price: price || undefined }
|
||||
}
|
||||
notionalSize={notionalSize}
|
||||
assetSymbol={assetSymbol}
|
||||
market={market}
|
||||
/>
|
||||
<Button
|
||||
data-testid="place-order"
|
||||
type="submit"
|
||||
className="w-full"
|
||||
intent={side === Schema.Side.SIDE_BUY ? Intent.Success : Intent.Danger}
|
||||
subLabel={`${formatValue(
|
||||
normalizedOrder.size,
|
||||
market.positionDecimalPlaces
|
||||
)} ${assetUnit} @ ${
|
||||
type === Schema.OrderType.TYPE_MARKET
|
||||
? 'market'
|
||||
: `${formatValue(
|
||||
normalizedOrder.price,
|
||||
market.decimalPlaces
|
||||
)} ${quoteName}`
|
||||
}`}
|
||||
>
|
||||
{t(
|
||||
type === Schema.OrderType.TYPE_MARKET
|
||||
? 'Place market order'
|
||||
: 'Place limit order'
|
||||
)}
|
||||
</Button>
|
||||
<DealTicketMarginDetails
|
||||
onMarketClick={onMarketClick}
|
||||
assetSymbol={assetSymbol}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import classnames from 'classnames';
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
export interface KeyValuePros {
|
||||
label: string;
|
||||
value?: string | null | undefined;
|
||||
symbol: string;
|
||||
indent?: boolean | undefined;
|
||||
labelDescription?: ReactNode;
|
||||
formattedValue?: string;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export const KeyValue = ({
|
||||
label,
|
||||
value,
|
||||
labelDescription,
|
||||
symbol,
|
||||
indent,
|
||||
onClick,
|
||||
formattedValue,
|
||||
}: KeyValuePros) => {
|
||||
const displayValue = `${formattedValue ?? '-'} ${symbol || ''}`;
|
||||
const valueElement = onClick ? (
|
||||
<button onClick={onClick} className="text-muted">
|
||||
{displayValue}
|
||||
</button>
|
||||
) : (
|
||||
<div className="text-muted">{displayValue}</div>
|
||||
);
|
||||
return (
|
||||
<div
|
||||
data-testid={
|
||||
'deal-ticket-fee-' + label.toLocaleLowerCase().replace(/\s/g, '-')
|
||||
}
|
||||
key={typeof label === 'string' ? label : 'value-dropdown'}
|
||||
className={classnames(
|
||||
'text-xs mt-2 flex justify-between items-center gap-4 flex-wrap',
|
||||
{ 'ml-2': indent }
|
||||
)}
|
||||
>
|
||||
<Tooltip description={labelDescription}>
|
||||
<div>{label}</div>
|
||||
</Tooltip>
|
||||
<Tooltip description={`${value ?? '-'} ${symbol || ''}`}>
|
||||
{valueElement}
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -80,13 +80,14 @@ const getAffixElement = ({
|
||||
appendIconName,
|
||||
appendIconDescription,
|
||||
}: Pick<TradingInputProps, keyof AffixProps>) => {
|
||||
const position = prependIconName || prependElement ? 'pre' : 'post';
|
||||
|
||||
const className = classNames(
|
||||
['fill-black dark:fill-white', 'absolute', 'z-10'],
|
||||
'absolute z-10 top-0 bottom-0 flex items-center',
|
||||
{
|
||||
'left-3': position === 'pre',
|
||||
'right-3': position === 'post',
|
||||
'fill-black dark:fill-white': prependIconName || appendIconName,
|
||||
'left-3': prependIconName,
|
||||
'right-3': appendIconName,
|
||||
'left-1': prependElement,
|
||||
'right-1': appendElement,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -161,7 +162,7 @@ export const TradingInput = forwardRef<HTMLInputElement, TradingInputProps>(
|
||||
|
||||
if (element) {
|
||||
return (
|
||||
<div className="flex items-center relative">
|
||||
<div className="relative">
|
||||
{hasPrepended && element}
|
||||
{input}
|
||||
{hasAppended && element}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"name": "@vegaprotocol/wallet",
|
||||
"version": "0.0.1"
|
||||
"version": "0.0.1",
|
||||
"peerDependencies": {
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
"tsConfig": "libs/wallet/tsconfig.lib.json",
|
||||
"project": "libs/wallet/package.json",
|
||||
"entryFile": "libs/wallet/src/index.ts",
|
||||
"external": ["react/jsx-runtime"],
|
||||
"external": ["react", "react-dom", "react/jsx-runtime"],
|
||||
"rollupConfig": "@nx/react/plugins/bundle-rollup",
|
||||
"compiler": "babel",
|
||||
"format": ["esm", "cjs"],
|
||||
"assets": [
|
||||
{
|
||||
"glob": "libs/wallet/README.md",
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
export const ChromeIcon = () => {
|
||||
return (
|
||||
<svg
|
||||
width="28"
|
||||
height="28"
|
||||
viewBox="0 0 32 32"
|
||||
fill="none"
|
||||
data-testid="chrome-logo"
|
||||
>
|
||||
<g clipPath="url(#clip0_3681_24659)">
|
||||
<path
|
||||
d="M15.9987 9.99963L26.3893 9.99964C25.3364 8.17534 23.8217 6.6604 21.9976 5.60716C20.1735 4.55391 18.1042 3.99949 15.9979 3.99964C13.8915 3.99979 11.8223 4.5545 9.99837 5.608C8.1744 6.66149 6.65995 8.17664 5.6073 10.0011L10.8026 18.9996L10.8072 18.9984C10.2787 18.0871 9.99984 17.0525 9.99865 15.999C9.99747 14.9454 10.274 13.9102 10.8005 12.9977C11.3269 12.0851 12.0847 11.3275 12.9973 10.8011C13.9099 10.2748 14.9451 9.99832 15.9987 9.99963Z"
|
||||
fill="url(#paint0_linear_3681_24659)"
|
||||
/>
|
||||
<path
|
||||
d="M21.1974 18.9989L16.0021 27.9974C18.1084 27.9977 20.1777 27.4435 22.0019 26.3904C23.8261 25.3373 25.3409 23.8224 26.3939 21.9982C27.447 20.174 28.0012 18.1047 28.0008 15.9983C28.0004 13.892 27.4455 11.8228 26.3918 9.99898L16.0012 9.99899L15.9999 10.0036C17.0534 10.0016 18.0889 10.2773 19.0018 10.8031C19.9148 11.3288 20.673 12.0859 21.2001 12.9981C21.7272 13.9103 22.0044 14.9454 22.004 15.9989C22.0035 17.0524 21.7253 18.0872 21.1974 18.9989Z"
|
||||
fill="url(#paint1_linear_3681_24659)"
|
||||
/>
|
||||
<path
|
||||
d="M10.8044 19.0016L5.60914 10.0031C4.5557 11.8271 4.00106 13.8963 4.00098 16.0026C4.0009 18.109 4.55539 20.1782 5.60869 22.0023C6.66199 23.8264 8.17698 25.341 10.0013 26.3938C11.8257 27.4467 13.895 28.0007 16.0014 28.0001L21.1967 19.0015L21.1933 18.9981C20.6683 19.9115 19.9118 20.6703 19 21.1981C18.0882 21.7259 17.0534 22.004 15.9999 22.0043C14.9464 22.0047 13.9114 21.7273 12.9992 21.2001C12.0871 20.6729 11.3301 19.9146 10.8044 19.0016Z"
|
||||
fill="url(#paint2_linear_3681_24659)"
|
||||
/>
|
||||
<path
|
||||
d="M16 22C19.3137 22 22 19.3137 22 16C22 12.6863 19.3137 10 16 10C12.6863 10 10 12.6863 10 16C10 19.3137 12.6863 22 16 22Z"
|
||||
fill="white"
|
||||
/>
|
||||
<path
|
||||
d="M16 20.75C18.6234 20.75 20.75 18.6234 20.75 16C20.75 13.3766 18.6234 11.25 16 11.25C13.3766 11.25 11.25 13.3766 11.25 16C11.25 18.6234 13.3766 20.75 16 20.75Z"
|
||||
fill="#1A73E8"
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="paint0_linear_3681_24659"
|
||||
x1="25.093"
|
||||
y1="9.25084"
|
||||
x2="14.702"
|
||||
y2="27.2485"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#D93025" />
|
||||
<stop offset="1" stopColor="#EA4335" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="paint1_linear_3681_24659"
|
||||
x1="27.073"
|
||||
y1="11.4997"
|
||||
x2="6.29104"
|
||||
y2="11.4997"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#FCC934" />
|
||||
<stop offset="1" stopColor="#FBBC04" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="paint2_linear_3681_24659"
|
||||
x1="17.2992"
|
||||
y1="27.2508"
|
||||
x2="6.90819"
|
||||
y2="9.25305"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#1E8E3E" />
|
||||
<stop offset="1" stopColor="#34A853" />
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_3681_24659">
|
||||
<rect
|
||||
width="24"
|
||||
height="24"
|
||||
fill="white"
|
||||
transform="translate(4 4)"
|
||||
/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ExternalLinks, useEnvironment } from '@vegaprotocol/environment';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import {
|
||||
ExternalLink,
|
||||
@@ -7,12 +6,15 @@ import {
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import classNames from 'classnames';
|
||||
import type { ReactNode } from 'react';
|
||||
import { MozillaIcon } from './mozilla-icon';
|
||||
import { ChromeIcon } from './chrome-icon';
|
||||
import { useVegaWallet } from '../use-vega-wallet';
|
||||
|
||||
export const ConnectDialogTitle = ({ children }: { children: ReactNode }) => {
|
||||
return (
|
||||
<h1
|
||||
data-testid="wallet-dialog-title"
|
||||
className="text-2xl uppercase mb-6 font-alpha calt"
|
||||
className="mb-6 text-2xl uppercase font-alpha calt"
|
||||
>
|
||||
{children}
|
||||
</h1>
|
||||
@@ -24,6 +26,7 @@ export const ConnectDialogContent = ({ children }: { children: ReactNode }) => {
|
||||
};
|
||||
|
||||
export const ConnectDialogFooter = () => {
|
||||
const { links } = useVegaWallet();
|
||||
const wrapperClasses = classNames(
|
||||
'flex justify-center gap-4 mt-4',
|
||||
'px-4 md:px-8 pt-4 md:pt-6',
|
||||
@@ -32,335 +35,37 @@ export const ConnectDialogFooter = () => {
|
||||
);
|
||||
return (
|
||||
<footer className={wrapperClasses}>
|
||||
<ExternalLink
|
||||
href={ExternalLinks.VEGA_WALLET_URL_ABOUT}
|
||||
className="underline"
|
||||
>
|
||||
<ExternalLink href={links.about} className="underline">
|
||||
{t('About the Vega wallet')}{' '}
|
||||
<VegaIcon name={VegaIconNames.ARROW_TOP_RIGHT} />
|
||||
</ExternalLink>
|
||||
{ExternalLinks.VEGA_WALLET_BROWSER_LIST && (
|
||||
<>
|
||||
{' | '}
|
||||
<ExternalLink
|
||||
href={ExternalLinks.VEGA_WALLET_BROWSER_LIST}
|
||||
className="underline"
|
||||
>
|
||||
{t('Supported browsers')}{' '}
|
||||
<VegaIcon name={VegaIconNames.ARROW_TOP_RIGHT} />
|
||||
</ExternalLink>
|
||||
</>
|
||||
)}
|
||||
{' | '}
|
||||
<ExternalLink href={links.browserList} className="underline">
|
||||
{t('Supported browsers')}{' '}
|
||||
<VegaIcon name={VegaIconNames.ARROW_TOP_RIGHT} />
|
||||
</ExternalLink>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export const ChromeIcon = () => {
|
||||
return (
|
||||
<svg
|
||||
width="28"
|
||||
height="28"
|
||||
viewBox="0 0 32 32"
|
||||
fill="none"
|
||||
data-testid="chrome-logo"
|
||||
>
|
||||
<g clipPath="url(#clip0_3681_24659)">
|
||||
<path
|
||||
d="M15.9987 9.99963L26.3893 9.99964C25.3364 8.17534 23.8217 6.6604 21.9976 5.60716C20.1735 4.55391 18.1042 3.99949 15.9979 3.99964C13.8915 3.99979 11.8223 4.5545 9.99837 5.608C8.1744 6.66149 6.65995 8.17664 5.6073 10.0011L10.8026 18.9996L10.8072 18.9984C10.2787 18.0871 9.99984 17.0525 9.99865 15.999C9.99747 14.9454 10.274 13.9102 10.8005 12.9977C11.3269 12.0851 12.0847 11.3275 12.9973 10.8011C13.9099 10.2748 14.9451 9.99832 15.9987 9.99963Z"
|
||||
fill="url(#paint0_linear_3681_24659)"
|
||||
/>
|
||||
<path
|
||||
d="M21.1974 18.9989L16.0021 27.9974C18.1084 27.9977 20.1777 27.4435 22.0019 26.3904C23.8261 25.3373 25.3409 23.8224 26.3939 21.9982C27.447 20.174 28.0012 18.1047 28.0008 15.9983C28.0004 13.892 27.4455 11.8228 26.3918 9.99898L16.0012 9.99899L15.9999 10.0036C17.0534 10.0016 18.0889 10.2773 19.0018 10.8031C19.9148 11.3288 20.673 12.0859 21.2001 12.9981C21.7272 13.9103 22.0044 14.9454 22.004 15.9989C22.0035 17.0524 21.7253 18.0872 21.1974 18.9989Z"
|
||||
fill="url(#paint1_linear_3681_24659)"
|
||||
/>
|
||||
<path
|
||||
d="M10.8044 19.0016L5.60914 10.0031C4.5557 11.8271 4.00106 13.8963 4.00098 16.0026C4.0009 18.109 4.55539 20.1782 5.60869 22.0023C6.66199 23.8264 8.17698 25.341 10.0013 26.3938C11.8257 27.4467 13.895 28.0007 16.0014 28.0001L21.1967 19.0015L21.1933 18.9981C20.6683 19.9115 19.9118 20.6703 19 21.1981C18.0882 21.7259 17.0534 22.004 15.9999 22.0043C14.9464 22.0047 13.9114 21.7273 12.9992 21.2001C12.0871 20.6729 11.3301 19.9146 10.8044 19.0016Z"
|
||||
fill="url(#paint2_linear_3681_24659)"
|
||||
/>
|
||||
<path
|
||||
d="M16 22C19.3137 22 22 19.3137 22 16C22 12.6863 19.3137 10 16 10C12.6863 10 10 12.6863 10 16C10 19.3137 12.6863 22 16 22Z"
|
||||
fill="white"
|
||||
/>
|
||||
<path
|
||||
d="M16 20.75C18.6234 20.75 20.75 18.6234 20.75 16C20.75 13.3766 18.6234 11.25 16 11.25C13.3766 11.25 11.25 13.3766 11.25 16C11.25 18.6234 13.3766 20.75 16 20.75Z"
|
||||
fill="#1A73E8"
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="paint0_linear_3681_24659"
|
||||
x1="25.093"
|
||||
y1="9.25084"
|
||||
x2="14.702"
|
||||
y2="27.2485"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#D93025" />
|
||||
<stop offset="1" stopColor="#EA4335" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="paint1_linear_3681_24659"
|
||||
x1="27.073"
|
||||
y1="11.4997"
|
||||
x2="6.29104"
|
||||
y2="11.4997"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#FCC934" />
|
||||
<stop offset="1" stopColor="#FBBC04" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="paint2_linear_3681_24659"
|
||||
x1="17.2992"
|
||||
y1="27.2508"
|
||||
x2="6.90819"
|
||||
y2="9.25305"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#1E8E3E" />
|
||||
<stop offset="1" stopColor="#34A853" />
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_3681_24659">
|
||||
<rect
|
||||
width="24"
|
||||
height="24"
|
||||
fill="white"
|
||||
transform="translate(4 4)"
|
||||
/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
export const MozillaIcon = () => {
|
||||
return (
|
||||
<svg
|
||||
width="22"
|
||||
height="22"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
data-testid="mozilla-logo"
|
||||
>
|
||||
<g clipPath="url(#clip0_3681_24667)">
|
||||
<path
|
||||
d="M22.4398 7.79786C21.9502 6.62017 20.9585 5.34873 20.1798 4.94687C20.8136 6.1893 21.1804 7.43561 21.3205 8.36575C21.3205 8.36758 21.3212 8.37212 21.3227 8.3845C20.0489 5.20951 17.889 3.92926 16.1252 1.1417C16.0361 1.00075 15.9468 0.85942 15.8598 0.710452C15.8155 0.634372 15.7742 0.556628 15.7358 0.477389C15.6625 0.335913 15.606 0.186371 15.5674 0.0317953C15.5676 0.0244774 15.5652 0.017323 15.5604 0.0117374C15.5557 0.00615177 15.549 0.00253868 15.5418 0.00160783C15.5349 -0.000373182 15.5275 -0.000373182 15.5206 0.00160783C15.519 0.00217033 15.5167 0.00399845 15.515 0.0046547C15.5125 0.00563908 15.5094 0.00788908 15.5068 0.0093422C15.508 0.0076547 15.5107 0.00385783 15.5115 0.0029672C12.6816 1.66028 11.7216 4.72614 11.6334 6.26003C10.5034 6.33772 9.42293 6.75406 8.53298 7.45478C8.43981 7.37608 8.3424 7.30253 8.24119 7.23447C7.98442 6.33615 7.97351 5.38538 8.20959 4.4814C7.05234 5.00833 6.15225 5.84125 5.49787 6.57672H5.49267C5.04609 6.01108 5.07759 4.14517 5.10305 3.75559C5.0977 3.73145 4.76991 3.92575 4.72697 3.95505C4.3329 4.23633 3.96449 4.55194 3.62606 4.89817C3.24095 5.28871 2.88907 5.71069 2.57409 6.15972C2.57409 6.16028 2.57377 6.16094 2.57358 6.1615C2.57358 6.16089 2.57391 6.16028 2.57409 6.15972C1.8497 7.18625 1.33595 8.34618 1.06252 9.57245C1.05712 9.59687 1.05258 9.62219 1.04733 9.6468C1.02614 9.74598 0.949828 10.2421 0.936469 10.3499C0.935438 10.3582 0.934969 10.3662 0.933984 10.3745C0.835324 10.8874 0.774224 11.4069 0.751172 11.9287C0.751172 11.9479 0.75 11.967 0.75 11.9862C0.750187 18.2072 5.79394 23.2501 12.0154 23.2501C17.5872 23.2501 22.2135 19.2053 23.1192 13.8924C23.1383 13.7482 23.1536 13.6033 23.1704 13.4578C23.3943 11.5261 23.1456 9.49572 22.4398 7.79786ZM9.45562 16.6148C9.50831 16.6399 9.55781 16.6675 9.61191 16.6916C9.61416 16.6931 9.61725 16.6949 9.61955 16.6963C9.56449 16.67 9.50984 16.6428 9.45562 16.6148ZM21.3236 8.38726L21.3221 8.37634C21.3227 8.38033 21.3234 8.3845 21.324 8.38848L21.3236 8.38726Z"
|
||||
fill="url(#paint0_linear_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M22.4397 7.79776C21.9501 6.62007 20.9584 5.34864 20.1797 4.94678C20.8135 6.1892 21.1803 7.43551 21.3204 8.36565C21.3204 8.36293 21.321 8.3679 21.3221 8.37625C21.3227 8.38023 21.3234 8.3844 21.324 8.38839C22.3869 11.2698 21.8078 14.1999 20.9734 15.9903C19.6825 18.7607 16.5571 21.5999 11.6652 21.4614C6.37978 21.3117 1.7235 17.39 0.854297 12.2536C0.695906 11.4436 0.854297 11.0323 0.933984 10.3746C0.836906 10.8816 0.799922 11.0281 0.751172 11.9289C0.751172 11.9481 0.75 11.9671 0.75 11.9864C0.750094 18.2071 5.79384 23.25 12.0153 23.25C17.5871 23.25 22.2134 19.2052 23.1191 13.8923C23.1382 13.7481 23.1535 13.6032 23.1703 13.4577C23.3942 11.526 23.1455 9.49562 22.4397 7.79776Z"
|
||||
fill="url(#paint1_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M22.4397 7.79776C21.9501 6.62007 20.9584 5.34864 20.1797 4.94678C20.8135 6.1892 21.1803 7.43551 21.3204 8.36565C21.3204 8.36293 21.321 8.3679 21.3221 8.37625C21.3227 8.38023 21.3234 8.3844 21.324 8.38839C22.3869 11.2698 21.8078 14.1999 20.9734 15.9903C19.6825 18.7607 16.5571 21.5999 11.6652 21.4614C6.37978 21.3117 1.7235 17.39 0.854297 12.2536C0.695906 11.4436 0.854297 11.0323 0.933984 10.3746C0.836906 10.8816 0.799922 11.0281 0.751172 11.9289C0.751172 11.9481 0.75 11.9671 0.75 11.9864C0.750094 18.2071 5.79384 23.25 12.0153 23.25C17.5871 23.25 22.2134 19.2052 23.1191 13.8923C23.1382 13.7481 23.1535 13.6032 23.1703 13.4577C23.3942 11.526 23.1455 9.49562 22.4397 7.79776Z"
|
||||
fill="url(#paint2_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M16.965 9.12184C16.9896 9.13909 17.0119 9.15625 17.035 9.1734C16.7523 8.67164 16.4002 8.21224 15.9892 7.80878C12.4874 4.3074 15.071 0.216811 15.5067 0.00906055C15.5079 0.00737305 15.5106 0.00357617 15.5114 0.00268555C12.6815 1.66 11.7215 4.72586 11.6333 6.25975C11.7646 6.25065 11.8954 6.23964 12.029 6.23964C14.1408 6.23964 15.9801 7.40073 16.965 9.12184Z"
|
||||
fill="url(#paint3_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M12.0361 9.82097C12.0176 10.1012 11.0276 11.0675 10.6814 11.0675C7.47799 11.0675 6.95801 13.0051 6.95801 13.0051C7.0999 14.6368 8.23587 15.9805 9.61165 16.6915C9.67441 16.7239 9.73793 16.7532 9.80149 16.7822C9.91047 16.8304 10.0208 16.8756 10.1324 16.9175C10.6041 17.0845 11.0982 17.1798 11.5982 17.2002C17.2129 17.4635 18.3007 10.488 14.2488 8.4623C15.2864 8.28183 16.3635 8.69916 16.965 9.12169C15.9801 7.40072 14.1408 6.23962 12.0291 6.23962C11.8955 6.23962 11.7647 6.25064 11.6334 6.25973C10.5033 6.33742 9.42291 6.75376 8.53296 7.45448C8.70471 7.5998 8.89859 7.79405 9.30705 8.19642C10.0712 8.94956 12.0319 9.72947 12.0361 9.82097Z"
|
||||
fill="url(#paint4_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M12.0361 9.82097C12.0176 10.1012 11.0276 11.0675 10.6814 11.0675C7.47799 11.0675 6.95801 13.0051 6.95801 13.0051C7.0999 14.6368 8.23587 15.9805 9.61165 16.6915C9.67441 16.7239 9.73793 16.7532 9.80149 16.7822C9.91047 16.8304 10.0208 16.8756 10.1324 16.9175C10.6041 17.0845 11.0982 17.1798 11.5982 17.2002C17.2129 17.4635 18.3007 10.488 14.2488 8.4623C15.2864 8.28183 16.3635 8.69916 16.965 9.12169C15.9801 7.40072 14.1408 6.23962 12.0291 6.23962C11.8955 6.23962 11.7647 6.25064 11.6334 6.25973C10.5033 6.33742 9.42291 6.75376 8.53296 7.45448C8.70471 7.5998 8.89859 7.79405 9.30705 8.19642C10.0712 8.94956 12.0319 9.72947 12.0361 9.82097Z"
|
||||
fill="url(#paint5_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M8.00739 7.07982C8.08584 7.13043 8.16368 7.18199 8.24087 7.23451C7.98411 6.33619 7.97319 5.38542 8.20928 4.48145C7.05203 5.00837 6.15193 5.84129 5.49756 6.57676C5.5517 6.57521 7.18571 6.54582 8.00739 7.07982Z"
|
||||
fill="url(#paint6_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M0.853976 12.2536C1.72318 17.3901 6.37946 21.3118 11.6649 21.4614C16.5568 21.5999 19.6822 18.7605 20.9731 15.9904C21.8075 14.1997 22.3866 11.2701 21.3237 8.38842L21.3233 8.3872L21.3218 8.37628C21.3206 8.36793 21.3199 8.36296 21.3201 8.36568C21.3201 8.36751 21.3208 8.37206 21.3223 8.38443C21.7219 10.9935 20.3947 13.5212 18.3199 15.2302L18.3137 15.2449C14.271 18.5366 10.4024 17.2309 9.61913 16.6964C9.56408 16.67 9.50939 16.6427 9.45507 16.6147C7.0981 15.4884 6.12441 13.3411 6.3332 11.4996C4.34302 11.4996 3.66441 9.82101 3.66441 9.82101C3.66441 9.82101 5.45124 8.54699 7.8062 9.65503C9.98729 10.6813 12.0356 9.8211 12.0359 9.82101C12.0317 9.72951 10.071 8.9496 9.30667 8.19651C8.89824 7.79414 8.70432 7.60012 8.53257 7.45457C8.4394 7.37587 8.34198 7.30232 8.24077 7.23426C8.16349 7.18188 8.08566 7.13031 8.00729 7.07957C7.18566 6.54557 5.5516 6.57496 5.49746 6.57637H5.49226C5.04568 6.01073 5.07718 4.14482 5.10263 3.75524C5.09729 3.7311 4.76949 3.9254 4.72655 3.9547C4.33248 4.23598 3.96408 4.55159 3.62565 4.89782C3.24052 5.28846 2.88865 5.71053 2.57368 6.15965C2.57368 6.16021 2.57335 6.16087 2.57316 6.16143C2.57316 6.16082 2.57349 6.16021 2.57368 6.15965C1.84929 7.18619 1.33553 8.34611 1.0621 9.57238C1.05671 9.59681 0.656632 11.3462 0.853976 12.2536Z"
|
||||
fill="url(#paint7_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M15.9894 7.80883C16.4004 8.21229 16.7525 8.67169 17.0352 9.17345C17.0972 9.22005 17.1552 9.2665 17.2043 9.31183C19.7582 11.665 18.4201 14.9931 18.3203 15.2303C20.395 13.5212 21.7222 10.9936 21.3227 8.38445C20.0489 5.20951 17.8889 3.92926 16.1251 1.1417C16.0361 1.00075 15.9468 0.85942 15.8598 0.710452C15.8155 0.634372 15.7741 0.556628 15.7357 0.477389C15.6625 0.335913 15.6059 0.186371 15.5673 0.0317953C15.5676 0.0244774 15.5651 0.017323 15.5604 0.0117374C15.5556 0.00615177 15.549 0.00253868 15.5417 0.00160783C15.5348 -0.000373182 15.5275 -0.000373182 15.5206 0.00160783C15.519 0.00217033 15.5166 0.00399845 15.515 0.0046547C15.5125 0.00563908 15.5093 0.00788908 15.5067 0.0093422C15.0712 0.216905 12.4876 4.3075 15.9894 7.80883Z"
|
||||
fill="url(#paint8_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M17.2043 9.31181C17.1551 9.26648 17.0972 9.22003 17.0352 9.17343C17.0123 9.15618 16.9898 9.13903 16.9652 9.12187C16.3637 8.69934 15.2866 8.28201 14.2489 8.46248C18.3008 10.4881 17.2131 17.4637 11.5984 17.2004C11.0984 17.18 10.6043 17.0847 10.1326 16.9177C10.021 16.8757 9.91066 16.8306 9.80166 16.7824C9.7381 16.7534 9.67458 16.7241 9.61182 16.6917C9.61407 16.6932 9.61716 16.6949 9.61946 16.6964C10.4027 17.2307 14.2713 18.5365 18.314 15.2448L18.3202 15.2302C18.42 14.9932 19.7581 11.665 17.2043 9.31181Z"
|
||||
fill="url(#paint9_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M6.95794 13.0051C6.95794 13.0051 7.47793 11.0675 10.6813 11.0675C11.0276 11.0675 12.0177 10.1012 12.036 9.82096C12.0543 9.54074 9.98756 10.6812 7.80633 9.65497C5.45138 8.54694 3.66455 9.82096 3.66455 9.82096C3.66455 9.82096 4.34316 11.4995 6.33333 11.4995C6.1246 13.341 7.09828 15.4886 9.45521 16.6147C9.50789 16.6399 9.55739 16.6674 9.61149 16.6915C8.2358 15.9805 7.09983 14.6368 6.95794 13.0051Z"
|
||||
fill="url(#paint10_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M22.4396 7.79786C21.95 6.62017 20.9583 5.34873 20.1796 4.94687C20.8134 6.1893 21.1802 7.43561 21.3203 8.36575C21.3203 8.36758 21.321 8.37212 21.3225 8.3845C20.0487 5.20951 17.8888 3.92926 16.125 1.1417C16.0359 1.00075 15.9466 0.85942 15.8596 0.710452C15.8153 0.634372 15.774 0.556628 15.7356 0.477389C15.6623 0.335913 15.6058 0.186371 15.5672 0.0317953C15.5675 0.0244774 15.565 0.017323 15.5602 0.0117374C15.5555 0.00615177 15.5489 0.00253868 15.5416 0.00160783C15.5347 -0.000373182 15.5274 -0.000373182 15.5205 0.00160783C15.5189 0.00217033 15.5165 0.00399845 15.5148 0.0046547C15.5123 0.00563908 15.5092 0.00788908 15.5066 0.0093422C15.5078 0.0076547 15.5105 0.00385783 15.5113 0.0029672C12.6814 1.66028 11.7214 4.72614 11.6332 6.26003C11.7645 6.25094 11.8953 6.23992 12.0289 6.23992C14.1408 6.23992 15.9801 7.40101 16.9649 9.12198C16.3634 8.69945 15.2863 8.28212 14.2486 8.46259C18.3005 10.4882 17.2127 17.4638 11.598 17.2005C11.098 17.1801 10.6039 17.0848 10.1322 16.9178C10.0207 16.8758 9.91032 16.8307 9.80133 16.7825C9.73777 16.7535 9.67425 16.7242 9.61148 16.6918C9.61373 16.6933 9.61683 16.6951 9.61912 16.6965C9.56407 16.67 9.50938 16.6427 9.45506 16.6148C9.50775 16.6399 9.55725 16.6675 9.61134 16.6916C8.23556 15.9806 7.09959 14.6369 6.9577 13.0052C6.9577 13.0052 7.47769 11.0676 10.6811 11.0676C11.0274 11.0676 12.0174 10.1013 12.0358 9.82108C12.0316 9.72958 10.0709 8.94967 9.30656 8.19658C8.89814 7.7942 8.70422 7.60019 8.53247 7.45464C8.43929 7.37594 8.34188 7.30239 8.24067 7.23433C7.98391 6.33601 7.97299 5.38524 8.20908 4.48126C7.05183 5.00819 6.15173 5.84111 5.49736 6.57658H5.49216C5.04558 6.01094 5.07708 4.14503 5.10253 3.75545C5.09719 3.73131 4.76939 3.92561 4.72645 3.9549C4.33238 4.23619 3.96398 4.5518 3.62555 4.89803C3.24054 5.28863 2.88878 5.71066 2.57391 6.15972C2.57391 6.16028 2.57358 6.16094 2.57339 6.1615C2.57339 6.16089 2.57372 6.16028 2.57391 6.15972C1.84952 7.18625 1.33576 8.34618 1.06233 9.57245C1.05694 9.59687 1.05239 9.62219 1.04714 9.6468C1.02595 9.74598 0.930609 10.2493 0.917297 10.3572C0.916266 10.3655 0.918281 10.349 0.917297 10.3572C0.830351 10.8773 0.774875 11.4022 0.751172 11.929C0.751172 11.9482 0.75 11.9672 0.75 11.9865C0.75 18.2072 5.79375 23.2501 12.0152 23.2501C17.587 23.2501 22.2133 19.2053 23.119 13.8924C23.1381 13.7482 23.1534 13.6033 23.1702 13.4578C23.3941 11.5261 23.1454 9.49572 22.4396 7.79786ZM21.322 8.37634C21.3226 8.38033 21.3233 8.3845 21.3239 8.38848L21.3235 8.38726L21.322 8.37634Z"
|
||||
fill="url(#paint11_linear_3681_24667)"
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="paint0_linear_3681_24667"
|
||||
x1="20.3814"
|
||||
y1="3.60386"
|
||||
x2="2.29295"
|
||||
y2="21.0528"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop offset="0.05" stopColor="#FFF44F" />
|
||||
<stop offset="0.37" stopColor="#FF980E" />
|
||||
<stop offset="0.53" stopColor="#FF3647" />
|
||||
<stop offset="0.7" stopColor="#E31587" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id="paint1_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(16.3404 2.59171) scale(23.0401 23.4281)"
|
||||
>
|
||||
<stop offset="0.13" stopColor="#FFBD4F" />
|
||||
<stop offset="0.28" stopColor="#FF980E" />
|
||||
<stop offset="0.47" stopColor="#FF3750" />
|
||||
<stop offset="0.78" stopColor="#EB0878" />
|
||||
<stop offset="0.86" stopColor="#E50080" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint2_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(9.65968 12.2681) scale(23.6161 23.4281)"
|
||||
>
|
||||
<stop offset="0.3" stopColor="#960E18" />
|
||||
<stop offset="0.35" stopColor="#B11927" stopOpacity="0.74" />
|
||||
<stop offset="0.43" stopColor="#DB293D" stopOpacity="0.34" />
|
||||
<stop offset="0.5" stopColor="#F5334B" stopOpacity="0.09" />
|
||||
<stop offset="0.53" stopColor="#FF3750" stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint3_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(14.2261 -1.0978) scale(7.56236 12.839)"
|
||||
>
|
||||
<stop offset="0.13" stopColor="#FFF44F" />
|
||||
<stop offset="0.53" stopColor="#FF980E" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint4_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(9.2356 18.3163) scale(10.007 10.9678)"
|
||||
>
|
||||
<stop offset="0.35" stopColor="#3A8EE6" />
|
||||
<stop offset="0.67" stopColor="#9059FF" />
|
||||
<stop offset="1" stopColor="#C139E6" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint5_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(10.9455 9.859) scale(5.31373 6.47101)"
|
||||
>
|
||||
<stop offset="0.21" stopColor="#9059FF" stopOpacity="0" />
|
||||
<stop offset="0.97" stopColor="#6E008B" stopOpacity="0.6" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint6_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(11.2585 1.72838) scale(7.95561 7.98388)"
|
||||
>
|
||||
<stop offset="0.1" stopColor="#FFE226" />
|
||||
<stop offset="0.79" stopColor="#FF7139" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint7_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(18.5242 -3.50921) scale(37.9818 31.8836)"
|
||||
>
|
||||
<stop offset="0.11" stopColor="#FFF44F" />
|
||||
<stop offset="0.46" stopColor="#FF980E" />
|
||||
<stop offset="0.72" stopColor="#FF3647" />
|
||||
<stop offset="0.9" stopColor="#E31587" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint8_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(4.41888 7.02007) rotate(77.3946) scale(12.0503 52.1278)"
|
||||
>
|
||||
<stop stopColor="#FFF44F" />
|
||||
<stop offset="0.3" stopColor="#FF980E" />
|
||||
<stop offset="0.57" stopColor="#FF3647" />
|
||||
<stop offset="0.74" stopColor="#E31587" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint9_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(11.3407 4.60001) scale(21.8071 21.424)"
|
||||
>
|
||||
<stop offset="0.14" stopColor="#FFF44F" />
|
||||
<stop offset="0.48" stopColor="#FF980E" />
|
||||
<stop offset="0.66" stopColor="#FF3647" />
|
||||
<stop offset="0.9" stopColor="#E31587" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint10_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(17.0005 5.8529) scale(26.2114 23.4492)"
|
||||
>
|
||||
<stop offset="0.09" stopColor="#FFF44F" />
|
||||
<stop offset="0.63" stopColor="#FF980E" />
|
||||
</radialGradient>
|
||||
<linearGradient
|
||||
id="paint11_linear_3681_24667"
|
||||
x1="18.75"
|
||||
y1="3.25511"
|
||||
x2="4.28552"
|
||||
y2="19.0592"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop offset="0.17" stopColor="#FFF44F" stopOpacity="0.8" />
|
||||
<stop offset="0.6" stopColor="#FFF44F" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_3681_24667">
|
||||
<rect width="24" height="24" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
export const BrowserIcon = () => {
|
||||
const { MOZILLA_EXTENSION_URL, CHROME_EXTENSION_URL } = useEnvironment();
|
||||
export const BrowserIcon = ({
|
||||
chromeExtensionUrl,
|
||||
mozillaExtensionUrl,
|
||||
}: {
|
||||
chromeExtensionUrl: string;
|
||||
mozillaExtensionUrl: string;
|
||||
}) => {
|
||||
const isItChrome = window.navigator.userAgent.includes('Chrome');
|
||||
const isItMozilla =
|
||||
window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
return (
|
||||
<div className="absolute right-1 top-0 h-8 flex items-center">
|
||||
<div className="absolute top-0 flex items-center h-8 right-1">
|
||||
{!isItChrome && !isItMozilla ? (
|
||||
<>
|
||||
<a href={MOZILLA_EXTENSION_URL} target="_blank" rel="noreferrer">
|
||||
<a href={mozillaExtensionUrl} target="_blank" rel="noreferrer">
|
||||
<MozillaIcon />
|
||||
</a>{' '}
|
||||
<a href={CHROME_EXTENSION_URL} target="_blank" rel="noreferrer">
|
||||
<a href={chromeExtensionUrl} target="_blank" rel="noreferrer">
|
||||
<ChromeIcon />
|
||||
</a>
|
||||
</>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { act, fireEvent, render, screen } from '@testing-library/react';
|
||||
import type { MockedResponse } from '@apollo/client/testing';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import type { VegaWalletConfig } from '../provider';
|
||||
import { VegaWalletProvider } from '../provider';
|
||||
import {
|
||||
VegaConnectDialog,
|
||||
CLOSE_DELAY,
|
||||
useVegaWalletDialogStore,
|
||||
} from './connect-dialog';
|
||||
import { VegaConnectDialog, CLOSE_DELAY } from './connect-dialog';
|
||||
import { useVegaWalletDialogStore } from './vega-wallet-dialog-store';
|
||||
import type { VegaConnectDialogProps } from '..';
|
||||
import {
|
||||
ClientErrors,
|
||||
@@ -15,7 +13,6 @@ import {
|
||||
ViewConnector,
|
||||
WalletError,
|
||||
} from '../connectors';
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import type { ChainIdQuery } from './__generated__/ChainId';
|
||||
import { ChainIdDocument } from './__generated__/ChainId';
|
||||
import {
|
||||
@@ -28,26 +25,14 @@ import {
|
||||
const mockUpdateDialogOpen = jest.fn();
|
||||
const mockCloseVegaDialog = jest.fn();
|
||||
|
||||
jest.mock('@vegaprotocol/environment');
|
||||
let mockIsDesktopRunning = true;
|
||||
|
||||
jest.mock('../use-is-wallet-service-running', () => ({
|
||||
useIsWalletServiceRunning: jest
|
||||
.fn()
|
||||
.mockImplementation(() => mockIsDesktopRunning),
|
||||
}));
|
||||
|
||||
// @ts-ignore ignore mock implementation
|
||||
useEnvironment.mockImplementation(() => ({
|
||||
VEGA_ENV: 'TESTNET',
|
||||
VEGA_URL: 'https://vega-node.url',
|
||||
VEGA_NETWORKS: JSON.stringify({}),
|
||||
VEGA_WALLET_URL: mockVegaWalletUrl,
|
||||
GIT_BRANCH: 'test',
|
||||
GIT_COMMIT_HASH: 'abcdef',
|
||||
GIT_ORIGIN_URL: 'https://github.com/test/repo',
|
||||
HOSTED_WALLET_URL: mockHostedWalletUrl,
|
||||
}));
|
||||
|
||||
let defaultProps: VegaConnectDialogProps;
|
||||
|
||||
const INITIAL_KEY = 'some-key';
|
||||
@@ -59,7 +44,9 @@ const connectors = {
|
||||
jsonRpc,
|
||||
view,
|
||||
injected,
|
||||
snap: undefined,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
defaultProps = {
|
||||
@@ -73,12 +60,24 @@ beforeEach(() => {
|
||||
});
|
||||
});
|
||||
|
||||
const mockVegaWalletUrl = 'http://mock.wallet.com';
|
||||
const mockHostedWalletUrl = 'http://mock.hosted.com';
|
||||
|
||||
const mockChainId = 'chain-id';
|
||||
|
||||
function generateJSX(props?: Partial<VegaConnectDialogProps>) {
|
||||
const defaultConfig: VegaWalletConfig = {
|
||||
network: 'TESTNET',
|
||||
vegaUrl: 'https://vega.xyz',
|
||||
vegaWalletServiceUrl: 'https://vegaservice.xyz',
|
||||
links: {
|
||||
explorer: 'explorer-link',
|
||||
concepts: 'concepts-link',
|
||||
chromeExtensionUrl: 'chrome-link',
|
||||
mozillaExtensionUrl: 'mozilla-link',
|
||||
},
|
||||
};
|
||||
|
||||
function generateJSX(
|
||||
props?: Partial<VegaConnectDialogProps>,
|
||||
config?: Partial<VegaWalletConfig>
|
||||
) {
|
||||
const chainIdMock: MockedResponse<ChainIdQuery> = {
|
||||
request: {
|
||||
query: ChainIdDocument,
|
||||
@@ -93,7 +92,7 @@ function generateJSX(props?: Partial<VegaConnectDialogProps>) {
|
||||
};
|
||||
return (
|
||||
<MockedProvider mocks={[chainIdMock]}>
|
||||
<VegaWalletProvider>
|
||||
<VegaWalletProvider config={{ ...defaultConfig, ...config }}>
|
||||
<VegaConnectDialog {...defaultProps} {...props} />
|
||||
</VegaWalletProvider>
|
||||
</MockedProvider>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import classNames from 'classnames';
|
||||
import { create } from 'zustand';
|
||||
import {
|
||||
Dialog,
|
||||
Intent,
|
||||
@@ -14,7 +13,7 @@ import type { ReactNode } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import type { WalletClientError } from '@vegaprotocol/wallet-client';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type { VegaConnector } from '../connectors';
|
||||
import type { Connectors, VegaConnector } from '../connectors';
|
||||
import {
|
||||
DEFAULT_SNAP_ID,
|
||||
InjectedConnector,
|
||||
@@ -25,7 +24,6 @@ import {
|
||||
} from '../connectors';
|
||||
import { JsonRpcConnectorForm } from './json-rpc-connector-form';
|
||||
import { ViewConnectorForm } from './view-connector-form';
|
||||
import { FLAGS, useEnvironment } from '@vegaprotocol/environment';
|
||||
import {
|
||||
BrowserIcon,
|
||||
ConnectDialogContent,
|
||||
@@ -42,9 +40,10 @@ import { InjectedConnectorForm } from './injected-connector-form';
|
||||
import { isBrowserWalletInstalled } from '../utils';
|
||||
import { useIsWalletServiceRunning } from '../use-is-wallet-service-running';
|
||||
import { useIsSnapRunning } from '../use-is-snap-running';
|
||||
import { useVegaWalletDialogStore } from './vega-wallet-dialog-store';
|
||||
|
||||
export const CLOSE_DELAY = 1700;
|
||||
type Connectors = { [key: string]: VegaConnector };
|
||||
|
||||
export type WalletType = 'injected' | 'jsonRpc' | 'view' | 'snap';
|
||||
|
||||
export interface VegaConnectDialogProps {
|
||||
@@ -52,23 +51,6 @@ export interface VegaConnectDialogProps {
|
||||
riskMessage?: ReactNode;
|
||||
}
|
||||
|
||||
export interface VegaWalletDialogStore {
|
||||
vegaWalletDialogOpen: boolean;
|
||||
updateVegaWalletDialog: (open: boolean) => void;
|
||||
openVegaWalletDialog: () => void;
|
||||
closeVegaWalletDialog: () => void;
|
||||
}
|
||||
|
||||
export const useVegaWalletDialogStore = create<VegaWalletDialogStore>()(
|
||||
(set) => ({
|
||||
vegaWalletDialogOpen: false,
|
||||
updateVegaWalletDialog: (open: boolean) =>
|
||||
set({ vegaWalletDialogOpen: open }),
|
||||
openVegaWalletDialog: () => set({ vegaWalletDialogOpen: true }),
|
||||
closeVegaWalletDialog: () => set({ vegaWalletDialogOpen: false }),
|
||||
})
|
||||
);
|
||||
|
||||
export const VegaConnectDialog = ({
|
||||
connectors,
|
||||
riskMessage,
|
||||
@@ -123,12 +105,12 @@ const ConnectDialogContainer = ({
|
||||
appChainId: string;
|
||||
riskMessage?: ReactNode;
|
||||
}) => {
|
||||
const { VEGA_WALLET_URL } = useEnvironment();
|
||||
const { vegaUrl, vegaWalletServiceUrl } = useVegaWallet();
|
||||
const closeDialog = useVegaWalletDialogStore(
|
||||
(store) => store.closeVegaWalletDialog
|
||||
);
|
||||
const [selectedConnector, setSelectedConnector] = useState<VegaConnector>();
|
||||
const [walletUrl, setWalletUrl] = useState(VEGA_WALLET_URL || '');
|
||||
const [walletUrl, setWalletUrl] = useState(vegaWalletServiceUrl);
|
||||
|
||||
const reset = useCallback(() => {
|
||||
setSelectedConnector(undefined);
|
||||
@@ -147,7 +129,6 @@ const ConnectDialogContainer = ({
|
||||
|
||||
const handleSelect = (type: WalletType) => {
|
||||
const connector = connectors[type];
|
||||
connector.url = walletUrl;
|
||||
|
||||
if (!connector) {
|
||||
// we should never get here unless connectors are not configured correctly
|
||||
@@ -159,21 +140,28 @@ const ConnectDialogContainer = ({
|
||||
// Immediately connect on selection if jsonRpc is selected, we can't do this
|
||||
// for rest because we need to show an authentication form
|
||||
if (connector instanceof JsonRpcConnector) {
|
||||
connector.url = walletUrl;
|
||||
jsonRpcConnect(connector, appChainId);
|
||||
} else if (
|
||||
connector instanceof InjectedConnector ||
|
||||
connector instanceof SnapConnector
|
||||
) {
|
||||
} else if (connector instanceof InjectedConnector) {
|
||||
injectedConnect(connector, appChainId);
|
||||
} else if (connector instanceof SnapConnector) {
|
||||
// Set the nodeAddress to send tx's to, normally this is handled by
|
||||
// the vega wallet
|
||||
connector.nodeAddress = new URL(vegaUrl).origin;
|
||||
injectedConnect(connector, appChainId);
|
||||
}
|
||||
};
|
||||
|
||||
const isDesktopWalletRunning = useIsWalletServiceRunning(
|
||||
walletUrl,
|
||||
connectors,
|
||||
connectors['jsonRpc'],
|
||||
appChainId
|
||||
);
|
||||
|
||||
const isSnapRunning = useIsSnapRunning(DEFAULT_SNAP_ID);
|
||||
const isSnapRunning = useIsSnapRunning(
|
||||
DEFAULT_SNAP_ID,
|
||||
Boolean(connectors['snap'])
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -190,6 +178,7 @@ const ConnectDialogContainer = ({
|
||||
/>
|
||||
) : (
|
||||
<ConnectorList
|
||||
connectors={connectors}
|
||||
walletUrl={walletUrl}
|
||||
setWalletUrl={setWalletUrl}
|
||||
onSelect={handleSelect}
|
||||
@@ -204,29 +193,34 @@ const ConnectDialogContainer = ({
|
||||
};
|
||||
|
||||
const ConnectorList = ({
|
||||
connectors,
|
||||
onSelect,
|
||||
walletUrl,
|
||||
setWalletUrl,
|
||||
isDesktopWalletRunning,
|
||||
isSnapRunning,
|
||||
}: {
|
||||
connectors: Connectors;
|
||||
onSelect: (type: WalletType) => void;
|
||||
walletUrl: string;
|
||||
setWalletUrl: (value: string) => void;
|
||||
isDesktopWalletRunning: boolean | null;
|
||||
isSnapRunning: boolean | null;
|
||||
}) => {
|
||||
const { pubKey } = useVegaWallet();
|
||||
const { pubKey, links } = useVegaWallet();
|
||||
const title = isBrowserWalletInstalled()
|
||||
? t('Connect Vega wallet')
|
||||
: t('Get a Vega wallet');
|
||||
|
||||
const extendedText = (
|
||||
<>
|
||||
<div className="w-full h-full flex justify-center items-center gap-1 text-base">
|
||||
<div className="flex items-center justify-center w-full h-full text-base gap-1">
|
||||
{t('Connect')}
|
||||
</div>
|
||||
<BrowserIcon />
|
||||
<BrowserIcon
|
||||
chromeExtensionUrl={links.chromeExtensionUrl}
|
||||
mozillaExtensionUrl={links.mozillaExtensionUrl}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -247,20 +241,23 @@ const ConnectorList = ({
|
||||
onClick={() => onSelect('injected')}
|
||||
/>
|
||||
) : (
|
||||
<GetWalletButton />
|
||||
<GetWalletButton
|
||||
chromeExtensionUrl={links.chromeExtensionUrl}
|
||||
mozillaExtensionUrl={links.mozillaExtensionUrl}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{FLAGS.METAMASK_SNAPS ? (
|
||||
{connectors['snap'] !== undefined ? (
|
||||
<div>
|
||||
{isSnapRunning ? (
|
||||
<ConnectionOption
|
||||
type="snap"
|
||||
text={
|
||||
<>
|
||||
<div className="w-full h-full flex justify-center items-center gap-1 text-base">
|
||||
<div className="flex items-center justify-center w-full h-full text-base gap-1">
|
||||
{t('Connect via Vega MetaMask Snap')}
|
||||
</div>
|
||||
<div className="absolute right-1 top-0 h-8 flex items-center">
|
||||
<div className="absolute top-0 flex items-center h-8 right-1">
|
||||
<VegaIcon name={VegaIconNames.METAMASK} size={24} />
|
||||
</div>
|
||||
</>
|
||||
@@ -274,10 +271,10 @@ const ConnectorList = ({
|
||||
type="snap"
|
||||
text={
|
||||
<>
|
||||
<div className="w-full h-full flex justify-center items-center gap-1 text-base">
|
||||
<div className="flex items-center justify-center w-full h-full text-base gap-1">
|
||||
{t('Install Vega MetaMask Snap')}
|
||||
</div>
|
||||
<div className="absolute right-1 top-0 h-8 flex items-center">
|
||||
<div className="absolute top-0 flex items-center h-8 right-1">
|
||||
<VegaIcon name={VegaIconNames.METAMASK} size={24} />
|
||||
</div>
|
||||
</>
|
||||
@@ -374,30 +371,43 @@ const SelectedForm = ({
|
||||
throw new Error('No connector selected');
|
||||
};
|
||||
|
||||
export const GetWalletButton = ({ className }: { className?: string }) => {
|
||||
const { MOZILLA_EXTENSION_URL, CHROME_EXTENSION_URL } = useEnvironment();
|
||||
export const GetWalletButton = ({
|
||||
chromeExtensionUrl,
|
||||
mozillaExtensionUrl,
|
||||
className,
|
||||
}: {
|
||||
chromeExtensionUrl?: string;
|
||||
mozillaExtensionUrl?: string;
|
||||
className?: string;
|
||||
}) => {
|
||||
const isItChrome = window.navigator.userAgent.includes('Chrome');
|
||||
const isItMozilla =
|
||||
window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
|
||||
const onClick = () => {
|
||||
if (isItMozilla) {
|
||||
window.open(MOZILLA_EXTENSION_URL, '_blank');
|
||||
window.open(mozillaExtensionUrl, '_blank');
|
||||
return;
|
||||
}
|
||||
if (isItChrome) {
|
||||
window.open(CHROME_EXTENSION_URL, '_blank');
|
||||
window.open(chromeExtensionUrl, '_blank');
|
||||
}
|
||||
};
|
||||
|
||||
const buttonContent = (
|
||||
<>
|
||||
<div className="flex items-center justify-center gap-1 text-base">
|
||||
<div className="flex items-center justify-center text-base gap-1">
|
||||
{t('Get the Vega Wallet')}
|
||||
<Pill size="xxs" intent={Intent.Info}>
|
||||
ALPHA
|
||||
</Pill>
|
||||
</div>
|
||||
<BrowserIcon />
|
||||
{chromeExtensionUrl && mozillaExtensionUrl && (
|
||||
<BrowserIcon
|
||||
chromeExtensionUrl={chromeExtensionUrl}
|
||||
mozillaExtensionUrl={mozillaExtensionUrl}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -452,7 +462,7 @@ const ConnectionOption = ({
|
||||
icon={icon}
|
||||
fill
|
||||
>
|
||||
<span className="flex justify-center items-center text-base">{text}</span>
|
||||
<span className="flex items-center justify-center text-base">{text}</span>
|
||||
</TradingButton>
|
||||
);
|
||||
};
|
||||
@@ -508,7 +518,7 @@ const CustomUrlInput = ({
|
||||
onClick={() => onSelect('jsonRpc')}
|
||||
/>
|
||||
{isDesktopWalletRunning !== null && (
|
||||
<p className="mb-6 text-sm pt-2">
|
||||
<p className="pt-2 mb-6 text-sm">
|
||||
{isDesktopWalletRunning ? (
|
||||
<button
|
||||
className="underline text-default"
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './connect-dialog';
|
||||
export * from './view-as-dialog';
|
||||
export * from './vega-wallet-dialog-store';
|
||||
|
||||
@@ -14,7 +14,6 @@ import type { JsonRpcConnector } from '../connectors';
|
||||
import { ClientErrors } from '../connectors';
|
||||
import { ConnectDialogTitle } from './connect-dialog-elements';
|
||||
import { Status } from '../use-json-rpc-connect';
|
||||
import { DocsLinks } from '@vegaprotocol/environment';
|
||||
import { useVegaWallet } from '../use-vega-wallet';
|
||||
import { setAcknowledged } from '../storage';
|
||||
|
||||
@@ -156,6 +155,7 @@ const Error = ({
|
||||
appChainId: string;
|
||||
onTryAgain: () => void;
|
||||
}) => {
|
||||
const { links } = useVegaWallet();
|
||||
let title = t('Something went wrong');
|
||||
let text: ReactNode | undefined = t('An unknown error occurred');
|
||||
let tryAgain: ReactNode | null = (
|
||||
@@ -182,11 +182,9 @@ const Error = ({
|
||||
<>
|
||||
{capitalize(error.message)}
|
||||
{'. '}
|
||||
{DocsLinks && (
|
||||
<Link href={DocsLinks.VEGA_WALLET_CONCEPTS_URL}>
|
||||
{t('Read the docs to troubleshoot')}
|
||||
</Link>
|
||||
)}
|
||||
<Link href={links.concepts}>
|
||||
{t('Read the docs to troubleshoot')}
|
||||
</Link>
|
||||
</>
|
||||
);
|
||||
} else if (error.code === ServiceErrors.REQUEST_PROCESSING) {
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
export const MozillaIcon = () => {
|
||||
return (
|
||||
<svg
|
||||
width="22"
|
||||
height="22"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
data-testid="mozilla-logo"
|
||||
>
|
||||
<g clipPath="url(#clip0_3681_24667)">
|
||||
<path
|
||||
d="M22.4398 7.79786C21.9502 6.62017 20.9585 5.34873 20.1798 4.94687C20.8136 6.1893 21.1804 7.43561 21.3205 8.36575C21.3205 8.36758 21.3212 8.37212 21.3227 8.3845C20.0489 5.20951 17.889 3.92926 16.1252 1.1417C16.0361 1.00075 15.9468 0.85942 15.8598 0.710452C15.8155 0.634372 15.7742 0.556628 15.7358 0.477389C15.6625 0.335913 15.606 0.186371 15.5674 0.0317953C15.5676 0.0244774 15.5652 0.017323 15.5604 0.0117374C15.5557 0.00615177 15.549 0.00253868 15.5418 0.00160783C15.5349 -0.000373182 15.5275 -0.000373182 15.5206 0.00160783C15.519 0.00217033 15.5167 0.00399845 15.515 0.0046547C15.5125 0.00563908 15.5094 0.00788908 15.5068 0.0093422C15.508 0.0076547 15.5107 0.00385783 15.5115 0.0029672C12.6816 1.66028 11.7216 4.72614 11.6334 6.26003C10.5034 6.33772 9.42293 6.75406 8.53298 7.45478C8.43981 7.37608 8.3424 7.30253 8.24119 7.23447C7.98442 6.33615 7.97351 5.38538 8.20959 4.4814C7.05234 5.00833 6.15225 5.84125 5.49787 6.57672H5.49267C5.04609 6.01108 5.07759 4.14517 5.10305 3.75559C5.0977 3.73145 4.76991 3.92575 4.72697 3.95505C4.3329 4.23633 3.96449 4.55194 3.62606 4.89817C3.24095 5.28871 2.88907 5.71069 2.57409 6.15972C2.57409 6.16028 2.57377 6.16094 2.57358 6.1615C2.57358 6.16089 2.57391 6.16028 2.57409 6.15972C1.8497 7.18625 1.33595 8.34618 1.06252 9.57245C1.05712 9.59687 1.05258 9.62219 1.04733 9.6468C1.02614 9.74598 0.949828 10.2421 0.936469 10.3499C0.935438 10.3582 0.934969 10.3662 0.933984 10.3745C0.835324 10.8874 0.774224 11.4069 0.751172 11.9287C0.751172 11.9479 0.75 11.967 0.75 11.9862C0.750187 18.2072 5.79394 23.2501 12.0154 23.2501C17.5872 23.2501 22.2135 19.2053 23.1192 13.8924C23.1383 13.7482 23.1536 13.6033 23.1704 13.4578C23.3943 11.5261 23.1456 9.49572 22.4398 7.79786ZM9.45562 16.6148C9.50831 16.6399 9.55781 16.6675 9.61191 16.6916C9.61416 16.6931 9.61725 16.6949 9.61955 16.6963C9.56449 16.67 9.50984 16.6428 9.45562 16.6148ZM21.3236 8.38726L21.3221 8.37634C21.3227 8.38033 21.3234 8.3845 21.324 8.38848L21.3236 8.38726Z"
|
||||
fill="url(#paint0_linear_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M22.4397 7.79776C21.9501 6.62007 20.9584 5.34864 20.1797 4.94678C20.8135 6.1892 21.1803 7.43551 21.3204 8.36565C21.3204 8.36293 21.321 8.3679 21.3221 8.37625C21.3227 8.38023 21.3234 8.3844 21.324 8.38839C22.3869 11.2698 21.8078 14.1999 20.9734 15.9903C19.6825 18.7607 16.5571 21.5999 11.6652 21.4614C6.37978 21.3117 1.7235 17.39 0.854297 12.2536C0.695906 11.4436 0.854297 11.0323 0.933984 10.3746C0.836906 10.8816 0.799922 11.0281 0.751172 11.9289C0.751172 11.9481 0.75 11.9671 0.75 11.9864C0.750094 18.2071 5.79384 23.25 12.0153 23.25C17.5871 23.25 22.2134 19.2052 23.1191 13.8923C23.1382 13.7481 23.1535 13.6032 23.1703 13.4577C23.3942 11.526 23.1455 9.49562 22.4397 7.79776Z"
|
||||
fill="url(#paint1_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M22.4397 7.79776C21.9501 6.62007 20.9584 5.34864 20.1797 4.94678C20.8135 6.1892 21.1803 7.43551 21.3204 8.36565C21.3204 8.36293 21.321 8.3679 21.3221 8.37625C21.3227 8.38023 21.3234 8.3844 21.324 8.38839C22.3869 11.2698 21.8078 14.1999 20.9734 15.9903C19.6825 18.7607 16.5571 21.5999 11.6652 21.4614C6.37978 21.3117 1.7235 17.39 0.854297 12.2536C0.695906 11.4436 0.854297 11.0323 0.933984 10.3746C0.836906 10.8816 0.799922 11.0281 0.751172 11.9289C0.751172 11.9481 0.75 11.9671 0.75 11.9864C0.750094 18.2071 5.79384 23.25 12.0153 23.25C17.5871 23.25 22.2134 19.2052 23.1191 13.8923C23.1382 13.7481 23.1535 13.6032 23.1703 13.4577C23.3942 11.526 23.1455 9.49562 22.4397 7.79776Z"
|
||||
fill="url(#paint2_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M16.965 9.12184C16.9896 9.13909 17.0119 9.15625 17.035 9.1734C16.7523 8.67164 16.4002 8.21224 15.9892 7.80878C12.4874 4.3074 15.071 0.216811 15.5067 0.00906055C15.5079 0.00737305 15.5106 0.00357617 15.5114 0.00268555C12.6815 1.66 11.7215 4.72586 11.6333 6.25975C11.7646 6.25065 11.8954 6.23964 12.029 6.23964C14.1408 6.23964 15.9801 7.40073 16.965 9.12184Z"
|
||||
fill="url(#paint3_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M12.0361 9.82097C12.0176 10.1012 11.0276 11.0675 10.6814 11.0675C7.47799 11.0675 6.95801 13.0051 6.95801 13.0051C7.0999 14.6368 8.23587 15.9805 9.61165 16.6915C9.67441 16.7239 9.73793 16.7532 9.80149 16.7822C9.91047 16.8304 10.0208 16.8756 10.1324 16.9175C10.6041 17.0845 11.0982 17.1798 11.5982 17.2002C17.2129 17.4635 18.3007 10.488 14.2488 8.4623C15.2864 8.28183 16.3635 8.69916 16.965 9.12169C15.9801 7.40072 14.1408 6.23962 12.0291 6.23962C11.8955 6.23962 11.7647 6.25064 11.6334 6.25973C10.5033 6.33742 9.42291 6.75376 8.53296 7.45448C8.70471 7.5998 8.89859 7.79405 9.30705 8.19642C10.0712 8.94956 12.0319 9.72947 12.0361 9.82097Z"
|
||||
fill="url(#paint4_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M12.0361 9.82097C12.0176 10.1012 11.0276 11.0675 10.6814 11.0675C7.47799 11.0675 6.95801 13.0051 6.95801 13.0051C7.0999 14.6368 8.23587 15.9805 9.61165 16.6915C9.67441 16.7239 9.73793 16.7532 9.80149 16.7822C9.91047 16.8304 10.0208 16.8756 10.1324 16.9175C10.6041 17.0845 11.0982 17.1798 11.5982 17.2002C17.2129 17.4635 18.3007 10.488 14.2488 8.4623C15.2864 8.28183 16.3635 8.69916 16.965 9.12169C15.9801 7.40072 14.1408 6.23962 12.0291 6.23962C11.8955 6.23962 11.7647 6.25064 11.6334 6.25973C10.5033 6.33742 9.42291 6.75376 8.53296 7.45448C8.70471 7.5998 8.89859 7.79405 9.30705 8.19642C10.0712 8.94956 12.0319 9.72947 12.0361 9.82097Z"
|
||||
fill="url(#paint5_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M8.00739 7.07982C8.08584 7.13043 8.16368 7.18199 8.24087 7.23451C7.98411 6.33619 7.97319 5.38542 8.20928 4.48145C7.05203 5.00837 6.15193 5.84129 5.49756 6.57676C5.5517 6.57521 7.18571 6.54582 8.00739 7.07982Z"
|
||||
fill="url(#paint6_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M0.853976 12.2536C1.72318 17.3901 6.37946 21.3118 11.6649 21.4614C16.5568 21.5999 19.6822 18.7605 20.9731 15.9904C21.8075 14.1997 22.3866 11.2701 21.3237 8.38842L21.3233 8.3872L21.3218 8.37628C21.3206 8.36793 21.3199 8.36296 21.3201 8.36568C21.3201 8.36751 21.3208 8.37206 21.3223 8.38443C21.7219 10.9935 20.3947 13.5212 18.3199 15.2302L18.3137 15.2449C14.271 18.5366 10.4024 17.2309 9.61913 16.6964C9.56408 16.67 9.50939 16.6427 9.45507 16.6147C7.0981 15.4884 6.12441 13.3411 6.3332 11.4996C4.34302 11.4996 3.66441 9.82101 3.66441 9.82101C3.66441 9.82101 5.45124 8.54699 7.8062 9.65503C9.98729 10.6813 12.0356 9.8211 12.0359 9.82101C12.0317 9.72951 10.071 8.9496 9.30667 8.19651C8.89824 7.79414 8.70432 7.60012 8.53257 7.45457C8.4394 7.37587 8.34198 7.30232 8.24077 7.23426C8.16349 7.18188 8.08566 7.13031 8.00729 7.07957C7.18566 6.54557 5.5516 6.57496 5.49746 6.57637H5.49226C5.04568 6.01073 5.07718 4.14482 5.10263 3.75524C5.09729 3.7311 4.76949 3.9254 4.72655 3.9547C4.33248 4.23598 3.96408 4.55159 3.62565 4.89782C3.24052 5.28846 2.88865 5.71053 2.57368 6.15965C2.57368 6.16021 2.57335 6.16087 2.57316 6.16143C2.57316 6.16082 2.57349 6.16021 2.57368 6.15965C1.84929 7.18619 1.33553 8.34611 1.0621 9.57238C1.05671 9.59681 0.656632 11.3462 0.853976 12.2536Z"
|
||||
fill="url(#paint7_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M15.9894 7.80883C16.4004 8.21229 16.7525 8.67169 17.0352 9.17345C17.0972 9.22005 17.1552 9.2665 17.2043 9.31183C19.7582 11.665 18.4201 14.9931 18.3203 15.2303C20.395 13.5212 21.7222 10.9936 21.3227 8.38445C20.0489 5.20951 17.8889 3.92926 16.1251 1.1417C16.0361 1.00075 15.9468 0.85942 15.8598 0.710452C15.8155 0.634372 15.7741 0.556628 15.7357 0.477389C15.6625 0.335913 15.6059 0.186371 15.5673 0.0317953C15.5676 0.0244774 15.5651 0.017323 15.5604 0.0117374C15.5556 0.00615177 15.549 0.00253868 15.5417 0.00160783C15.5348 -0.000373182 15.5275 -0.000373182 15.5206 0.00160783C15.519 0.00217033 15.5166 0.00399845 15.515 0.0046547C15.5125 0.00563908 15.5093 0.00788908 15.5067 0.0093422C15.0712 0.216905 12.4876 4.3075 15.9894 7.80883Z"
|
||||
fill="url(#paint8_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M17.2043 9.31181C17.1551 9.26648 17.0972 9.22003 17.0352 9.17343C17.0123 9.15618 16.9898 9.13903 16.9652 9.12187C16.3637 8.69934 15.2866 8.28201 14.2489 8.46248C18.3008 10.4881 17.2131 17.4637 11.5984 17.2004C11.0984 17.18 10.6043 17.0847 10.1326 16.9177C10.021 16.8757 9.91066 16.8306 9.80166 16.7824C9.7381 16.7534 9.67458 16.7241 9.61182 16.6917C9.61407 16.6932 9.61716 16.6949 9.61946 16.6964C10.4027 17.2307 14.2713 18.5365 18.314 15.2448L18.3202 15.2302C18.42 14.9932 19.7581 11.665 17.2043 9.31181Z"
|
||||
fill="url(#paint9_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M6.95794 13.0051C6.95794 13.0051 7.47793 11.0675 10.6813 11.0675C11.0276 11.0675 12.0177 10.1012 12.036 9.82096C12.0543 9.54074 9.98756 10.6812 7.80633 9.65497C5.45138 8.54694 3.66455 9.82096 3.66455 9.82096C3.66455 9.82096 4.34316 11.4995 6.33333 11.4995C6.1246 13.341 7.09828 15.4886 9.45521 16.6147C9.50789 16.6399 9.55739 16.6674 9.61149 16.6915C8.2358 15.9805 7.09983 14.6368 6.95794 13.0051Z"
|
||||
fill="url(#paint10_radial_3681_24667)"
|
||||
/>
|
||||
<path
|
||||
d="M22.4396 7.79786C21.95 6.62017 20.9583 5.34873 20.1796 4.94687C20.8134 6.1893 21.1802 7.43561 21.3203 8.36575C21.3203 8.36758 21.321 8.37212 21.3225 8.3845C20.0487 5.20951 17.8888 3.92926 16.125 1.1417C16.0359 1.00075 15.9466 0.85942 15.8596 0.710452C15.8153 0.634372 15.774 0.556628 15.7356 0.477389C15.6623 0.335913 15.6058 0.186371 15.5672 0.0317953C15.5675 0.0244774 15.565 0.017323 15.5602 0.0117374C15.5555 0.00615177 15.5489 0.00253868 15.5416 0.00160783C15.5347 -0.000373182 15.5274 -0.000373182 15.5205 0.00160783C15.5189 0.00217033 15.5165 0.00399845 15.5148 0.0046547C15.5123 0.00563908 15.5092 0.00788908 15.5066 0.0093422C15.5078 0.0076547 15.5105 0.00385783 15.5113 0.0029672C12.6814 1.66028 11.7214 4.72614 11.6332 6.26003C11.7645 6.25094 11.8953 6.23992 12.0289 6.23992C14.1408 6.23992 15.9801 7.40101 16.9649 9.12198C16.3634 8.69945 15.2863 8.28212 14.2486 8.46259C18.3005 10.4882 17.2127 17.4638 11.598 17.2005C11.098 17.1801 10.6039 17.0848 10.1322 16.9178C10.0207 16.8758 9.91032 16.8307 9.80133 16.7825C9.73777 16.7535 9.67425 16.7242 9.61148 16.6918C9.61373 16.6933 9.61683 16.6951 9.61912 16.6965C9.56407 16.67 9.50938 16.6427 9.45506 16.6148C9.50775 16.6399 9.55725 16.6675 9.61134 16.6916C8.23556 15.9806 7.09959 14.6369 6.9577 13.0052C6.9577 13.0052 7.47769 11.0676 10.6811 11.0676C11.0274 11.0676 12.0174 10.1013 12.0358 9.82108C12.0316 9.72958 10.0709 8.94967 9.30656 8.19658C8.89814 7.7942 8.70422 7.60019 8.53247 7.45464C8.43929 7.37594 8.34188 7.30239 8.24067 7.23433C7.98391 6.33601 7.97299 5.38524 8.20908 4.48126C7.05183 5.00819 6.15173 5.84111 5.49736 6.57658H5.49216C5.04558 6.01094 5.07708 4.14503 5.10253 3.75545C5.09719 3.73131 4.76939 3.92561 4.72645 3.9549C4.33238 4.23619 3.96398 4.5518 3.62555 4.89803C3.24054 5.28863 2.88878 5.71066 2.57391 6.15972C2.57391 6.16028 2.57358 6.16094 2.57339 6.1615C2.57339 6.16089 2.57372 6.16028 2.57391 6.15972C1.84952 7.18625 1.33576 8.34618 1.06233 9.57245C1.05694 9.59687 1.05239 9.62219 1.04714 9.6468C1.02595 9.74598 0.930609 10.2493 0.917297 10.3572C0.916266 10.3655 0.918281 10.349 0.917297 10.3572C0.830351 10.8773 0.774875 11.4022 0.751172 11.929C0.751172 11.9482 0.75 11.9672 0.75 11.9865C0.75 18.2072 5.79375 23.2501 12.0152 23.2501C17.587 23.2501 22.2133 19.2053 23.119 13.8924C23.1381 13.7482 23.1534 13.6033 23.1702 13.4578C23.3941 11.5261 23.1454 9.49572 22.4396 7.79786ZM21.322 8.37634C21.3226 8.38033 21.3233 8.3845 21.3239 8.38848L21.3235 8.38726L21.322 8.37634Z"
|
||||
fill="url(#paint11_linear_3681_24667)"
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="paint0_linear_3681_24667"
|
||||
x1="20.3814"
|
||||
y1="3.60386"
|
||||
x2="2.29295"
|
||||
y2="21.0528"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop offset="0.05" stopColor="#FFF44F" />
|
||||
<stop offset="0.37" stopColor="#FF980E" />
|
||||
<stop offset="0.53" stopColor="#FF3647" />
|
||||
<stop offset="0.7" stopColor="#E31587" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id="paint1_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(16.3404 2.59171) scale(23.0401 23.4281)"
|
||||
>
|
||||
<stop offset="0.13" stopColor="#FFBD4F" />
|
||||
<stop offset="0.28" stopColor="#FF980E" />
|
||||
<stop offset="0.47" stopColor="#FF3750" />
|
||||
<stop offset="0.78" stopColor="#EB0878" />
|
||||
<stop offset="0.86" stopColor="#E50080" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint2_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(9.65968 12.2681) scale(23.6161 23.4281)"
|
||||
>
|
||||
<stop offset="0.3" stopColor="#960E18" />
|
||||
<stop offset="0.35" stopColor="#B11927" stopOpacity="0.74" />
|
||||
<stop offset="0.43" stopColor="#DB293D" stopOpacity="0.34" />
|
||||
<stop offset="0.5" stopColor="#F5334B" stopOpacity="0.09" />
|
||||
<stop offset="0.53" stopColor="#FF3750" stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint3_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(14.2261 -1.0978) scale(7.56236 12.839)"
|
||||
>
|
||||
<stop offset="0.13" stopColor="#FFF44F" />
|
||||
<stop offset="0.53" stopColor="#FF980E" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint4_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(9.2356 18.3163) scale(10.007 10.9678)"
|
||||
>
|
||||
<stop offset="0.35" stopColor="#3A8EE6" />
|
||||
<stop offset="0.67" stopColor="#9059FF" />
|
||||
<stop offset="1" stopColor="#C139E6" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint5_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(10.9455 9.859) scale(5.31373 6.47101)"
|
||||
>
|
||||
<stop offset="0.21" stopColor="#9059FF" stopOpacity="0" />
|
||||
<stop offset="0.97" stopColor="#6E008B" stopOpacity="0.6" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint6_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(11.2585 1.72838) scale(7.95561 7.98388)"
|
||||
>
|
||||
<stop offset="0.1" stopColor="#FFE226" />
|
||||
<stop offset="0.79" stopColor="#FF7139" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint7_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(18.5242 -3.50921) scale(37.9818 31.8836)"
|
||||
>
|
||||
<stop offset="0.11" stopColor="#FFF44F" />
|
||||
<stop offset="0.46" stopColor="#FF980E" />
|
||||
<stop offset="0.72" stopColor="#FF3647" />
|
||||
<stop offset="0.9" stopColor="#E31587" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint8_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(4.41888 7.02007) rotate(77.3946) scale(12.0503 52.1278)"
|
||||
>
|
||||
<stop stopColor="#FFF44F" />
|
||||
<stop offset="0.3" stopColor="#FF980E" />
|
||||
<stop offset="0.57" stopColor="#FF3647" />
|
||||
<stop offset="0.74" stopColor="#E31587" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint9_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(11.3407 4.60001) scale(21.8071 21.424)"
|
||||
>
|
||||
<stop offset="0.14" stopColor="#FFF44F" />
|
||||
<stop offset="0.48" stopColor="#FF980E" />
|
||||
<stop offset="0.66" stopColor="#FF3647" />
|
||||
<stop offset="0.9" stopColor="#E31587" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id="paint10_radial_3681_24667"
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(17.0005 5.8529) scale(26.2114 23.4492)"
|
||||
>
|
||||
<stop offset="0.09" stopColor="#FFF44F" />
|
||||
<stop offset="0.63" stopColor="#FF980E" />
|
||||
</radialGradient>
|
||||
<linearGradient
|
||||
id="paint11_linear_3681_24667"
|
||||
x1="18.75"
|
||||
y1="3.25511"
|
||||
x2="4.28552"
|
||||
y2="19.0592"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop offset="0.17" stopColor="#FFF44F" stopOpacity="0.8" />
|
||||
<stop offset="0.6" stopColor="#FFF44F" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_3681_24667">
|
||||
<rect width="24" height="24" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
export interface VegaWalletDialogStore {
|
||||
vegaWalletDialogOpen: boolean;
|
||||
updateVegaWalletDialog: (open: boolean) => void;
|
||||
openVegaWalletDialog: () => void;
|
||||
closeVegaWalletDialog: () => void;
|
||||
}
|
||||
|
||||
export const useVegaWalletDialogStore = create<VegaWalletDialogStore>()(
|
||||
(set) => ({
|
||||
vegaWalletDialogOpen: false,
|
||||
updateVegaWalletDialog: (open: boolean) =>
|
||||
set({ vegaWalletDialogOpen: open }),
|
||||
openVegaWalletDialog: () => set({ vegaWalletDialogOpen: true }),
|
||||
closeVegaWalletDialog: () => set({ vegaWalletDialogOpen: false }),
|
||||
})
|
||||
);
|
||||
@@ -1,5 +1,17 @@
|
||||
import type { InjectedConnector } from './injected-connector';
|
||||
import type { JsonRpcConnector } from './json-rpc-connector';
|
||||
import type { SnapConnector } from './snap-connector';
|
||||
import type { ViewConnector } from './view-connector';
|
||||
|
||||
export * from './injected-connector';
|
||||
export * from './json-rpc-connector';
|
||||
export * from './snap-connector';
|
||||
export * from './vega-connector';
|
||||
export * from './view-connector';
|
||||
|
||||
export type Connectors = {
|
||||
jsonRpc: JsonRpcConnector | undefined;
|
||||
injected: InjectedConnector | undefined;
|
||||
snap: SnapConnector | undefined;
|
||||
view: ViewConnector | undefined;
|
||||
};
|
||||
|
||||
@@ -147,8 +147,9 @@ export class SnapConnector implements VegaConnector {
|
||||
snapId: string | undefined = undefined;
|
||||
nodeAddress: string | undefined = undefined;
|
||||
|
||||
constructor(nodeAddress?: string, snapId = DEFAULT_SNAP_ID) {
|
||||
this.nodeAddress = nodeAddress;
|
||||
// note we cannot set nodeAddress in the constructor because the
|
||||
// trading app will not know what the vega url is until the app runs
|
||||
constructor(snapId = DEFAULT_SNAP_ID) {
|
||||
this.snapId = snapId;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,15 @@ import type {
|
||||
} from './connectors';
|
||||
|
||||
export interface VegaWalletContextShape {
|
||||
/** Current connected network */
|
||||
network: string;
|
||||
|
||||
/** Url of current connected node */
|
||||
vegaUrl: string;
|
||||
|
||||
/** Url of running wallet service */
|
||||
vegaWalletServiceUrl: string;
|
||||
|
||||
/** If the current connector does not support signing transactions */
|
||||
isReadOnly: boolean;
|
||||
/** The current select public key */
|
||||
@@ -37,6 +46,16 @@ export interface VegaWalletContextShape {
|
||||
|
||||
/** Acknowledge disclaimer */
|
||||
acknowledgeNeeded?: boolean;
|
||||
|
||||
/** Useful links for wallet users */
|
||||
links: {
|
||||
explorer: string;
|
||||
about: string;
|
||||
concepts: string;
|
||||
browserList: string;
|
||||
chromeExtensionUrl: string;
|
||||
mozillaExtensionUrl: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const VegaWalletContext = createContext<
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
export * from './context';
|
||||
export * from './use-vega-wallet';
|
||||
export * from './connectors';
|
||||
export * from './context';
|
||||
export * from './use-vega-transaction';
|
||||
export * from './use-vega-wallet';
|
||||
export * from './use-vega-transaction-manager';
|
||||
export * from './use-vega-transaction-store';
|
||||
export * from './use-vega-transaction-updater';
|
||||
export * from './use-transaction-result';
|
||||
export * from './use-eager-connect';
|
||||
export * from './manage-dialog';
|
||||
export * from './vega-transaction-dialog';
|
||||
export * from './provider';
|
||||
export * from './connect-dialog';
|
||||
export * from './utils';
|
||||
export * from './storage';
|
||||
export * from './types';
|
||||
export * from './vega-transaction-dialog';
|
||||
export * from './__generated__/TransactionResult';
|
||||
export * from './__generated__/WithdrawalApproval';
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
Intent,
|
||||
Icon,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { useVegaWallet } from '..';
|
||||
import { useVegaWallet } from '../use-vega-wallet';
|
||||
|
||||
export interface VegaManageDialogProps {
|
||||
dialogOpen: boolean;
|
||||
@@ -38,13 +38,13 @@ export const VegaManageDialog = ({
|
||||
className="mb-2 last:mb-0"
|
||||
>
|
||||
<div
|
||||
className="flex gap-4 justify-between text-sm"
|
||||
className="flex justify-between text-sm gap-4"
|
||||
data-testid={isSelected ? 'selected-key' : ''}
|
||||
>
|
||||
<p data-testid="vega-public-key-full">
|
||||
{truncateByChars(pk.publicKey)}
|
||||
</p>
|
||||
<div className="flex gap-4 ml-auto">
|
||||
<div className="flex ml-auto gap-4">
|
||||
{!isSelected && (
|
||||
<button
|
||||
onClick={() => {
|
||||
|
||||
@@ -2,19 +2,32 @@ import { act, renderHook } from '@testing-library/react';
|
||||
import type { Transaction } from './connectors';
|
||||
import { ViewConnector, JsonRpcConnector } from './connectors';
|
||||
import { useVegaWallet } from './use-vega-wallet';
|
||||
import type { VegaWalletConfig } from './provider';
|
||||
import { VegaWalletProvider } from './provider';
|
||||
import { LocalStorage } from '@vegaprotocol/utils';
|
||||
import type { ReactNode } from 'react';
|
||||
import { WALLET_KEY } from './storage';
|
||||
import * as Environment from '@vegaprotocol/environment';
|
||||
import * as ReactHelpers from '@vegaprotocol/react-helpers';
|
||||
|
||||
const jsonRpcConnector = new JsonRpcConnector();
|
||||
const viewConnector = new ViewConnector();
|
||||
|
||||
const setup = () => {
|
||||
const defaultConfig: VegaWalletConfig = {
|
||||
network: 'TESTNET',
|
||||
vegaUrl: 'https://vega.xyz',
|
||||
vegaWalletServiceUrl: 'https://vegaservice.xyz',
|
||||
links: {
|
||||
explorer: 'explorer-link',
|
||||
concepts: 'concepts-link',
|
||||
chromeExtensionUrl: 'chrome-link',
|
||||
mozillaExtensionUrl: 'mozilla-link',
|
||||
},
|
||||
};
|
||||
|
||||
const setup = (config?: Partial<VegaWalletConfig>) => {
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<VegaWalletProvider>{children}</VegaWalletProvider>
|
||||
<VegaWalletProvider config={{ ...defaultConfig, ...config }}>
|
||||
{children}
|
||||
</VegaWalletProvider>
|
||||
);
|
||||
return renderHook(() => useVegaWallet(), { wrapper });
|
||||
};
|
||||
@@ -51,6 +64,9 @@ describe('VegaWalletProvider', () => {
|
||||
|
||||
// Default state
|
||||
expect(result.current).toEqual({
|
||||
network: defaultConfig.network,
|
||||
vegaUrl: defaultConfig.vegaUrl,
|
||||
vegaWalletServiceUrl: defaultConfig.vegaWalletServiceUrl,
|
||||
acknowledgeNeeded: false,
|
||||
pubKey: null,
|
||||
pubKeys: null,
|
||||
@@ -60,6 +76,11 @@ describe('VegaWalletProvider', () => {
|
||||
disconnect: expect.any(Function),
|
||||
sendTx: expect.any(Function),
|
||||
fetchPubKeys: expect.any(Function || undefined),
|
||||
links: {
|
||||
about: expect.any(String),
|
||||
browserList: expect.any(String),
|
||||
...defaultConfig.links,
|
||||
},
|
||||
});
|
||||
|
||||
// Connect
|
||||
@@ -91,17 +112,7 @@ describe('VegaWalletProvider', () => {
|
||||
const { result } = setup();
|
||||
|
||||
// Default state
|
||||
expect(result.current).toEqual({
|
||||
acknowledgeNeeded: false,
|
||||
pubKey: null,
|
||||
pubKeys: null,
|
||||
isReadOnly: false,
|
||||
selectPubKey: expect.any(Function),
|
||||
connect: expect.any(Function),
|
||||
disconnect: expect.any(Function),
|
||||
sendTx: expect.any(Function),
|
||||
fetchPubKeys: expect.any(Function),
|
||||
});
|
||||
expect(result.current.pubKey).toEqual(null);
|
||||
|
||||
// Connect
|
||||
await act(async () => {
|
||||
@@ -128,6 +139,7 @@ describe('VegaWalletProvider', () => {
|
||||
result.current.connect(jsonRpcConnector);
|
||||
result.current.selectPubKey(mockPubKeys[0].publicKey);
|
||||
});
|
||||
|
||||
expect(result.current.pubKey).toBe(mockPubKeys[0].publicKey);
|
||||
|
||||
// Disconnect
|
||||
@@ -154,22 +166,12 @@ describe('VegaWalletProvider', () => {
|
||||
});
|
||||
|
||||
it('acknowledgeNeeded will set on', async () => {
|
||||
jest
|
||||
.spyOn(Environment, 'useEnvironment')
|
||||
.mockReturnValue({ VEGA_ENV: 'MAINNET' });
|
||||
jest.spyOn(ReactHelpers, 'useLocalStorage').mockImplementation(() => [
|
||||
'',
|
||||
() => {
|
||||
/**/
|
||||
},
|
||||
() => {
|
||||
/**/
|
||||
},
|
||||
]);
|
||||
jest
|
||||
.spyOn(viewConnector, 'connect')
|
||||
.mockImplementation(() => Promise.resolve(mockPubKeys));
|
||||
const { result } = setup();
|
||||
|
||||
const { result } = setup({ network: 'MAINNET' });
|
||||
|
||||
expect(result.current.acknowledgeNeeded).toBe(true);
|
||||
|
||||
await act(async () => {
|
||||
|
||||
@@ -11,14 +11,45 @@ import type {
|
||||
import { VegaWalletContext } from './context';
|
||||
import { WALLET_KEY, WALLET_RISK_ACCEPTED_KEY } from './storage';
|
||||
import { ViewConnector } from './connectors';
|
||||
import { useEnvironment, Networks } from '@vegaprotocol/environment';
|
||||
import { useLocalStorage } from '@vegaprotocol/react-helpers';
|
||||
|
||||
type Networks =
|
||||
| 'MAINNET'
|
||||
| 'MAINNET_MIRROR'
|
||||
| 'TESTNET'
|
||||
| 'VALIDATOR_TESTNET'
|
||||
| 'STAGNET1'
|
||||
| 'DEVNET'
|
||||
| 'CUSTOM';
|
||||
|
||||
interface VegaWalletLinks {
|
||||
explorer: string;
|
||||
concepts: string;
|
||||
chromeExtensionUrl: string;
|
||||
mozillaExtensionUrl: string;
|
||||
}
|
||||
|
||||
export interface VegaWalletConfig {
|
||||
network: Networks;
|
||||
vegaUrl: string;
|
||||
vegaWalletServiceUrl: string;
|
||||
links: VegaWalletLinks;
|
||||
}
|
||||
|
||||
const ExternalLinks = {
|
||||
VEGA_WALLET_URL_ABOUT: 'https://vega.xyz/wallet/#overview',
|
||||
VEGA_WALLET_BROWSER_LIST: '',
|
||||
};
|
||||
|
||||
interface VegaWalletProviderProps {
|
||||
children: ReactNode;
|
||||
config: VegaWalletConfig;
|
||||
}
|
||||
|
||||
export const VegaWalletProvider = ({ children }: VegaWalletProviderProps) => {
|
||||
export const VegaWalletProvider = ({
|
||||
children,
|
||||
config,
|
||||
}: VegaWalletProviderProps) => {
|
||||
// Current selected pubKey
|
||||
const [pubKey, setPubKey] = useState<string | null>(null);
|
||||
const [isReadOnly, setIsReadOnly] = useState<boolean>(false);
|
||||
@@ -109,13 +140,23 @@ export const VegaWalletProvider = ({ children }: VegaWalletProviderProps) => {
|
||||
return connector.current.sendTx(pubkey, transaction);
|
||||
}, []);
|
||||
|
||||
const { VEGA_ENV } = useEnvironment();
|
||||
const [riskAcceptedValue] = useLocalStorage(WALLET_RISK_ACCEPTED_KEY);
|
||||
const acknowledgeNeeded =
|
||||
VEGA_ENV === Networks.MAINNET && riskAcceptedValue !== 'true';
|
||||
config.network === 'MAINNET' && riskAcceptedValue !== 'true';
|
||||
|
||||
const contextValue = useMemo<VegaWalletContextShape>(() => {
|
||||
return {
|
||||
vegaUrl: config.vegaUrl,
|
||||
vegaWalletServiceUrl: config.vegaWalletServiceUrl,
|
||||
network: config.network,
|
||||
links: {
|
||||
explorer: config.links.explorer,
|
||||
about: ExternalLinks.VEGA_WALLET_URL_ABOUT,
|
||||
browserList: ExternalLinks.VEGA_WALLET_BROWSER_LIST,
|
||||
concepts: config.links.concepts,
|
||||
chromeExtensionUrl: config.links.chromeExtensionUrl,
|
||||
mozillaExtensionUrl: config.links.mozillaExtensionUrl,
|
||||
},
|
||||
isReadOnly,
|
||||
pubKey,
|
||||
pubKeys,
|
||||
@@ -127,6 +168,7 @@ export const VegaWalletProvider = ({ children }: VegaWalletProviderProps) => {
|
||||
acknowledgeNeeded,
|
||||
};
|
||||
}, [
|
||||
config,
|
||||
isReadOnly,
|
||||
pubKey,
|
||||
pubKeys,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export enum VegaTxStatus {
|
||||
Default = 'Default',
|
||||
Requested = 'Requested',
|
||||
Pending = 'Pending',
|
||||
Error = 'Error',
|
||||
Complete = 'Complete',
|
||||
}
|
||||
|
||||
export interface VegaTxState {
|
||||
status: VegaTxStatus;
|
||||
error: Error | null;
|
||||
txHash: string | null;
|
||||
signature: string | null;
|
||||
dialogOpen: boolean;
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
import type { SnapConnector } from './';
|
||||
import { useVegaWallet } from './';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { VegaConnector } from './connectors/vega-connector';
|
||||
import { InjectedConnector } from './connectors/injected-connector';
|
||||
import { SnapConnector } from './connectors/snap-connector';
|
||||
import { getConfig } from './storage';
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import type { Connectors } from './connectors';
|
||||
import { useVegaWallet } from './use-vega-wallet';
|
||||
|
||||
export function useEagerConnect(Connectors: {
|
||||
[connector: string]: VegaConnector;
|
||||
}) {
|
||||
const { VEGA_URL } = useEnvironment();
|
||||
export function useEagerConnect(connectors: Connectors) {
|
||||
const [connecting, setConnecting] = useState(true);
|
||||
const { connect, acknowledgeNeeded } = useVegaWallet();
|
||||
const { vegaUrl, connect, acknowledgeNeeded } = useVegaWallet();
|
||||
|
||||
useEffect(() => {
|
||||
const attemptConnect = async () => {
|
||||
@@ -23,7 +20,7 @@ export function useEagerConnect(Connectors: {
|
||||
|
||||
// Use the connector string in local storage to find the right connector to auto
|
||||
// connect to
|
||||
const connector = Connectors[cfg.connector];
|
||||
const connector = connectors[cfg.connector];
|
||||
|
||||
// Developer hasn't provided this connector
|
||||
if (!connector) {
|
||||
@@ -33,20 +30,16 @@ export function useEagerConnect(Connectors: {
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (cfg.connector === 'injected') {
|
||||
const injectedInstance = Connectors[cfg.connector];
|
||||
// @ts-ignore only injected wallet has connectWallet method
|
||||
await injectedInstance.connectWallet();
|
||||
await connect(injectedInstance);
|
||||
} else if (cfg.connector === 'snap') {
|
||||
const snapInstance = Connectors[cfg.connector] as SnapConnector;
|
||||
if (VEGA_URL) {
|
||||
snapInstance.nodeAddress = new URL(VEGA_URL).origin;
|
||||
await connect(snapInstance);
|
||||
}
|
||||
if (connector instanceof InjectedConnector) {
|
||||
await connector.connectWallet();
|
||||
await connect(connector);
|
||||
} else if (connector instanceof SnapConnector) {
|
||||
connector.nodeAddress = new URL(vegaUrl).origin;
|
||||
await connect(connector);
|
||||
} else {
|
||||
await connect(Connectors[cfg.connector]);
|
||||
await connect(connector);
|
||||
}
|
||||
} catch {
|
||||
console.warn(`Failed to connect with connector: ${cfg.connector}`);
|
||||
@@ -58,7 +51,7 @@ export function useEagerConnect(Connectors: {
|
||||
if (typeof window !== 'undefined') {
|
||||
attemptConnect();
|
||||
}
|
||||
}, [connect, Connectors, acknowledgeNeeded, VEGA_URL]);
|
||||
}, [connect, connectors, acknowledgeNeeded, vegaUrl]);
|
||||
|
||||
return connecting;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
import { act, renderHook, waitFor } from '@testing-library/react';
|
||||
import { Status, useInjectedConnector } from './use-injected-connector';
|
||||
import type { ReactNode } from 'react';
|
||||
import type { VegaWalletConfig } from './provider';
|
||||
import { VegaWalletProvider } from './provider';
|
||||
import { InjectedConnector } from './connectors';
|
||||
import { mockBrowserWallet } from './test-helpers';
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import { Networks } from '@vegaprotocol/environment';
|
||||
|
||||
jest.mock('@vegaprotocol/environment');
|
||||
const defaultConfig: VegaWalletConfig = {
|
||||
network: 'TESTNET',
|
||||
vegaUrl: 'https://vega.xyz',
|
||||
vegaWalletServiceUrl: 'https://vegaservice.xyz',
|
||||
links: {
|
||||
explorer: 'explorer-link',
|
||||
concepts: 'concepts-link',
|
||||
chromeExtensionUrl: 'chrome-link',
|
||||
mozillaExtensionUrl: 'mozilla-link',
|
||||
},
|
||||
};
|
||||
|
||||
const setup = (callback = jest.fn()) => {
|
||||
const setup = (callback = jest.fn(), config?: Partial<VegaWalletConfig>) => {
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<VegaWalletProvider>{children}</VegaWalletProvider>
|
||||
<VegaWalletProvider config={{ ...defaultConfig, ...config }}>
|
||||
{children}
|
||||
</VegaWalletProvider>
|
||||
);
|
||||
return renderHook(() => useInjectedConnector(callback), { wrapper });
|
||||
};
|
||||
@@ -19,10 +30,6 @@ const setup = (callback = jest.fn()) => {
|
||||
const injected = new InjectedConnector();
|
||||
|
||||
describe('useInjectedConnector', () => {
|
||||
beforeEach(() => {
|
||||
// @ts-ignore useEnvironment has been mocked
|
||||
useEnvironment.mockImplementation(() => ({ VEGA_ENV: Networks.TESTNET }));
|
||||
});
|
||||
it('attempts connection', async () => {
|
||||
const { result } = setup();
|
||||
expect(typeof result.current.connect).toBe('function');
|
||||
@@ -84,11 +91,8 @@ describe('useInjectedConnector', () => {
|
||||
|
||||
it('connects when aknowledgement required', async () => {
|
||||
const callback = jest.fn();
|
||||
// @ts-ignore useEnvironment has been mocked
|
||||
useEnvironment.mockImplementation(() => ({ VEGA_ENV: Networks.MAINNET }));
|
||||
|
||||
const vega = mockBrowserWallet();
|
||||
const { result } = setup(callback);
|
||||
const { result } = setup(callback, { network: 'MAINNET' });
|
||||
|
||||
act(() => {
|
||||
result.current.connect(injected, '1'); // default mock chainId is '1'
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
} from './connectors';
|
||||
import { InjectedConnector } from './connectors';
|
||||
import { useVegaWallet } from './use-vega-wallet';
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
|
||||
export enum Status {
|
||||
Idle = 'Idle',
|
||||
@@ -18,10 +17,9 @@ export enum Status {
|
||||
}
|
||||
|
||||
export const useInjectedConnector = (onConnect: () => void) => {
|
||||
const { connect, acknowledgeNeeded } = useVegaWallet();
|
||||
const { vegaUrl, connect, acknowledgeNeeded } = useVegaWallet();
|
||||
const [status, setStatus] = useState(Status.Idle);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
const { VEGA_URL } = useEnvironment();
|
||||
|
||||
const attemptConnect = useCallback(
|
||||
async (
|
||||
@@ -36,10 +34,10 @@ export const useInjectedConnector = (onConnect: () => void) => {
|
||||
if (!('ethereum' in window)) {
|
||||
throw SnapConnectorErrors.ETHEREUM_UNDEFINED;
|
||||
}
|
||||
if (!VEGA_URL) {
|
||||
if (!vegaUrl) {
|
||||
throw SnapConnectorErrors.NODE_ADDRESS_NOT_SET;
|
||||
}
|
||||
connector.nodeAddress = new URL(VEGA_URL).origin;
|
||||
connector.nodeAddress = new URL(vegaUrl).origin;
|
||||
}
|
||||
|
||||
setStatus(Status.GettingChainId);
|
||||
@@ -71,7 +69,7 @@ export const useInjectedConnector = (onConnect: () => void) => {
|
||||
setStatus(Status.Error);
|
||||
}
|
||||
},
|
||||
[VEGA_URL, acknowledgeNeeded, connect, onConnect]
|
||||
[vegaUrl, acknowledgeNeeded, connect, onConnect]
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -3,20 +3,25 @@ import { getSnap } from './connectors';
|
||||
|
||||
const INTERVAL = 2_000;
|
||||
|
||||
export const useIsSnapRunning = (snapId: string) => {
|
||||
export const useIsSnapRunning = (snapId: string, shouldCheck: boolean) => {
|
||||
const [running, setRunning] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!shouldCheck) return;
|
||||
|
||||
const checkState = async () => {
|
||||
const snap = await getSnap(snapId);
|
||||
setRunning(!!snap);
|
||||
};
|
||||
|
||||
const i = setInterval(() => {
|
||||
checkState();
|
||||
}, INTERVAL);
|
||||
|
||||
checkState();
|
||||
|
||||
return () => {
|
||||
clearInterval(i);
|
||||
};
|
||||
}, [snapId]);
|
||||
}, [snapId, shouldCheck]);
|
||||
return running;
|
||||
};
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import type { VegaConnector } from './connectors';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import type { JsonRpcConnector } from './connectors';
|
||||
import { ClientErrors } from './connectors';
|
||||
|
||||
export const useIsWalletServiceRunning = (
|
||||
url: string,
|
||||
connectors: { [key: string]: VegaConnector },
|
||||
connector: JsonRpcConnector | undefined,
|
||||
appChainId: string
|
||||
) => {
|
||||
const [run, setRun] = useState<boolean | null>(null);
|
||||
|
||||
const checkState = useCallback(async () => {
|
||||
const connector = connectors['jsonRpc'] as JsonRpcConnector;
|
||||
if (!connector) return false;
|
||||
|
||||
if (url && url !== connector.url) {
|
||||
connector.url = url;
|
||||
}
|
||||
|
||||
try {
|
||||
await connector.checkCompat();
|
||||
const chainIdResult = await connector.getChainId();
|
||||
@@ -25,9 +26,11 @@ export const useIsWalletServiceRunning = (
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, [connectors, url, appChainId]);
|
||||
}, [connector, url, appChainId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!connector) return;
|
||||
|
||||
let interval: NodeJS.Timeout;
|
||||
checkState().then((value) => {
|
||||
setRun(value);
|
||||
@@ -38,7 +41,7 @@ export const useIsWalletServiceRunning = (
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [checkState]);
|
||||
}, [checkState, connector]);
|
||||
|
||||
return run;
|
||||
};
|
||||
|
||||
@@ -2,13 +2,12 @@ import { useVegaTransactionManager } from './use-vega-transaction-manager';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import waitForNextTick from 'flush-promises';
|
||||
import type { TransactionResponse } from './connectors/vega-connector';
|
||||
import { VegaTxStatus } from './types';
|
||||
import type {
|
||||
VegaTransactionStore,
|
||||
VegaStoredTxState,
|
||||
} from './use-vega-transaction-store';
|
||||
|
||||
import { VegaTxStatus } from './use-vega-transaction';
|
||||
|
||||
const mockSendTx = jest.fn<Promise<Partial<TransactionResponse> | null>, []>();
|
||||
|
||||
const pubKey = 'pubKey';
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
import { useVegaWallet } from './use-vega-wallet';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import type { WalletError } from './connectors';
|
||||
import { WalletError } from './connectors';
|
||||
import { ClientErrors } from './connectors';
|
||||
import { VegaTxStatus, orderErrorResolve } from './use-vega-transaction';
|
||||
import { useVegaTransactionStore } from './use-vega-transaction-store';
|
||||
import {
|
||||
WalletClientError,
|
||||
WalletHttpError,
|
||||
} from '@vegaprotocol/wallet-client';
|
||||
import { VegaTxStatus } from './types';
|
||||
|
||||
const orderErrorResolve = (err: Error | unknown): Error => {
|
||||
if (err instanceof WalletClientError || err instanceof WalletError) {
|
||||
return err;
|
||||
} else if (err instanceof WalletHttpError) {
|
||||
return ClientErrors.UNKNOWN;
|
||||
} else if (err instanceof TypeError) {
|
||||
return ClientErrors.NO_SERVICE;
|
||||
} else if (err instanceof Error) {
|
||||
return err;
|
||||
}
|
||||
return ClientErrors.UNKNOWN;
|
||||
};
|
||||
|
||||
export const useVegaTransactionManager = () => {
|
||||
const { sendTx, pubKey, disconnect } = useVegaWallet();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useVegaTransactionStore } from './use-vega-transaction-store';
|
||||
import { VegaTxStatus } from './use-vega-transaction';
|
||||
import type { VegaStoredTxState } from './use-vega-transaction-store';
|
||||
import type {
|
||||
OrderAmendmentBody,
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
OrderType,
|
||||
Side,
|
||||
} from '@vegaprotocol/types';
|
||||
import { VegaTxStatus } from './types';
|
||||
|
||||
jest.mock('./utils', () => ({
|
||||
...jest.requireActual('./utils'),
|
||||
|
||||
@@ -13,8 +13,6 @@ import {
|
||||
import { determineId } from './utils';
|
||||
|
||||
import { create } from 'zustand';
|
||||
import type { VegaTxState } from './use-vega-transaction';
|
||||
import { VegaTxStatus } from './use-vega-transaction';
|
||||
import type {
|
||||
TransactionEventFieldsFragment,
|
||||
WithdrawalBusEventFieldsFragment,
|
||||
@@ -23,6 +21,9 @@ import type {
|
||||
|
||||
import type { WithdrawalApprovalQuery } from './__generated__/WithdrawalApproval';
|
||||
import { subscribeWithSelector } from 'zustand/middleware';
|
||||
import type { VegaTxState } from './types';
|
||||
import { VegaTxStatus } from './types';
|
||||
|
||||
export interface VegaStoredTxState extends VegaTxState {
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
@@ -33,6 +34,7 @@ export interface VegaStoredTxState extends VegaTxState {
|
||||
withdrawalApproval?: WithdrawalApprovalQuery['erc20WithdrawalApproval'];
|
||||
order?: OrderTxUpdateFieldsFragment;
|
||||
}
|
||||
|
||||
export interface VegaTransactionStore {
|
||||
transactions: (VegaStoredTxState | undefined)[];
|
||||
create: (tx: Transaction, order?: OrderTxUpdateFieldsFragment) => number;
|
||||
|
||||
@@ -2,15 +2,13 @@ import { act, renderHook } from '@testing-library/react';
|
||||
import type { VegaWalletContextShape } from './context';
|
||||
import { VegaWalletContext } from './context';
|
||||
import type { ReactNode } from 'react';
|
||||
import {
|
||||
initialState,
|
||||
useVegaTransaction,
|
||||
VegaTxStatus,
|
||||
} from './use-vega-transaction';
|
||||
import { initialState, useVegaTransaction } from './use-vega-transaction';
|
||||
import type { Transaction } from './connectors';
|
||||
import { WalletError } from './connectors';
|
||||
import { VegaTxStatus } from './types';
|
||||
|
||||
const mockPubKey = '0x123';
|
||||
|
||||
const defaultWalletContext = {
|
||||
pubKey: null,
|
||||
pubKeys: [],
|
||||
@@ -20,7 +18,7 @@ const defaultWalletContext = {
|
||||
disconnect: jest.fn(),
|
||||
selectPubKey: jest.fn(),
|
||||
connector: null,
|
||||
};
|
||||
} as unknown as VegaWalletContextShape;
|
||||
|
||||
function setup(context?: Partial<VegaWalletContextShape>) {
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
|
||||
@@ -11,6 +11,8 @@ import type { Intent } from '@vegaprotocol/ui-toolkit';
|
||||
import type { Transaction } from './connectors';
|
||||
import { WalletError } from './connectors';
|
||||
import { ClientErrors } from './connectors';
|
||||
import type { VegaTxState } from './types';
|
||||
import { VegaTxStatus } from './types';
|
||||
|
||||
export interface DialogProps {
|
||||
intent?: Intent;
|
||||
@@ -19,22 +21,6 @@ export interface DialogProps {
|
||||
content?: VegaTransactionContentMap;
|
||||
}
|
||||
|
||||
export enum VegaTxStatus {
|
||||
Default = 'Default',
|
||||
Requested = 'Requested',
|
||||
Pending = 'Pending',
|
||||
Error = 'Error',
|
||||
Complete = 'Complete',
|
||||
}
|
||||
|
||||
export interface VegaTxState {
|
||||
status: VegaTxStatus;
|
||||
error: Error | null;
|
||||
txHash: string | null;
|
||||
signature: string | null;
|
||||
dialogOpen: boolean;
|
||||
}
|
||||
|
||||
export const initialState = {
|
||||
status: VegaTxStatus.Default,
|
||||
error: null,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useContext } from 'react';
|
||||
import { useVegaWalletDialogStore, VegaWalletContext } from '.';
|
||||
import { useVegaWalletDialogStore } from './connect-dialog/vega-wallet-dialog-store';
|
||||
import { VegaWalletContext } from './context';
|
||||
|
||||
export function useVegaWallet() {
|
||||
const context = useContext(VegaWalletContext);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { WalletError } from '../connectors';
|
||||
import { VegaTxStatus } from '../use-vega-transaction';
|
||||
import type { VegaWalletContextShape } from '../context';
|
||||
import { VegaWalletContext } from '../context';
|
||||
import { VegaTxStatus } from '../types';
|
||||
import type { VegaTransactionDialogProps } from './vega-transaction-dialog';
|
||||
import { VegaTransactionDialog } from './vega-transaction-dialog';
|
||||
|
||||
@@ -16,6 +18,12 @@ jest.mock('@vegaprotocol/environment', () => ({
|
||||
}));
|
||||
|
||||
describe('VegaTransactionDialog', () => {
|
||||
const walletContext = {
|
||||
network: 'TESTNET',
|
||||
links: {
|
||||
explorer: 'explorer',
|
||||
},
|
||||
} as VegaWalletContextShape;
|
||||
let props: VegaTransactionDialogProps;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -33,7 +41,11 @@ describe('VegaTransactionDialog', () => {
|
||||
});
|
||||
|
||||
it('requested', () => {
|
||||
render(<VegaTransactionDialog {...props} />);
|
||||
render(
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<VegaTransactionDialog {...props} />
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
expect(screen.getByTestId('dialog-title')).toHaveTextContent(/confirm/i);
|
||||
expect(screen.getByTestId(VegaTxStatus.Requested)).toHaveTextContent(
|
||||
/please open your wallet/i
|
||||
@@ -45,14 +57,16 @@ describe('VegaTransactionDialog', () => {
|
||||
|
||||
it('pending', () => {
|
||||
render(
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
txHash: 'tx-hash',
|
||||
status: VegaTxStatus.Pending,
|
||||
}}
|
||||
/>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
txHash: 'tx-hash',
|
||||
status: VegaTxStatus.Pending,
|
||||
}}
|
||||
/>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
expect(screen.getByTestId('dialog-title')).toHaveTextContent(/awaiting/i);
|
||||
expect(screen.getByTestId(VegaTxStatus.Pending)).toHaveTextContent(
|
||||
@@ -63,14 +77,16 @@ describe('VegaTransactionDialog', () => {
|
||||
|
||||
it('error', () => {
|
||||
render(
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
error: new WalletError('rejected', 1),
|
||||
status: VegaTxStatus.Error,
|
||||
}}
|
||||
/>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
error: new WalletError('rejected', 1),
|
||||
status: VegaTxStatus.Error,
|
||||
}}
|
||||
/>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
expect(screen.getByTestId('dialog-title')).toHaveTextContent(/failed/i);
|
||||
expect(screen.getByTestId(VegaTxStatus.Error)).toHaveTextContent(
|
||||
@@ -80,14 +96,16 @@ describe('VegaTransactionDialog', () => {
|
||||
|
||||
it('default complete', () => {
|
||||
render(
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
txHash: 'tx-hash',
|
||||
status: VegaTxStatus.Complete,
|
||||
}}
|
||||
/>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
txHash: 'tx-hash',
|
||||
status: VegaTxStatus.Complete,
|
||||
}}
|
||||
/>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
expect(screen.getByTestId('dialog-title')).toHaveTextContent(/complete/i);
|
||||
expect(screen.getByTestId(VegaTxStatus.Complete)).toHaveTextContent(
|
||||
@@ -105,16 +123,18 @@ describe('VegaTransactionDialog', () => {
|
||||
[status]: <div>{text}</div>,
|
||||
};
|
||||
render(
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
txHash: 'tx-hash',
|
||||
status: status as VegaTxStatus,
|
||||
}}
|
||||
title={title}
|
||||
content={content}
|
||||
/>
|
||||
<VegaWalletContext.Provider value={walletContext}>
|
||||
<VegaTransactionDialog
|
||||
{...props}
|
||||
transaction={{
|
||||
...props.transaction,
|
||||
txHash: 'tx-hash',
|
||||
status: status as VegaTxStatus,
|
||||
}}
|
||||
title={title}
|
||||
content={content}
|
||||
/>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
expect(screen.getByTestId('dialog-title')).toHaveTextContent(title);
|
||||
expect(screen.getByText(text)).toBeInTheDocument();
|
||||
@@ -127,7 +147,7 @@ describe('VegaTransactionDialog', () => {
|
||||
);
|
||||
expect(screen.getByTestId('tx-block-explorer')).toHaveAttribute(
|
||||
'href',
|
||||
`https://test.explorer.vega.network/txs/0x${txHash}`
|
||||
`${walletContext.links.explorer}/txs/0x${txHash}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Networks, useEnvironment } from '@vegaprotocol/environment';
|
||||
import type { ReactNode } from 'react';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { Dialog, Icon, Intent, Loader } from '@vegaprotocol/ui-toolkit';
|
||||
import type { ReactNode } from 'react';
|
||||
import { WalletClientError } from '@vegaprotocol/wallet-client';
|
||||
import type { VegaTxState } from '../use-vega-transaction';
|
||||
import { VegaTxStatus } from '../use-vega-transaction';
|
||||
import type { VegaTxState } from '../types';
|
||||
import { VegaTxStatus } from '../types';
|
||||
import { useVegaWallet } from '../use-vega-wallet';
|
||||
|
||||
export type VegaTransactionContentMap = {
|
||||
[C in VegaTxStatus]?: JSX.Element;
|
||||
@@ -86,7 +86,7 @@ interface VegaDialogProps {
|
||||
* Default dialog content
|
||||
*/
|
||||
export const VegaDialog = ({ transaction }: VegaDialogProps) => {
|
||||
const { VEGA_EXPLORER_URL, VEGA_ENV } = useEnvironment();
|
||||
const { links, network } = useVegaWallet();
|
||||
|
||||
let content = null;
|
||||
if (transaction.status === VegaTxStatus.Requested) {
|
||||
@@ -97,9 +97,9 @@ export const VegaDialog = ({ transaction }: VegaDialogProps) => {
|
||||
'Please open your wallet application and confirm or reject the transaction'
|
||||
)}
|
||||
</p>
|
||||
{VEGA_ENV !== Networks.MAINNET && (
|
||||
{network !== 'MAINNET' && (
|
||||
<p data-testid="testnet-transaction-info">
|
||||
{t('[This is %s transaction only]').replace('%s', VEGA_ENV)}
|
||||
{t('[This is %s transaction only]').replace('%s', network)}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
@@ -125,7 +125,7 @@ export const VegaDialog = ({ transaction }: VegaDialogProps) => {
|
||||
<a
|
||||
className="underline"
|
||||
data-testid="tx-block-explorer"
|
||||
href={`${VEGA_EXPLORER_URL}/txs/0x${transaction.txHash}`}
|
||||
href={`${links.explorer}/txs/0x${transaction.txHash}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@@ -146,7 +146,7 @@ export const VegaDialog = ({ transaction }: VegaDialogProps) => {
|
||||
<a
|
||||
className="underline"
|
||||
data-testid="tx-block-explorer"
|
||||
href={`${VEGA_EXPLORER_URL}/txs/0x${transaction.txHash}`}
|
||||
href={`${links.explorer}/txs/0x${transaction.txHash}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
||||
@@ -139,7 +139,6 @@
|
||||
"@storybook/react-webpack5": "7.0.24",
|
||||
"@svgr/rollup": "^8.0.1",
|
||||
"@svgr/webpack": "^6.1.2",
|
||||
"@swc/core": "^1.2.173",
|
||||
"@swc/jest": "0.2.20",
|
||||
"@testing-library/jest-dom": "^5.16.2",
|
||||
"@testing-library/react": "14.0.0",
|
||||
|
||||
@@ -7565,72 +7565,6 @@
|
||||
"@svgr/plugin-jsx" "8.0.1"
|
||||
"@svgr/plugin-svgo" "8.0.1"
|
||||
|
||||
"@swc/core-darwin-arm64@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.56.tgz#a846f7fdbc274aa7d299568031dde025d44a3b4c"
|
||||
integrity sha512-DZcu7BzDaLEdWHabz9DRTP0yEBLqkrWmskFcD5BX0lGAvoIvE4duMnAqi5F2B3X7630QioHRCYFoRw2WkeE3Cw==
|
||||
|
||||
"@swc/core-darwin-x64@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.56.tgz#793865f14f07f5eff6a6e6764aa6c766983fa007"
|
||||
integrity sha512-VH5saqYFasdRXJy6RAT+MXm0+IjkMZvOkohJwUei+oA65cKJofQwrJ1jZro8yOJFYvUSI3jgNRGsdBkmo/4hMw==
|
||||
|
||||
"@swc/core-linux-arm-gnueabihf@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.56.tgz#6942e9a4f6086da66d995c46c2ab2b0f7fa86a1d"
|
||||
integrity sha512-LWwPo6NnJkH01+ukqvkoNIOpMdw+Zundm4vBeicwyVrkP+mC3kwVfi03TUFpQUz3kRKdw/QEnxGTj+MouCPbtw==
|
||||
|
||||
"@swc/core-linux-arm64-gnu@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.56.tgz#21c3f8083c2d0a8028a07bf42cdd2a345e5108e9"
|
||||
integrity sha512-GzsUy/4egJ4cMlxbM+Ub7AMi5CKAc+pxBxrh8MUPQbyStW8jGgnQsJouTnGy0LHawtdEnsCOl6PcO6OgvktXuQ==
|
||||
|
||||
"@swc/core-linux-arm64-musl@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.56.tgz#87c9781f0814bca65074f357e5cfdcdd7fb09845"
|
||||
integrity sha512-9gxL09BIiAv8zY0DjfnFf19bo8+P4T9tdhzPwcm+1yPJcY5yr1+YFWLNFzz01agtOj6VlZ2/wUJTaOfdjjtc+A==
|
||||
|
||||
"@swc/core-linux-x64-gnu@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.56.tgz#55edae77d1c6a2b6230abbc79bccd175cb7c2208"
|
||||
integrity sha512-n0ORNknl50vMRkll3BDO1E4WOqY6iISlPV1ZQCRLWQ6YQ2q8/WAryBxc2OAybcGHBUFkxyACpJukeU1QZ/9tNw==
|
||||
|
||||
"@swc/core-linux-x64-musl@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.56.tgz#45bf5a6611350bcbe3bdd1eac6f5fcfe69502137"
|
||||
integrity sha512-r+D34WLAOAlJtfw1gaVWpHRwCncU9nzW9i7w9kSw4HpWYnHJOz54jLGSEmNsrhdTCz1VK2ar+V2ktFUsrlGlDA==
|
||||
|
||||
"@swc/core-win32-arm64-msvc@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.56.tgz#28853170b9e4f57a793d617aab75ef4b9c4b8a7f"
|
||||
integrity sha512-29Yt75Is6X24z3x8h/xZC1HnDPkPpyLH9mDQiM6Cuc0I9mVr1XSriPEUB2N/awf5IE4SA8c+3IVq1DtKWbkJIw==
|
||||
|
||||
"@swc/core-win32-ia32-msvc@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.56.tgz#dfa120fece0741c6ccc24885d4c155c9593a956e"
|
||||
integrity sha512-mplp0zbYDrcHtfvkniXlXdB04e2qIjz2Gq/XHKr4Rnc6xVORJjjXF91IemXKpavx2oZYJws+LNJL7UFQ8jyCdQ==
|
||||
|
||||
"@swc/core-win32-x64-msvc@1.3.56":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.56.tgz#23b601b9afcdc435e2e4d66767ac5fa6bb50d640"
|
||||
integrity sha512-zp8MBnrw/bjdLenO/ifYzHrImSjKunqL0C2IF4LXYNRfcbYFh2NwobsVQMZ20IT0474lKRdlP8Oxdt+bHuXrzA==
|
||||
|
||||
"@swc/core@^1.2.173":
|
||||
version "1.3.56"
|
||||
resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.3.56.tgz#b12e98bc9ef39dc6092e71ea922f8073f7bec50f"
|
||||
integrity sha512-yz/EeXT+PMZucUNrYceRUaTfuNS4IIu5EDZSOlvCEvm4jAmZi7CYH1B/kvzEzoAOzr7zkQiDPNJftcQXLkjbjA==
|
||||
optionalDependencies:
|
||||
"@swc/core-darwin-arm64" "1.3.56"
|
||||
"@swc/core-darwin-x64" "1.3.56"
|
||||
"@swc/core-linux-arm-gnueabihf" "1.3.56"
|
||||
"@swc/core-linux-arm64-gnu" "1.3.56"
|
||||
"@swc/core-linux-arm64-musl" "1.3.56"
|
||||
"@swc/core-linux-x64-gnu" "1.3.56"
|
||||
"@swc/core-linux-x64-musl" "1.3.56"
|
||||
"@swc/core-win32-arm64-msvc" "1.3.56"
|
||||
"@swc/core-win32-ia32-msvc" "1.3.56"
|
||||
"@swc/core-win32-x64-msvc" "1.3.56"
|
||||
|
||||
"@swc/helpers@0.4.14":
|
||||
version "0.4.14"
|
||||
resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74"
|
||||
|
||||
Reference in New Issue
Block a user