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

Commit

Permalink
Add support for token transfer links (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin authored Jan 26, 2022
1 parent 5ca9174 commit a715a40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/custom/components/EnhancedTransactionLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ExplorerDataType } from 'utils/getExplorerLink'

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

Expand Down Expand Up @@ -27,6 +25,6 @@ export function EnhancedTransactionLink(props: Props) {

return <GnosisSafeLink chainId={chainId} safeTransaction={safeTx} gnosisSafeThreshold={gnosisSafeInfo.threshold} />
} else {
return <ExplorerLink id={tx.hash} type={ExplorerDataType.TRANSACTION} />
return <ExplorerLink id={tx.hash} type="transaction" />
}
}
5 changes: 2 additions & 3 deletions src/custom/pages/Claim/ClaimingStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import { useClaimState } from 'state/claim/hooks'
import { useActiveWeb3React } from 'hooks/web3'
import CowProtocolLogo from 'components/CowProtocolLogo'
import { useAllClaimingTransactions } from 'state/enhancedTransactions/hooks'
import React, { useMemo } from 'react'
import { useMemo } from 'react'
import { Link } from 'react-router-dom'
import { ExplorerLink } from 'components/ExplorerLink'
import { EnhancedTransactionLink } from 'components/EnhancedTransactionLink'
import { ExplorerDataType } from 'utils/getExplorerLink'
import { V_COW } from 'constants/tokens'
import AddToMetamask from 'components/AddToMetamask'
import SVG from 'react-inlinesvg'
Expand Down Expand Up @@ -88,7 +87,7 @@ export default function ClaimingStatus() {
You have just claimed on behalf of{' '}
<b>
{activeClaimAccount} (
<ExplorerLink id={activeClaimAccount} type={ExplorerDataType.ADDRESS} />)
<ExplorerLink id={activeClaimAccount} type="token-transfer" />)
</b>
</p>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/custom/pages/Claim/InvestmentFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { ClaimCommonTypes, ClaimWithInvestmentData, EnhancedUserClaimData } from
import { COW_LINKS } from 'pages/Claim'
import { ExternalLink } from 'theme'
import { ExplorerLink } from 'components/ExplorerLink'
import { ExplorerDataType } from 'utils/getExplorerLink'

import { BadgeVariant } from 'components/Badge'
import { DollarSign, Icon, Send } from 'react-feather'
Expand Down Expand Up @@ -115,7 +114,7 @@ function AccountDetails({ label, account, connectedAccount, Icon }: AccountDetai
<Icon width={14} height={14} /> {label}:
</b>
<i>
<ExplorerLink id={account} label={account} type={ExplorerDataType.ADDRESS} />{' '}
<ExplorerLink id={account} label={account} type="address" />{' '}
{account === connectedAccount ? (
<Badge variant={BadgeVariant.POSITIVE}>&nbsp; Connected account</Badge>
) : (
Expand Down
7 changes: 6 additions & 1 deletion src/custom/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = {
100: 'xdai.',
}

export type BlockExplorerLinkType = 'transaction' | 'token' | 'address' | 'block'
export type BlockExplorerLinkType = 'transaction' | 'token' | 'address' | 'block' | 'token-transfer'

function getEtherscanUrl(chainId: ChainId, data: string, type: BlockExplorerLinkType): string {
const prefix = `https://${ETHERSCAN_PREFIXES[chainId] || ETHERSCAN_PREFIXES[1]}etherscan.io`
Expand All @@ -41,6 +41,9 @@ function getEtherscanUrl(chainId: ChainId, data: string, type: BlockExplorerLink
case 'block': {
return `${prefix}/block/${data}`
}
case 'token-transfer': {
return `${prefix}/address/${data}#tokentxns`
}
case 'address':
default: {
return `${prefix}/address/${data}`
Expand All @@ -66,6 +69,8 @@ function getBlockscoutUrlSuffix(type: BlockExplorerLinkType, data: string): stri
return `blocks/${data}/transactions`
case 'address':
return `address/${data}/transactions`
case 'token-transfer':
return `address/${data}/token-transfers`
case 'token':
return `tokens/${data}/token-transfers`
}
Expand Down

0 comments on commit a715a40

Please sign in to comment.