// @flow
import React from 'react'
import Wrapper from './Wrapper'
import { getUrlForTx } from './helpers'

type PropsT = {
  hash: string,
  children?: Object,
  inline?: boolean,
  network?: 'main' | 'ropsten'
}

export default class Transaction extends React.PureComponent<PropsT> {
  render() {
    const { hash, children, network = 'main', ...linkAttributes } = this.props

    return (
      <Wrapper
        title={hash}
        target="_blank"
        {...linkAttributes}
        href={getUrlForTx(hash, { network })}
      >
        {children || hash}
      </Wrapper>
    )
  }
}
