-
Notifications
You must be signed in to change notification settings - Fork 635
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
Swaps: fix handling of native currency formatting/presentation #5826
Conversation
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.
Comments inline
…@benisgold/swaps-native-currency
/** | ||
* @desc convert from amount value to display formatted string | ||
*/ | ||
export const convertAmountToNativeDisplayWorklet = ( |
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.
does this converts or just formats?
also I always get confused on what native means, my instinct is that native is the network native gas token like eth, but sometimes we use it as the user preferred 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.
just formats. i kept the preexisting name for this util
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 agree it's very confusing. we use this terminology in both ways across the app
src/__swaps__/utils/numbers.ts
Outdated
@@ -176,12 +177,10 @@ export const convertAmountToNativeAmount = (amount: BigNumberish, priceUnit: Big | |||
export const convertAmountAndPriceToNativeDisplay = ( |
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.
given that convertAmountAndPriceToNativeDisplay
and convertAmountAndPriceToNativeDisplayWithThreshold
are now basically the same with just the useThreshold
arg being different, can we do the same and consolidate these or make a ticket to do this as clean up (ideally we would also convert the args to an object while we're at 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.
what's the policy on putting args in an object or not
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'll go ahead and approve, but yeah the padding for nativeCurrency == eth is kinda weird with padding zeroes. Minor nitpick.
…@benisgold/swaps-native-currency
8d403f4
to
72d52b8
Compare
…@benisgold/swaps-native-currency
niceIncrement: initialNiceIncrement, | ||
percentageToSwap: 0.5, | ||
sliderXPosition: SLIDER_WIDTH / 2, | ||
stripSeparators: true, | ||
isStablecoin, | ||
}); | ||
|
||
const initialInputNativeValue = toFixedWorklet(mulWorklet(initialInputAmount, initialSelectedInputAsset?.price?.value ?? 0), 2); | ||
const nativeCurrency = store.getState().settings.nativeCurrency; |
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.
any reason we can't just use convertAmountAndPriceToNativeDisplay
here?
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 don't want to include the denomination here
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.
🌮
…@benisgold/swaps-native-currency
…o brody/swap-v2-e2e * 'brody/swap-v2-e2e' of github.com:rainbow-me/rainbow: Revert "Lint on pre-commit (#5836)" (#5849) Lint on pre-commit (#5836) Swaps: fix handling of native currency formatting/presentation (#5826) Android crash fix from BlurView (#5844) Fix favorites nuances (#5846) fix quoted decimals issue (#5847)
Fixes APP-1346
What changed (plus any additional context for devs)
convertAmountToNativeDisplay
andconvertAmountToNativeDisplayWithThreshold
toLocaleStringPolyfill
shim since it's broken and no longer neededScreen recordings / screenshots
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-06-07.at.15.44.50.mp4
What to test