Skip to content

Commit

Permalink
🪄 [QA] Update stage environments (#693)
Browse files Browse the repository at this point in the history
This is a pull request that upon merging will update stage environments
with recent `main` changes.
The environments that will be updated:
* Stage live: https://stage-live--taho-development.netlify.app/
* Stage fork: https://stage-fork--taho-development.netlify.app/

Read more: [Deployment to Production
Flow](https://github.com/tahowallet/dapp/blob/main/docs/testing-env.md)
  • Loading branch information
andreachapman authored Nov 14, 2023
2 parents 616bf07 + 297637d commit 203afd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/shared/components/TokenAmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default function TokenAmountInput({
<div>
{label && (
<div className="label">{`${label} ${bigIntToDisplayUserAmount(
balance
balance,
18,
5
)} ${symbol}`}</div>
)}
<SharedInput
Expand All @@ -88,7 +90,7 @@ export default function TokenAmountInput({
isDisabled={disabled}
onMouseDown={(event) => {
event.preventDefault()
onChange(bigIntToUserAmount(balance))
onChange(bigIntToUserAmount(balance, 18, 18))
}}
>
Max
Expand Down
14 changes: 10 additions & 4 deletions src/shared/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import { FixedPointNumber } from "shared/types/stake"
const FLOATING_POINT_REGEX = /^[^0-9]*([0-9,]+)(?:\.([0-9]*))?$/

export const separateThousandsByComma = (
value: number | bigint | string
value: number | bigint | string,
decimals = 2
): string => {
const adjustedValue = typeof value === "string" ? +value : value
return adjustedValue.toLocaleString("en-US", { maximumFractionDigits: 2 })
return adjustedValue.toLocaleString("en-US", {
// @ts-expect-error - `maximumFractionDigits` wants to get number less than 21,
// but as the tokens have 18 decimals have, we can safely pass a parameter
maximumFractionDigits: decimals < 21 ? decimals : 2,
})
}

function parseToFixedPointNumber(
Expand Down Expand Up @@ -81,7 +86,7 @@ export function bigIntToUserAmount(
desiredDecimals = 2
): string {
const desiredDecimalsAmount =
amount / 10n ** BigInt(Math.max(1, decimals - desiredDecimals))
amount / 10n ** BigInt(Math.max(0, decimals - desiredDecimals))

return (
Number(desiredDecimalsAmount) /
Expand All @@ -98,6 +103,7 @@ export function bigIntToDisplayUserAmount(
const amountBigInt = typeof amount === "string" ? BigInt(amount) : amount

return separateThousandsByComma(
bigIntToUserAmount(amountBigInt, decimals, desiredDecimals)
bigIntToUserAmount(amountBigInt, decimals, desiredDecimals),
desiredDecimals
)
}

0 comments on commit 203afd4

Please sign in to comment.