chore: minor misc fixes
This commit is contained in:
@@ -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 (
|
||||
<>
|
||||
<h3 className="mt-4 mb-2">{t('getWallet')}</h3>
|
||||
<div className="flex flex-row gap-4">
|
||||
<Link className="text-neutral-500" href={ExternalLinks.VEGA_WALLET_URL}>
|
||||
{t('getWalletLink')}
|
||||
</Link>
|
||||
<ButtonLink
|
||||
className="text-neutral-500"
|
||||
data-testid="view-as-user"
|
||||
// TODO: fix me
|
||||
// onClick={() => setViewAsDialog(true)}
|
||||
>
|
||||
{t('viewAsParty')}
|
||||
</ButtonLink>
|
||||
</div>
|
||||
<Link className="text-neutral-500" href={ExternalLinks.VEGA_WALLET_URL}>
|
||||
{t('getWalletLink')}
|
||||
</Link>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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 (
|
||||
// <div className="pt-6 border-t border-default">
|
||||
// <div className={wrapperClasses}>
|
||||
// <h3 className="text-lg">{t('Get started')}</h3>
|
||||
// <GetStartedCheckList />
|
||||
// {step > OnboardingStep.ONBOARDING_DEPOSIT_STEP && (
|
||||
// <TradingAnchorButton
|
||||
// href={Links.HOME()}
|
||||
// onClick={() => dismiss()}
|
||||
// intent={Intent.Info}
|
||||
// >
|
||||
// {t('Start trading')}
|
||||
// </TradingAnchorButton>
|
||||
// )}
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
return <div>TODO: fix this</div>;
|
||||
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 (
|
||||
<div className="pt-6 border-t border-default">
|
||||
<div className={wrapperClasses}>
|
||||
<h3 className="text-lg">{t('Get started')}</h3>
|
||||
<GetStartedCheckList />
|
||||
{step > OnboardingStep.ONBOARDING_DEPOSIT_STEP && (
|
||||
<TradingAnchorButton
|
||||
href={Links.HOME()}
|
||||
onClick={() => dismiss()}
|
||||
intent={Intent.Info}
|
||||
>
|
||||
{t('Start trading')}
|
||||
</TradingAnchorButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<TransferContainer assetId={assetId} />
|
||||
{/* <GetStarted /> */}
|
||||
<GetStarted />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<WithdrawContainer assetId={assetId} />
|
||||
{/* <GetStarted /> */}
|
||||
<GetStarted />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -55,7 +55,7 @@ export const WelcomeDialog = () => {
|
||||
intent={Intent.None}
|
||||
dataTestId="welcome-dialog"
|
||||
>
|
||||
<Content
|
||||
<DialogStepSwitch
|
||||
dialog={dialog}
|
||||
onConnect={() => {
|
||||
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 <ConnectionOptions onConnect={onConnect} />;
|
||||
return <OnboardConnectionOptions onConnect={onConnect} />;
|
||||
}
|
||||
|
||||
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 }) => {
|
||||
<ul className="flex flex-col -mx-4 -mb-4">
|
||||
{connectors.map((c) => {
|
||||
return (
|
||||
<ConnectionOption
|
||||
<OnboardConnectionOption
|
||||
key={c.id}
|
||||
id={c.id}
|
||||
name={c.name}
|
||||
@@ -152,7 +152,7 @@ const ConnectionOptions = ({ onConnect }: { onConnect: () => void }) => {
|
||||
return <ConnectionStatus status={status} />;
|
||||
};
|
||||
|
||||
export const ConnectionOption = ({
|
||||
export const OnboardConnectionOption = ({
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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]: {
|
||||
|
||||
@@ -80,9 +80,7 @@ export type Wallet = {
|
||||
connect: (id: ConnectorType) => Promise<{ status: Status }>;
|
||||
disconnect: () => Promise<{ status: Status }>;
|
||||
refreshKeys: () => Promise<void>;
|
||||
sendTransaction: (
|
||||
params: TransactionParams
|
||||
) => Promise<TransactionResponse | undefined>;
|
||||
sendTransaction: (params: TransactionParams) => Promise<TransactionResponse>;
|
||||
reset: () => void;
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ export const normalizeTransfer = <T extends Exact<Transfer, T>>(
|
||||
// @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;
|
||||
|
||||
@@ -4,8 +4,6 @@ import compact from 'lodash/compact';
|
||||
import {
|
||||
isTransferTransaction,
|
||||
isBatchMarketInstructionsTransaction,
|
||||
// ClientErrors,
|
||||
// WalletError,
|
||||
isOrderAmendmentTransaction,
|
||||
isOrderCancellationTransaction,
|
||||
isOrderSubmissionTransaction,
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
ozone access unlock valid olympic save include omit supply green clown session
|
||||
@@ -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 = ""
|
||||
Reference in New Issue
Block a user