Skip to content

Commit

Permalink
Merge pull request #5308 from LiskHQ/5305-fix-token-fee-symbol
Browse files Browse the repository at this point in the history
Fix fee token symbol
  • Loading branch information
ManuGowda committed Sep 11, 2023
2 parents b211392 + ece9135 commit 7a85e69
Show file tree
Hide file tree
Showing 38 changed files with 279 additions and 119 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"plugins": ["import", "babel", "jest", "prettier"],
"globals": {
"ipc": true,
"LISK_ENABLE_DEV_TOOL": true,
"PRODUCTION": true
},
"env": {
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/win.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const win = {
});

// Enables DevTools
const { LISK_ENABLE_DEV_TOOL, DEBUG } = process.env();
const { DEBUG } = process.env();

if (LISK_ENABLE_DEV_TOOL || DEBUG) {
win.browser.devtools = true;
Expand Down
1 change: 1 addition & 0 deletions app/src/modules/win.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Electron Browser Window Wrapper', () => {
register: () => {},
};
const url = 'http://localhost:8080/';
window.LISK_ENABLE_DEV_TOOL = false;

const electron = {
screen: { getPrimaryDisplay: () => ({ workAreaSize: { width: 1400, height: 900 } }) },
Expand Down
4 changes: 2 additions & 2 deletions libs/hardwareWallet/ledger/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const LEDGER_HW_IPC_CHANNELS = {
export const LEDGER_CUSTOM_ERRORS = {
openDevicePath: {
return_code: 1,
match: 'cannot open device with path'
}
match: 'cannot open device with path',
},
};
export const CHECK_STATUS_INTERVAL = 4000;
1 change: 0 additions & 1 deletion setup/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const config = {
new ESLintPlugin({
context: '../',
}),
// new webpack.IgnorePlugin({ resourceRegExp: /\.\/locale$/ }),
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(false),
VERSION: JSON.stringify(version),
Expand Down
6 changes: 6 additions & 0 deletions setup/config/webpack.config.electron.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { resolve } = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.config');

Expand Down Expand Up @@ -26,6 +27,11 @@ const config = {
},
],
},
plugins: [
new webpack.DefinePlugin({
LISK_ENABLE_DEV_TOOL: JSON.parse(process.env.ENABLE_DEV_TOOL || true),
}),
],
};

