Skip to content

Commit 5e4cdcd

Browse files
committed
Used untagged message for claim signing and minor refactor
1 parent 7696599 commit 5e4cdcd

File tree

3 files changed

+25
-2
lines changed
  • libs/hardwareWallet/ledger/ledgerLiskAppIPCChannel
  • src/modules/message/store

3 files changed

+25
-2
lines changed

libs/hardwareWallet/ledger/ledgerLiskAppIPCChannel/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getPubKey,
99
getConnectedDevices,
1010
getSignedMessage,
11+
getSignedRawMessage,
1112
getSignedTransaction,
1213
getMultipleAddresses,
1314
} from './serverLedgerHWCommunication';
@@ -39,7 +40,7 @@ export const ledgerLiskAppIPCChannel = () => {
3940

4041
createIpcMainChannel(GET_SIGNED_RAW_MESSAGE, async (data) => {
4142
const id = `${GET_SIGNED_RAW_MESSAGE}-${Date.now()}`;
42-
const result = await getSequentiallyQueuedData(myq, id, () => getSignedMessage(data));
43+
const result = await getSequentiallyQueuedData(myq, id, () => getSignedRawMessage(data));
4344
return result;
4445
});
4546

libs/hardwareWallet/ledger/ledgerLiskAppIPCChannel/serverLedgerHWCommunication/index.js

+22
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ export async function getSignedMessage({ devicePath, accountIndex, unsignedMessa
9090
}
9191
}
9292

93+
export async function getSignedRawMessage({ devicePath, accountIndex, unsignedMessage }) {
94+
let transport;
95+
try {
96+
transport = await TransportNodeHid.open(devicePath);
97+
const liskLedger = new LiskApp(transport);
98+
const ledgerAccount = getLedgerAccount(accountIndex);
99+
const message = isHexString(unsignedMessage)
100+
? Buffer.from(unsignedMessage, 'hex')
101+
: Buffer.from(unsignedMessage);
102+
const response = await liskLedger.claimMessage(ledgerAccount.derivePath(), message);
103+
await transport?.close();
104+
105+
if (response?.error_message === 'No errors') {
106+
return response;
107+
}
108+
return Promise.reject(response.return_code);
109+
} catch (error) {
110+
if (transport) await transport.close();
111+
return Promise.reject(error);
112+
}
113+
}
114+
93115
export async function getConnectedDevices() {
94116
try {
95117
const devicePaths = await TransportNodeHid.list();

src/modules/message/store/action.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const signClaimMessage =
5050
const [error, signature] = await to(
5151
signClaimMessageUsingHW({
5252
account: currentAccount,
53-
message: getUnsignedNonProtocolMessage(portalMessage),
53+
message: portalMessage,
5454
})
5555
);
5656

0 commit comments

Comments
 (0)