Skip to content

Commit

Permalink
feat: apply new query for snapshot api
Browse files Browse the repository at this point in the history
  • Loading branch information
zach-mantle committed Aug 27, 2024
1 parent 76d6b8c commit cb4620d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions apps/token-graph/src/app/snapshot/v2/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ const fetchL2SnapshotVotes = async (address: string, snapshot: string) => {
},
body: JSON.stringify({
query: `query GetDelegates($address: String, $snapshot: Int){
l2DelegateVotesChangeds(orderBy: blockNumber_DESC, limit: 1, where: {address_eq: $address, blockNumber_lte: $snapshot}) {
l2TotalVotesChangedsByAddressAndBlockNumber(address: $address, blockNumber: $snapshot, limit: 1) {
address
l2Votes
blockNumber
totalVotes
}
}
`,
Expand All @@ -28,16 +27,16 @@ const fetchL2SnapshotVotes = async (address: string, snapshot: string) => {

const snapshotVotes = await fetchSnapshotVotes.json();
const { data } = await snapshotVotes;
let l2Votes = "0";
let totalVotes = "0";

if (
data.l2DelegateVotesChangeds.length &&
data.l2DelegateVotesChangeds[0].l2Votes
data.l2DelegateVotesChangeds[0].totalVotes
) {
l2Votes = data.l2DelegateVotesChangeds[0].l2Votes;
totalVotes = data.l2DelegateVotesChangeds[0].totalVotes;
}

return l2Votes;
return totalVotes;
};

export async function GET() {
Expand Down

0 comments on commit cb4620d

Please sign in to comment.