Created
November 1, 2024 18:16
-
-
Save PBillingsby/d991a370c145ad349c350a4bce46d07a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const walletAddresses = [ | |
| // '0x0B11006bce54971f74F1F5a7c150e86f58328440', // Random | |
| '0xC44CB6599bEc03196fD230208aBf4AFc68514DD2', // Strawberry | |
| '0x87634d76668F2B24DE80eAF420552C6ccDC47490', // Rodebrecht 4090 | |
| // '0xe70a47B75496D098dE30B4F1f454Dd32642104F5' // Sigmund | |
| ]; | |
| const baseUrl = 'https://api-testnet.lilypad.tech/pow-logs/rewards'; | |
| const dateMapping = [ | |
| // { date: '2024-09-06', phase: 5, day: 3 }, | |
| // { date: '2024-09-07', phase: 5, day: 4 }, | |
| // { date: '2024-09-08', phase: 5, day: 5 }, | |
| // { date: '2024-09-09', phase: 5, day: 6 }, | |
| { date: '2024-09-09', phase: 5, day: 6 }, | |
| { date: '2024-09-23', phase: 6, day: 6 }, | |
| { date: '2024-09-28', phase: 6, day: 11 }, | |
| { date: '2024-09-30', phase: 6, day: 13 }, | |
| // { date: '2024-09-11', phase: 5, day: 8 }, | |
| // { date: '2024-09-12', phase: 5, day: 9 }, | |
| // { date: '2024-09-13', phase: 5, day: 10 }, | |
| // { date: '2024-09-14', phase: 5, day: 11 }, | |
| // { date: '2024-09-15', phase: 6, day: 1 }, | |
| // { date: '2024-09-16', phase: 6, day: 2 }, | |
| // { date: '2024-09-17', phase: 6, day: 3 } | |
| ]; | |
| async function fetchRewardsData() { | |
| const groupedData = []; | |
| for (const mapping of dateMapping) { | |
| for (const [index, address] of walletAddresses.entries()) { | |
| try { | |
| const url = `${baseUrl}/${address}?day=${mapping.day}&phase=${mapping.phase}`; | |
| const response = await fetch(url); | |
| if (!response.ok) { | |
| console.error(`Error fetching data for ${address} on ${mapping.date}`); | |
| continue; | |
| } | |
| const data = await response.json(); | |
| // Format date to mm/dd/yyyy | |
| const date = new Date(mapping.date); | |
| const formattedDate = `${date.getMonth()}/${date.getDate()}/${date.getFullYear()}`; | |
| groupedData.push({ | |
| 'Node': `Node ${index === 0 ? "Strawberry" : "Rodebrecht"}`, | |
| 'Date': formattedDate, | |
| 'Today Points': parseFloat(data.TodayPoints).toFixed(2), | |
| 'Total Points': parseFloat(data.TotalPoints).toFixed(2) | |
| }); | |
| } catch (error) { | |
| console.error(`Error processing ${address} on ${mapping.date}:`, error); | |
| } | |
| } | |
| } | |
| return groupedData; | |
| } | |
| async function main() { | |
| console.log('Fetching rewards data...\n'); | |
| try { | |
| const data = await fetchRewardsData(); | |
| // Log each entry in the desired format | |
| data.forEach(entry => { | |
| console.log(`${entry.Node} - ${entry.Date}`); | |
| console.log(`Today Points: ${entry['Today Points']}`); | |
| console.log(`Total Points: ${entry['Total Points']}`); | |
| console.log('------------------------'); | |
| }); | |
| } catch (error) { | |
| console.error('Error fetching data:', error); | |
| } | |
| } | |
| // Run the script | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment