Skip to content

Commit

Permalink
add dryRun flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Nov 16, 2024
1 parent 7854350 commit ebe7add
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/scripts/runFundingPotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -226,16 +226,18 @@ 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 {
await execShellCommand(command, serviceDir);
} 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() {
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit ebe7add

Please sign in to comment.