From 65c8a1642f44fbf0073009def34f46eb1a162531 Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Thu, 13 Feb 2025 12:20:56 +0000 Subject: [PATCH] chore:(drop_me_after_review): add mock data for test --- .github/.scripts/boost.ts | 70 +++++++++++++++++++++++++++++++++- .github/workflows/booster.yaml | 15 ++++++-- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/.github/.scripts/boost.ts b/.github/.scripts/boost.ts index 39f7164e..192d97ae 100644 --- a/.github/.scripts/boost.ts +++ b/.github/.scripts/boost.ts @@ -1 +1,69 @@ -;(() => {})() +import { promises as fs } from 'fs' +import path from 'path' +;(async () => { + try { + // Define paths + const rootDir = process.cwd() // Assumes the script is run from the project root + const dataDir = path.join(rootDir, 'nft_boost_data') + const latestFilePath = path.join(dataDir, 'latest') + const jsonFileName = '0xDEADDEADDEADDEADDEADDEADDEADDEADDEADDEAD_666666.json' + const jsonFilePath = path.join(dataDir, jsonFileName) + + // 1. Create folder nft_boost_data if it doesn't exist + try { + await fs.access(dataDir) + // Folder exists + } catch { + // Folder does not exist; create it + await fs.mkdir(dataDir) + console.log(`Directory created: ${dataDir}`) + } + + // 2. Create file 'latest' in the nft_boost_data folder if it doesn't exist + try { + await fs.access(latestFilePath) + // File exists + } catch { + // File does not exist; create an empty file + await fs.writeFile(latestFilePath, '', 'utf8') + console.log(`File created: ${latestFilePath}`) + } + + // 3. Create JSON file if it doesn't exist with the specified template + try { + await fs.access(jsonFilePath) + // File exists + } catch { + // File does not exist; create it with template content + const jsonData = { + nftContractAddress: '0xDEADDEADDEADDEADDEADDEADDEADDEADDEADDEAD_666666', + boostPercentage: 0, + calculationBlock: 0, + holders: { + // Example structure: + // "0xHolderAddress1": { + // estimatedRBTCRewards: 0, + // estimatedRIFRewards: 0, + // boostedRBTCRewards: 0, + // boostedRIFRewards: 0, + // tokenId: "0xTokenId" + // }, + // "0xHolderAddress2": { + // estimatedRBTCRewards: 0, + // estimatedRIFRewards: 0, + // boostedRBTCRewards: 0, + // boostedRIFRewards: 0 + // } + }, + } + await fs.writeFile(jsonFilePath, JSON.stringify(jsonData, null, 2), 'utf8') + console.log(`JSON file created: ${jsonFilePath}`) + } + + // 4. Make the latest file contain the JSON file name + await fs.writeFile(latestFilePath, jsonFileName, 'utf8') + console.log(`Latest file updated with content: ${jsonFileName}`) + } catch (error) { + console.error('Error:', error) + } +})() diff --git a/.github/workflows/booster.yaml b/.github/workflows/booster.yaml index e7515ff8..daafe7e1 100644 --- a/.github/workflows/booster.yaml +++ b/.github/workflows/booster.yaml @@ -12,6 +12,8 @@ on: nft: description: 'The address of the NFT contract' required: true + # TODO: remove after testing/review: + pull_request: jobs: boost: @@ -39,10 +41,15 @@ jobs: BOOSTER_RPC_URL: ${{ secrets.BOOSTER_RPC_URL }} BOOSTER_CHAIN_ID: ${{ secrets.BOOSTER_CHAIN_ID }} run: | - npx tsx ./github/.scripts/boost.ts \ - --campaignId ${{ github.event.inputs.campaignId }} \ - --amount ${{ github.event.inputs.amount }} \ - --nft ${{ github.event.inputs.nft }} + # npx tsx ./github/.scripts/boost.ts \ + # --campaignId ${{ github.event.inputs.campaignId }} \ + # --amount ${{ github.event.inputs.amount }} \ + # --nft ${{ github.event.inputs.nft }} + # TODO: remove after testing/review: + npx tsx .github/.scripts/boost.ts \ + --campaignId "Vanguard_campaign_01" \ + --amount 20 \ + --nft "0xDEADDEADDEADDEADDEADDEADDEADDEADDEADDEAD_666666" - name: Commit and push changes run: |