Skip to content

Commit

Permalink
Merge pull request #45 from CudoVentures/cudos-dev
Browse files Browse the repository at this point in the history
Cudos dev
  • Loading branch information
maptuhec authored Nov 2, 2022
2 parents a6d8c7d + 2603fba commit c9667d3
Show file tree
Hide file tree
Showing 28 changed files with 3,062 additions and 3,201 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
26 changes: 15 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
3 changes: 3 additions & 0 deletions src/assets/vectors/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/linkedin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/spotify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/telegram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/vectors/youtube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/Dialog/AddressBook/AddAddressButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
34 changes: 27 additions & 7 deletions src/components/Dialog/FundWallet/FundWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -105,6 +106,7 @@ const FundWallet = () => {

const generateFundWalletMsg = async () => {
try {
await estimateFee()
const { msg, fee } = await getFundWalletMsgAndFees()
setMsg(msg)
setFees(fee)
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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 (
<MuiDialog
BackdropProps={defaultStyles.defaultBackDrop}
Expand Down
17 changes: 9 additions & 8 deletions src/components/Dialog/SingleSend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 { executeMsgs, getSingleSendMsgAndFees } from '../ReusableModal/helpers'
import { isValidCudosAddress } from 'utils/validation'
import { SelectFromAddrBookBtn, SelectFromAddrBookDropDown } from '../MultiSend/helperComponents'
Expand All @@ -32,6 +32,7 @@ import {
GENERAL_FAILURE_TITLE,
INSUFFICIENT_BALANCE,
INVALID_DATA_PROMPT_MSG,
MINIMUM_GAS_FEE,
NATIVE_TOKEN_DENOM,
PROPOSAL_CREATION_FAILURE_TITLE,
PROPOSAL_CREATION_LOADING_TITLE,
Expand Down Expand Up @@ -230,13 +231,13 @@ const SingleSend = () => {
}

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 = () => {
Expand All @@ -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 => {
Expand Down
35 changes: 26 additions & 9 deletions src/components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Box sx={styles.footerContainer} gap={6}>
<Box display="flex" alignItems="center">
{centerLinks.map((link) => (
<Box display="flex">
{FOOTER.LEFT_LINKS.map((link) => (
<Grid
item
key={link.text}
Expand Down Expand Up @@ -40,8 +35,30 @@ const Footer = () => {
</Grid>
))}
</Box>
<Box
alignItems="center"
display="flex"
gap={3}
sx={{ marginLeft: 'auto' }}
>
{FOOTER.RIGHT_LINKS.map((link) => (
<Grid
key={link.url}
onClick={() => window.open(link.url, '_blank')?.focus()}
sx={({ palette }) => ({
cursor: 'pointer',
color: palette.text.secondary,
'&:hover': {
color: palette.primary.main
}
})}
>
{link.icon}
</Grid>
))}
</Box>
</Box>
)
}

export default Footer
export default Footer
5 changes: 3 additions & 2 deletions src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Box style={{height: '96.5vh', width: '99.7vw', display: 'grid'}}>
<Box style={styles.layoutHolder}>
<Header />
<Box sx={{ padding: '0 1rem' }} flexGrow={1}>
<Box sx={{ overflow: 'auto', padding: '0 1rem' }} flexGrow={1}>
{children}
</Box>
<Footer />
Expand Down
27 changes: 17 additions & 10 deletions src/components/Layout/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@ import { styled, Box } from '@mui/material'
import theme from '../../theme'

export const styles = {
layoutHolder: {
height: '96.5vh',
width: '99.7vw',
display: 'grid',
alignContent: 'space-between'
},
anchorStyle: {
alignItems: 'center',
textDecoration: 'none',
alignItems: 'center',
textDecoration: 'none',
display: 'flex'
},
networkInfoHolder: {
width: 'max-content',
marginRight: '20px',
display: 'flex',
width: 'max-content',
marginRight: '20px',
display: 'flex',
alignItems: 'center'
},
avatarStyling: {
borderRadius: "0px",
width: '18px',
borderRadius: "0px",
width: '18px',
height: '18px'
},
menuContainer: {
Expand Down Expand Up @@ -53,7 +59,7 @@ export const styles = {
float: 'right',
fontSize: '14px',
height: '224px',
minWidth: '224px',
width: '100%',
fontWeight: '500',
display: 'flex',
borderRadius: '0px 0px 20px 20px',
Expand All @@ -75,12 +81,13 @@ export const styles = {
footerContainer: {
display: 'flex',
justifyContent: 'center',
alignItems: 'flex-end',
alignItems: 'center',
bottom: 0,
right: 0,
left: 0,
width: 'inherit',
padding: '20px 0 10px 0'
padding: '1rem 1rem 0 1rem',
marginBottom: '-20px'
}
} as const

Expand Down
Loading

0 comments on commit c9667d3

Please sign in to comment.