chore: filter assets by status (1108) (#1192)
* chore: filter assets by status (1108) * chore: moved asset status * chore: re-adding filterin after merge (changed upstream) * chore: filter assets by status (1108) * chore: moved asset status * types * fixed deposit cypress tests
This commit is contained in:
parent
293e2ffbc3
commit
9de3683bf3
@ -3,6 +3,8 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
import { AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: Deposits
|
// GraphQL query operation: Deposits
|
||||||
// ====================================================
|
// ====================================================
|
||||||
@ -39,6 +41,10 @@ export interface Deposits_assetsConnection_edges_node {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery } from '@apollo/client';
|
||||||
import { DepositManager } from '@vegaprotocol/deposits';
|
import { DepositManager } from '@vegaprotocol/deposits';
|
||||||
import { t } from '@vegaprotocol/react-helpers';
|
import { getEnabledAssets, t } from '@vegaprotocol/react-helpers';
|
||||||
import { Networks, useEnvironment } from '@vegaprotocol/environment';
|
import { Networks, useEnvironment } from '@vegaprotocol/environment';
|
||||||
import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
import { Web3Container } from '@vegaprotocol/web3';
|
import { Web3Container } from '@vegaprotocol/web3';
|
||||||
import { assetsConnectionToAssets } from '@vegaprotocol/react-helpers';
|
|
||||||
import type { Deposits } from './__generated__/Deposits';
|
import type { Deposits } from './__generated__/Deposits';
|
||||||
|
|
||||||
const DEPOSITS_QUERY = gql`
|
const DEPOSITS_QUERY = gql`
|
||||||
@ -17,6 +16,7 @@ const DEPOSITS_QUERY = gql`
|
|||||||
name
|
name
|
||||||
symbol
|
symbol
|
||||||
decimals
|
decimals
|
||||||
|
status
|
||||||
source {
|
source {
|
||||||
... on ERC20 {
|
... on ERC20 {
|
||||||
contractAddress
|
contractAddress
|
||||||
@ -40,7 +40,7 @@ export const DepositContainer = () => {
|
|||||||
skip: !keypair?.pub,
|
skip: !keypair?.pub,
|
||||||
});
|
});
|
||||||
|
|
||||||
const assets = assetsConnectionToAssets(data?.assetsConnection);
|
const assets = getEnabledAssets(data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer<Deposits> data={data} loading={loading} error={error}>
|
<AsyncRenderer<Deposits> data={data} loading={loading} error={error}>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery } from '@apollo/client';
|
||||||
import { assetsConnectionToAssets, t } from '@vegaprotocol/react-helpers';
|
import { getAssets, t } from '@vegaprotocol/react-helpers';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RouteTitle } from '../../components/route-title';
|
import { RouteTitle } from '../../components/route-title';
|
||||||
import { SubHeading } from '../../components/sub-heading';
|
import { SubHeading } from '../../components/sub-heading';
|
||||||
@ -39,7 +39,7 @@ export const ASSETS_QUERY = gql`
|
|||||||
const Assets = () => {
|
const Assets = () => {
|
||||||
const { data } = useQuery<AssetsQuery>(ASSETS_QUERY);
|
const { data } = useQuery<AssetsQuery>(ASSETS_QUERY);
|
||||||
|
|
||||||
const assets = assetsConnectionToAssets(data?.assetsConnection);
|
const assets = getAssets(data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
|
@ -9,14 +9,15 @@ describe('deposit form validation', () => {
|
|||||||
cy.mockWeb3Provider();
|
cy.mockWeb3Provider();
|
||||||
cy.mockGQL((req) => {
|
cy.mockGQL((req) => {
|
||||||
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
||||||
aliasQuery(req, 'AssetsConnection', generateDepositPage());
|
aliasQuery(req, 'DepositPage', generateDepositPage());
|
||||||
});
|
});
|
||||||
cy.visit('/portfolio/deposit');
|
cy.visit('/portfolio/deposit');
|
||||||
|
|
||||||
cy.wait('@AssetsConnection');
|
|
||||||
// Deposit page requires connection Ethereum wallet first
|
// Deposit page requires connection Ethereum wallet first
|
||||||
cy.getByTestId(connectEthWalletBtn).click();
|
cy.getByTestId(connectEthWalletBtn).click();
|
||||||
cy.getByTestId('web3-connector-MetaMask').click();
|
cy.getByTestId('web3-connector-MetaMask').click();
|
||||||
|
|
||||||
|
cy.wait('@DepositPage');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles empty fields', () => {
|
it('handles empty fields', () => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { AssetStatus } from '@vegaprotocol/types';
|
||||||
import merge from 'lodash/merge';
|
import merge from 'lodash/merge';
|
||||||
import type { PartialDeep } from 'type-fest';
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ export const generateDepositPage = (
|
|||||||
symbol: 'AST0',
|
symbol: 'AST0',
|
||||||
name: 'Asset 0',
|
name: 'Asset 0',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
||||||
@ -28,6 +30,7 @@ export const generateDepositPage = (
|
|||||||
symbol: 'AST1',
|
symbol: 'AST1',
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AccountType } from '@vegaprotocol/types';
|
import { AccountType, AssetStatus } from '@vegaprotocol/types';
|
||||||
import type {
|
import type {
|
||||||
WithdrawFormQuery,
|
WithdrawFormQuery,
|
||||||
WithdrawFormQuery_assetsConnection_edges,
|
WithdrawFormQuery_assetsConnection_edges,
|
||||||
@ -32,6 +32,7 @@ export const generateWithdrawFormQuery = (
|
|||||||
symbol: 'AST0',
|
symbol: 'AST0',
|
||||||
name: 'Asset 0',
|
name: 'Asset 0',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
||||||
@ -46,6 +47,7 @@ export const generateWithdrawFormQuery = (
|
|||||||
symbol: 'AST1',
|
symbol: 'AST1',
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { WithdrawalStatus } from '@vegaprotocol/types';
|
import { AssetStatus, WithdrawalStatus } from '@vegaprotocol/types';
|
||||||
import type { Withdrawals } from '@vegaprotocol/withdraws';
|
import type { Withdrawals } from '@vegaprotocol/withdraws';
|
||||||
import merge from 'lodash/merge';
|
import merge from 'lodash/merge';
|
||||||
import type { PartialDeep } from 'type-fest';
|
import type { PartialDeep } from 'type-fest';
|
||||||
@ -30,6 +30,7 @@ export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
|
|||||||
name: 'asset-0 name',
|
name: 'asset-0 name',
|
||||||
symbol: 'AST0',
|
symbol: 'AST0',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x123',
|
contractAddress: '0x123',
|
||||||
@ -59,6 +60,7 @@ export const generateWithdrawals = (override?: PartialDeep<Withdrawals>) => {
|
|||||||
name: 'asset-0 name',
|
name: 'asset-0 name',
|
||||||
symbol: 'AST0',
|
symbol: 'AST0',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x123',
|
contractAddress: '0x123',
|
||||||
|
6
apps/trading/lib/__generated__/AssetFields.ts
generated
6
apps/trading/lib/__generated__/AssetFields.ts
generated
@ -3,6 +3,8 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
import { AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL fragment: AssetFields
|
// GraphQL fragment: AssetFields
|
||||||
// ====================================================
|
// ====================================================
|
||||||
@ -39,6 +41,10 @@ export interface AssetFields {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -6,6 +6,7 @@ export const ASSET_FRAGMENT = gql`
|
|||||||
symbol
|
symbol
|
||||||
name
|
name
|
||||||
decimals
|
decimals
|
||||||
|
status
|
||||||
source {
|
source {
|
||||||
... on ERC20 {
|
... on ERC20 {
|
||||||
contractAddress
|
contractAddress
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
import { AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: DepositPage
|
// GraphQL query operation: DepositPage
|
||||||
// ====================================================
|
// ====================================================
|
||||||
@ -39,6 +41,10 @@ export interface DepositPage_assetsConnection_edges_node {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,7 @@ import { gql } from '@apollo/client';
|
|||||||
import { PageQueryContainer } from '../../../components/page-query-container';
|
import { PageQueryContainer } from '../../../components/page-query-container';
|
||||||
import type { DepositPage } from './__generated__/DepositPage';
|
import type { DepositPage } from './__generated__/DepositPage';
|
||||||
import { DepositManager } from '@vegaprotocol/deposits';
|
import { DepositManager } from '@vegaprotocol/deposits';
|
||||||
import { assetsConnectionToAssets, t } from '@vegaprotocol/react-helpers';
|
import { getEnabledAssets, t } from '@vegaprotocol/react-helpers';
|
||||||
import { useEnvironment } from '@vegaprotocol/environment';
|
import { useEnvironment } from '@vegaprotocol/environment';
|
||||||
import { Splash } from '@vegaprotocol/ui-toolkit';
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { ASSET_FRAGMENT } from '../../../lib/query-fragments';
|
import { ASSET_FRAGMENT } from '../../../lib/query-fragments';
|
||||||
@ -30,7 +30,7 @@ export const DepositContainer = () => {
|
|||||||
<PageQueryContainer<DepositPage>
|
<PageQueryContainer<DepositPage>
|
||||||
query={DEPOSIT_PAGE_QUERY}
|
query={DEPOSIT_PAGE_QUERY}
|
||||||
render={(data) => {
|
render={(data) => {
|
||||||
const assets = assetsConnectionToAssets(data.assetsConnection);
|
const assets = getEnabledAssets(data);
|
||||||
if (!assets.length) {
|
if (!assets.length) {
|
||||||
return (
|
return (
|
||||||
<Splash>
|
<Splash>
|
||||||
|
@ -16,14 +16,15 @@ export interface Asset {
|
|||||||
source: ERC20AssetSource | BuiltinAssetSource;
|
source: ERC20AssetSource | BuiltinAssetSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AssetEdge {
|
export enum AssetStatus {
|
||||||
__typename: 'AssetEdge';
|
STATUS_ENABLED = 'STATUS_ENABLED',
|
||||||
node: Asset;
|
STATUS_PENDING_LISTING = 'STATUS_PENDING_LISTING',
|
||||||
|
STATUS_PROPOSED = 'STATUS_PROPOSED',
|
||||||
|
STATUS_REJECTED = 'STATUS_REJECTED',
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AssetsConnection {
|
export interface AssetWithStatus extends Asset {
|
||||||
__typename: 'AssetsConnection';
|
status: AssetStatus;
|
||||||
edges: (AssetEdge | null)[] | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ERC20Asset = Omit<Asset, 'source'> & {
|
export type ERC20Asset = Omit<Asset, 'source'> & {
|
||||||
@ -39,11 +40,26 @@ export const isAssetTypeERC20 = (asset?: Asset): asset is ERC20Asset => {
|
|||||||
return asset.source.__typename === 'ERC20';
|
return asset.source.__typename === 'ERC20';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const assetsConnectionToAssets = (
|
type AssetEdge<T extends Asset> = {
|
||||||
assetsConnection: AssetsConnection | undefined | null
|
__typename: 'AssetEdge';
|
||||||
): Asset[] => {
|
node: T;
|
||||||
const edges = assetsConnection?.edges?.filter((e) => e && e?.node);
|
|
||||||
if (!edges) return [];
|
|
||||||
|
|
||||||
return (edges as AssetEdge[]).map((e) => e.node);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type AssetsConnection<T extends Asset> = {
|
||||||
|
assetsConnection: {
|
||||||
|
edges: (AssetEdge<T> | null)[] | null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAssets = (data?: AssetsConnection<Asset>): Asset[] =>
|
||||||
|
data?.assetsConnection?.edges
|
||||||
|
?.filter((e) => e && e?.node)
|
||||||
|
.map((e) => (e as AssetEdge<Asset>).node as Asset) || [];
|
||||||
|
|
||||||
|
export const getEnabledAssets = (
|
||||||
|
data?: AssetsConnection<AssetWithStatus>
|
||||||
|
): Asset[] =>
|
||||||
|
data?.assetsConnection?.edges
|
||||||
|
?.filter((e) => e && e?.node)
|
||||||
|
.map((e) => (e as AssetEdge<AssetWithStatus>).node)
|
||||||
|
.filter((a) => a.status === AssetStatus.STATUS_ENABLED) || [];
|
||||||
|
7
libs/types/src/__generated__/globalTypes.ts
generated
7
libs/types/src/__generated__/globalTypes.ts
generated
@ -29,6 +29,13 @@ export enum AccountType {
|
|||||||
ACCOUNT_TYPE_SETTLEMENT = "ACCOUNT_TYPE_SETTLEMENT",
|
ACCOUNT_TYPE_SETTLEMENT = "ACCOUNT_TYPE_SETTLEMENT",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum AssetStatus {
|
||||||
|
STATUS_ENABLED = "STATUS_ENABLED",
|
||||||
|
STATUS_PENDING_LISTING = "STATUS_PENDING_LISTING",
|
||||||
|
STATUS_PROPOSED = "STATUS_PROPOSED",
|
||||||
|
STATUS_REJECTED = "STATUS_REJECTED",
|
||||||
|
}
|
||||||
|
|
||||||
export enum AuctionTrigger {
|
export enum AuctionTrigger {
|
||||||
AUCTION_TRIGGER_BATCH = "AUCTION_TRIGGER_BATCH",
|
AUCTION_TRIGGER_BATCH = "AUCTION_TRIGGER_BATCH",
|
||||||
AUCTION_TRIGGER_LIQUIDITY = "AUCTION_TRIGGER_LIQUIDITY",
|
AUCTION_TRIGGER_LIQUIDITY = "AUCTION_TRIGGER_LIQUIDITY",
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
import { AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL fragment: AssetFields
|
// GraphQL fragment: AssetFields
|
||||||
// ====================================================
|
// ====================================================
|
||||||
@ -39,6 +41,10 @@ export interface AssetFields {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { AccountType } from "@vegaprotocol/types";
|
import { AccountType, AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: WithdrawFormQuery
|
// GraphQL query operation: WithdrawFormQuery
|
||||||
@ -97,6 +97,10 @@ export interface WithdrawFormQuery_assetsConnection_edges_node {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WithdrawalStatus } from "@vegaprotocol/types";
|
import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL subscription operation: WithdrawalEvent
|
// GraphQL subscription operation: WithdrawalEvent
|
||||||
@ -45,6 +45,10 @@ export interface WithdrawalEvent_busEvents_event_Withdrawal_asset {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WithdrawalStatus } from "@vegaprotocol/types";
|
import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL fragment: WithdrawalFields
|
// GraphQL fragment: WithdrawalFields
|
||||||
@ -41,6 +41,10 @@ export interface WithdrawalFields_asset {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { WithdrawalStatus } from "@vegaprotocol/types";
|
import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: Withdrawals
|
// GraphQL query operation: Withdrawals
|
||||||
@ -41,6 +41,10 @@ export interface Withdrawals_party_withdrawalsConnection_edges_node_asset {
|
|||||||
* 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
|
* 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;
|
decimals: number;
|
||||||
|
/**
|
||||||
|
* The status of the asset in the Vega network
|
||||||
|
*/
|
||||||
|
status: AssetStatus;
|
||||||
/**
|
/**
|
||||||
* The origin source of the asset (e.g: an ERC20 asset)
|
* The origin source of the asset (e.g: an ERC20 asset)
|
||||||
*/
|
*/
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
import type { Asset } from '@vegaprotocol/react-helpers';
|
import type { Asset, AssetWithStatus } from '@vegaprotocol/react-helpers';
|
||||||
import { AccountType, WithdrawalStatus } from '@vegaprotocol/types';
|
import {
|
||||||
|
AccountType,
|
||||||
|
AssetStatus,
|
||||||
|
WithdrawalStatus,
|
||||||
|
} from '@vegaprotocol/types';
|
||||||
import merge from 'lodash/merge';
|
import merge from 'lodash/merge';
|
||||||
import type { PartialDeep } from 'type-fest';
|
import type { PartialDeep } from 'type-fest';
|
||||||
import type { Account } from './types';
|
import type { Account } from './types';
|
||||||
import type { Withdrawals_party_withdrawalsConnection_edges_node } from './__generated__/Withdrawals';
|
import type { Withdrawals_party_withdrawalsConnection_edges_node } from './__generated__/Withdrawals';
|
||||||
|
|
||||||
export const generateAsset = (override?: PartialDeep<Asset>) => {
|
export const generateAsset = (override?: PartialDeep<Asset>) => {
|
||||||
const defaultAsset: Asset = {
|
const defaultAsset: AssetWithStatus = {
|
||||||
__typename: 'Asset',
|
__typename: 'Asset',
|
||||||
id: 'asset-id',
|
id: 'asset-id',
|
||||||
symbol: 'asset-symbol',
|
symbol: 'asset-symbol',
|
||||||
name: 'asset-name',
|
name: 'asset-name',
|
||||||
decimals: 5,
|
decimals: 5,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: 'contract-address',
|
contractAddress: 'contract-address',
|
||||||
@ -47,6 +52,7 @@ export const generateWithdrawal = (
|
|||||||
id: 'asset-id',
|
id: 'asset-id',
|
||||||
symbol: 'asset-symbol',
|
symbol: 'asset-symbol',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x123',
|
contractAddress: '0x123',
|
||||||
|
@ -20,6 +20,7 @@ import type {
|
|||||||
} from './__generated__/WithdrawalEvent';
|
} from './__generated__/WithdrawalEvent';
|
||||||
import { WITHDRAWAL_BUS_EVENT_SUB } from './use-withdrawals';
|
import { WITHDRAWAL_BUS_EVENT_SUB } from './use-withdrawals';
|
||||||
import { WithdrawalStatus } from '@vegaprotocol/types';
|
import { WithdrawalStatus } from '@vegaprotocol/types';
|
||||||
|
import { AssetStatus } from '@vegaprotocol/types/types';
|
||||||
|
|
||||||
function setup(
|
function setup(
|
||||||
vegaWalletContext: Partial<VegaWalletContextShape>,
|
vegaWalletContext: Partial<VegaWalletContextShape>,
|
||||||
@ -73,6 +74,7 @@ beforeEach(() => {
|
|||||||
name: 'asset-name',
|
name: 'asset-name',
|
||||||
symbol: 'asset-symbol',
|
symbol: 'asset-symbol',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
|
status: AssetStatus.STATUS_ENABLED,
|
||||||
source: {
|
source: {
|
||||||
__typename: 'ERC20',
|
__typename: 'ERC20',
|
||||||
contractAddress: '0x123',
|
contractAddress: '0x123',
|
||||||
|
@ -27,6 +27,7 @@ const WITHDRAWAL_FRAGMENT = gql`
|
|||||||
name
|
name
|
||||||
symbol
|
symbol
|
||||||
decimals
|
decimals
|
||||||
|
status
|
||||||
source {
|
source {
|
||||||
... on ERC20 {
|
... on ERC20 {
|
||||||
contractAddress
|
contractAddress
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import compact from 'lodash/compact';
|
|
||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery } from '@apollo/client';
|
||||||
import { t } from '@vegaprotocol/react-helpers';
|
import { getEnabledAssets, t } from '@vegaprotocol/react-helpers';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import type { WithdrawalArgs } from './use-create-withdraw';
|
import type { WithdrawalArgs } from './use-create-withdraw';
|
||||||
import { WithdrawManager } from './withdraw-manager';
|
import { WithdrawManager } from './withdraw-manager';
|
||||||
@ -12,6 +11,7 @@ export const ASSET_FRAGMENT = gql`
|
|||||||
symbol
|
symbol
|
||||||
name
|
name
|
||||||
decimals
|
decimals
|
||||||
|
status
|
||||||
source {
|
source {
|
||||||
... on ERC20 {
|
... on ERC20 {
|
||||||
contractAddress
|
contractAddress
|
||||||
@ -69,7 +69,7 @@ export const WithdrawFormContainer = ({
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return compact(data.assetsConnection.edges).map((e) => e.node);
|
return getEnabledAssets(data);
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
if (loading || !data) {
|
if (loading || !data) {
|
||||||
|
@ -2,6 +2,7 @@ import { useCallback } from 'react';
|
|||||||
import sortBy from 'lodash/sortBy';
|
import sortBy from 'lodash/sortBy';
|
||||||
import { WithdrawForm } from './withdraw-form';
|
import { WithdrawForm } from './withdraw-form';
|
||||||
import type { WithdrawalArgs } from './use-create-withdraw';
|
import type { WithdrawalArgs } from './use-create-withdraw';
|
||||||
|
import type { Asset } from '@vegaprotocol/react-helpers';
|
||||||
import { addDecimal } from '@vegaprotocol/react-helpers';
|
import { addDecimal } from '@vegaprotocol/react-helpers';
|
||||||
import { AccountType } from '@vegaprotocol/types';
|
import { AccountType } from '@vegaprotocol/types';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
@ -10,10 +11,9 @@ import { useGetWithdrawThreshold } from './use-get-withdraw-threshold';
|
|||||||
import { captureException } from '@sentry/react';
|
import { captureException } from '@sentry/react';
|
||||||
import { useGetWithdrawDelay } from './use-get-withdraw-delay';
|
import { useGetWithdrawDelay } from './use-get-withdraw-delay';
|
||||||
import { useWithdrawStore } from './withdraw-store';
|
import { useWithdrawStore } from './withdraw-store';
|
||||||
import type { AssetFields } from './__generated__/AssetFields';
|
|
||||||
|
|
||||||
export interface WithdrawManagerProps {
|
export interface WithdrawManagerProps {
|
||||||
assets: AssetFields[];
|
assets: Asset[];
|
||||||
accounts: Account[];
|
accounts: Account[];
|
||||||
submit: (args: WithdrawalArgs) => void;
|
submit: (args: WithdrawalArgs) => void;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user