Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/SendToken.js
import React, { useState, useEffect } from 'react'; | import React, { useState, useEffect } from 'react'; | ||||
import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||
import { WalletContext } from '@utils/context'; | import { WalletContext } from '@utils/context'; | ||||
import { | import { | ||||
Form, | Form, | ||||
notification, | notification, | ||||
message, | message, | ||||
Row, | Row, | ||||
Col, | Col, | ||||
Alert, | Alert, | ||||
Descriptions, | Descriptions, | ||||
} from 'antd'; | } from 'antd'; | ||||
import Paragraph from 'antd/lib/typography/Paragraph'; | |||||
import PrimaryButton, { | import PrimaryButton, { | ||||
SecondaryButton, | SecondaryButton, | ||||
} from '@components/Common/PrimaryButton'; | } from '@components/Common/PrimaryButton'; | ||||
import { | import { | ||||
FormItemWithMaxAddon, | FormItemWithMaxAddon, | ||||
FormItemWithQRCodeAddon, | FormItemWithQRCodeAddon, | ||||
} from '@components/Common/EnhancedInputs'; | } from '@components/Common/EnhancedInputs'; | ||||
import useBCH from '@hooks/useBCH'; | import useBCH from '@hooks/useBCH'; | ||||
Show All 9 Lines | import { | ||||
parseAddress, | parseAddress, | ||||
isValidTokenPrefix, | isValidTokenPrefix, | ||||
} from '@components/Common/Ticker.js'; | } from '@components/Common/Ticker.js'; | ||||
import { Event } from '@utils/GoogleAnalytics'; | import { Event } from '@utils/GoogleAnalytics'; | ||||
import { | import { | ||||
getWalletState, | getWalletState, | ||||
convertEtokenToSimpleledger, | convertEtokenToSimpleledger, | ||||
} from '@utils/cashMethods'; | } from '@utils/cashMethods'; | ||||
import { TokenReceivedNotificationIcon } from '@components/Common/CustomIcons'; | |||||
import ApiError from '@components/Common/ApiError'; | import ApiError from '@components/Common/ApiError'; | ||||
import { sendTokenNotification } from '../../hooks/Notifications'; | |||||
const SendToken = ({ tokenId, jestBCH, passLoadingStatus }) => { | const SendToken = ({ tokenId, jestBCH, passLoadingStatus }) => { | ||||
const { wallet, apiError } = React.useContext(WalletContext); | const { wallet, apiError } = React.useContext(WalletContext); | ||||
const walletState = getWalletState(wallet); | const walletState = getWalletState(wallet); | ||||
const { tokens, slpBalancesAndUtxos } = walletState; | const { tokens, slpBalancesAndUtxos } = walletState; | ||||
const token = tokens.find(token => token.tokenId === tokenId); | const token = tokens.find(token => token.tokenId === tokenId); | ||||
const [tokenStats, setTokenStats] = useState(null); | const [tokenStats, setTokenStats] = useState(null); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | async function submit() { | ||||
try { | try { | ||||
const link = await sendToken(BCH, wallet, slpBalancesAndUtxos, { | const link = await sendToken(BCH, wallet, slpBalancesAndUtxos, { | ||||
tokenId: tokenId, | tokenId: tokenId, | ||||
tokenReceiverAddress: cleanAddress, | tokenReceiverAddress: cleanAddress, | ||||
amount: value, | amount: value, | ||||
}); | }); | ||||
notification.success({ | sendTokenNotification(); | ||||
bytesofman: need to pass the `link` param i.e. `sendTokenNotification(link)` | |||||
message: 'Success', | |||||
description: ( | |||||
<a href={link} target="_blank" rel="noopener noreferrer"> | |||||
<Paragraph> | |||||
Transaction successful. Click to view in block | |||||
explorer. | |||||
</Paragraph> | |||||
</a> | |||||
), | |||||
duration: 3, | |||||
icon: <TokenReceivedNotificationIcon />, | |||||
style: { width: '100%' }, | |||||
}); | |||||
} catch (e) { | } catch (e) { | ||||
passLoadingStatus(false); | passLoadingStatus(false); | ||||
let message; | let message; | ||||
if (!e.error && !e.message) { | if (!e.error && !e.message) { | ||||
message = `Transaction failed: no response from ${getRestUrl()}.`; | message = `Transaction failed: no response from ${getRestUrl()}.`; | ||||
} else if ( | } else if ( | ||||
/Could not communicate with full node or other external service/.test( | /Could not communicate with full node or other external service/.test( | ||||
▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines |
need to pass the link param i.e. sendTokenNotification(link)