Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/server_vote_receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ async function pdaExists(pda) {
// Endpoint to append data and initialize PDA if needed
app.post('/', async (req, res) => {
const { first_block_id, final_hash, pubkey } = req.body;
if (!first_block_id || !final_hash || !pubkey) {
return res.status(400).json({ error: "Bad request", details: "One or more of required params were not supplied" });;
}
console.log(req.body);
const block_id = first_block_id;
console.log(block_id + " " + pubkey + "\n");

try {
const uniqueId = new BN(block_id);
const pubkeyObj = new PublicKey(pubkey);

const [pda, bump] = await PublicKey.findProgramAddress(
[Buffer.from("pda_account"), uniqueId.toArrayLike(Buffer, "le", 8)],
program.programId
);
} catch (err) {
res.status(400).json({ error: "Bad request", details: err.toString() });
}

try {
// Check if the PDA already exists
Expand Down