-
Notifications
You must be signed in to change notification settings - Fork 0
Add CoinType used for Ledger and encode/decode utils #2
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
OBorce
commented
Dec 5, 2025
- also use the specific version of parity scale codec with the fix for NanoX
- also use the specific version of parrity scale codec with the fix for NanoX
| pub struct SecondsCount(#[codec(compact)] pub SecondsCountUIntType); | ||
|
|
||
| #[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
| pub enum CoinType { |
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.
Let's put it in a separate file, e.g. coin_type.rs
| pub fn encode_as_compact(num: u32) -> PscVec<u8> { | ||
| parity_scale_codec::Compact::<u32>::encode(&num.into()) | ||
| } |
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.
This function has a generic name, but it's only defined for u32. Either make it generic over the type or at least give it a specific name, e.g. encode_u32_as_compact (though this will also look quite ugly, so plz try making it generic first).
But are all these functions really needed?
| pub fn decode_all<T: Decode>(mut bytes: &[u8]) -> Option<T> { | ||
| T::decode_all(&mut bytes).ok() | ||
| } |
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.
It's better to return a Result and let the caller decide what to do with it,
| parity-scale-codec = { git = "https://github.com/paritytech/parity-scale-codec.git", rev = "5021525697edc0661591ebc71392c48d950a10b0", default-features = false, features = [ | ||
| "derive", | ||
| ] } |
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.
Same comment as in mintlayer/mintlayer-trezor-firmware#24 (comment)