Skip to content
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

Validate token decimals before send #219

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unstoppabledomains/ui-components",
"version": "0.0.51-browser-extension.5",
"version": "0.0.51-browser-extension.6",
"private": true,
"description": "An open and reusable suite of Unstoppable Domains management components",
"keywords": [
Expand Down
15 changes: 14 additions & 1 deletion packages/ui-components/src/components/Wallet/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,20 @@ const Send: React.FC<Props> = ({
};

const handleAmountChange = (value: string) => {
setAmount(value);
// validate an asset is selected
if (!accountAsset) {
return;
}

// normalize asset decimals if present
const normalizedValue = accountAsset.balance?.decimals
? `0.${value
.replaceAll('0.', '')
.slice(0, accountAsset.balance.decimals)}`
: value;

// use normalized value
setAmount(normalizedValue);
};

if (isLoading) {
Expand Down
3 changes: 0 additions & 3 deletions packages/ui-components/src/components/Wallet/Token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import type {Theme} from '@mui/material/styles';
import {useTheme} from '@mui/material/styles';
import numeral from 'numeral';
import React from 'react';
import {Line} from 'react-chartjs-2';
Expand Down Expand Up @@ -120,8 +119,6 @@ const Token: React.FC<Props> = ({
showGraph,
hideBalance,
}) => {
const theme = useTheme();

const {classes, cx} = useStyles({
palette: isOwner ? WalletPaletteOwner : WalletPalettePublic,
});
Expand Down
Loading