Compare commits

..

4 Commits

Author SHA1 Message Date
88264d890d Remove '.git' from .dockerignore; the Vega build process uses git commands ('rev-parse') to navigate 2024-03-29 18:52:21 -07:00
Alessio
26b78f878b Add a simple path prefix for static assets 2024-03-29 11:12:26 -07:00
Art
054c0377b4
chore(governance): lp votes for batch proposal (#5914)
Co-authored-by: Dariusz Majcherczyk <dariusz.majcherczyk@gmail.com>
2024-03-11 13:10:34 +01:00
Matthew Russell
29bcbd06fb
fix(trading,types): fix default build and type generation commands (#5959) 2024-03-11 10:06:59 +00:00
53 changed files with 455 additions and 352 deletions

View File

@ -4,6 +4,5 @@ tmp/*
.dockerignore .dockerignore
dockerfiles dockerfiles
node_modules node_modules
.git
.github .github
.vscode .vscode

View File

@ -10,7 +10,7 @@ import {
addDecimalsFormatNumber, addDecimalsFormatNumber,
formatNumber, formatNumber,
removePaginationWrapper, removePaginationWrapper,
validForSyntaxHighlighter, suitableForSyntaxHighlighter,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { RouteTitle } from '../../components/route-title'; import { RouteTitle } from '../../components/route-title';
@ -134,7 +134,7 @@ export const NetworkParameterRow = ({
}: { }: {
row: { key: string; value: string }; row: { key: string; value: string };
}) => { }) => {
const isSyntaxRow = validForSyntaxHighlighter(value); const isSyntaxRow = suitableForSyntaxHighlighter(value);
useDocumentTitle(['Network Parameters']); useDocumentTitle(['Network Parameters']);
return ( return (

View File

@ -38,6 +38,7 @@ import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats'; import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
import { MarketName } from '../proposal/market-name'; import { MarketName } from '../proposal/market-name';
import { Indicator } from '../proposal/indicator'; import { Indicator } from '../proposal/indicator';
import { type ProposalNode } from '../proposal/proposal-utils';
const ProposalTypeTags = ({ const ProposalTypeTags = ({
proposal, proposal,
@ -540,10 +541,12 @@ const BatchProposalStateText = ({
export const ProposalHeader = ({ export const ProposalHeader = ({
proposal, proposal,
restData,
isListItem = true, isListItem = true,
voteState, voteState,
}: { }: {
proposal: Proposal | BatchProposal; proposal: Proposal | BatchProposal;
restData?: ProposalNode | null;
isListItem?: boolean; isListItem?: boolean;
voteState?: VoteState | null; voteState?: VoteState | null;
}) => { }) => {
@ -595,7 +598,7 @@ export const ProposalHeader = ({
)} )}
</div> </div>
<ProposalDetails proposal={proposal} /> <ProposalDetails proposal={proposal} />
<VoteBreakdown proposal={proposal} /> <VoteBreakdown proposal={proposal} restData={restData} />
</> </>
); );
}; };

View File

@ -91,6 +91,28 @@ export type ProposalNode = {
proposal: ProposalData; proposal: ProposalData;
proposalType: ProposalNodeType; proposalType: ProposalNodeType;
proposals: SubProposalData[]; proposals: SubProposalData[];
yes?: [
{
partyId: string;
elsPerMarket?: [
{
marketId: string;
els: string;
}
];
}
];
no?: [
{
partyId: string;
elsPerMarket?: [
{
marketId: string;
els: string;
}
];
}
];
}; };
type SingleProposalNode = ProposalNode & { type SingleProposalNode = ProposalNode & {

View File

@ -48,6 +48,7 @@ export const Proposal = ({ proposal, restData }: ProposalProps) => {
<ProposalHeader <ProposalHeader
proposal={proposal} proposal={proposal}
restData={restData}
isListItem={false} isListItem={false}
voteState={voteState} voteState={voteState}
/> />

View File

@ -17,6 +17,7 @@ import {
import { useBatchVoteInformation } from '../../hooks/use-vote-information'; import { useBatchVoteInformation } from '../../hooks/use-vote-information';
import { MarketName } from '../proposal/market-name'; import { MarketName } from '../proposal/market-name';
import { Indicator } from '../proposal/indicator'; import { Indicator } from '../proposal/indicator';
import { type ProposalNode } from '../proposal/proposal-utils';
export const CompactVotes = ({ number }: { number: BigNumber }) => ( export const CompactVotes = ({ number }: { number: BigNumber }) => (
<CompactNumber <CompactNumber
@ -110,24 +111,64 @@ const Status = ({ reached, threshold, text, testId }: StatusProps) => {
export const VoteBreakdown = ({ export const VoteBreakdown = ({
proposal, proposal,
restData,
}: { }: {
proposal: Proposal | BatchProposal; proposal: Proposal | BatchProposal;
restData?: ProposalNode | null;
}) => { }) => {
if (proposal.__typename === 'Proposal') { if (proposal.__typename === 'Proposal') {
return <VoteBreakdownNormal proposal={proposal} />; return <VoteBreakdownNormal proposal={proposal} />;
} }
if (proposal.__typename === 'BatchProposal') { if (proposal.__typename === 'BatchProposal') {
return <VoteBreakdownBatch proposal={proposal} />; return <VoteBreakdownBatch proposal={proposal} restData={restData} />;
} }
return null; return null;
}; };
const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => { const VoteBreakdownBatch = ({
proposal,
restData,
}: {
proposal: BatchProposal;
restData?: ProposalNode | null;
}) => {
const [fullBreakdown, setFullBreakdown] = useState(false); const [fullBreakdown, setFullBreakdown] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
const yesELS =
restData?.yes?.reduce((all, y) => {
if (y.elsPerMarket) {
y.elsPerMarket.forEach((item) => {
const share = Number(item.els);
if (all[item.marketId]) {
all[item.marketId].push(share);
} else {
all[item.marketId] = [share];
}
return all;
});
}
return all;
}, {} as Record<string, number[]>) || {};
const noELS =
restData?.no?.reduce((all, y) => {
if (y.elsPerMarket) {
y.elsPerMarket.forEach((item) => {
const share = Number(item.els);
if (all[item.marketId]) {
all[item.marketId].push(share);
} else {
all[item.marketId] = [share];
}
return all;
});
}
return all;
}, {} as Record<string, number[]>) || {};
const voteInfo = useBatchVoteInformation({ const voteInfo = useBatchVoteInformation({
terms: compact( terms: compact(
proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : [] proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : []
@ -194,6 +235,8 @@ const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
proposal={proposal} proposal={proposal}
votes={proposal.votes} votes={proposal.votes}
terms={p.terms} terms={p.terms}
yesELS={yesELS}
noELS={noELS}
/> />
); );
})} })}
@ -254,6 +297,8 @@ const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
proposal={proposal} proposal={proposal}
votes={proposal.votes} votes={proposal.votes}
terms={p.terms} terms={p.terms}
yesELS={yesELS}
noELS={noELS}
/> />
); );
})} })}
@ -271,17 +316,17 @@ const VoteBreakdownBatchSubProposal = ({
votes, votes,
terms, terms,
indicator, indicator,
yesELS,
noELS,
}: { }: {
proposal: BatchProposal; proposal: BatchProposal;
votes: VoteFieldsFragment; votes: VoteFieldsFragment;
terms: ProposalTermsFieldsFragment; terms: ProposalTermsFieldsFragment;
indicator?: number; indicator?: number;
yesELS: Record<string, number[]>;
noELS: Record<string, number[]>;
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const voteInfo = useVoteInformation({
votes,
terms,
});
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN; const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket'; const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket';
@ -294,6 +339,15 @@ const VoteBreakdownBatchSubProposal = ({
marketId = terms.change.market.id; marketId = terms.change.market.id;
} }
const voteInfo = useVoteInformation({
votes,
terms,
// yes votes ELS for this specific proposal (market)
yesELS: marketId ? yesELS[marketId] : undefined,
// no votes ELS for this specific proposal (market)
noELS: marketId ? noELS[marketId] : undefined,
});
const marketName = marketId ? ( const marketName = marketId ? (
<> <>
: <MarketName marketId={marketId} /> : <MarketName marketId={marketId} />

View File

@ -8,13 +8,18 @@ import {
type VoteFieldsFragment, type VoteFieldsFragment,
} from '../__generated__/Proposals'; } from '../__generated__/Proposals';
import { type ProposalChangeType } from '../types'; import { type ProposalChangeType } from '../types';
import sum from 'lodash/sum';
export const useVoteInformation = ({ export const useVoteInformation = ({
votes, votes,
terms, terms,
yesELS,
noELS,
}: { }: {
votes: VoteFieldsFragment; votes: VoteFieldsFragment;
terms: ProposalTermsFieldsFragment; terms: ProposalTermsFieldsFragment;
yesELS?: number[];
noELS?: number[];
}) => { }) => {
const { const {
appState: { totalSupply, decimals }, appState: { totalSupply, decimals },
@ -31,7 +36,9 @@ export const useVoteInformation = ({
paramsForChange, paramsForChange,
votes, votes,
totalSupply, totalSupply,
decimals decimals,
yesELS,
noELS
); );
}; };
@ -72,7 +79,11 @@ const getVoteData = (
}, },
votes: ProposalFieldsFragment['votes'], votes: ProposalFieldsFragment['votes'],
totalSupply: BigNumber, totalSupply: BigNumber,
decimals: number decimals: number,
/** A list of ELS yes votes */
yesELS?: number[],
/** A list if ELS no votes */
noELS?: number[]
) => { ) => {
const requiredMajorityPercentage = params.requiredMajority const requiredMajorityPercentage = params.requiredMajority
? new BigNumber(params.requiredMajority).times(100) ? new BigNumber(params.requiredMajority).times(100)
@ -86,17 +97,31 @@ const getVoteData = (
addDecimal(votes.no.totalTokens ?? 0, decimals) addDecimal(votes.no.totalTokens ?? 0, decimals)
); );
const noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight let noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
? new BigNumber(0) ? new BigNumber(0)
: new BigNumber(votes.no.totalEquityLikeShareWeight).times(100); : new BigNumber(votes.no.totalEquityLikeShareWeight).times(100);
// there's no meaningful `totalEquityLikeShareWeight` in batch proposals,
// it has to be deduced from `elsPerMarket` of `no` votes of given proposal
// data. (by REST DATA)
if (noELS != null) {
const noTotalELS = sum(noELS);
noEquityLikeShareWeight = new BigNumber(noTotalELS).times(100);
}
const yesTokens = new BigNumber( const yesTokens = new BigNumber(
addDecimal(votes.yes.totalTokens ?? 0, decimals) addDecimal(votes.yes.totalTokens ?? 0, decimals)
); );
const yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight let yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
? new BigNumber(0) ? new BigNumber(0)
: new BigNumber(votes.yes.totalEquityLikeShareWeight).times(100); : new BigNumber(votes.yes.totalEquityLikeShareWeight).times(100);
// there's no meaningful `totalEquityLikeShareWeight` in batch proposals,
// it has to be deduced from `elsPerMarket` of `yes` votes of given proposal
// data. (by REST DATA)
if (noELS != null) {
const yesTotalELS = sum(yesELS);
yesEquityLikeShareWeight = new BigNumber(yesTotalELS).times(100);
}
const totalTokensVoted = yesTokens.plus(noTokens); const totalTokensVoted = yesTokens.plus(noTokens);

View File

@ -1,7 +1,7 @@
import { useState } from 'react'; import { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
import { validForSyntaxHighlighter } from '@vegaprotocol/utils'; import { suitableForSyntaxHighlighter } from '@vegaprotocol/utils';
import { useNetworkParams } from '@vegaprotocol/network-parameters'; import { useNetworkParams } from '@vegaprotocol/network-parameters';
import { import {
getClosingTimestamp, getClosingTimestamp,
@ -46,7 +46,7 @@ const SelectedNetworkParamCurrentValue = ({
<div className="mb-4"> <div className="mb-4">
<p className="text-sm text-white">{t('CurrentValue')}</p> <p className="text-sm text-white">{t('CurrentValue')}</p>
{validForSyntaxHighlighter(value) ? ( {suitableForSyntaxHighlighter(value) ? (
<SyntaxHighlighter data={JSON.parse(value)} /> <SyntaxHighlighter data={JSON.parse(value)} />
) : ( ) : (
<Input <Input

View File

@ -8,7 +8,7 @@ import {
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { useValidateJson } from '@vegaprotocol/react-helpers'; import { useValidateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,

View File

@ -7,7 +7,7 @@ import {
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { useValidateJson } from '@vegaprotocol/react-helpers'; import { useValidateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,

View File

@ -14,7 +14,7 @@ import {
RoundedWrapper, RoundedWrapper,
TextArea, TextArea,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { useValidateJson } from '@vegaprotocol/react-helpers'; import { useValidateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,

View File

@ -7,7 +7,7 @@ import {
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { useValidateJson } from '@vegaprotocol/react-helpers'; import { useValidateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,

View File

@ -8,7 +8,7 @@ import {
useProposalSubmit, useProposalSubmit,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { useValidateJson } from '@vegaprotocol/react-helpers'; import { useValidateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,

View File

@ -9,7 +9,7 @@ import {
VegaIcon, VegaIcon,
VegaIconNames, VegaIconNames,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { URL_REGEX, validVegaPublicKey } from '@vegaprotocol/utils'; import { URL_REGEX, isValidVegaPublicKey } from '@vegaprotocol/utils';
import { type useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction'; import { type useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
import { useT } from '../../lib/use-t'; import { useT } from '../../lib/use-t';
@ -217,7 +217,9 @@ export const TeamForm = ({
validate: { validate: {
allowList: (value) => { allowList: (value) => {
const publicKeys = parseAllowListText(value); const publicKeys = parseAllowListText(value);
if (publicKeys.every((pk) => validVegaPublicKey(pk))) { if (
publicKeys.every((pk) => isValidVegaPublicKey(pk))
) {
return true; return true;
} }
return t('Invalid public key found in allow list'); return t('Invalid public key found in allow list');

View File

@ -2,11 +2,12 @@ import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
import { DocsLinks, useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks, useEnvironment } from '@vegaprotocol/environment';
import { ButtonLink, ExternalLink, Link } from '@vegaprotocol/ui-toolkit'; import { ButtonLink, ExternalLink, Link } from '@vegaprotocol/ui-toolkit';
import type { Market } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets';
import { addDecimalsFormatNumber, fromNanoSeconds } from '@vegaprotocol/utils';
import { import {
useMarketExpiryDate, addDecimalsFormatNumber,
fromNanoSeconds,
getExpiryDate,
getMarketExpiryDate, getMarketExpiryDate,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/utils';
import { import {
Last24hPriceChange, Last24hPriceChange,
Last24hVolume, Last24hVolume,
@ -263,13 +264,12 @@ export const FundingCountdown = ({ marketId }: { marketId: string }) => {
}; };
const ExpiryLabel = ({ market }: ExpiryLabelProps) => { const ExpiryLabel = ({ market }: ExpiryLabelProps) => {
const expiryDate = useMarketExpiryDate(
market.tradableInstrument.instrument.metadata.tags,
market.marketTimestamps.close,
market.state
);
const content = market.tradableInstrument.instrument.metadata.tags const content = market.tradableInstrument.instrument.metadata.tags
? expiryDate ? getExpiryDate(
market.tradableInstrument.instrument.metadata.tags,
market.marketTimestamps.close,
market.state
)
: '-'; : '-';
return <div data-testid="trading-expiry">{content}</div>; return <div data-testid="trading-expiry">{content}</div>;
}; };

View File

@ -11,8 +11,10 @@ import { useMemo } from 'react';
import type { Asset } from '@vegaprotocol/types'; import type { Asset } from '@vegaprotocol/types';
import type { ProductType } from '@vegaprotocol/types'; import type { ProductType } from '@vegaprotocol/types';
import { MarketState, MarketStateMapping } from '@vegaprotocol/types'; import { MarketState, MarketStateMapping } from '@vegaprotocol/types';
import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import {
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers'; addDecimalsFormatNumber,
getMarketExpiryDate,
} from '@vegaprotocol/utils';
import { closedMarketsWithDataProvider, getAsset } from '@vegaprotocol/markets'; import { closedMarketsWithDataProvider, getAsset } from '@vegaprotocol/markets';
import type { DataSourceFilterFragment } from '@vegaprotocol/markets'; import type { DataSourceFilterFragment } from '@vegaprotocol/markets';
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';

View File

@ -7,8 +7,11 @@ import {
useSuccessorMarket, useSuccessorMarket,
type Market, type Market,
} from '@vegaprotocol/markets'; } from '@vegaprotocol/markets';
import { addDecimalsFormatNumber, isNumeric } from '@vegaprotocol/utils'; import {
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers'; addDecimalsFormatNumber,
getMarketExpiryDate,
isNumeric,
} from '@vegaprotocol/utils';
import { useT, ns } from '../../lib/use-t'; import { useT, ns } from '../../lib/use-t';
import { Links } from '../../lib/links'; import { Links } from '../../lib/links';

View File

@ -9,7 +9,7 @@ import {
import { useProfileDialogStore } from '../../stores/profile-dialog-store'; import { useProfileDialogStore } from '../../stores/profile-dialog-store';
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
import { useT } from '../../lib/use-t'; import { useT } from '../../lib/use-t';
import { useRequired } from '@vegaprotocol/react-helpers'; import { useRequired } from '@vegaprotocol/utils';
import { import {
useSimpleTransaction, useSimpleTransaction,
type Status, type Status,

View File

@ -39,6 +39,8 @@ const nextConfig = {
GIT_COMMIT: commitHash, GIT_COMMIT: commitHash,
GIT_TAG: tag, GIT_TAG: tag,
}, },
basePath: '/apps/vegas', // Set the base path
assetPrefix: '/apps/vegas', // Set the asset prefix
}; };
module.exports = SENTRY_AUTH_TOKEN module.exports = SENTRY_AUTH_TOKEN

View File

@ -1,15 +1,13 @@
import sortBy from 'lodash/sortBy'; import sortBy from 'lodash/sortBy';
import { import {
useMaxSafe,
useRequired,
useVegaPublicKey,
addDecimal, addDecimal,
toBigNum, toBigNum,
removeDecimal, removeDecimal,
addDecimalsFormatNumber, addDecimalsFormatNumber,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import {
useMaxSafe,
useRequired,
useVegaPublicKey,
} from '@vegaprotocol/react-helpers';
import { useT } from './use-t'; import { useT } from './use-t';
import { import {
TradingFormGroup, TradingFormGroup,

View File

@ -1,8 +1,7 @@
import { Controller, type Control } from 'react-hook-form'; import { Controller, type Control } from 'react-hook-form';
import type { Market } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets';
import type { OrderFormValues } from '../../hooks/use-form-values'; import type { OrderFormValues } from '../../hooks/use-form-values';
import { determinePriceStep } from '@vegaprotocol/utils'; import { determinePriceStep, useValidateAmount } from '@vegaprotocol/utils';
import { useValidateAmount } from '@vegaprotocol/react-helpers';
import { import {
TradingFormGroup, TradingFormGroup,
Tooltip, Tooltip,

View File

@ -1,7 +1,7 @@
import { Controller, type Control } from 'react-hook-form'; import { Controller, type Control } from 'react-hook-form';
import type { Market } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets';
import type { OrderFormValues } from '../../hooks/use-form-values'; import type { OrderFormValues } from '../../hooks/use-form-values';
import { useValidateAmount } from '@vegaprotocol/react-helpers'; import { useValidateAmount } from '@vegaprotocol/utils';
import { import {
TradingFormGroup, TradingFormGroup,
TradingInput, TradingInput,

View File

@ -8,8 +8,8 @@ import {
formatForInput, formatForInput,
formatValue, formatValue,
removeDecimal, removeDecimal,
useValidateAmount,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { useValidateAmount } from '@vegaprotocol/react-helpers';
import { type Control, type UseFormWatch } from 'react-hook-form'; import { type Control, type UseFormWatch } from 'react-hook-form';
import { useForm, Controller, useController } from 'react-hook-form'; import { useForm, Controller, useController } from 'react-hook-form';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';

View File

@ -31,10 +31,10 @@ import { useOpenVolume } from '@vegaprotocol/positions';
import { import {
toBigNum, toBigNum,
removeDecimal, removeDecimal,
useValidateAmount,
formatForInput, formatForInput,
formatValue, formatValue,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { useValidateAmount } from '@vegaprotocol/react-helpers';
import { activeOrdersProvider } from '@vegaprotocol/orders'; import { activeOrdersProvider } from '@vegaprotocol/orders';
import { import {
getAsset, getAsset,

View File

@ -1,18 +1,16 @@
import type { Asset, AssetFieldsFragment } from '@vegaprotocol/assets'; import type { Asset, AssetFieldsFragment } from '@vegaprotocol/assets';
import { AssetOption } from '@vegaprotocol/assets'; import { AssetOption } from '@vegaprotocol/assets';
import { import {
addDecimal,
isAssetTypeERC20,
formatNumber,
} from '@vegaprotocol/utils';
import {
useLocalStorage,
useEthereumAddress, useEthereumAddress,
useRequired, useRequired,
useVegaPublicKey, useVegaPublicKey,
useMinSafe, useMinSafe,
useMaxSafe, useMaxSafe,
} from '@vegaprotocol/react-helpers'; addDecimal,
isAssetTypeERC20,
formatNumber,
} from '@vegaprotocol/utils';
import { useLocalStorage } from '@vegaprotocol/react-helpers';
import { import {
TradingFormGroup, TradingFormGroup,
TradingInput, TradingInput,

View File

@ -16,7 +16,6 @@ import en_markets from './locales/en/markets.json';
import en_web3 from './locales/en/web3.json'; import en_web3 from './locales/en/web3.json';
import en_proposals from './locales/en/proposals.json'; import en_proposals from './locales/en/proposals.json';
import en_positions from './locales/en/positions.json'; import en_positions from './locales/en/positions.json';
import en_react_helpers from './locales/en/react-helpers.json';
import en_trades from './locales/en/trading.json'; import en_trades from './locales/en/trading.json';
import en_ui_toolkit from './locales/en/ui-toolkit.json'; import en_ui_toolkit from './locales/en/ui-toolkit.json';
import en_wallet from './locales/en/wallet.json'; import en_wallet from './locales/en/wallet.json';
@ -40,7 +39,6 @@ export const locales = {
web3: en_web3, web3: en_web3,
positions: en_positions, positions: en_positions,
proposals: en_proposals, proposals: en_proposals,
react_helpers: en_react_helpers,
trades: en_trades, trades: en_trades,
'ui-toolkit': en_ui_toolkit, 'ui-toolkit': en_ui_toolkit,
wallet: en_wallet, wallet: en_wallet,

View File

@ -27,8 +27,8 @@ import {
formatNumber, formatNumber,
formatNumberPercentage, formatNumberPercentage,
getDateTimeFormat, getDateTimeFormat,
getMarketExpiryDateFormatted,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { getMarketExpiryDateFormatted } from '@vegaprotocol/react-helpers';
import type { Get } from 'type-fest'; import type { Get } from 'type-fest';
import { MarketInfoTable } from './info-key-value-table'; import { MarketInfoTable } from './info-key-value-table';
import type { import type {

View File

@ -3,10 +3,10 @@ import {
getDateTimeFormat, getDateTimeFormat,
addDecimal, addDecimal,
addDecimalsFormatNumber, addDecimalsFormatNumber,
useValidateAmount,
determinePriceStep, determinePriceStep,
determineSizeStep, determineSizeStep,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { useValidateAmount } from '@vegaprotocol/react-helpers';
import { Size } from '@vegaprotocol/datagrid'; import { Size } from '@vegaprotocol/datagrid';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { import {

View File

@ -3,8 +3,8 @@ import {
getDateTimeFormat, getDateTimeFormat,
isNumeric, isNumeric,
toBigNum, toBigNum,
useFormatTrigger,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { useFormatTrigger } from '@vegaprotocol/react-helpers';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { import {
ActionsDropdown, ActionsDropdown,

View File

@ -12,8 +12,5 @@ export * from './use-theme-switcher';
export * from './use-storybook-theme-observer'; export * from './use-storybook-theme-observer';
export * from './use-yesterday'; export * from './use-yesterday';
export * from './use-previous'; export * from './use-previous';
export * from './use-validate';
export * from './use-market-expiry-date';
export { useScript } from './use-script'; export { useScript } from './use-script';
export { useUserAgent } from './use-user-agent'; export { useUserAgent } from './use-user-agent';
export { useFormatTrigger } from './use-format-trigger';

View File

@ -1,121 +0,0 @@
import { useCallback } from 'react';
import BigNumber from 'bignumber.js';
import * as utils from '@vegaprotocol/utils';
import { useT } from './use-t';
export const useRequired = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!utils.validRequired(value)) {
return t('Required');
}
return true;
},
[t]
);
};
export const useEthereumAddress = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!utils.validEthAddress(value)) {
return t('Invalid Ethereum address');
}
return true;
},
[t]
);
};
export const useVegaPublicKey = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!utils.validVegaPublicKey(value)) {
return t('Invalid Vega key');
}
return true;
},
[t]
);
};
export const useMinSafe = () => {
const t = useT();
return useCallback(
(min: BigNumber) => (value: string) => {
if (utils.validMinSafe(value, min)) {
return t('Value is below minimum');
}
return true;
},
[t]
);
};
export const useMaxSafe = () => {
const t = useT();
return useCallback(
(max: BigNumber) => (value: string) => {
if (utils.validMaxSafe(value, max)) {
return t('Value is above maximum');
}
return true;
},
[t]
);
};
export const useValidateJson = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!utils.validJSON(value)) {
return t('Must be valid JSON');
}
return true;
},
[t]
);
};
export const useValidateUrl = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!utils.validUrl(value)) {
return t('Invalid URL');
}
return true;
},
[t]
);
};
/** Used in deal ticket price/size amounts */
export const useValidateAmount = () => {
const t = useT();
return useCallback(
(step: number | string, field: string) => {
return (value?: string) => {
if (!utils.validStep(step, value)) {
if (new BigNumber(step).isEqualTo(1)) {
return t('{{field}} must be whole numbers for this market', {
field,
step,
});
}
return t('{{field}} must be a multiple of {{step}} for this market', {
field,
step,
});
}
return true;
};
},
[t]
);
};

View File

@ -17,8 +17,7 @@ import {
type SymbolQuery, type SymbolQuery,
type SymbolQueryVariables, type SymbolQueryVariables,
} from './__generated__/Symbol'; } from './__generated__/Symbol';
import { toBigNum } from '@vegaprotocol/utils'; import { getMarketExpiryDate, toBigNum } from '@vegaprotocol/utils';
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers';
import { import {
type IBasicDataFeed, type IBasicDataFeed,
type DatafeedConfiguration, type DatafeedConfiguration,

View File

@ -34,6 +34,21 @@
"options": { "options": {
"jestConfig": "libs/types/jest.config.ts" "jestConfig": "libs/types/jest.config.ts"
} }
},
"generate": {
"executor": "nx:run-commands",
"options": {
"commands": ["npx graphql-codegen --config=libs/types/codegen.yml"],
"parallel": false
}
},
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
} }
}, },
"tags": [] "tags": []

View File

@ -1,6 +1,6 @@
{ {
"extends": ["../../.eslintrc.json"], "extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"], "ignorePatterns": ["!**/*", "__generated__"],
"overrides": [ "overrides": [
{ {
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
@ -9,18 +9,16 @@
"error", "error",
{ {
"paths": [ "paths": [
"error",
"@apollo/client", "@apollo/client",
"@ethersproject",
"@vegaprotocol/data-provider", "@vegaprotocol/data-provider",
"ag-grid-react", "ag-grid-react",
"ag-grid-community", "ag-grid-community",
"ethers",
"graphql", "graphql",
"graphql-tag", "graphql-tag",
"graphql-ws", "graphql-ws",
"react", "ethers",
"react-dom", "@ethersproject"
"react-i18next"
], ],
"patterns": ["@sentry/*"] "patterns": ["@sentry/*"]
} }

View File

@ -7,6 +7,10 @@
"date-fns": "^2.28.0", "date-fns": "^2.28.0",
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"peerDependencies": {
"react": "18.2.0",
"react-i18next": "13.5.0"
},
"type": "module", "type": "module",
"module": "./index.js" "module": "./index.js"
} }

View File

@ -35,6 +35,14 @@
"options": { "options": {
"jestConfig": "libs/utils/jest.config.ts" "jestConfig": "libs/utils/jest.config.ts"
} }
},
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
} }
}, },
"tags": [] "tags": []

View File

@ -7,6 +7,7 @@ export * from './lib/helpers';
export * from './lib/is-asset-erc20'; export * from './lib/is-asset-erc20';
export * from './lib/is-valid-url'; export * from './lib/is-valid-url';
export * from './lib/local-storage'; export * from './lib/local-storage';
export * from './lib/markets';
export * from './lib/price-change'; export * from './lib/price-change';
export * from './lib/remove-0x'; export * from './lib/remove-0x';
export * from './lib/remove-pagination-wrapper'; export * from './lib/remove-pagination-wrapper';

View File

@ -3,4 +3,5 @@ export * from './number';
export * from './range'; export * from './range';
export * from './size'; export * from './size';
export * from './strings'; export * from './strings';
export * from './trigger';
export * from './ether'; export * from './ether';

View File

@ -1,7 +1,7 @@
import { useCallback } from 'react';
import { type StopOrder, StopOrderTriggerDirection } from '@vegaprotocol/types'; import { type StopOrder, StopOrderTriggerDirection } from '@vegaprotocol/types';
import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { addDecimalsFormatNumber } from './number';
import { useT } from './use-t'; import { useCallback } from 'react';
import { useT } from '../use-t';
export const useFormatTrigger = () => { export const useFormatTrigger = () => {
const t = useT(); const t = useT();

View File

@ -1,10 +1,42 @@
import { MarketState } from '@vegaprotocol/types'; import { MarketState } from '@vegaprotocol/types';
import { getDateTimeFormat } from '@vegaprotocol/utils';
import { isValid, parseISO } from 'date-fns'; import { isValid, parseISO } from 'date-fns';
import { getDateTimeFormat } from './format';
import { useT } from './use-t'; import { useT } from './use-t';
export const useMarketExpiryDate = ( export const getMarketExpiryDate = (
tags: ReadonlyArray<string> | null | undefined, tags?: ReadonlyArray<string> | null
): Date | null => {
if (tags) {
const dateFound = tags.reduce<Date | null>((agg, tag) => {
const parsed = parseISO(
(tag.match(/^settlement.*:/) &&
tag
.split(':')
.filter((item, i) => i)
.join(':')) as string
);
if (isValid(parsed)) {
agg = parsed;
}
return agg;
}, null);
return dateFound;
}
return null;
};
export const getMarketExpiryDateFormatted = (
tags?: ReadonlyArray<string> | null
): string | null => {
if (tags) {
const dateFound = getMarketExpiryDate(tags);
return dateFound ? getDateTimeFormat().format(dateFound) : null;
}
return null;
};
export const getExpiryDate = (
tags: ReadonlyArray<string> | null,
close: string | null, close: string | null,
state: MarketState state: MarketState
): string => { ): string => {
@ -35,35 +67,3 @@ export const useMarketExpiryDate = (
} }
return content; return content;
}; };
export const getMarketExpiryDateFormatted = (
tags?: ReadonlyArray<string> | null
): string | null => {
if (tags) {
const dateFound = getMarketExpiryDate(tags);
return dateFound ? getDateTimeFormat().format(dateFound) : null;
}
return null;
};
export const getMarketExpiryDate = (
tags?: ReadonlyArray<string> | null
): Date | null => {
if (tags) {
const dateFound = tags.reduce<Date | null>((agg, tag) => {
const parsed = parseISO(
(tag.match(/^settlement.*:/) &&
tag
.split(':')
.filter((item, i) => i)
.join(':')) as string
);
if (isValid(parsed)) {
agg = parsed;
}
return agg;
}, null);
return dateFound;
}
return null;
};

View File

@ -1,3 +1,3 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
export const ns = 'react-helpers'; export const ns = 'utils';
export const useT = () => useTranslation(ns).t; export const useT = () => useTranslation(ns).t;

View File

@ -1,66 +1,40 @@
import { validEthAddress, validVegaPublicKey, validStep } from './common'; import { renderHook } from '@testing-library/react';
import { useEthereumAddress, useVegaPublicKey } from './common';
it('ethereumAddress', () => {
const result = renderHook(useEthereumAddress);
const ethereumAddress = result.result.current;
const errorMessage = 'Invalid Ethereum address';
it('validEthAddress', () => {
const validAddress = '0x72c22822A19D20DE7e426fB84aa047399Ddd8853'; const validAddress = '0x72c22822A19D20DE7e426fB84aa047399Ddd8853';
expect(validEthAddress(validAddress)).toEqual(true); expect(ethereumAddress(validAddress)).toEqual(true);
const invalidChars = '0xzzc22822A19D20DE7e426fB84aa047399Ddd8853'; const invalidChars = '0xzzc22822A19D20DE7e426fB84aa047399Ddd8853';
expect(validEthAddress(invalidChars)).toEqual(false); expect(ethereumAddress(invalidChars)).toEqual(errorMessage);
const tooManyChars = '0x72c22822A19D20DE7e426fB84aa047399Ddd88531111111'; const tooManyChars = '0x72c22822A19D20DE7e426fB84aa047399Ddd88531111111';
expect(validEthAddress(tooManyChars)).toEqual(false); expect(ethereumAddress(tooManyChars)).toEqual(errorMessage);
const no0x = '1x72c22822A19D20DE7e426fB84aa047399Ddd8853'; const no0x = '1x72c22822A19D20DE7e426fB84aa047399Ddd8853';
expect(validEthAddress(no0x)).toEqual(false); expect(ethereumAddress(no0x)).toEqual(errorMessage);
}); });
it('validVegaPublicKey', () => { it('vegaPublicKey', () => {
const result = renderHook(useVegaPublicKey);
const vegaPublicKey = result.result.current;
const errorMessage = 'Invalid Vega key';
const validKey = const validKey =
'70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680'; '70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680';
expect(validVegaPublicKey(validKey)).toEqual(true); expect(vegaPublicKey(validKey)).toEqual(true);
const invalidChars = const invalidChars =
'zzz14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680'; 'zzz14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680';
expect(validVegaPublicKey(invalidChars)).toEqual(false); expect(vegaPublicKey(invalidChars)).toEqual(errorMessage);
const tooManyChars = const tooManyChars =
'70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680111111'; '70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680111111';
expect(validVegaPublicKey(tooManyChars)).toEqual(false); expect(vegaPublicKey(tooManyChars)).toEqual(errorMessage);
});
describe('validateAgainstStep', () => {
it('fails when step is an empty string', () => {
expect(validStep('', '1234')).toEqual(false);
});
it.each([
[0, 0],
[1234567890, 0],
[0.03, 0.03],
[0.09, 0.03],
[0.27, 0.03],
[1, 1],
[123, 1],
[4, 2],
[8, 2],
])(
'checks whether given value (%s) IS a multiple of given step (%s)',
(value, step) => {
expect(validStep(step, value)).toEqual(true);
}
);
it.each([
[1, 2],
[0.1, 0.003],
[1.11, 0.1],
[123.1, 1],
[222, 221],
[NaN, 1],
])(
'checks whether given value (%s) IS NOT a multiple of given step (%s)',
(value, step) => {
expect(validStep(step, value)).toEqual(false);
}
);
}); });

View File

@ -1,52 +1,77 @@
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { useT } from '../use-t';
import { useCallback } from 'react';
export const validRequired = (value: string | number | undefined | null) => { export const useRequired = () => {
if (value === null || value === undefined || value === '') { const t = useT();
return false; return useCallback(
} (value: string) => {
return true; if (value === null || value === undefined || value === '') {
return t('Required');
}
return true;
},
[t]
);
};
export const useEthereumAddress = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!/^0x[0-9a-fA-F]{40}$/i.test(value)) {
return t('Invalid Ethereum address');
}
return true;
},
[t]
);
}; };
export const VEGA_ID_REGEX = /^[A-Fa-f0-9]{64}$/i; export const VEGA_ID_REGEX = /^[A-Fa-f0-9]{64}$/i;
export const validVegaPublicKey = (value: string) => { export const isValidVegaPublicKey = (value: string) => {
return VEGA_ID_REGEX.test(value); return VEGA_ID_REGEX.test(value);
}; };
export const useVegaPublicKey = () => {
export const URL_REGEX = const t = useT();
/^(https?:\/\/)?([a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+)(:[0-9]{1,5})?(\/[^\s]*)?$/; return useCallback(
export const validUrl = (value: string) => { (value: string) => {
return URL_REGEX.test(value); if (!isValidVegaPublicKey(value)) {
return t('Invalid Vega key');
}
return true;
},
[t]
);
}; };
export const ETH_ADDRESS = /^0x[0-9a-fA-F]{40}$/i; export const useMinSafe = () => {
export const validEthAddress = (value: string) => { const t = useT();
return ETH_ADDRESS.test(value); return useCallback(
(min: BigNumber) => (value: string) => {
if (new BigNumber(value).isLessThan(min)) {
return t('Value is below minimum');
}
return true;
},
[t]
);
}; };
export const validMinSafe = ( export const useMaxSafe = () => {
value: string | number | BigNumber, const t = useT();
min: string | number | BigNumber return useCallback(
) => { (max: BigNumber) => (value: string) => {
return new BigNumber(value).isLessThan(min); if (new BigNumber(value).isGreaterThan(max)) {
return t('Value is above maximum');
}
return true;
},
[t]
);
}; };
export const validMaxSafe = ( export const suitableForSyntaxHighlighter = (str: string) => {
value: string | number | BigNumber,
max: string | number | BigNumber
) => {
return new BigNumber(value).isGreaterThan(max);
};
export const validJSON = (value: string) => {
try {
JSON.parse(value);
return true;
} catch (e) {
return false;
}
};
export const validForSyntaxHighlighter = (str: string) => {
try { try {
const test = JSON.parse(str); const test = JSON.parse(str);
return test && Object.keys(test).length > 0; return test && Object.keys(test).length > 0;
@ -55,17 +80,35 @@ export const validForSyntaxHighlighter = (str: string) => {
} }
}; };
export const validStep = (step: string | number, input?: string | number) => { export const useValidateJson = () => {
const stepValue = new BigNumber(step); const t = useT();
if (stepValue.isNaN()) { return useCallback(
// unable to check if step is not a number (value: string) => {
return false; try {
} JSON.parse(value);
if (stepValue.isZero()) { return true;
// every number is valid when step is zero } catch (e) {
return true; return t('Must be valid JSON');
} }
},
const value = new BigNumber(input || ''); [t]
return value.modulo(stepValue).isZero(); );
};
export const URL_REGEX =
/^(https?:\/\/)?([a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+)(:[0-9]{1,5})?(\/[^\s]*)?$/;
const isValidUrl = (value: string) => {
return URL_REGEX.test(value);
};
export const useValidateUrl = () => {
const t = useT();
return useCallback(
(value: string) => {
if (!isValidUrl(value)) {
return t('Invalid URL');
}
return true;
},
[t]
);
}; };

View File

@ -1 +1,2 @@
export * from './common'; export * from './common';
export * from './validate-amount';

View File

@ -0,0 +1,38 @@
import { validateAgainstStep } from './validate-amount';
describe('validateAgainstStep', () => {
it('fails when step is an empty string', () => {
expect(validateAgainstStep('', '1234')).toEqual(false);
});
it.each([
[0, 0],
[1234567890, 0],
[0.03, 0.03],
[0.09, 0.03],
[0.27, 0.03],
[1, 1],
[123, 1],
[4, 2],
[8, 2],
])(
'checks whether given value (%s) IS a multiple of given step (%s)',
(value, step) => {
expect(validateAgainstStep(step, value)).toEqual(true);
}
);
it.each([
[1, 2],
[0.1, 0.003],
[1.11, 0.1],
[123.1, 1],
[222, 221],
[NaN, 1],
])(
'checks whether given value (%s) IS NOT a multiple of given step (%s)',
(value, step) => {
expect(validateAgainstStep(step, value)).toEqual(false);
}
);
});

View File

@ -0,0 +1,50 @@
import { useCallback } from 'react';
import { useT } from '../use-t';
import BigNumber from 'bignumber.js';
export const useValidateAmount = () => {
const t = useT();
return useCallback(
(step: number | string, field: string) => {
return (value?: string) => {
const isValid = validateAgainstStep(step, value);
if (!isValid) {
if (new BigNumber(step).isEqualTo(1)) {
return t('{{field}} must be whole numbers for this market', {
field,
step,
});
}
return t('{{field}} must be a multiple of {{step}} for this market', {
field,
step,
});
}
return true;
};
},
[t]
);
};
const isMultipleOf = (value: BigNumber, multipleOf: BigNumber) =>
value.modulo(multipleOf).isZero();
export const validateAgainstStep = (
step: string | number,
input?: string | number
) => {
const stepValue = new BigNumber(step);
if (stepValue.isNaN()) {
// unable to check if step is not a number
return false;
}
if (stepValue.isZero()) {
// every number is valid when step is zero
return true;
}
const value = new BigNumber(input || '');
return isMultipleOf(value, stepValue);
};

View File

@ -35,6 +35,14 @@
"options": { "options": {
"jestConfig": "libs/wallet/jest.config.ts" "jestConfig": "libs/wallet/jest.config.ts"
} }
},
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
} }
}, },
"tags": [] "tags": []

View File

@ -1,6 +1,6 @@
import { type StoreApi } from 'zustand'; import { type StoreApi } from 'zustand';
import { type Store, type Connector } from '../types'; import { type Store, type Connector } from '../types';
import { validVegaPublicKey } from '@vegaprotocol/utils'; import { isValidVegaPublicKey } from '@vegaprotocol/utils';
import { import {
ConnectorError, ConnectorError,
chainIdError, chainIdError,
@ -40,7 +40,7 @@ export class ViewPartyConnector implements Connector {
throw userRejectedError(); throw userRejectedError();
} }
if (!validVegaPublicKey(value)) { if (!isValidVegaPublicKey(value)) {
throw connectError('invalid public key'); throw connectError('invalid public key');
} }

View File

@ -40,9 +40,9 @@ import {
formatNumber, formatNumber,
toBigNum, toBigNum,
truncateByChars, truncateByChars,
useFormatTrigger,
HALFMAXGOINT64, HALFMAXGOINT64,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { useFormatTrigger } from '@vegaprotocol/react-helpers';
import { useAssetsMapProvider } from '@vegaprotocol/assets'; import { useAssetsMapProvider } from '@vegaprotocol/assets';
import { useEthWithdrawApprovalsStore } from './use-ethereum-withdraw-approvals-store'; import { useEthWithdrawApprovalsStore } from './use-ethereum-withdraw-approvals-store';
import { DApp, EXPLORER_TX, useLinks } from '@vegaprotocol/environment'; import { DApp, EXPLORER_TX, useLinks } from '@vegaprotocol/environment';

View File

@ -1,15 +1,13 @@
import type { Asset } from '@vegaprotocol/assets'; import type { Asset } from '@vegaprotocol/assets';
import { AssetOption } from '@vegaprotocol/assets'; import { AssetOption } from '@vegaprotocol/assets';
import {
removeDecimal,
isAssetTypeERC20,
formatNumber,
} from '@vegaprotocol/utils';
import { import {
useEthereumAddress, useEthereumAddress,
useRequired, useRequired,
useMinSafe, useMinSafe,
} from '@vegaprotocol/react-helpers'; removeDecimal,
isAssetTypeERC20,
formatNumber,
} from '@vegaprotocol/utils';
import { useLocalStorage } from '@vegaprotocol/react-helpers'; import { useLocalStorage } from '@vegaprotocol/react-helpers';
import { import {
TradingFormGroup, TradingFormGroup,

View File

@ -241,8 +241,5 @@
"graphql": "15.8.0", "graphql": "15.8.0",
"//": "workaround storybook issue: https://github.com/storybookjs/storybook/issues/21642", "//": "workaround storybook issue: https://github.com/storybookjs/storybook/issues/21642",
"@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.cd77847.0" "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.cd77847.0"
},
"nx": {
"includedScripts": []
} }
} }

View File

@ -1,14 +0,0 @@
{
"name": "nx-monorepo",
"$schema": "node_modules/nx/schemas/project-schema.json",
"targets": {
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
}
}
}