-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:(drop_me_after_review): add mock data for test
- Loading branch information
Showing
2 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters