From 707c4fed40f0026b1f89a6bb61ed68e0a96bb4c5 Mon Sep 17 00:00:00 2001 From: Aaron Li Date: Sun, 29 Aug 2021 21:08:36 -0700 Subject: [PATCH] RequestPayment: fix bugs and cleanup --- code/client/src/integration/RequestPayment.jsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/code/client/src/integration/RequestPayment.jsx b/code/client/src/integration/RequestPayment.jsx index ef233150..51a51de5 100644 --- a/code/client/src/integration/RequestPayment.jsx +++ b/code/client/src/integration/RequestPayment.jsx @@ -3,7 +3,6 @@ import BN from 'bn.js' import AnimatedSection from '../components/AnimatedSection' import { AverageRow } from '../components/Grid' import { Hint } from '../components/Text' -import Paths from '../constants/paths' import React, { useState } from 'react' import { useSelector } from 'react-redux' import { SearchOutlined } from '@ant-design/icons' @@ -15,7 +14,6 @@ import { handleAddressError } from '../handler' import { HarmonyONE } from '../components/TokenAssets' const { Title, Text, Paragraph } = Typography const RequestPaymennt = ({ caller, callback, amount, dest, from }) => { - const history = useHistory() dest = util.safeNormalizedAddress(dest) const network = useSelector(state => state.wallet.network) const balances = useSelector(state => state.wallet.balances) @@ -27,12 +25,12 @@ const RequestPaymennt = ({ caller, callback, amount, dest, from }) => { const [selectedAddress, setSelectedAddress] = useState(from ? (selectedWallet || {}) : defaultUserAddress) const { formatted: amountFormatted, fiatFormatted: amountFiatFormatted } = util.computeBalance(amount, price) const [showSend, setShowSend] = useState(false) - const checkCallback = () => { if (!callback) { message.error('The app did not specify a callback URL. Please contact the app developer.') return false } + return true } const next = () => { if (!selectedAddress.value) { @@ -40,7 +38,7 @@ const RequestPaymennt = ({ caller, callback, amount, dest, from }) => { } const normalizedAddress = util.safeExec(util.normalizedAddress, [selectedAddress.value], handleAddressError) if (!normalizedAddress) { - return + return message.error(`normalizedAddress=${normalizedAddress}`) } const balance = balances[selectedAddress.value] if (!(new BN(amount).lte(new BN(balance)))) { @@ -77,8 +75,11 @@ const RequestPaymennt = ({ caller, callback, amount, dest, from }) => { {from && !selectedWallet && - The app wants you to pay from address - However, you do not have that address. Please go back to the app, and choose an 1wallet address that you own. If you do own that 1wallet address but it is not appearing in your wallets, you need restore the wallet first using "Restore" feature with your Google Authenticator. + + The app wants you to pay from address: + + However, you do not have that 1wallet address. Please go back to the app, and choose an 1wallet address that you own. If you do own that 1wallet address but it is not appearing in your wallets, you need restore the wallet first using "Restore" feature with your Google Authenticator. + } {from && selectedWallet && @@ -146,7 +147,7 @@ const RequestPaymennt = ({ caller, callback, amount, dest, from }) => { {showSend && } )