Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
e9f784b2
Unverified
Commit
e9f784b2
authored
Nov 02, 2023
by
Charles Bachmeier
Committed by
GitHub
Nov 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: clean up getExplorerLink helper fn (#7537)
parent
f9a94695
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
31 deletions
+2
-31
getExplorerLink.ts
src/utils/getExplorerLink.ts
+2
-31
No files found.
src/utils/getExplorerLink.ts
View file @
e9f784b2
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment