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

feat: add CurrencyAmount.{greaterThan,equalTo,lessThan} #53

Open
olehmisar opened this issue Jun 22, 2024 · 0 comments
Open

feat: add CurrencyAmount.{greaterThan,equalTo,lessThan} #53

olehmisar opened this issue Jun 22, 2024 · 0 comments

Comments

@olehmisar
Copy link

I am using sdk-core for my projects and safety checks on this.currency.equals(other.currency) for CurrencyAmount would be great. Something like this(you may want to omit | 0 but this is quite handy in practice)

class CurrencyAmount<T> {
  ...

  public greaterThan(other: CurrencyAmount<T> | 0): boolean {
    invariant(other === 0 || this.currency.equals(other.currency), "CURRENCY");
    return super.greaterThan(other);
  }
  
  public equalTo(other: CurrencyAmount<T> | 0): boolean {
    invariant(other === 0 || this.currency.equals(other.currency), "CURRENCY");
    return super.equalTo(other);
  }
  
  public lessThan(other: CurrencyAmount<T> | 0): boolean {
    invariant(other === 0 || this.currency.equals(other.currency), "CURRENCY");
    return super.lessThan(other);
  }
}
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

No branches or pull requests

1 participant