Compare commits

..
Author SHA1 Message Date
Matthew Russell 0ffc104b8f chore: trigger test run 2022-09-28 15:14:14 -07:00
Matthew Russell 0575464151 chore: add no version check to vegawallet service run commands 2022-09-28 15:07:39 -07:00
Bartłomiej GłowniaandRado 8dd63d7cac chore: fix mocks and hydration error (#1520)
* chore: fix DealTicket mock

* chore: fix React Hydration Error

* test: change tag

Co-authored-by: Rado <szpiechrados@gmail.com>
2022-09-28 14:40:21 -07:00
Matthew Russell 8bffc05be2 fix: ensure sub is cancelled if dialog is closed (#1472)
* fix: ensure sub is cancelled if dialog is closed

* fix: pass transaction object in use proposal hooks
2022-09-28 12:34:49 -07:00
Matthew Russell 26e3596c5a fix: align market dropdown cells for both my markets and all markets (#1492) 2022-09-28 12:15:09 -07:00
mattrussell36 6ad68f87cc chore: update tranches
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-09-28 18:08:30 +00:00
Radosław Szpiech 86fdd75d6c fix: disabled test (#1525) 2022-09-28 18:56:45 +02:00
22 changed files with 86 additions and 82 deletions
@@ -155,11 +155,11 @@ jobs:
- name: Start service using fairground network
if: ${{ env.RUN_CAPSULE==false }}
run: vegawallet service run --network fairground --automatic-consent --home ~/.vegacapsule/testnet/wallet &
run: vegawallet service run --network fairground --automatic-consent --home ~/.vegacapsule/testnet/wallet --no-version-check &
- name: Start service using capsule network
if: ${{ env.RUN_CAPSULE }}
run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet &
run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet --no-version-check &
######
## Run some tests
@@ -122,7 +122,7 @@ jobs:
- name: Create public key 2
run: vegawallet key generate -w UI_Trading_Test -p ./passphrase --home ~/.vegacapsule/testnet/wallet
- name: Start service
run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet &
run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet --no-version-check &
######
## Run some tests
+2 -2
View File
@@ -150,11 +150,11 @@ jobs:
- name: Start service using fairground network
if: ${{ env.RUN_CAPSULE==false }}
run: vegawallet service run --network fairground --automatic-consent --home ~/.vegacapsule/testnet/wallet &
run: vegawallet service run --network fairground --automatic-consent --home ~/.vegacapsule/testnet/wallet --no-version-check &
- name: Start service using capsule network
if: ${{ env.RUN_CAPSULE }}
run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet &
run: vegawallet service run --network DV --automatic-consent --home ~/.vegacapsule/testnet/wallet --no-version-check &
######
## Run some tests
+17 -17
View File
@@ -232,7 +232,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45",
"total_removed": "0",
"locked_amount": "102598.914989767088346825",
"locked_amount": "102539.22427853179423677",
"deposits": [
{
"amount": "129999.45",
@@ -298,7 +298,7 @@
"tranche_end": "2023-09-03T00:00:00.000Z",
"total_added": "52600",
"total_removed": "0",
"locked_amount": "48924.58834348046834",
"locked_amount": "48888.32743531202288",
"deposits": [
{
"amount": "2600",
@@ -471,7 +471,7 @@
"tranche_end": "2023-09-17T00:00:00.000Z",
"total_added": "5000",
"total_removed": "0",
"locked_amount": "4842.4070903094875",
"locked_amount": "4838.960235920852",
"deposits": [
{
"amount": "5000",
@@ -682,7 +682,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "97499.58",
"total_removed": "0",
"locked_amount": "43862.1797066262302923728",
"locked_amount": "43803.628679345667381351",
"deposits": [
{
"amount": "97499.58",
@@ -715,7 +715,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "135173.4239508",
"total_removed": "0",
"locked_amount": "59952.027169538316245890461",
"locked_amount": "59871.99802365895157038359444",
"deposits": [
{
"amount": "135173.4239508",
@@ -748,7 +748,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "32499.86",
"total_removed": "0",
"locked_amount": "18452.061543249386219992",
"locked_amount": "18427.430137194610427382",
"deposits": [
{
"amount": "32499.86",
@@ -781,7 +781,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "10833.29",
"total_removed": "0",
"locked_amount": "6005.966977760755850949",
"locked_amount": "5997.949694107434824618",
"deposits": [
{
"amount": "10833.29",
@@ -814,7 +814,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "22749.93",
"total_removed": "0",
"locked_amount": "22451.645971367801250489",
"locked_amount": "22421.675574443718990018",
"deposits": [
{
"amount": "6500",
@@ -889,7 +889,7 @@
"tranche_end": "2022-11-01T00:00:00.000Z",
"total_added": "30000",
"total_removed": "0",
"locked_amount": "5461.2583031400951",
"locked_amount": "5420.233242753624",
"deposits": [
{
"amount": "7500",
@@ -1006,7 +1006,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38",
"total_removed": "479504.6187210477481",
"locked_amount": "1310093.255085850965425228",
"locked_amount": "1308755.924955803042225806",
"deposits": [
{
"amount": "1852091.69",
@@ -1292,7 +1292,7 @@
"tranche_end": "2023-02-01T00:00:00.000Z",
"total_added": "42500",
"total_removed": "0",
"locked_amount": "28986.782596115136",
"locked_amount": "28928.663760567634",
"deposits": [
{
"amount": "12500",
@@ -2171,7 +2171,7 @@
"tranche_end": "2022-09-30T00:00:00.000Z",
"total_added": "60916.66666633337",
"total_removed": "20696.25757434884556896",
"locked_amount": "233.625974397268181059908184634195",
"locked_amount": "194.323732786211788632241212572505",
"deposits": [
{
"amount": "2833.333333",
@@ -24070,7 +24070,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671",
"total_removed": "212048.9552173080602",
"locked_amount": "2037658.53177041435547647926",
"locked_amount": "2035603.52096942864727141711",
"deposits": [
{
"amount": "1998.95815",
@@ -24982,7 +24982,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15870102.715470999700000001",
"total_removed": "217308.1020176145778644",
"locked_amount": "12525093.9091163918322046608536422120302785",
"locked_amount": "12517806.9727604023540423149782230207704786",
"deposits": [
{
"amount": "16249.93",
@@ -28385,7 +28385,7 @@
"tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999",
"total_removed": "2775274.787258440951450397",
"locked_amount": "5841641.497126259854111255996264977",
"locked_amount": "5834914.244009937787798226811205626",
"deposits": [
{
"amount": "129284.449",
@@ -33754,7 +33754,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "5778205.3912159303",
"total_removed": "1802365.899333321320457354",
"locked_amount": "1991164.48192803281902462239746552",
"locked_amount": "1988506.503535685578836932847713835",
"deposits": [
{
"amount": "552496.6455",
@@ -35240,7 +35240,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996",
"total_removed": "3739.39870202926",
"locked_amount": "322878.642111764085168685514967",
"locked_amount": "322553.01390340530969756986605788",
"deposits": [
{
"amount": "3000",
+1 -1
View File
@@ -89,7 +89,7 @@
"tranche_end": "2022-10-12T00:53:20.000Z",
"total_added": "1010.000000000000000001",
"total_removed": "668.4622323651",
"locked_amount": "37.44712075088781850003707635717909685",
"locked_amount": "36.75072805682389880003638685946220188",
"deposits": [
{
"amount": "1000",
@@ -49,7 +49,8 @@ describe('vega wallet', { tags: '@smoke' }, () => {
.should('have.text', 'Required');
});
it('can change selected public key and disconnect', () => {
// skipped as it was blocking CI jobs
it.skip('can change selected public key and disconnect', () => {
const key2 = Cypress.env('VEGA_PUBLIC_KEY2');
const truncatedKey2 = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY2');
connectVegaWallet();
@@ -27,7 +27,7 @@ const mockTx = {
},
};
describe('deal ticket orders', { tags: '@regression' }, () => {
describe('deal ticket orders', { tags: '@smoke' }, () => {
before(() => {
cy.mockGQL((req) => {
mockTradingPage(req, MarketState.STATE_ACTIVE);
@@ -158,7 +158,7 @@ describe('deal ticket orders', { tags: '@regression' }, () => {
it.skip('unsuccessful order due to no collateral');
});
describe('deal ticket validation', { tags: '@regression' }, () => {
describe('deal ticket validation', { tags: '@smoke' }, () => {
before(() => {
cy.mockGQL((req) => {
mockTradingPage(req, MarketState.STATE_ACTIVE);
+1 -5
View File
@@ -43,11 +43,7 @@ export const mockTradingPage = (
aliasQuery(req, 'Orders', generateOrders());
aliasQuery(req, 'Accounts', generateAccounts());
aliasQuery(req, 'Positions', generatePositions());
aliasQuery(
req,
'DealTicketQuery',
generateDealTicketQuery({ market: { state } })
);
aliasQuery(req, 'DealTicket', generateDealTicketQuery({ market: { state } }));
aliasQuery(
req,
'MarketInfoQuery',
@@ -6,6 +6,7 @@ import type {
ProposalEvent_busEvents_event_Proposal,
} from './__generated__/ProposalEvent';
import type { Subscription } from 'zen-observable-ts';
import type { VegaTxState } from '@vegaprotocol/wallet';
export const PROPOSAL_EVENT_SUB = gql`
subscription ProposalEvent($partyId: ID!) {
@@ -24,7 +25,7 @@ export const PROPOSAL_EVENT_SUB = gql`
}
`;
export const useProposalEvent = () => {
export const useProposalEvent = (transaction: VegaTxState) => {
const client = useApolloClient();
const subRef = useRef<Subscription | null>(null);
@@ -66,10 +67,13 @@ export const useProposalEvent = () => {
);
useEffect(() => {
if (!transaction.dialogOpen) {
subRef.current?.unsubscribe();
}
return () => {
subRef.current?.unsubscribe();
};
}, []);
}, [transaction.dialogOpen]);
return waitForProposalEvent;
};
@@ -8,9 +8,9 @@ import type { ProposalEvent_busEvents_event_Proposal } from './__generated__/Pro
export const useProposalSubmit = () => {
const { keypair } = useVegaWallet();
const waitForProposalEvent = useProposalEvent();
const { send, transaction, setComplete, Dialog } = useVegaTransaction();
const waitForProposalEvent = useProposalEvent(transaction);
const [finalizedProposal, setFinalizedProposal] =
useState<ProposalEvent_busEvents_event_Proposal | null>(null);
@@ -202,9 +202,9 @@ export const SelectMarketPopover = ({
Loading market data
</div>
) : (
<>
<table className="relative text-sm w-full whitespace-nowrap">
{keypair && (party?.positionsConnection?.edges?.length ?? 0) > 0 ? (
<table className="relative text-sm w-full whitespace-nowrap">
<>
<TableTitle>{t('My markets')}</TableTitle>
<SelectAllMarketsTableBody
markets={markets}
@@ -227,19 +227,17 @@ export const SelectMarketPopover = ({
)
}
/>
</table>
</>
) : null}
<table className="relative text-sm w-full whitespace-nowrap">
<TableTitle>{t('All markets')}</TableTitle>
<SelectAllMarketsTableBody
markets={data?.markets}
marketsData={data?.marketsData}
marketsCandles={data?.marketsCandles}
onSelect={onSelectMarket}
onCellClick={onCellClick}
/>
</table>
</>
<TableTitle>{t('All markets')}</TableTitle>
<SelectAllMarketsTableBody
markets={data?.markets}
marketsData={data?.marketsData}
marketsCandles={data?.marketsCandles}
onSelect={onSelectMarket}
onCellClick={onCellClick}
/>
</table>
)}
</div>
</Popover>
@@ -11,7 +11,6 @@ export interface CancelOrderArgs {
export const useOrderCancel = () => {
const { keypair } = useVegaWallet();
const waitForOrderEvent = useOrderEvent();
const [cancelledOrder, setCancelledOrder] =
useState<OrderEvent_busEvents_event_Order | null>(null);
@@ -24,6 +23,8 @@ export const useOrderCancel = () => {
Dialog,
} = useVegaTransaction();
const waitForOrderEvent = useOrderEvent(transaction);
const reset = useCallback(() => {
resetTransaction();
setCancelledOrder(null);
@@ -25,7 +25,7 @@ export const useOrderEdit = (order: OrderWithMarket | null) => {
Dialog,
} = useVegaTransaction();
const waitForOrderEvent = useOrderEvent();
const waitForOrderEvent = useOrderEvent(transaction);
const reset = useCallback(() => {
resetTransaction();
@@ -7,8 +7,9 @@ import type {
OrderEvent_busEvents_event_Order,
} from './';
import type { Subscription } from 'zen-observable-ts';
import type { VegaTxState } from '@vegaprotocol/wallet';
export const useOrderEvent = () => {
export const useOrderEvent = (transaction: VegaTxState) => {
const client = useApolloClient();
const subRef = useRef<Subscription | null>(null);
@@ -50,10 +51,14 @@ export const useOrderEvent = () => {
);
useEffect(() => {
if (!transaction.dialogOpen) {
subRef.current?.unsubscribe();
}
return () => {
subRef.current?.unsubscribe();
};
}, []);
}, [transaction.dialogOpen]);
return waitForOrderEvent;
};
@@ -96,7 +96,6 @@ export const getOrderDialogIcon = (
export const useOrderSubmit = () => {
const { keypair } = useVegaWallet();
const waitForOrderEvent = useOrderEvent();
const {
send,
@@ -106,6 +105,8 @@ export const useOrderSubmit = () => {
Dialog,
} = useVegaTransaction();
const waitForOrderEvent = useOrderEvent(transaction);
const [finalizedOrder, setFinalizedOrder] =
useState<OrderEvent_busEvents_event_Order | null>(null);
+1 -1
View File
@@ -8,7 +8,6 @@ import type { Position } from '../';
export const useClosePosition = () => {
const { keypair } = useVegaWallet();
const waitForPositionEvent = usePositionEvent();
const {
send,
@@ -17,6 +16,7 @@ export const useClosePosition = () => {
setComplete,
Dialog,
} = useVegaTransaction();
const waitForPositionEvent = usePositionEvent(transaction);
const reset = useCallback(() => {
resetTransaction();
+2 -1
View File
@@ -1,7 +1,8 @@
import type { VegaTxState } from '@vegaprotocol/wallet';
import { useCallback } from 'react';
// this should be replaced by implementation of busEvents listener when it will be available
export const usePositionEvent = () => {
export const usePositionEvent = (transaction: VegaTxState) => {
const waitForOrderEvent = useCallback(
(id: string, partyId: string, callback: () => void) => {
Promise.resolve().then(() => {
@@ -29,7 +29,8 @@ const toggleTheme = () => {
};
export function useThemeSwitcher(): [themeVariant, () => void] {
const [theme, setTheme] = useState<themeVariant>(getCurrentTheme());
const [theme, setTheme] = useState<themeVariant>(lightTheme);
useEffect(() => setTheme(getCurrentTheme()), []);
useEffect(() => {
if (theme === darkTheme) {
document.documentElement.classList.add(darkThemeCssClass);
@@ -1,4 +1,4 @@
import { useEffect, useRef } from 'react';
import React from 'react';
import { SunIcon, MoonIcon } from './icons';
export const ThemeSwitcher = ({
@@ -10,22 +10,7 @@ export const ThemeSwitcher = ({
onToggle: () => void;
className?: string;
}) => {
const sun = useRef<HTMLSpanElement>(null);
const moon = useRef<HTMLSpanElement>(null);
const classes = 'text-neutral-800 dark:text-neutral-300 hidden';
useEffect(() => {
if (!theme || !sun.current || !moon.current) return;
switch (theme) {
case 'dark':
moon.current.classList.add('hidden');
sun.current.classList.remove('hidden');
break;
case 'light':
moon.current.classList.remove('hidden');
sun.current.classList.add('hidden');
break;
}
}, [sun, moon, theme]);
const classes = 'text-neutral-800 dark:text-neutral-300';
return (
<button
type="button"
@@ -33,12 +18,16 @@ export const ThemeSwitcher = ({
className={className}
data-testid="theme-switcher"
>
<span ref={sun} className={classes}>
<SunIcon />
</span>
<span ref={moon} className={classes}>
<MoonIcon />
</span>
{theme === 'dark' && (
<span className={classes}>
<SunIcon />
</span>
)}
{theme === 'light' && (
<span className={classes}>
<MoonIcon />
</span>
)}
</button>
);
};
@@ -46,6 +46,7 @@ export function VegaConnectDialog({
return (
<Dialog
data-testid="test-change"
open={dialogOpen}
onChange={setDialogOpen}
title="Connect to your Vega Wallet"
@@ -15,7 +15,6 @@ export interface WithdrawalArgs {
export const useCreateWithdraw = () => {
const waitForWithdrawalApproval = useWithdrawalApproval();
const waitForWithdrawal = useWithdrawalEvent();
const [approval, setApproval] =
useState<Erc20Approval_erc20WithdrawalApproval | null>(null);
const [withdrawal, setWithdrawal] = useState<WithdrawalFields | null>(null);
@@ -27,6 +26,8 @@ export const useCreateWithdraw = () => {
const { transaction, send, setComplete, reset, Dialog } =
useVegaTransaction();
const waitForWithdrawal = useWithdrawalEvent(transaction);
const submit = useCallback(
async (withdrawal: WithdrawalArgs) => {
if (!keypair) {
@@ -1,4 +1,5 @@
import { useApolloClient } from '@apollo/client';
import type { VegaTxState } from '@vegaprotocol/wallet';
import { useCallback, useEffect, useRef } from 'react';
import type { Subscription } from 'zen-observable-ts';
import { WITHDRAWAL_BUS_EVENT_SUB } from './use-withdrawals';
@@ -12,7 +13,8 @@ type WaitForWithdrawalEvent = (
id: string,
partyId: string
) => Promise<WithdrawalEvent_busEvents_event_Withdrawal>;
export const useWithdrawalEvent = () => {
export const useWithdrawalEvent = (transaction: VegaTxState) => {
const client = useApolloClient();
const subRef = useRef<Subscription | null>(null);
@@ -52,10 +54,13 @@ export const useWithdrawalEvent = () => {
);
useEffect(() => {
if (!transaction.dialogOpen) {
subRef.current?.unsubscribe();
}
return () => {
subRef.current?.unsubscribe();
};
}, []);
}, [transaction.dialogOpen]);
return waitForWithdrawalEvent;
};