From 0c7a127116b5a833a8c5a2f6f76c4d081c9e2758 Mon Sep 17 00:00:00 2001 From: Michael Piazza Date: Sun, 18 Oct 2020 21:59:32 -0700 Subject: [PATCH 1/4] Prevent sending to self --- .../artist-dashboard-page/WalletModal.tsx | 13 ++++++++---- .../components/SendInputBody.tsx | 21 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/containers/artist-dashboard-page/WalletModal.tsx b/src/containers/artist-dashboard-page/WalletModal.tsx index 7b57eca4e2..6157cf2fc2 100644 --- a/src/containers/artist-dashboard-page/WalletModal.tsx +++ b/src/containers/artist-dashboard-page/WalletModal.tsx @@ -151,6 +151,10 @@ const ModalContent = ({ if (!modalState || !account) return null + // @ts-ignore + // TODO: user models need to have wallets + const wallet = account.wallet as WalletAddress + // This silly `ret` dance is to satisfy // TS's no-fallthrough rule... let ret: Nullable = null @@ -172,9 +176,6 @@ const ModalContent = ({ break } case 'RECEIVE': { - // @ts-ignore - // TODO: users need to have wallets... - const wallet = account.wallet ret = break } @@ -183,7 +184,11 @@ const ModalContent = ({ switch (sendStage.stage) { case 'INPUT': ret = ( - + ) break case 'AWAITING_CONFIRMATION': diff --git a/src/containers/artist-dashboard-page/components/SendInputBody.tsx b/src/containers/artist-dashboard-page/components/SendInputBody.tsx index 4c5cbea8be..92ec537357 100644 --- a/src/containers/artist-dashboard-page/components/SendInputBody.tsx +++ b/src/containers/artist-dashboard-page/components/SendInputBody.tsx @@ -35,6 +35,7 @@ const messages = { amountMalformed: 'Amount must be a valid number', addressMalformed: 'Please enter a valid address', addressRequired: 'Address is required', + addressIsSelf: 'Address can not be your own', sendAmountLabel: 'Amount to SEND', destination: 'Destination Address' } @@ -44,7 +45,7 @@ type BalanceError = | 'INSUFFICIENT_TRANSFER_AMOUNT' | 'EMPTY' | 'MALFORMED' -type AddressError = 'MALFORMED' | 'EMPTY' +type AddressError = 'MALFORMED' | 'EMPTY' | 'SEND_TO_SELF' const balanceErrorMap: { [B in BalanceError]: string } = { INSUFFICIENT_BALANCE: messages.insufficientBalance, @@ -55,12 +56,14 @@ const balanceErrorMap: { [B in BalanceError]: string } = { const addressErrorMap: { [A in AddressError]: string } = { MALFORMED: messages.addressMalformed, - EMPTY: messages.addressRequired + EMPTY: messages.addressRequired, + SEND_TO_SELF: messages.addressIsSelf } type SendInputBodyProps = { currentBalance: BNWei onSend: (balance: BNWei, destinationAddress: WalletAddress) => void + wallet: WalletAddress } const isValidDestination = (wallet: WalletAddress) => { @@ -68,9 +71,13 @@ const isValidDestination = (wallet: WalletAddress) => { return libs.web3Manager.web3.utils.isAddress(wallet) } -const validateWallet = (wallet: Nullable): Nullable => { +const validateWallet = ( + wallet: Nullable, + ownWallet: WalletAddress +): Nullable => { if (!wallet) return 'EMPTY' if (!isValidDestination(wallet)) return 'MALFORMED' + if (wallet.toLowerCase() === ownWallet.toLowerCase()) return 'SEND_TO_SELF' return null } @@ -108,7 +115,11 @@ const parseAudioInputToWei = (audio: StringAudio): Nullable => { } } -const SendInputBody = ({ currentBalance, onSend }: SendInputBodyProps) => { +const SendInputBody = ({ + currentBalance, + onSend, + wallet +}: SendInputBodyProps) => { const [amountToSend, setAmountToSend] = useState( '' as StringAudio ) @@ -129,7 +140,7 @@ const SendInputBody = ({ currentBalance, onSend }: SendInputBodyProps) => { const onClickSend = () => { const balanceError = validateSendAmount(amountToSend, currentBalance) - const walletError = validateWallet(destinationAddress) + const walletError = validateWallet(destinationAddress, wallet) setBalanceError(balanceError) setAddressError(walletError) if (balanceError || walletError) return From 1182b964df3be7c81235dea6bf47447bc74a242e Mon Sep 17 00:00:00 2001 From: Michael Piazza Date: Sun, 18 Oct 2020 22:03:39 -0700 Subject: [PATCH 2/4] Link to discord --- src/containers/artist-dashboard-page/Tiles.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/containers/artist-dashboard-page/Tiles.tsx b/src/containers/artist-dashboard-page/Tiles.tsx index 44d8b188d8..d9a32caae6 100644 --- a/src/containers/artist-dashboard-page/Tiles.tsx +++ b/src/containers/artist-dashboard-page/Tiles.tsx @@ -26,6 +26,8 @@ import { } from 'store/token-dashboard/slice' import TokenHoverTooltip from './components/TokenHoverTooltip' +const DISCORD_URL = 'https://discord.com/invite/kZkT9ZK' + const messages = { claimCTA: 'CLAIM $AUDIO', noClaim1: 'You earn $AUDIO by using Audius.', @@ -146,7 +148,7 @@ export const ExplainerTile = ({ className }: { className?: string }) => { const featureChart = hasAudio ? featureChartLevel1 : featureChartLevel0 const disabled = { [styles.disabled]: !hasAudio } const onClickVipDiscord = useCallback(() => { - alert('todo') + window.open(DISCORD_URL, '_blank') }, []) return ( From 3cc90b7719c8f5837baa41e6cac3fa980ef8de51 Mon Sep 17 00:00:00 2001 From: Michael Piazza Date: Sun, 18 Oct 2020 22:18:40 -0700 Subject: [PATCH 3/4] Fix rewards graphic sizing issue --- src/containers/artist-dashboard-page/Tiles.module.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containers/artist-dashboard-page/Tiles.module.css b/src/containers/artist-dashboard-page/Tiles.module.css index b7aed9bdaf..331a151f7c 100644 --- a/src/containers/artist-dashboard-page/Tiles.module.css +++ b/src/containers/artist-dashboard-page/Tiles.module.css @@ -123,7 +123,7 @@ /* Explainer Tile */ .explainerTile { - height: 520px; + min-height: 520px; background-color: var(--white); display: inline-flex; flex-direction: row; @@ -155,6 +155,7 @@ flex-direction: column; align-items: flex-start; padding: 32px 72px 0px 0px; + margin-bottom: 74px; } .whatIsAudio { From 5ae47c69d48fa8f0b1c84f45cbacee57172a9d66 Mon Sep 17 00:00:00 2001 From: Michael Piazza Date: Sun, 18 Oct 2020 22:36:00 -0700 Subject: [PATCH 4/4] Fix nav header button colors --- src/containers/nav/desktop/NavHeader.module.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containers/nav/desktop/NavHeader.module.css b/src/containers/nav/desktop/NavHeader.module.css index caf56b4d82..61641e0e88 100644 --- a/src/containers/nav/desktop/NavHeader.module.css +++ b/src/containers/nav/desktop/NavHeader.module.css @@ -48,15 +48,15 @@ svg.logo path { } .dashboardIcon { - background-color: var(--accent-orange); + background-color: var(--accent-orange-light-1); } .dashboardIcon svg path { - fill: var(--white) !important; + fill: var(--static-white) !important; } .dashboardIcon:hover:not(:global(.active)) { - background-color: var(--accent-orange-light-1) !important; + background-color: var(--accent-orange) !important; } .headerIconWrapper:global(.active),