diff --git a/apps/governance/src/components/vega-wallet/vega-wallet-prompt.tsx b/apps/governance/src/components/vega-wallet/vega-wallet-prompt.tsx index 618016a3f..aaa1d0bb7 100644 --- a/apps/governance/src/components/vega-wallet/vega-wallet-prompt.tsx +++ b/apps/governance/src/components/vega-wallet/vega-wallet-prompt.tsx @@ -1,27 +1,15 @@ -import { ButtonLink, Link } from '@vegaprotocol/ui-toolkit'; +import { Link } from '@vegaprotocol/ui-toolkit'; import { useTranslation } from 'react-i18next'; import { ExternalLinks } from '@vegaprotocol/environment'; -// import { useViewAsDialog } from '@vegaprotocol/wallet'; export const VegaWalletPrompt = () => { const { t } = useTranslation(); - // const setViewAsDialog = useViewAsDialog((state) => state.setOpen); return ( <>

{t('getWallet')}

-
- - {t('getWalletLink')} - - setViewAsDialog(true)} - > - {t('viewAsParty')} - -
+ + {t('getWalletLink')} + ); }; diff --git a/apps/governance/src/lib/vega-connectors.ts b/apps/governance/src/lib/vega-connectors.ts index 9e3d72463..d4fe97543 100644 --- a/apps/governance/src/lib/vega-connectors.ts +++ b/apps/governance/src/lib/vega-connectors.ts @@ -15,6 +15,7 @@ const jsonRpc = new JsonRpcConnector({ }); const snap = new SnapConnector({ + // TODO: un hard code url node: 'https://api.n08.testnet.vega.rocks', snapId: 'npm:@vegaprotocol/snap', version: '0.3.1', @@ -29,6 +30,7 @@ export const config = createConfig({ injected, jsonRpc, snap, + // TODO: fix type // @ts-ignore getChainId only throws readOnly, ], diff --git a/apps/governance/src/routes/proposals/test-helpers/mocks.ts b/apps/governance/src/routes/proposals/test-helpers/mocks.ts index 4cbe876e2..6a12aeaf4 100644 --- a/apps/governance/src/routes/proposals/test-helpers/mocks.ts +++ b/apps/governance/src/routes/proposals/test-helpers/mocks.ts @@ -5,7 +5,12 @@ import type { VoteValue } from '@vegaprotocol/types'; import type { UserVoteQuery } from '../components/vote-details/__generated__/Vote'; import { UserVoteDocument } from '../components/vote-details/__generated__/Vote'; import faker from 'faker'; -import { mockPubkey } from '../../../setup-tests'; +import { type Key } from '@vegaprotocol/wallet'; + +export const mockPubkey: Key = { + publicKey: '0x123', + name: 'test key 1', +}; const mockEthereumConfig = { network_id: '3', diff --git a/apps/governance/src/setup-tests.ts b/apps/governance/src/setup-tests.ts index c46c69c6d..19620686f 100644 --- a/apps/governance/src/setup-tests.ts +++ b/apps/governance/src/setup-tests.ts @@ -4,16 +4,10 @@ // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom'; import { locales } from '@vegaprotocol/i18n'; -import { type Key } from '@vegaprotocol/wallet'; import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import ResizeObserver from 'resize-observer-polyfill'; -export const mockPubkey: Key = { - publicKey: '0x123', - name: 'test key 1', -}; - // Set up i18n instance so that components have the correct default // en translations i18n.use(initReactI18next).init({ diff --git a/apps/trading/client-pages/deposit/deposit-get-started.tsx b/apps/trading/client-pages/deposit/deposit-get-started.tsx index e0adc7364..5701effa1 100644 --- a/apps/trading/client-pages/deposit/deposit-get-started.tsx +++ b/apps/trading/client-pages/deposit/deposit-get-started.tsx @@ -1,41 +1,45 @@ -// import { Intent, TradingAnchorButton } from '@vegaprotocol/ui-toolkit'; -// import { GetStartedCheckList } from '../../components/welcome-dialog'; -// import { Links } from '../../lib/links'; -// import classNames from 'classnames'; -// import { useT } from '../../lib/use-t'; +import classNames from 'classnames'; +import { Intent, TradingAnchorButton } from '@vegaprotocol/ui-toolkit'; +import { GetStartedCheckList } from '../../components/welcome-dialog'; +import { + useGetOnboardingStep, + useOnboardingStore, + OnboardingStep, +} from '../../components/welcome-dialog/use-get-onboarding-step'; +import { Links } from '../../lib/links'; +import { useT } from '../../lib/use-t'; export const DepositGetStarted = () => { - // const t = useT(); - // const onboardingDismissed = useOnboardingStore((store) => store.dismissed); - // // const dismiss = useOnboardingStore((store) => store.dismiss); - // const step = useGetOnboardingStep(); - // const wrapperClasses = classNames( - // 'flex flex-col py-4 px-6 gap-4 rounded', - // 'bg-vega-blue-300 dark:bg-vega-blue-700', - // 'border border-vega-blue-350 dark:border-vega-blue-650' - // ); - // - // // Dont show unless still onboarding - // if (onboardingDismissed) { - // return null; - // } - // - // return ( - //
- //
- //

{t('Get started')}

- // - // {step > OnboardingStep.ONBOARDING_DEPOSIT_STEP && ( - // dismiss()} - // intent={Intent.Info} - // > - // {t('Start trading')} - // - // )} - //
- //
- // ); - return
TODO: fix this
; + const t = useT(); + const onboardingDismissed = useOnboardingStore((store) => store.dismissed); + const dismiss = useOnboardingStore((store) => store.dismiss); + const step = useGetOnboardingStep(); + const wrapperClasses = classNames( + 'flex flex-col py-4 px-6 gap-4 rounded', + 'bg-vega-blue-300 dark:bg-vega-blue-700', + 'border border-vega-blue-350 dark:border-vega-blue-650' + ); + + // Dont show unless still onboarding + if (onboardingDismissed) { + return null; + } + + return ( +
+
+

{t('Get started')}

+ + {step > OnboardingStep.ONBOARDING_DEPOSIT_STEP && ( + dismiss()} + intent={Intent.Info} + > + {t('Start trading')} + + )} +
+
+ ); }; diff --git a/apps/trading/client-pages/transfer/transfer.tsx b/apps/trading/client-pages/transfer/transfer.tsx index 9328d2217..1b489bfb5 100644 --- a/apps/trading/client-pages/transfer/transfer.tsx +++ b/apps/trading/client-pages/transfer/transfer.tsx @@ -1,6 +1,6 @@ import { useSearchParams } from 'react-router-dom'; import { TransferContainer } from '@vegaprotocol/accounts'; -// import { GetStarted } from '../../components/welcome-dialog/get-started'; +import { GetStarted } from '../../components/welcome-dialog/get-started'; export const Transfer = () => { const [searchParams] = useSearchParams(); @@ -9,7 +9,7 @@ export const Transfer = () => { return ( <> - {/* */} + ); }; diff --git a/apps/trading/client-pages/withdraw/withdraw.tsx b/apps/trading/client-pages/withdraw/withdraw.tsx index e71593a11..16a87b775 100644 --- a/apps/trading/client-pages/withdraw/withdraw.tsx +++ b/apps/trading/client-pages/withdraw/withdraw.tsx @@ -1,5 +1,5 @@ import { useSearchParams } from 'react-router-dom'; -// import { GetStarted } from '../../components/welcome-dialog/get-started'; +import { GetStarted } from '../../components/welcome-dialog/get-started'; import { WithdrawContainer } from '../../components/withdraw-container'; export const Withdraw = () => { @@ -8,7 +8,7 @@ export const Withdraw = () => { return ( <> - {/* */} + ); }; diff --git a/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts b/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts index a4ee3149e..8a499947c 100644 --- a/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts +++ b/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts @@ -56,8 +56,7 @@ export enum OnboardingStep { } export const useGetOnboardingStep = () => { - // const connecting = useGlobalStore((store) => store.eagerConnecting); - const { pubKey = '', pubKeys } = useVegaWallet(); + const { status, pubKey = '', pubKeys } = useVegaWallet(); const { data: depositsData } = useDataProvider({ dataProvider: depositsProvider, variables: { partyId: pubKey || '' }, @@ -96,11 +95,12 @@ export const useGetOnboardingStep = () => { const positions = Boolean(positionsData?.length); const isLoading = Boolean( - pubKey && - (depositsData === null || - ordersData === null || - collateralData === null || - positionsData === null) + status === 'connecting' || + (pubKey && + (depositsData === null || + ordersData === null || + collateralData === null || + positionsData === null)) ); let step = OnboardingStep.ONBOARDING_UNKNOWN_STEP; if (isLoading) { diff --git a/apps/trading/components/welcome-dialog/welcome-dialog.tsx b/apps/trading/components/welcome-dialog/welcome-dialog.tsx index 112dc0513..674b80540 100644 --- a/apps/trading/components/welcome-dialog/welcome-dialog.tsx +++ b/apps/trading/components/welcome-dialog/welcome-dialog.tsx @@ -55,7 +55,7 @@ export const WelcomeDialog = () => { intent={Intent.None} dataTestId="welcome-dialog" > - { setTimeout(() => setDialog('intro'), 1000); @@ -65,7 +65,7 @@ export const WelcomeDialog = () => { ); }; -const Content = ({ +const DialogStepSwitch = ({ dialog, onConnect, }: { @@ -81,7 +81,7 @@ const Content = ({ } if (dialog === 'connect') { - return ; + return ; } if (dialog === 'risk') { @@ -102,7 +102,7 @@ const Content = ({ } }; -const ConnectionOptions = ({ onConnect }: { onConnect: () => void }) => { +const OnboardConnectionOptions = ({ onConnect }: { onConnect: () => void }) => { const t = useT(); const error = useWallet((store) => store.error); const { connect, connectors } = useConnect(); @@ -116,7 +116,7 @@ const ConnectionOptions = ({ onConnect }: { onConnect: () => void }) => {
    {connectors.map((c) => { return ( - void }) => { return ; }; -export const ConnectionOption = ({ +export const OnboardConnectionOption = ({ id, name, description, diff --git a/apps/trading/lib/vega-wallet.ts b/apps/trading/lib/vega-wallet.ts index 50d059731..f411ba669 100644 --- a/apps/trading/lib/vega-wallet.ts +++ b/apps/trading/lib/vega-wallet.ts @@ -16,6 +16,7 @@ const jsonRpc = new JsonRpcConnector({ }); const snap = new SnapConnector({ + // TODO: unhardcode node url node: 'https://api.n08.testnet.vega.rocks', snapId: 'npm:@vegaprotocol/snap', version: '0.3.1', @@ -30,6 +31,7 @@ export const config = createConfig({ injected, jsonRpc, snap, + // TODO: fix types // @ts-ignore getChainId only throws readOnly, ], diff --git a/libs/i18n/src/locales/en/governance.json b/libs/i18n/src/locales/en/governance.json index e540cefaf..714172d17 100644 --- a/libs/i18n/src/locales/en/governance.json +++ b/libs/i18n/src/locales/en/governance.json @@ -158,6 +158,7 @@ "Continue": "Continue", "ContinueSharingData": "Continue sharing data", "copied!": "Copied!", + "Copy": "Copy", "copyToClipboard": "Copy to clipboard", "copyId": "Copy ID to clipboard", "CouldNotInstantiateMarket": "Could not instantiate market", @@ -193,6 +194,7 @@ "disclaimer4": "The Vega Governance App is provided “as is”. The developers of the Vega Governance App make no representations or warranties of any kind, whether express or implied, statutory or otherwise regarding the Vega Governance App. They disclaim all warranties of merchantability, quality, fitness for purpose. They disclaim all warranties that the Vega Governance App is free of harmful components or errors.", "disclaimer5": "No developer of the Vega Governance App accepts any responsibility for, or liability to users in connection with their use of the Vega Governance App.", "disconnect": "Disconnect", + "Disconnect all keys": "Disconnect all keys", "disconnectedNotice": "You have been disconnected. Connect your ETH wallet to the {{correctNetwork}} network to use this app.", "Dissociate VEGA tokens": "Disassociate $VEGA tokens", "Dissociating {{amount}} VEGA tokens from Vega key {{vegaKey}}": "Disassociating {{amount}} $VEGA tokens from Vega key {{vegaKey}}", @@ -632,6 +634,7 @@ "Score": "Score", "seeHowRewardsAreCalculated": "See how rewards are calculated", "seeRejectedProposals": "See rejected proposals", + "Select": "Select", "Select country": "Select country/region of residence", "Select your country or region of current residence": "Select your country or region of current residence", "SelectAMarketToChange": "Select a market to change", @@ -881,7 +884,6 @@ "View on Etherscan (opens in a new tab)": "View on Etherscan (opens in a new tab)", "View transaction on Etherscan": "View transaction on Etherscan", "viewAllTranches": "View all tranches", - "viewAsParty": "View as party", "viewDetails": "View details", "viewKeys": "View keys", "viewMarketJson": "View market JSON", diff --git a/libs/i18n/src/locales/en/wallet-react.json b/libs/i18n/src/locales/en/wallet-react.json index fdaeb4fe1..4de236de0 100644 --- a/libs/i18n/src/locales/en/wallet-react.json +++ b/libs/i18n/src/locales/en/wallet-react.json @@ -19,10 +19,8 @@ "Connect with Vega Wallet extension for {{browserName}} to access all features including key management and detailed transaction views from your browser.": "Connect with Vega Wallet extension for {{browserName}} to access all features including key management and detailed transaction views from your browser.", "Connecting...": "Connecting...", "Connection in progress": "Connection in progress", - "Copy": "Copy", "Could not connect to Vega MetaMask Snap": "Could not connect to Vega MetaMask Snap", "Custom wallet location": "Custom wallet location", - "Disconnect all keys": "Disconnect all keys", "Enter a custom wallet location": "Enter a custom wallet location", "Get a Vega wallet": "Get a Vega wallet", "Get the Vega Wallet": "Get the Vega Wallet", @@ -40,7 +38,6 @@ "Pubkey must be be valid hex": "Pubkey must be be valid hex", "Read the docs to troubleshoot": "Read the docs to troubleshoot", "Required": "Required", - "Select": "Select", "SELECT A VEGA KEY": "SELECT A VEGA KEY", "Snap failed": "Snap failed", "Something went wrong": "Something went wrong", diff --git a/libs/wallet-react/src/hooks/use-simple-transaction.ts b/libs/wallet-react/src/hooks/use-simple-transaction.ts index e49c6e488..299571cb5 100644 --- a/libs/wallet-react/src/hooks/use-simple-transaction.ts +++ b/libs/wallet-react/src/hooks/use-simple-transaction.ts @@ -1,6 +1,11 @@ import { useState } from 'react'; import { useVegaWallet } from './use-vega-wallet'; -import { determineId, type Transaction } from '@vegaprotocol/wallet'; +import { + ConnectorError, + ConnectorErrors, + determineId, + type Transaction, +} from '@vegaprotocol/wallet'; import { useSimpleTransactionSubscription, type SimpleTransactionFieldsFragment, @@ -43,10 +48,6 @@ export const useSimpleTransaction = (opts?: Options) => { try { const res = await sendTx(pubKey, tx); - if (!res || 'error' in res) { - throw new Error(t('Transaction could not be sent')); - } - setStatus('pending'); setResult({ txHash: res?.transactionHash.toLowerCase(), @@ -54,8 +55,8 @@ export const useSimpleTransaction = (opts?: Options) => { id: determineId(res.signature), }); } catch (err) { - if (err instanceof Error) { - if (err.message.includes('user rejected')) { + if (err instanceof ConnectorError) { + if (err.code === ConnectorErrors.userRejected.code) { setStatus('idle'); } else { setError(err.message); diff --git a/libs/wallet/project.json b/libs/wallet/project.json index 72797361b..273238344 100644 --- a/libs/wallet/project.json +++ b/libs/wallet/project.json @@ -17,9 +17,7 @@ "react", "react-dom", "react/jsx-runtime", - "@vegaprotocol/i18n", "@vegaprotocol/types", - "@vegaprotocol/ui-toolkit", "@vegaprotocol/utils" ], "rollupConfig": "@nx/react/plugins/bundle-rollup", diff --git a/libs/wallet/src/connectors/snap-connector.ts b/libs/wallet/src/connectors/snap-connector.ts index 9d104d9f3..207b29d5e 100644 --- a/libs/wallet/src/connectors/snap-connector.ts +++ b/libs/wallet/src/connectors/snap-connector.ts @@ -27,6 +27,9 @@ export class SnapConnector implements Connector { version: string; snapId: string; + // Note: we may not be able to set `node` in the constructor + // as the trading app won't know the current node until + // the app runs constructor(config: SnapConfig) { this.node = config.node; this.version = config.version; @@ -126,6 +129,12 @@ export class SnapConnector implements Connector { // Snap methods //////////////////////////////////// + /** + * Requests permission for a website to communicate with the specified snaps + * and attempts to install them if they're not already installed. + * If the installation of any snap fails, returns the error that caused the failure. + * More informations here: https://docs.metamask.io/snaps/reference/rpc-api/#wallet_requestsnaps + */ async requestSnap() { await this.request(EthereumMethod.RequestSnaps, { [this.snapId]: { diff --git a/libs/wallet/src/types.ts b/libs/wallet/src/types.ts index c9506e293..53a58ef97 100644 --- a/libs/wallet/src/types.ts +++ b/libs/wallet/src/types.ts @@ -80,9 +80,7 @@ export type Wallet = { connect: (id: ConnectorType) => Promise<{ status: Status }>; disconnect: () => Promise<{ status: Status }>; refreshKeys: () => Promise; - sendTransaction: ( - params: TransactionParams - ) => Promise; + sendTransaction: (params: TransactionParams) => Promise; reset: () => void; }; diff --git a/libs/wallet/src/utils.ts b/libs/wallet/src/utils.ts index 60d30243b..326a6de12 100644 --- a/libs/wallet/src/utils.ts +++ b/libs/wallet/src/utils.ts @@ -83,7 +83,6 @@ export const normalizeTransfer = >( // @ts-ignore not sure why but window.vega not defined despite it being globally declared export const isBrowserWalletInstalled = () => Boolean(window.vega); -// TODO: we might be able to use wallets type narrowing export const isMarginModeUpdateTransaction = ( transaction: Transaction ): transaction is UpdateMarginModeBody => 'updateMarginMode' in transaction; diff --git a/libs/web3/src/lib/use-vega-transaction-toasts.tsx b/libs/web3/src/lib/use-vega-transaction-toasts.tsx index f03a1de0e..488a623b2 100644 --- a/libs/web3/src/lib/use-vega-transaction-toasts.tsx +++ b/libs/web3/src/lib/use-vega-transaction-toasts.tsx @@ -4,8 +4,6 @@ import compact from 'lodash/compact'; import { isTransferTransaction, isBatchMarketInstructionsTransaction, - // ClientErrors, - // WalletError, isOrderAmendmentTransaction, isOrderCancellationTransaction, isOrderSubmissionTransaction, diff --git a/recovery.txt b/recovery.txt deleted file mode 100644 index f3ec7481d..000000000 --- a/recovery.txt +++ /dev/null @@ -1 +0,0 @@ -ozone access unlock valid olympic save include omit supply green clown session diff --git a/vegacapsule/testnet/wallet/config/wallet-service/networks/DV.toml b/vegacapsule/testnet/wallet/config/wallet-service/networks/DV.toml deleted file mode 100644 index 62322426d..000000000 --- a/vegacapsule/testnet/wallet/config/wallet-service/networks/DV.toml +++ /dev/null @@ -1,12 +0,0 @@ -FileVersion = 2 - -[API] - [API.GRPC] - Hosts = ["127.0.0.1:3002", "127.0.0.1:3012", "127.0.0.1:3022", "127.0.0.1:3032"] - [API.REST] - [API.GraphQL] - -[Apps] - Console = "" - Governance = "" - Explorer = ""