Browse Source

Merge pull request #368 from gre/fix-tx-url

link to explorers for more coins
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
61ffe2eaf7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/components/modals/OperationDetails.js
  2. 18
      src/helpers/explorers.js

17
src/components/modals/OperationDetails.js

@ -7,6 +7,7 @@ import { translate } from 'react-i18next'
import styled from 'styled-components'
import moment from 'moment'
import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/helpers/operation'
import { getTxURL } from 'helpers/explorers'
import type { Account, Operation } from '@ledgerhq/live-common/lib/types'
import type { T, CurrencySettings } from 'types/common'
@ -69,12 +70,15 @@ type Props = {
const OperationDetails = connect(mapStateToProps)((props: Props) => {
const { t, onClose, operation, account, marketColor, currencySettings } = props
const { id, hash, date, senders, recipients, type } = operation
const { hash, date, senders, recipients, type } = operation
const amount = getOperationAmountNumber(operation)
const { name, unit, currency } = account
const confirmations = operation.blockHeight ? account.blockHeight - operation.blockHeight : 0
const isConfirmed = confirmations >= currencySettings.confirmationsNb
const url = getTxURL(account, operation)
return (
<ModalBody onClose={onClose}>
<ModalTitle>Operation details</ModalTitle>
@ -145,12 +149,11 @@ const OperationDetails = connect(mapStateToProps)((props: Props) => {
</ModalContent>
<ModalFooter horizontal justify="flex-end" flow={2}>
<Button onClick={onClose}>Cancel</Button>
<Button
primary
onClick={() => shell.openExternal(`https://testnet.blockchain.info/tx/${id}`)}
>
View operation
</Button>
{url ? (
<Button primary onClick={() => shell.openExternal(url)}>
View operation
</Button>
) : null}
</ModalFooter>
</ModalBody>
)

18
src/helpers/explorers.js

@ -0,0 +1,18 @@
// @flow
import type { Account, Operation } from '@ledgerhq/live-common/lib/types'
const txExplorers: { [_: string]: (Operation) => string } = {
bitcoin_cash: op => `https://bitcoincash.blockexplorer.com/tx/${op.hash}`,
bitcoin_gold: op => `https://btgexplorer.com/tx/${op.hash}`,
bitcoin_testnet: op => `https://testnet.blockchain.info/tx/${op.hash}`,
bitcoin: op => `https://blockchain.info/tx/${op.hash}`,
ethereum_testnet: op => `https://ropsten.etherscan.io/tx/${op.hash}`,
ethereum: op => `https://etherscan.io/tx/${op.hash}`,
ripple: op => `https://bithomp.com/explorer/${op.hash}`,
zcash: op => `https://explorer.zcha.in/transactions/${op.hash}`,
}
export const getTxURL = (account: Account, operation: Operation): ?string => {
const f = txExplorers[account.currency.id]
return f ? f(operation) : null
}
Loading…
Cancel
Save