Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve todo error #5339

Merged
merged 15 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const {
GET_SIGNED_MESSAGE,
} = LEDGER_HW_IPC_CHANNELS;

// TODO: remove when server have a queuing system
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
Expand Down
1 change: 0 additions & 1 deletion setup/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ module.exports = {
'src/modules/pos/validator/store/reducers/staking.js',
'src/modules/transaction/components/TransactionResult/illustrationsMap.js',
'src/modules/transaction/components/Regular/Regular.js',
'src/modules/token/fungible/components/BalanceInfo/EmptyBalanceTooltipWrapper.js',
'src/modules/wallet/utils/api/index.js',
'src/modules/transaction/utils/hwManager/index.js',
'src/modules/transaction/utils/transactionDetailsHelper.js',
Expand Down
7 changes: 1 addition & 6 deletions src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"Add message (Optional)": "Add message (Optional)",
"Add network": "Add network",
"Add new": "Add new",
"Add to stakes": "Add to stakes",
"Add to staking queue": "Add to staking queue",
"Add to watched": "Add to watched",
"Add your account": "Add your account",
Expand Down Expand Up @@ -578,8 +577,6 @@
"Send": "Send",
"Send a reclaim transaction": "Send a reclaim transaction",
"Send tokens": "Send tokens",
"Send {{token}}": "Send {{token}}",
"Send {{token}} here": "Send {{token}} here",
"Sender": "Sender",
"Sender account: ": "Sender account: ",
"Sender address": "Sender address",
Expand Down Expand Up @@ -609,7 +606,6 @@
"Stake added to queue": "Stake added to queue",
"Stake amount": "Stake amount",
"Stake amount can't be zero or negative.": "Stake amount can't be zero or negative.",
"Stake for validator": "Stake for validator",
"Stake now": "Stake now",
"Stake validator": "Stake validator",
"Staked": "Staked",
Expand Down Expand Up @@ -687,7 +683,7 @@
"This transaction was initiated from another application for signature request.": "This transaction was initiated from another application for signature request.",
"This validator has been permanently banned": "This validator has been permanently banned",
"This validator is among the first 101 validators by validator weight.": "This validator is among the first 101 validators by validator weight.",
"This validator is among the first 101 validators in validator weight ranking.": "This validator is among the first 101 validators in validator weight ranking.",
"This validator is among the first {{roundLength}} validators in validator weight ranking.": "This validator is among the first {{roundLength}} validators in validator weight ranking.",
"This validator will be punished in upcoming rounds": "This validator will be punished in upcoming rounds",
"To": "To",
"To application": "To application",
Expand Down Expand Up @@ -796,7 +792,6 @@
"You can now download your encrypted secret recovery phrase and use it to add your account on other devices.": "You can now download your encrypted secret recovery phrase and use it to add your account on other devices.",
"You can only stake in multiplies of 10 LSK.": "You can only stake in multiplies of 10 LSK.",
"You can see a list of your applications on the network dropdown.": "You can see a list of your applications on the network dropdown.",
"You cannot stake for this validator": "You cannot stake for this validator",
"You do not have any bookmarks yet.": "You do not have any bookmarks yet.",
"You do not have any tokens yet.": "You do not have any tokens yet.",
"You have cancelled the transaction on your hardware wallet.": "You have cancelled the transaction on your hardware wallet.",
Expand Down
6 changes: 2 additions & 4 deletions src/modules/account/hooks/useDeprecatedAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ const defaultAccount = {
address: '',
publicKey: '',
legacyAddress: '',
// @todo Replace mock balance value once we have the balance in the account store
balance: '10000000000000',
balance: '0',
username: '',
isMigrated: true,
isValidator: false,
isMultisignature: false,
},
// @todo same here.
token: {
balance: '10000000000000',
balance: '0',
tokenID: '00000000',
},
sequence: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable max-lines */
/* eslint-disable complexity */
/* istanbul ignore file */ // @todo Add unit tests by #4824
import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import classNames from 'classnames';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ModalWrapper from '@bookmark/components/BookmarksListModal/BookmarkModalW
import styles from '@bookmark/components/BookmarksListModal/BookmarkListModal.css';

const Bookmarks = ({ bookmarks, token, t, bookmarkRemoved, bookmarkUpdated }) => {
// TODO: Refactor manager component for bookmark list
const history = useHistory();
return (
<ModalWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @todo: this should be re-instated when the issue with lisk-client is fixed
/* istanbul ignore file */
import React from 'react';
import Tooltip from 'src/theme/Tooltip';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
display: flex;
flex-direction: column;

& > div > div {
max-height: 300px;
overflow-y: auto;
}

& .fieldLabel {
@mixin contentNormal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import classNames from 'classnames';
import { withTranslation } from 'react-i18next';
import { MODULE_COMMANDS_NAME_MAP } from 'src/modules/transaction/configuration/moduleCommand';
import { getModuleCommandTitle } from 'src/modules/transaction/utils/moduleCommand';
import Select from 'src/theme/Select';
import { useCommandSchema } from '@network/hooks';
import styles from './filters.css';

const SelectFilter = ({
Expand All @@ -15,12 +15,15 @@ const SelectFilter = ({
name,
updateCustomFilters,
}) => {
// TODO: This logic is static, different blockchain application can have different commands
// We need this logic to be dynamic based on selected chain.
const options = Object.keys(MODULE_COMMANDS_NAME_MAP).map((key) => ({
value: MODULE_COMMANDS_NAME_MAP[key],
label: getModuleCommandTitle()[MODULE_COMMANDS_NAME_MAP[key]],
const { moduleCommandSchemas, isLoading } = useCommandSchema();

if (isLoading) return null;

const options = Object.keys(moduleCommandSchemas).map((key) => ({
value: key,
label: getModuleCommandTitle()[key],
}));

options.unshift({ value: '', label: placeholder });

const onChange = (value) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';
import { mount } from 'enzyme';
import { useCommandSchema } from '@network/hooks';
import SelectFilter from './selectFilter';
import { mockCommandParametersSchemas } from '../../__fixtures__';

jest.mock('@network/hooks/useCommandsSchema');

describe('SelectFilter', () => {
const props = {
Expand All @@ -14,10 +18,30 @@ describe('SelectFilter', () => {
label: 'Type',
};

useCommandSchema.mockReturnValue({
moduleCommandSchemas: mockCommandParametersSchemas.data.commands.reduce(
(result, { moduleCommand, schema }) => ({ ...result, [moduleCommand]: schema }),
{}
),
});

it('should handle input selection', () => {
const wrapper = mount(<SelectFilter {...props} />);
wrapper.find('Select.input').simulate('click');
wrapper.find('span.option').at(0).simulate('click');
expect(props.updateCustomFilters).toBeCalled();
});

it('should not render the component while loading', () => {
useCommandSchema.mockReturnValue({
isLoading: true,
moduleCommandSchemas: mockCommandParametersSchemas.data.commands.reduce(
(result, { moduleCommand, schema }) => ({ ...result, [moduleCommand]: schema }),
{}
),
});

const wrapper = mount(<SelectFilter {...props} />);
expect(wrapper.find('.fieldGroup').exists()).toBeFalsy();
});
});
8 changes: 1 addition & 7 deletions src/modules/legacy/components/Summary/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,4 @@ const Summary = ({ balanceReclaimed, nextStep, wallet, t, fees }) => {
);
};

// istanbul ignore next
const areEqual = (
prevProps,
nextProps // @todo account has multiple balance now
) => prevProps.wallet.summary.balance === nextProps.wallet.summary.balance;

export default React.memo(Summary, areEqual);
export default Summary;
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { PrimaryButton } from 'src/theme/buttons';
import DialogLink from 'src/theme/dialog/link';
import styles from './ValidatorSummary.css';
import { convertCommissionToPercentage } from '../../utils';
import { usePosConstants } from '../../hooks/queries';

const ValidatorSummary = ({ validator, status, weight }) => {
const { address, name, rank, commission, nextAllocatedTime } = validator;
const { t } = useTranslation();
const { data: posConstants } = usePosConstants();
const roundLength = posConstants?.data?.roundLength || '-';

return (
<Box className={styles.wrapper}>
Expand All @@ -36,8 +39,12 @@ const ValidatorSummary = ({ validator, status, weight }) => {
</div>
</BoxHeader>
<BoxContent>
{/* @Todo: the value of roundLength should be dynamically integrated from the usePosConstants query hook which would be addressed in issue #4502 */}
<p>{t('This validator is among the first 101 validators in validator weight ranking.')}</p>
<p>
{t(
'This validator is among the first {{roundLength}} validators in validator weight ranking.',
{ roundLength }
)}
</p>
<div className={styles.summaryDetails}>
<div>
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { screen } from '@testing-library/react';
import { mockValidators } from '../../__fixtures__';
import ValidatorSummary from './ValidatorSummary';
import { convertCommissionToPercentage } from '../../utils';
import { mockPosConstants } from '../../__fixtures__/mockPosConstants';
import { usePosConstants } from '../../hooks/queries';

jest.mock('react-i18next', () => ({
...jest.requireActual('react-i18next'),
Expand All @@ -13,6 +15,8 @@ jest.mock('react-i18next', () => ({
}),
}));

jest.mock('../../hooks/queries/usePosConstants');

describe('ValidatorSummary', () => {
let wrapper;
const props = {
Expand All @@ -22,6 +26,8 @@ describe('ValidatorSummary', () => {
lastGeneratedTime: 23293993234,
};

usePosConstants.mockReturnValue({ data: mockPosConstants });

beforeEach(() => {
jest.clearAllMocks();
wrapper = renderWithRouter(ValidatorSummary, props);
Expand All @@ -30,7 +36,7 @@ describe('ValidatorSummary', () => {
it('should display properly', () => {
expect(
screen.getByText(
'This validator is among the first 101 validators in validator weight ranking.'
'This validator is among the first {{roundLength}} validators in validator weight ranking.'
)
).toBeTruthy();
expect(screen.getByText('Commission :')).toBeTruthy();
Expand All @@ -53,4 +59,20 @@ describe('ValidatorSummary', () => {
);
expect(screen.getByText('Stake')).toHaveAttribute('disabled');
});

it('should return - when roundLength is not available', () => {
usePosConstants.mockReturnValue({ data: {} });

wrapper.rerender(
<MemoryRouter>
<ValidatorSummary {...props} />
</MemoryRouter>
);

expect(
screen.getByText(
'This validator is among the first {{roundLength}} validators in validator weight ranking.'
)
).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { addedToWatchList, removedFromWatchList } from 'src/redux/actions';
import { mockAppsTokens } from '@token/fungible/__fixtures__';
import usePosToken from '@pos/validator/hooks/usePosToken';
import ValidatorRow from './ValidatorRow';
import { usePosConstants } from '../../hooks/queries';
import { mockPosConstants } from '../../__fixtures__/mockPosConstants';

jest.mock('src/redux/actions');
jest.mock('@pos/validator/hooks/usePosToken');
jest.mock('../../hooks/queries/usePosConstants');

let wrapper;
const props = {
Expand Down Expand Up @@ -38,6 +41,7 @@ const props = {
};

usePosToken.mockReturnValue({ token: mockAppsTokens.data[0] });
usePosConstants.mockReturnValue({ data: mockPosConstants });

describe('ValidatorRow', () => {
it('adds validators to watch list when watch icon is clicked', () => {
Expand Down
1 change: 0 additions & 1 deletion src/modules/pos/validator/hooks/queries/usePosConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const usePosConstants = ({ config: customConfig = {}, options } = {}) =>
...customConfig,
};

// @TODO: we need to change the caching time from 5mins to something larger since this is a constant that doesn't frequently change
return useCustomQuery({
keys: [POS_CONSTANTS],
config,
Expand Down
82 changes: 0 additions & 82 deletions src/modules/token/fungible/components/BalanceInfo/ActionBar.js

This file was deleted.

Loading