diff --git a/package.json b/package.json index 8babf44..6d3307c 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "tsconfig-paths": "^4.0.0", "typescript": "^4.6.3", "vite": "^2.9.9", + "vite-plugin-svgr": "^2.2.1", "vite-tsconfig-paths": "^3.5.0" }, "jest": { diff --git a/src/App.tsx b/src/App.tsx index 0ffbe04..f02d4da 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -51,18 +51,22 @@ const App = () => { }, []); useEffect(() => { - window.addEventListener("keplr_keystorechange", - async () => { - await connectAccount(KEPLR_LEDGER) - return - }); - //@ts-ignore - window.cosmostation.cosmos.on("accountChanged", - async () => { - await connectAccount(COSMOSTATION_LEDGER) - return - }); + if (window.keplr) { + window.addEventListener("keplr_keystorechange", + async () => { + await connectAccount(KEPLR_LEDGER) + return + }); + } + + if (window.cosmostation) { + window.cosmostation.cosmos.on("accountChanged", + async () => { + await connectAccount(COSMOSTATION_LEDGER) + return + }); + } }, [connectAccount]) diff --git a/src/assets/vectors/discord.svg b/src/assets/vectors/discord.svg new file mode 100644 index 0000000..23c64ec --- /dev/null +++ b/src/assets/vectors/discord.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/facebook.svg b/src/assets/vectors/facebook.svg new file mode 100644 index 0000000..e174951 --- /dev/null +++ b/src/assets/vectors/facebook.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/linkedin.svg b/src/assets/vectors/linkedin.svg new file mode 100644 index 0000000..43e7921 --- /dev/null +++ b/src/assets/vectors/linkedin.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/medium.svg b/src/assets/vectors/medium.svg new file mode 100644 index 0000000..c6e951f --- /dev/null +++ b/src/assets/vectors/medium.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/spotify.svg b/src/assets/vectors/spotify.svg new file mode 100644 index 0000000..129c9a2 --- /dev/null +++ b/src/assets/vectors/spotify.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/telegram.svg b/src/assets/vectors/telegram.svg new file mode 100644 index 0000000..78c8cd8 --- /dev/null +++ b/src/assets/vectors/telegram.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/twitter.svg b/src/assets/vectors/twitter.svg new file mode 100644 index 0000000..193f090 --- /dev/null +++ b/src/assets/vectors/twitter.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/vectors/youtube.svg b/src/assets/vectors/youtube.svg new file mode 100644 index 0000000..4991062 --- /dev/null +++ b/src/assets/vectors/youtube.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/Dialog/AddressBook/AddAddressButtons.tsx b/src/components/Dialog/AddressBook/AddAddressButtons.tsx index ee63adb..b6c4ef7 100644 --- a/src/components/Dialog/AddressBook/AddAddressButtons.tsx +++ b/src/components/Dialog/AddressBook/AddAddressButtons.tsx @@ -116,7 +116,8 @@ const AddAddressButtons = () => { if (!fail) { const newAddressBook = { ...addressBook, [userAddress]: userName } dispatch(updateUser({ - addressBook: newAddressBook + addressBook: newAddressBook, + newAddedAddress: userAddress })) const { address } = await getConnectedUserAddressAndName(connectedLedger!) diff --git a/src/components/Dialog/FundWallet/FundWallet.tsx b/src/components/Dialog/FundWallet/FundWallet.tsx index 2f1781f..9d12219 100644 --- a/src/components/Dialog/FundWallet/FundWallet.tsx +++ b/src/components/Dialog/FundWallet/FundWallet.tsx @@ -19,7 +19,7 @@ import AssetsTable from 'components/AssetsTable/AssetsTable' import { CancelRoundedIcon, ModalContainer } from '../styles' import { initialState as initialModalState } from 'store/modals' import { Box, Button, Input, Tooltip, Typography } from '@mui/material' -import { handleFullBalanceToPrecision, separateFractions } from 'utils/regexFormatting' +import { formatSendAmount, handleFullBalanceToPrecision, separateFractions } from 'utils/regexFormatting' import { getSigningClient } from 'utils/config' import { MultiSendUser } from 'utils/multiSendTableHelper' import { chainIDToAlias } from 'components/Layout/Networkinfo' @@ -33,6 +33,7 @@ import { GENERAL_FAILURE_MSG, GENERAL_FAILURE_TITLE, INSUFFICIENT_BALANCE, + MINIMUM_GAS_FEE, NATIVE_TOKEN_DENOM, WALLET_FUNDING_FAILURE_TITLE, WALLET_FUNDING_LOADING_TITLE, @@ -105,6 +106,7 @@ const FundWallet = () => { const generateFundWalletMsg = async () => { try { + await estimateFee() const { msg, fee } = await getFundWalletMsgAndFees() setMsg(msg) setFees(fee) @@ -221,13 +223,13 @@ const FundWallet = () => { } const maxingOut = () => { + if (new BigNumber(chosenBalance!.amount!).isLessThan(amountToAcudos(MINIMUM_GAS_FEE))) { + return + } + + const amount = formatSendAmount(chosenBalance!) + setAmountToSend(amount) setMaxOut(true) - const tempAmount = parseFloat(handleFullBalanceToPrecision( - chosenBalance!.amount!, - 2, - chosenBalance!.denom! - )) - setAmountToSend(tempAmount) } const isAdminTransfer = () => { @@ -290,6 +292,24 @@ const FundWallet = () => { ) } + const estimateFee = async () => { + const currentBalance = new BigNumber(chosenBalance!.amount!) + if (isAdminTransfer() || currentBalance.isLessThan(amountToAcudos(MINIMUM_GAS_FEE))) { + return + } + + let estimate = await getFundWalletMsgAndFees() + const fee = estimate.fee.amount[0].amount + const sendAmount = new BigNumber(amountToAcudos(amountToSend)) + if (currentBalance.isLessThan(sendAmount.plus(fee))) { + const sendAmountAfterFee = formatSendAmount({ + amount: sendAmount.minus(fee).toString(10), + denom: chosenBalance!.denom! + }) + setAmountToSend(sendAmountAfterFee) + } + } + return ( { } const maxingOut = () => { + if (new BigNumber(chosenBalance!.amount!).isLessThan(amountToAcudos(MINIMUM_GAS_FEE))) { + return + } + + const amount = formatSendAmount(chosenBalance!) + setAmountToSend(amount) setMaxOut(true) - const tempAmount = parseFloat(handleFullBalanceToPrecision( - chosenBalance!.amount!, - 2, - chosenBalance!.denom! - )) - setAmountToSend(tempAmount) } const isAdminTransfer = () => { @@ -258,7 +259,7 @@ const SingleSend = () => { neededFees.isLessThanOrEqualTo(cudosBalance) } - return new BigNumber(transferAmount).plus(neededFees).isLessThanOrEqualTo(accountBalance) + return new BigNumber(transferAmount).isLessThanOrEqualTo(accountBalance) } const getTooltip = (): string => { diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index 172e678..d309da2 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -1,18 +1,13 @@ import { Box, Grid, Typography } from '@mui/material' import { COLORS_DARK_THEME } from 'theme/colors' +import { FOOTER } from 'utils/constants' import { styles } from './styles' -const centerLinks = [ - { text: 'All rights reserved 2022', url: 'https://www.cudos.org/' }, - { text: 'cudos.org', url: 'https://www.cudos.org/' }, - { text: 'v.02.00', url: 'https://github.com/CudoVentures/cudos-multisig-v2' }, -] - const Footer = () => { return ( - - {centerLinks.map((link) => ( + + {FOOTER.LEFT_LINKS.map((link) => ( { ))} + + {FOOTER.RIGHT_LINKS.map((link) => ( + window.open(link.url, '_blank')?.focus()} + sx={({ palette }) => ({ + cursor: 'pointer', + color: palette.text.secondary, + '&:hover': { + color: palette.primary.main + } + })} + > + {link.icon} + + ))} + ) } -export default Footer \ No newline at end of file +export default Footer diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index cde4230..5269eec 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -1,12 +1,13 @@ import { Box } from '@mui/material' import Footer from './Footer' import Header from './Header' +import { styles } from './styles' const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => { return ( - +
- + {children}