From d3aa1886f64b96419a790804ead1487a2137c1da Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 13:41:45 +0000 Subject: [PATCH 1/5] feat: dynamically fetch entropy gas limits from blockchain - Add EntropyGasLimitTable component to fetch gas limits using getProviderInfoV2 - Update contract addresses page to display dynamic gas limits - Remove static gas limit column from EntropyDeploymentTable - Add IEntropyV2.json ABI for blockchain queries - Follow same pattern as EntropyFeeTable for async data fetching Co-Authored-By: Jayant --- abis/IEntropyV2.json | 628 ++++++++++++++++++++++++++ components/EntropyDeploymentTable.tsx | 2 - components/EntropyGasLimitTable.tsx | 68 +++ pages/entropy/contract-addresses.mdx | 23 + 4 files changed, 719 insertions(+), 2 deletions(-) create mode 100644 abis/IEntropyV2.json create mode 100644 components/EntropyGasLimitTable.tsx diff --git a/abis/IEntropyV2.json b/abis/IEntropyV2.json new file mode 100644 index 00000000..dbf49601 --- /dev/null +++ b/abis/IEntropyV2.json @@ -0,0 +1,628 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "oldDefaultGasLimit", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "newDefaultGasLimit", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "ProviderDefaultGasLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldFeeManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newFeeManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "ProviderFeeManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "oldFee", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newFee", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "ProviderFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "oldMaxNumHashes", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "newMaxNumHashes", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "ProviderMaxNumHashesAdvanced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "oldUri", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "newUri", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "ProviderUriUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "Registered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "sequenceNumber", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "userContribution", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "gasLimit", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "Requested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "sequenceNumber", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "randomNumber", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "userContribution", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "providerContribution", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bool", + "name": "callbackFailed", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "callbackReturnValue", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "callbackGasUsed", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "Revealed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "withdrawnAmount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraArgs", + "type": "bytes" + } + ], + "name": "Withdrawal", + "type": "event" + }, + { + "inputs": [], + "name": "getDefaultProvider", + "outputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "internalType": "uint32", + "name": "gasLimit", + "type": "uint32" + } + ], + "name": "getFeeV2", + "outputs": [ + { + "internalType": "uint128", + "name": "feeAmount", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFeeV2", + "outputs": [ + { + "internalType": "uint128", + "name": "feeAmount", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "gasLimit", + "type": "uint32" + } + ], + "name": "getFeeV2", + "outputs": [ + { + "internalType": "uint128", + "name": "feeAmount", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + } + ], + "name": "getProviderInfoV2", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "feeInWei", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "accruedFeesInWei", + "type": "uint128" + }, + { + "internalType": "bytes32", + "name": "originalCommitment", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "originalCommitmentSequenceNumber", + "type": "uint64" + }, + { + "internalType": "bytes", + "name": "commitmentMetadata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "uri", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "endSequenceNumber", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "sequenceNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "currentCommitment", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "currentCommitmentSequenceNumber", + "type": "uint64" + }, + { + "internalType": "address", + "name": "feeManager", + "type": "address" + }, + { + "internalType": "uint32", + "name": "maxNumHashes", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "defaultGasLimit", + "type": "uint32" + } + ], + "internalType": "struct EntropyStructsV2.ProviderInfo", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "internalType": "uint64", + "name": "sequenceNumber", + "type": "uint64" + } + ], + "name": "getRequestV2", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "internalType": "uint64", + "name": "sequenceNumber", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "numHashes", + "type": "uint32" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "blockNumber", + "type": "uint64" + }, + { + "internalType": "address", + "name": "requester", + "type": "address" + }, + { + "internalType": "bool", + "name": "useBlockhash", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "callbackStatus", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "gasLimit10k", + "type": "uint16" + } + ], + "internalType": "struct EntropyStructsV2.Request", + "name": "req", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "gasLimit", + "type": "uint32" + } + ], + "name": "requestV2", + "outputs": [ + { + "internalType": "uint64", + "name": "assignedSequenceNumber", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "internalType": "uint32", + "name": "gasLimit", + "type": "uint32" + } + ], + "name": "requestV2", + "outputs": [ + { + "internalType": "uint64", + "name": "assignedSequenceNumber", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "requestV2", + "outputs": [ + { + "internalType": "uint64", + "name": "assignedSequenceNumber", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "userRandomNumber", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "gasLimit", + "type": "uint32" + } + ], + "name": "requestV2", + "outputs": [ + { + "internalType": "uint64", + "name": "assignedSequenceNumber", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + } +] diff --git a/components/EntropyDeploymentTable.tsx b/components/EntropyDeploymentTable.tsx index a2548408..837c9095 100644 --- a/components/EntropyDeploymentTable.tsx +++ b/components/EntropyDeploymentTable.tsx @@ -16,7 +16,6 @@ const EntropyDeploymentTable = ({ Chain Id Entropy Contract Address {showReveal && Reveal Delay} - Gas Limit @@ -44,7 +43,6 @@ const EntropyDeploymentTable = ({ {showReveal && {deployment.delay}} - {deployment.gasLimit} ))} diff --git a/components/EntropyGasLimitTable.tsx b/components/EntropyGasLimitTable.tsx new file mode 100644 index 00000000..dec72401 --- /dev/null +++ b/components/EntropyGasLimitTable.tsx @@ -0,0 +1,68 @@ +import React, { useEffect, useState } from "react"; +import { ethers } from "ethers"; +import { EntropyDeployment } from "./EntropyDeployments"; +import EntropyAbiV2 from "../abis/IEntropyV2.json"; +import { StyledTd } from "./Table"; + +const EntropyGasLimitTable = ({ + deployments, +}: { + deployments: Record>; +}) => { + const [gasLimits, setGasLimits] = useState>({}); + + useEffect(() => { + for (const [name, deployment] of Object.entries(deployments)) { + const contract = new ethers.Contract( + deployment.address, + EntropyAbiV2, + ethers.getDefaultProvider(deployment.rpc) + ); + contract.getDefaultProvider().then((defaultProvider: string) => { + contract.getProviderInfoV2(defaultProvider).then((providerInfo: any) => { + const gasLimit = providerInfo.defaultGasLimit; + const formattedGasLimit = gasLimit.toString(); + setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit })); + }); + }); + } + }, [deployments]); + + const sortedDeployments = Object.entries(deployments).sort(); + return ( + + + + + + + + + {sortedDeployments.map(([name, deployment]) => ( + + + + {name} + + + + {gasLimits[name] === undefined ? ( + "Loading..." + ) : ( + gasLimits[name] + )} + + + ))} + +
Chain IdGas Limit
+ ); +}; + +export default EntropyGasLimitTable; diff --git a/pages/entropy/contract-addresses.mdx b/pages/entropy/contract-addresses.mdx index 6f075a2c..c1e975d2 100644 --- a/pages/entropy/contract-addresses.mdx +++ b/pages/entropy/contract-addresses.mdx @@ -1,5 +1,6 @@ import { EntropyDeployments } from "../../components/EntropyDeployments"; import EntropyDeploymentTable from "../../components/EntropyDeploymentTable"; +import EntropyGasLimitTable from "../../components/EntropyGasLimitTable"; # Entropy Contract Addresses on EVM @@ -14,6 +15,18 @@ import EntropyDeploymentTable from "../../components/EntropyDeploymentTable"; showReveal={true} /> +### Gas Limits (Dynamic) + +The following table shows the current gas limits fetched directly from the blockchain: + + v.network === "mainnet" && v.rpc !== undefined + ) + )} +/> + **The default provider for above mainnet chains is `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506`.** The default provider on mainnet has a reveal delay to avoid changes on the outcome of the Entropy request because of block reorgs. @@ -32,6 +45,16 @@ The default provider fulfills the request by sending a transaction with a gas li showReveal={true} /> +### Gas Limits (Dynamic) + + v.network === "testnet" && v.rpc !== undefined + ) + )} +/> + **The default provider for above testnet chains is `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344`.** The default provider on testnet has reveal delays identical to the corresponding mainnet chains to ensure consistent behavior across environments. From cdf45fa8dd712d9a5ac51d6c2e5785c8e7df92f7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 13:47:32 +0000 Subject: [PATCH 2/5] fix: apply prettier formatting to EntropyGasLimitTable.tsx - Fix pre-commit CI failure by applying prettier formatting - Reformat promise chain and simplify ternary operator Co-Authored-By: Jayant --- components/EntropyGasLimitTable.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/components/EntropyGasLimitTable.tsx b/components/EntropyGasLimitTable.tsx index dec72401..ee4aa8a7 100644 --- a/components/EntropyGasLimitTable.tsx +++ b/components/EntropyGasLimitTable.tsx @@ -19,11 +19,13 @@ const EntropyGasLimitTable = ({ ethers.getDefaultProvider(deployment.rpc) ); contract.getDefaultProvider().then((defaultProvider: string) => { - contract.getProviderInfoV2(defaultProvider).then((providerInfo: any) => { - const gasLimit = providerInfo.defaultGasLimit; - const formattedGasLimit = gasLimit.toString(); - setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit })); - }); + contract + .getProviderInfoV2(defaultProvider) + .then((providerInfo: any) => { + const gasLimit = providerInfo.defaultGasLimit; + const formattedGasLimit = gasLimit.toString(); + setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit })); + }); }); } }, [deployments]); @@ -52,11 +54,7 @@ const EntropyGasLimitTable = ({ - {gasLimits[name] === undefined ? ( - "Loading..." - ) : ( - gasLimits[name] - )} + {gasLimits[name] === undefined ? "Loading..." : gasLimits[name]} ))} From c12ed19471e84714bf0482b9c220fd02822229e0 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 21:02:13 +0000 Subject: [PATCH 3/5] refactor: remove abis folder and integrate gas limit into main table - Remove abis/IEntropyV2.json file as requested - Delete separate EntropyGasLimitTable component - Integrate gas limit column back into EntropyDeploymentTable - Update contract-addresses.mdx to use unified table approach - Currently showing static gas limits, dynamic fetching to be implemented next Co-Authored-By: Jayant --- abis/IEntropyV2.json | 628 -------------------------- components/EntropyDeploymentTable.tsx | 2 + components/EntropyGasLimitTable.tsx | 66 --- pages/entropy/contract-addresses.mdx | 23 - 4 files changed, 2 insertions(+), 717 deletions(-) delete mode 100644 abis/IEntropyV2.json delete mode 100644 components/EntropyGasLimitTable.tsx diff --git a/abis/IEntropyV2.json b/abis/IEntropyV2.json deleted file mode 100644 index dbf49601..00000000 --- a/abis/IEntropyV2.json +++ /dev/null @@ -1,628 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "oldDefaultGasLimit", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "newDefaultGasLimit", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "ProviderDefaultGasLimitUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "oldFeeManager", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newFeeManager", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "ProviderFeeManagerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "oldFee", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "newFee", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "ProviderFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "oldMaxNumHashes", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "newMaxNumHashes", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "ProviderMaxNumHashesAdvanced", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "oldUri", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "newUri", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "ProviderUriUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "Registered", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint64", - "name": "sequenceNumber", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "userContribution", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "gasLimit", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "Requested", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint64", - "name": "sequenceNumber", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "randomNumber", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "userContribution", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "providerContribution", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bool", - "name": "callbackFailed", - "type": "bool" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "callbackReturnValue", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "callbackGasUsed", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "Revealed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "withdrawnAmount", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraArgs", - "type": "bytes" - } - ], - "name": "Withdrawal", - "type": "event" - }, - { - "inputs": [], - "name": "getDefaultProvider", - "outputs": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "internalType": "uint32", - "name": "gasLimit", - "type": "uint32" - } - ], - "name": "getFeeV2", - "outputs": [ - { - "internalType": "uint128", - "name": "feeAmount", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getFeeV2", - "outputs": [ - { - "internalType": "uint128", - "name": "feeAmount", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "gasLimit", - "type": "uint32" - } - ], - "name": "getFeeV2", - "outputs": [ - { - "internalType": "uint128", - "name": "feeAmount", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - } - ], - "name": "getProviderInfoV2", - "outputs": [ - { - "components": [ - { - "internalType": "uint128", - "name": "feeInWei", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "accruedFeesInWei", - "type": "uint128" - }, - { - "internalType": "bytes32", - "name": "originalCommitment", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "originalCommitmentSequenceNumber", - "type": "uint64" - }, - { - "internalType": "bytes", - "name": "commitmentMetadata", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "uri", - "type": "bytes" - }, - { - "internalType": "uint64", - "name": "endSequenceNumber", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "sequenceNumber", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "currentCommitment", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "currentCommitmentSequenceNumber", - "type": "uint64" - }, - { - "internalType": "address", - "name": "feeManager", - "type": "address" - }, - { - "internalType": "uint32", - "name": "maxNumHashes", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "defaultGasLimit", - "type": "uint32" - } - ], - "internalType": "struct EntropyStructsV2.ProviderInfo", - "name": "info", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "internalType": "uint64", - "name": "sequenceNumber", - "type": "uint64" - } - ], - "name": "getRequestV2", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "internalType": "uint64", - "name": "sequenceNumber", - "type": "uint64" - }, - { - "internalType": "uint32", - "name": "numHashes", - "type": "uint32" - }, - { - "internalType": "bytes32", - "name": "commitment", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "blockNumber", - "type": "uint64" - }, - { - "internalType": "address", - "name": "requester", - "type": "address" - }, - { - "internalType": "bool", - "name": "useBlockhash", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "callbackStatus", - "type": "uint8" - }, - { - "internalType": "uint16", - "name": "gasLimit10k", - "type": "uint16" - } - ], - "internalType": "struct EntropyStructsV2.Request", - "name": "req", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "gasLimit", - "type": "uint32" - } - ], - "name": "requestV2", - "outputs": [ - { - "internalType": "uint64", - "name": "assignedSequenceNumber", - "type": "uint64" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "internalType": "uint32", - "name": "gasLimit", - "type": "uint32" - } - ], - "name": "requestV2", - "outputs": [ - { - "internalType": "uint64", - "name": "assignedSequenceNumber", - "type": "uint64" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "requestV2", - "outputs": [ - { - "internalType": "uint64", - "name": "assignedSequenceNumber", - "type": "uint64" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "userRandomNumber", - "type": "bytes32" - }, - { - "internalType": "uint32", - "name": "gasLimit", - "type": "uint32" - } - ], - "name": "requestV2", - "outputs": [ - { - "internalType": "uint64", - "name": "assignedSequenceNumber", - "type": "uint64" - } - ], - "stateMutability": "payable", - "type": "function" - } -] diff --git a/components/EntropyDeploymentTable.tsx b/components/EntropyDeploymentTable.tsx index 837c9095..a2548408 100644 --- a/components/EntropyDeploymentTable.tsx +++ b/components/EntropyDeploymentTable.tsx @@ -16,6 +16,7 @@ const EntropyDeploymentTable = ({ Chain Id Entropy Contract Address {showReveal && Reveal Delay} + Gas Limit @@ -43,6 +44,7 @@ const EntropyDeploymentTable = ({ {showReveal && {deployment.delay}} + {deployment.gasLimit} ))} diff --git a/components/EntropyGasLimitTable.tsx b/components/EntropyGasLimitTable.tsx deleted file mode 100644 index ee4aa8a7..00000000 --- a/components/EntropyGasLimitTable.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { ethers } from "ethers"; -import { EntropyDeployment } from "./EntropyDeployments"; -import EntropyAbiV2 from "../abis/IEntropyV2.json"; -import { StyledTd } from "./Table"; - -const EntropyGasLimitTable = ({ - deployments, -}: { - deployments: Record>; -}) => { - const [gasLimits, setGasLimits] = useState>({}); - - useEffect(() => { - for (const [name, deployment] of Object.entries(deployments)) { - const contract = new ethers.Contract( - deployment.address, - EntropyAbiV2, - ethers.getDefaultProvider(deployment.rpc) - ); - contract.getDefaultProvider().then((defaultProvider: string) => { - contract - .getProviderInfoV2(defaultProvider) - .then((providerInfo: any) => { - const gasLimit = providerInfo.defaultGasLimit; - const formattedGasLimit = gasLimit.toString(); - setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit })); - }); - }); - } - }, [deployments]); - - const sortedDeployments = Object.entries(deployments).sort(); - return ( - - - - - - - - - {sortedDeployments.map(([name, deployment]) => ( - - - - {name} - - - - {gasLimits[name] === undefined ? "Loading..." : gasLimits[name]} - - - ))} - -
Chain IdGas Limit
- ); -}; - -export default EntropyGasLimitTable; diff --git a/pages/entropy/contract-addresses.mdx b/pages/entropy/contract-addresses.mdx index c1e975d2..6f075a2c 100644 --- a/pages/entropy/contract-addresses.mdx +++ b/pages/entropy/contract-addresses.mdx @@ -1,6 +1,5 @@ import { EntropyDeployments } from "../../components/EntropyDeployments"; import EntropyDeploymentTable from "../../components/EntropyDeploymentTable"; -import EntropyGasLimitTable from "../../components/EntropyGasLimitTable"; # Entropy Contract Addresses on EVM @@ -15,18 +14,6 @@ import EntropyGasLimitTable from "../../components/EntropyGasLimitTable"; showReveal={true} /> -### Gas Limits (Dynamic) - -The following table shows the current gas limits fetched directly from the blockchain: - - v.network === "mainnet" && v.rpc !== undefined - ) - )} -/> - **The default provider for above mainnet chains is `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506`.** The default provider on mainnet has a reveal delay to avoid changes on the outcome of the Entropy request because of block reorgs. @@ -45,16 +32,6 @@ The default provider fulfills the request by sending a transaction with a gas li showReveal={true} /> -### Gas Limits (Dynamic) - - v.network === "testnet" && v.rpc !== undefined - ) - )} -/> - **The default provider for above testnet chains is `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344`.** The default provider on testnet has reveal delays identical to the corresponding mainnet chains to ensure consistent behavior across environments. From 4b3821555d84792ff8a9bcdcb68a5073add2e05d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 21:02:53 +0000 Subject: [PATCH 4/5] feat: implement dynamic gas limit fetching in unified table - Add inline ABI for getProviderInfoV2 method to avoid abis folder dependency - Integrate dynamic gas limit fetching directly into EntropyDeploymentTable - Maintain fallback to static values when blockchain queries fail - Show 'Loading...' state while fetching dynamic values from contracts - Successfully combines contract addresses and gas limits in single table Co-Authored-By: Jayant --- components/EntropyDeploymentTable.tsx | 142 +++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 1 deletion(-) diff --git a/components/EntropyDeploymentTable.tsx b/components/EntropyDeploymentTable.tsx index a2548408..913a96e1 100644 --- a/components/EntropyDeploymentTable.tsx +++ b/components/EntropyDeploymentTable.tsx @@ -1,6 +1,110 @@ +import React, { useEffect, useState } from "react"; +import { ethers } from "ethers"; import { EntropyDeployment } from "./EntropyDeployments"; import { StyledTd } from "./Table"; +const ENTROPY_V2_ABI = [ + { + "inputs": [], + "name": "getDefaultProvider", + "outputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provider", + "type": "address" + } + ], + "name": "getProviderInfoV2", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "feeInWei", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "accruedFeesInWei", + "type": "uint128" + }, + { + "internalType": "bytes32", + "name": "originalCommitment", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "originalCommitmentSequenceNumber", + "type": "uint64" + }, + { + "internalType": "bytes", + "name": "commitmentMetadata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "uri", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "endSequenceNumber", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "sequenceNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "currentCommitment", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "currentCommitmentSequenceNumber", + "type": "uint64" + }, + { + "internalType": "address", + "name": "feeManager", + "type": "address" + }, + { + "internalType": "bool", + "name": "withCallback", + "type": "bool" + }, + { + "internalType": "uint32", + "name": "defaultGasLimit", + "type": "uint32" + } + ], + "internalType": "struct EntropyStructsV2.ProviderInfo", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + } +]; + const EntropyDeploymentTable = ({ deployments, showReveal, @@ -8,6 +112,40 @@ const EntropyDeploymentTable = ({ deployments: Record; showReveal: boolean; }) => { + const [gasLimits, setGasLimits] = useState>({}); + + useEffect(() => { + for (const [name, deployment] of Object.entries(deployments)) { + if (deployment.rpc) { + try { + const contract = new ethers.Contract( + deployment.address, + ENTROPY_V2_ABI, + ethers.getDefaultProvider(deployment.rpc) + ); + contract.getDefaultProvider().then((defaultProvider: string) => { + contract + .getProviderInfoV2(defaultProvider) + .then((providerInfo: any) => { + const gasLimit = providerInfo.defaultGasLimit; + const formattedGasLimit = gasLimit.toString(); + setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit })); + }) + .catch(() => { + setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); + }); + }).catch(() => { + setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); + }); + } catch { + setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); + } + } else { + setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); + } + } + }, [deployments]); + const sortedDeployments = Object.entries(deployments).sort(); return ( @@ -44,7 +182,9 @@ const EntropyDeploymentTable = ({ {showReveal && {deployment.delay}} - {deployment.gasLimit} + + {gasLimits[name] === undefined ? "Loading..." : gasLimits[name]} + ))} From a954b3437889be056010c4d54a33597bb6bb178a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 21:04:21 +0000 Subject: [PATCH 5/5] fix: apply prettier formatting to EntropyDeploymentTable.tsx - Fix formatting issues identified by pre-commit prettier hook - Ensure code style consistency across the repository Co-Authored-By: Jayant --- components/EntropyDeploymentTable.tsx | 168 ++++++++++++++------------ 1 file changed, 90 insertions(+), 78 deletions(-) diff --git a/components/EntropyDeploymentTable.tsx b/components/EntropyDeploymentTable.tsx index 913a96e1..9f1838f8 100644 --- a/components/EntropyDeploymentTable.tsx +++ b/components/EntropyDeploymentTable.tsx @@ -5,104 +5,104 @@ import { StyledTd } from "./Table"; const ENTROPY_V2_ABI = [ { - "inputs": [], - "name": "getDefaultProvider", - "outputs": [ + inputs: [], + name: "getDefaultProvider", + outputs: [ { - "internalType": "address", - "name": "provider", - "type": "address" - } + internalType: "address", + name: "provider", + type: "address", + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: "view", + type: "function", }, { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "provider", - "type": "address" - } + internalType: "address", + name: "provider", + type: "address", + }, ], - "name": "getProviderInfoV2", - "outputs": [ + name: "getProviderInfoV2", + outputs: [ { - "components": [ + components: [ { - "internalType": "uint128", - "name": "feeInWei", - "type": "uint128" + internalType: "uint128", + name: "feeInWei", + type: "uint128", }, { - "internalType": "uint128", - "name": "accruedFeesInWei", - "type": "uint128" + internalType: "uint128", + name: "accruedFeesInWei", + type: "uint128", }, { - "internalType": "bytes32", - "name": "originalCommitment", - "type": "bytes32" + internalType: "bytes32", + name: "originalCommitment", + type: "bytes32", }, { - "internalType": "uint64", - "name": "originalCommitmentSequenceNumber", - "type": "uint64" + internalType: "uint64", + name: "originalCommitmentSequenceNumber", + type: "uint64", }, { - "internalType": "bytes", - "name": "commitmentMetadata", - "type": "bytes" + internalType: "bytes", + name: "commitmentMetadata", + type: "bytes", }, { - "internalType": "bytes", - "name": "uri", - "type": "bytes" + internalType: "bytes", + name: "uri", + type: "bytes", }, { - "internalType": "uint64", - "name": "endSequenceNumber", - "type": "uint64" + internalType: "uint64", + name: "endSequenceNumber", + type: "uint64", }, { - "internalType": "uint64", - "name": "sequenceNumber", - "type": "uint64" + internalType: "uint64", + name: "sequenceNumber", + type: "uint64", }, { - "internalType": "bytes32", - "name": "currentCommitment", - "type": "bytes32" + internalType: "bytes32", + name: "currentCommitment", + type: "bytes32", }, { - "internalType": "uint64", - "name": "currentCommitmentSequenceNumber", - "type": "uint64" + internalType: "uint64", + name: "currentCommitmentSequenceNumber", + type: "uint64", }, { - "internalType": "address", - "name": "feeManager", - "type": "address" + internalType: "address", + name: "feeManager", + type: "address", }, { - "internalType": "bool", - "name": "withCallback", - "type": "bool" + internalType: "bool", + name: "withCallback", + type: "bool", }, { - "internalType": "uint32", - "name": "defaultGasLimit", - "type": "uint32" - } + internalType: "uint32", + name: "defaultGasLimit", + type: "uint32", + }, ], - "internalType": "struct EntropyStructsV2.ProviderInfo", - "name": "info", - "type": "tuple" - } + internalType: "struct EntropyStructsV2.ProviderInfo", + name: "info", + type: "tuple", + }, ], - "stateMutability": "view", - "type": "function" - } + stateMutability: "view", + type: "function", + }, ]; const EntropyDeploymentTable = ({ @@ -123,20 +123,32 @@ const EntropyDeploymentTable = ({ ENTROPY_V2_ABI, ethers.getDefaultProvider(deployment.rpc) ); - contract.getDefaultProvider().then((defaultProvider: string) => { - contract - .getProviderInfoV2(defaultProvider) - .then((providerInfo: any) => { - const gasLimit = providerInfo.defaultGasLimit; - const formattedGasLimit = gasLimit.toString(); - setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit })); - }) - .catch(() => { - setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); - }); - }).catch(() => { - setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); - }); + contract + .getDefaultProvider() + .then((defaultProvider: string) => { + contract + .getProviderInfoV2(defaultProvider) + .then((providerInfo: any) => { + const gasLimit = providerInfo.defaultGasLimit; + const formattedGasLimit = gasLimit.toString(); + setGasLimits((prev) => ({ + ...prev, + [name]: formattedGasLimit, + })); + }) + .catch(() => { + setGasLimits((prev) => ({ + ...prev, + [name]: deployment.gasLimit, + })); + }); + }) + .catch(() => { + setGasLimits((prev) => ({ + ...prev, + [name]: deployment.gasLimit, + })); + }); } catch { setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit })); }