Commit e9f784b2 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

refactor: clean up getExplorerLink helper fn (#7537)

parent f9a94695
...@@ -4,6 +4,8 @@ const BLOCK_EXPLORER_PREFIXES: { [chainId: number]: string } = { ...@@ -4,6 +4,8 @@ const BLOCK_EXPLORER_PREFIXES: { [chainId: number]: string } = {
[ChainId.MAINNET]: 'https://etherscan.io', [ChainId.MAINNET]: 'https://etherscan.io',
[ChainId.GOERLI]: 'https://goerli.etherscan.io', [ChainId.GOERLI]: 'https://goerli.etherscan.io',
[ChainId.SEPOLIA]: 'https://sepolia.etherscan.io', [ChainId.SEPOLIA]: 'https://sepolia.etherscan.io',
[ChainId.ARBITRUM_ONE]: 'https://arbiscan.io',
[ChainId.ARBITRUM_GOERLI]: 'https://goerli.arbiscan.io',
[ChainId.OPTIMISM]: 'https://optimistic.etherscan.io', [ChainId.OPTIMISM]: 'https://optimistic.etherscan.io',
[ChainId.OPTIMISM_GOERLI]: 'https://goerli-optimism.etherscan.io', [ChainId.OPTIMISM_GOERLI]: 'https://goerli-optimism.etherscan.io',
[ChainId.POLYGON]: 'https://polygonscan.com', [ChainId.POLYGON]: 'https://polygonscan.com',
...@@ -30,34 +32,6 @@ export enum ExplorerDataType { ...@@ -30,34 +32,6 @@ export enum ExplorerDataType {
* @param type the type of the data * @param type the type of the data
*/ */
export function getExplorerLink(chainId: number, data: string, type: ExplorerDataType): string { export function getExplorerLink(chainId: number, data: string, type: ExplorerDataType): string {
if (chainId === ChainId.ARBITRUM_ONE) {
switch (type) {
case ExplorerDataType.TRANSACTION:
return `https://arbiscan.io/tx/${data}`
case ExplorerDataType.ADDRESS:
case ExplorerDataType.TOKEN:
return `https://arbiscan.io/address/${data}`
case ExplorerDataType.BLOCK:
return `https://arbiscan.io/block/${data}`
default:
return `https://arbiscan.io/`
}
}
if (chainId === ChainId.ARBITRUM_GOERLI) {
switch (type) {
case ExplorerDataType.TRANSACTION:
return `https://goerli.arbiscan.io/tx/${data}`
case ExplorerDataType.ADDRESS:
case ExplorerDataType.TOKEN:
return `https://goerli.arbiscan.io/address/${data}`
case ExplorerDataType.BLOCK:
return `https://goerli.arbiscan.io/block/${data}`
default:
return `https://goerli.arbiscan.io/`
}
}
const prefix = BLOCK_EXPLORER_PREFIXES[chainId] ?? 'https://etherscan.io' const prefix = BLOCK_EXPLORER_PREFIXES[chainId] ?? 'https://etherscan.io'
switch (type) { switch (type) {
...@@ -68,9 +42,6 @@ export function getExplorerLink(chainId: number, data: string, type: ExplorerDat ...@@ -68,9 +42,6 @@ export function getExplorerLink(chainId: number, data: string, type: ExplorerDat
return `${prefix}/token/${data}` return `${prefix}/token/${data}`
case ExplorerDataType.BLOCK: case ExplorerDataType.BLOCK:
if (chainId === ChainId.OPTIMISM || chainId === ChainId.OPTIMISM_GOERLI) {
return `${prefix}/tx/${data}`
}
return `${prefix}/block/${data}` return `${prefix}/block/${data}`
case ExplorerDataType.ADDRESS: case ExplorerDataType.ADDRESS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment