scaffold-eth / scaffold-eth-2

Open source forkable Ethereum dev stack
https://scaffoldeth.io
MIT License
1.34k stars 837 forks source link

feat: useDisplayUsdMode hook #859

Closed rin-st closed 4 months ago

rin-st commented 4 months ago

Description

Adds useDisplayUsdMode hook which helps to work with nativeCurrency/USD values.

Hook takes as parameter defaultUsdMode which sets an initial value, and returns { displayUsdMode, toggleDisplayUsdMode }. toggleDisplayUsdMode allows to change inner displayUsdMode, and displayUsdMode basically returns current USD mode.

defaultUsdMode and displayUsdMode variables are booleans. true means USD, false means Native Currency.

See discussion here

Note:

Additional Information

rin-st commented 4 months ago

Lol initally I was bit hesitant to have this hook in hooks/scaffold-eth since seem too specific to SE-2 internal use but then realised that we have hooks like useAnimateConfig etc too in their, not sure what the best place to keep this internal hooks but I think its fine for now !

I agree that the hooks folder is a little bit mess. Maybe in future create two folders like core (main hooks from docs) and internal/helpers/utils(all other hooks)?

technophile-04 commented 4 months ago

Niceee tysm @rin-st !!


Maybe in future create two folders like core (main hooks from docs) and internal/helpers/utils(all other hooks)?

Yup makes sense !