This repository was archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(batch-graph): add link to etherscan to nodes (#507)
* feat: add address and href fields to Account * refactor: move getExplorerUrl to src/utils * feat: add address to Account instances * feat:add href to account instances * feat: add href to node data * feat: change node label color on hover * feat: open node href on click * feat: reduce edge distance and make label auto rotate * fix: account.address is optional and can be undefined * feat: add node border on hover * fix: 🐛 add cursor pointer to graph (#509) * fix: 🐛 add cursor pointer to graph * fix: 🐛 rerender issue * fix: 🐛 missing hover states * fix: add invisible border to all nodes to avoid flickering on hover --------- Co-authored-by: Tukan van der Borgh <[email protected]>
- Loading branch information
1 parent
bbccc41
commit 9b2b2b8
Showing
10 changed files
with
94 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Network } from 'types' | ||
|
||
export type BlockExplorerLinkType = 'tx' | 'address' | 'contract' | 'token' | 'event' | ||
|
||
function getEtherscanUrlPrefix(networkId: Network): string { | ||
return !networkId || networkId === Network.MAINNET || networkId === Network.GNOSIS_CHAIN | ||
? '' | ||
: (Network[networkId] || '').toLowerCase() + '.' | ||
} | ||
|
||
function getEtherscanUrlSuffix(type: BlockExplorerLinkType, identifier: string): string { | ||
switch (type) { | ||
case 'tx': | ||
return `tx/${identifier}` | ||
case 'event': | ||
return `tx/${identifier}#eventlog` | ||
case 'address': | ||
return `address/${identifier}` | ||
case 'contract': | ||
return `address/${identifier}#code` | ||
case 'token': | ||
return `token/${identifier}` | ||
} | ||
} | ||
|
||
function getEtherscanUrl(host: string, networkId: number, type: BlockExplorerLinkType, identifier: string): string { | ||
return `https://${getEtherscanUrlPrefix(networkId)}${host}/${getEtherscanUrlSuffix(type, identifier)}` | ||
} | ||
|
||
export function getExplorerUrl(networkId: number, type: BlockExplorerLinkType, identifier: string): string { | ||
return networkId === Network.GNOSIS_CHAIN | ||
? getEtherscanUrl('gnosisscan.io', networkId, type, identifier) | ||
: getEtherscanUrl('etherscan.io', networkId, type, identifier) | ||
} |