From 673a542120c19cd024f609948cf5db22ad4da362 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Fri, 8 Feb 2019 14:46:45 +0100 Subject: [PATCH] feat: block explorer link in environment file --- .env | 3 +++ src/constants/index.js | 3 +++ src/scripts/utils.js | 14 ++++++++++- src/views/refund/refund.js | 7 ++++-- src/views/refund/steps/completeRefund.js | 6 +++-- src/views/swap/steps/sendTransaction.js | 30 ++++++++++-------------- 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/.env b/.env index 91c69cb..5a8e217 100644 --- a/.env +++ b/.env @@ -6,3 +6,6 @@ REACT_APP_BOLTZ_API=http://localhost:9001 # Network configurations REACT_APP_BITCOIN_NETWORK=bitcoinSimnet REACT_APP_LITECOIN_NETWORK=litecoinSimnet + +REACT_APP_BITCOIN_EXPLORER=https://blockstream.info/testnet/tx +REACT_APP_LITECOIN_EXPLORER=https://chain.so/tx/LTCTEST diff --git a/src/constants/index.js b/src/constants/index.js index ac1a537..309d797 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -4,3 +4,6 @@ export const boltzApi = process.env.REACT_APP_BOLTZ_API; export const bitcoinNetwork = Networks[process.env.REACT_APP_BITCOIN_NETWORK]; export const litecoinNetwork = Networks[process.env.REACT_APP_LITECOIN_NETWORK]; + +export const bitcoinExplorer = process.env.REACT_APP_BITCOIN_EXPLORER; +export const litecoinExplorer = process.env.REACT_APP_LITECOIN_EXPLORER; diff --git a/src/scripts/utils.js b/src/scripts/utils.js index dedf66d..46e6971 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -1,4 +1,9 @@ -import { bitcoinNetwork, litecoinNetwork } from '../constants'; +import { + bitcoinNetwork, + litecoinNetwork, + bitcoinExplorer, + litecoinExplorer, +} from '../constants'; // Number satohis and litoshis in a whole coin const decimals = 100000000; @@ -89,3 +94,10 @@ export const copyToClipBoard = () => { export const getNetwork = symbol => { return symbol === 'BTC' ? bitcoinNetwork : litecoinNetwork; }; + +/** + * Get the block explorer URL for a currency + */ +export const getExplorer = symbol => { + return symbol === 'BTC' ? bitcoinExplorer : litecoinExplorer; +}; diff --git a/src/views/refund/refund.js b/src/views/refund/refund.js index c1f9f55..9ee5a39 100644 --- a/src/views/refund/refund.js +++ b/src/views/refund/refund.js @@ -28,7 +28,7 @@ const uploadRefundFileText = (refundFile, txHash) => { if (Object.keys(refundFile).length === 0) { return 'Upload refund file'; } else if (txHash === '') { - return 'Input transaction hash'; + return 'Paste transaction hash'; } }; @@ -85,7 +85,10 @@ const Refund = ({ ( - + )} /> diff --git a/src/views/refund/steps/completeRefund.js b/src/views/refund/steps/completeRefund.js index 30ee228..5b9bceb 100644 --- a/src/views/refund/steps/completeRefund.js +++ b/src/views/refund/steps/completeRefund.js @@ -2,6 +2,7 @@ import React from 'react'; import injectSheet from 'react-jss'; import PropTypes from 'prop-types'; import View from '../../../components/view'; +import { getExplorer } from '../../../scripts/utils'; import { FaCheckCircle } from 'react-icons/fa'; const CompleteRefundStyles = theme => ({ @@ -29,13 +30,13 @@ const CompleteRefundStyles = theme => ({ }, }); -const StyledCompleteRefund = ({ classes, refundTransactionHash }) => ( +const StyledCompleteRefund = ({ classes, currency, refundTransactionHash }) => ( Success!

@@ -48,6 +49,7 @@ const StyledCompleteRefund = ({ classes, refundTransactionHash }) => ( StyledCompleteRefund.propTypes = { classes: PropTypes.object.isRequired, + currency: PropTypes.string.isRequired, refundTransactionHash: PropTypes.string.isRequired, }; diff --git a/src/views/swap/steps/sendTransaction.js b/src/views/swap/steps/sendTransaction.js index 91852d0..cf4bedd 100644 --- a/src/views/swap/steps/sendTransaction.js +++ b/src/views/swap/steps/sendTransaction.js @@ -3,11 +3,7 @@ import PropTypes from 'prop-types'; import injectSheet from 'react-jss'; import View from '../../../components/view'; import QrCode from '../../../components/qrcode'; -import { - getCurrencyName, - toWholeCoins, - copyToClipBoard, -} from '../../../scripts/utils'; +import { toWholeCoins, copyToClipBoard } from '../../../scripts/utils'; const SendTransactionStyles = () => ({ wrapper: { @@ -62,9 +58,7 @@ const StyledSendTransaction = ({ classes, swapInfo, swapResponse }) => ( {' '} {toWholeCoins(swapResponse.expectedAmount)} {swapInfo.base}{' '} {' '} -
- on {getCurrencyName(swapInfo.base)}
- blockchain address: + to this address:

{swapResponse.address} @@ -72,15 +66,17 @@ const StyledSendTransaction = ({ classes, swapInfo, swapResponse }) => ( copyToClipBoard()}> Copy -

- If the address does not work with your wallet:
-
- use this tool - -

+ {swapInfo.base === 'LTC' ? ( +

+ If the address does not work with your wallet:
+ + use this tool + +

+ ) : null}
);