-
Notifications
You must be signed in to change notification settings - Fork 5
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
♻️ (core) [DSDK-337]: Command signature: pass params to command constructor #99
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
it("should not parse the response when getApdu not called", () => { | ||
const PERCENTAGE_RESPONSE = new ApduResponse({ | ||
statusCode: PERCENTAGE_RESPONSE_HEX.slice(-2), | ||
data: PERCENTAGE_RESPONSE_HEX.slice(0, -2), | ||
}); | ||
expect(() => command.parseResponse(PERCENTAGE_RESPONSE)).toThrow( | ||
InvalidBatteryStatusTypeError, | ||
); | ||
}); |
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 test was solely needed because there was no constructor initialising the arguments, so if getApdu(params) wasn't called) then some internal prop was not initialised.
@@ -10,6 +10,8 @@ import { ApduResponse } from "@api/device-session/ApduResponse"; | |||
* The command to close a runnint application on the device. | |||
*/ | |||
export class CloseAppCommand implements Command<void> { | |||
args: void = undefined; |
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.
[ASK] why specifying void
here but not in the other commands ?
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.
ah it's a mistake, I was trying out different stuff and forgot to remove this
4c4d93f
to
e3e9065
Compare
@@ -10,6 +10,8 @@ import { ApduResponse } from "@api/device-session/ApduResponse"; | |||
* The command to close a runnint application on the device. | |||
*/ | |||
export class CloseAppCommand implements Command<void> { | |||
args = undefined; |
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.
i think you can just
args;
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.
@@ -28,6 +28,8 @@ export type GetAppAndVersionResponse = { | |||
export class GetAppAndVersionCommand | |||
implements Command<GetAppAndVersionResponse> | |||
{ | |||
args = undefined; |
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 here
@@ -64,6 +64,8 @@ export type GetOsVersionResponse = { | |||
* Command to get information about the device firmware. | |||
*/ | |||
export class GetOsVersionCommand implements Command<GetOsVersionResponse> { | |||
args = undefined; |
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 here
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.
LGTM ✅
📝 Description
Instead of doing
change to
The reasoning is that parameters are part of a command itself, not something living next to it.
❓ Context
✅ Checklist
Pull Requests must pass the CI and be code reviewed. Set as Draft if the PR is not ready.
🧐 Checklist for the PR Reviewers