Skip to content

Commit

Permalink
Used untagged message for claim signing and minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ikem-legend committed Apr 10, 2024
1 parent 7696599 commit 5e4cdcd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libs/hardwareWallet/ledger/ledgerLiskAppIPCChannel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getPubKey,
getConnectedDevices,
getSignedMessage,
getSignedRawMessage,
getSignedTransaction,
getMultipleAddresses,
} from './serverLedgerHWCommunication';
Expand Down Expand Up @@ -39,7 +40,7 @@ export const ledgerLiskAppIPCChannel = () => {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ export async function getSignedMessage({ devicePath, accountIndex, unsignedMessa
}
}

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)
? Buffer.from(unsignedMessage, '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);
} catch (error) {
if (transport) await transport.close();
return Promise.reject(error);
}
}

export async function getConnectedDevices() {
try {
const devicePaths = await TransportNodeHid.list();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/message/store/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const signClaimMessage =
const [error, signature] = await to(
signClaimMessageUsingHW({
account: currentAccount,
message: getUnsignedNonProtocolMessage(portalMessage),
message: portalMessage,
})
);

Expand Down

0 comments on commit 5e4cdcd

Please sign in to comment.