Skip to content

Commit

Permalink
Fix Ledger typed data signing uppercase 0X
Browse files Browse the repository at this point in the history
The Ledger-specific signing screen showed the domain and message hashes
with a startin 0X due to an aggressive toUpperCase call. To make it
easier to scan, it now starts with 0x (lowercase x) as expected.
  • Loading branch information
Shadowfiend committed Jul 15, 2024
1 parent 1c6ff61 commit 7a25914
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ function SignerLedgerSigningTypedData({
typedData: EIP712TypedData
}): ReactElement {
const { EIP712Domain: _, ...typesForSigning } = typedData.types
const domainHash = _TypedDataEncoder

// Below, we prefix the 0x so that we can uppercase the hex characters
// without uppercasing the X. This is because the Ledger displays hex
// characters all uppercase for this operation, but an uppercased X
// both makes our display and the Ledger's less accurate and makes it
// harder to scan the values.
const domainHash = `0x${_TypedDataEncoder
.hashDomain(typedData.domain)
.toUpperCase()
const messageHash = _TypedDataEncoder
.substring(2)
.toUpperCase()}`
const messageHash = `0x${_TypedDataEncoder
.from(typesForSigning)
.hash(typedData.message)
.toUpperCase()
.substring(2)
.toUpperCase()}`

return (
<TransactionDetailContainer>
Expand Down

0 comments on commit 7a25914

Please sign in to comment.