Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Strip network prefix from the Address when calling EthHashInfo (#3037)
Browse files Browse the repository at this point in the history
* Strip network prefix from the Address when calling EthHashInfo

* Do not use chain prefix for TxHash and SafeTxHash in the Tx List
  • Loading branch information
DiogoSoaress committed Nov 23, 2021
1 parent 38ab408 commit 6809c9d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/components/PrefixedEthHashInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ReactElement } from 'react'
import { useSelector } from 'react-redux'
import { copyShortNameSelector, showShortNameSelector } from 'src/logic/appearance/selectors'
import { extractShortChainName } from 'src/routes/routes'
import getAddressWithoutNetworkPrefix from 'src/utils/getAddressWithoutNetworkPrefix'

type Props = Omit<Parameters<typeof EthHashInfo>[0], 'shouldShowShortName' | 'shouldCopyShortName'>

Expand All @@ -12,7 +13,7 @@ const PrefixedEthHashInfo = ({ hash, ...rest }: Props): ReactElement => {

return (
<EthHashInfo
hash={hash}
hash={getAddressWithoutNetworkPrefix(hash)}
shortName={extractShortChainName()}
shouldShowShortName={showChainPrefix}
shouldCopyShortName={copyChainPrefix}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getExplorerInfo } from 'src/config'
import { formatDateTime } from 'src/utils/date'
import { Transaction } from 'src/logic/safe/store/models/types/gateway.d'
import { NOT_AVAILABLE } from './utils'
import { PrefixedInlineEthHashInfo, TxDetailsContainer } from './styled'
import { InlineEthHashInfo, TxDetailsContainer } from './styled'
import { Creation } from '@gnosis.pm/safe-react-gateway-sdk'
import { useKnownAddress } from './hooks/useKnownAddress'
import PrefixedEthHashInfo from 'src/components/PrefixedEthHashInfo'
Expand Down Expand Up @@ -34,7 +34,7 @@ export const TxInfoCreation = ({ transaction }: { transaction: Transaction }): R
<Text size="xl" strong as="span">
Transaction hash:{' '}
</Text>
<PrefixedInlineEthHashInfo
<InlineEthHashInfo
textSize="xl"
hash={txInfo.transactionHash}
shortenHash={8}
Expand Down
12 changes: 3 additions & 9 deletions src/routes/safe/components/Transactions/TxList/TxSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactElement } from 'react'
import { getExplorerInfo } from 'src/config'
import { formatDateTime } from 'src/utils/date'
import { ExpandedTxDetails, isMultiSigExecutionDetails } from 'src/logic/safe/store/models/types/gateway.d'
import { PrefixedInlineEthHashInfo } from './styled'
import { InlineEthHashInfo } from './styled'
import { NOT_AVAILABLE } from './utils'

export const TxSummary = ({ txDetails }: { txDetails: ExpandedTxDetails }): ReactElement => {
Expand All @@ -22,13 +22,7 @@ export const TxSummary = ({ txDetails }: { txDetails: ExpandedTxDetails }): Reac
Transaction hash:{' '}
</Text>
{txHash ? (
<PrefixedInlineEthHashInfo
textSize="xl"
hash={txHash}
shortenHash={8}
showCopyBtn
explorerUrl={explorerUrl}
/>
<InlineEthHashInfo textSize="xl" hash={txHash} shortenHash={8} showCopyBtn explorerUrl={explorerUrl} />
) : (
<Text size="xl" as="span">
{NOT_AVAILABLE}
Expand All @@ -40,7 +34,7 @@ export const TxSummary = ({ txDetails }: { txDetails: ExpandedTxDetails }): Reac
<Text size="xl" strong as="span">
SafeTxHash:{' '}
</Text>
<PrefixedInlineEthHashInfo textSize="xl" hash={safeTxHash} shortenHash={8} showCopyBtn />
<InlineEthHashInfo textSize="xl" hash={safeTxHash} shortenHash={8} showCopyBtn />
</div>
)}
{nonce !== undefined && (
Expand Down
5 changes: 2 additions & 3 deletions src/routes/safe/components/Transactions/TxList/styled.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Text, Accordion, AccordionDetails, AccordionSummary } from '@gnosis.pm/safe-react-components'
import { Text, Accordion, AccordionDetails, AccordionSummary, EthHashInfo } from '@gnosis.pm/safe-react-components'
import styled, { css } from 'styled-components'
import PrefixedEthHashInfo from 'src/components/PrefixedEthHashInfo'

export const Wrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -467,7 +466,7 @@ export const OwnerListItem = styled.li`
}
`

export const PrefixedInlineEthHashInfo = styled(PrefixedEthHashInfo)`
export const InlineEthHashInfo = styled(EthHashInfo)`
display: inline-flex;
span {
Expand Down

0 comments on commit 6809c9d

Please sign in to comment.