Commit 3d488b1
feat: add 7702 methods to ledger (#564)
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
Are there any issues or other links reviewers should consult to
understand this pull request better? For instance:
* Fixes #12345
* See: #67890
-->
This PR adds the 7702 methods to the ledger keyring. The method itself
is not usable until the dmk support has been added.
## Examples
<!--
Are there any examples of this change being used in another repository?
When considering changes to the MetaMask module template, it's strongly
preferred that the change be experimented with in another repository
first. This gives reviewers a better sense of how the change works,
making it less likely the change will need to be reverted or adjusted
later.
-->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes hardware signing and signature recovery for
personal_sign/typed data; EIP-7702 is new delegation signing surface,
though iframe/mobile paths are not live yet.
>
> **Overview**
> Adds **EIP-7702 delegation authorization signing** to the Ledger
Ethereum keyring and wires it through the V2 account API.
>
> `LedgerKeyring.signEip7702Authorization` unlocks the account, calls
the bridge’s new `deviceSignDelegationAuthorization` (chain id, contract
address without `0x`, nonce), builds a signature with **yParity**
(`00`/`01`) instead of legacy `27`/`28`, and verifies with
`recoverEIP7702Authorization`. The `LedgerBridge` interface gains
delegation types and `deviceSignDelegationAuthorization`; **iframe and
mobile bridges throw** until DMK/device support exists.
>
> **personal_sign** and **typed data** now parse Ledger’s `v` via
`#parseLedgerRecoveryParam` (decimal, bare hex like `'1b'`, `0x`/`0X`
hex, numbers) instead of `parseInt(..., 10)`, fixing wrong recovery when
the device returns hex `v`.
>
> V2 `LedgerKeyring` advertises
`EthKeyringMethod.SignEip7702Authorization` on EOA accounts. Changelog
and Jest coverage thresholds are updated; extensive unit tests cover
7702 signing and `v` parsing edge cases.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c91b13d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com>1 parent a5e7517 commit 3d488b1
9 files changed
Lines changed: 529 additions & 7 deletions
File tree
- packages/keyring-eth-ledger-bridge
- src
- v2
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
| |||
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
80 | 98 | | |
81 | 99 | | |
82 | 100 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
| |||
0 commit comments