diff --git a/src/scripts/runFundingPotService.ts b/src/scripts/runFundingPotService.ts index 65a708501..d020b4b94 100644 --- a/src/scripts/runFundingPotService.ts +++ b/src/scripts/runFundingPotService.ts @@ -35,7 +35,7 @@ async function pullLatestVersionOfFundingPot() { } } -async function generateBatchFile(batchNumber: number) { +async function generateBatchFile(batchNumber: number, dryRun: boolean) { console.info(`Generating batch config for batch number: ${batchNumber}`); const { round, isEarlyAccess } = await getRoundByBatchNumber(batchNumber); if (!isEarlyAccess) { @@ -71,7 +71,7 @@ async function generateBatchFile(batchNumber: number) { }, IS_EARLY_ACCESS: isEarlyAccess, // Set based on the round type PRICE: (round.tokenPrice || '0.1').toString(), // Default price to "0.1" if not provided - // ONLY_REPORT: onlyReport, // If we set this flag, only report will be generated and no transactions propose to the safes + ONLY_REPORT: dryRun, // If we set this flag, only report will be generated and no transactions propose to the safes }; const batchFilePath = path.join( @@ -226,7 +226,7 @@ async function installDependencies() { await execShellCommand('npm install --loglevel=error', serviceDir); } -async function runFundingPotService(batchNumber: number) { +async function runFundingPotService(batchNumber: number, dryRun?: boolean) { const command = 'npm run all ' + batchNumber; console.info(`Running "${command}" in ${serviceDir}...`); try { @@ -234,8 +234,10 @@ async function runFundingPotService(batchNumber: number) { } catch (e) { console.error('Error in funding pot execution:', e); } - console.info('Saving reports to the DB...'); - await saveReportsToDB(reportFilesDir); + if (!dryRun) { + console.info('Saving reports to the DB...'); + await saveReportsToDB(reportFilesDir); + } } async function getFirstRoundThatNeedExecuteBatchMinting() { @@ -327,6 +329,7 @@ async function main() { (await getFirstRoundThatNeedExecuteBatchMinting()).batchNumber; console.info('Batch number is:', batchNumber); + const dryRun = Boolean(process.argv[3]) || false; // Step 1 console.info('Start pulling latest version of funding pot service...'); await pullLatestVersionOfFundingPot(); @@ -344,7 +347,7 @@ async function main() { // Step 5 console.info('Create batch config in the funding pot service...'); - await generateBatchFile(batchNumber); + await generateBatchFile(batchNumber, dryRun); console.info('Batch config created successfully.'); // Step 4 @@ -359,18 +362,20 @@ async function main() { // Step 6 console.info('Running funding pot service...'); - await runFundingPotService(batchNumber); + await runFundingPotService(batchNumber, dryRun); console.info('Funding pot service executed successfully!'); // Step 7 - console.info('Setting batch minting execution flag in round data...'); - await setBatchMintingExecutionFlag(batchNumber); - console.info('Batch minting execution flag set successfully.'); - - // Step 8 - console.info('Start Syncing reward data in donations...'); - await updateRewardsForDonations(batchNumber); - console.info('Rewards data synced successfully.'); + if (!dryRun) { + console.info('Setting batch minting execution flag in round data...'); + await setBatchMintingExecutionFlag(batchNumber); + console.info('Batch minting execution flag set successfully.'); + + // Step 8 + console.info('Start Syncing reward data in donations...'); + await updateRewardsForDonations(batchNumber); + console.info('Rewards data synced successfully.'); + } console.info('Done!'); process.exit(); } catch (error) {