fix(governance): rewards pagination and columns (#5879)
This commit is contained in:
parent
2b91aebc2a
commit
4733bc169c
@ -14,7 +14,6 @@ NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/m
|
|||||||
|
|
||||||
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/main/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/main/announcements.json
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||||
|
@ -15,7 +15,6 @@ NX_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit suppl
|
|||||||
NX_LOCAL_PROVIDER_URL=http://localhost:8545/
|
NX_LOCAL_PROVIDER_URL=http://localhost:8545/
|
||||||
NX_VEGA_WALLET_URL=http://localhost:1789
|
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
|||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
NX_VEGA_EXPLORER_URL=#
|
NX_VEGA_EXPLORER_URL=#
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-devnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-devnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.n00.devnet1.vega.xyz/api/v2/
|
NX_VEGA_REST_URL=https://api.n00.devnet1.vega.xyz/api/v2/
|
||||||
|
@ -10,7 +10,6 @@ NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/
|
|||||||
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz
|
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet
|
||||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40:87edc2605e544f888305d7fc4a9141bd@o286262.ingest.sentry.io/5882996
|
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40:87edc2605e544f888305d7fc4a9141bd@o286262.ingest.sentry.io/5882996
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.vega.community/api/v2/
|
NX_VEGA_REST_URL=https://api.vega.community/api/v2/
|
||||||
|
@ -9,7 +9,6 @@ NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
|||||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.mainnet-mirror.vega.rocks
|
NX_VEGA_EXPLORER_URL=https://explorer.mainnet-mirror.vega.rocks
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-mirror-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-mirror-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.mainnet-mirror.vega.rocks/api/v2/
|
NX_VEGA_REST_URL=https://api.mainnet-mirror.vega.rocks/api/v2/
|
||||||
|
@ -5,7 +5,6 @@ NX_VEGA_NETWORKS='{"DEVNET":"https://dev.governance.vega.xyz","STAGNET1":"https:
|
|||||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml
|
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks
|
NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
||||||
|
@ -9,7 +9,6 @@ NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
|||||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-testnet-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-testnet-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/
|
NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/
|
||||||
|
@ -4,7 +4,6 @@ import keyBy from 'lodash/keyBy';
|
|||||||
import uniq from 'lodash/uniq';
|
import uniq from 'lodash/uniq';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ENV } from '../../config';
|
|
||||||
|
|
||||||
import noIcon from '../../images/token-no-icon.png';
|
import noIcon from '../../images/token-no-icon.png';
|
||||||
import vegaBlack from '../../images/vega_black.png';
|
import vegaBlack from '../../images/vega_black.png';
|
||||||
@ -37,7 +36,6 @@ export const usePollForDelegations = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
const { delegationsPagination } = ENV;
|
|
||||||
const [delegations, setDelegations] = React.useState<
|
const [delegations, setDelegations] = React.useState<
|
||||||
WalletDelegationFieldsFragment[]
|
WalletDelegationFieldsFragment[]
|
||||||
>([]);
|
>([]);
|
||||||
@ -68,11 +66,9 @@ export const usePollForDelegations = () => {
|
|||||||
query: DelegationsDocument,
|
query: DelegationsDocument,
|
||||||
variables: {
|
variables: {
|
||||||
partyId: pubKey,
|
partyId: pubKey,
|
||||||
delegationsPagination: delegationsPagination
|
delegationsPagination: {
|
||||||
? {
|
first: 50,
|
||||||
first: Number(delegationsPagination),
|
},
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
})
|
})
|
||||||
@ -236,14 +232,14 @@ export const usePollForDelegations = () => {
|
|||||||
// will just continue to fail
|
// will just continue to fail
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
mounted = false;
|
mounted = false;
|
||||||
};
|
};
|
||||||
}, [delegationsPagination, client, decimals, pubKey, t, vegaToken.address]);
|
}, [client, decimals, pubKey, t, vegaToken.address]);
|
||||||
|
|
||||||
return { delegations, currentStakeAvailable, delegatedNodes, accounts };
|
return { delegations, currentStakeAvailable, delegatedNodes, accounts };
|
||||||
};
|
};
|
||||||
|
@ -65,7 +65,6 @@ export const ENV = {
|
|||||||
docsUrl: windowOrDefault('NX_VEGA_DOCS_URL'),
|
docsUrl: windowOrDefault('NX_VEGA_DOCS_URL'),
|
||||||
ethWalletMnemonic: windowOrDefault('NX_ETH_WALLET_MNEMONIC'),
|
ethWalletMnemonic: windowOrDefault('NX_ETH_WALLET_MNEMONIC'),
|
||||||
localProviderUrl: windowOrDefault('NX_LOCAL_PROVIDER_URL'),
|
localProviderUrl: windowOrDefault('NX_LOCAL_PROVIDER_URL'),
|
||||||
delegationsPagination: windowOrDefault('NX_DELEGATIONS_PAGINATION'),
|
|
||||||
rest: windowOrDefault('NX_VEGA_REST_URL'),
|
rest: windowOrDefault('NX_VEGA_REST_URL'),
|
||||||
addresses:
|
addresses:
|
||||||
ContractAddresses[(envName === 'local' ? 'CUSTOM' : envName) as Networks],
|
ContractAddresses[(envName === 'local' ? 'CUSTOM' : envName) as Networks],
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { useMemo, useEffect, useState, useCallback, useRef } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||||
import type { EpochFieldsFragment } from '../home/__generated__/Rewards';
|
import type { EpochFieldsFragment } from '../home/__generated__/Rewards';
|
||||||
import { useRewardsQuery } from '../home/__generated__/Rewards';
|
import { useRewardsQuery } from '../home/__generated__/Rewards';
|
||||||
import { ENV } from '../../../config';
|
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
import { EpochIndividualRewardsTable } from './epoch-individual-rewards-table';
|
import { EpochIndividualRewardsTable } from './epoch-individual-rewards-table';
|
||||||
import { generateEpochIndividualRewardsList } from './generate-epoch-individual-rewards-list';
|
import { generateEpochIndividualRewardsList } from './generate-epoch-individual-rewards-list';
|
||||||
@ -27,22 +26,16 @@ export const EpochIndividualRewards = ({
|
|||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
const { delegationsPagination } = ENV;
|
|
||||||
const { param: marketCreationQuantumMultiple } = useNetworkParam(
|
const { param: marketCreationQuantumMultiple } = useNetworkParam(
|
||||||
'rewards_marketCreationQuantumMultiple'
|
'rewards_marketCreationQuantumMultiple'
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data, loading, error, refetch } = useRewardsQuery({
|
const { data, loading, error } = useRewardsQuery({
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
variables: {
|
variables: {
|
||||||
partyId: pubKey || '',
|
partyId: pubKey || '',
|
||||||
fromEpoch: epochId - EPOCHS_PAGE_SIZE,
|
...calculateEpochOffset({ epochId, page, size: EPOCHS_PAGE_SIZE }),
|
||||||
toEpoch: epochId,
|
delegationsPagination: { first: 50 },
|
||||||
delegationsPagination: delegationsPagination
|
|
||||||
? {
|
|
||||||
first: Number(delegationsPagination),
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
skip: !pubKey,
|
skip: !pubKey,
|
||||||
});
|
});
|
||||||
@ -70,36 +63,6 @@ export const EpochIndividualRewards = ({
|
|||||||
});
|
});
|
||||||
}, [data?.party, epochId, epochRewardSummaries, page, rewards]);
|
}, [data?.party, epochId, epochRewardSummaries, page, rewards]);
|
||||||
|
|
||||||
const refetchData = useCallback(
|
|
||||||
async (toPage?: number) => {
|
|
||||||
const targetPage = toPage ?? page;
|
|
||||||
await refetch({
|
|
||||||
partyId: pubKey || '',
|
|
||||||
...calculateEpochOffset({ epochId, page, size: EPOCHS_PAGE_SIZE }),
|
|
||||||
delegationsPagination: delegationsPagination
|
|
||||||
? {
|
|
||||||
first: Number(delegationsPagination),
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
});
|
|
||||||
setPage(targetPage);
|
|
||||||
},
|
|
||||||
[epochId, page, refetch, delegationsPagination, pubKey]
|
|
||||||
);
|
|
||||||
|
|
||||||
const prevEpochIdRef = useRef<number | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (prevEpochIdRef.current === null) {
|
|
||||||
prevEpochIdRef.current = epochId;
|
|
||||||
} else if (epochId !== prevEpochIdRef.current) {
|
|
||||||
// When the epoch changes, we want to refetch the data to update the current page
|
|
||||||
refetchData();
|
|
||||||
}
|
|
||||||
|
|
||||||
prevEpochIdRef.current = epochId;
|
|
||||||
}, [epochId, refetchData]);
|
|
||||||
|
|
||||||
// Workarounds for the error handling of AsyncRenderer
|
// Workarounds for the error handling of AsyncRenderer
|
||||||
const filteredErrors = filterAcceptableGraphqlErrors(error);
|
const filteredErrors = filterAcceptableGraphqlErrors(error);
|
||||||
const filteredData = data || [];
|
const filteredData = data || [];
|
||||||
@ -131,10 +94,10 @@ export const EpochIndividualRewards = ({
|
|||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
hasPrevPage={page > 1}
|
hasPrevPage={page > 1}
|
||||||
hasNextPage={page < totalPages}
|
hasNextPage={page < totalPages}
|
||||||
onBack={() => refetchData(page - 1)}
|
onBack={() => setPage((x) => x - 1)}
|
||||||
onNext={() => refetchData(page + 1)}
|
onNext={() => setPage((x) => x + 1)}
|
||||||
onFirst={() => refetchData(1)}
|
onFirst={() => setPage(1)}
|
||||||
onLast={() => refetchData(totalPages)}
|
onLast={() => setPage(totalPages)}
|
||||||
>
|
>
|
||||||
{t('Page')} {page}
|
{t('Page')} {page}
|
||||||
</Pagination>
|
</Pagination>
|
||||||
|
@ -23,36 +23,6 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
epoch: { id: '2' },
|
epoch: { id: '2' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const reward3: RewardFieldsFragment = {
|
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '200',
|
|
||||||
percentageOfTotal: '0.2',
|
|
||||||
receivedAt: new Date(),
|
|
||||||
asset: { id: 'gbp', symbol: 'GBP', name: 'GBP', decimals: 7 },
|
|
||||||
party: { id: 'blah' },
|
|
||||||
epoch: { id: '2' },
|
|
||||||
};
|
|
||||||
|
|
||||||
const reward4: RewardFieldsFragment = {
|
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '100',
|
|
||||||
percentageOfTotal: '0.1',
|
|
||||||
receivedAt: new Date(),
|
|
||||||
asset: { id: 'usd', symbol: 'USD', name: 'USD', decimals: 6 },
|
|
||||||
party: { id: 'blah' },
|
|
||||||
epoch: { id: '1' },
|
|
||||||
};
|
|
||||||
|
|
||||||
const reward5: RewardFieldsFragment = {
|
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '150',
|
|
||||||
percentageOfTotal: '0.15',
|
|
||||||
receivedAt: new Date(),
|
|
||||||
asset: { id: 'usd', symbol: 'USD', name: 'USD', decimals: 6 },
|
|
||||||
party: { id: 'blah' },
|
|
||||||
epoch: { id: '3' },
|
|
||||||
};
|
|
||||||
|
|
||||||
const rewardWrongType: RewardFieldsFragment = {
|
const rewardWrongType: RewardFieldsFragment = {
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_INSURANCE,
|
rewardType: AccountType.ACCOUNT_TYPE_INSURANCE,
|
||||||
amount: '50',
|
amount: '50',
|
||||||
@ -120,26 +90,10 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '0',
|
amount: '0',
|
||||||
percentageOfTotal: '0',
|
percentageOfTotal: '0',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
||||||
amount: '100',
|
amount: '100',
|
||||||
percentageOfTotal: '0.1',
|
percentageOfTotal: '0.1',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -147,7 +101,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return an array sorted by epoch descending', () => {
|
it('should return an array sorted by epoch descending', () => {
|
||||||
const rewards = [reward1, reward2, reward3, reward4];
|
const rewards = [reward1, reward2];
|
||||||
const result1 = generateEpochIndividualRewardsList({
|
const result1 = generateEpochIndividualRewardsList({
|
||||||
rewards,
|
rewards,
|
||||||
epochId: 2,
|
epochId: 2,
|
||||||
@ -157,7 +111,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
expect(result1[0].epoch).toEqual(2);
|
expect(result1[0].epoch).toEqual(2);
|
||||||
expect(result1[1].epoch).toEqual(1);
|
expect(result1[1].epoch).toEqual(1);
|
||||||
|
|
||||||
const reorderedRewards = [reward4, reward3, reward2, reward1];
|
const reorderedRewards = [reward2, reward1];
|
||||||
const result2 = generateEpochIndividualRewardsList({
|
const result2 = generateEpochIndividualRewardsList({
|
||||||
rewards: reorderedRewards,
|
rewards: reorderedRewards,
|
||||||
epochId: 2,
|
epochId: 2,
|
||||||
@ -170,7 +124,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
|
|
||||||
it('returns data in the expected shape', () => {
|
it('returns data in the expected shape', () => {
|
||||||
// Just sanity checking the whole structure here
|
// Just sanity checking the whole structure here
|
||||||
const rewards = [reward1, reward2, reward3, reward4];
|
const rewards = [reward1, reward2];
|
||||||
const result = generateEpochIndividualRewardsList({
|
const result = generateEpochIndividualRewardsList({
|
||||||
rewards,
|
rewards,
|
||||||
epochId: 2,
|
epochId: 2,
|
||||||
@ -181,37 +135,6 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
rewards: [
|
rewards: [
|
||||||
{
|
|
||||||
asset: 'GBP',
|
|
||||||
totalAmount: '200',
|
|
||||||
decimals: 7,
|
|
||||||
rewardTypes: {
|
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '200',
|
|
||||||
percentageOfTotal: '0.2',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
asset: 'EUR',
|
asset: 'EUR',
|
||||||
totalAmount: '50',
|
totalAmount: '50',
|
||||||
@ -221,26 +144,10 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '0',
|
amount: '0',
|
||||||
percentageOfTotal: '0',
|
percentageOfTotal: '0',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
||||||
amount: '50',
|
amount: '50',
|
||||||
percentageOfTotal: '0.05',
|
percentageOfTotal: '0.05',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -250,33 +157,17 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
rewards: [
|
rewards: [
|
||||||
{
|
{
|
||||||
asset: 'USD',
|
asset: 'USD',
|
||||||
totalAmount: '200',
|
totalAmount: '100',
|
||||||
decimals: 6,
|
decimals: 6,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
percentageOfTotal: '0',
|
percentageOfTotal: '0',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '100',
|
|
||||||
percentageOfTotal: '0.1',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
||||||
amount: '100',
|
amount: '100',
|
||||||
percentageOfTotal: '0.1',
|
percentageOfTotal: '0.1',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -285,7 +176,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns data correctly for the requested epoch range', () => {
|
it('returns data correctly for the requested epoch range', () => {
|
||||||
const rewards = [reward1, reward2, reward3, reward4, reward5];
|
const rewards = [reward1, reward2];
|
||||||
const resultPageOne = generateEpochIndividualRewardsList({
|
const resultPageOne = generateEpochIndividualRewardsList({
|
||||||
rewards,
|
rewards,
|
||||||
epochId: 3,
|
epochId: 3,
|
||||||
@ -297,74 +188,11 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
expect(resultPageOne).toEqual([
|
expect(resultPageOne).toEqual([
|
||||||
{
|
{
|
||||||
epoch: 3,
|
epoch: 3,
|
||||||
rewards: [
|
rewards: [],
|
||||||
{
|
|
||||||
asset: 'USD',
|
|
||||||
decimals: 6,
|
|
||||||
totalAmount: '150',
|
|
||||||
rewardTypes: {
|
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '150',
|
|
||||||
percentageOfTotal: '0.15',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
rewards: [
|
rewards: [
|
||||||
{
|
|
||||||
asset: 'GBP',
|
|
||||||
totalAmount: '200',
|
|
||||||
decimals: 7,
|
|
||||||
rewardTypes: {
|
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '200',
|
|
||||||
percentageOfTotal: '0.2',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
asset: 'EUR',
|
asset: 'EUR',
|
||||||
totalAmount: '50',
|
totalAmount: '50',
|
||||||
@ -374,26 +202,10 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '0',
|
amount: '0',
|
||||||
percentageOfTotal: '0',
|
percentageOfTotal: '0',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
||||||
amount: '50',
|
amount: '50',
|
||||||
percentageOfTotal: '0.05',
|
percentageOfTotal: '0.05',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -414,33 +226,17 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
rewards: [
|
rewards: [
|
||||||
{
|
{
|
||||||
asset: 'USD',
|
asset: 'USD',
|
||||||
totalAmount: '200',
|
totalAmount: '100',
|
||||||
decimals: 6,
|
decimals: 6,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
percentageOfTotal: '0',
|
percentageOfTotal: '0',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
amount: '100',
|
|
||||||
percentageOfTotal: '0.1',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
[AccountType.ACCOUNT_TYPE_GLOBAL_REWARD]: {
|
||||||
amount: '100',
|
amount: '100',
|
||||||
percentageOfTotal: '0.1',
|
percentageOfTotal: '0.1',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
amount: '0',
|
|
||||||
percentageOfTotal: '0',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useState, useCallback, useEffect } from 'react';
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { EpochFieldsFragment } from '../home/__generated__/Rewards';
|
import type { EpochFieldsFragment } from '../home/__generated__/Rewards';
|
||||||
@ -23,36 +23,16 @@ export const EpochTotalRewards = ({ currentEpoch }: EpochTotalRewardsProps) => {
|
|||||||
'rewards_marketCreationQuantumMultiple'
|
'rewards_marketCreationQuantumMultiple'
|
||||||
);
|
);
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const { data, loading, error, refetch } = useEpochAssetsRewardsQuery({
|
const { data, loading, error } = useEpochAssetsRewardsQuery({
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
variables: {
|
variables: {
|
||||||
epochRewardSummariesFilter: {
|
|
||||||
fromEpoch: epochId - EPOCHS_PAGE_SIZE,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const refetchData = useCallback(
|
|
||||||
async (toPage?: number) => {
|
|
||||||
const targetPage = toPage ?? page;
|
|
||||||
await refetch({
|
|
||||||
epochRewardSummariesFilter: calculateEpochOffset({
|
epochRewardSummariesFilter: calculateEpochOffset({
|
||||||
epochId,
|
epochId,
|
||||||
page: targetPage,
|
page: page,
|
||||||
size: EPOCHS_PAGE_SIZE,
|
size: EPOCHS_PAGE_SIZE,
|
||||||
}),
|
}),
|
||||||
});
|
|
||||||
setPage(targetPage);
|
|
||||||
},
|
},
|
||||||
[epochId, page, refetch]
|
});
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// when the epoch changes, we want to refetch the data to update the current page
|
|
||||||
if (data) {
|
|
||||||
refetchData();
|
|
||||||
}
|
|
||||||
}, [epochId, data, refetchData]);
|
|
||||||
|
|
||||||
const epochTotalRewardSummaries =
|
const epochTotalRewardSummaries =
|
||||||
generateEpochTotalRewardsList({
|
generateEpochTotalRewardsList({
|
||||||
@ -85,10 +65,10 @@ export const EpochTotalRewards = ({ currentEpoch }: EpochTotalRewardsProps) => {
|
|||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
hasPrevPage={page > 1}
|
hasPrevPage={page > 1}
|
||||||
hasNextPage={page < totalPages}
|
hasNextPage={page < totalPages}
|
||||||
onBack={() => refetchData(page - 1)}
|
onBack={() => setPage((x) => x - 1)}
|
||||||
onNext={() => refetchData(page + 1)}
|
onNext={() => setPage((x) => x + 1)}
|
||||||
onFirst={() => refetchData(1)}
|
onFirst={() => setPage(1)}
|
||||||
onLast={() => refetchData(totalPages)}
|
onLast={() => setPage(totalPages)}
|
||||||
>
|
>
|
||||||
{t('Page')} {page}
|
{t('Page')} {page}
|
||||||
</Pagination>
|
</Pagination>
|
||||||
|
@ -149,38 +149,6 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
amount: '0',
|
amount: '0',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
]),
|
||||||
totalAmount: '123',
|
totalAmount: '123',
|
||||||
},
|
},
|
||||||
@ -291,40 +259,8 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
amount: '100',
|
amount: '100',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
amount: '123',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
]),
|
||||||
totalAmount: '223',
|
totalAmount: '100',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
@ -334,66 +270,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'2',
|
'2',
|
||||||
{
|
{
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
assetRewards: new Map([
|
assetRewards: new Map(),
|
||||||
[
|
|
||||||
'1',
|
|
||||||
{
|
|
||||||
assetId: '1',
|
|
||||||
decimals: 18,
|
|
||||||
name: 'Asset 1',
|
|
||||||
rewards: new Map([
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
|
||||||
{
|
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '5',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
|
||||||
totalAmount: '5',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
@ -489,66 +366,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'2',
|
'2',
|
||||||
{
|
{
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
assetRewards: new Map([
|
assetRewards: new Map(),
|
||||||
[
|
|
||||||
'1',
|
|
||||||
{
|
|
||||||
assetId: '1',
|
|
||||||
name: 'Asset 1',
|
|
||||||
decimals: 18,
|
|
||||||
rewards: new Map([
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
|
||||||
{
|
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '33',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
|
||||||
totalAmount: '33',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -578,38 +396,6 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
amount: '15',
|
amount: '15',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
]),
|
||||||
totalAmount: '15',
|
totalAmount: '15',
|
||||||
},
|
},
|
||||||
@ -656,40 +442,8 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
amount: '100',
|
amount: '100',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
|
||||||
amount: '123',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
{
|
|
||||||
rewardType:
|
|
||||||
AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
|
|
||||||
amount: '0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]),
|
]),
|
||||||
totalAmount: '223',
|
totalAmount: '100',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
|
@ -18,22 +18,6 @@ export const RowAccountTypes = {
|
|||||||
columnTitle: 'rewardsColInfraHeader',
|
columnTitle: 'rewardsColInfraHeader',
|
||||||
description: 'rewardsColInfraTooltip',
|
description: 'rewardsColInfraTooltip',
|
||||||
},
|
},
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES]: {
|
|
||||||
columnTitle: 'rewardsColPriceTakingHeader',
|
|
||||||
description: 'rewardsColPriceTakingTooltip',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES]: {
|
|
||||||
columnTitle: 'rewardsColPriceMakingHeader',
|
|
||||||
description: 'rewardsColPriceMakingTooltip',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES]: {
|
|
||||||
columnTitle: 'rewardsColLiquidityProvisionHeader',
|
|
||||||
description: 'rewardsColLiquidityProvisionTooltip',
|
|
||||||
},
|
|
||||||
[AccountType.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS]: {
|
|
||||||
columnTitle: 'rewardsColMarketCreationHeader',
|
|
||||||
description: 'rewardsColMarketCreationTooltip',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ColumnHeaderProps {
|
interface ColumnHeaderProps {
|
||||||
@ -55,7 +39,7 @@ export const rowGridItemStyles = (last = false) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
const gridStyles = classNames(
|
const gridStyles = classNames(
|
||||||
'grid grid-cols-[repeat(8,minmax(100px,auto))] max-w-full overflow-auto',
|
'grid grid-cols-[repeat(4,minmax(100px,auto))] max-w-full overflow-auto',
|
||||||
`border-t border-vega-dark-200`,
|
`border-t border-vega-dark-200`,
|
||||||
'text-sm'
|
'text-sm'
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,6 @@ import { usePreviousEpochQuery } from '../__generated__/PreviousEpoch';
|
|||||||
import { ValidatorTables } from './validator-tables';
|
import { ValidatorTables } from './validator-tables';
|
||||||
import { useRefreshAfterEpoch } from '../../../hooks/use-refresh-after-epoch';
|
import { useRefreshAfterEpoch } from '../../../hooks/use-refresh-after-epoch';
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
import { ENV } from '../../../config';
|
|
||||||
import { getMultisigStatusInfo } from '../../../lib/get-multisig-status-info';
|
import { getMultisigStatusInfo } from '../../../lib/get-multisig-status-info';
|
||||||
import { MultisigIncorrectNotice } from '../../../components/multisig-incorrect-notice';
|
import { MultisigIncorrectNotice } from '../../../components/multisig-incorrect-notice';
|
||||||
|
|
||||||
@ -20,7 +19,6 @@ export const EpochData = () => {
|
|||||||
refetch: nodesRefetch,
|
refetch: nodesRefetch,
|
||||||
} = useNodesQuery();
|
} = useNodesQuery();
|
||||||
|
|
||||||
const { delegationsPagination } = ENV;
|
|
||||||
const {
|
const {
|
||||||
data: userStakingData,
|
data: userStakingData,
|
||||||
error: userStakingError,
|
error: userStakingError,
|
||||||
@ -29,11 +27,9 @@ export const EpochData = () => {
|
|||||||
} = useStakingQuery({
|
} = useStakingQuery({
|
||||||
variables: {
|
variables: {
|
||||||
partyId: pubKey || '',
|
partyId: pubKey || '',
|
||||||
delegationsPagination: delegationsPagination
|
delegationsPagination: {
|
||||||
? {
|
first: 50,
|
||||||
first: Number(delegationsPagination),
|
},
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { data: previousEpochData } = usePreviousEpochQuery({
|
const { data: previousEpochData } = usePreviousEpochQuery({
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { ENV } from '../../../config';
|
|
||||||
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -28,16 +27,13 @@ export const NodeContainer = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
const { delegationsPagination } = ENV;
|
|
||||||
|
|
||||||
const { data, loading, error, refetch } = useStakingQuery({
|
const { data, loading, error, refetch } = useStakingQuery({
|
||||||
variables: {
|
variables: {
|
||||||
partyId: pubKey || '',
|
partyId: pubKey || '',
|
||||||
delegationsPagination: delegationsPagination
|
delegationsPagination: {
|
||||||
? {
|
first: 50,
|
||||||
first: Number(delegationsPagination),
|
},
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
errorPolicy: 'all',
|
errorPolicy: 'all',
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,6 @@ import * as Sentry from '@sentry/react';
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { ENV } from '../../../config';
|
|
||||||
import { usePartyDelegationsLazyQuery } from './__generated__/PartyDelegations';
|
import { usePartyDelegationsLazyQuery } from './__generated__/PartyDelegations';
|
||||||
import { TokenInput } from '../../../components/token-input';
|
import { TokenInput } from '../../../components/token-input';
|
||||||
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
||||||
@ -79,7 +78,6 @@ export const StakingForm = ({
|
|||||||
const [error, setError] = useState<Error | null>(null);
|
const [error, setError] = useState<Error | null>(null);
|
||||||
const [isDialogVisible, setIsDialogVisible] = useState(false);
|
const [isDialogVisible, setIsDialogVisible] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { delegationsPagination } = ENV;
|
|
||||||
const [action, setAction] = React.useState<StakeAction>(
|
const [action, setAction] = React.useState<StakeAction>(
|
||||||
params.action as StakeAction
|
params.action as StakeAction
|
||||||
);
|
);
|
||||||
@ -154,11 +152,9 @@ export const StakingForm = ({
|
|||||||
const [delegationSearch, { data }] = usePartyDelegationsLazyQuery({
|
const [delegationSearch, { data }] = usePartyDelegationsLazyQuery({
|
||||||
variables: {
|
variables: {
|
||||||
partyId: pubKey,
|
partyId: pubKey,
|
||||||
delegationsPagination: delegationsPagination
|
delegationsPagination: {
|
||||||
? {
|
first: 50,
|
||||||
first: Number(delegationsPagination),
|
},
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user