mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
Explorer links - add toggle for lowercase hash (#2766)
This commit is contained in:
+6
-2
@@ -333,9 +333,13 @@ Settings for meta tags, OG tags and SEO
|
||||
| logo | `string` | URL to explorer logo file. Should be at least 40x40. | - | - | `'https://foo.app/icon.png'` |
|
||||
| title | `string` | Displayed name of the explorer | Required | - | `Anyblock` |
|
||||
| baseUrl | `string` | Base url of the explorer | Required | - | `https://explorer.anyblock.tools` |
|
||||
| paths | `Record<'tx' \| 'block' \| 'address' \| 'token', string>` | Map of explorer entities and their paths | Required | - | `{'tx':'/ethereum/poa/core/tx'}` |
|
||||
| paths | `Record<'tx' \| 'block' \| 'address' \| 'token', string>` | Map of explorer entities and their paths. Path can be a template with `:id` or `:id_lowercase` param, or a string (see note below) | Required | - | `{'tx':'/ethereum/poa/core/tx'}` |
|
||||
|
||||
*Note* If a path template contains `:id` or `:id_lowercase`, it will be replaced with the entity-id in its original case or lowercased respectively. If neither parameter is present, the entity-id will be appended to the end of the path in lowercase. For example, with baseUrl `https://explorer.anyblock.tools`:
|
||||
- Path `{'tx':'/ethereum/poa/core/tx/:id/details'}` and entity-id `0x123...AbC` results in `https://explorer.anyblock.tools/ethereum/poa/core/tx/0x123...AbC/details`
|
||||
- Path `{'tx':'/ethereum/poa/core/tx/:id_lowercase/details'}` and entity-id `0x123...AbC` results in `https://explorer.anyblock.tools/ethereum/poa/core/tx/0x123...abc/details`
|
||||
- Path `{'tx':'/ethereum/poa/core/tx'}` and entity-id `0x123...AbC` results in `https://explorer.anyblock.tools/ethereum/poa/core/tx/0x123...abc`
|
||||
|
||||
*Note* The url of an entity will be constructed as `<baseUrl><paths[<entity-type>]><entity-id>`, e.g `https://explorer.anyblock.tools/ethereum/poa/core/tx/<tx-id>`
|
||||
|
||||
#### Contract code IDE configuration properties
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ const AddressPageContent = () => {
|
||||
<SolidityscanReport hash={ hash }/> }
|
||||
{ !isLoading && addressEnsDomainsQuery.data && config.features.nameService.isEnabled &&
|
||||
<AddressEnsDomains query={ addressEnsDomainsQuery } addressHash={ hash } mainDomainName={ addressQuery.data?.ens_domain_name }/> }
|
||||
<NetworkExplorers type="address" pathParam={ hash.toLowerCase() }/>
|
||||
<NetworkExplorers type="address" pathParam={ hash }/>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
|
||||
@@ -21,7 +21,16 @@ const NetworkExplorers = ({ className, type, pathParam }: Props) => {
|
||||
return config.UI.explorers.items
|
||||
.filter((explorer) => typeof explorer.paths[type] === 'string')
|
||||
.map((explorer) => {
|
||||
const url = new URL(stripTrailingSlash(explorer.paths[type] || '') + '/' + pathParam, explorer.baseUrl);
|
||||
const path = explorer.paths[type] || '';
|
||||
let pathWithParam;
|
||||
if (path.includes(':id_lowercase')) {
|
||||
pathWithParam = path.replace(':id_lowercase', pathParam.toLowerCase());
|
||||
} else if (path.includes(':id')) {
|
||||
pathWithParam = path.replace(':id', pathParam);
|
||||
} else {
|
||||
pathWithParam = stripTrailingSlash(path) + '/' + pathParam.toLowerCase();
|
||||
}
|
||||
const url = new URL(pathWithParam, explorer.baseUrl);
|
||||
return (
|
||||
<Link external h="34px" key={ explorer.baseUrl } href={ url.toString() } alignItems="center" display="inline-flex" minW="120px">
|
||||
{ explorer.logo ?
|
||||
|
||||
@@ -132,7 +132,7 @@ const TokenPageTitle = ({ tokenQuery, addressQuery, hash }: Props) => {
|
||||
<AccountActionsMenu isLoading={ isLoading }/>
|
||||
<Flex ml={{ base: 0, lg: 'auto' }} columnGap={ 2 } flexGrow={{ base: 1, lg: 0 }}>
|
||||
<TokenVerifiedInfo verifiedInfoQuery={ verifiedInfoQuery }/>
|
||||
<NetworkExplorers type="token" pathParam={ addressHash.toLowerCase() } ml={{ base: 'auto', lg: 0 }}/>
|
||||
<NetworkExplorers type="token" pathParam={ addressHash } ml={{ base: 'auto', lg: 0 }}/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user