Filter cards from names that don't own the linked poll

This commit is contained in:
QuickMythril 2024-12-30 02:30:19 -05:00
parent a10c1a061d
commit 3ccaa50e09

View File

@ -217,8 +217,9 @@ const loadCards = async () => {
return null;
}
// Check if the name is currently owned by any address
let nameData;
try {
const nameData = await qortalRequest({
nameData = await qortalRequest({
action: "GET_NAME_DATA",
name: card.name
});
@ -232,6 +233,7 @@ const loadCards = async () => {
return null;
}
// If structure is valid and name is owned, we consider the card valid
card.address = nameData.owner
return card;
})
);
@ -282,6 +284,26 @@ const loadCards = async () => {
return;
}
// Fetch the poll's owner (the address that created the poll)
let pollOwner;
try {
pollOwner = await fetchPollOwner(cardDataResponse.poll);
if (!pollOwner) {
console.warn(`Skipping card, could not fetch poll owner for: ${cardDataResponse.poll}`);
removeSkeleton(card.identifier);
return;
}
} catch (err) {
console.warn(`Error fetching poll owner for poll ${cardDataResponse.poll}`, err);
removeSkeleton(card.identifier);
return;
}
if (card.address !== pollOwner) {
console.warn(`Skipping card ${card.identifier}, mismatch: name owner != poll owner`);
removeSkeleton(card.identifier);
return;
}
// Fetch poll results
const pollResults = await fetchPollResults(cardDataResponse.poll);
const BgColor = generateDarkPastelBackgroundBy(card.name)