Skip to content

Commit

Permalink
Merge pull request #5597 from LiskHQ/5596-add-final-balance
Browse files Browse the repository at this point in the history
Add final mainnet balance
  • Loading branch information
shuse2 authored Aug 12, 2024
2 parents e49c4f3 + 094b950 commit 24cef21
Show file tree
Hide file tree
Showing 25 changed files with 375 additions and 189 deletions.
6 changes: 6 additions & 0 deletions setup/react/app/ApplicationBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
/* eslint-disable max-statements */
import React, { createContext } from 'react';
import { useCurrentAccount } from 'src/modules/account/hooks';
import { useCurrentApplication } from 'src/modules/blockchainApplication/manage/hooks';
import { useReduxStateModifier } from 'src/utils/useReduxStateModifier';
import { useLedgerDeviceListener } from '@libs/hardwareWallet/ledger/ledgerDeviceListener/useLedgerDeviceListener';
import { useRewardsClaimable } from 'src/modules/pos/reward/hooks/queries';
import { liskMainnetApplication } from 'src/modules/blockchainApplication/manage/const/liskApplications';

export const ApplicationBootstrapContext = createContext({
hasNetworkError: false,
Expand All @@ -17,6 +19,10 @@ export const ApplicationBootstrapContext = createContext({
const ApplicationBootstrap = ({ children }) => {
const [currentAccount] = useCurrentAccount();
const accountAddress = currentAccount?.metadata?.address;
const [currentApplication, setCurrentApplication] = useCurrentApplication();
if (!Object.keys(currentApplication).length) {
setCurrentApplication(liskMainnetApplication['00000000']);
}

useLedgerDeviceListener();
useReduxStateModifier();
Expand Down
2 changes: 2 additions & 0 deletions src/const/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const TOKENS_BALANCE = 'GET_TOKENS_BALANCE';
export const TOKENS_SUPPORTED = 'GET_TOKENS_SUPPORTED';
export const TOKEN_BALANCES_TOP = 'GET_TOKEN_BALANCES_TOP';
export const TOKENS_ACCOUNT_EXISTS = 'GET_TOKENS_ACCOUNT_EXISTS';
export const LISK_LEGACY_ACCOUNT = 'GET_LISK_LEGACY_ACCOUNT';
export const LISK_LEGACY_HISTORY = 'GET_LISK_LEGACY_HISTORY';
export const PEERS = 'GET_PEERS';
export const VALIDATORS = 'GET_VALIDATORS';
export const STAKES_SENT = 'GET_STAKES_SENT';
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
"Done": "Done",
"Don’t have a Lisk account yet?": "Don’t have a Lisk account yet?",
"Download": "Download",
"Download account history": "Download account history",
"Download completed": "Download completed",
"Duplicate public keys detected.": "Duplicate public keys detected.",
"Edit": "Edit",
Expand Down Expand Up @@ -788,6 +789,7 @@
"View profile": "View profile",
"View remaining": "View remaining",
"Volume": "Volume",
"Wallet": "Wallet",
"Wallet address:": "Wallet address:",
"Wallet balance": "Wallet balance",
"Wallet connections": "Wallet connections",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import React from 'react';
import { useSelector } from 'react-redux';
import { useCurrentAccount } from '@account/hooks';
import Overview from '@wallet/components/overview/overviewManager';
import Box from '@theme/box';
import BoxHeader from '@theme/box/header';
import BoxTabs from '@theme/tabs';
import BoxContent from '@theme/box/content';
import Transactions from '@transaction/components/Explorer';
import TransactionEvents from '@transaction/components/TransactionEvents';
import { selectActiveToken, selectSettings, selectTransactions } from 'src/redux/selectors';
import SwippableInfoBanner from '@common/components/infoBanner/swippableInfoBanner';
import banners from './banners';
import styles from './AccountOverview.css';

// eslint-disable-next-line max-statements
export default function AccountOverview({ address: searchAddress }) {
const { t } = useTranslation();
export default function AccountOverview() {
const activeToken = useSelector(selectActiveToken);
const { discreetMode } = useSelector(selectSettings);
const { confirmed } = useSelector(selectTransactions);
const [activeTab, setActiveTab] = useState('transactions');
const [
{
metadata: { address: currentAddress },
},
] = useCurrentAccount();

const tabs = {
tabs: [
{
value: 'transactions',
name: t('Transactions'),
className: 'transactions',
},
{
value: 'events',
name: t('Events'),
className: 'events',
},
],
active: activeTab,
onClick: ({ value }) => setActiveTab(value),
};
const accountAddress = searchAddress ?? currentAddress;

return (
<section>
Expand All @@ -54,18 +20,6 @@ export default function AccountOverview({ address: searchAddress }) {
discreetMode={discreetMode}
transactions={confirmed}
/>
<Box>
<BoxHeader>
<BoxTabs {...tabs} />
</BoxHeader>
<BoxContent className={styles.content}>
{activeTab === 'transactions' ? (
<Transactions address={accountAddress} />
) : (
<TransactionEvents isWallet hasFilter address={accountAddress} />
)}
</BoxContent>
</Box>
</section>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { SIGNING_METHODS } from '@libs/wcm/constants/permissions';
import { EVENTS } from '@libs/wcm/constants/lifeCycle';
import { useAppsMetaTokens } from '@token/fungible/hooks/queries/useAppsMetaTokens';
import { toTransactionJSON } from '@transaction/utils/encoding';
import { useBlockchainApplicationMeta } from '@blockchainApplication/manage/hooks/queries/useBlockchainApplicationMeta';
import { convertFromBaseDenom } from '@token/fungible/utils/helpers';
import { joinModuleAndCommand } from '@transaction/utils/moduleCommand';
import { signMessage, signClaimMessage } from '@message/store/action';
Expand Down Expand Up @@ -54,7 +53,6 @@ const RequestSummary = ({ nextStep, history, message, portalMessage }) => {
const [errorMessage, setErrorMessage] = useState('');
const { sessionRequest, respond } = useSession({ isEnabled: !message });
const reduxDispatch = useDispatch();
const metaData = useBlockchainApplicationMeta();
useDeprecatedAccount(senderAccount);
useSchemas();

Expand Down Expand Up @@ -309,11 +307,7 @@ const RequestSummary = ({ nextStep, history, message, portalMessage }) => {
className={styles.button}
onClick={!encryptedSenderAccount ? navigateToAddAccountFlow : approveHandler}
data-testid="approve-button"
disabled={
!metaData.data ||
errorMessage ||
(!isSenderCurrentAccount && !!encryptedSenderAccount)
}
disabled={errorMessage || (!isSenderCurrentAccount && !!encryptedSenderAccount)}
>
{!encryptedSenderAccount ? t('Add account') : t('Continue')}
</PrimaryButton>
Expand Down
103 changes: 103 additions & 0 deletions src/modules/blockchainApplication/manage/const/liskApplications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
export const liskMainnetApplication = {
'00000000': {
chainName: 'lisk_mainchain',
displayName: 'Lisk',
chainID: '00000000',
title: 'Lisk - Mainnet',
description: 'Metadata configuration for the Lisk blockchain (mainchain) in mainnet',
networkType: 'mainnet',
isDefault: true,
status: 'activated',
genesisURL: 'https://downloads.lisk.com/lisk/mainnet/genesis_block.json.tar.gz',
projectPage: 'https://lisk.com',
serviceURLs: [
{
http: 'https://service.lisk.com',
ws: 'wss://service.lisk.com',
apiCertificatePublicKey:
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwAOGlgzeePs8O7FjSU9a\nUKQg4EYSJNgQqkwD/ITAJ6TzcXRCUK+N230NaFcQ8EFJw/8Al0r8mpjpOOEpPZDq\n+WljcCRkVHXZCJMvgDNcstzdrt1fKzsCrER2jB3hDUXt04xzzlk8ArJG0JeD/CmW\nAsQqL/S6v/GRVTuViHqzWm2eF2XrduUK8wIbQ1y+7HoVdgZDf5MpuvEXluVX4IeJ\nMyzbn9djdrDkHkcbml8dOHyLE6GOS5jKtXj+bKhyTVlSZFbexxKYiBqCpR6kMUnM\nVrURmWGT+jb7UhGkJiP7EpFB7MjAB+yXMiygd6lz67qjG6wFky1wB9NYGJ/50rrV\nDQIDAQAB\n-----END PUBLIC KEY-----',
},
],
logo: {
png: 'https://raw.githubusercontent.com/LiskHQ/app-registry/main/mainnet/Lisk/images/application/lisk.png',
svg: 'https://raw.githubusercontent.com/LiskHQ/app-registry/main/mainnet/Lisk/images/application/lisk.svg',
},
explorers: [
{
url: 'https://liskscan.com',
txnPage: 'https://liskscan.com/transactions',
},
{
url: 'https://lisk.observer',
txnPage: 'https://lisk.observer/transactions',
},
],
appNodes: [
{
url: 'https://mainnet.lisk.com',
apiCertificatePublicKey:
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqiQIDBSSlqKeWo0st2Hy\nJRbDzqYgcZfQvOpttr4kMbDjAYnz6XvZe3kOHcnMM2ePWrAS66SHTqdVbEEiu9Kf\njEQQkmk/Xv7XSMQ5kwidv+ANNDjTaC9GRnUHQ3pH77ZZY5msq0kEvmDvyMljU9kD\neqpugQn7jQVTG7te7PyXnZxvzMq8tgDILEwRnkF2hUF6jCH5X763aOT7X6yKUKY5\nZSUqmStKGPt1i34E5Pvb2AumsApkyqXfST/N/h8NV3UXRTBQ/fwAEvtOj3IMNNrw\nRUZIYAvwPFxTLXF0Dfj0fEiLFQzq+VPk3jsD9EbH1FotHXPtgA7brvG0uHfWKNsQ\nIQIDAQAB\n-----END PUBLIC KEY-----',
maintainer: 'Lightcurve GmbH',
},
{
url: 'wss://mainnet.lisk.com',
apiCertificatePublicKey:
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqiQIDBSSlqKeWo0st2Hy\nJRbDzqYgcZfQvOpttr4kMbDjAYnz6XvZe3kOHcnMM2ePWrAS66SHTqdVbEEiu9Kf\njEQQkmk/Xv7XSMQ5kwidv+ANNDjTaC9GRnUHQ3pH77ZZY5msq0kEvmDvyMljU9kD\neqpugQn7jQVTG7te7PyXnZxvzMq8tgDILEwRnkF2hUF6jCH5X763aOT7X6yKUKY5\nZSUqmStKGPt1i34E5Pvb2AumsApkyqXfST/N/h8NV3UXRTBQ/fwAEvtOj3IMNNrw\nRUZIYAvwPFxTLXF0Dfj0fEiLFQzq+VPk3jsD9EbH1FotHXPtgA7brvG0uHfWKNsQ\nIQIDAQAB\n-----END PUBLIC KEY-----',
maintainer: 'Lightcurve GmbH',
},
],
backgroundColor: '#f7f9fb',
},
};

export const liskTestnetApplication = {
'01000000': {
chainName: 'lisk_mainchain',
displayName: 'Lisk',
chainID: '01000000',
title: 'Lisk - Testnet',
description: 'Metadata configuration for the Lisk blockchain (mainchain) in testnet',
networkType: 'testnet',
isDefault: true,
status: 'activated',
genesisURL: 'https://downloads.lisk.com/lisk/testnet/genesis_block.json.tar.gz',
projectPage: 'https://lisk.com',
serviceURLs: [
{
http: 'https://testnet-service.lisk.com',
ws: 'wss://testnet-service.lisk.com',
apiCertificatePublicKey:
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA55eVRxMsjgsakiSmRJGN\ng7u5XCO63BzbyFeUUuZ5YGRodFDw/cVAaIg9mWAtYRQM3FemJRt6zGcneFTbfmFC\nFcrGFbFqbcBssuHeyaBQroP8E5NcYVy7ZYJmZTaFBL9fpFzgrGdnLgjrlTkx7G+d\n95299QFRfX+mtSXuU0qzsSJzLaO9TsED3+I0aH80nJtxO8/ZI+RqjmomV5aAU0EO\n4S7a7npMZjxVKqwEcUcHeGf+4VLFGDc821IV45T4OZCxRG0sWgbc/AglY1xzRzJv\n1PTTWSYaukKM4rsuVEh6P12dAvMowh4wPGGPkQopXfS135xuHeefjnILl5/OcwHF\n3wIDAQAB\n-----END PUBLIC KEY-----',
},
],
logo: {
png: 'https://raw.githubusercontent.com/LiskHQ/app-registry/main/testnet/Lisk/images/application/lisk.png',
svg: 'https://raw.githubusercontent.com/LiskHQ/app-registry/main/testnet/Lisk/images/application/lisk.svg',
},
explorers: [
{
url: 'https://testnet.liskscan.com',
txnPage: 'https://testnet.liskscan.com/transactions',
},
{
url: 'https://testnet.lisk.observer',
txnPage: 'https://testnet.lisk.observer/transactions',
},
],
appNodes: [
{
url: 'https://testnet.lisk.com',
apiCertificatePublicKey:
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA55eVRxMsjgsakiSmRJGN\ng7u5XCO63BzbyFeUUuZ5YGRodFDw/cVAaIg9mWAtYRQM3FemJRt6zGcneFTbfmFC\nFcrGFbFqbcBssuHeyaBQroP8E5NcYVy7ZYJmZTaFBL9fpFzgrGdnLgjrlTkx7G+d\n95299QFRfX+mtSXuU0qzsSJzLaO9TsED3+I0aH80nJtxO8/ZI+RqjmomV5aAU0EO\n4S7a7npMZjxVKqwEcUcHeGf+4VLFGDc821IV45T4OZCxRG0sWgbc/AglY1xzRzJv\n1PTTWSYaukKM4rsuVEh6P12dAvMowh4wPGGPkQopXfS135xuHeefjnILl5/OcwHF\n3wIDAQAB\n-----END PUBLIC KEY-----',
maintainer: 'Lightcurve GmbH',
},
{
url: 'wss://testnet.lisk.com',
apiCertificatePublicKey:
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA55eVRxMsjgsakiSmRJGN\ng7u5XCO63BzbyFeUUuZ5YGRodFDw/cVAaIg9mWAtYRQM3FemJRt6zGcneFTbfmFC\nFcrGFbFqbcBssuHeyaBQroP8E5NcYVy7ZYJmZTaFBL9fpFzgrGdnLgjrlTkx7G+d\n95299QFRfX+mtSXuU0qzsSJzLaO9TsED3+I0aH80nJtxO8/ZI+RqjmomV5aAU0EO\n4S7a7npMZjxVKqwEcUcHeGf+4VLFGDc821IV45T4OZCxRG0sWgbc/AglY1xzRzJv\n1PTTWSYaukKM4rsuVEh6P12dAvMowh4wPGGPkQopXfS135xuHeefjnILl5/OcwHF\n3wIDAQAB\n-----END PUBLIC KEY-----',
maintainer: 'Lightcurve GmbH',
},
],
backgroundColor: '#f7f9fb',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { selectApplications } from '../store/selectors';
import { useCurrentApplication } from './useCurrentApplication';
import { usePinBlockchainApplication } from './usePinBlockchainApplication';
import { useApplicationExploreAndMetaData } from './useApplicationExploreAndMetaData';
import { liskMainnetApplication, liskTestnetApplication } from '../const/liskApplications';

// eslint-disable-next-line max-statements
export function useApplicationManagement({ queryClient } = {}) {
Expand All @@ -19,6 +20,11 @@ export function useApplicationManagement({ queryClient } = {}) {
const { checkPinByChainId, pins } = usePinBlockchainApplication();
const applicationsObject = useSelector(selectApplications)[mainChainNetwork.name] || {};

const liskApplications = { mainnet: liskMainnetApplication, testnet: liskTestnetApplication };
const networkApplications = Object.keys(useSelector(selectApplications)).length
? useSelector(selectApplications)
: { ...liskApplications };

const applications = useMemo(() => {
const appsList = Object.values(applicationsObject).filter((app) => app?.status);
// Sort apps list by pinned apps and terminated apps such that
Expand Down Expand Up @@ -63,6 +69,7 @@ export function useApplicationManagement({ queryClient } = {}) {
return {
isLoading,
applications,
networkApplications,
setApplication,
setApplications,
getApplicationByChainId,
Expand Down
11 changes: 7 additions & 4 deletions src/modules/common/components/bars/sideBar/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ describe('SideBar', () => {
});

it(`renders ${menuItems.length} menu items elements`, () => {
expect(wrapper).toContainMatchingElements(menuLinks.length, 'a');
// Last two menu items are not anchor tags
expect(wrapper).toContainMatchingElements(menuItems.length - 2, 'a');
});

it('shows sidebar toggle info on hover', () => {
Expand All @@ -75,12 +76,13 @@ describe('SideBar', () => {

describe(`renders ${menuItems.length} menu items`, () => {
it('without labels if sideBarExpanded is false', () => {
expect(wrapper).toContainMatchingElements(menuLinks.length, 'a');
// Last two menu items are not anchor tags
expect(wrapper).toContainMatchingElements(menuItems.length - 2, 'a');
wrapper.find('a').forEach((link) => expect(link).not.toContain(/\w*/));
});

it('without labels if sideBarExpanded is true', () => {
const expectedLinks = ['Applications'];
const expectedLinks = ['Wallet', 'Applications'];

mockAppState.settings = { ...mockAppState.settings, sideBarExpanded: true };
wrapper = mountWithRouter(SideBar, myProps);
Expand All @@ -96,7 +98,8 @@ describe('SideBar', () => {
pathname: routes.reclaim.path,
},
});
expect(wrapper).toContainMatchingElements(menuLinks.length, 'a');
// Last two menu items are not anchor tags
expect(wrapper).toContainMatchingElements(menuItems.length - 2, 'a');
menuItems[0].forEach((_, index) => {
expect(wrapper.find('a').at(index)).toHaveClassName('disabled');
});
Expand Down
8 changes: 8 additions & 0 deletions src/modules/common/components/bars/sideBar/menuLinks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import routes from 'src/routes/routes';

const menuLinks = (t) => [
[
{
icon: 'walletIcon',
id: 'wallet',
label: t('Wallet'),
path: routes.wallet.path,
},
],
[
{
icon: 'applicationsIcon',
Expand Down
11 changes: 6 additions & 5 deletions src/modules/common/components/customRoute/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* eslint-disable complexity */
import React from 'react';
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import { Redirect, Route } from 'react-router-dom';
import { useAccounts, useCurrentAccount } from '@account/hooks';
import Piwik from 'src/utils/piwik';
import routes from 'src/routes/routes';
import useSettings from '@settings/hooks/useSettings';
import networks from '@network/configuration/networks';
import offlineStyle from 'src/modules/common/components/offlineWrapper/offlineWrapper.css';
import { useCheckLegacyAccount } from '@legacy/hooks/queries';
import { useTranslation } from 'react-i18next';
Expand All @@ -17,15 +16,17 @@ const CustomRoute = ({ path, exact, isPrivate, forbiddenTokens, component, histo
const { t } = useTranslation();
const token = useSelector((state) => state.token);
const isNetworkSet = useSelector(({ network }) => !!network.name);
const [isFirstTimeLoading, setIsFirstTimeLoading] = useState(true);
const [currentAccount] = useCurrentAccount();
const { pubkey, address, isHW } = currentAccount?.metadata || {};
const isAuthenticated = !!address;
const { isMigrated } = useCheckLegacyAccount(pubkey);
const { search = '' } = history.location;
const { accounts } = useAccounts();
const { setValue: setMainChainNetwork } = useSettings('mainChainNetwork');
if (!isNetworkSet) {
setMainChainNetwork(networks.mainnet);
const { mainChainNetwork, setValue: setMainChainNetwork } = useSettings('mainChainNetwork');
if (isFirstTimeLoading) {
setMainChainNetwork(mainChainNetwork);
setIsFirstTimeLoading(false);
}

Piwik.tracking(history, token);
Expand Down
1 change: 1 addition & 0 deletions src/modules/common/components/customRoute/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('CustomRoute', () => {
useSettings.mockReturnValue({
mainChainNetwork: { name: 'devnet' },
toggleSetting: mockToggleSetting,
setValue: jest.fn(),
});
});

Expand Down
Loading

0 comments on commit 24cef21

Please sign in to comment.