Skip to content

Commit

Permalink
chore:(drop_me_after_review): add mock data for test
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed Feb 14, 2025
1 parent 675bc37 commit 35a06d7
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
71 changes: 70 additions & 1 deletion .github/.scripts/boost.ts
Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
;(() => {})()
import { promises as fs } from 'fs'
import path from 'path'
//TODO: replace with actual implementation
;(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)
}
})()
9 changes: 7 additions & 2 deletions .github/workflows/booster.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Boost backers' rewards in an active NFT campaign

permissions:
contents: write

on:
workflow_dispatch:
inputs:
Expand All @@ -19,6 +22,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: true

- name: Set up Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
Expand All @@ -35,7 +40,7 @@ jobs:
- name: Boost backers' rewards
run: |
npx tsx ./.github/.scripts/boost.ts \
npx tsx .github/.scripts/boost.ts \
--campaignId ${{ github.event.inputs.campaignId }} \
--amount ${{ github.event.inputs.amount }} \
--nft ${{ github.event.inputs.nft }}
Expand All @@ -53,4 +58,4 @@ jobs:
git commit -m "Add files generated by boost script" || echo "No changes to commit"
# Push the commit back to the current branch
git push
git push --force

0 comments on commit 35a06d7

Please sign in to comment.