Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
fixups after eth-sig-util update
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Oct 3, 2023
1 parent b89f0be commit f5c2c98
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/ledger-keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TransactionFactory, TxData, TypedTransaction } from '@ethereumjs/tx';
import type { MessageTypes, TypedMessage } from '@metamask/eth-sig-util';
import {
recoverPersonalSignature,
recoverTypedSignature,
SignTypedDataVersion,
TypedDataUtils,
} from '@metamask/eth-sig-util';
Expand Down Expand Up @@ -474,10 +475,7 @@ export class LedgerKeyring extends EventEmitter {
'EIP712Domain',
domain,
types,
// @ts-expect-error @types/eth-sig-util documents this function
// as taking three arguments, but it actually takes four.
// See: https://github.com/MetaMask/eth-sig-util/blob/v2.5.4/index.js#L174
isV4,
SignTypedDataVersion.V4,
).toString('hex');
const hashStructMessageHex = TypedDataUtils.hashStruct(
primaryType.toString(),
Expand Down Expand Up @@ -510,13 +508,10 @@ export class LedgerKeyring extends EventEmitter {
recoveryId = `0${recoveryId}`;
}
const signature = `0x${payload.r}${payload.s}${recoveryId}`;
// @ts-expect-error recoverTypedSignature_v4 is missing from
// @types/eth-sig-util.
// See: https://github.com/MetaMask/eth-sig-util/blob/v2.5.4/index.js#L464
const addressSignedWith = recoverTypedSignature_v4({
const addressSignedWith = recoverTypedSignature({
data,
// eslint-disable-next-line id-denylist
sig: signature,
signature,
version: SignTypedDataVersion.V4,
});
if (
ethUtil.toChecksumAddress(addressSignedWith) !==
Expand Down

0 comments on commit f5c2c98

Please sign in to comment.