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: Rarity endpoints return prices field with prices in various currencies #500

Merged
merged 15 commits into from
May 9, 2022

Conversation

fzavalia
Copy link
Contributor

@fzavalia fzavalia commented Apr 20, 2022

Closes #490

@fzavalia
Copy link
Contributor Author

@coveralls
Copy link

coveralls commented Apr 20, 2022

Pull Request Test Coverage Report for Build 2295822557

  • 38 of 48 (79.17%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 69.903%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Rarity/utils.ts 6 16 37.5%
Totals Coverage Status
Change from base Build 2283497350: 0.1%
Covered Lines: 2550
Relevant Lines: 3506

💛 - Coveralls

@fzavalia fzavalia force-pushed the feat/rarity-endpoints-in-mana-converted branch from deeede0 to 1b148eb Compare May 2, 2022 20:15
@fzavalia fzavalia marked this pull request as ready for review May 3, 2022 18:49
Comment on lines +90 to +101
return {
id: rarity.name,
name: rarity.name,
price: rarity.price.toString(),
maxSupply: rarity.maxSupply.toString(),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we return the currency of the price. If inUSD is not set, it's not clear which is the currency it's returning the price.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you suggest adding another field such as currency: 'mana' | 'usd' to distinguish?

return collectionAPI.fetchRarities()
}

const inUSD = req.query.inUSD === 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we name this query parameter currency? We can later have different conversions if we want to.

Suggested change
const inUSD = req.query.inUSD === 'true'
const inUSD = req.query.currency === 'usd'

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 like that!

})
})

// TODO: Tests for when rarities feature flag is enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests are missing here :)

@fzavalia
Copy link
Contributor Author

fzavalia commented May 6, 2022

@LautaroPetaccio Thanks for the feedback!

  • Added missing tests.
  • Change query param to currency (defaults to MANA).
  • Returned rarities also include a currency field indicating in what currency the price is in.

@fzavalia fzavalia force-pushed the feat/rarity-endpoints-in-mana-converted branch from 08ab436 to c9ebf41 Compare May 9, 2022 12:24
@fzavalia
Copy link
Contributor Author

fzavalia commented May 9, 2022

@LautaroPetaccio
No more currency query param, now both the price in MANA and USD will be returned as "price" (MANA), "originalPrice" (USD).
This allows the frontend to only make only 1 request to the server instead of 2 as well as keeping the logic simpler.

Comment on lines 47 to 49
price: blockchainRarity.price,
originalPrice: graphRarity.price,
originalCurrency: Currency.USD,
Copy link
Contributor

Choose a reason for hiding this comment

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

As "Original" as name might be a bit confusing, what if we change this to a map?

As a map:

price: {
'MANA': '4000000000000000000',
'USD': '10000000000000000000'
}

@fzavalia fzavalia changed the title feat: Rarity endpoints can return price converted from USD to MANA feat: Rarity endpoints return prices field with prices in various currencies May 9, 2022
@fzavalia
Copy link
Contributor Author

fzavalia commented May 9, 2022

@LautaroPetaccio Replaced "original" fields with "prices" field containing a Record of Currency -> Price

@fzavalia fzavalia merged commit f5becde into master May 9, 2022
@fzavalia fzavalia deleted the feat/rarity-endpoints-in-mana-converted branch May 9, 2022 19:34
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.

/rarities should return converted rarity prices
3 participants