Skip to content

Commit

Permalink
Merge pull request #5581 from LiskHQ/release/3.0.2
Browse files Browse the repository at this point in the history
Merge release/3.0.2 into development
  • Loading branch information
sameersubudhi authored May 16, 2024
2 parents 83a8599 + 66e64ef commit b51efb7
Show file tree
Hide file tree
Showing 40 changed files with 729 additions and 325 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_MAPBOX_ACCESS_TOKEN=
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"LISK_ENABLE_DEV_TOOL": true,
"PRODUCTION": true,
"LISK_DOMAIN": true,
"REACT_APP_DEFAULT_NETWORK": true
"REACT_APP_DEFAULT_NETWORK": true,
"REACT_APP_MAPBOX_ACCESS_TOKEN": true
},
"env": {
"es2020": true,
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ app/app.js
blockchain_explorer.db.gz
reports
.history
.env
yarn-error.log
*.tgz

## Local environment files
.env.*
!.env.example

## Commercial fonts
setup/react/assets/fonts/basierCircle/
setup/react/assets/fonts/gilroy/
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pipeline {
ansiColor('xterm')
}
parameters {
string(name: 'CORE_VERSION', defaultValue: '4.0.1')
string(name: 'CORE_VERSION', defaultValue: '4.0.5')
string(name: 'SERVICE_BRANCH_NAME', defaultValue: 'development')
}
stages {
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lisk-desktop",
"version": "3.0.1",
"version": "3.0.2-alpha.0",
"productName": "Lisk",
"description": "Lisk",
"main": "./build/main.js",
Expand Down
9 changes: 9 additions & 0 deletions app/src/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { contextBridge, ipcRenderer } = require('electron');
const REQUEST = 'REQUEST';
const RESPONSE = 'RESPONSE';
const GET_SIGNED_MESSAGE = 'GET_SIGNED_MESSAGE';
const GET_SIGNED_RAW_MESSAGE = 'GET_SIGNED_RAW_MESSAGE';
const GET_SIGNED_TRANSACTION = 'GET_SIGNED_TRANSACTION';
const GET_PUB_KEY = 'GET_PUB_KEY';
const GET_MULTIPLE_ADDRESSES = 'GET_MULTIPLE_ADDRESSES';
Expand Down Expand Up @@ -61,6 +62,9 @@ contextBridge.exposeInMainWorld('ipc', {
[`${GET_SIGNED_MESSAGE}.${REQUEST}`]: (title) => {
ipcRenderer.send(`${GET_SIGNED_MESSAGE}.${REQUEST}`, title);
},
[`${GET_SIGNED_RAW_MESSAGE}.${REQUEST}`]: (title) => {
ipcRenderer.send(`${GET_SIGNED_RAW_MESSAGE}.${REQUEST}`, title);
},
[`${GET_CONNECTED_DEVICES}.${RESPONSE}`]: (func) => {
ipcRenderer.once(`${GET_CONNECTED_DEVICES}.${RESPONSE}`, (event, ...args) => {
func(event, ...args);
Expand Down Expand Up @@ -91,6 +95,11 @@ contextBridge.exposeInMainWorld('ipc', {
func(event, ...args);
});
},
[`${GET_SIGNED_RAW_MESSAGE}.${RESPONSE}`]: (func) => {
ipcRenderer.once(`${GET_SIGNED_RAW_MESSAGE}.${RESPONSE}`, (event, ...args) => {
func(event, ...args);
});
},
[LEDGER_HW_HID_EVENT]: (func) => {
ipcRenderer.on(LEDGER_HW_HID_EVENT, (event, ...args) => {
func(event, ...args);
Expand Down
1 change: 1 addition & 0 deletions libs/hardwareWallet/ledger/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const REQUEST = 'REQUEST';
export const LEDGER_HW_HID_EVENT = 'LEDGER_HW_HID_EVENT';
export const LEDGER_HW_IPC_CHANNELS = {
GET_SIGNED_MESSAGE: 'GET_SIGNED_MESSAGE',
GET_SIGNED_RAW_MESSAGE: 'GET_SIGNED_RAW_MESSAGE',
GET_SIGNED_TRANSACTION: 'GET_SIGNED_TRANSACTION',
GET_PUB_KEY: 'GET_PUB_KEY',
GET_MULTIPLE_ADDRESSES: 'GET_MULTIPLE_ADDRESSES',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
GET_PUB_KEY,
GET_MULTIPLE_ADDRESSES,
GET_SIGNED_MESSAGE,
GET_SIGNED_RAW_MESSAGE,
} = LEDGER_HW_IPC_CHANNELS;

function sleep(ms) {
Expand All @@ -34,6 +35,16 @@ export const getSignedMessage = async (devicePath, accountIndex, unsignedMessage
return signedMessage;
};

export const getSignedRawMessage = async (devicePath, accountIndex, unsignedMessage) => {
const signedRawMessage = await executeIPCCommand(GET_SIGNED_RAW_MESSAGE, {
devicePath,
accountIndex,
unsignedMessage,
});

return signedRawMessage;
};

export const getPubKey = async (devicePath, accountIndex, showOnDevice) => {
const pubKey = await executeIPCCommand(GET_PUB_KEY, {
devicePath,
Expand Down
8 changes: 8 additions & 0 deletions libs/hardwareWallet/ledger/ledgerLiskAppIPCChannel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {
getPubKey,
getConnectedDevices,
getSignedMessage,
getSignedRawMessage,
getSignedTransaction,
getMultipleAddresses,
} from './serverLedgerHWCommunication';

const {
GET_CONNECTED_DEVICES,
GET_SIGNED_MESSAGE,
GET_SIGNED_RAW_MESSAGE,
GET_PUB_KEY,
GET_MULTIPLE_ADDRESSES,
GET_SIGNED_TRANSACTION,
Expand All @@ -36,6 +38,12 @@ export const ledgerLiskAppIPCChannel = () => {
return result;
});

createIpcMainChannel(GET_SIGNED_RAW_MESSAGE, async (data) => {
const id = `${GET_SIGNED_RAW_MESSAGE}-${Date.now()}`;
const result = await getSequentiallyQueuedData(myq, id, () => getSignedRawMessage(data));
return result;
});

createIpcMainChannel(GET_PUB_KEY, async (data) => {
const id = `${GET_PUB_KEY}-${Date.now()}`;
const result = await getSequentiallyQueuedData(myq, id, () => getPubKey(data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const isHexString = (data) => {
return data === '' || /^([0-9a-f]{2})+$/i.test(data);
};

const NO_ERRORS = 'No errors';

export async function getPubKey({ devicePath, accountIndex, showOnDevice }) {
let transport;
try {
Expand All @@ -20,7 +22,7 @@ export async function getPubKey({ devicePath, accountIndex, showOnDevice }) {
? await liskLedger.showAddressAndPubKey(ledgerAccount.derivePath())
: await liskLedger.getAddressAndPubKey(ledgerAccount.derivePath());
await transport?.close();
if (response?.error_message === 'No errors') {
if (response?.error_message === NO_ERRORS) {
return response?.pubKey;
}
return Promise.reject(response.return_code);
Expand All @@ -37,7 +39,7 @@ export async function getMultipleAddresses({ devicePath, accountIndexes }) {
const liskLedger = new LiskApp(transport);
const response = await liskLedger.getMultipleAddresses(accountIndexes);
await transport?.close();
if (response?.error_message === 'No errors') {
if (response?.error_message === NO_ERRORS) {
return response?.addr;
}
return Promise.reject(response.return_code);
Expand All @@ -58,7 +60,7 @@ export async function getSignedTransaction({ devicePath, accountIndex, unsignedM
Buffer.from(unsignedMessage, 'hex')
);
if (transport && transport.close) await transport.close();
if (response?.error_message === 'No errors') {
if (response?.error_message === NO_ERRORS) {
return response;
}
return Promise.reject(response.return_code);
Expand All @@ -80,7 +82,29 @@ export async function getSignedMessage({ devicePath, accountIndex, unsignedMessa
const response = await liskLedger.signMessage(ledgerAccount.derivePath(), message);
await transport?.close();

if (response?.error_message === 'No errors') {
if (response?.error_message === NO_ERRORS) {
return response;
}
return Promise.reject(response.return_code);
} catch (error) {
if (transport) await transport.close();
return Promise.reject(error);
}
}

export async function getSignedRawMessage({ devicePath, accountIndex, unsignedMessage }) {
let transport;
try {
transport = await TransportNodeHid.open(devicePath);
const liskLedger = new LiskApp(transport);
const ledgerAccount = getLedgerAccount(accountIndex);
const message = isHexString(unsignedMessage.substring(2))
? Buffer.from(unsignedMessage.substring(2), 'hex')
: Buffer.from(unsignedMessage);
const response = await liskLedger.claimMessage(ledgerAccount.derivePath(), message);
await transport?.close();

if (response?.error_message === NO_ERRORS) {
return response;
}
return Promise.reject(response.return_code);
Expand Down
1 change: 1 addition & 0 deletions libs/wcm/constants/permissions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const SIGNING_METHODS = {
SIGN_TRANSACTION: { key: 'sign_transaction', title: 'Signature request' },
SIGN_MESSAGE: { key: 'sign_message', title: 'Sign message' },
SIGN_RAW_MESSAGE: { key: 'sign_raw_message', title: 'Sign raw message' },
};
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Lisk",
"version": "3.0.1",
"version": "3.0.2-alpha.0",
"author": "Lisk Foundation <[email protected]>, lightcurve GmbH <[email protected]>",
"license": "GPL-3.0",
"productName": "Lisk",
Expand Down Expand Up @@ -114,13 +114,13 @@
},
"dependencies": {
"@hookform/resolvers": "2.8.8",
"@ledgerhq/hw-transport-node-hid": "6.27.17-next.0",
"@ledgerhq/hw-transport-node-hid": "6.28.5",
"@liskhq/lisk-client": "6.0.1",
"@tanstack/react-query": "4.0.10",
"@tanstack/react-query-devtools": "4.2.1",
"@walletconnect/sign-client": "2.9.0",
"@walletconnect/utils": "2.9.0",
"@zondax/ledger-lisk": "0.0.2",
"@zondax/ledger-lisk": "0.0.3",
"async-await-queue": "2.1.3",
"await-to-js": "2.1.1",
"axios": "1.6.0",
Expand All @@ -131,6 +131,7 @@
"crypto-browserify": "^3.12.0",
"dompurify": "2.4.6",
"electron-localshortcut": "3.2.1",
"electron-log": "5.1.2",
"electron-store": "8.1.0",
"express": "4.18.2",
"express-rate-limit": "6.7.0",
Expand Down Expand Up @@ -178,6 +179,7 @@
"socket.io-client": "4.7.0",
"stream-browserify": "3.0.0",
"swiper": "8.4.2",
"tweetnacl": "1.0.3",
"usb": "2.9.0",
"yup": "0.32.11"
},
Expand All @@ -190,6 +192,7 @@
"@babel/preset-env": "7.22.5",
"@babel/preset-react": "7.22.5",
"@cucumber/cucumber": "9.2.0",
"@electron/rebuild": "3.6.0",
"@electron/universal": "1.4.1",
"@playwright/test": "1.32.1",
"@svgr/webpack": "8.0.1",
Expand All @@ -212,12 +215,11 @@
"cpx": "1.5.0",
"cross-env": "7.0.3",
"css-loader": "5.2.4",
"electron": "27.1.0",
"electron": "29.3.0",
"electron-builder": "24.6.4",
"electron-builder-notarize": "1.5.1",
"electron-devtools-installer": "3.2.0",
"electron-ipc-mock": "0.0.3",
"electron-rebuild": "3.2.9",
"electron-updater": "6.1.4",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.7",
Expand Down
1 change: 1 addition & 0 deletions setup/config/webpack.config.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const config = {
VERSION: `"${bundleVersion}"`,
LISK_DOMAIN: '"https://lisk.com"',
REACT_APP_DEFAULT_NETWORK: `"${process.env.DEFAULT_NETWORK}"`,
REACT_APP_MAPBOX_ACCESS_TOKEN: `"${process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}"`,
}),
new StyleLintPlugin({
context: `${path.resolve(__dirname, '../../src')}`,
Expand Down
1 change: 1 addition & 0 deletions setup/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ module.exports = {
TEST: true,
VERSION: '',
REACT_APP_DEFAULT_NETWORK: 'undefined',
REACT_APP_MAPBOX_ACCESS_TOKEN: 'pk.eyJ1Ij',
LISK_ENABLE_DEV_TOOL: false,
LISK_DOMAIN: 'https://lisk.com',
},
Expand Down
6 changes: 5 additions & 1 deletion setup/react/app/MainRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Route, Switch } from 'react-router-dom';
import { addSearchParamsToUrl, removeSearchParamsFromUrl } from 'src/utils/searchParams';
import { useEvents } from '@libs/wcm/hooks/useEvents';
import { EVENTS } from '@libs/wcm/constants/lifeCycle';
import { SIGNING_METHODS } from '@libs/wcm/constants/permissions';
import routesMap from 'src/routes/routesMap';
import NotFound from '@common/components/NotFound';
import CustomRoute from '@common/components/customRoute';
Expand All @@ -28,7 +29,10 @@ const MainRouter = ({ history }) => {
if (event.name === EVENTS.SESSION_REQUEST) {
const method = event.meta?.params?.request?.method;

if (method === 'sign_message') {
if (
method === SIGNING_METHODS.SIGN_MESSAGE.key ||
method === SIGNING_METHODS.SIGN_RAW_MESSAGE.key
) {
showRequestModal('requestSignMessageDialog', event);
} else {
showRequestModal('requestView', event);
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
"Invalid amount": "Invalid amount",
"Invalid dates": "Invalid dates",
"Invalid network name": "Invalid network name",
"Invalid transaction initiated from another application/network.": "Invalid transaction initiated from another application/network.",
"Invalid signature request initiated from another application/network.": "Invalid signature request initiated from another application/network.",
"Invalid websocket URL": "Invalid websocket URL",
"Is the problem persisting?": "Is the problem persisting?",
"Keep it safe as it is the only way to access your wallet.": "Keep it safe as it is the only way to access your wallet.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@ import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useCurrentAccount } from '@account/hooks';
import { useDispatch } from 'react-redux';
import { signMessage } from '@message/store/action';
import { signMessage, signClaimMessage } from '@message/store/action';
import CopyToClipboard from '@common/components/copyToClipboard';
import { PrimaryButton } from '@theme/buttons';
import styles from './RequestSignMessageConfirmation.css';

export function RequestSignMessageConfirmation({ nextStep, address, message }) {
export function RequestSignMessageConfirmation({ nextStep, address, message, portalMessage }) {
const { t } = useTranslation();
const [currentAccount] = useCurrentAccount();
const dispatch = useDispatch();

/* istanbul ignore next */
const onClick = () => {
nextStep({
message,
actionFunction: (formProps, _, privateKey) =>
dispatch(signMessage({ message, nextStep, privateKey, currentAccount })),
});
if (message) {
nextStep({
message,
actionFunction: (formProps, _, privateKey) =>
dispatch(signMessage({ message, nextStep, privateKey, currentAccount })),
});
} else {
nextStep({
message: portalMessage,
actionFunction: (formProps, _, privateKey) =>
dispatch(signClaimMessage({ portalMessage, nextStep, privateKey, currentAccount })),
});
}
};

return (
Expand All @@ -39,7 +47,7 @@ export function RequestSignMessageConfirmation({ nextStep, address, message }) {
}}
/>
<p className={styles.label}>{t('Message')}</p>
<div className={styles.messageBox}>{message}</div>
<div className={styles.messageBox}>{message ?? portalMessage}</div>
<PrimaryButton className={classNames(styles.btnContinue, 'continue-btn')} onClick={onClick}>
{t('Continue')}
</PrimaryButton>
Expand Down
Loading

0 comments on commit b51efb7

Please sign in to comment.