module.exports = merge(baseConfig, config);
2 changes: 0 additions & 2 deletions src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@
"Number of signatures must be equal to the number of members.": "Number of signatures must be equal to the number of members.",
"Number of signatures must be lower than {{num}}.": "Number of signatures must be lower than {{num}}.",
"Number of signatures required to approve any outgoing transactions from this account.": "Number of signatures required to approve any outgoing transactions from this account.",
"Number of transactions / Volume (LSK)": "Number of transactions / Volume (LSK)",
"Old Commission": "Old Commission",
"Old wallet address": "Old wallet address",
"Onboarding": "Onboarding",
Expand Down Expand Up @@ -643,7 +642,6 @@
"Terminated": "Terminated",
"Terms of Use": "Terms of Use",
"The Lisk application is closed": "The Lisk application is closed",
"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",
Expand Down
8 changes: 5 additions & 3 deletions src/modules/account/const/accountMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ export const accountMenu = ({
},
{
component: hasAvailableTokenBalance ? 'multiSignature' : 'noTokenBalance',
data: {
message: i18next.t('Token balance is not enough to register a multisignature account.'),
},
data: !hasAvailableTokenBalance
? {
message: i18next.t('Token balance is not enough to register a multisignature account.'),
}
: {},
icon: 'multiSignatureOutline',
label: 'Register multisignature account',
isHidden: authData?.data?.numberOfSignatures > 0 || hasNetworkError || isLoadingNetwork,
Expand Down
4 changes: 3 additions & 1 deletion src/modules/block/components/blockDetails/blockDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import TokenAmount from '@token/fungible/components/tokenAmount';
import Transactions from '@transaction/components/BlockDetailsTransactions';
import { truncateAddress } from '@wallet/utils/account';
import WalletVisual from '@wallet/components/walletVisual';
import { useCurrentApplication } from '@blockchainApplication/manage/hooks';
import TransactionEvents from '@transaction/components/TransactionEvents';
import { useBlocks } from '../../hooks/queries/useBlocks';
import { useLatestBlock } from '../../hooks/queries/useLatestBlock';
Expand Down Expand Up @@ -104,7 +105,8 @@ const getFields = (data = {}, token, t, currentHeight) => ({

const Rows = ({ data, t, currentHeight }) => {
const { data: tokens } = useTokenBalances();
const token = tokens?.data?.[0] || {};
const [currentApplication] = useCurrentApplication();
const token = tokens?.data?.find(({ chainID }) => chainID === currentApplication.chainID) || {};

const fields = getFields(data, token, t, currentHeight);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ const DialogAddNetwork = () => {
// eslint-disable-next-line max-statements
async function onSubmit(values) {
setErrorText('');
const fullNetworkList = [...Object.values(networks), ...customNetworks];
const fullNetworkList = [
...Object.values(networks).filter(({ isAvailable }) => isAvailable),
...customNetworks,
];
const duplicateNetworkFields = getDuplicateNetworkFields(values, fullNetworkList, defaultName);
if (duplicateNetworkFields) {
const duplicates = Object.keys(duplicateNetworkFields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,32 @@ describe('ChangeCommissionForm', () => {
expect.objectContaining({
fees: [
{
components: [{ type: 'bytesFee', value: 96000n }],
components: [
{
feeToken: { availableBalance: 40000000, chainID: '04000000', symbol: 'LSK' },
type: 'bytesFee',
value: 96000n,
},
],
title: 'Transaction',
value: '0 LSK',
value: '-',
},
{ components: [], isHidden: true, title: 'Message', value: '0 LSK' },
{ components: [], isHidden: true, title: 'Message', value: '-' },
],
formProps: {
composedFees: [
{
components: [{ type: 'bytesFee', value: 96000n }],
components: [
{
feeToken: { availableBalance: 40000000, chainID: '04000000', symbol: 'LSK' },
type: 'bytesFee',
value: 96000n,
},
],
title: 'Transaction',
value: '0 LSK',
value: '-',
},
{ components: [], isHidden: true, title: 'Message', value: '0 LSK' },
{ components: [], isHidden: true, title: 'Message', value: '-' },
],
fields: {
newCommission: '30.00',
Expand Down
14 changes: 3 additions & 11 deletions src/modules/pos/validator/components/StakingQueue/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
/* istanbul ignore file */
import React, { useEffect, useMemo, useState, useCallback } from 'react';

import React, { useEffect, useState, useCallback } from 'react';
import TxSignatureCollector from '@transaction/components/TxSignatureCollector';
import { useTokenBalances } from 'src/modules/token/fungible/hooks/queries';
import { removeSearchParamsFromUrl } from 'src/utils/searchParams';
import MultiStep from 'src/modules/common/components/OldMultiStep';
import Dialog from 'src/theme/dialog/dialog';
import StakeForm from '../StakeForm';
import StakeSummary from '../StakeSummary';
import StakeStatus from '../StakeStatus';
import styles from './styles.css';
import { usePosConstants } from '../../hooks/queries';
import usePosToken from '../../hooks/usePosToken';

const StakingQueue = ({ history, processLaunchProtocol }) => {
const [isStepTxSignatureCollector, setIsStepTxSignatureCollector] = useState(false);
const onMultiStepChange = useCallback(({ step: { current } }) => {
setIsStepTxSignatureCollector([2, 3].includes(current));
}, []);

const { data: posConstants, isLoading: isGettingPosConstants } = usePosConstants();

const { data: tokens } = useTokenBalances({
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const token = useMemo(() => tokens?.data?.[0] || {}, [tokens]);
const { token } = usePosToken();

const closeModal = () => {
removeSearchParamsFromUrl(history, ['modal'], true);
Expand Down
14 changes: 4 additions & 10 deletions src/modules/pos/validator/components/UnlockBalanceForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { MODULE_COMMANDS_NAME_MAP } from '@transaction/configuration/moduleCommand';
import { useTokenBalances } from '@token/fungible/hooks/queries';
import BoxContent from 'src/theme/box/content';
import BoxHeader from 'src/theme/box/header';
import TxComposer from '@transaction/components/TxComposer';
import getUnlockButtonTitle from '../../utils/getUnlockButtonTitle';
import useUnlockableCalculator from '../../hooks/useUnlockableCalculator';
import BalanceTable from './BalanceTable';
import styles from './unlockBalance.css';
import { usePosConstants } from '../../hooks/queries';
import usePosToken from '../../hooks/usePosToken';

const UnlockBalanceForm = ({ nextStep }) => {
const { t } = useTranslation();
const { lockedPendingUnlocks, sentStakesAmount, unlockedAmount } = useUnlockableCalculator();
const { data: posConstants, isLoading: isGettingPosConstants } = usePosConstants();
const { data: tokens } = useTokenBalances({
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const posToken = tokens?.data?.[0] || {};
const { token } = usePosToken();

const onConfirm = async (formProps, transactionJSON, selectedPriority, fees) => {
nextStep({
Expand All @@ -34,7 +28,7 @@ const UnlockBalanceForm = ({ nextStep }) => {
const unlockBalanceFormProps = {
moduleCommand: MODULE_COMMANDS_NAME_MAP.unlock,
fields: {
token: posToken,
token,
},
isFormValid: unlockedAmount > 0,
enableMinimumBalanceFeedback: true,
Expand Down Expand Up @@ -62,7 +56,7 @@ const UnlockBalanceForm = ({ nextStep }) => {
sentStakesAmount={sentStakesAmount}
unlockedAmount={unlockedAmount}
lockedPendingUnlocks={lockedPendingUnlocks}
token={posToken}
token={token}
/>
</BoxContent>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,24 @@ describe('Unlock LSK modal', () => {
composedFees: [
{
title: 'Transaction',
value: '0 LSK',
components: [{ type: 'bytesFee', value: 96000n }],
value: '-',
components: [
{
type: 'bytesFee',
value: 96000n,
feeToken: {
availableBalance: '1000000000',
chainName: 'Lisk',
lockedBalances: [{ amount: '10000000000', moduleID: '5' }],
symbol: 'LSK',
tokenID: '0000000100000000',
},
},
],
},
{
title: 'Message',
value: '0 LSK',
value: '-',
isHidden: true,
components: [],
},
Expand All @@ -245,12 +257,24 @@ describe('Unlock LSK modal', () => {
fees: [
{
title: 'Transaction',
value: '0 LSK',
components: [{ type: 'bytesFee', value: 96000n }],
value: '-',
components: [
{
type: 'bytesFee',
value: 96000n,
feeToken: {
availableBalance: '1000000000',
chainName: 'Lisk',
lockedBalances: [{ amount: '10000000000', moduleID: '5' }],
symbol: 'LSK',
tokenID: '0000000100000000',
},
},
],
},
{
title: 'Message',
value: '0 LSK',
value: '-',
isHidden: true,
components: [],
},
Expand All @@ -266,43 +290,71 @@ describe('Unlock LSK modal', () => {

expect(props.nextStep).toBeCalledWith(
expect.objectContaining({
transactionJSON,
fees: [
{
components: [
{
feeToken: {
availableBalance: '1000000000',
chainName: 'Lisk',
lockedBalances: [{ amount: '10000000000', moduleID: '5' }],
symbol: 'LSK',
tokenID: '0000000100000000',
},
type: 'bytesFee',
value: 96000n,
},
],
title: 'Transaction',
value: '-',
},
{ components: [], isHidden: true, title: 'Message', value: '-' },
],
formProps: {
composedFees: [
{
components: [
{
feeToken: {
availableBalance: '1000000000',
chainName: 'Lisk',
lockedBalances: [{ amount: '10000000000', moduleID: '5' }],
symbol: 'LSK',
tokenID: '0000000100000000',
},
type: 'bytesFee',
value: 96000n,
},
],
title: 'Transaction',
value: '0 LSK',
components: [{ type: 'bytesFee', value: 96000n }],
},
{
title: 'Message',
value: '0 LSK',
isHidden: true,
components: [],
value: '-',
},
{ components: [], isHidden: true, title: 'Message', value: '-' },
],
isFormValid: true,
enableMinimumBalanceFeedback: true,
moduleCommand: 'pos:unlock',
fields: {
token: mockTokensBalance.data[0],
token: {
availableBalance: '1000000000',
chainName: 'Lisk',
lockedBalances: [{ amount: '10000000000', moduleID: '5' }],
symbol: 'LSK',
tokenID: '0000000100000000',
},
},
isFormValid: true,
moduleCommand: 'pos:unlock',
unlockedAmount: 455000000000,
},
fees: [
{
title: 'Transaction',
value: '0 LSK',
components: [{ type: 'bytesFee', value: 96000n }],
},
{
title: 'Message',
value: '0 LSK',
isHidden: true,
components: [],
},
],
selectedPriority: { selectedIndex: 1 },
transactionJSON: {
command: 'unlock',
fee: '5104000',
module: 'pos',
nonce: '0',
params: {},
senderPublicKey: 'cf434a889d6c7a064e8de61bb01759a76f585e5ff45a78ba8126ca332601f535',
signatures: [],
},
})
);
});
Expand Down
Loading

0 comments on commit 7a85e69

Please sign in to comment.