diff --git a/scripts/routines/routineUpdateBulletin.js b/scripts/routines/routineUpdateBulletin.js index a92665e..8641103 100644 --- a/scripts/routines/routineUpdateBulletin.js +++ b/scripts/routines/routineUpdateBulletin.js @@ -1,62 +1,72 @@ -const { ethers } = require('ethers') +const { ethers } = require("ethers"); const { determineTest, getLocalhostJsonRPCProvider, logNewLine, getEnvWSigner, getChainProvider, - CUICA_DATA_MAINNET -} = require('../utilsCuica') -const { routineSignLastRound } = require('./routineSignLastRound') + CUICA_DATA_MAINNET, +} = require("../utilsCuica"); +const { routineSignLastRound } = require("./routineSignLastRound"); -const TEST = determineTest() +const TEST = determineTest(); /** * @notice Updates roundId data at {PriceBulletin} - * @param {string} chainName + * @param {string} chainName */ -async function routineUpdateBulletin(chainName='localhost') { - const {digest, v, r, s, info, callData} = await routineSignLastRound(chainName) +async function routineUpdateBulletin(chainName = "localhost") { + const { digest, v, r, s, info, callData } = await routineSignLastRound( + chainName + ); const bulletinAbi = [ - 'function updateBulletin(bytes)', - 'function updateBulletinWithRewardLog(bytes)', - 'function updateBulletinWithRewardClaim(bytes, address)', - 'function latestRoundData() view returns (uint, int256, uint, uint, uint)', - ] - let bulletin + "function updateBulletin(bytes)", + "function updateBulletinWithRewardLog(bytes)", + "function updateBulletinWithRewardClaim(bytes, address)", + "function latestRoundData() view returns (uint, int256, uint, uint, uint)", + ]; + let bulletin; if (TEST) { bulletin = new ethers.Contract( CUICA_DATA_MAINNET.gnosis.priceBulletin, bulletinAbi, getEnvWSigner(getLocalhostJsonRPCProvider()) - ) + ); } else { bulletin = new ethers.Contract( CUICA_DATA_MAINNET[chainName].priceBulletin, bulletinAbi, getEnvWSigner(getChainProvider(chainName)) - ) + ); } - console.log(`${logNewLine('INFO')} Updating PriceBulletin ...`) - const tx = await bulletin.updateBulletin( - callData - ) - await tx.wait() - let lastRoundInfo = await bulletin.latestRoundData() + console.log( + `${logNewLine("INFO")} ${chainName} - Updating PriceBulletin ...` + ); + const tx = await bulletin.updateBulletin(callData); + await tx.wait(); + let lastRoundInfo = await bulletin.latestRoundData(); lastRoundInfo = { roundId: lastRoundInfo[0], answer: lastRoundInfo[1], startedAt: lastRoundInfo[2], updatedAt: lastRoundInfo[3], - answeredInRound: lastRoundInfo[4] - } + answeredInRound: lastRoundInfo[4], + }; const updateResult = info.roundId.eq(lastRoundInfo.roundId); if (updateResult) { - console.log(`${logNewLine('INFO')} Successfully updated {PriceBulletin}: latestAnswer(): ${lastRoundInfo.answer.toString()}`) + console.log( + `${logNewLine( + "INFO" + )} ${chainName} - Successfully updated {PriceBulletin}: latestAnswer(): ${lastRoundInfo.answer.toString()}` + ); } else { - console.log(`${logNewLine('WARN')} !!! Failed to update {PriceBulletin}: roundId: ${info.roundId.toString()}`) + console.log( + `${logNewLine( + "WARN" + )} ${chainName} - !!! Failed to update {PriceBulletin}: roundId: ${info.roundId.toString()}` + ); } } @@ -65,10 +75,10 @@ async function routineUpdateBulletin(chainName='localhost') { if (require.main === module) { routineUpdateBulletin() .then(() => process.exit(0)) - .catch(error => { - console.error(error) - process.exit(1) - }) + .catch((error) => { + console.error(error); + process.exit(1); + }); } -exports.routineUpdateBulletin = routineUpdateBulletin \ No newline at end of file +exports.routineUpdateBulletin = routineUpdateBulletin; diff --git a/scripts/scheduler.js b/scripts/scheduler.js index 9799829..44ca111 100644 --- a/scripts/scheduler.js +++ b/scripts/scheduler.js @@ -82,6 +82,10 @@ async function routineCallbacks() { console.log(`${logNewLine('INFO')} Begin of scheduler callbacks ...`) await routineUpdateAllOracles() await routineUpdateBulletin('gnosis') + + // Testnets + await routineUpdateBulletin('sepolia') + await routineUpdateBulletin('goerli') } scheduler() diff --git a/scripts/utilsCuica.js b/scripts/utilsCuica.js index 98dc2dc..d958bf4 100644 --- a/scripts/utilsCuica.js +++ b/scripts/utilsCuica.js @@ -35,6 +35,10 @@ const PROVIDERS = { sepolia: { chainId: 11155111, providers: [process.env.RPC_SEPOLIA] + }, + goerli: { + chainId: 5, + providers: [process.env.RPC_GOERLI] } }