Skip to content

Market data: Poloniex to Coingecko - #475

Open
curupo wants to merge 3 commits into
NemProject:devfrom
curupo:feat/market-data-ploniex-to-coingecko
Open

Market data: Poloniex to Coingecko#475
curupo wants to merge 3 commits into
NemProject:devfrom
curupo:feat/market-data-ploniex-to-coingecko

Conversation

@curupo

@curupo curupo commented Jul 29, 2026

Copy link
Copy Markdown

No description provided.

Comment thread nanowallet/src/app/utils/marketData.js Outdated
* BTC_XEM ticker this replaces (highestBid, baseVolume, percentChange
* as a fraction) so existing consumers don't need to change.
*
* Cached for CACHE_TTL_MS to stay within CoinGecko's public API rate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be acceptable to remove the cache if it is included only for rate-limit protection.

CoinGecko’s keyless Public API uses IP-based rate limiting, and these requests are made directly from each user’s wallet, so users generally do not share one central server quota. Market data is also requested only during connection or manual refresh.

Comment thread nanowallet/src/app/utils/marketData.js Outdated
@@ -0,0 +1,80 @@
/** @module utils/marketData */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think marketData.js would be more suitable under the services directory as src/app/services/marketData.service.js, because it performs HTTP requests.

it can then be registered in services/index.js and injected into DataBridge and MarketDataCtrl instead of being imported directly.

@AnthonyLaw

Copy link
Copy Markdown
Contributor

Great work! I’ve left a few comments on the PR. Please don’t forget to add tests as well. 🙏🏼

@curupo

curupo commented Jul 30, 2026

Copy link
Copy Markdown
Author

Thanks for the review.
I've addressed the points you raised.
What do you think?

@AnthonyLaw AnthonyLaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work!

return response.json();
}).then((json) => {
let nemData = json && json.nem;
if (!nemData || typeof nemData.btc !== 'number') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I recommend you check another field as well.
Those fields might return null.

typeof nemData.btc_24h_vol !== 'number' ||
typeof nemData.btc_24h_change !== 'number'

done();
});

it('should fall back to the last successfully fetched data when a later request fails', async (done) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This unit test failed.
You might check again.

done();
});

it('should always request fresh data instead of short-circuiting on a previous value', async (done) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This unit test failed.
You might check again.

* On fetch failure, falls back to the last successfully fetched value
* (even if stale), rather than erroring out, if one is available.
*
* @return {Promise} - Resolves with a {highestBid, baseVolume, percentChange} object

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can make the return type more explicit by documenting the resolved object shape:

/**

  • @returns {Promise<{
  • highestBid: number,
  • baseVolume: number,
  • percentChange: number
  • }>} Market data shaped like the former Poloniex response.
    */

@curupo

curupo commented Aug 1, 2026

Copy link
Copy Markdown
Author

Thanks for the review.
Testing was insufficient. I apologize.

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.

2 participants