Skip to content
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

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
Open

Added MintInfo Class #209

wants to merge 9 commits into from

Conversation

Egge21M
Copy link
Collaborator

@Egge21M Egge21M commented Nov 16, 2024

Description

Adds a MintInfo class that exposes some helper methods to easily check if a mint supports a NUT.

Changes

  • Added MintInfo Class
  • Replaced GetInfoResponse with MintInfo

PR Tasks

  • Open PR
  • run npm run test --> no failing unit tests
  • run npm run format

src/model/MintInfo.ts Outdated Show resolved Hide resolved
import { GetInfoResponse, MPPMethod, SwapMethod, WebSocketSupport } from './types';

export class MintInfo {
private readonly mintInfo: GetInfoResponse;
Copy link
Collaborator

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?

Copy link
Collaborator

@gudnuf gudnuf left a 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) {

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.

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants