Skip to content

Commit

Permalink
Add block gas limit in each chain card
Browse files Browse the repository at this point in the history
Related to DefiLlama#1426

Add block gas limit display to each chain card.

* Modify `components/chain/index.js` to include a new row in the table for displaying the block gas limit, with a default value of 'Unknown' if not available.
* Update `hooks/useRPCData.js` to fetch the block gas limit and include it in the formatted data.
* Change `stores/index.js` to manage the block gas limit state, adding a new state variable and updating the `updateChain` function to include the block gas limit.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/DefiLlama/chainlist/issues/1426?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
Setland34 committed Jan 29, 2025
1 parent da39bd3 commit a04f442
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions components/chain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export default function Chain({ chain, buttonOnly, lang }) {
{chain.nativeCurrency ? chain.nativeCurrency.symbol : "none"}
</td>
</tr>
<tr>
<td className="text-center font-bold px-4 dark:text-[#B3B3B3]">Block Gas Limit</td>
<td className="text-center font-bold px-4 dark:text-[#B3B3B3]">
{chain.blockGasLimit ? chain.blockGasLimit : "Unknown"}
</td>
</tr>
</tbody>
</table>

Expand Down
3 changes: 2 additions & 1 deletion hooks/useRPCData.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ const fetchChain = async (baseURL) => {
const formatData = (url, data) => {
let height = data?.result?.number ?? null;
let latency = data?.latency ?? null;
let blockGasLimit = data?.result?.gasLimit ?? null;
if (height) {
const hexString = height.toString(16);
height = parseInt(hexString, 16);
} else {
latency = null;
}
return { url, height, latency };
return { url, height, latency, blockGasLimit };
};

const useHttpQuery = (url) => {
Expand Down
3 changes: 2 additions & 1 deletion stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import create from "zustand";

export const useChain = create((set) => ({
id: null,
updateChain: (id) => set(() => ({ id })),
blockGasLimit: 'Unknown',
updateChain: (id, blockGasLimit = 'Unknown') => set(() => ({ id, blockGasLimit })),
}));

export const useRpcStore = create((set) => ({
Expand Down

0 comments on commit a04f442

Please sign in to comment.