feat: add Trezor hardware wallet support#31
Merged
aviggiano merged 1 commit intoMay 14, 2026
Conversation
Collaborator
|
Hi there, Thanks for your submission. I will review this until the end of the week and we'll get this merge soon |
Collaborator
|
Hey This looks go to be merged I don't have a Trezor so haven't tested it, and the unit testing support for this library is very inconvenient. So we should expect users to do their own testing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trezor hardware wallet support
Motivation
The library previously only supported Ledger for signing. Teams using Trezor had no path to propose transactions through safe-utils.
What's added
Safe.sol— Trezor signing path insign()The
sign()function now reads aHARDWARE_WALLETenvironment variable (defaults toledger) and branches accordingly:When
trezoris selected,sign()callscast wallet sign --trezor <safeTxHash>viavm.ffiinstead of using Ledger's EIP-712--datapath. One post-processing step is required: Trezor signs viaeth_sign, which prepends\x19Ethereum Signed Message:\n32to the hash. Safe'scheckNSignaturesdetects this signature type by checkingv >= 31, so the recovery byte is incremented by 4 (output[64] += 4) before returning.README.mdHARDWARE_WALLET=trezorenv var usage example.sign()note to cover both--ledgerand--trezorflags.Why not
--trezordirectly?cast wallet sign --trezor --data <EIP-712 json>is not supported by Trezor's firmware — it only handles raw message signing (eth_sign), not structured data (eth_signTypedData). Passing the rawsafeTxHashand adjustingvis the correct workaround.