diff --git a/apps/explorer/src/app/components/jump-to/index.tsx b/apps/explorer/src/app/components/jump-to/index.tsx index c1807a9e3..c00f47de8 100644 --- a/apps/explorer/src/app/components/jump-to/index.tsx +++ b/apps/explorer/src/app/components/jump-to/index.tsx @@ -36,7 +36,12 @@ export const JumpTo = ({ placeholder={placeholder} className="max-w-[200px]" /> - diff --git a/apps/explorer/src/app/components/search/search.tsx b/apps/explorer/src/app/components/search/search.tsx index 3c33ffb47..ea4e9e932 100644 --- a/apps/explorer/src/app/components/search/search.tsx +++ b/apps/explorer/src/app/components/search/search.tsx @@ -75,7 +75,12 @@ export const Search = () => { )} - diff --git a/apps/simple-trading-app/src/app/components/drawer/drawer-toggle.tsx b/apps/simple-trading-app/src/app/components/drawer/drawer-toggle.tsx index a9fbc02b7..aec0e1c18 100644 --- a/apps/simple-trading-app/src/app/components/drawer/drawer-toggle.tsx +++ b/apps/simple-trading-app/src/app/components/drawer/drawer-toggle.tsx @@ -35,7 +35,7 @@ export const DrawerToggle = ({ }, [variant]); return ( - ); diff --git a/apps/simple-trading-app/src/app/components/simple-market-list/simple-market-list.tsx b/apps/simple-trading-app/src/app/components/simple-market-list/simple-market-list.tsx index 831470e8d..f5ae85aab 100644 --- a/apps/simple-trading-app/src/app/components/simple-market-list/simple-market-list.tsx +++ b/apps/simple-trading-app/src/app/components/simple-market-list/simple-market-list.tsx @@ -101,7 +101,7 @@ const SimpleMarketList = () => {
diff --git a/apps/simple-trading-app/src/app/components/stepper/stepper.tsx b/apps/simple-trading-app/src/app/components/stepper/stepper.tsx index 3a9bb0006..3d099ffa5 100644 --- a/apps/simple-trading-app/src/app/components/stepper/stepper.tsx +++ b/apps/simple-trading-app/src/app/components/stepper/stepper.tsx @@ -70,7 +70,7 @@ export default ({ steps }: StepperProps) => { {index === steps.length - 1 ? 'Finish' : 'Continue'} @@ -215,7 +220,8 @@ export const EthWallet = () => { {account ? ( ) : ( - + )} {account && ( diff --git a/apps/token/src/components/locked-progress/locked-progress.tsx b/apps/token/src/components/locked-progress/locked-progress.tsx index 3c12cb031..ed9637b8a 100644 --- a/apps/token/src/components/locked-progress/locked-progress.tsx +++ b/apps/token/src/components/locked-progress/locked-progress.tsx @@ -1,8 +1,8 @@ import React from 'react'; - import { formatNumber } from '../../lib/format-number'; import type { BigNumber } from '../../lib/bignumber'; import { theme } from '@vegaprotocol/tailwindcss-config'; +import classnames from 'classnames'; const Colors = theme.colors; @@ -14,9 +14,10 @@ const ProgressContents = ({ children: React.ReactNode; }) => (
{children}
@@ -25,17 +26,22 @@ const ProgressContents = ({ const ProgressIndicator = ({ bgColor, side, + light, }: { bgColor: string; side: 'left' | 'right'; + light: boolean; }) => ( ); @@ -64,6 +70,7 @@ export interface LockedProgressProps { leftColor?: string; rightColor?: string; light?: boolean; + decimals?: number; } export const LockedProgress = ({ @@ -73,8 +80,9 @@ export const LockedProgress = ({ leftLabel, rightLabel, leftColor = Colors.vega.pink, - rightColor = Colors.green.DEFAULT, + rightColor = Colors.vega.green, light = false, + decimals = 2, }: LockedProgressProps) => { const lockedPercentage = React.useMemo(() => { return locked.div(total).times(100); @@ -85,26 +93,35 @@ export const LockedProgress = ({ }, [total, unlocked]); return ( -
-
+ <> +
- + {leftLabel} {rightLabel} - + - {formatNumber(locked, 2)} - {formatNumber(unlocked, 2)} + {formatNumber(locked, decimals)} + {formatNumber(unlocked, decimals)} -
+ ); }; diff --git a/apps/token/src/components/vega-wallet/vega-wallet.tsx b/apps/token/src/components/vega-wallet/vega-wallet.tsx index 79b582949..307e6f392 100644 --- a/apps/token/src/components/vega-wallet/vega-wallet.tsx +++ b/apps/token/src/components/vega-wallet/vega-wallet.tsx @@ -180,15 +180,15 @@ const VegaWalletConnected = ({ vegaKeys }: VegaWalletConnectedProps) => {
))} - - + + - - + + diff --git a/apps/token/src/config/env.ts b/apps/token/src/config/env.ts index 48df11587..1e5d972c8 100644 --- a/apps/token/src/config/env.ts +++ b/apps/token/src/config/env.ts @@ -55,6 +55,9 @@ export const ENV = { commit: windowOrDefault('NX_COMMIT_REF'), branch: windowOrDefault('NX_BRANCH'), vegaUrl: windowOrDefault('NX_VEGA_URL'), + urlConnect: TRUTHY.includes(windowOrDefault('NX_ETH_URL_CONNECT')), + ethWalletMnemonic: windowOrDefault('NX_ETH_WALLET_MNEMONIC'), + localProviderUrl: windowOrDefault('NX_LOCAL_PROVIDER_URL'), flags: { NETWORK_DOWN: TRUTHY.includes(windowOrDefault('NX_NETWORK_DOWN')), HOSTED_WALLET_ENABLED: TRUTHY.includes( diff --git a/apps/token/src/hooks/__mocks__/use-tranches.ts b/apps/token/src/hooks/__mocks__/use-tranches.ts index 42afaf090..2aa866267 100644 --- a/apps/token/src/hooks/__mocks__/use-tranches.ts +++ b/apps/token/src/hooks/__mocks__/use-tranches.ts @@ -1,10 +1,8 @@ import React from 'react'; -import { useContracts } from '../../contexts/contracts/contracts-context'; import mock from './tranches-mock'; import type { Tranche } from '@vegaprotocol/smart-contracts'; export function useTranches() { - const { vesting } = useContracts(); const [tranches, setTranches] = React.useState(null); const [error, setError] = React.useState(null); @@ -17,7 +15,7 @@ export function useTranches() { } }; run(); - }, [vesting]); + }, []); return { tranches, error }; } diff --git a/apps/token/src/hooks/use-refresh-associated-balances.ts b/apps/token/src/hooks/use-refresh-associated-balances.ts index 6f0831f89..f87ae011e 100644 --- a/apps/token/src/hooks/use-refresh-associated-balances.ts +++ b/apps/token/src/hooks/use-refresh-associated-balances.ts @@ -1,3 +1,4 @@ +import { toBigNum } from '@vegaprotocol/react-helpers'; import React from 'react'; import { @@ -7,23 +8,26 @@ import { import { useContracts } from '../contexts/contracts/contracts-context'; export function useRefreshAssociatedBalances() { - const { appDispatch } = useAppState(); + const { + appDispatch, + appState: { decimals }, + } = useAppState(); const { staking, vesting } = useContracts(); return React.useCallback( async (ethAddress: string, vegaKey: string) => { const [walletAssociatedBalance, vestingAssociatedBalance] = await Promise.all([ - staking.stakeBalance(ethAddress, `0x${vegaKey}`), - vesting.stakeBalance(ethAddress, `0x${vegaKey}`), + staking.stakeBalance(ethAddress, vegaKey), + vesting.stakeBalance(ethAddress, vegaKey), ]); appDispatch({ type: AppStateActionType.REFRESH_ASSOCIATED_BALANCES, - walletAssociatedBalance, - vestingAssociatedBalance, + walletAssociatedBalance: toBigNum(walletAssociatedBalance, decimals), + vestingAssociatedBalance: toBigNum(vestingAssociatedBalance, decimals), }); }, - [staking, vesting, appDispatch] + [staking, vesting, appDispatch, decimals] ); } diff --git a/apps/token/src/i18n/translations/dev.json b/apps/token/src/i18n/translations/dev.json index bc61ef421..6f6463837 100644 --- a/apps/token/src/i18n/translations/dev.json +++ b/apps/token/src/i18n/translations/dev.json @@ -193,6 +193,7 @@ "noGovernanceTokens": "You need some VEGA tokens to participate in governance", "youVoted": "You voted", "changeVote": "Change vote", + "voteRequested": "Please confirm transaction in wallet", "votePending": "Casting vote", "voteError": "Something went wrong, and your vote was not seen by the network", "back": "back", @@ -280,6 +281,7 @@ "stakingHasAssociated": "You have {{tokens}} $VEGA tokens associated.", "stakingAssociateMoreButton": "Associate more $VEGA tokens with wallet", "stakingDisassociateButton": "Disassociate $VEGA tokens from wallet", + "stakingConfirm": "Open you wallet app to confirm", "associateButton": "Associate $VEGA tokens with wallet", "nodeQueryFailed": "Could not get data for validator {{node}}", "stakeAddPendingTitle": "Adding {{amount}} $VEGA to validator {{node}}", @@ -540,5 +542,8 @@ "numberOfAgainstVotes": "Number of votes against", "yesPercentage": "Yes percentage", "noPercentage": "No percentage", - "proposalTerms": "Proposal terms" + "proposalTerms": "Proposal terms", + "currentlySetTo": "Currently set to ", + "pass": "Pass", + "fail": "Fail" } diff --git a/apps/token/src/index.html b/apps/token/src/index.html index 6396c83af..33627cdd5 100644 --- a/apps/token/src/index.html +++ b/apps/token/src/index.html @@ -1,5 +1,5 @@ - + diff --git a/apps/token/src/lib/url-connector.ts b/apps/token/src/lib/url-connector.ts new file mode 100644 index 000000000..0133e0f75 --- /dev/null +++ b/apps/token/src/lib/url-connector.ts @@ -0,0 +1,150 @@ +import { ethers, Wallet } from 'ethers'; +import { Connector } from '@web3-react/types'; + +import { Eip1193Bridge } from '@ethersproject/experimental'; +import type { ConnectionInfo } from '@ethersproject/web'; +import type { Actions } from '@web3-react/types'; +import { ENV } from '../config/env'; + +export class CustomizedBridge extends Eip1193Bridge { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async sendAsync(...args: any) { + console.debug('sendAsync called', ...args); + return this.send(...args); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + override async send(...args: any) { + console.debug('send called', ...args); + const isCallbackForm = + typeof args[0] === 'object' && typeof args[1] === 'function'; + let callback; + let method; + let params; + if (isCallbackForm) { + callback = args[1]; + method = args[0].method; + params = args[0].params; + } else { + method = args[0]; + params = args[1]; + } + try { + // Hacky, https://github.com/ethers-io/ethers.js/issues/1683#issuecomment-1016227588 + + // If from is present on eth_call it errors, removing it makes the library set + // from as the connected wallet which works fine + if (params && params.length && params[0].from && method === 'eth_call') + delete params[0].from; + let result; + // For sending a transaction if we call send it will error + // as it wants gasLimit in sendTransaction but hexlify sets the property gas + // to gasLimit which makes sensd transaction error. + // This has taken the code from the super method for sendTransaction and altered + // it slightly to make it work with the gas limit issues. + if ( + params && + params.length && + params[0].from && + method === 'eth_sendTransaction' + ) { + // Hexlify will not take gas, must be gasLimit, set this property to be gasLimit + params[0].gasLimit = params[0].gas; + delete params[0].gas; + // If from is present on eth_sendTransaction it errors, removing it makes the library set + // from as the connected wallet which works fine + delete params[0].from; + const req = ethers.providers.JsonRpcProvider.hexlifyTransaction( + params[0] + ); + // Hexlify sets the gasLimit property to be gas again and send transaction requires gasLimit + req['gasLimit'] = req['gas']; + delete req['gas']; + + if (!this.signer) { + throw new Error('No signer'); + } + + // Send the transaction + const tx = await this.signer.sendTransaction(req); + result = tx.hash; + } else { + // All other transactions the base class works for + result = await super.send(method, params); + } + console.debug('result received', method, params, result); + if (isCallbackForm) { + callback(null, { result }); + } else { + return result; + } + } catch (error) { + console.error(error); + if (isCallbackForm) { + callback(error, null); + } else { + throw error; + } + } + } +} + +type url = string | ConnectionInfo; + +export class Url extends Connector { + /** {@inheritdoc Connector.provider} */ + public override provider: Eip1193Bridge | undefined; + + private eagerConnection?: Promise; + private url: url; + + /** + * @param url - An RPC url. + * @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed. + */ + constructor(actions: Actions, url: url, connectEagerly = false) { + super(actions); + + if (connectEagerly && typeof window === 'undefined') { + throw new Error( + 'connectEagerly = true is invalid for SSR, instead use the activate method in a useEffect' + ); + } + + this.url = url; + + if (connectEagerly) void this.activate(); + } + + private async isomorphicInitialize() { + if (this.eagerConnection) return this.eagerConnection; + + await (this.eagerConnection = import('@ethersproject/providers') + .then(({ JsonRpcProvider }) => JsonRpcProvider) + .then((JsonRpcProvider) => { + const provider = new JsonRpcProvider(this.url); + const privateKey = Wallet.fromMnemonic( + ENV.ethWalletMnemonic, + `m/44'/60'/0'/0/0` + ).privateKey; + const signer = new Wallet(privateKey, provider); + this.provider = new CustomizedBridge(signer, provider); + this.actions.update({ accounts: [signer.address], chainId: 1440 }); + })); + } + + /** {@inheritdoc Connector.activate} */ + public async activate(): Promise { + this.actions.startActivation(); + + await this.isomorphicInitialize(); + + try { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const chainId = await this.provider!.request({ method: 'eth_chainId' }); + this.actions.update({ chainId: Number(chainId) }); + } catch (error) { + this.actions.reportError(error as Error); + } + } +} diff --git a/apps/token/src/lib/web3-connectors.ts b/apps/token/src/lib/web3-connectors.ts index 9faef842f..26f5415a0 100644 --- a/apps/token/src/lib/web3-connectors.ts +++ b/apps/token/src/lib/web3-connectors.ts @@ -3,11 +3,18 @@ import type { Web3ReactHooks } from '@web3-react/core'; import { initializeConnector } from '@web3-react/core'; import { MetaMask } from '@web3-react/metamask'; import { WalletConnect } from '@web3-react/walletconnect'; +import { Url } from './url-connector'; +import type { Connector } from '@web3-react/types'; +import { ENV } from '../config/env'; const [metamask, metamaskHooks] = initializeConnector( (actions) => new MetaMask(actions) ); +const [urlConnector, urlHooks] = initializeConnector( + (actions) => new Url(actions, ENV.localProviderUrl) +); + export const createDefaultProvider = (providerUrl: string, chainId: number) => { return new ethers.providers.JsonRpcProvider(providerUrl, chainId); }; @@ -27,7 +34,8 @@ export const createConnectors = (providerUrl: string, chainId: number) => { [chainId] ); return [ + ENV.urlConnect ? [urlConnector, urlHooks] : null, [metamask, metamaskHooks], [walletconnect, walletconnectHooks], - ] as [MetaMask | WalletConnect, Web3ReactHooks][]; + ].filter(Boolean) as [Connector, Web3ReactHooks][]; }; diff --git a/apps/token/src/routes/claim/target-address-mismatch.tsx b/apps/token/src/routes/claim/target-address-mismatch.tsx index 6f5e9eb7c..23069ac69 100644 --- a/apps/token/src/routes/claim/target-address-mismatch.tsx +++ b/apps/token/src/routes/claim/target-address-mismatch.tsx @@ -25,7 +25,7 @@ export const TargetAddressMismatch = ({ }} components={{ bold: , - red: , + red: , }} />

diff --git a/apps/token/src/routes/contracts/index.tsx b/apps/token/src/routes/contracts/index.tsx index 81cd33dc2..54a62e39d 100644 --- a/apps/token/src/routes/contracts/index.tsx +++ b/apps/token/src/routes/contracts/index.tsx @@ -43,7 +43,7 @@ const Contracts = () => { title={t('View address on Etherscan')} href={`${ETHERSCAN_URL}/address/${contract.address}`} > - {config.collateral_bridge_contract.address} + {contract.address} ); @@ -58,7 +58,6 @@ const Contracts = () => { title={t('View address on Etherscan')} href={`${ETHERSCAN_URL}/address/${value}`} > - asdfasd {value} diff --git a/apps/token/src/routes/governance/components/current-proposal-status/current-proposal-status.tsx b/apps/token/src/routes/governance/components/current-proposal-status/current-proposal-status.tsx index 1000a146b..1ecbfb938 100644 --- a/apps/token/src/routes/governance/components/current-proposal-status/current-proposal-status.tsx +++ b/apps/token/src/routes/governance/components/current-proposal-status/current-proposal-status.tsx @@ -34,30 +34,22 @@ export const CurrentProposalStatus = ({ { addSuffix: true } ); - if (proposal.state === ProposalState.Open && willPass) { - return {t('shouldPass')}; - } - - if (!participationMet) { - return ( - <> - {t('voteFailedReason')} - - {t('participationNotMet')} - -  {daysClosedAgo}. - - ); - } - - if (!majorityMet) { - return ( - <> - {t('voteFailedReason')} - {t('majorityNotMet')} -  {daysClosedAgo}. - - ); + if (proposal.state === ProposalState.Open) { + if (willPass) { + return ( + <> + {t('currentlySetTo')} + {t('pass')} + + ); + } else { + return ( + <> + {t('currentlySetTo')} + {t('fail')} + + ); + } } if ( @@ -65,6 +57,26 @@ export const CurrentProposalStatus = ({ proposal.state === ProposalState.Declined || proposal.state === ProposalState.Rejected ) { + if (!participationMet) { + return ( + <> + {t('voteFailedReason')} + {t('participationNotMet')} +  {daysClosedAgo}. + + ); + } + + if (!majorityMet) { + return ( + <> + {t('voteFailedReason')} + {t('majorityNotMet')} +  {daysClosedAgo}. + + ); + } + return ( <> {t('voteFailedReason')} diff --git a/apps/token/src/routes/governance/components/vote-details/use-user-vote.tsx b/apps/token/src/routes/governance/components/vote-details/use-user-vote.tsx index a9fd5be7d..cced62554 100644 --- a/apps/token/src/routes/governance/components/vote-details/use-user-vote.tsx +++ b/apps/token/src/routes/governance/components/vote-details/use-user-vote.tsx @@ -17,6 +17,7 @@ export enum VoteState { NotCast = 'NotCast', Yes = 'Yes', No = 'No', + Requested = 'Requested', Pending = 'Pending', Failed = 'Failed', } @@ -69,7 +70,7 @@ export function useUserVote( } }, [userVote]); - // Start a starts a timeout of 30s to set a failed message if + // Starts a timeout of 30s to set a failed message if // the vote is not seen by the time the callback is invoked React.useEffect(() => { // eslint-disable-next-line @@ -93,7 +94,7 @@ export function useUserVote( async function castVote(value: VoteValue) { if (!proposalId || !keypair) return; - setVoteState(VoteState.Pending); + setVoteState(VoteState.Requested); try { const variables = { @@ -105,6 +106,7 @@ export function useUserVote( }, }; await sendTx(variables); + setVoteState(VoteState.Pending); // Now await vote via poll in parent component } catch (err) { diff --git a/apps/token/src/routes/governance/components/vote-details/vote-buttons.tsx b/apps/token/src/routes/governance/components/vote-details/vote-buttons.tsx index e8d70992a..ef588ed0a 100644 --- a/apps/token/src/routes/governance/components/vote-details/vote-buttons.tsx +++ b/apps/token/src/routes/governance/components/vote-details/vote-buttons.tsx @@ -124,6 +124,10 @@ export const VoteButtons = ({ return

{cantVoteUI}

; } + if (voteState === VoteState.Requested) { + return

{t('voteRequested')}...

; + } + if (voteState === VoteState.Pending) { return

{t('votePending')}...

; } diff --git a/apps/token/src/routes/governance/components/vote-details/vote-details.tsx b/apps/token/src/routes/governance/components/vote-details/vote-details.tsx index 287644684..5057c4bd7 100644 --- a/apps/token/src/routes/governance/components/vote-details/vote-details.tsx +++ b/apps/token/src/routes/governance/components/vote-details/vote-details.tsx @@ -49,7 +49,7 @@ export const VoteDetails = ({ proposal }: VoteDetailsProps) => { - .  + {'. '} {proposal.state === ProposalState.Open ? daysLeft : null}

diff --git a/apps/token/src/routes/redemption/redemption.tsx b/apps/token/src/routes/redemption/redemption.tsx index e4953c476..6863593f9 100644 --- a/apps/token/src/routes/redemption/redemption.tsx +++ b/apps/token/src/routes/redemption/redemption.tsx @@ -8,7 +8,6 @@ import { Link } from 'react-router-dom'; import { EthConnectPrompt } from '../../components/eth-connect-prompt'; import { SplashLoader } from '../../components/splash-loader'; import { useAppState } from '../../contexts/app-state/app-state-context'; -import { useContracts } from '../../contexts/contracts/contracts-context'; import { useTranches } from '../../hooks/use-tranches'; import { Routes as RoutesConfig } from '../router-config'; import { @@ -19,7 +18,6 @@ import { const RedemptionRouter = () => { const { t } = useTranslation(); - const { vesting } = useContracts(); const [state, dispatch] = React.useReducer( redemptionReducer, initialRedemptionState @@ -49,7 +47,7 @@ const RedemptionRouter = () => { if (account) { run(account); } - }, [account, tranches, vesting]); + }, [account, tranches]); if (error) { return ( diff --git a/apps/token/src/routes/redemption/tranche-item.tsx b/apps/token/src/routes/redemption/tranche-item.tsx index 54e157dd2..3a3de1b2b 100644 --- a/apps/token/src/routes/redemption/tranche-item.tsx +++ b/apps/token/src/routes/redemption/tranche-item.tsx @@ -76,6 +76,7 @@ export const TrancheItem = ({ total={total} leftLabel={t('Locked')} rightLabel={t('Unlocked')} + decimals={18} />
diff --git a/apps/token/src/routes/staking/associate/wallet-associate.tsx b/apps/token/src/routes/staking/associate/wallet-associate.tsx index 47f7cb69e..ebab8dc29 100644 --- a/apps/token/src/routes/staking/associate/wallet-associate.tsx +++ b/apps/token/src/routes/staking/associate/wallet-associate.tsx @@ -12,7 +12,7 @@ import { useTransaction } from '../../../hooks/use-transaction'; import { BigNumber } from '../../../lib/bignumber'; import { AssociateInfo } from './associate-info'; import type { VegaKeyExtended } from '@vegaprotocol/wallet'; -import { toBigNum } from '@vegaprotocol/react-helpers'; +import { removeDecimal, toBigNum } from '@vegaprotocol/react-helpers'; import type { EthereumConfig } from '@vegaprotocol/web3'; export const WalletAssociate = ({ @@ -35,19 +35,18 @@ export const WalletAssociate = ({ appDispatch, appState: { walletBalance, allowance, walletAssociatedBalance, decimals }, } = useAppState(); - const { token } = useContracts(); const { state: approveState, perform: approve, dispatch: approveDispatch, - } = useTransaction(() => - token.approve( + } = useTransaction(() => { + return token.approve( ethereumConfig.staking_bridge_contract.address, - Number.MAX_SAFE_INTEGER.toString() - ) - ); + removeDecimal('1000000', decimals).toString() + ); + }); // Once they have approved deposits then we need to refresh their allowance React.useEffect(() => { diff --git a/apps/token/src/routes/staking/disassociate/disassociate-page.tsx b/apps/token/src/routes/staking/disassociate/disassociate-page.tsx index 5219a48bc..0c472dcc8 100644 --- a/apps/token/src/routes/staking/disassociate/disassociate-page.tsx +++ b/apps/token/src/routes/staking/disassociate/disassociate-page.tsx @@ -8,6 +8,7 @@ import { } from '../../../components/staking-method-radio'; import { TxState } from '../../../hooks/transaction-reducer'; import { useSearchParams } from '../../../hooks/use-search-params'; +import { useRefreshAssociatedBalances } from '../../../hooks/use-refresh-associated-balances'; import { ContractDisassociate } from './contract-disassociate'; import { DisassociateTransaction } from './disassociate-transaction'; import { useRemoveStake } from './hooks'; @@ -26,6 +27,7 @@ export const DisassociatePage = ({ const [amount, setAmount] = React.useState(''); const [selectedStakingMethod, setSelectedStakingMethod] = React.useState(params.method || null); + const refreshBalances = useRefreshAssociatedBalances(); // Clear the amount when the staking method changes React.useEffect(() => { @@ -38,6 +40,12 @@ export const DisassociatePage = ({ perform: txPerform, } = useRemoveStake(address, amount, vegaKey.pub, selectedStakingMethod); + React.useEffect(() => { + if (txState.txState === TxState.Complete) { + refreshBalances(address, vegaKey.pub); + } + }, [txState, refreshBalances, address, vegaKey.pub]); + if (txState.txState !== TxState.Default) { return ( ; + } else if (formState === FormState.Requested) { + return ( + +

{t('stakingConfirm')}

+
+ ); } else if (formState === FormState.Pending) { return ; } else if (formState === FormState.Success) { diff --git a/apps/token/src/routes/staking/staking-node.tsx b/apps/token/src/routes/staking/staking-node.tsx index a29452b4b..9724c73bb 100644 --- a/apps/token/src/routes/staking/staking-node.tsx +++ b/apps/token/src/routes/staking/staking-node.tsx @@ -88,7 +88,9 @@ export const StakingNode = ({ vegaKey, data }: StakingNodeProps) => { if (!nodeInfo) { return ( - {t('stakingNodeNotFound', { node })} + + {t('stakingNodeNotFound', { node })} + ); } diff --git a/apps/token/src/routes/tranches/tranche-progress.tsx b/apps/token/src/routes/tranches/tranche-progress.tsx index 213f5b66c..fb970e685 100644 --- a/apps/token/src/routes/tranches/tranche-progress.tsx +++ b/apps/token/src/routes/tranches/tranche-progress.tsx @@ -40,7 +40,7 @@ export const TrancheProgress = ({ {t('Redeemed')} diff --git a/apps/token/src/routes/tranches/vesting-chart.tsx b/apps/token/src/routes/tranches/vesting-chart.tsx index 767d38ce5..d838ec296 100644 --- a/apps/token/src/routes/tranches/vesting-chart.tsx +++ b/apps/token/src/routes/tranches/vesting-chart.tsx @@ -36,7 +36,7 @@ export const VestingChart = () => { ['pink', Colors.vega.pink], ['green', Colors.vega.green], ['orange', Colors.orange], - ['yellow', Colors.yellow.DEFAULT], + ['yellow', Colors.vega.yellow], ].map(([key, color]) => ( @@ -119,7 +119,7 @@ export const VestingChart = () => { dot={false} type="monotone" dataKey="publicSale" - stroke={Colors.yellow.DEFAULT} + stroke={Colors.vega.yellow} fill="url(#yellow)" yAxisId={0} strokeWidth={2} diff --git a/apps/trading-e2e/src/support/mocks/generate-orders.ts b/apps/trading-e2e/src/support/mocks/generate-orders.ts index 3e5bc8946..6c7219f62 100644 --- a/apps/trading-e2e/src/support/mocks/generate-orders.ts +++ b/apps/trading-e2e/src/support/mocks/generate-orders.ts @@ -76,6 +76,7 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'c6f4337b31ed57a961969c3ba10297b369d01b9e75a4cbb96db4fc62886444e6', name: 'BTCUSD Monthly (30 Jun 2022)', decimalPlaces: 5, + positionDecimalPlaces: 0, tradableInstrument: { __typename: 'TradableInstrument', instrument: { diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index 1384dc92f..801f5ac8b 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -1,8 +1,8 @@ import { useRouter } from 'next/router'; import { Vega } from '../icons/vega'; import Link from 'next/link'; -import { AnchorButton } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/react-helpers'; +import classNames from 'classnames'; export const Navbar = () => { return ( @@ -33,14 +33,17 @@ const NavLink = ({ name, path, exact, testId = name }: NavLinkProps) => { const router = useRouter(); const isActive = router.asPath === path || (!exact && router.asPath.startsWith(path)); + const linkClasses = classNames( + 'px-16 py-6 border-0 self-end', + 'uppercase xs:text-ui sm:text-body-large md:text-h5 lg:text-h4', + { + 'bg-vega-pink dark:bg-vega-yellow text-white dark:text-black': isActive, + 'text-black dark:text-white': !isActive, + } + ); return ( - - {name} - + + {name} + ); }; diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index 38aaf4014..e5e10d23a 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -24,84 +24,80 @@ function AppBody({ Component, pageProps }: AppProps) { const { push } = useRouter(); const store = useGlobalStore(); const { VEGA_NETWORKS } = useEnvironment(); - const [, toggleTheme] = useThemeSwitcher(); + const [theme, toggleTheme] = useThemeSwitcher(); return ( -
- -
- -
- { - store.setVegaWalletConnectDialog(open); - }} - setManageDialog={(open) => { - store.setVegaWalletManageDialog(open); - }} - /> - + +
+ +
+ +
+ { + store.setVegaWalletConnectDialog(open); + }} + setManageDialog={(open) => { + store.setVegaWalletManageDialog(open); + }} + /> + +
-
-
- {/* @ts-ignore conflict between @types/react and nextjs internal types */} - -
- store.setVegaWalletConnectDialog(open)} - /> - store.setVegaWalletManageDialog(open)} - /> - store.setVegaNetworkSwitcherDialog(open)} - onConnect={({ network }) => { - if (VEGA_NETWORKS[network]) { - push(VEGA_NETWORKS[network] ?? ''); - } - }} - /> - -
+
+ {/* @ts-ignore conflict between @types/react and nextjs internal types */} + +
+ store.setVegaWalletConnectDialog(open)} + /> + store.setVegaWalletManageDialog(open)} + /> + store.setVegaNetworkSwitcherDialog(open)} + onConnect={({ network }) => { + if (VEGA_NETWORKS[network]) { + push(VEGA_NETWORKS[network] ?? ''); + } + }} + /> + +
+ ); } function VegaTradingApp(props: AppProps) { - const [theme] = useThemeSwitcher(); - return ( - - - - - {t('Welcome to Vega trading!')} - - - {['1', 'true'].includes( - process.env['NX_USE_ENV_OVERRIDES'] || '' - ) ? ( - /* eslint-disable-next-line @next/next/no-sync-scripts */ -