Skip to content

Commit e5f0b2b

Browse files
committed
feat: skip verification if fee manager addres is not present
1 parent 27db907 commit e5f0b2b

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

server/services/clientEvm.ts

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ export async function executeContract({
139139
}
140140
}
141141

142-
143-
144142
async function getContractAddresses() {
145143
try {
146144
const clients = await getClients();
@@ -254,63 +252,69 @@ export async function verifyReport(report: StreamReport) {
254252
[feeTokenAddress]
255253
);
256254

257-
const [fee] = await readContract(publicClient, {
258-
address: feeManagerAddress,
259-
abi: feeManagerAbi,
260-
functionName: 'getFeeAndReward',
261-
args: [account.address, reportData, feeTokenAddress],
262-
});
263-
logger.info(`⛽️ Estimated fee: ${formatEther(fee.amount)} LINK`, { fee });
264-
265-
const approveLinkGas = await estimateContractGas(publicClient, {
266-
account,
267-
address: feeTokenAddress,
268-
abi: erc20Abi,
269-
functionName: 'approve',
270-
args: [rewardManagerAddress, fee.amount],
271-
});
272-
273-
logger.info(
274-
`⛽️ Estimated gas for LINK approval: ${formatEther(approveLinkGas)} ${
275-
publicClient.chain?.nativeCurrency.symbol
276-
}`,
277-
{ approveLinkGas }
278-
);
279255
const gasCap = await getGasCap();
280-
if (gasCap && approveLinkGas > BigInt(gasCap)) {
281-
logger.info(
282-
`🛑 LINK approval gas is above the limit of ${formatEther(
283-
BigInt(gasCap)
284-
)} | Aborting`,
285-
{ approveLinkGas, gasCap }
286-
);
287-
return;
288-
}
289256

290-
const { request: approveLinkRequest } = await simulateContract(
291-
publicClient,
292-
{
257+
if (feeManagerAddress && feeManagerAddress !== zeroAddress) {
258+
logger.info('⌛ Estimating fee for verification');
259+
const [fee] = await readContract(publicClient, {
260+
address: feeManagerAddress,
261+
abi: feeManagerAbi,
262+
functionName: 'getFeeAndReward',
263+
args: [account.address, reportData, feeTokenAddress],
264+
});
265+
logger.info(`⛽️ Estimated fee: ${formatEther(fee.amount)} LINK`, {
266+
fee,
267+
});
268+
269+
const approveLinkGas = await estimateContractGas(publicClient, {
293270
account,
294271
address: feeTokenAddress,
295272
abi: erc20Abi,
296273
functionName: 'approve',
297274
args: [rewardManagerAddress, fee.amount],
275+
});
276+
277+
logger.info(
278+
`⛽️ Estimated gas for LINK approval: ${formatEther(approveLinkGas)} ${
279+
publicClient.chain?.nativeCurrency.symbol
280+
}`,
281+
{ approveLinkGas }
282+
);
283+
if (gasCap && approveLinkGas > BigInt(gasCap)) {
284+
logger.info(
285+
`🛑 LINK approval gas is above the limit of ${formatEther(
286+
BigInt(gasCap)
287+
)} | Aborting`,
288+
{ approveLinkGas, gasCap }
289+
);
290+
return;
298291
}
299-
);
300-
const approveLinkHash = await writeContract(
301-
walletClient,
302-
approveLinkRequest
303-
);
304-
const approveLinkReceipt = await waitForTransactionReceipt(publicClient, {
305-
hash: approveLinkHash,
306-
});
307292

308-
if (approveLinkReceipt.status !== 'success') {
309-
logger.warn(
310-
`🛑 LINK approval transaction was not successful | Aborting`,
311-
{ transactionReceipt: approveLinkReceipt }
293+
const { request: approveLinkRequest } = await simulateContract(
294+
publicClient,
295+
{
296+
account,
297+
address: feeTokenAddress,
298+
abi: erc20Abi,
299+
functionName: 'approve',
300+
args: [rewardManagerAddress, fee.amount],
301+
}
312302
);
313-
return;
303+
const approveLinkHash = await writeContract(
304+
walletClient,
305+
approveLinkRequest
306+
);
307+
const approveLinkReceipt = await waitForTransactionReceipt(publicClient, {
308+
hash: approveLinkHash,
309+
});
310+
311+
if (approveLinkReceipt.status !== 'success') {
312+
logger.warn(
313+
`🛑 LINK approval transaction was not successful | Aborting`,
314+
{ transactionReceipt: approveLinkReceipt }
315+
);
316+
return;
317+
}
314318
}
315319

316320
const verifyReportGas = await estimateContractGas(publicClient, {

0 commit comments

Comments
 (0)