chore: migrate withdrawals lib (#2009)

* chore: cleanup lib types

* chore: migrate withdrawals

* fix: withdrawals query and types

* fix: types

* fix: orders build

* fix: withdraws build

* fix: format

* fix: more build stuff in withdrawal lib

* fix: format

* fix: more withdrawal builds

* fix: format

* fix: orders build again

* fix: remaining build errors

* fix: format

* fix: withdrawal tests

* fix: trick git to pick up file rename?

* fix: rename back to orders

* fix: rename generated file
This commit is contained in:
botond 2022-11-10 15:13:58 +01:00 committed by GitHub
parent 045454b484
commit df8a22a19e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
105 changed files with 388 additions and 1027 deletions

View File

@ -1,10 +1,12 @@
import { AssetStatus, WithdrawalStatus } from '@vegaprotocol/types';
import type { Withdrawals } from '@vegaprotocol/withdraws';
import { Schema } from '@vegaprotocol/types';
import type { WithdrawalsQuery } from '@vegaprotocol/withdraws';
import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest';
export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
const defaultResult: Withdrawals = {
export const generateWithdrawals = (
override?: PartialDeep<WithdrawalsQuery>
) => {
const defaultResult: WithdrawalsQuery = {
party: {
id: 'party-0',
withdrawalsConnection: {
@ -14,7 +16,7 @@ export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
__typename: 'WithdrawalEdge',
node: {
id: 'withdrawal-0',
status: WithdrawalStatus.STATUS_FINALIZED,
status: Schema.WithdrawalStatus.STATUS_FINALIZED,
amount: '100',
txHash: null,
createdTimestamp: new Date('2022-02-02').toISOString(),
@ -30,7 +32,7 @@ export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
name: 'asset-0 name',
symbol: 'AST0',
decimals: 5,
status: AssetStatus.STATUS_ENABLED,
status: Schema.AssetStatus.STATUS_ENABLED,
source: {
__typename: 'ERC20',
contractAddress: '0x123',
@ -43,7 +45,7 @@ export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
__typename: 'WithdrawalEdge',
node: {
id: 'withdrawal-1',
status: WithdrawalStatus.STATUS_FINALIZED,
status: Schema.WithdrawalStatus.STATUS_FINALIZED,
amount: '100',
txHash:
'0x5d7b1a35ba6bd23be17bb7a159c13cdbb3121fceb94e9c6c510f5503dce48d03',
@ -60,7 +62,7 @@ export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
name: 'asset-0 name',
symbol: 'AST0',
decimals: 5,
status: AssetStatus.STATUS_ENABLED,
status: Schema.AssetStatus.STATUS_ENABLED,
source: {
__typename: 'ERC20',
contractAddress: '0x123',

View File

@ -10,14 +10,14 @@ import produce from 'immer';
import {
AccountEventsDocument,
AccountsDocument,
} from './__generated___/Accounts';
} from './__generated__/Accounts';
import type { IterableElement } from 'type-fest';
import type {
AccountFieldsFragment,
AccountsQuery,
AccountEventsSubscription,
} from './__generated___/Accounts';
} from './__generated__/Accounts';
import type { Market } from '@vegaprotocol/market-list';
import type { Asset } from '@vegaprotocol/assets';

View File

@ -1,4 +1,4 @@
export * from './__generated___/Accounts';
export * from './__generated__/Accounts';
export * from './accounts-data-provider';
export * from './accounts-table';
export * from './asset-balance';

View File

@ -1,8 +1,8 @@
import { makeDataProvider, useDataProvider } from '@vegaprotocol/react-helpers';
import { useMemo } from 'react';
import type { AssetQuery, AssetFieldsFragment } from './__generated___/Asset';
import { AssetDocument } from './__generated___/Asset';
import type { AssetQuery, AssetFieldsFragment } from './__generated__/Asset';
import { AssetDocument } from './__generated__/Asset';
export type Asset = AssetFieldsFragment;

View File

@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react';
import { AssetStatus } from '@vegaprotocol/types';
import { AssetDetailsDialog } from './asset-details-dialog';
import { AssetDetail, testId } from './asset-details-table';
import { AssetsDocument } from './__generated___/Assets';
import { AssetsDocument } from './__generated__/Assets';
import { generateBuiltinAsset, generateERC20Asset } from './test-helpers';
const mockedData = {

View File

@ -3,9 +3,9 @@ import {
makeDerivedDataProvider,
useDataProvider,
} from '@vegaprotocol/react-helpers';
import { AssetsDocument } from './__generated___/Assets';
import { AssetsDocument } from './__generated__/Assets';
import { AssetStatus } from '@vegaprotocol/types';
import type { AssetsQuery } from './__generated___/Assets';
import type { AssetsQuery } from './__generated__/Assets';
import type { Asset } from './asset-data-provider';
export interface ERC20AssetSource {

View File

@ -1,5 +1,5 @@
export * from './__generated___/Asset';
export * from './__generated___/Assets';
export * from './__generated__/Asset';
export * from './__generated__/Assets';
export * from './asset-data-provider';
export * from './assets-data-provider';
export * from './asset-details-dialog';

View File

@ -3,19 +3,19 @@ import type { Candle, DataSource } from 'pennant';
import { Interval as PennantInterval } from 'pennant';
import { addDecimal } from '@vegaprotocol/react-helpers';
import { ChartDocument } from './__generated___/Chart';
import type { ChartQuery, ChartQueryVariables } from './__generated___/Chart';
import { ChartDocument } from './__generated__/Chart';
import type { ChartQuery, ChartQueryVariables } from './__generated__/Chart';
import {
CandlesDocument,
CandlesEventsDocument,
} from './__generated___/Candles';
} from './__generated__/Candles';
import type {
CandlesQuery,
CandlesQueryVariables,
CandleFieldsFragment,
CandlesEventsSubscription,
CandlesEventsSubscriptionVariables,
} from './__generated___/Candles';
} from './__generated__/Candles';
import type { Subscription } from 'zen-observable-ts';
import { Interval } from '@vegaprotocol/types';

View File

@ -1,4 +1,4 @@
export * from './__generated___/Candles';
export * from './__generated___/Chart';
export * from './__generated__/Candles';
export * from './__generated__/Chart';
export * from './candles-chart';
export * from './data-source';

View File

@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { AccountType } from '@vegaprotocol/types';
import { toBigNum } from '@vegaprotocol/react-helpers';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket';
import type { OrderMargin } from '../../hooks/use-order-margin';
import { usePartyBalanceQuery, useSettlementAccount } from '../../hooks';

View File

@ -11,7 +11,7 @@ import {
} from '@vegaprotocol/types';
import type { ValidationProps } from './use-order-validation';
import { marketTranslations, useOrderValidation } from './use-order-validation';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket';
import * as OrderMarginValidation from './use-order-margin-validation';
import { ValidateMargin } from './validate-margin';
import { ERROR_SIZE_DECIMAL } from '../constants';

View File

@ -14,7 +14,7 @@ import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { Tooltip } from '@vegaprotocol/ui-toolkit';
import { MarketDataGrid } from '../trading-mode-tooltip';
import { compileGridData } from '../trading-mode-tooltip/compile-grid-data';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket';
import { ValidateMargin } from './validate-margin';
import type { OrderMargin } from '../../hooks/use-order-margin';
import { useOrderMarginValidation } from './use-order-margin-validation';

View File

@ -2,7 +2,7 @@ import type { UseFormRegister } from 'react-hook-form';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { DealTicketMarketAmount } from './deal-ticket-market-amount';
import { DealTicketLimitAmount } from './deal-ticket-limit-amount';
import type { DealTicketMarketFragment } from './__generated___/DealTicket';
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
import { Schema } from '@vegaprotocol/types';
import type { DealTicketErrorMessage } from './deal-ticket-error';

View File

@ -1,8 +1,8 @@
import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit';
import { DealTicketManager } from './deal-ticket-manager';
import { t } from '@vegaprotocol/react-helpers';
import { useDealTicketQuery } from './__generated___/DealTicket';
import type { DealTicketQuery } from './__generated___/DealTicket';
import { useDealTicketQuery } from './__generated__/DealTicket';
import type { DealTicketQuery } from './__generated__/DealTicket';
export interface DealTicketContainerProps {
marketId: string;

View File

@ -1,7 +1,7 @@
import type { ReactNode } from 'react';
import { VegaTxStatus } from '@vegaprotocol/wallet';
import { DealTicket } from './deal-ticket';
import type { DealTicketMarketFragment } from './__generated___/DealTicket';
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
import { useOrderSubmit, OrderFeedback } from '@vegaprotocol/orders';
import { Schema } from '@vegaprotocol/types';
import { Icon, Intent } from '@vegaprotocol/ui-toolkit';

View File

@ -2,7 +2,7 @@
import { VegaWalletContext } from '@vegaprotocol/wallet';
import { fireEvent, render, screen, act } from '@testing-library/react';
import { DealTicket } from './deal-ticket';
import type { DealTicketMarketFragment } from './__generated___/DealTicket';
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
import { Schema } from '@vegaprotocol/types';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import type { MockedResponse } from '@apollo/client/testing';

View File

@ -20,7 +20,7 @@ import { SideSelector } from './side-selector';
import { TimeInForceSelector } from './time-in-force-selector';
import { TypeSelector } from './type-selector';
import type { DealTicketMarketFragment } from './__generated___/DealTicket';
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import type { DealTicketErrorMessage } from './deal-ticket-error';

View File

@ -1,4 +1,4 @@
export * from './__generated___/DealTicket';
export * from './__generated__/DealTicket';
export * from './deal-ticket-amount';
export * from './deal-ticket-container';
export * from './deal-ticket-limit-amount';

View File

@ -7,7 +7,7 @@ import { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types';
import { Link as UILink } from '@vegaprotocol/ui-toolkit';
import type { ReactNode } from 'react';
import type { MarketDataGridProps } from './market-data-grid';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../deal-ticket/__generated__/DealTicket';
import { Link } from 'react-router-dom';
export const compileGridData = (

View File

@ -4,7 +4,7 @@ import { MockedProvider } from '@apollo/client/testing';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import type { PartyBalanceQuery } from './__generated__/PartyBalance';
import { useOrderCloseOut } from './use-order-closeout';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated__/DealTicket';
jest.mock('@vegaprotocol/wallet', () => ({
...jest.requireActual('@vegaprotocol/wallet'),

View File

@ -6,7 +6,7 @@ import { useMarketPositions } from './use-market-positions';
import { useMarketDataMarkPrice } from './use-market-data-mark-price';
import { usePartyMarketDataQuery } from './__generated__/PartyMarketData';
import { Schema } from '@vegaprotocol/types';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated__/DealTicket';
import type { PartyBalanceQuery } from './__generated__/PartyBalance';
import { useSettlementAccount } from './use-settlement-account';

View File

@ -4,7 +4,7 @@ import { BigNumber } from 'bignumber.js';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import type { PositionMargin } from './use-market-positions';
import { useOrderMargin } from './use-order-margin';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated__/DealTicket';
let mockEstimateData = {
estimateOrder: {

View File

@ -6,7 +6,7 @@ import { useMarketPositions } from './use-market-positions';
import { useMarketDataMarkPrice } from './use-market-data-mark-price';
import type { EstimateOrderQuery } from './__generated__/EstimateOrder';
import { useEstimateOrderQuery } from './__generated__/EstimateOrder';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated___/DealTicket';
import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated__/DealTicket';
interface Props {
order: OrderSubmissionBody['orderSubmission'];

View File

@ -11,7 +11,7 @@ import type {
VegaValueFormatterParams,
} from '@vegaprotocol/ui-toolkit';
import { AgGridDynamic as AgGrid, Link } from '@vegaprotocol/ui-toolkit';
import type { DepositFieldsFragment } from './__generated___/Deposit';
import type { DepositFieldsFragment } from './__generated__/Deposit';
import { useEnvironment } from '@vegaprotocol/environment';
import { DepositStatusMapping } from '@vegaprotocol/types';

View File

@ -1,4 +1,4 @@
export * from './__generated___/Deposit';
export * from './__generated__/Deposit';
export * from './deposit-container';
export * from './deposit-form';
export * from './deposit-limits';

View File

@ -8,13 +8,13 @@ import { Schema } from '@vegaprotocol/types';
import {
useDepositsQuery,
DepositEventDocument,
} from './__generated___/Deposit';
} from './__generated__/Deposit';
import type {
DepositFieldsFragment,
DepositsQuery,
DepositEventSubscription,
DepositEventSubscriptionVariables,
} from './__generated___/Deposit';
} from './__generated__/Deposit';
export const useDeposits = () => {
const { pubKey } = useVegaWallet();

View File

@ -3,8 +3,8 @@ import * as Sentry from '@sentry/react';
import type {
DepositEventSubscription,
DepositEventSubscriptionVariables,
} from './__generated___/Deposit';
import { DepositEventDocument } from './__generated___/Deposit';
} from './__generated__/Deposit';
import { DepositEventDocument } from './__generated__/Deposit';
import { Schema } from '@vegaprotocol/types';
import { useState } from 'react';
import { remove0x, removeDecimal } from '@vegaprotocol/react-helpers';

View File

@ -1,4 +1,4 @@
export * from './lib/fills-container';
export * from './lib/use-fills-list';
export * from './lib/fills-data-provider';
export * from './lib/__generated___/Fills';
export * from './lib/__generated__/Fills';

View File

@ -10,13 +10,13 @@ import {
import type { Market } from '@vegaprotocol/market-list';
import { marketsProvider } from '@vegaprotocol/market-list';
import type { PageInfo, Edge } from '@vegaprotocol/react-helpers';
import { FillsDocument, FillsEventDocument } from './__generated___/Fills';
import { FillsDocument, FillsEventDocument } from './__generated__/Fills';
import type {
FillsQuery,
FillFieldsFragment,
FillEdgeFragment,
FillsEventSubscription,
} from './__generated___/Fills';
} from './__generated__/Fills';
const update = (
data: FillEdgeFragment[] | null,

View File

@ -1,13 +1,13 @@
import { useApolloClient } from '@apollo/client';
import { useCallback, useEffect, useRef } from 'react';
import { VoteEventDocument } from './__generated___/VoteSubsciption';
import { VoteEventDocument } from './__generated__/VoteSubsciption';
import type { Subscription } from 'zen-observable-ts';
import type { VegaTxState } from '@vegaprotocol/wallet';
import type {
VoteEventFieldsFragment,
VoteEventSubscription,
VoteEventSubscriptionVariables,
} from './__generated___/VoteSubsciption';
} from './__generated__/VoteSubsciption';
export const useVoteEvent = (transaction: VegaTxState) => {
const client = useApolloClient();

View File

@ -3,7 +3,7 @@ import * as Sentry from '@sentry/react';
import { useVegaTransaction, useVegaWallet } from '@vegaprotocol/wallet';
import { useVoteEvent } from './use-vote-event';
import type { VoteValue } from '@vegaprotocol/types';
import type { VoteEventFieldsFragment } from './__generated___/VoteSubsciption';
import type { VoteEventFieldsFragment } from './__generated__/VoteSubsciption';
export const useVoteSubmit = () => {
const { pubKey } = useVegaWallet();

View File

@ -11,8 +11,8 @@ import { useMemo } from 'react';
import type {
LedgerEntriesQuery,
LedgerEntryFragment,
} from './__generated___/LedgerEntries';
import { LedgerEntriesDocument } from './__generated___/LedgerEntries';
} from './__generated__/LedgerEntries';
import { LedgerEntriesDocument } from './__generated__/LedgerEntries';
export type LedgerEntry = LedgerEntryFragment & {
id: number;

View File

@ -1,2 +1,2 @@
export * from './__generated___/orders';
export * from './__generated__/Orders';
export * from './order-data-provider';

View File

@ -15,8 +15,8 @@ import type {
OrderFieldsFragment,
OrdersQuery,
OrdersUpdateSubscription,
} from './__generated___/orders';
import { OrdersDocument, OrdersUpdateDocument } from './__generated___/orders';
} from './__generated__/Orders';
import { OrdersDocument, OrdersUpdateDocument } from './__generated__/Orders';
export type Order = Omit<OrderFieldsFragment, 'market'> & {
market?: Market;

View File

@ -1,5 +1,5 @@
import { useEnvironment } from '@vegaprotocol/environment';
import type { OrderEventFieldsFragment } from '../../order-hooks/__generated___/OrderEvent';
import type { OrderEventFieldsFragment } from '../../order-hooks/__generated__/OrderEvent';
import { addDecimalsFormatNumber, Size, t } from '@vegaprotocol/react-helpers';
import {
OrderRejectionReasonMapping,

View File

@ -3,7 +3,7 @@ import { MockedProvider } from '@apollo/client/testing';
import { renderHook, waitFor } from '@testing-library/react';
import { useOrderListData } from './use-order-list-data';
import type { Edge } from '@vegaprotocol/react-helpers';
import type { OrderFieldsFragment } from '../order-data-provider/__generated___/orders';
import type { OrderFieldsFragment } from '../order-data-provider/__generated__/Orders';
import type { IGetRowsParams } from 'ag-grid-community';
const loadMock = jest.fn();

View File

@ -1,4 +1,4 @@
export * from './__generated___/OrderEvent';
export * from './__generated__/OrderEvent';
export * from './use-order-cancel';
export * from './use-order-submit';
export * from './use-order-edit';

View File

@ -3,8 +3,8 @@ import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet';
import type { ReactNode } from 'react';
import { useOrderEdit } from './use-order-edit';
import type { OrderEventSubscription } from './__generated___/OrderEvent';
import { OrderEventDocument } from './__generated___/OrderEvent';
import type { OrderEventSubscription } from './__generated__/OrderEvent';
import { OrderEventDocument } from './__generated__/OrderEvent';
import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import type { Order } from '../components';

View File

@ -1,11 +1,11 @@
import { useApolloClient } from '@apollo/client';
import { useCallback, useEffect, useRef } from 'react';
import { OrderEventDocument } from './__generated___/OrderEvent';
import { OrderEventDocument } from './__generated__/OrderEvent';
import type {
OrderEventSubscription,
OrderEventSubscriptionVariables,
OrderEventFieldsFragment,
} from './__generated___/OrderEvent';
} from './__generated__/OrderEvent';
import type { Subscription } from 'zen-observable-ts';
import type { VegaTxState } from '@vegaprotocol/wallet';
import { Schema } from '@vegaprotocol/types';

View File

@ -1,6 +1,6 @@
import { useCallback, useState } from 'react';
import type { ReactNode } from 'react';
import type { OrderEventFieldsFragment } from './__generated___/OrderEvent';
import type { OrderEventFieldsFragment } from './__generated__/OrderEvent';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { toNanoSeconds } from '@vegaprotocol/react-helpers';
import { useVegaTransaction, determineId } from '@vegaprotocol/wallet';

View File

@ -1,4 +1,4 @@
export * from './lib/__generated___/Positions';
export * from './lib/__generated__/Positions';
export * from './lib/positions-container';
export * from './lib/positions-data-providers';
export * from './lib/positions-table';

View File

@ -3,11 +3,11 @@ import { makeDataProvider } from '@vegaprotocol/react-helpers';
import {
MarginsSubscriptionDocument,
MarginsDocument,
} from './__generated___/Positions';
} from './__generated__/Positions';
import type {
MarginsQuery,
MarginsSubscriptionSubscription,
} from './__generated___/Positions';
} from './__generated__/Positions';
const update = (
data: MarginsQuery['party'],

View File

@ -1,7 +1,7 @@
import { AccountType, MarketTradingMode } from '@vegaprotocol/types';
import type { Account } from '@vegaprotocol/accounts';
import type { MarketWithData } from '@vegaprotocol/market-list';
import type { PositionsQuery, MarginsQuery } from './__generated___/Positions';
import type { PositionsQuery, MarginsQuery } from './__generated__/Positions';
import { getMetrics, rejoinPositionData } from './positions-data-providers';
const accounts = [

View File

@ -18,11 +18,11 @@ import type {
PositionsSubscriptionSubscription,
MarginsQuery,
MarginFieldsFragment,
} from './__generated___/Positions';
} from './__generated__/Positions';
import {
PositionsDocument,
PositionsSubscriptionDocument,
} from './__generated___/Positions';
} from './__generated__/Positions';
import { marginsDataProvider } from './margin-data-provider';
type PositionMarginLevel = Pick<

View File

@ -1,4 +1,4 @@
export * from './__generated___/NetworkParams';
export * from './__generated__/NetworkParams';
export * from './use-apply-grid-transaction';
export * from './use-data-provider';
export * from './use-fetch';

View File

@ -8,9 +8,9 @@ import {
useNetworkParams,
} from './use-network-params';
import type { ReactNode } from 'react';
import type { NetworkParamsQuery } from './__generated___/NetworkParams';
import { NetworkParamDocument } from './__generated___/NetworkParams';
import { NetworkParamsDocument } from './__generated___/NetworkParams';
import type { NetworkParamsQuery } from './__generated__/NetworkParams';
import { NetworkParamDocument } from './__generated__/NetworkParams';
import { NetworkParamsDocument } from './__generated__/NetworkParams';
describe('useNetworkParam', () => {
const setup = (arg: NetworkParamsKey) => {

View File

@ -3,7 +3,7 @@ import { useMemo } from 'react';
import {
useNetworkParamQuery,
useNetworkParamsQuery,
} from './__generated___/NetworkParams';
} from './__generated__/NetworkParams';
export const NetworkParams = {
blockchains_ethereumConfig: 'blockchains_ethereumConfig',

View File

@ -11,4 +11,4 @@ export * from './lib/remove-0x';
export * from './lib/storage';
export * from './lib/time';
export * from './lib/validate';
export * from './lib/__generated___/ChainId';
export * from './lib/__generated__/ChainId';

View File

@ -1,2 +1,2 @@
export * from './lib/trades-container';
export * from './lib/__generated___/Trades';
export * from './lib/__generated__/Trades';

View File

@ -9,7 +9,7 @@ import type { BodyScrollEvent, BodyScrollEndEvent } from 'ag-grid-community';
import { MAX_TRADES, tradesWithMarketProvider } from './trades-data-provider';
import { TradesTable } from './trades-table';
import type { Trade, TradeEdge } from './trades-data-provider';
import type { TradesQueryVariables } from './__generated___/Trades';
import type { TradesQueryVariables } from './__generated__/Trades';
interface TradesContainerProps {
marketId: string;

View File

@ -12,8 +12,8 @@ import type {
TradesQuery,
TradeFieldsFragment,
TradesUpdateSubscription,
} from './__generated___/Trades';
import { TradesDocument, TradesUpdateDocument } from './__generated___/Trades';
} from './__generated__/Trades';
import { TradesDocument, TradesUpdateDocument } from './__generated__/Trades';
import orderBy from 'lodash/orderBy';
import produce from 'immer';

View File

@ -13,17 +13,34 @@ module.exports = {
],
excludes: [
'**/generic-data-provider.ts',
'**/__generated___/*',
'**/__generated__/*',
'../../libs/accounts/**',
'../../libs/assets/**',
'../../libs/candles-chart/**',
'../../libs/cypress/**',
'../../libs/deal-ticket/**',
'../../libs/deposits/**',
'../../libs/environment/**',
'../../libs/fills/**',
'../../libs/governance/**',
'../../libs/ledger/**',
'../../libs/liquidity/**',
// @TODO: uncomment these when migrated
// '../../libs/maket-depth/**',
// '../../libs/market-list/**',
// '../../libs/market-info/**',
'../../libs/network-info/**',
'../../libs/network-stats/**',
'../../libs/orders/**',
'../../libs/positions/**',
'../../libs/react-helpers/**',
'../../libs/smart-contracts/**',
'../../libs/tailwind-config/**',
'../../libs/trades/**',
'../../libs/ui-toolkit/**',
'../../libs/wallet/**',
'../../libs/web3/**',
'../../libs/withdraws/**',
],
},
};

View File

@ -63,6 +63,18 @@ export enum DataSourceSpecStatus {
STATUS_DEACTIVATED = "STATUS_DEACTIVATED",
}
/**
* The interval for trade candles when subscribing via Vega GraphQL, default is I15M
*/
export enum Interval {
INTERVAL_I15M = "INTERVAL_I15M",
INTERVAL_I1D = "INTERVAL_I1D",
INTERVAL_I1H = "INTERVAL_I1H",
INTERVAL_I1M = "INTERVAL_I1M",
INTERVAL_I5M = "INTERVAL_I5M",
INTERVAL_I6H = "INTERVAL_I6H",
}
/**
* The current state of a market
*/
@ -181,20 +193,17 @@ export enum StakeLinkingStatus {
STATUS_REJECTED = "STATUS_REJECTED",
}
export enum ValidatorStatus {
VALIDATOR_NODE_STATUS_ERSATZ = "VALIDATOR_NODE_STATUS_ERSATZ",
VALIDATOR_NODE_STATUS_PENDING = "VALIDATOR_NODE_STATUS_PENDING",
VALIDATOR_NODE_STATUS_TENDERMINT = "VALIDATOR_NODE_STATUS_TENDERMINT",
}
export enum VoteValue {
VALUE_NO = "VALUE_NO",
VALUE_YES = "VALUE_YES",
}
/**
* The status of a withdrawal
*/
export enum WithdrawalStatus {
STATUS_FINALIZED = "STATUS_FINALIZED",
STATUS_OPEN = "STATUS_OPEN",
STATUS_REJECTED = "STATUS_REJECTED",
}
//==============================================================
// END Enums and Input Objects
//==============================================================

View File

@ -278,18 +278,6 @@ export enum WithdrawalStatusMapping {
STATUS_REJECTED = 'Rejected',
}
/**
* The interval for trade candles when subscribing via Vega GraphQL, default is I15M
*/
export enum Interval {
INTERVAL_I15M = 'INTERVAL_I15M',
INTERVAL_I1D = 'INTERVAL_I1D',
INTERVAL_I1H = 'INTERVAL_I1H',
INTERVAL_I1M = 'INTERVAL_I1M',
INTERVAL_I5M = 'INTERVAL_I5M',
INTERVAL_I6H = 'INTERVAL_I6H',
}
export enum ProposalUserAction {
CREATE = 'CREATE',
VOTE = 'VOTE',

View File

@ -10,4 +10,4 @@ export * from './provider';
export * from './connect-dialog';
export * from './utils';
export * from './constants';
export * from './__generated___/TransactionResult';
export * from './__generated__/TransactionResult';

View File

@ -3,8 +3,8 @@ import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import { renderHook } from '@testing-library/react';
import { Schema as Types } from '@vegaprotocol/types';
import type { TransactionEventSubscription } from './__generated___/TransactionResult';
import { TransactionEventDocument } from './__generated___/TransactionResult';
import type { TransactionEventSubscription } from './__generated__/TransactionResult';
import { TransactionEventDocument } from './__generated__/TransactionResult';
import { useTransactionResult } from './use-transaction-result';
const pubKey = 'test-pubkey';

View File

@ -5,8 +5,8 @@ import type { Subscription } from 'zen-observable-ts';
import type {
TransactionEventSubscription,
TransactionEventSubscriptionVariables,
} from './__generated___/TransactionResult';
import { TransactionEventDocument } from './__generated___/TransactionResult';
} from './__generated__/TransactionResult';
import { TransactionEventDocument } from './__generated__/TransactionResult';
export interface TransactionResult {
partyId: string;

View File

@ -9,5 +9,5 @@ export * from './lib/use-complete-withdraw';
export * from './lib/use-create-withdraw';
export * from './lib/use-verify-withdrawal';
export * from './lib/use-withdrawals';
export * from './lib/__generated__/Withdrawals';
export * from './lib/__generated__/WithdrawalFields';
export * from './lib/__generated__/Withdrawal';
export * from './lib/__generated__/Erc20Approval';

View File

@ -1,32 +0,0 @@
query WithdrawPageQuery($partyId: ID!) {
party(id: $partyId) {
id
withdrawals {
id
txHash
}
accounts {
type
balance
asset {
id
symbol
}
}
}
assetsConnection {
edges {
node {
id
symbol
name
decimals
source {
... on ERC20 {
contractAddress
}
}
}
}
}
}

View File

@ -1,11 +1,23 @@
fragment PendingWithdrawal on Withdrawal {
pendingOnForeignChain @client
txHash
}
fragment WithdrawalFields on Withdrawal {
id
status
amount
asset {
id
name
symbol
decimals
status
source {
... on ERC20 {
contractAddress
}
}
}
createdTimestamp
withdrawnTimestamp
@ -21,8 +33,12 @@ fragment WithdrawalFields on Withdrawal {
query Withdrawals($partyId: ID!) {
party(id: $partyId) {
id
withdrawals {
...WithdrawalFields
withdrawalsConnection {
edges {
node {
...WithdrawalFields
}
}
}
}
}

View File

@ -1,52 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AssetStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: AssetFields
// ====================================================
export interface AssetFields_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface AssetFields_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type AssetFields_source = AssetFields_source_BuiltinAsset | AssetFields_source_ERC20;
export interface AssetFields {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The status of the asset in the Vega network
*/
status: AssetStatus;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: AssetFields_source;
}

View File

@ -1,52 +1,54 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { Schema as Types } from '@vegaprotocol/types';
// ====================================================
// GraphQL query operation: Erc20Approval
// ====================================================
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type Erc20ApprovalQueryVariables = Types.Exact<{
withdrawalId: Types.Scalars['ID'];
}>;
export interface Erc20Approval_erc20WithdrawalApproval {
__typename: "Erc20WithdrawalApproval";
/**
* The source asset in the ethereum network
*/
assetSource: string;
/**
* The amount to be withdrawn
*/
amount: string;
/**
* The nonce to be used in the request
*/
nonce: string;
/**
* Signature aggregate from the nodes, in the following format:
* 0x + sig1 + sig2 + ... + sigN
*/
signatures: string;
/**
* The target address which will receive the funds
*/
targetAddress: string;
/**
* Timestamp in seconds for expiry of the approval
*/
expiry: string;
/**
* Timestamp at which the withdrawal was created
*/
creation: string;
export type Erc20ApprovalQuery = { __typename?: 'Query', erc20WithdrawalApproval?: { __typename?: 'Erc20WithdrawalApproval', assetSource: string, amount: string, nonce: string, signatures: string, targetAddress: string, expiry: string, creation: string } | null };
export const Erc20ApprovalDocument = gql`
query Erc20Approval($withdrawalId: ID!) {
erc20WithdrawalApproval(withdrawalId: $withdrawalId) {
assetSource
amount
nonce
signatures
targetAddress
expiry
creation
}
}
`;
export interface Erc20Approval {
/**
* Find an erc20 withdrawal approval using its withdrawal ID
*/
erc20WithdrawalApproval: Erc20Approval_erc20WithdrawalApproval | null;
}
export interface Erc20ApprovalVariables {
withdrawalId: string;
}
/**
* __useErc20ApprovalQuery__
*
* To run a query within a React component, call `useErc20ApprovalQuery` and pass it any options that fit your needs.
* When your component renders, `useErc20ApprovalQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useErc20ApprovalQuery({
* variables: {
* withdrawalId: // value for 'withdrawalId'
* },
* });
*/
export function useErc20ApprovalQuery(baseOptions: Apollo.QueryHookOptions<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>(Erc20ApprovalDocument, options);
}
export function useErc20ApprovalLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>(Erc20ApprovalDocument, options);
}
export type Erc20ApprovalQueryHookResult = ReturnType<typeof useErc20ApprovalQuery>;
export type Erc20ApprovalLazyQueryHookResult = ReturnType<typeof useErc20ApprovalLazyQuery>;
export type Erc20ApprovalQueryResult = Apollo.QueryResult<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>;

View File

@ -1,20 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL fragment: PendingWithdrawal
// ====================================================
export interface PendingWithdrawal {
__typename: "Withdrawal";
/**
* Whether or the not the withdrawal is being processed on Ethereum
*/
pendingOnForeignChain: boolean;
/**
* Hash of the transaction on the foreign chain
*/
txHash: string | null;
}

View File

@ -3,22 +3,30 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type WithdrawalFieldsFragment = { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null };
export type PendingWithdrawalFragment = { __typename?: 'Withdrawal', pendingOnForeignChain: boolean, txHash?: string | null };
export type WithdrawalFieldsFragment = { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, status: Types.AssetStatus, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null };
export type WithdrawalsQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID'];
}>;
export type WithdrawalsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, withdrawals?: Array<{ __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null }> | null } | null };
export type WithdrawalsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, withdrawalsConnection?: { __typename?: 'WithdrawalsConnection', edges?: Array<{ __typename?: 'WithdrawalEdge', node: { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, status: Types.AssetStatus, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null } } | null> | null } | null } | null };
export type WithdrawalEventSubscriptionVariables = Types.Exact<{
partyId: Types.Scalars['ID'];
}>;
export type WithdrawalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null } }> | null };
export type WithdrawalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, status: Types.AssetStatus, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null } }> | null };
export const PendingWithdrawalFragmentDoc = gql`
fragment PendingWithdrawal on Withdrawal {
pendingOnForeignChain @client
txHash
}
`;
export const WithdrawalFieldsFragmentDoc = gql`
fragment WithdrawalFields on Withdrawal {
id
@ -26,8 +34,15 @@ export const WithdrawalFieldsFragmentDoc = gql`
amount
asset {
id
name
symbol
decimals
status
source {
... on ERC20 {
contractAddress
}
}
}
createdTimestamp
withdrawnTimestamp
@ -44,8 +59,12 @@ export const WithdrawalsDocument = gql`
query Withdrawals($partyId: ID!) {
party(id: $partyId) {
id
withdrawals {
...WithdrawalFields
withdrawalsConnection {
edges {
node {
...WithdrawalFields
}
}
}
}
}

View File

@ -1,125 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL subscription operation: WithdrawalEvent
// ====================================================
export interface WithdrawalEvent_busEvents_event_TimeUpdate {
__typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Order" | "Trade" | "AccountEvent" | "Party" | "MarginLevels" | "Proposal" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Deposit" | "OracleSpec" | "LiquidityProvision" | "TransactionResult";
}
export interface WithdrawalEvent_busEvents_event_Withdrawal_asset_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface WithdrawalEvent_busEvents_event_Withdrawal_asset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type WithdrawalEvent_busEvents_event_Withdrawal_asset_source = WithdrawalEvent_busEvents_event_Withdrawal_asset_source_BuiltinAsset | WithdrawalEvent_busEvents_event_Withdrawal_asset_source_ERC20;
export interface WithdrawalEvent_busEvents_event_Withdrawal_asset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The status of the asset in the Vega network
*/
status: AssetStatus;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: WithdrawalEvent_busEvents_event_Withdrawal_asset_source;
}
export interface WithdrawalEvent_busEvents_event_Withdrawal_details {
__typename: "Erc20WithdrawalDetails";
/**
* The ethereum address of the receiver of the asset funds
*/
receiverAddress: string;
}
export interface WithdrawalEvent_busEvents_event_Withdrawal {
__typename: "Withdrawal";
/**
* The Vega internal ID of the withdrawal
*/
id: string;
/**
* The current status of the withdrawal
*/
status: WithdrawalStatus;
/**
* The amount to be withdrawn
*/
amount: string;
/**
* The asset to be withdrawn
*/
asset: WithdrawalEvent_busEvents_event_Withdrawal_asset;
/**
* RFC3339Nano time at which the withdrawal was created
*/
createdTimestamp: string;
/**
* RFC3339Nano time at which the withdrawal was finalised
*/
withdrawnTimestamp: string | null;
/**
* Hash of the transaction on the foreign chain
*/
txHash: string | null;
/**
* Foreign chain specific details about the withdrawal
*/
details: WithdrawalEvent_busEvents_event_Withdrawal_details | null;
/**
* Whether or the not the withdrawal is being processed on Ethereum
*/
pendingOnForeignChain: boolean;
}
export type WithdrawalEvent_busEvents_event = WithdrawalEvent_busEvents_event_TimeUpdate | WithdrawalEvent_busEvents_event_Withdrawal;
export interface WithdrawalEvent_busEvents {
__typename: "BusEvent";
/**
* The payload - the wrapped event
*/
event: WithdrawalEvent_busEvents_event;
}
export interface WithdrawalEvent {
/**
* Subscribe to event data from the event bus
*/
busEvents: WithdrawalEvent_busEvents[] | null;
}
export interface WithdrawalEventVariables {
partyId: string;
}

View File

@ -1,100 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: WithdrawalFields
// ====================================================
export interface WithdrawalFields_asset_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface WithdrawalFields_asset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type WithdrawalFields_asset_source = WithdrawalFields_asset_source_BuiltinAsset | WithdrawalFields_asset_source_ERC20;
export interface WithdrawalFields_asset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The status of the asset in the Vega network
*/
status: AssetStatus;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: WithdrawalFields_asset_source;
}
export interface WithdrawalFields_details {
__typename: "Erc20WithdrawalDetails";
/**
* The ethereum address of the receiver of the asset funds
*/
receiverAddress: string;
}
export interface WithdrawalFields {
__typename: "Withdrawal";
/**
* The Vega internal ID of the withdrawal
*/
id: string;
/**
* The current status of the withdrawal
*/
status: WithdrawalStatus;
/**
* The amount to be withdrawn
*/
amount: string;
/**
* The asset to be withdrawn
*/
asset: WithdrawalFields_asset;
/**
* RFC3339Nano time at which the withdrawal was created
*/
createdTimestamp: string;
/**
* RFC3339Nano time at which the withdrawal was finalised
*/
withdrawnTimestamp: string | null;
/**
* Hash of the transaction on the foreign chain
*/
txHash: string | null;
/**
* Foreign chain specific details about the withdrawal
*/
details: WithdrawalFields_details | null;
/**
* Whether or the not the withdrawal is being processed on Ethereum
*/
pendingOnForeignChain: boolean;
}

View File

@ -1,139 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: Withdrawals
// ====================================================
export interface Withdrawals_party_withdrawalsConnection_edges_node_asset_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface Withdrawals_party_withdrawalsConnection_edges_node_asset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type Withdrawals_party_withdrawalsConnection_edges_node_asset_source = Withdrawals_party_withdrawalsConnection_edges_node_asset_source_BuiltinAsset | Withdrawals_party_withdrawalsConnection_edges_node_asset_source_ERC20;
export interface Withdrawals_party_withdrawalsConnection_edges_node_asset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
/**
* The status of the asset in the Vega network
*/
status: AssetStatus;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: Withdrawals_party_withdrawalsConnection_edges_node_asset_source;
}
export interface Withdrawals_party_withdrawalsConnection_edges_node_details {
__typename: "Erc20WithdrawalDetails";
/**
* The ethereum address of the receiver of the asset funds
*/
receiverAddress: string;
}
export interface Withdrawals_party_withdrawalsConnection_edges_node {
__typename: "Withdrawal";
/**
* The Vega internal ID of the withdrawal
*/
id: string;
/**
* The current status of the withdrawal
*/
status: WithdrawalStatus;
/**
* The amount to be withdrawn
*/
amount: string;
/**
* The asset to be withdrawn
*/
asset: Withdrawals_party_withdrawalsConnection_edges_node_asset;
/**
* RFC3339Nano time at which the withdrawal was created
*/
createdTimestamp: string;
/**
* RFC3339Nano time at which the withdrawal was finalised
*/
withdrawnTimestamp: string | null;
/**
* Hash of the transaction on the foreign chain
*/
txHash: string | null;
/**
* Foreign chain specific details about the withdrawal
*/
details: Withdrawals_party_withdrawalsConnection_edges_node_details | null;
/**
* Whether or the not the withdrawal is being processed on Ethereum
*/
pendingOnForeignChain: boolean;
}
export interface Withdrawals_party_withdrawalsConnection_edges {
__typename: "WithdrawalEdge";
/**
* The withdrawal
*/
node: Withdrawals_party_withdrawalsConnection_edges_node;
}
export interface Withdrawals_party_withdrawalsConnection {
__typename: "WithdrawalsConnection";
/**
* The withdrawals
*/
edges: (Withdrawals_party_withdrawalsConnection_edges | null)[] | null;
}
export interface Withdrawals_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The list of all withdrawals initiated by the party
*/
withdrawalsConnection: Withdrawals_party_withdrawalsConnection | null;
}
export interface Withdrawals {
/**
* An entity that is trading on the Vega network
*/
party: Withdrawals_party | null;
}
export interface WithdrawalsVariables {
partyId: string;
}

View File

@ -1,54 +0,0 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type Erc20ApprovalQueryVariables = Types.Exact<{
withdrawalId: Types.Scalars['ID'];
}>;
export type Erc20ApprovalQuery = { __typename?: 'Query', erc20WithdrawalApproval?: { __typename?: 'Erc20WithdrawalApproval', assetSource: string, amount: string, nonce: string, signatures: string, targetAddress: string, expiry: string, creation: string } | null };
export const Erc20ApprovalDocument = gql`
query Erc20Approval($withdrawalId: ID!) {
erc20WithdrawalApproval(withdrawalId: $withdrawalId) {
assetSource
amount
nonce
signatures
targetAddress
expiry
creation
}
}
`;
/**
* __useErc20ApprovalQuery__
*
* To run a query within a React component, call `useErc20ApprovalQuery` and pass it any options that fit your needs.
* When your component renders, `useErc20ApprovalQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useErc20ApprovalQuery({
* variables: {
* withdrawalId: // value for 'withdrawalId'
* },
* });
*/
export function useErc20ApprovalQuery(baseOptions: Apollo.QueryHookOptions<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>(Erc20ApprovalDocument, options);
}
export function useErc20ApprovalLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>(Erc20ApprovalDocument, options);
}
export type Erc20ApprovalQueryHookResult = ReturnType<typeof useErc20ApprovalQuery>;
export type Erc20ApprovalLazyQueryHookResult = ReturnType<typeof useErc20ApprovalLazyQuery>;
export type Erc20ApprovalQueryResult = Apollo.QueryResult<Erc20ApprovalQuery, Erc20ApprovalQueryVariables>;

View File

@ -1,75 +0,0 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type WithdrawPageQueryQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID'];
}>;
export type WithdrawPageQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, withdrawals?: Array<{ __typename?: 'Withdrawal', id: string, txHash?: string | null }> | null, accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string } }> | null } | null, assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } | null };
export const WithdrawPageQueryDocument = gql`
query WithdrawPageQuery($partyId: ID!) {
party(id: $partyId) {
id
withdrawals {
id
txHash
}
accounts {
type
balance
asset {
id
symbol
}
}
}
assetsConnection {
edges {
node {
id
symbol
name
decimals
source {
... on ERC20 {
contractAddress
}
}
}
}
}
}
`;
/**
* __useWithdrawPageQueryQuery__
*
* To run a query within a React component, call `useWithdrawPageQueryQuery` and pass it any options that fit your needs.
* When your component renders, `useWithdrawPageQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useWithdrawPageQueryQuery({
* variables: {
* partyId: // value for 'partyId'
* },
* });
*/
export function useWithdrawPageQueryQuery(baseOptions: Apollo.QueryHookOptions<WithdrawPageQueryQuery, WithdrawPageQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<WithdrawPageQueryQuery, WithdrawPageQueryQueryVariables>(WithdrawPageQueryDocument, options);
}
export function useWithdrawPageQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<WithdrawPageQueryQuery, WithdrawPageQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<WithdrawPageQueryQuery, WithdrawPageQueryQueryVariables>(WithdrawPageQueryDocument, options);
}
export type WithdrawPageQueryQueryHookResult = ReturnType<typeof useWithdrawPageQueryQuery>;
export type WithdrawPageQueryLazyQueryHookResult = ReturnType<typeof useWithdrawPageQueryLazyQuery>;
export type WithdrawPageQueryQueryResult = Apollo.QueryResult<WithdrawPageQueryQuery, WithdrawPageQueryQueryVariables>;

View File

@ -5,13 +5,13 @@ import { CompleteCell } from './pending-withdrawals-table';
import { PendingWithdrawalsTable } from './pending-withdrawals-table';
import { getTimeFormat } from '@vegaprotocol/react-helpers';
import type { TypedDataAgGrid } from '@vegaprotocol/ui-toolkit';
import type { WithdrawalFields } from './__generated__/WithdrawalFields';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
jest.mock('@web3-react/core', () => ({
useWeb3React: () => ({ provider: undefined }),
}));
const generateTable = (props: TypedDataAgGrid<WithdrawalFields>) => (
const generateTable = (props: TypedDataAgGrid<WithdrawalFieldsFragment>) => (
<MockedProvider>
<PendingWithdrawalsTable {...props} />
</MockedProvider>

View File

@ -22,12 +22,12 @@ import {
} from '@vegaprotocol/ui-toolkit';
import { useEnvironment } from '@vegaprotocol/environment';
import { useCompleteWithdraw } from './use-complete-withdraw';
import type { WithdrawalFields } from './__generated__/WithdrawalFields';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
import type { VerifyState } from './use-verify-withdrawal';
import { ApprovalStatus, useVerifyWithdrawal } from './use-verify-withdrawal';
export const PendingWithdrawalsTable = (
props: TypedDataAgGrid<WithdrawalFields>
props: TypedDataAgGrid<WithdrawalFieldsFragment>
) => {
const { ETHERSCAN_URL } = useEnvironment();
const {
@ -60,7 +60,7 @@ export const PendingWithdrawalsTable = (
valueFormatter={({
value,
data,
}: VegaValueFormatterParams<WithdrawalFields, 'amount'>) => {
}: VegaValueFormatterParams<WithdrawalFieldsFragment, 'amount'>) => {
return isNumeric(value) && data?.asset
? addDecimalsFormatNumber(value, data.asset.decimals)
: null;
@ -74,7 +74,7 @@ export const PendingWithdrawalsTable = (
value,
valueFormatted,
}: VegaICellRendererParams<
WithdrawalFields,
WithdrawalFieldsFragment,
'details.receiverAddress'
> & {
ethUrl: string;
@ -92,7 +92,7 @@ export const PendingWithdrawalsTable = (
valueFormatter={({
value,
}: VegaValueFormatterParams<
WithdrawalFields,
WithdrawalFieldsFragment,
'details.receiverAddress'
>) => {
if (!value) return '-';
@ -105,7 +105,7 @@ export const PendingWithdrawalsTable = (
valueFormatter={({
value,
}: VegaValueFormatterParams<
WithdrawalFields,
WithdrawalFieldsFragment,
'createdTimestamp'
>) => {
return value ? getDateTimeFormat().format(new Date(value)) : '';
@ -116,7 +116,7 @@ export const PendingWithdrawalsTable = (
field="status"
flex={2}
cellRendererParams={{
complete: async (withdrawal: WithdrawalFields) => {
complete: async (withdrawal: WithdrawalFieldsFragment) => {
const verified = await verify(withdrawal);
if (!verified) {
@ -149,8 +149,8 @@ export const PendingWithdrawalsTable = (
};
export type CompleteCellProps = {
data: WithdrawalFields;
complete: (withdrawal: WithdrawalFields) => void;
data: WithdrawalFieldsFragment;
complete: (withdrawal: WithdrawalFieldsFragment) => void;
};
export const CompleteCell = ({ data, complete }: CompleteCellProps) => (
<Button

View File

@ -1,15 +0,0 @@
import { gql } from '@apollo/client';
export const ERC20_APPROVAL_QUERY = gql`
query Erc20Approval($withdrawalId: ID!) {
erc20WithdrawalApproval(withdrawalId: $withdrawalId) {
assetSource
amount
nonce
signatures
targetAddress
expiry
creation
}
}
`;

View File

@ -1,13 +1,9 @@
import type { Asset } from '@vegaprotocol/assets';
import {
AccountType,
AssetStatus,
WithdrawalStatus,
} from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest';
import type { AccountFieldsFragment } from '@vegaprotocol/accounts';
import type { Withdrawals_party_withdrawalsConnection_edges_node } from './__generated__/Withdrawals';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
export const generateAsset = (override?: PartialDeep<Asset>) => {
const defaultAsset: Asset = {
@ -16,7 +12,7 @@ export const generateAsset = (override?: PartialDeep<Asset>) => {
name: 'asset-name',
quantum: '',
decimals: 5,
status: AssetStatus.STATUS_ENABLED,
status: Schema.AssetStatus.STATUS_ENABLED,
source: {
contractAddress: 'contract-address',
lifetimeLimit: '123000000',
@ -56,7 +52,7 @@ export const generateAccount = (
override?: PartialDeep<AccountFieldsFragment>
) => {
const defaultAccount: AccountFieldsFragment = {
type: AccountType.ACCOUNT_TYPE_GENERAL,
type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000',
asset: {
id: 'asset-id',
@ -66,13 +62,13 @@ export const generateAccount = (
};
export const generateWithdrawal = (
override?: PartialDeep<Withdrawals_party_withdrawalsConnection_edges_node>
): Withdrawals_party_withdrawalsConnection_edges_node => {
override?: PartialDeep<WithdrawalFieldsFragment>
): WithdrawalFieldsFragment => {
return merge(
{
__typename: 'Withdrawal',
id: 'withdrawal-id',
status: WithdrawalStatus.STATUS_OPEN,
status: Schema.WithdrawalStatus.STATUS_OPEN,
amount: '100',
asset: {
__typename: 'Asset',
@ -80,7 +76,7 @@ export const generateWithdrawal = (
id: 'asset-id',
symbol: 'asset-symbol',
decimals: 2,
status: AssetStatus.STATUS_ENABLED,
status: Schema.AssetStatus.STATUS_ENABLED,
source: {
__typename: 'ERC20',
contractAddress: '0x123',

View File

@ -4,11 +4,10 @@ import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import type { ReactNode } from 'react';
import { useCompleteWithdraw } from './use-complete-withdraw';
import type { Erc20Approval } from './__generated__/Erc20Approval';
import { ERC20_APPROVAL_QUERY } from './queries';
import type { Erc20ApprovalQuery } from './__generated__/Erc20Approval';
import { Erc20ApprovalDocument } from './__generated__/Erc20Approval';
import * as web3 from '@vegaprotocol/web3';
import * as sentry from '@sentry/react';
import type { Erc20Approval_erc20WithdrawalApproval } from './__generated__/Erc20Approval';
jest.mock('@vegaprotocol/web3', () => {
const orig = jest.requireActual('@vegaprotocol/web3');
@ -31,8 +30,7 @@ function setup(mocks?: MockedResponse[]) {
it('Should perform the Ethereum transaction with the fetched approval', async () => {
const withdrawalId = 'withdrawal-id';
const erc20WithdrawalApproval: Erc20Approval_erc20WithdrawalApproval = {
__typename: 'Erc20WithdrawalApproval',
const erc20WithdrawalApproval = {
assetSource: 'asset-source',
amount: '100',
nonce: '1',
@ -41,9 +39,9 @@ it('Should perform the Ethereum transaction with the fetched approval', async ()
targetAddress: 'target-address',
expiry: 'expiry',
};
const mockERC20Approval: MockedResponse<Erc20Approval> = {
const mockERC20Approval: MockedResponse<Erc20ApprovalQuery> = {
request: {
query: ERC20_APPROVAL_QUERY,
query: Erc20ApprovalDocument,
variables: { withdrawalId },
},
result: {
@ -77,9 +75,9 @@ it('Should perform the Ethereum transaction with the fetched approval', async ()
it('Captures an error if the erc20Withdrawal is not found', async () => {
const withdrawalId = 'withdrawal-id';
const mockERC20Approval: MockedResponse<Erc20Approval> = {
const mockERC20Approval: MockedResponse<Erc20ApprovalQuery> = {
request: {
query: ERC20_APPROVAL_QUERY,
query: Erc20ApprovalDocument,
variables: { withdrawalId },
},
result: {
@ -108,9 +106,9 @@ it('Captures an error if the erc20Withdrawal is not found', async () => {
it('Captures an error if erc20 approval query fails', async () => {
const withdrawalId = 'withdrawal-id';
const mockERC20Approval: MockedResponse<Erc20Approval> = {
const mockERC20Approval: MockedResponse<Erc20ApprovalQuery> = {
request: {
query: ERC20_APPROVAL_QUERY,
query: Erc20ApprovalDocument,
variables: { withdrawalId },
},
error: new Error('query failed'),

View File

@ -1,4 +1,4 @@
import { gql, useApolloClient } from '@apollo/client';
import { useApolloClient } from '@apollo/client';
import { captureException } from '@sentry/react';
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
import {
@ -7,19 +7,13 @@ import {
useEthereumTransaction,
} from '@vegaprotocol/web3';
import { useCallback, useEffect, useState } from 'react';
import { ERC20_APPROVAL_QUERY } from './queries';
import { Erc20ApprovalDocument } from './__generated__/Erc20Approval';
import type {
Erc20Approval,
Erc20ApprovalVariables,
Erc20ApprovalQuery,
Erc20ApprovalQueryVariables,
} from './__generated__/Erc20Approval';
import type { PendingWithdrawal } from './__generated__/PendingWithdrawal';
export const PENDING_WITHDRAWAL_FRAGMMENT = gql`
fragment PendingWithdrawal on Withdrawal {
pendingOnForeignChain @client
txHash
}
`;
import { PendingWithdrawalFragmentDoc } from './__generated__/Withdrawal';
import type { PendingWithdrawalFragment } from './__generated__/Withdrawal';
export const useCompleteWithdraw = () => {
const { query, cache } = useApolloClient();
@ -38,8 +32,11 @@ export const useCompleteWithdraw = () => {
if (!contract) {
return;
}
const res = await query<Erc20Approval, Erc20ApprovalVariables>({
query: ERC20_APPROVAL_QUERY,
const res = await query<
Erc20ApprovalQuery,
Erc20ApprovalQueryVariables
>({
query: Erc20ApprovalDocument,
variables: { withdrawalId },
});
@ -66,9 +63,9 @@ export const useCompleteWithdraw = () => {
useEffect(() => {
if (id && transaction.txHash) {
cache.writeFragment<PendingWithdrawal>({
cache.writeFragment<PendingWithdrawalFragment>({
id: `Withdrawal:${id}`,
fragment: PENDING_WITHDRAWAL_FRAGMMENT,
fragment: PendingWithdrawalFragmentDoc,
data: {
__typename: 'Withdrawal',
pendingOnForeignChain:

View File

@ -2,10 +2,10 @@ import { act, renderHook } from '@testing-library/react';
import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import type { ReactNode } from 'react';
import { ERC20_APPROVAL_QUERY } from './queries';
import type { WithdrawalArgs } from './use-create-withdraw';
import { useCreateWithdraw } from './use-create-withdraw';
import type { Erc20Approval } from './__generated__/Erc20Approval';
import { Erc20ApprovalDocument } from './__generated__/Erc20Approval';
import type { Erc20ApprovalQuery } from './__generated__/Erc20Approval';
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
import {
initialState,
@ -15,11 +15,10 @@ import {
} from '@vegaprotocol/wallet';
import { waitFor } from '@testing-library/react';
import type {
WithdrawalEvent,
WithdrawalEvent_busEvents_event_Withdrawal,
} from './__generated__/WithdrawalEvent';
import { WITHDRAWAL_BUS_EVENT_SUB } from './use-withdrawals';
import { WithdrawalStatus } from '@vegaprotocol/types';
WithdrawalEventSubscription,
WithdrawalFieldsFragment,
} from './__generated__/Withdrawal';
import { WithdrawalsDocument } from './__generated__/Withdrawal';
import { Schema } from '@vegaprotocol/types';
function setup(
@ -54,9 +53,9 @@ afterAll(() => {
const pubKey = '0x123';
let mockSend: jest.Mock;
let withdrawalInput: WithdrawalArgs;
let withdrawalEvent: WithdrawalEvent_busEvents_event_Withdrawal;
let mockERC20Approval: MockedResponse<Erc20Approval>;
let mockWithdrawalEvent: MockedResponse<WithdrawalEvent>;
let withdrawalEvent: WithdrawalFieldsFragment;
let mockERC20Approval: MockedResponse<Erc20ApprovalQuery>;
let mockWithdrawalEvent: MockedResponse<WithdrawalEventSubscription>;
beforeEach(() => {
mockSend = jest
@ -64,7 +63,7 @@ beforeEach(() => {
.mockReturnValue(Promise.resolve({ transactionHash: txHash, signature }));
withdrawalEvent = {
id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50',
status: WithdrawalStatus.STATUS_OPEN,
status: Schema.WithdrawalStatus.STATUS_OPEN,
amount: '100',
asset: {
__typename: 'Asset',
@ -96,7 +95,7 @@ beforeEach(() => {
};
mockERC20Approval = {
request: {
query: ERC20_APPROVAL_QUERY,
query: Erc20ApprovalDocument,
variables: { withdrawalId: derivedWithdrawalId },
},
result: {
@ -117,7 +116,7 @@ beforeEach(() => {
};
mockWithdrawalEvent = {
request: {
query: WITHDRAWAL_BUS_EVENT_SUB,
query: WithdrawalsDocument,
variables: { partyId: pubKey },
},
result: {

View File

@ -6,8 +6,8 @@ import {
import { useCallback, useState } from 'react';
import { useWithdrawalApproval } from './use-withdrawal-approval';
import { useWithdrawalEvent } from './use-withdrawal-event';
import type { Erc20Approval_erc20WithdrawalApproval } from './__generated__/Erc20Approval';
import type { WithdrawalFields } from './__generated__/WithdrawalFields';
import type { Erc20ApprovalQuery } from './__generated__/Erc20Approval';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
export interface WithdrawalArgs {
amount: string;
@ -18,9 +18,12 @@ export interface WithdrawalArgs {
export const useCreateWithdraw = () => {
const waitForWithdrawalApproval = useWithdrawalApproval();
const [approval, setApproval] =
useState<Erc20Approval_erc20WithdrawalApproval | null>(null);
const [withdrawal, setWithdrawal] = useState<WithdrawalFields | null>(null);
const [approval, setApproval] = useState<
Erc20ApprovalQuery['erc20WithdrawalApproval'] | null
>(null);
const [withdrawal, setWithdrawal] = useState<WithdrawalFieldsFragment | null>(
null
);
const [availableTimestamp, setAvailableTimestamp] = useState<number | null>(
null
);

View File

@ -1,8 +1,8 @@
import { useCallback } from 'react';
import { useBridgeContract } from '@vegaprotocol/web3';
import BigNumber from 'bignumber.js';
import type { Asset } from '@vegaprotocol/assets';
import { addDecimal } from '@vegaprotocol/react-helpers';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
/**
* Returns a function to get the threshold amount for a withdrawal. If a withdrawal amount
@ -12,7 +12,11 @@ import { addDecimal } from '@vegaprotocol/react-helpers';
export const useGetWithdrawThreshold = () => {
const contract = useBridgeContract();
const getThreshold = useCallback(
async (asset: Pick<Asset, 'source' | 'decimals'> | undefined) => {
async (
asset:
| Pick<WithdrawalFieldsFragment['asset'], 'source' | 'decimals'>
| undefined
) => {
if (!contract || asset?.source.__typename !== 'ERC20') {
return new BigNumber(Infinity);
}

View File

@ -1,17 +1,16 @@
import { useCallback, useState } from 'react';
import { captureException } from '@sentry/react';
import type { WithdrawalFields } from './__generated__/WithdrawalFields';
import BigNumber from 'bignumber.js';
import { addDecimal, t } from '@vegaprotocol/react-helpers';
import { useGetWithdrawThreshold } from './use-get-withdraw-threshold';
import { useGetWithdrawDelay } from './use-get-withdraw-delay';
import { ERC20_APPROVAL_QUERY } from './queries';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
import { Erc20ApprovalDocument } from './__generated__/Erc20Approval';
import type {
Erc20Approval,
Erc20ApprovalVariables,
Erc20ApprovalQuery,
Erc20ApprovalQueryVariables,
} from './__generated__/Erc20Approval';
import { useApolloClient } from '@apollo/client';
import type { ERC20Asset } from '@vegaprotocol/assets';
export enum ApprovalStatus {
Idle = 'Idle',
@ -58,7 +57,7 @@ export const useVerifyWithdrawal = () => {
}, [setState]);
const verify = useCallback(
async (withdrawal: WithdrawalFields) => {
async (withdrawal: WithdrawalFieldsFragment) => {
try {
setState({ dialogOpen: true });
@ -81,7 +80,7 @@ export const useVerifyWithdrawal = () => {
addDecimal(withdrawal.amount, withdrawal.asset.decimals)
);
const threshold = await getThreshold(withdrawal.asset as ERC20Asset);
const threshold = await getThreshold(withdrawal.asset);
if (threshold && amount.isGreaterThan(threshold)) {
const delaySecs = await getDelay();
@ -98,8 +97,11 @@ export const useVerifyWithdrawal = () => {
}
}
const res = await client.query<Erc20Approval, Erc20ApprovalVariables>({
query: ERC20_APPROVAL_QUERY,
const res = await client.query<
Erc20ApprovalQuery,
Erc20ApprovalQueryVariables
>({
query: Erc20ApprovalDocument,
variables: { withdrawalId: withdrawal.id },
});

View File

@ -1,15 +1,14 @@
import { useApolloClient } from '@apollo/client';
import { useCallback, useEffect, useRef } from 'react';
import { ERC20_APPROVAL_QUERY } from './queries';
import { Erc20ApprovalDocument } from './__generated__/Erc20Approval';
import type {
Erc20Approval,
Erc20ApprovalVariables,
Erc20Approval_erc20WithdrawalApproval,
Erc20ApprovalQuery,
Erc20ApprovalQueryVariables,
} from './__generated__/Erc20Approval';
type WaitForApproval = (
id: string
) => Promise<Erc20Approval_erc20WithdrawalApproval>;
) => Promise<Erc20ApprovalQuery['erc20WithdrawalApproval']>;
export const useWithdrawalApproval = () => {
const client = useApolloClient();
@ -22,10 +21,10 @@ export const useWithdrawalApproval = () => {
intervalRef.current = setInterval(async () => {
try {
const res = await client.query<
Erc20Approval,
Erc20ApprovalVariables
Erc20ApprovalQuery,
Erc20ApprovalQueryVariables
>({
query: ERC20_APPROVAL_QUERY,
query: Erc20ApprovalDocument,
variables: { withdrawalId: id },
fetchPolicy: 'network-only',
});

View File

@ -2,17 +2,17 @@ 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';
import { WithdrawalsDocument } from './__generated__/Withdrawal';
import type {
WithdrawalEvent,
WithdrawalEventVariables,
WithdrawalEvent_busEvents_event_Withdrawal,
} from './__generated__/WithdrawalEvent';
WithdrawalEventSubscription,
WithdrawalEventSubscriptionVariables,
WithdrawalFieldsFragment,
} from './__generated__/Withdrawal';
type WaitForWithdrawalEvent = (
id: string,
partyId: string
) => Promise<WithdrawalEvent_busEvents_event_Withdrawal>;
) => Promise<WithdrawalFieldsFragment>;
export const useWithdrawalEvent = (transaction: VegaTxState) => {
const client = useApolloClient();
@ -22,8 +22,11 @@ export const useWithdrawalEvent = (transaction: VegaTxState) => {
(id, partyId) => {
return new Promise((resolve) => {
subRef.current = client
.subscribe<WithdrawalEvent, WithdrawalEventVariables>({
query: WITHDRAWAL_BUS_EVENT_SUB,
.subscribe<
WithdrawalEventSubscription,
WithdrawalEventSubscriptionVariables
>({
query: WithdrawalsDocument,
variables: { partyId },
})
.subscribe(({ data }) => {

View File

@ -1,24 +1,21 @@
import { WithdrawalStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import { generateWithdrawal } from './test-helpers';
import { updateQuery } from './use-withdrawals';
import type {
WithdrawalEvent,
WithdrawalEvent_busEvents_event_Withdrawal,
} from './__generated__/WithdrawalEvent';
import type {
Withdrawals,
Withdrawals_party_withdrawalsConnection_edges_node,
} from './__generated__/Withdrawals';
WithdrawalsQuery,
WithdrawalEventSubscription,
WithdrawalFieldsFragment,
} from './__generated__/Withdrawal';
describe('updateQuery', () => {
it('updates existing withdrawals', () => {
const withdrawal = generateWithdrawal({
id: '1',
status: WithdrawalStatus.STATUS_OPEN,
status: Schema.WithdrawalStatus.STATUS_OPEN,
});
const withdrawalUpdate = generateWithdrawal({
id: '1',
status: WithdrawalStatus.STATUS_FINALIZED,
status: Schema.WithdrawalStatus.STATUS_FINALIZED,
});
const prev = mockQuery([withdrawal]);
const incoming = mockSub([withdrawalUpdate]);
@ -31,7 +28,6 @@ describe('updateQuery', () => {
__typename: 'WithdrawalsConnection',
edges: [
{
__typename: 'WithdrawalEdge',
node: withdrawalUpdate,
},
],
@ -60,11 +56,9 @@ describe('updateQuery', () => {
__typename: 'WithdrawalsConnection',
edges: [
{
__typename: 'WithdrawalEdge',
node: withdrawalUpdate,
},
{
__typename: 'WithdrawalEdge',
node: withdrawal,
},
],
@ -90,7 +84,6 @@ describe('updateQuery', () => {
__typename: 'WithdrawalsConnection',
edges: [
{
__typename: 'WithdrawalEdge',
node: withdrawalUpdate,
},
],
@ -102,14 +95,14 @@ describe('updateQuery', () => {
it('Handles updates and inserts simultaneously', () => {
const withdrawal1 = generateWithdrawal({
id: '1',
status: WithdrawalStatus.STATUS_OPEN,
status: Schema.WithdrawalStatus.STATUS_OPEN,
});
const withdrawal2 = generateWithdrawal({
id: '2',
});
const withdrawalUpdate = generateWithdrawal({
id: '1',
status: WithdrawalStatus.STATUS_FINALIZED,
status: Schema.WithdrawalStatus.STATUS_FINALIZED,
});
const withdrawalNew = generateWithdrawal({
id: '3',
@ -125,15 +118,12 @@ describe('updateQuery', () => {
__typename: 'WithdrawalsConnection',
edges: [
{
__typename: 'WithdrawalEdge',
node: withdrawalUpdate,
},
{
__typename: 'WithdrawalEdge',
node: withdrawalNew,
},
{
__typename: 'WithdrawalEdge',
node: withdrawal2,
},
],
@ -144,8 +134,8 @@ describe('updateQuery', () => {
});
const mockQuery = (
withdrawals: Withdrawals_party_withdrawalsConnection_edges_node[]
): Withdrawals => {
withdrawals: WithdrawalFieldsFragment[]
): WithdrawalsQuery => {
return {
party: {
__typename: 'Party',
@ -153,7 +143,6 @@ const mockQuery = (
withdrawalsConnection: {
__typename: 'WithdrawalsConnection',
edges: withdrawals.map((w) => ({
__typename: 'WithdrawalEdge',
node: w,
})),
},
@ -162,10 +151,10 @@ const mockQuery = (
};
const mockSub = (
withdrawals: WithdrawalEvent_busEvents_event_Withdrawal[]
withdrawals: WithdrawalFieldsFragment[]
): {
subscriptionData: {
data: WithdrawalEvent;
data: WithdrawalEventSubscription;
};
} => {
return {

Some files were not shown because too many files have changed in this diff Show More