Skip to content

Commit

Permalink
Merge branch 'next' into feat/oeth-withdrawal
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Aug 1, 2024
2 parents 5c5f83b + 08230f8 commit 52034fb
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 221 deletions.
Empty file removed .github/workflows/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const MyVotingPowerCard = (props: CardProps) => {
const votingPowerPercent = toNumber(
div(
[BigInt(info?.votingPower ?? 0), tokens.mainnet.xOGN.decimals],
[xOgnTotalSupply, tokens.mainnet.xOGN.decimals],
[xOgnTotalSupply ?? 1n, tokens.mainnet.xOGN.decimals],
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const ProposalsCountCard = (props: CardProps) => {
token: tokens.mainnet.xOGN.address,
chainId: tokens.mainnet.xOGN.chainId,
},
{ select: (data) => data?.erc20HoldersConnection?.totalCount },
{ select: (data) => data?.erc20HoldersConnection?.totalCount ?? 0 },
);

const active =
proposals?.filter((p) =>
proposals?.filter?.((p) =>
[OgvProposalState.Active.toLowerCase()].includes(p.status.toLowerCase()),
)?.length ?? 0;

Expand Down
6 changes: 3 additions & 3 deletions libs/defi/ogn/src/staking/components/ExtendAddLockupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export const ExtendAddLockupModal = ({
<Typography>
{intl.formatNumber(
+formatUnits(
BigInt(lockup.amount),
BigInt(lockup?.amount ?? 0),
tokens.mainnet.OGN.decimals,
),
{
Expand All @@ -326,7 +326,7 @@ export const ExtendAddLockupModal = ({
<Typography>
{intl.formatNumber(
+formatUnits(
BigInt(lockup.points) ?? 0n,
BigInt(lockup?.points ?? 0),
tokens.mainnet.xOGN.decimals,
) /
+formatUnits(
Expand Down Expand Up @@ -523,7 +523,7 @@ export const ExtendAddLockupModal = ({
votingPowerPercent <= 1e-6 && votingPowerPercent > 0
? `~ `
: '',
value: intl.formatNumber(votingPowerPercent, {
value: intl.formatNumber(votingPowerPercent ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 5,
Expand Down
9 changes: 6 additions & 3 deletions libs/defi/ogn/src/staking/components/LockupsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export const LockupsTable = () => {
header: intl.formatMessage({ defaultMessage: 'OGN' }),
cell: (info) =>
intl.formatNumber(
+formatUnits(BigInt(info.getValue()), tokens.mainnet.OGN.decimals),
+formatUnits(
BigInt(info.getValue() ?? 0),
tokens.mainnet.OGN.decimals,
),
{
minimumFractionDigits: 0,
maximumFractionDigits: 0,
Expand Down Expand Up @@ -95,7 +98,7 @@ export const LockupsTable = () => {
cell: (info) =>
intl.formatNumber(
+formatUnits(
BigInt(info.getValue()),
BigInt(info.getValue() ?? 0),
tokens.mainnet.xOGN.decimals,
),
{
Expand All @@ -116,7 +119,7 @@ export const LockupsTable = () => {
>
{intl.formatNumber(
+formatUnits(
BigInt(info.getValue()) ?? 0n,
BigInt(info.getValue() ?? 0),
tokens.mainnet.xOGN.decimals,
) /
+formatUnits(
Expand Down
9 changes: 6 additions & 3 deletions libs/defi/ogn/src/staking/components/StakeRewardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export const StakeRewardModal = (props: DialogProps) => {
: '',
value:
amount > 0n
? intl.formatNumber(votingPowerPercent, {
? intl.formatNumber(votingPowerPercent ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 5,
Expand Down Expand Up @@ -621,7 +621,10 @@ function LockupSelect({
header: intl.formatMessage({ defaultMessage: 'OGN' }),
cell: (info) =>
intl.formatNumber(
+formatUnits(BigInt(info.getValue()), tokens.mainnet.OGN.decimals),
+formatUnits(
BigInt(info.getValue() ?? 0),
tokens.mainnet.OGN.decimals,
),
{
minimumFractionDigits: 0,
maximumFractionDigits: 0,
Expand All @@ -643,7 +646,7 @@ function LockupSelect({
cell: (info) =>
intl.formatNumber(
+formatUnits(
BigInt(info.getValue()) ?? 0n,
BigInt(info.getValue() ?? 0),
tokens.mainnet.xOGN.decimals,
) /
+formatUnits(
Expand Down
2 changes: 1 addition & 1 deletion libs/defi/ogn/src/staking/components/StakingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export const StakingForm = () => {
votingPowerPercent <= 1e-6 && votingPowerPercent > 0
? `~ `
: '',
value: intl.formatNumber(votingPowerPercent, {
value: intl.formatNumber(votingPowerPercent ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 5,
Expand Down
4 changes: 2 additions & 2 deletions libs/defi/ogn/src/staking/components/UnstakeLockupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const UnstakeLockupModal = ({
<Typography>
{intl.formatNumber(
+formatUnits(
BigInt(lockup.amount),
BigInt(lockup.amount ?? 0),
tokens.mainnet.OGN.decimals,
),
{
Expand All @@ -160,7 +160,7 @@ export const UnstakeLockupModal = ({
</Typography>
<Typography>{formatTimeRemaining(lockup.end)}</Typography>
<LoadingLabel isLoading={isPreviewOgnLoading}>
{intl.formatNumber(penaltyPercent, {
{intl.formatNumber(penaltyPercent ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 2,
Expand Down
2 changes: 1 addition & 1 deletion libs/defi/ogn/src/staking/components/VotingPowerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const VotingPowerCard = (props: CardProps) => {
defaultMessage: '{tilt}{value}',
},
{
value: intl.formatNumber(percent, {
value: intl.formatNumber(percent ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 5,
Expand Down
6 changes: 4 additions & 2 deletions libs/defi/ogv/src/migration/components/ConvertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export const ConvertModal = ({
>
<Collapse orientation="horizontal" in={!ratioOpen}>
<Typography mr={0.75}>
{intl.formatNumber(stakingRatio / 100, {
{intl.formatNumber((stakingRatio ?? 0) / 100, {
style: 'percent',
})}
</Typography>
Expand All @@ -267,7 +267,9 @@ export const ConvertModal = ({
fontWeight="bold"
color="primary.main"
>
{intl.formatNumber(stakingRatio / 100, { style: 'percent' })}
{intl.formatNumber((stakingRatio ?? 0) / 100, {
style: 'percent',
})}
</Typography>
<Slider
value={stakingRatio}
Expand Down
6 changes: 4 additions & 2 deletions libs/defi/ogv/src/migration/components/MigrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function SummaryCard({ ogv, convertProps, ...rest }: SummaryCardProps) {
const intl = useIntl();

const converted =
+formatUnits(ogv, tokens.mainnet.OGV.decimals) * ogvToOgnRate;
+formatUnits(ogv ?? 0n, tokens.mainnet.OGV.decimals) * ogvToOgnRate;

return (
<Card {...rest}>
Expand All @@ -379,7 +379,9 @@ function SummaryCard({ ogv, convertProps, ...rest }: SummaryCardProps) {
spacing={1}
>
<Typography variant="featured2" fontWeight="bold">
{intl.formatNumber(+formatUnits(ogv, tokens.mainnet.OGV.decimals))}
{intl.formatNumber(
+formatUnits(ogv ?? 0n, tokens.mainnet.OGV.decimals),
)}
</Typography>
<TokenChip
token={tokens.mainnet.OGV}
Expand Down
2 changes: 1 addition & 1 deletion libs/defi/shared/src/components/TokenInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const TokenInput = forwardRef<HTMLInputElement, TokenInputProps>(
flexGrow={1}
color={amount === 0n ? 'text.secondary' : 'text.primary'}
>
{intl.formatNumber(+formatUnits(amount, decimals), {
{intl.formatNumber(+formatUnits(amount ?? 0n, decimals), {
roundingMode: 'floor',
minimumFractionDigits: 0,
maximumFractionDigits: 8,
Expand Down
8 changes: 4 additions & 4 deletions libs/shared/providers/src/intl/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useFormat = () => {
zeroPlaceholder = '0.00',
options?: FormatNumberOptions,
) => {
if (!amount || amount === 0n) return zeroPlaceholder;
if (!amount || amount === 0n || amount === 0) return zeroPlaceholder;

const amt =
typeof amount === 'bigint' ? +formatUnits(amount, decimals) : amount;
Expand All @@ -55,7 +55,7 @@ export const useFormat = () => {
zeroPlaceholder = '0.00',
options?: FormatNumberOptions,
) => {
if (!amount || amount === 0n) return zeroPlaceholder;
if (!amount || amount === 0n || amount === 0) return zeroPlaceholder;

const amt =
typeof amount === 'bigint' ? +formatUnits(amount, decimals) : amount;
Expand All @@ -76,7 +76,7 @@ export const useFormat = () => {
zeroPlaceholder = '$0.00',
options?: FormatNumberOptions,
) => {
if (!amount || amount === 0n) return zeroPlaceholder;
if (!amount || amount === 0n || amount === 0) return zeroPlaceholder;

const amt =
typeof amount === 'bigint' ? +formatUnits(amount, decimals) : amount;
Expand All @@ -100,7 +100,7 @@ export const useFormat = () => {
zeroPlaceholder = '0.00',
options?: FormatNumberOptions,
) => {
if (!amount || amount === 0n) return zeroPlaceholder;
if (!amount || amount === 0n || amount === 0) return zeroPlaceholder;

const amt =
typeof amount === 'bigint' ? +formatUnits(amount, decimals) : amount;
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/providers/src/wagmi/components/BalanceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function BalanceRow({
{isBalanceLoading ? (
<Skeleton width={38} />
) : (
intl.formatNumber(balance, {
intl.formatNumber(balance ?? 0, {
minimumFractionDigits: 4,
maximumFractionDigits: 4,
})
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,5 @@
"vite-plugin-static-copy": "^1.0.6",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "~4.3.1"
},
"engines": {
"node": "20",
"npm": "9"
}
}
Loading

0 comments on commit 52034fb

Please sign in to comment.