-
Notifications
You must be signed in to change notification settings - Fork 12
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
account.signTypedData()
for @celo/viem-account-ledger
(#505)
#513
Conversation
### Description - Needed this for my own work. `viem-account-ledger` was the nicest wrapper for Viem I could find, and everything else is Ethers or lower-level. - Ledger requires the domain seperator to be passed in explicitly, so you need to hash things independently (i.e you cannot use Viem's `hashTypedData()`). ### Tested - Tested this onchain and got valid signatures back. I'm using it in my own work to sign a Gnosis transaction hash, and submit onchain to approve the transaction. I successfully approved a transaction hash using this. - If you guys want to copy this branch and add unit tests that's totally fine. Just wanted to make this easier for ya'll to integrate. <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `ledgerToAccount` functionality by implementing the `signTypedData` method for EIP-712 typed data signing, incorporating new utility functions from `viem` and defining an interface for message properties. ### Detailed summary - Added imports for `getTypesForEIP712Domain`, `hashDomain`, `hashStruct`, `HashTypedDataParameters` from `viem`. - Defined a new interface `MessageTypeProperty`. - Implemented the `signTypedData` method to handle EIP-712 signing. - Utilized `hashDomain` and `hashStruct` to compute hashes for the signing process. - Used `serializeSignature` to format the signature before returning. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> Co-authored-by: Nicolas Brugneaux <nicolas.brugneaux@gmail.com>
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #513 +/- ##
==========================================
+ Coverage 76.45% 76.58% +0.13%
==========================================
Files 247 248 +1
Lines 10448 10639 +191
Branches 1649 1699 +50
==========================================
+ Hits 7988 8148 +160
- Misses 2369 2393 +24
- Partials 91 98 +7
|
Hi @jbrower95 thanks again for your work! After some investigation, I came to the conclusion that unfortunately celo-app still cannot sign typed data Explanation:In return transport.send(0xe0, 0x0c, 0x00, 0x00, buffer) the second argument is the hex code that the app will receive and decide what to do with it, for signing it's Unfortunately you can find in https://github.com/LedgerHQ/app-celo-spender/blob/develop/src/main.c#L600-L625 that the celo-app does not implement a TLDR: it's not implemented in the C application
I see that running the tests on the |
I added support for ethereum app for eip1559 txs and |
71f8fac
to
2714a3b
Compare
Big oopsie related to #513 no having changesets <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces beta support for `signTypedData` in the `@celo/viem-account-ledger` and `@celo/wallet-ledger` packages when used with the `ethereum` ledger app. ### Detailed summary - Added beta support for `signTypedData` in `@celo/viem-account-ledger`. - Added beta support for `signTypedData` in `@celo/wallet-ledger`. - Support is specifically for use with the `ethereum` ledger app. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> --------- Co-authored-by: Aaron DeRuvo <aaron.deruvo@clabs.co>
Note
Originally opened by @jbrower95
Description
viem-account-ledger
was the nicest wrapper for Viem I could find, and everything else is Ethers or lower-level.hashTypedData()
).Tested
PR-Codex overview
This PR primarily focuses on enhancing the
LedgerSigner
andLedgerWallet
classes by adding anappName
property to their configurations and implementing logic to handle different ledger applications (Celo and Ethereum) effectively.Detailed summary
appName
property toappConfiguration
inLedgerSigner
.appName
with a default value.signTypedData
andsignTransaction
methods based onappName
.readAppName
function to fetch the app name from the ledger device.readAppName
and various transaction signing scenarios.test-utils
module and its contents.Description
Tell us why these changes are being made
Other changes
Describe any minor or "drive-by" changes here. If none delete this section
Tested
An explanation of how the changes were tested or an explanation as to why they don't need to be.
How to QA
List of steps required to QA the change if applicable
Related issues
PR-Codex overview
This PR focuses on enhancing the
ledgerToAccount
functionality by implementing thesignTypedData
method, which allows for signing EIP-712 typed data using the Ledger device. It also adds new utility functions for handling EIP-712 domains and structures.Detailed summary
getTypesForEIP712Domain
,hashDomain
,hashStruct
, andHashTypedDataParameters
fromviem
.MessageTypeProperty
interface for type safety.signTypedData
method to sign EIP-712 typed data.hashDomain
andhashStruct
for message hashing.