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