Skip to content

Commit

Permalink
feat: Enable Ledger clear signing feature (#28909)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This PR enable the clear signing feature in metamask mobile.
Please refer to this feature requests for detail:
MetaMask/accounts-planning#544
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28909?quickstart=1)

## **Related issues**

Fixes: MetaMask/accounts-planning#544

## **Manual testing steps**

- Test the clear signing using this dapp provided by ledger team:
https://clear-signing-tester.vercel.app/
- EIP712 sign message (Polygon mainnet or Ethereum mainnet).
- Sign transaction (Linea testnet).
- Swap in a layer 2 chain like Linea or Polygon.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: Sébastien Van Eyck <[email protected]>
Co-authored-by: MetaMask Bot <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2025
1 parent 4cbce35 commit 2d443ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions app/scripts/lib/offscreen-bridge/ledger-offscreen-bridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { LedgerBridge } from '@metamask/eth-ledger-bridge-keyring';
import {
LedgerBridge,
LedgerSignTypedDataParams,
LedgerSignTypedDataResponse,
} from '@metamask/eth-ledger-bridge-keyring';
import {
LedgerAction,
OffscreenCommunicationEvents,
Expand Down Expand Up @@ -161,11 +165,9 @@ export class LedgerOffscreenBridge
});
}

deviceSignTypedData(params: {
hdPath: string;
domainSeparatorHex: string;
hashStructMessageHex: string;
}) {
deviceSignTypedData(
params: LedgerSignTypedDataParams,
): Promise<LedgerSignTypedDataResponse> {
return new Promise<{
v: number;
s: string;
Expand Down
2 changes: 1 addition & 1 deletion offscreen/scripts/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function setupMessageListeners(iframe: HTMLIFrameElement) {
export default async function init() {
return new Promise<void>((resolve) => {
const iframe = document.createElement('iframe');
iframe.src = 'https://metamask.github.io/eth-ledger-bridge-keyring';
iframe.src = 'https://metamask.github.io/ledger-iframe-bridge/8.0.0/';
iframe.allow = 'hid';
iframe.onload = () => {
setupMessageListeners(iframe);
Expand Down

0 comments on commit 2d443ff

Please sign in to comment.