Skip to content

Commit 4b38215

Browse files
devin-ai-integration[bot]Jayant
andcommitted
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 <[email protected]>
1 parent c12ed19 commit 4b38215

File tree

1 file changed

+141
-1
lines changed

1 file changed

+141
-1
lines changed

components/EntropyDeploymentTable.tsx

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,151 @@
1+
import React, { useEffect, useState } from "react";
2+
import { ethers } from "ethers";
13
import { EntropyDeployment } from "./EntropyDeployments";
24
import { StyledTd } from "./Table";
35

6+
const ENTROPY_V2_ABI = [
7+
{
8+
"inputs": [],
9+
"name": "getDefaultProvider",
10+
"outputs": [
11+
{
12+
"internalType": "address",
13+
"name": "provider",
14+
"type": "address"
15+
}
16+
],
17+
"stateMutability": "view",
18+
"type": "function"
19+
},
20+
{
21+
"inputs": [
22+
{
23+
"internalType": "address",
24+
"name": "provider",
25+
"type": "address"
26+
}
27+
],
28+
"name": "getProviderInfoV2",
29+
"outputs": [
30+
{
31+
"components": [
32+
{
33+
"internalType": "uint128",
34+
"name": "feeInWei",
35+
"type": "uint128"
36+
},
37+
{
38+
"internalType": "uint128",
39+
"name": "accruedFeesInWei",
40+
"type": "uint128"
41+
},
42+
{
43+
"internalType": "bytes32",
44+
"name": "originalCommitment",
45+
"type": "bytes32"
46+
},
47+
{
48+
"internalType": "uint64",
49+
"name": "originalCommitmentSequenceNumber",
50+
"type": "uint64"
51+
},
52+
{
53+
"internalType": "bytes",
54+
"name": "commitmentMetadata",
55+
"type": "bytes"
56+
},
57+
{
58+
"internalType": "bytes",
59+
"name": "uri",
60+
"type": "bytes"
61+
},
62+
{
63+
"internalType": "uint64",
64+
"name": "endSequenceNumber",
65+
"type": "uint64"
66+
},
67+
{
68+
"internalType": "uint64",
69+
"name": "sequenceNumber",
70+
"type": "uint64"
71+
},
72+
{
73+
"internalType": "bytes32",
74+
"name": "currentCommitment",
75+
"type": "bytes32"
76+
},
77+
{
78+
"internalType": "uint64",
79+
"name": "currentCommitmentSequenceNumber",
80+
"type": "uint64"
81+
},
82+
{
83+
"internalType": "address",
84+
"name": "feeManager",
85+
"type": "address"
86+
},
87+
{
88+
"internalType": "bool",
89+
"name": "withCallback",
90+
"type": "bool"
91+
},
92+
{
93+
"internalType": "uint32",
94+
"name": "defaultGasLimit",
95+
"type": "uint32"
96+
}
97+
],
98+
"internalType": "struct EntropyStructsV2.ProviderInfo",
99+
"name": "info",
100+
"type": "tuple"
101+
}
102+
],
103+
"stateMutability": "view",
104+
"type": "function"
105+
}
106+
];
107+
4108
const EntropyDeploymentTable = ({
5109
deployments,
6110
showReveal,
7111
}: {
8112
deployments: Record<string, EntropyDeployment>;
9113
showReveal: boolean;
10114
}) => {
115+
const [gasLimits, setGasLimits] = useState<Record<string, string>>({});
116+
117+
useEffect(() => {
118+
for (const [name, deployment] of Object.entries(deployments)) {
119+
if (deployment.rpc) {
120+
try {
121+
const contract = new ethers.Contract(
122+
deployment.address,
123+
ENTROPY_V2_ABI,
124+
ethers.getDefaultProvider(deployment.rpc)
125+
);
126+
contract.getDefaultProvider().then((defaultProvider: string) => {
127+
contract
128+
.getProviderInfoV2(defaultProvider)
129+
.then((providerInfo: any) => {
130+
const gasLimit = providerInfo.defaultGasLimit;
131+
const formattedGasLimit = gasLimit.toString();
132+
setGasLimits((prev) => ({ ...prev, [name]: formattedGasLimit }));
133+
})
134+
.catch(() => {
135+
setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit }));
136+
});
137+
}).catch(() => {
138+
setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit }));
139+
});
140+
} catch {
141+
setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit }));
142+
}
143+
} else {
144+
setGasLimits((prev) => ({ ...prev, [name]: deployment.gasLimit }));
145+
}
146+
}
147+
}, [deployments]);
148+
11149
const sortedDeployments = Object.entries(deployments).sort();
12150
return (
13151
<table>
@@ -44,7 +182,9 @@ const EntropyDeploymentTable = ({
44182
</a>
45183
</StyledTd>
46184
{showReveal && <StyledTd>{deployment.delay}</StyledTd>}
47-
<StyledTd>{deployment.gasLimit}</StyledTd>
185+
<StyledTd>
186+
{gasLimits[name] === undefined ? "Loading..." : gasLimits[name]}
187+
</StyledTd>
48188
</tr>
49189
))}
50190
</tbody>

0 commit comments

Comments
 (0)