From 785435021f34715230c4de7950ba1a68b836dc5e Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 16 Nov 2024 12:56:38 +0700 Subject: [PATCH 1/3] add dynamic offset for time --- src/scripts/runFundingPotService.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scripts/runFundingPotService.ts b/src/scripts/runFundingPotService.ts index 42f5dc04f..65a708501 100644 --- a/src/scripts/runFundingPotService.ts +++ b/src/scripts/runFundingPotService.ts @@ -42,10 +42,15 @@ async function generateBatchFile(batchNumber: number) { round.startDate = round.beginDate; } + const now = new Date(); + const offsetSecs = now.getTimezoneOffset() * 60; + const batchConfig = { TIMEFRAME: { - FROM_TIMESTAMP: Math.floor(new Date(round.startDate).getTime() / 1000), // Convert to timestamp - TO_TIMESTAMP: Math.floor(new Date(round.endDate).getTime() / 1000), + FROM_TIMESTAMP: + Math.floor(new Date(round.startDate).getTime() / 1000) - offsetSecs, // Convert to timestamp + TO_TIMESTAMP: + Math.floor(new Date(round.endDate).getTime() / 1000) - offsetSecs, }, VESTING_DETAILS: getStreamDetails(isEarlyAccess), LIMITS: { From ebe7add44f12ccef447fb1266545e2cdde2e42da Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 16 Nov 2024 12:57:16 +0700 Subject: [PATCH 2/3] add dryRun flag --- src/scripts/runFundingPotService.ts | 35 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) 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) { From 925296eca2cf21bae17c89e9d5e300a70bfcbf92 Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 16 Nov 2024 16:05:38 +0700 Subject: [PATCH 3/3] put correct backend url for production --- src/scripts/runFundingPotService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scripts/runFundingPotService.ts b/src/scripts/runFundingPotService.ts index d020b4b94..64296c62c 100644 --- a/src/scripts/runFundingPotService.ts +++ b/src/scripts/runFundingPotService.ts @@ -178,7 +178,11 @@ async function createEnvFile() { 'RPC_URL="https://rpc.ankr.com/base_sepolia"', 'RPC_URL="https://zkevm-rpc.com"', ) - .replace('CHAIN_ID=84532', 'CHAIN_ID=1101'); + .replace('CHAIN_ID=84532', 'CHAIN_ID=1101') + .replace( + 'BACKEND_URL="https://staging.qacc-be.generalmagic.io/graphql"', + `BACKEND_URL="${config.get('SERVER_URL')}/graphql"`, + ); await fs.writeFile(envFilePath, updatedEnvContent, 'utf-8'); } catch (error) {