-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,175 additions
and
353 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
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 |
---|---|---|
@@ -0,0 +1,249 @@ | ||
const express = require('express') | ||
Check failure on line 1 in api/index.js GitHub Actions / Lint
|
||
const app = express() | ||
|
||
const port = 3000 | ||
app.use(express.json()); | ||
|
||
app.get('/', (req, res) => { | ||
res.send('Hello, Express.js!'); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Listening on port ${port}`) | ||
}) | ||
|
||
app.post("/api/bootstrap", async (req, res) => { | ||
const events = req.body; | ||
console.log(events) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
//Loop through each item in the apply array | ||
events.apply.forEach((item) => { | ||
// Loop through each transaction in the item | ||
console.log(item) | ||
item.transactions.forEach((transaction) => { | ||
// If the transaction has operations, loop through them | ||
if (transaction.operations?.length) { | ||
transaction.operations.forEach((operation) => { | ||
// Log the operation | ||
console.log({ operation }); | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
console.log( | ||
{events: transaction.metadata.receipt.events[0].data}, | ||
{metadata: transaction.metadata}, | ||
{transaction: transaction} | ||
) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
}); | ||
} else { | ||
console.log( | ||
{events: transaction.metadata.receipt.events[0].data}, | ||
{metadata: transaction.metadata}, | ||
{transaction: transaction} | ||
) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
} | ||
}); | ||
console.log('/////////////////////////////////////END/////////////////////////////////////') | ||
}); | ||
|
||
// Send a response back to Chainhook to acknowledge receipt of the event | ||
res.status(200).send({ message: "Bootstrap added!" }); | ||
}); | ||
|
||
app.post("/api/proposal-submission", async (req, res) => { | ||
const events = req.body; | ||
console.log(events) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
//Loop through each item in the apply array | ||
events.apply.forEach((item) => { | ||
// Loop through each transaction in the item | ||
item.transactions.forEach((transaction) => { | ||
// If the transaction has operations, loop through them | ||
if (transaction.operations?.length) { | ||
transaction.operations.forEach((operation) => { | ||
// Log the operation | ||
console.log({ operation }); | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
}); | ||
} else { | ||
console.log( | ||
{events: transaction.metadata.receipt.events[0].data}, | ||
{metadata: transaction.metadata}, | ||
{transaction: transaction} | ||
) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
} | ||
}); | ||
console.log('///////////////////////////////////////// END \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') | ||
}); | ||
|
||
|
||
// Send a response back to Chainhook to acknowledge receipt of the event | ||
res.status(200).send({ message: "Proposal added!" }); | ||
}); | ||
|
||
app.post("/api/vote", async (req, res) => { | ||
const events = req.body; | ||
console.log(events) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
//Loop through each item in the apply array | ||
events.apply.forEach((item) => { | ||
// Loop through each transaction in the item | ||
item.transactions.forEach((transaction) => { | ||
// If the transaction has operations, loop through them | ||
if (transaction.operations?.length) { | ||
transaction.operations.forEach((operation) => { | ||
// Log the operation | ||
console.log({ operation }); | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
}); | ||
} else { | ||
console.log( | ||
{events: transaction.metadata.receipt.events[0].data}, | ||
{metadata: transaction.metadata}, | ||
{transaction: transaction} | ||
) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
} | ||
}); | ||
console.log('///////////////////////////////////////// END \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') | ||
}); | ||
|
||
|
||
// Send a response back to Chainhook to acknowledge receipt of the event | ||
res.status(200).send({ message: "Vote added!" }); | ||
}); | ||
|
||
app.post("/api/bootstrap", async (req, res) => { | ||
const events = req.body; | ||
console.log(events) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
//Loop through each item in the apply array | ||
events.apply.forEach((item) => { | ||
// Loop through each transaction in the item | ||
item.transactions.forEach((transaction) => { | ||
// If the transaction has operations, loop through them | ||
if (transaction.operations?.length) { | ||
transaction.operations.forEach((operation) => { | ||
// Log the operation | ||
console.log({ operation }); | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
}); | ||
} else { | ||
console.log( | ||
{events: transaction.metadata.receipt.events[0].data}, | ||
{metadata: transaction.metadata}, | ||
{transaction: transaction} | ||
) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
} | ||
}); | ||
console.log('///////////////////////////////////////// END \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') | ||
}); | ||
|
||
|
||
// Send a response back to Chainhook to acknowledge receipt of the event | ||
res.status(200).send({ message: "Vote added!" }); | ||
}); | ||
|
||
app.post("/api/test", async (req, res) => { | ||
const events = req.body; | ||
console.log(events) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
//Loop through each item in the apply array | ||
events.apply.forEach((item) => { | ||
// Loop through each transaction in the item | ||
item.transactions.forEach((transaction) => { | ||
// If the transaction has operations, loop through them | ||
if (transaction.operations?.length) { | ||
transaction.operations.forEach((operation) => { | ||
// Log the operation | ||
console.log({ operation }); | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
}); | ||
} else { | ||
console.log( | ||
{events: transaction.metadata.receipt.events[0].data}, | ||
{metadata: transaction.metadata}, | ||
{transaction: transaction} | ||
) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
} | ||
}); | ||
console.log('///////////////////////////////////////// END \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') | ||
}); | ||
|
||
// Send a response back to Chainhook to acknowledge receipt of the event | ||
res.status(200).send({ message: "Test Success!" }); | ||
}); | ||
|
||
app.post("/api/conclude-proposal", async (req, res) => { | ||
const events = req.body; | ||
console.log(events) | ||
console.log(' ') | ||
console.log('**********************************************************************************************************') | ||
console.log(' ') | ||
//Loop through each item in the apply array | ||
events.apply.forEach((item) => { | ||
// Loop through each transaction in the item | ||
console.log(item) | ||
// item.transactions.forEach((transaction) => { | ||
// // If the transaction has operations, loop through them | ||
// if (transaction.operations?.length) { | ||
// transaction.operations.forEach((operation) => { | ||
// // Log the operation | ||
// console.log({ operation }); | ||
// console.log(' ') | ||
// console.log('**********************************************************************************************************') | ||
// console.log(' ') | ||
// }); | ||
// } else { | ||
// console.log( | ||
// {events: transaction.metadata.receipt.events[0].data}, | ||
// {metadata: transaction.metadata}, | ||
// {transaction: transaction} | ||
// ) | ||
// console.log(' ') | ||
// console.log('**********************************************************************************************************') | ||
// console.log(' ') | ||
// } | ||
// }); | ||
console.log('///////////////////////////////////////// END \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') | ||
}); | ||
|
||
|
||
// Send a response back to Chainhook to acknowledge receipt of the event | ||
res.status(200).send({ message: "Conclusion Success!" }); | ||
}); |
Oops, something went wrong.