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 utility code for NFT Features #4256
feat: Add utility code for NFT Features #4256
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@zzmp will own reviewing this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The
png
s andsvg
s should be added with the appropriate PR, not as part of utility code, unless they are directly referenced by utility code. - The
ttf
s are redundant - we already include Inter in public/fonts/Inter-roman.var.woff2. privacy.pdf
should probably not be included. I don't see anything linking to it.
(these are just initial comments - I'll give this a more thorough review tomorrow AM)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of the packages that you've added are not yet used, or are already used implicitly and do not need to be explicitly added. They should not be added until they are actually used, even if it makes the subsequent PRs a little more cumbersome. Adding them all at once risks adding no-longer used packages, and makes it harder to review and ensure that our dependencies are being pinned correctly (and that no malicious dependencies or version skew gets through).
Please remove these packages from the package.json
, and then re-checkout the lockfile and re-install the files to regenerate it: git checkout main yarn.lock
.
- @babel/runtime
- @testing-library/react-hooks
- @types/react-table
- tslib
- @react-spring/web
- @use-gesture/react
- color.js
- deepmerge
- html2canvas
- overlayscrollbars
- overlayscrollbars-react
- query-string
- react-country-flag
- react-error-overlay
- react-infinite-scroll-component
- react-merge-refs
- react-meta-tags
- react-player
- react-select
- react-tilty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've still got to go through src/nft/utils/
and the yarn.lock
.
src/lib/hooks/useCurrencyBalance.ts
Outdated
@@ -141,3 +141,6 @@ export default function useCurrencyBalance( | |||
useMemo(() => [currency], [currency]) | |||
)[0] | |||
} | |||
|
|||
export const useCurrencyBalanceString = (account: string): string => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following other naming conventions in this file, this should be useNativeCurrencyBalance(account: string): CurrencyAmount<Currency> | undefined
.
You should defer converting it to a string until it is used, so that it is passed around as a more usable CurrencyAmount
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This utility function was named and recommended by Connor in this PR https://github.com/Uniswap/interface-nft/pull/4#discussion_r907469235
reset?: keyof JSX.IntrinsicElements | ||
} | ||
|
||
export const atoms = ({ reset, ...rest }: Atoms) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document what reset
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used by the Box
component when declaring the component as something other than a div
. It's should only be used for that specific purpose https://github.com/Uniswap/interface-nft/blob/main/src/nft/components/Box.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of the utils use hard-coded english strings. What is the plan for i18n/l10n?
Will nft features use lingui? Have they been using something else?
return isNaN(d) ? false : true | ||
} | ||
|
||
export const getTimeDifference = (eventTimestamp: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not internationalized. Why not use a library for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have no yet started the work for internationalization for NFT components. For procedurally generated text such as getting time difference in either days, hours, or minutes is there a standard practice? When it is tackled which I believe is outside of the scope of this PR, should we return a Trans component in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either return a trans component, or use a library which deals with internationalizing date/time strings. I believe we already use such a library in places like governance.
|
||
export const fetchPrice = async (currency: Currency = Currency.ETH): Promise<number | undefined> => { | ||
try { | ||
const response = await fetch(`https://api.coinbase.com/v2/exchange-rates?currency=${currency}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but it seems strange to go to coinbase for this price when the global app checks it from uniswap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we retrieved current price on Genie. For the sake of V0 and the scope of this ticket would it be fine if we keep this and add it as tech debt to replace and refactor where it is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - you should make a low-priority jira ticket to document the tech debt (same with i18n work).
@@ -0,0 +1,5 @@ | |||
export const roundAndPluralize = (i: number, word: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work with internationalization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll be tackling internationalization in a later sprint. When we do, will we not be able to have any kind of generalized behaviour helper function here or will we just need to use a conditional for the full word?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will not be able to use a helper function, you'll need to use the i18n libraries (lingui) to deal with pluralization.
@@ -0,0 +1,24 @@ | |||
import { roundAndPluralize } from './roundAndPluralize' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work with i10n.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll be tackling internationalization in a later sprint.
The lockfile changes were too large to comment on, so I updated them locally and pushed the changes to this branch. |
7db6fed
to
d5c9f21
Compare
@@ -0,0 +1,16 @@ | |||
export const buildSellObject = (amount: string) => { | |||
return { | |||
address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's effectively the same as the null address and it's what the genieswap contract uses for buying with ETH. @azflin might be able to discuss this further if you have more questions on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix the issues the linter brought up before merging?
- src/nft/queries/genie/RouteFetcher.ts#L15 (
!==
instead of!=
) - src/nft/queries/openSea/OSCollectionsFetcher.ts#L7 (
===
instead of==
)
Adds in the utility code for NFT Features including: