diff --git a/api-examples/get_ballots.html b/api-examples/get_ballots.html index 917f848..d5c8032 100644 --- a/api-examples/get_ballots.html +++ b/api-examples/get_ballots.html @@ -1,66 +1,122 @@ - + - - - Get Ballots + + + Compound Governance Ballots + + + - -

Proposal ID:

-
- + - - + const formattedHtml = ballots.map(ballot => { + const supportStatus = ballot.support ? 'In Favor' : 'Against'; + const supportColor = ballot.support ? 'text-green-600' : 'text-red-600'; + const votesFormatted = parseFloat(ballot.votes).toFixed(2); + const addressShort = `${ballot.voter.address.substring(0, 6)}...${ballot.voter.address.substring(38)}`; + return ` +
+

${ballot.voter.address}

+
+

+ Support: + ${supportStatus} +

+

+ Votes: + ${votesFormatted} COMP +

+
+
+ `; + }).join(''); + + ballotListContainer.innerHTML = formattedHtml; + }; + + // Fetch data from Compound API + fetch(apiUrl) + .then(response => { + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + return response.json(); + }) + .then(result => { + const submittedBallots = result.proposal_vote_receipts || []; + renderBallots(submittedBallots); + }) + .catch(error => { + console.error("API Fetch Error:", error); + ballotListContainer.innerHTML = ''; + errorText.innerText = `Could not fetch data. ${error.message}`; + errorElement.classList.remove('hidden'); + }); + }); + +