Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: natively support clear signing with Ledger #4416

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Oct 24, 2024

⚠️ This is awaiting a fix in the Ledger SDK.

What it solves

The inability to perform clear signing with Ledger devices.

How this PR fixes it

This replaces the outdated @web3-onboard/ledger module, which relied on an archived Ledger package, with a custom module built on Ledger's new Web Management Device Kit.

How to test it

Connect a Ledger device and test each RPC method (which corresponds to each SDK method):

  • Successful connection (accounts)
  • Signing a message (signing)
  • Signing a transaction (signing typed data)
  • Executing a transaction (sending a transaction)

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@iamacook iamacook self-assigned this Oct 24, 2024
Copy link

github-actions bot commented Oct 24, 2024

Copy link

github-actions bot commented Oct 24, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.71% (-0.33% 🔻)
13529/18355
🔴 Branches
51.49% (-1.19% 🔻)
3291/6392
🔴 Functions
57.26% (-0.58% 🔻)
1969/3439
🟡 Lines
75.41% (-0.29% 🔻)
12302/16314
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / transaction-guards.ts
69.91% (-6.19% 🔻)
34.52% (-23.81% 🔻)
68.75% (-10.94% 🔻)
70.73% (-7.32% 🔻)
🟡
... / formatters.ts
74.14% (-5.17% 🔻)
57.14%
76.92% (-7.69% 🔻)
74.42% (-4.65% 🔻)
🟡
... / useDraftBatch.ts
62.07% (-3.45% 🔻)
0% 20% 65.38%
🔴
... / index.ts
11.32% (-1.89% 🔻)
100% 0%
22.22% (-3.7% 🔻)
🟢
... / index.tsx
92.86% (-7.14% 🔻)
50% (-25% 🔻)
100% 100%
🟢
... / DataRow.tsx
80% (-20% 🔻)
0% (-100% 🔻)
100% 100%
🟢
... / index.tsx
96.88% (-3.13% 🔻)
68.18% (-20.95% 🔻)
100%
96.77% (-3.23% 🔻)
🔴
... / index.tsx
57.14% (-37.14% 🔻)
9.52% (-66.67% 🔻)
33.33% (-33.33% 🔻)
59.38% (-37.5% 🔻)
🟡
... / SafeTxGasForm.tsx
64%
45.45% (-18.18% 🔻)
16.67% 62.5%
🟢
... / index.tsx
91.67%
78.38% (-2.7% 🔻)
100% 100%
🟡
... / index.tsx
54.55% (-45.45% 🔻)
0% (-66.67% 🔻)
0% (-100% 🔻)
60% (-40% 🔻)
🟢
... / index.tsx
100%
93.33% (-6.67% 🔻)
100% 100%
🟢
... / index.tsx
86.05%
37.14% (-2.86% 🔻)
42.86% 85.37%
🟢
... / TransferActions.tsx
80.43%
73.33% (-13.33% 🔻)
40% 81.4%
🟢
... / index.tsx
86.81% (-13.19% 🔻)
72.45% (-27.55% 🔻)
42.86% (-57.14% 🔻)
86.21% (-13.79% 🔻)
🟡
... / CounterfactualForm.tsx
68.18%
42.86% (-17.86% 🔻)
66.67% 68.25%
🟢
... / tokenTransferParams.ts
96.3% (-3.7% 🔻)
80%
80% (-20% 🔻)
95.83% (-4.17% 🔻)
🔴
... / index.tsx
50% (-32.14% 🔻)
0% (-12.5% 🔻)
0% (-100% 🔻)
51.85% (-29.63% 🔻)
🟡
... / index.tsx
55.56% (-44.44% 🔻)
0%
0% (-100% 🔻)
62.5% (-37.5% 🔻)
🔴
... / useAllSafes.ts
50%
17.24% (-3.45% 🔻)
37.5% 55.56%
🟡 src/pages/_app.tsx
69.33% (-0.4% 🔻)
42.86% 0%
68.06% (-0.44% 🔻)
🔴
... / index.tsx
30.08% (-4.88% 🔻)
0% (-1.96% 🔻)
0% (-2.63% 🔻)
33.04% (-4.46% 🔻)
🔴
... / useAllSafesGrouped.ts
28.57% (-42.86% 🔻)
0%
0% (-37.5% 🔻)
27.78% (-50% 🔻)
🟡
... / index.tsx
60% (-1.9% 🔻)
0% 0%
66.67% (-1.75% 🔻)
🟢
... / BatchTxList.tsx
66.67% (-33.33% 🔻)
100%
0% (-100% 🔻)
80% (-20% 🔻)
🟡
... / BatchTxItem.tsx
58.33% (-20.83% 🔻)
0% (-71.43% 🔻)
0% (-50% 🔻)
60.87% (-17.39% 🔻)
🔴
... / RecoverAccountFlowReview.tsx
46.38% (-0.85% 🔻)
0% 0%
46.38% (-0.85% 🔻)
🟡
... / index.tsx
66.67% (-33.33% 🔻)
0% (-75% 🔻)
0% (-100% 🔻)
66.67% (-33.33% 🔻)

Test suite run success

1573 tests passing in 208 suites.

Report generated by 🧪jest coverage report action from 7d2244c

@@ -0,0 +1,349 @@
import type { DeviceActionState } from '@ledgerhq/device-management-kit'
import type { SignTransactionDAOutput, SignTypedDataDAOutput, TypedData } from '@ledgerhq/device-signer-kit-ethereum'
import type { GetAddressCommandResponse } from '@ledgerhq/device-signer-kit-ethereum/api/app-binder/GetAddressCommandTypes.js'
Copy link

@valpinkman valpinkman Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be imported directly from the index on the package. it should not be imported directly with a direct path.

If the export is not present in the index, please file an issue here https://github.com/LedgerHQ/device-sdk-ts/issues, it's probably a bug / we forgot to export it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem possible as GetAddressCommandResponse is not exported from the relevant barrel file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello 👋 In fact it's the wrong type that you are using, it should be GetAddressDAOutput, and this one is accessible 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(in the end they are equal)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I changed it in 05f3955.

Copy link

@iamacook iamacook changed the title WIP: fix: natively support clear signing with Ledger fix: natively support clear signing with Ledger Nov 6, 2024
@@ -13,7 +13,7 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "Bundler",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to support the SDK.

import type {
Permission,
PermissionRequest,
} from 'node_modules/@safe-global/safe-apps-sdk/dist/types/types/permissions'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and the other similar changes) are required to support the adjusted moduleResolution.

Copy link

github-actions bot commented Nov 6, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 1011.86 KB (🟢 -452 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

@katspaugh
Copy link
Member

WalletConnect's AppKit now has Ledger support so we should probably migrate from onboard to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants