darkforest-eth / plugins

A showcase of Dark Forest plugins from the community!
https://plugins.zkga.me
GNU General Public License v3.0
122 stars 136 forks source link

New plugin: Active Players #192

Closed davidryan59 closed 2 years ago

davidryan59 commented 2 years ago

Plugin uses GraphQL to query a list of the 1000 latest arrivals (moves)

A table is created of which players have sent the most moves, in decreasing frequency

Useful for:

davidryan59 commented 2 years ago

This plugin requires data from The Graph

Graph API URL worked for Round 4, but I don't think it worked for Round 5, but I don't know why?

ichub commented 2 years ago

Hey @davidryan59 - we released a broken subgraph for round 5, but it's since been fixed! Do you think you could test your plugin out with the following subgraph? https://thegraph.com/hosted-service/subgraph/darkforest-eth/dark-forest-v06-round-5

davidryan59 commented 2 years ago

Hey @davidryan59 - we released a broken subgraph for round 5, but it's since been fixed! Do you think you could test your plugin out with the following subgraph? https://thegraph.com/hosted-service/subgraph/darkforest-eth/dark-forest-v06-round-5

@ichub I have tried using the graph API above, and it did not work, with error:

"Access to fetch at 'https://thegraph.com/hosted-service/subgraph/darkforest-eth/dark-forest-v06-round-5' from origin 'https://zkga.me' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

It worked with this Graph API: https://api.thegraph.com/subgraphs/name/darkforest-eth/dark-forest-v06-round-5

I think this line will need to update in any future rounds anyway.

How would you like to proceed?

davidryan59 commented 2 years ago

From @ichub via Discord: "We could add df.getGraphApiUrl(). I can get that in tomorrow"

ichub commented 2 years ago

From @ichub via Discord: "We could add df.getGraphApiUrl(). I can get that in tomorrow"

done! we've added the following API:

import {THEGRAPH_API_URL} from "https://cdn.skypack.dev/@darkforest_eth/constants";
console.log(THEGRAPH_API_URL);
davidryan59 commented 2 years ago

@ichub I have used THEGRAPH_API_URL import now, tested in v0.6.5, it works well. Thanks!

Ready for review now?