Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Create new tx link component
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Jan 24, 2022
1 parent 3ef286b commit 08c73f4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
32 changes: 32 additions & 0 deletions src/custom/components/EnhancedTransactionLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ExplorerDataType } from 'utils/getExplorerLink'

import { ExplorerLink } from 'components/ExplorerLink'
import { GnosisSafeLink } from 'components/AccountDetails/Transaction/StatusDetails'

import { EnhancedTransactionDetails, HashType } from 'state/enhancedTransactions/reducer'
import { useWalletInfo } from 'hooks/useWalletInfo'

interface Props {
tx: EnhancedTransactionDetails
}

/**
* Creates a link to the relevant explorer: Etherscan, GP Explorer or Blockscout, or Gnosis Safe web if its a Gnosis Safe Transaction
* @param props
*/
export function EnhancedTransactionLink(props: Props) {
const { tx } = props
const { chainId, gnosisSafeInfo } = useWalletInfo()

if (tx.hashType === HashType.GNOSIS_SAFE_TX) {
const safeTx = tx.safeTransaction

if (!chainId || !safeTx || !gnosisSafeInfo) {
return null
}

return <GnosisSafeLink chainId={chainId} safeTransaction={safeTx} gnosisSafeThreshold={gnosisSafeInfo.threshold} />
} else {
return <ExplorerLink id={tx.hash} type={ExplorerDataType.TRANSACTION} />
}
}
7 changes: 2 additions & 5 deletions src/custom/pages/Claim/ClaimingStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { useActiveWeb3React } from 'hooks/web3'
import CowProtocolLogo from 'components/CowProtocolLogo'
import { useAllClaimingTransactions } from 'state/enhancedTransactions/hooks'
import { useMemo } from 'react'
import { ExplorerLink } from 'components/ExplorerLink'
import { ExplorerDataType } from 'utils/getExplorerLink'
import { EnhancedTransactionLink } from 'components/EnhancedTransactionLink'
// import { formatSmartLocationAware } from 'utils/format'

export default function ClaimingStatus() {
Expand Down Expand Up @@ -69,9 +68,7 @@ export default function ClaimingStatus() {
</p>
</AttemptFooter>
)}
{isSubmitted && chainId && lastClaimTx?.hash && (
<ExplorerLink id={lastClaimTx.hash} type={ExplorerDataType.TRANSACTION} />
)}
{isSubmitted && chainId && lastClaimTx?.hash && <EnhancedTransactionLink tx={lastClaimTx} />}
</ConfirmOrLoadingWrapper>
)
}

0 comments on commit 08c73f4

Please sign in to comment.