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

Add top gainers losers to token discovery service #5309

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Bigshmow
Copy link
Contributor

@Bigshmow Bigshmow commented Feb 11, 2025

Explanation

We're introducing methods that allow consumers to fetch top-gainers and top-losers from the portfolio api (ultimately via the Moralis service).

I've also consolidated some of the types in this PR so they are reusable and provided a base type inheritance.

References

Changelog

@metamask/package-a

  • Added: param types inherit from a ParamsBase

  • Added: getTopGainersByChains to the TokenDiscoveryApiService

  • Added: getTopLosersByChains to the TokenDiscoveryApiService

  • Changed: - BREAKING: Renamed TokenTrendingResponseItem name to MoralisTokenResponseItem

    • Consumer will get ts compilation errors after upgrading until they update their imports

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@Bigshmow Bigshmow marked this pull request as ready for review February 12, 2025 16:21
@Bigshmow Bigshmow requested review from a team as code owners February 12, 2025 16:21
GuiBibeau
GuiBibeau previously approved these changes Feb 12, 2025
Copy link

@GuiBibeau GuiBibeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a few proposals. Code looks great 👍

);
}

return response.json();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to validate the response in any way or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the validation but how do you feel about revisiting this in portfolio api first since it's closest to the server, and bad shapes would never even reach this point?
(this gives more credence to refactoring the error handling in the core repo you mention elsewhere)

@@ -16,7 +29,7 @@ export type TokenSearchResponseItem = {
logoUrl?: string;
};

export type TokenTrendingResponseItem = {
export type MoralisTokenResponseItem = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: this seems unrelated to a vanilla Response object and looks to be only the tokenItem. Adding Response into the name confuses me a bit and could lead people to think this includes status and other properties of an HTTP Response

https://developer.mozilla.org/en-US/docs/Web/API/Response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend dropping the ResponseItem portion all together to simply be MoralisToken? I like that too.

GuiBibeau
GuiBibeau previously approved these changes Feb 12, 2025
@Bigshmow Bigshmow enabled auto-merge (squash) February 12, 2025 21:56
…ithub.com:MetaMask/core into add-top-gainers-losers-to-token-discovery-service
@@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on adding more test coverage? When the thresholds are at 100, it makes it really easy to know what's untested because you can just look at the output of yarn test. When it's below 100, however, you end up having to guess or open the coverage report and manually search, which ends up being annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that a majority of packages here have their coverage set to 100. I think a more pragmatic 60-70% strikes a good balance between confidence and effort. Would you be willing to compromise on a level under 100 that still gives you confidence or is the 100% a dogma in your bones!

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