diff --git a/.github/workflows/cypress-trading-e2e.yml b/.github/workflows/cypress-trading-e2e.yml index 729176930..177812ee0 100644 --- a/.github/workflows/cypress-trading-e2e.yml +++ b/.github/workflows/cypress-trading-e2e.yml @@ -20,6 +20,8 @@ jobs: timeout-minutes: 30 runs-on: self-hosted steps: + - name: check version + run: vega version # Checkout front ends - name: Checkout frontend mono repo uses: actions/checkout@v3 diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx index 08a7e3c69..c18e853a1 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx @@ -1,10 +1,18 @@ +import { useCallback, useMemo } from 'react'; import type { ReactNode } from 'react'; -import { VegaTxStatus } from '@vegaprotocol/wallet'; +import type { VegaTxState } from '@vegaprotocol/wallet'; +import { + VegaTxStatus, + WalletError, + useVegaWallet, + useVegaWalletDialogStore, + ClientErrors, +} from '@vegaprotocol/wallet'; import { DealTicket } from './deal-ticket'; import type { MarketDealTicket } from '@vegaprotocol/market-list'; import { useOrderSubmit, OrderFeedback } from '@vegaprotocol/orders'; import * as Schema from '@vegaprotocol/types'; -import { Icon, Intent } from '@vegaprotocol/ui-toolkit'; +import { Button, Icon, Intent } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/react-helpers'; export interface DealTicketManagerProps { @@ -12,12 +20,54 @@ export interface DealTicketManagerProps { children?: ReactNode | ReactNode[]; } +interface ErrorContentProps { + transaction: VegaTxState; + reset: () => void; +} +const ErrorContent = ({ transaction, reset }: ErrorContentProps) => { + const { openVegaWalletDialog } = useVegaWalletDialogStore((store) => ({ + openVegaWalletDialog: store.openVegaWalletDialog, + })); + const { disconnect } = useVegaWallet(); + const reconnect = useCallback(async () => { + reset(); + await disconnect(); + openVegaWalletDialog(); + }, [reset, disconnect, openVegaWalletDialog]); + return useMemo(() => { + const { error } = transaction; + if (error) { + if ( + error instanceof WalletError && + error.code === ClientErrors.NO_SERVICE.code + ) { + return ( +
+ {error.message}: {error.data} +
+ ); + } + return null; + }, [transaction, reconnect]); +}; + export const DealTicketManager = ({ market, children, }: DealTicketManagerProps) => { - const { submit, transaction, finalizedOrder, Dialog } = useOrderSubmit(); - + const { submit, transaction, finalizedOrder, Dialog, reset } = + useOrderSubmit(); return ( <> {children || ( @@ -40,6 +90,7 @@ export const DealTicketManager = ({ Complete: (