-
Notifications
You must be signed in to change notification settings - Fork 33
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: hard-coded CLA byte #138
Conversation
CI failing but looks like it's due to a newer Rust version instead of my diffs. |
you do need to update the APDU construction in wasm.rs That said, in what cases would we NOT know the CLA at compile-time? |
I guess you'd always know it compile time. Am I understanding correctly that you're suggesting const generic? |
yes, if we did a const generic with default 0xE0 this would not be a breaking API change |
Weird. I changed the struct definition to: pub struct APDUCommand<const CLA: u8 = 0xE0> {
...
} but it still gives me an compilation error when I omit the generic param:
I've never worked with default const generic values before. It looks like the compiler accepts the syntax but somehow wouldn't allow omitting it when instantiating? Am I missing anything here? Sorry if this is obvious. |
Oh I figured out. Don't know how I missed this Stack Overflow answer in the first attempt. So the solution is to change let command = APDUCommand { into let command: APDUCommand = APDUCommand { and then it magically works. It looks like the default only applies when you name the type, not when you construct it. But apparently this would mean that using const generic with a default value would still be a breaking change, as downstream code that rely on type inference would no longer compile. |
Would it be worthwhile to add a few type aliases ?
|
Yeah that would probably be ideal. Posting the above just to say we'll end up breaking users whether we do it field-based or const-generic-based. I'm making the change towards const generics and fixing the CI now. |
Hmmm I just realized an issue. Since For But for It's not just structs. The What do you think? Should we pollute all these types with generics or go back to adding a new Overall I just feel like the added complexity isn't worth it when we can just add a field. The breakage from adding a field is actually smaller by comparison. Just my 2 cents though. Apparently if you still prefer the const generic way I will proceed. Thanks! |
mmm fair point. let's keep it as a prop and publish a breaking change |
b346eed
to
0e3be5d
Compare
Updated with the clippy and wasm fix. |
@prestwich Yo mind taking a look? Using this in a downstream crate but cannot publish to crates.io until this is released. Thanks for your time! |
oh sorry i was sure I had merged this. I'll run a release this morning. This is a breaking change so we're going to 0.12.0 |
Fixes #137.
Submitting this patch optimistically. This contains a breaking change as a new field
cla
has been added.Existing downstream applications would need to set
cla
to0xe0
to continue to useapp-ethereum
.