Tx decoding accreditation (#12918)
* feature: adding support for truffle and etherscan accreditation * Fix scss linting * fix styling and classnames * Switch font size to rem * Update ui/components/app/transaction-decoding/components/ui/accreditation/accreditation.component.js Co-authored-by: George Marshall <georgewrmarshall@gmail.com> * Update ui/components/app/transaction-decoding/components/ui/accreditation/index.scss Co-authored-by: George Marshall <georgewrmarshall@gmail.com> * Update ui/components/app/transaction-decoding/components/ui/accreditation/accreditation.component.js Co-authored-by: George Marshall <georgewrmarshall@gmail.com> * Update ui/components/app/transaction-decoding/components/ui/accreditation/accreditation.component.js Co-authored-by: George Marshall <georgewrmarshall@gmail.com> * Fix linting Co-authored-by: g. nicholas d'andrea <gnidan@trufflesuite.com> Co-authored-by: Dan J Miller <danjm.com@gmail.com> Co-authored-by: George Marshall <georgewrmarshall@gmail.com> Co-authored-by: g. nicholas d'andrea <gnidan@users.noreply.github.com>feature/default_network_editable
parent
9c5bc2ba6d
commit
a858b85899
@ -0,0 +1,70 @@ |
||||
import React, { useContext } from 'react'; |
||||
import { useSelector } from 'react-redux'; |
||||
import PropTypes from 'prop-types'; |
||||
import { getAccountLink } from '@metamask/etherscan-link'; |
||||
import { |
||||
getCurrentChainId, |
||||
getRpcPrefsForCurrentProvider, |
||||
} from '../../../../../../selectors'; |
||||
import { I18nContext } from '../../../../../../contexts/i18n'; |
||||
|
||||
import { TYPOGRAPHY } from '../../../../../../helpers/constants/design-system'; |
||||
|
||||
import Button from '../../../../../ui/button'; |
||||
import Typography from '../../../../../ui/typography'; |
||||
|
||||
const Accreditation = ({ fetchVia, address }) => { |
||||
const t = useContext(I18nContext); |
||||
const chainId = useSelector(getCurrentChainId); |
||||
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider); |
||||
const addressLink = getAccountLink(address, chainId, rpcPrefs); |
||||
|
||||
const AccreditationLink = () => { |
||||
return ( |
||||
<> |
||||
<Typography |
||||
variant={TYPOGRAPHY.H7} |
||||
className="accreditation__prefix" |
||||
boxProps={{ margin: 0 }} |
||||
> |
||||
{t('transactionDecodingAccreditationVerified')} |
||||
</Typography> |
||||
<Button |
||||
type="link" |
||||
className="accreditation__link" |
||||
onClick={() => { |
||||
global.platform.openTab({ |
||||
url: addressLink, |
||||
}); |
||||
}} |
||||
target="_blank" |
||||
rel="noopener noreferrer" |
||||
title={t('etherscanView')} |
||||
> |
||||
{fetchVia} |
||||
</Button> |
||||
<Typography variant={TYPOGRAPHY.H7} boxProps={{ margin: 0 }}> |
||||
{t('transactionDecodingAccreditationDecoded')} |
||||
</Typography> |
||||
</> |
||||
); |
||||
}; |
||||
|
||||
return ( |
||||
<div className="accreditation"> |
||||
<div className="accreditation__icon"> |
||||
<i className="fa fa-info-circle" /> |
||||
</div> |
||||
<div className="accreditation__info"> |
||||
<AccreditationLink /> |
||||
</div> |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
Accreditation.propTypes = { |
||||
fetchVia: PropTypes.string.isRequired, |
||||
address: PropTypes.string.isRequired, |
||||
}; |
||||
|
||||
export default Accreditation; |
@ -0,0 +1 @@ |
||||
export { default } from './accreditation.component'; |
@ -0,0 +1,23 @@ |
||||
.accreditation { |
||||
display: flex; |
||||
align-items: center; |
||||
margin-top: 8px; |
||||
|
||||
&__icon { |
||||
margin-right: 8px; |
||||
} |
||||
|
||||
&__info { |
||||
color: $ui-black; |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
} |
||||
|
||||
&__link.btn-link { |
||||
@include H7; |
||||
|
||||
padding: 0 4px; |
||||
width: auto; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue