Skip to content

Commit

Permalink
Add more coverage of tx history (#4060)
Browse files Browse the repository at this point in the history
* add more coverage of tx history - still need to move this to to backend in the future

* made tx labels/icons work with new schema meta type

* working tx history with expanded tx types

* added support for polygon bridge

* added more protocol coverage

* added ens domain renewal

* fixed translation key test

* added test for txHistory slice

* preserve native txtypes

* added some logging for debug

* fixed tx derivation bug

* fix most requested changes

* finished requested changes

* updated to production infra

* added requested changes

* fix test
  • Loading branch information
blurpesec authored Aug 17, 2021
1 parent d384159 commit 194a810
Show file tree
Hide file tree
Showing 28 changed files with 664 additions and 214 deletions.
2 changes: 1 addition & 1 deletion jest_config/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export { default as fETHNonWeb3TxConfigJSON } from './ethNonWeb3TxConfig.json';
export { default as fETHWeb3TxConfigJSON } from './ethWeb3TxConfig.json';

export { fDefiReserveRates } from './defiRates';
export { fTxHistoryAPI } from './txHistory';
export { fTxHistoryAPI, fTxHistory, fTxTypeMetas } from './txHistory';

export * from './sendFormFields';

Expand Down
32 changes: 31 additions & 1 deletion jest_config/__fixtures__/txHistory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ITxHistoryApiResponse } from '@services/ApiService/History';
import { ITxHistoryState, ITxMetaTypes } from '@store/txHistory.slice';
import {
ITxData,
ITxGasLimit,
Expand All @@ -13,7 +14,7 @@ import {

export const fTxHistoryAPI: ITxHistoryApiResponse = {
to: '0x7a250d5630b4cf539739df2c5dacb4c659f2488d' as TAddress,
from: '0x5197b5b062288bbf29008c92b08010a92dd677cd' as TAddress,
from: '0xfE5443FaC29fA621cFc33D41D1927fd0f5E0bB7c' as TAddress,
value: '0x1f399b1438a10000' as ITxValue,
blockNumber: '0xa2db5e',
timestamp: 1597606012,
Expand Down Expand Up @@ -41,3 +42,32 @@ export const fTxHistoryAPI: ITxHistoryApiResponse = {
txType: 'UNISWAP_V2_EXCHANGE' as ITxType,
data: '0x7ff36ab500000000000000000000000000000000000000000000010f4b84d285e47e19f600000000000000000000000000000000000000000000000000000000000000800000000000000000000000005197b5b062288bbf29008c92b08010a92dd677cd000000000000000000000000000000000000000000000000000000005f398d270000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000bbbbca6a901c926f240b89eacb641d8aec7aeafd' as ITxData
};

export const fTxTypeMetas: ITxMetaTypes = {
'1INCH_EXCHANGE': {
protocol: '1INCH',
type: 'EXCHANGE'
},
ERC_20_APPROVE: {
protocol: 'ERC_20',
type: 'APPROVE'
},
ERC_20_MINT: {
protocol: 'ERC_20',
type: 'MINT'
},
ERC_20_TRANSFER: {
protocol: 'ERC_20',
type: 'TRANSFER'
},
UNISWAP_V2_EXCHANGE: {
protocol: 'UNISWAP_V2',
type: 'EXCHANGE'
}
};

export const fTxHistory: ITxHistoryState = {
history: [],
txTypeMeta: fTxTypeMetas,
error: ''
};
67 changes: 67 additions & 0 deletions node-scripts/translations/excludedTranslationKeys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[
"1INCH",
"1INCH_V3",
"ERC20",
"ERC_20",
"GNOSIS_SAFE",
"SPARKPOOL",
"MININGPOOLHUB",
"ETHERMINE",
"AAVE",
"COMPOUND",
"UNISWAP_V1",
"UNISWAP_V2",
"UNISWAP_V3",
"PARASWAP",
"KYBER",
"REP",
"ONE_INCH_EXCHANGE",
"DEX_AG",
"IDEX",
"POLYGON",
"0X",
"0X_V3",
"BALANCER",
"ENS",
"METAMASK_V1",
"OPENSEA",
"PARASWAP_V4",
"POOLTOGETHER",
"SUSHISWAP",
"TORNADO_CASH_V1",
"CURVE_V1",
"CURVE_V2",
"MAKER_V2",
"YEARN_V2",
"SYNTHETIX",
"RARIBLE",
"AXIE_INFINITY",
"LIDO",
"PLATFORM_CLAIM",
"PLATFORM_MIGRATED",
"PLATFORM_DOMAIN_REGISTER",
"PLATFORM_DOMAIN_TRANSFER",
"PLATFORM_DOMAIN_RENEW",
"PLATFORM_CANCEL_ORDER",
"PLATFORM_REGISTER",
"PLATFORM_APPROVE",
"PLATFORM_APPROVAL",
"PLATFORM_MULTISIG_APPROVE_TX",
"PLATFORM_DEPOSIT_ETH",
"PLATFORM_DEPOSIT_TOKEN",
"PLATFORM_MINING_PAYOUT",
"PLATFORM_MINT",
"PLATFORM_ROUTER_TO",
"PLATFORM_SWAP",
"PLATFORM_TRANSFER",
"PLATFORM_UNWRAP",
"PLATFORM_WRAP",
"PLATFORM_DEPOSIT",
"PLATFORM_WITHDRAW",
"PLATFORM_EXCHANGE",
"PLATFORM_BORROW",
"PLATFORM_REPAY",
"PLATFORM_MIGRATION",
"PLATFORM_BRIDGE_IN",
"PLATFROM_BRIDGE_OUT"
]
5 changes: 4 additions & 1 deletion node-scripts/translations/translations-extract.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';

import excludedTranslationKeys from './excludedTranslationKeys.json';
import {
findTranslationKeys,
getJsonKeys,
Expand Down Expand Up @@ -50,7 +51,9 @@ describe('Translations extract', () => {
const jsonKeys = getJsonKeys();
jsonKeys.forEach((language) => {
const matchedKeys = findTranslationKeys(PROJECT_FILE_PATTERN, language);
const keysInUse = [...new Set([...extractedKeys, ...matchedKeys])];
const keysInUse = [
...new Set([...extractedKeys, ...matchedKeys, ...excludedTranslationKeys])
];
expect(keysInUse.sort()).toStrictEqual(language.sort());
});
});
Expand Down
45 changes: 45 additions & 0 deletions src/features/Dashboard/components/RecentTransactionList.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { DeepPartial } from '@reduxjs/toolkit';
import { mockStore, simpleRender } from 'test-utils';

import { fAccounts, fTxHistoryAPI, fTxTypeMetas } from '@fixtures';
import { ITxHistoryApiResponse } from '@services/ApiService/History';
import { translateRaw } from '@translations';

import RecentTransactionList from './RecentTransactionList';

/* Test components */
describe('RecentTransactionList', () => {
const renderComponent = () => {
return simpleRender(<RecentTransactionList accountsList={fAccounts} />, {
initialState: mockStore({
storeSlice: {
txHistory: {
history: [fTxHistoryAPI as unknown as DeepPartial<ITxHistoryApiResponse>],
txTypeMeta: fTxTypeMetas
}
}
})
})
};

test('Can render', () => {
const { getByText } = renderComponent();
const selector = translateRaw('RECENT_TRANSACTIONS');
expect(getByText(selector)).toBeInTheDocument();
});

test('Can render transactions', () => {
const { getByText } = renderComponent();
const selector = translateRaw('RECENT_TRANSACTIONS_DATE')
expect(getByText(selector)).toBeInTheDocument();
});

test('Can properly interpret tx complex tx type', () => {
const { getByText } = renderComponent();
const selector = translateRaw('RECENT_TX_LIST_PLATFORM_INTERACTION', {
$platform: translateRaw('UNISWAP_V2'),
$action: translateRaw('PLATFORM_EXCHANGE')
});
expect(getByText(selector)).toBeInTheDocument();
});
});
Loading

0 comments on commit 194a810

Please sign in to comment.