-
Notifications
You must be signed in to change notification settings - Fork 807
Move EthKeychain interface to utils/crypto/keychain package #4344
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
base: master
Are you sure you want to change the base?
Conversation
- Move EthKeychain interface from wallet/chain/c to utils/crypto/keychain/keychain.go - Add EthKeychain interface compliance check to secp256k1fx.Keychain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the code organization by moving the EthKeychain interface from the wallet/chain/c package to the utils/crypto/keychain package, centralizing keychain interfaces in one location.
- Relocates EthKeychain interface definition to improve code organization
- Updates import statements and type references across affected files
- Adds compile-time verification that secp256k1fx.Keychain implements EthKeychain
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
utils/crypto/keychain/keychain.go | Adds EthKeychain interface definition and imports |
wallet/chain/c/signer.go | Removes EthKeychain interface and updates type references |
vms/secp256k1fx/keychain.go | Adds compile-time check for EthKeychain implementation |
wallet/subnet/primary/wallet.go | Updates parameter type reference |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Isn't it supposed to be preferred to define the interface where it is used, rather than next to the struct that defines it? I know that isn't necessarily what we have done in avalanchego in the past, but this PR seems to be pushing us back into a bad pattern (rather than pushing us towards a cleaner pattern). |
You're right about the Go convention. Looking at usage, EthKeychain is primarily used in wallet/chain/c (signer) and wallet/subnet/primary (wallet creation). I moved it to match the existing Keychain pattern and also wanted to provide a single point of reference for keychain implementations (ledger, cubesigner, secp256k1fx). This makes it easier to see what interfaces need to be implemented when adding new keychain types IMO. But given the more limited usage compared to Keychain, would you prefer it back in wallet/chain/c where it's most heavily used? |
Why this should be merged
This refactoring improves code organization by centralizing keychain interfaces in a single package. Currently, the EthKeychain interface is defined in wallet/chain/c, which creates an awkward dependency where core keychain functionality is scattered across different packages. This separation makes it unclear that keychain implementations should provide both AVAX and Ethereum address support.
How this works
How this was tested
Need to be documented in RELEASES.md?