forked from blockscout/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a400a1
commit bff020e
Showing
10 changed files
with
225 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 20px; | ||
background-color: #f0f0f0; | ||
} | ||
.stats-card { | ||
background-color: white; | ||
padding: 20px; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
max-width: 800px; | ||
margin: 0 auto; | ||
} | ||
h1, h2 { | ||
color: #333; | ||
margin-top: 0; | ||
} | ||
.proposer-section { | ||
margin-bottom: 20px; | ||
} | ||
table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
margin-top: 10px; | ||
background-color: black; /* Set table background to black */ | ||
color: white; | ||
} | ||
th, td { | ||
padding: 8px; | ||
text-align: left; | ||
border-bottom: 1px solid #ddd; | ||
} | ||
th { | ||
background-color: #333; /* Darker shade for table headers */ | ||
color: white; /* Ensure header text is white */ | ||
} | ||
.count { | ||
font-weight: bold; | ||
color: #666; | ||
} | ||
.bolt { | ||
background-color: #444; /* Adjusted color for bolt row */ | ||
} | ||
.interstate { | ||
background-color: #fff0e6; | ||
} |
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,65 @@ | ||
import { useEffect, useState } from 'react'; | ||
import axios from 'axios'; | ||
import { Proposers } from './components/Proposers'; | ||
import { Gateway } from './components/Gateway'; | ||
|
||
|
||
|
||
interface Proposer { | ||
slot: number; | ||
validator_index: number; | ||
|
||
} | ||
|
||
function Proposer() { | ||
const [proposers, setProposers] = useState<Proposer[]>([]); | ||
const [timestamp, setTimestamp] = useState<string>(""); // Type the timestamp state | ||
|
||
const updateProposers = async () => { | ||
setTimestamp(new Date().toLocaleString()); | ||
console.log("timestamp"); | ||
try { | ||
const response = await fetch( | ||
"http://135.181.191.125:58017/api/v1/proposers/lookahead?activeOnly=true&futureOnly=true" | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Network response was not ok: ${response.statusText}`); | ||
} | ||
|
||
const data :any= await response.json(); | ||
|
||
// Ensure the data matches the expected type | ||
const mappedProposers = data.map((item: any) => ({ | ||
slot: item.slot, | ||
validator_index: item.validator_index, | ||
|
||
})); | ||
console.log("mapped_data", mappedProposers); | ||
|
||
setProposers(mappedProposers); | ||
} catch (error) { | ||
console.error("Error fetching proposers:", error); | ||
} | ||
}; | ||
|
||
|
||
useEffect(() => { | ||
const id = setInterval(() => updateProposers(), 1000); | ||
return () => clearInterval(id); | ||
}, []); | ||
|
||
return ( | ||
<div className="App" style={{width:"100%"}}> | ||
<h1 style={{color:'white'}}>Holesky Proposer Statistics</h1> | ||
<h2 style={{color:'white'}}>Available Aggregated Proposers || Last Updated: <span className="count">{timestamp}</span></h2> | ||
<h2 style={{color:'white'}}>Average response latency: <span className="count">200ms (est)</span></h2> | ||
<h2 style={{color:'white'}}>Total proposers: <span className="count">51,431</span></h2> | ||
|
||
<Proposers proposers={proposers} /> | ||
<Gateway /> | ||
</div> | ||
); | ||
} | ||
|
||
export default Proposer; |
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,13 @@ | ||
|
||
export const Gateway = () => { | ||
return ( | ||
<div> | ||
Gateways | ||
<ul> | ||
<li>api.interstate.so</li> | ||
<li>http://135.181.191.125:58017</li> | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
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,54 @@ | ||
interface Proposer { | ||
slot: number; | ||
validator_index: number; | ||
// Add other fields as necessary | ||
} | ||
|
||
interface ProposersProps { | ||
proposers: Proposer[]; | ||
|
||
} | ||
|
||
interface ProposerItemProps { | ||
item: Proposer; | ||
} | ||
|
||
export const Proposers = ({ proposers }: ProposersProps) => { | ||
return ( | ||
<> | ||
<h2 style={{color:"white"}}> | ||
Total Proposers In Upcoming 32 Slots: <span className="count">{proposers.length}</span> | ||
</h2> | ||
<div className="proposer-section"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Type</th> | ||
<th>Slot</th> | ||
<th>Validator Index</th> | ||
<th>Insurance Size</th> | ||
<th>Total Value Transacted</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{proposers.map((proposer, index) => ( | ||
<ProposerItem key={index} item={proposer} /> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export const ProposerItem = ({ item }: ProposerItemProps) => { | ||
return ( | ||
<tr className="bolt"> | ||
<td>Agg</td> | ||
<td>{item.slot}</td> | ||
<td>{item.validator_index}</td> | ||
<td>_</td> | ||
<td>_</td> | ||
</tr> | ||
); | ||
}; |
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