-
Notifications
You must be signed in to change notification settings - Fork 34
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
Added MintInfo Class #209
base: development
Are you sure you want to change the base?
Added MintInfo Class #209
Conversation
src/model/MintInfo.ts
Outdated
import { GetInfoResponse, MPPMethod, SwapMethod, WebSocketSupport } from './types'; | ||
|
||
export class MintInfo { | ||
private readonly mintInfo: GetInfoResponse; |
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.
should we use _mintInfo
to match other private fields?
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.
Looks great. Took me a second to realize what you were doing with the switch statement because I've never seen them used that way before, but now that I get it I think its a clean solution
isSupported(num: 17): { supported: boolean; params?: Array<WebSocketSupport> }; | ||
isSupported(num: 15): { supported: boolean; params?: Array<MPPMethod> }; | ||
isSupported(num: number) { | ||
switch (num) { |
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.
Should the cases be handled exhaustively so that unrecognized NUT numbers always resolve to false?
Or alternatively throw on unrecognized NUT number.
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.
Very good point! I added a default case that throws. Throwing in this case makes more sense to me, because it makes clear that this NUT is unsupported by the client, not the mint
Description
Adds a MintInfo class that exposes some helper methods to easily check if a mint supports a NUT.
Changes
PR Tasks
npm run test
--> no failing unit testsnpm run format