Skip to content

Commit 76fec81

Browse files
zavodilclaude
andauthored
feat(explorer-selector): add Near Rocks explorer (#1366)
- Add Near Rocks as a new explorer option in the NEAR Explorer Selector (first position) - Support both mainnet (https://near.rocks) and testnet (https://testnet.near.rocks) - URL path mappings: /account/:id, /tx/:id, /block/:id - Update grid layout from 3 to 4 columns when Pikespeak is available Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7fe7617 commit 76fec81

File tree

3 files changed

+83
-3
lines changed

3 files changed

+83
-3
lines changed
Lines changed: 1 addition & 0 deletions
Loading

apps/explorer-selector/src/components/ExplorerSelector.tsx

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export default function ExplorerSelector() {
2323
const network = getNetworkId();
2424

2525
const config = {
26+
nearrocks:
27+
network === 'testnet'
28+
? 'https://testnet.near.rocks'
29+
: 'https://near.rocks',
2630
nearblocks:
2731
network === 'testnet'
2832
? 'https://testnet.nearblocks.io'
@@ -82,6 +86,27 @@ export default function ExplorerSelector() {
8286
}
8387
}
8488

89+
function getNearRocksHref(link: string) {
90+
if (link)
91+
switch (path) {
92+
case 'accounts':
93+
return config.nearrocks + '/account/' + value;
94+
case 'transactions':
95+
return config.nearrocks + '/tx/' + value;
96+
case 'blocks':
97+
return config.nearrocks + '/block/' + value;
98+
// WIP: receipts and stats are not yet available on Near Rocks
99+
case 'receipts':
100+
case 'stats':
101+
return null;
102+
default:
103+
return config.nearrocks;
104+
}
105+
else {
106+
return config.nearrocks;
107+
}
108+
}
109+
85110
function getNearblocksLiteHref(link: string) {
86111
if (link)
87112
switch (path) {
@@ -151,6 +176,27 @@ export default function ExplorerSelector() {
151176
return false;
152177
}
153178

179+
function linkNearRocks(link: string) {
180+
if (link)
181+
switch (path) {
182+
case '':
183+
return true;
184+
case 'accounts':
185+
return true;
186+
case 'transactions':
187+
return true;
188+
case 'blocks':
189+
return true;
190+
// WIP: receipts and stats are not yet available on Near Rocks
191+
case 'receipts':
192+
case 'stats':
193+
return false;
194+
default:
195+
return false;
196+
}
197+
return false;
198+
}
199+
154200
function linkNearblocksLite(link: string) {
155201
if (link)
156202
switch (path) {
@@ -185,14 +231,23 @@ export default function ExplorerSelector() {
185231
}
186232

187233
const hasValidLink =
188-
linkNearblocks(path) || linkNearblocksLite(path) || linkPikespeakai(path);
234+
linkNearRocks(path) ||
235+
linkNearblocks(path) ||
236+
linkNearblocksLite(path) ||
237+
linkPikespeakai(path);
189238

190239
const isInvalidReceiptsPath = path === 'receipts' && isNumericId(value);
191240

241+
const nearRocksHref = getNearRocksHref(path);
192242
const href = getHref(path);
193243
const pikespeakHref = getPikespeakHref(path);
194244
const nearblocksLiteHref = getNearblocksLiteHref(path);
195245

246+
const isNearRocksInactive =
247+
(path && !linkNearRocks(path)) ||
248+
isInvalidReceiptsPath ||
249+
(path && value === '');
250+
196251
const isNearblocksInactive =
197252
(path && !linkNearblocks(path)) ||
198253
isInvalidReceiptsPath ||
@@ -250,10 +305,30 @@ export default function ExplorerSelector() {
250305
<div
251306
className={`${styles.linkContainer} ${
252307
config.pikespeakai !== null
253-
? styles.threeColumns
254-
: styles.twoColumns
308+
? styles.fourColumns
309+
: styles.threeColumns
255310
}`}
256311
>
312+
<a
313+
href={
314+
!isNearRocksInactive
315+
? nearRocksHref || config.nearrocks
316+
: config.nearrocks
317+
}
318+
className={`${styles.nearExplorerButton} ${
319+
isNearRocksInactive ? styles.inactive : ''
320+
}`}
321+
>
322+
<Image
323+
src="/images/nearrocks.svg"
324+
style={imageStyle}
325+
width={45}
326+
height={45}
327+
alt="Near Rocks"
328+
/>
329+
<h3 className={styles.explorerHead}>Near Rocks</h3>
330+
</a>
331+
257332
<a
258333
href={
259334
!isNearblocksLiteInactive

apps/explorer-selector/src/styles/ExplorerSelector.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
grid-template-columns: repeat(3, 1fr);
4848
}
4949

50+
.fourColumns {
51+
grid-template-columns: repeat(4, 1fr);
52+
}
53+
5054
@media (max-width: 768px) {
5155
.linkContainer {
5256
grid-template-columns: 1fr !important;

0 commit comments

Comments
 (0)