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

Feature/dpos update #4837

Merged
merged 36 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1abd63a
:memo: Update grammer and sentences (#4683)
ManuGowda Dec 29, 2022
6014148
Integrate useTransaction fee hook on all transactions (#4761)
eniolam1000752 Feb 1, 2023
eb77140
Remove auto sign out feature and codebase (#4779)
ManuGowda Feb 2, 2023
3fdbb9b
fix: resolved issue with validation on send form
eniolam1000752 Feb 2, 2023
b0c8dc8
Merge branch 'feature/dpos-update' into 4603-fix-token-transfer-valid…
eniolam1000752 Feb 2, 2023
8428362
fix: revereted changes on useTransferableTokens
eniolam1000752 Feb 2, 2023
5b19f74
merged changes from remote
eniolam1000752 Feb 2, 2023
e1572e2
fix: resolved failing unit test
eniolam1000752 Feb 2, 2023
1e58bfa
fix: resolved all failing unit tests
eniolam1000752 Feb 2, 2023
63c8ac7
fix: resolved failing test on claimrewards form
eniolam1000752 Feb 2, 2023
16e7d2e
Merge pull request #4786 from LiskHQ/4603-fix-token-transfer-validation
eniolam1000752 Feb 3, 2023
c628790
feature: integrated escrow and message fee
eniolam1000752 Feb 4, 2023
e9df234
fix: rresolve issue with messgae fee
eniolam1000752 Feb 4, 2023
0e004a5
fix: reverted useTransferableToken
eniolam1000752 Feb 4, 2023
d6c6c93
Merge branch 'feature/dpos-update' into 4521-integrate-ccm-fee-and-es…
eniolam1000752 Feb 4, 2023
55cee76
Merge pull request #4788 from LiskHQ/4521-integrate-ccm-fee-and-escrow
eniolam1000752 Feb 6, 2023
8705d26
:recycle: Resolve merge conflict
Feb 9, 2023
fde9562
:fire: Remove unwanted files
Feb 9, 2023
e15672d
Transaction page should not crash (#4798)
ManuGowda Feb 9, 2023
bd98437
feat: convert commission to percentage
soroushm Jan 12, 2023
7701492
feat: add size support for TxSummarizer
soroushm Jan 18, 2023
7b1b576
chore: min
soroushm Feb 9, 2023
49a0930
test: add coverage for getValidatorCommission
soroushm Feb 9, 2023
6cebde8
test: add coverage for ChangeCommissionDialog
soroushm Feb 9, 2023
48b7dc7
test: add coverage for useCurrentCommissionPercentage
soroushm Feb 9, 2023
de352b4
test: add coverage for ChangeCommissionInfo and add missing convert f…
soroushm Feb 9, 2023
74a946d
test: add coverage for ChangeCommissionStatus
soroushm Feb 9, 2023
98e06db
test: add coverage for ChangeCommissionSummary
soroushm Feb 9, 2023
c738328
chore: add missing translation
soroushm Feb 9, 2023
8f477e6
chore: resolve pr discussion
soroushm Feb 10, 2023
b03188d
chore: show edit commission only for my profile
soroushm Feb 10, 2023
cc711b9
chore: make it pretty
soroushm Feb 10, 2023
1de3d3a
test: add unit test for ChangeCommissionForm
soroushm Feb 10, 2023
44e133c
Merge pull request #4714 from LiskHQ/4642-edit-commission
ikem-legend Feb 10, 2023
716161e
:recycle: Update fonts path (#4807)
ManuGowda Feb 14, 2023
77a7299
:recycle: Resolve merge conflict
Mar 1, 2023
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
4 changes: 2 additions & 2 deletions Jenkinsfile.builds
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pipeline {
nvm(getNodejsVersion()) {
sh '''
npm ci
cp -R /Users/jenkins/fonts/basierCircle src/assets/fonts
cp -R /Users/jenkins/fonts/gilroy src/assets/fonts
cp -R /Users/jenkins/fonts/basierCircle setup/react/assets/fonts
cp -R /Users/jenkins/fonts/gilroy setup/react/assets/fonts
npm run build
npm run install:electron:dependencies
npm run dist:mac -- --publish never
Expand Down
123 changes: 28 additions & 95 deletions app/package-lock.json

Large diffs are not rendered by default.

43 changes: 11 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"@json-rpc-tools/utils": "1.7.6",
"@ledgerhq/hw-transport": "6.3.0",
"@ledgerhq/hw-transport-node-hid": "6.6.0",
"@liskhq/lisk-client": "6.0.0-alpha.11",
"@liskhq/lisk-client": "6.0.0-alpha.13",
"@tanstack/react-query": "4.0.10",
"@tanstack/react-query-devtools": "4.2.1",
"@walletconnect/sign-client": "2.0.0-rc.4",
Expand Down Expand Up @@ -160,7 +160,6 @@
"react": "16.14.0",
"react-chartjs-2": "=2.8.0",
"react-copy-to-clipboard": "5.0.3",
"react-countdown": "2.2.1",
"react-dom": "16.14.0",
"react-fast-compare": "2.0.4",
"react-highlight-words": "0.17.0",
Expand Down
1 change: 1 addition & 0 deletions src/const/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export const POS_REWARDS_CLAIMABLE = 'GET_POS_REWARDS_CLAIMABLE';
export const REWARD_DEFAULT = 'GET_REWARD_DEFAULT';
export const REWARD_INFLATION = 'GET_REWARD_INFLATION';
export const REWARD_CONSTANTS = 'GET_REWARD_CONSTANTS';
export const INVOKE = 'POST_PROXY_INVOKE';
export const INITIALIZED_ACCOUNTS = 'GET_INITIALIZED_ACCOUNTS';
13 changes: 8 additions & 5 deletions src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"Caution! You are about to stake for the punished validator, this will result in your LSK tokens being locked for a period of {{daysLeft}} days. In addition, please note that your stake will not be counted until the {{daysLeft}} day period has expired. ": "Caution! You are about to stake for the punished validator, this will result in your LSK tokens being locked for a period of {{daysLeft}} days. In addition, please note that your stake will not be counted until the {{daysLeft}} day period has expired. ",
"Chain ID": "Chain ID",
"Chain ID:": "Chain ID:",
"Change Commission succeeded": "Change Commission succeeded",
"Changed stakes": "Changed stakes",
"Check for Updates...": "Check for Updates...",
"Choose a hardware wallet to perform your transactions on add to your Lisk Desktop": "Choose a hardware wallet to perform your transactions on add to your Lisk Desktop",
Expand All @@ -124,6 +125,7 @@
"Commission": "Commission",
"Commission (%)": "Commission (%)",
"Commission :": "Commission :",
"Commission range is invalid": "Commission range is invalid",
"Community is key. Stake for validators, or register as one yourself. Feel like a feature is missing? Request it directly from the Lisk.": "Community is key. Stake for validators, or register as one yourself. Feel like a feature is missing? Request it directly from the Lisk.",
"Configure account": "Configure account",
"Confirm": "Confirm",
Expand Down Expand Up @@ -196,6 +198,7 @@
"Edit Stake": "Edit Stake",
"Edit account name": "Edit account name",
"Edit bookmark": "Edit bookmark",
"Edit commission": "Edit commission",
"Edit stake": "Edit stake",
"Effortlessly send and receive tokens": "Effortlessly send and receive tokens",
"Either change the optional member to mandatory or define more optional members.": "Either change the optional member to mandatory or define more optional members.",
Expand Down Expand Up @@ -359,6 +362,7 @@
"Network statistics": "Network statistics",
"Network switcher": "Network switcher",
"New": "New",
"New Commission": "New Commission",
"New blocks": "New blocks",
"New bookmark": "New bookmark",
"New transactions": "New transactions",
Expand Down Expand Up @@ -389,6 +393,7 @@
"Number of transactions / Volume (LSK)": "Number of transactions / Volume (LSK)",
"Official guidelines": "Official guidelines",
"Ok": "Ok",
"Old Commission": "Old Commission",
"Old wallet address": "Old wallet address",
"Only members of the group can sign the transaction.": "Only members of the group can sign the transaction.",
"Opt-in to sharing anonymous data in order to improve Lisk.": "Opt-in to sharing anonymous data in order to improve Lisk.",
Expand Down Expand Up @@ -499,7 +504,6 @@
"Required": "Required",
"Required signatures": "Required signatures",
"Requirements": "Requirements",
"Reset time": "Reset time",
"Restart app": "Restart app",
"Restore from JSON file": "Restore from JSON file",
"Restore from backup": "Restore from backup",
Expand Down Expand Up @@ -547,7 +551,6 @@
"Send {{token}}": "Send {{token}}",
"Send {{token}} here": "Send {{token}} here",
"Sender": "Sender",
"Session timed out": "Session timed out",
"Set up your account password": "Set up your account password",
"Settings": "Settings",
"Settings saved!": "Settings saved!",
Expand Down Expand Up @@ -602,6 +605,7 @@
"Terms of Use": "Terms of Use",
"The aggregated LSK volume transferred over the selected time period.": "The aggregated LSK volume transferred over the selected time period.",
"The chain ID uniquely identifies a chain in the Lisk ecosystem": "The chain ID uniquely identifies a chain in the Lisk ecosystem",
"The commission set will be your reward while the rest will be shared with the stakers.": "The commission set will be your reward while the rest will be shared with the stakers.",
"The default application can not be removed": "The default application can not be removed",
"The list shown only contains peers connected to the current Lisk Service node.": "The list shown only contains peers connected to the current Lisk Service node.",
"The message can't contain whitespace at the beginning or end.": "The message can't contain whitespace at the beginning or end.",
Expand Down Expand Up @@ -713,13 +717,13 @@
"View all tokens": "View all tokens",
"View multisignature account details": "View multisignature account details",
"View remaining": "View remaining",
"View your validator profile.": "View your validator profile.",
"Volume": "Volume",
"Wallet": "Wallet",
"Wallet address:": "Wallet address:",
"Wallet balance": "Wallet balance",
"Wallet connections": "Wallet connections",
"Wallet details": "Wallet details",
"Warning: Session Timeout": "Warning: Session Timeout",
"Watched": "Watched",
"We kindly ask you to transfer your balance to the new account.": "We kindly ask you to transfer your balance to the new account.",
"Welcome to": "Welcome to",
Expand Down Expand Up @@ -751,15 +755,14 @@
"You will be notified when your transaction is confirmed.": "You will be notified when your transaction is confirmed.",
"Your LSK tokens could not be reclaimed, you can try again or report to us via email": "Your LSK tokens could not be reclaimed, you can try again or report to us via email",
"Your account just received {{amount}} {{token}} {{message}}": "Your account just received {{amount}} {{token}} {{message}}",
"Your balance will be transfered in a few seconds.": "Your balance will be transfered in a few seconds.",
"Your multisignatures groups": "Your multisignatures groups",
"Your name": "Your name",
"Your session will be timed out in {{time}} if no network activity occurs.": "Your session will be timed out in {{time}} if no network activity occurs.",
"Your signature was successful": "Your signature was successful",
"Your signature will replace one optional signature.": "Your signature will replace one optional signature.",
"Your stake has been added to your staking queue": "Your stake has been added to your staking queue",
"Your tokens and passphrase are safe.": "Your tokens and passphrase are safe.",
"Your tokens associated with your secret recovery phrase are available to be reclaimed.": "Your tokens associated with your secret recovery phrase are available to be reclaimed.",
"Your tokens will be deposited to your account.": "Your tokens will be deposited to your account.",
"Your transaction has been submitted and will appear in sender account's wallet after confirmation.": "Your transaction has been submitted and will appear in sender account's wallet after confirmation.",
"Your transaction is signed successfully.": "Your transaction is signed successfully.",
"Your transaction is submitted to network, you can now track the status of this transaction in your wallet.": "Your transaction is submitted to network, you can now track the status of this transaction in your wallet.",
Expand Down
2 changes: 2 additions & 0 deletions src/modules/auth/hooks/queries/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './useAuth';
export * from './useGetInitializationFees';
export * from './useMessageFee';
30 changes: 30 additions & 0 deletions src/modules/auth/hooks/queries/useGetInitializationFees.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useInvokeQuery } from '@common/hooks';
import { useTokensBalance } from 'src/modules/token/fungible/hooks/queries';
import { useAuth } from './useAuth';

export const useGetInitializationFees = ({ options = {}, address } = {}) => {
const config = {
data: {
endpoint: 'token_getInitializationFees',
params: {},
},
};

const queryConfig = {
options: { enabled: !!address },
config: { params: { address } },
};

const { data: auth, isLoading: isAuthLoading } = useAuth(queryConfig);
const { data: token, isLoading: isTokenLoading } = useTokensBalance(queryConfig);

const isAccountInitialized = auth?.data?.nonce !== '0' && +token?.data?.[0]?.availableBalance > 0;
const shouldReturnInitalizationFee = !isAccountInitialized && !isAuthLoading && !isTokenLoading;

const result = useInvokeQuery({
config,
options: { ...options, enabled: shouldReturnInitalizationFee },
});

return shouldReturnInitalizationFee ? result : { data: null };
};
82 changes: 82 additions & 0 deletions src/modules/auth/hooks/queries/useGetInitializationFees.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { useAuth } from '@auth/hooks/queries';
import { mockAuth } from '@auth/__fixtures__';
import { renderHook } from '@testing-library/react-hooks';
import { useTokensBalance } from '@token/fungible/hooks/queries';
import { queryWrapper as wrapper } from 'src/utils/test/queryWrapper';
import { mockTokensBalance } from '@token/fungible/__fixtures__/mockTokens';
import { useGetInitializationFees } from './useGetInitializationFees';

jest.useRealTimers();

jest.mock('@auth/hooks/queries/useAuth');
jest.mock('@token/fungible/hooks/queries');

beforeEach(() => jest.clearAllMocks());

describe('useGetInitializationFees hook', () => {
it('should not call the useInvoke query if token is still loading', () => {
useTokensBalance.mockReturnValue({ data: mockTokensBalance, isLoading: true });
useAuth.mockReturnValue({ data: mockAuth, isLoading: false });
const { result } = renderHook(
() => useGetInitializationFees({ address: 'lsktzb4j7e3knk4mkxckdr3y69gtu2nwmsb3hjbkg' }),
{ wrapper }
);

expect(result.current.data).toBe(null);
});

it('does not call the useInoke query if auth is still loading', () => {
useTokensBalance.mockReturnValue({ data: mockTokensBalance, isLoading: false });
useAuth.mockReturnValue({ data: mockAuth, isLoading: true });
const { result } = renderHook(
() => useGetInitializationFees({ address: 'lsktzb4j7e3knk4mkxckdr3y69gtu2nwmsb3hjbkg' }),
{ wrapper }
);

expect(result.current.data).toBe(null);
});

it('does not call the useInoke query if both auth and token is still loading', () => {
useTokensBalance.mockReturnValue({ data: mockTokensBalance, isLoading: true });
useAuth.mockReturnValue({ data: mockAuth, isLoading: true });
const { result } = renderHook(
() => useGetInitializationFees({ address: 'lsktzb4j7e3knk4mkxckdr3y69gtu2nwmsb3hjbkg' }),
{ wrapper }
);

expect(result.current.data).toBe(null);
});

it('does not call the useInoke query if account is not initialized', async () => {
useTokensBalance.mockReturnValue({ data: mockTokensBalance, isLoading: false });
useAuth.mockReturnValue({
data: mockAuth,
isLoading: false,
});
const { result, waitFor } = renderHook(
() => useGetInitializationFees({ address: 'lsktzb4j7e3knk4mkxckdr3y69gtu2nwmsb3hjbkg' }),
{ wrapper }
);

await waitFor(() => !result.current.isLoading);

expect(result.current.data).toEqual({
data: { escrowAccount: '5000000', userAccount: '5000000' },
meta: { endpoint: 'token_getInitializationFees', params: {} },
});
});

it('does not call the useInoke query if account is not initialized', () => {
useTokensBalance.mockReturnValue({ data: mockTokensBalance, isLoading: false });
useAuth.mockReturnValue({
data: { ...mockAuth, data: { ...mockAuth.data, nonce: '2' } },
isLoading: false,
});
const { result } = renderHook(
() => useGetInitializationFees({ address: 'lsktzb4j7e3knk4mkxckdr3y69gtu2nwmsb3hjbkg' }),
{ wrapper }
);

expect(result.current.data).toBe(null);
});
});
10 changes: 10 additions & 0 deletions src/modules/auth/hooks/queries/useMessageFee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @Todo: should be re-instated and refactored when the command to get ccm fee has been implemented
export const useMessageFee = (/* { options = {}, isEnabled } = {} */) => {
// const result = useInvokeQuery({
// config,
// options: { ...options, enabled: isEnabled },
// });
const messageFee = 50000000;

return { data: messageFee };
};
10 changes: 10 additions & 0 deletions src/modules/common/__fixtures__/mockInvoke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const mockInvoke = {
data: {
userAccount: '5000000',
escrowAccount: '5000000',
},
meta: {
endpoint: 'token_getInitializationFees',
params: {},
},
};
2 changes: 1 addition & 1 deletion src/modules/common/components/amountField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const MaxAmountWarning = ({ resetInput, message, ignoreClicks }) => {
// eslint-disable-next-line complexity
const AmountField = ({
amount,
maxAmount,
maxAmount = {},
onChange,
className,
label,
Expand Down
Loading