fix: rename tradesPaged to tradesConnection (#770)

* fix: rename tradesPaged to tradesConnection

* fix: add missing import

* fix: remove config url from trading app so e2e test runs
This commit is contained in:
Matthew Russell 2022-07-15 11:12:20 +01:00 committed by GitHub
parent 4edcdb8f1f
commit ca56d9393a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 86 additions and 57 deletions

View File

@ -69,7 +69,6 @@ describe('markets table', () => {
cy.get('[role="gridcell"][col-id=data]').contains('Active').click();
cy.wait('@Market');
cy.get('.ag-root-wrapper').should('be.visible');
cy.contains('ACTIVE MARKET');
cy.url().should('include', '/markets/market-0');

View File

@ -46,7 +46,7 @@ describe('fills', () => {
];
const result = generateFills({
party: {
tradesPaged: {
tradesConnection: {
edges: fills.map((f, i) => {
return {
__typename: 'TradeEdge',

View File

@ -1,13 +1,13 @@
import type {
Fills,
Fills_party_tradesPaged_edges_node,
Fills_party_tradesConnection_edges_node,
} from '@vegaprotocol/fills';
import { Side } from '@vegaprotocol/types';
import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest';
export const generateFills = (override?: PartialDeep<Fills>): Fills => {
const fills: Fills_party_tradesPaged_edges_node[] = [
const fills: Fills_party_tradesConnection_edges_node[] = [
generateFill({
buyer: {
id: Cypress.env('VEGA_PUBLIC_KEY'),
@ -49,7 +49,7 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
const defaultResult: Fills = {
party: {
id: 'buyer-id',
tradesPaged: {
tradesConnection: {
__typename: 'TradeConnection',
totalCount: 1,
edges: fills.map((f) => {
@ -73,9 +73,9 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
};
export const generateFill = (
override?: PartialDeep<Fills_party_tradesPaged_edges_node>
override?: PartialDeep<Fills_party_tradesConnection_edges_node>
) => {
const defaultFill: Fills_party_tradesPaged_edges_node = {
const defaultFill: Fills_party_tradesConnection_edges_node = {
__typename: 'Trade',
id: '0',
createdAt: new Date().toISOString(),

View File

@ -1,6 +1,5 @@
# App configuration variables
NX_VEGA_ENV=TESTNET
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://ropsten.etherscan.io

View File

@ -1,6 +1,5 @@
# App configuration variables
NX_VEGA_ENV=TESTNET
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8

View File

@ -9,7 +9,7 @@ import { Pagination, Side } from "@vegaprotocol/types";
// GraphQL query operation: Fills
// ====================================================
export interface Fills_party_tradesPaged_edges_node_buyer {
export interface Fills_party_tradesConnection_edges_node_buyer {
__typename: "Party";
/**
* Party identifier
@ -17,7 +17,7 @@ export interface Fills_party_tradesPaged_edges_node_buyer {
id: string;
}
export interface Fills_party_tradesPaged_edges_node_seller {
export interface Fills_party_tradesConnection_edges_node_seller {
__typename: "Party";
/**
* Party identifier
@ -25,7 +25,7 @@ export interface Fills_party_tradesPaged_edges_node_seller {
id: string;
}
export interface Fills_party_tradesPaged_edges_node_buyerFee {
export interface Fills_party_tradesConnection_edges_node_buyerFee {
__typename: "TradeFee";
/**
* The maker fee, aggressive party to the other party (the one who had an order in the book)
@ -41,7 +41,7 @@ export interface Fills_party_tradesPaged_edges_node_buyerFee {
liquidityFee: string;
}
export interface Fills_party_tradesPaged_edges_node_sellerFee {
export interface Fills_party_tradesConnection_edges_node_sellerFee {
__typename: "TradeFee";
/**
* The maker fee, aggressive party to the other party (the one who had an order in the book)
@ -57,7 +57,7 @@ export interface Fills_party_tradesPaged_edges_node_sellerFee {
liquidityFee: string;
}
export interface Fills_party_tradesPaged_edges_node_market_tradableInstrument_instrument_product_settlementAsset {
export interface Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument_product_settlementAsset {
__typename: "Asset";
/**
* The id of the asset
@ -73,15 +73,15 @@ export interface Fills_party_tradesPaged_edges_node_market_tradableInstrument_in
decimals: number;
}
export interface Fills_party_tradesPaged_edges_node_market_tradableInstrument_instrument_product {
export interface Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument_product {
__typename: "Future";
/**
* The name of the asset (string)
*/
settlementAsset: Fills_party_tradesPaged_edges_node_market_tradableInstrument_instrument_product_settlementAsset;
settlementAsset: Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument_product_settlementAsset;
}
export interface Fills_party_tradesPaged_edges_node_market_tradableInstrument_instrument {
export interface Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
@ -94,18 +94,18 @@ export interface Fills_party_tradesPaged_edges_node_market_tradableInstrument_in
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/
product: Fills_party_tradesPaged_edges_node_market_tradableInstrument_instrument_product;
product: Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument_product;
}
export interface Fills_party_tradesPaged_edges_node_market_tradableInstrument {
export interface Fills_party_tradesConnection_edges_node_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of or reference to a fully specified instrument.
*/
instrument: Fills_party_tradesPaged_edges_node_market_tradableInstrument_instrument;
instrument: Fills_party_tradesConnection_edges_node_market_tradableInstrument_instrument;
}
export interface Fills_party_tradesPaged_edges_node_market {
export interface Fills_party_tradesConnection_edges_node_market {
__typename: "Market";
/**
* Market ID
@ -141,10 +141,10 @@ export interface Fills_party_tradesPaged_edges_node_market {
/**
* An instance of or reference to a tradable instrument.
*/
tradableInstrument: Fills_party_tradesPaged_edges_node_market_tradableInstrument;
tradableInstrument: Fills_party_tradesConnection_edges_node_market_tradableInstrument;
}
export interface Fills_party_tradesPaged_edges_node {
export interface Fills_party_tradesConnection_edges_node {
__typename: "Trade";
/**
* The hash of the trade data
@ -177,38 +177,38 @@ export interface Fills_party_tradesPaged_edges_node {
/**
* The party that bought
*/
buyer: Fills_party_tradesPaged_edges_node_buyer;
buyer: Fills_party_tradesConnection_edges_node_buyer;
/**
* The party that sold
*/
seller: Fills_party_tradesPaged_edges_node_seller;
seller: Fills_party_tradesConnection_edges_node_seller;
/**
* The fee paid by the buyer side of the trade
*/
buyerFee: Fills_party_tradesPaged_edges_node_buyerFee;
buyerFee: Fills_party_tradesConnection_edges_node_buyerFee;
/**
* The fee paid by the seller side of the trade
*/
sellerFee: Fills_party_tradesPaged_edges_node_sellerFee;
sellerFee: Fills_party_tradesConnection_edges_node_sellerFee;
/**
* The market the trade occurred on
*/
market: Fills_party_tradesPaged_edges_node_market;
market: Fills_party_tradesConnection_edges_node_market;
}
export interface Fills_party_tradesPaged_edges {
export interface Fills_party_tradesConnection_edges {
__typename: "TradeEdge";
node: Fills_party_tradesPaged_edges_node;
node: Fills_party_tradesConnection_edges_node;
cursor: string;
}
export interface Fills_party_tradesPaged_pageInfo {
export interface Fills_party_tradesConnection_pageInfo {
__typename: "PageInfo";
startCursor: string;
endCursor: string;
}
export interface Fills_party_tradesPaged {
export interface Fills_party_tradesConnection {
__typename: "TradeConnection";
/**
* The total number of trades in this connection
@ -217,11 +217,11 @@ export interface Fills_party_tradesPaged {
/**
* The trade in this connection
*/
edges: Fills_party_tradesPaged_edges[];
edges: Fills_party_tradesConnection_edges[];
/**
* The pagination information
*/
pageInfo: Fills_party_tradesPaged_pageInfo;
pageInfo: Fills_party_tradesConnection_pageInfo;
}
export interface Fills_party {
@ -230,7 +230,7 @@ export interface Fills_party {
* Party identifier
*/
id: string;
tradesPaged: Fills_party_tradesPaged;
tradesConnection: Fills_party_tradesConnection;
}
export interface Fills {

View File

@ -5,7 +5,7 @@ import type { PageInfo, Pagination } from '@vegaprotocol/react-helpers';
import type { FillFields } from './__generated__/FillFields';
import type {
Fills,
Fills_party_tradesPaged_edges,
Fills_party_tradesConnection_edges,
} from './__generated__/Fills';
import type { FillsSub } from './__generated__/FillsSub';
@ -17,19 +17,41 @@ const FILL_FRAGMENT = gql`
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
name
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
@ -41,7 +63,7 @@ export const FILLS_QUERY = gql`
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
party(id: $partyId) {
id
tradesPaged(marketId: $marketId, pagination: $pagination) {
tradesConnection(marketId: $marketId, pagination: $pagination) {
totalCount
edges {
node {
@ -67,7 +89,10 @@ export const FILLS_SUB = gql`
}
`;
const update = (data: Fills_party_tradesPaged_edges[], delta: FillFields[]) => {
const update = (
data: Fills_party_tradesConnection_edges[],
delta: FillFields[]
) => {
return produce(data, (draft) => {
delta.forEach((node) => {
const index = draft.findIndex((edge) => edge.node.id === node.id);
@ -80,21 +105,23 @@ const update = (data: Fills_party_tradesPaged_edges[], delta: FillFields[]) => {
});
};
const getData = (responseData: Fills): Fills_party_tradesPaged_edges[] | null =>
responseData.party?.tradesPaged.edges || null;
const getData = (
responseData: Fills
): Fills_party_tradesConnection_edges[] | null =>
responseData.party?.tradesConnection.edges || null;
const getPageInfo = (responseData: Fills): PageInfo | null =>
responseData.party?.tradesPaged.pageInfo || null;
responseData.party?.tradesConnection.pageInfo || null;
const getTotalCount = (responseData: Fills): number | undefined =>
responseData.party?.tradesPaged.totalCount;
responseData.party?.tradesConnection.totalCount;
const getDelta = (subscriptionData: FillsSub) => subscriptionData.trades || [];
const append = (
data: Fills_party_tradesPaged_edges[] | null,
data: Fills_party_tradesConnection_edges[] | null,
pageInfo: PageInfo,
insertionData: Fills_party_tradesPaged_edges[] | null,
insertionData: Fills_party_tradesConnection_edges[] | null,
insertionPageInfo: PageInfo | null,
pagination?: Pagination
) => {

View File

@ -6,7 +6,7 @@ import { FillsTable } from './fills-table';
import type { IGetRowsParams } from 'ag-grid-community';
import { fillsDataProvider as dataProvider } from './fills-data-provider';
import type { Fills_party_tradesPaged_edges } from './__generated__/Fills';
import type { Fills_party_tradesConnection_edges } from './__generated__/Fills';
import type { FillsSub_trades } from './__generated__/FillsSub';
interface FillsManagerProps {
@ -15,11 +15,11 @@ interface FillsManagerProps {
export const FillsManager = ({ partyId }: FillsManagerProps) => {
const gridRef = useRef<AgGridReact | null>(null);
const dataRef = useRef<Fills_party_tradesPaged_edges[] | null>(null);
const dataRef = useRef<Fills_party_tradesConnection_edges[] | null>(null);
const totalCountRef = useRef<number | undefined>(undefined);
const update = useCallback(
({ data }: { data: Fills_party_tradesPaged_edges[] }) => {
({ data }: { data: Fills_party_tradesConnection_edges[] }) => {
if (!gridRef.current?.api) {
return false;
}
@ -35,7 +35,7 @@ export const FillsManager = ({ partyId }: FillsManagerProps) => {
data,
totalCount,
}: {
data: Fills_party_tradesPaged_edges[];
data: Fills_party_tradesConnection_edges[];
totalCount?: number;
}) => {
dataRef.current = data;
@ -48,7 +48,7 @@ export const FillsManager = ({ partyId }: FillsManagerProps) => {
const variables = useMemo(() => ({ partyId }), [partyId]);
const { data, error, loading, load, totalCount } = useDataProvider<
Fills_party_tradesPaged_edges[],
Fills_party_tradesConnection_edges[],
FillsSub_trades[]
>({ dataProvider, update, insert, variables });
totalCountRef.current = totalCount;

View File

@ -16,7 +16,7 @@ Default.args = {
partyId: 'party-id',
datasource: {
getRows: makeGetRows(
fills.party?.tradesPaged.edges.map((e) => e.node) || []
fills.party?.tradesConnection.edges.map((e) => e.node) || []
),
},
};

View File

@ -1,14 +1,14 @@
import { Side } from '@vegaprotocol/types';
import merge from 'lodash/merge';
import type { IGetRowsParams } from 'ag-grid-community';
import type { PartialDeep } from 'type-fest';
import type {
Fills,
Fills_party_tradesPaged_edges_node,
Fills_party_tradesConnection_edges_node,
} from './__generated__/Fills';
import { Side } from '@vegaprotocol/types';
export const generateFills = (override?: PartialDeep<Fills>): Fills => {
const fills: Fills_party_tradesPaged_edges_node[] = [
const fills: Fills_party_tradesConnection_edges_node[] = [
generateFill({
buyer: {
id: 'party-id',
@ -50,7 +50,7 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
const defaultResult: Fills = {
party: {
id: 'buyer-id',
tradesPaged: {
tradesConnection: {
__typename: 'TradeConnection',
totalCount: 1,
edges: fills.map((f) => {
@ -74,9 +74,9 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
};
export const generateFill = (
override?: PartialDeep<Fills_party_tradesPaged_edges_node>
override?: PartialDeep<Fills_party_tradesConnection_edges_node>
) => {
const defaultFill: Fills_party_tradesPaged_edges_node = {
const defaultFill: Fills_party_tradesConnection_edges_node = {
__typename: 'Trade',
id: '0',
createdAt: new Date().toISOString(),
@ -135,7 +135,7 @@ export const generateFill = (
};
export const makeGetRows =
(data: Fills_party_tradesPaged_edges_node[]) =>
(data: Fills_party_tradesConnection_edges_node[]) =>
({ successCallback }: IGetRowsParams) => {
successCallback(data, data.length);
};

View File

@ -110,6 +110,7 @@ export enum MarketTradingMode {
BatchAuction = "BatchAuction",
Continuous = "Continuous",
MonitoringAuction = "MonitoringAuction",
NoTrading = "NoTrading",
OpeningAuction = "OpeningAuction",
}
@ -211,6 +212,7 @@ export enum ProposalRejectionReason {
EnactTimeTooLate = "EnactTimeTooLate",
EnactTimeTooSoon = "EnactTimeTooSoon",
IncompatibleTimestamps = "IncompatibleTimestamps",
InsufficientEquityLikeShare = "InsufficientEquityLikeShare",
InsufficientTokens = "InsufficientTokens",
InvalidAsset = "InvalidAsset",
InvalidAssetDetails = "InvalidAssetDetails",
@ -218,6 +220,7 @@ export enum ProposalRejectionReason {
InvalidFutureMaturityTimestamp = "InvalidFutureMaturityTimestamp",
InvalidFutureProduct = "InvalidFutureProduct",
InvalidInstrumentSecurity = "InvalidInstrumentSecurity",
InvalidMarket = "InvalidMarket",
InvalidRiskParameter = "InvalidRiskParameter",
InvalidShape = "InvalidShape",
MajorityThresholdNotReached = "MajorityThresholdNotReached",
@ -236,6 +239,8 @@ export enum ProposalRejectionReason {
OpeningAuctionDurationTooSmall = "OpeningAuctionDurationTooSmall",
ParticipationThresholdNotReached = "ParticipationThresholdNotReached",
ProductMaturityIsPassed = "ProductMaturityIsPassed",
TooManyMarketDecimalPlaces = "TooManyMarketDecimalPlaces",
TooManyPriceMonitoringTriggers = "TooManyPriceMonitoringTriggers",
UnsupportedProduct = "UnsupportedProduct",
UnsupportedTradingMode = "UnsupportedTradingMode",
}