Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode execution code #57

Merged
merged 9 commits into from
Feb 29, 2024
Merged

Decode execution code #57

merged 9 commits into from
Feb 29, 2024

Conversation

chapati23
Copy link
Contributor

@chapati23 chapati23 commented Feb 27, 2024

Before

Screenshot 2024-02-27 at 15 42 44

After

Screenshot 2024-02-27 at 15 42 51

Description

I added an integration with the Celo Explorer GraphQL API to fetch contract names & abis on the Execution Code component to show users in more human-readable form what a proposal will actually do.

Unfortunately Apollo makes it a bit difficult to have more than 1 GraphQL endpoint so I needed to change the project set up a bit to allow querying different GraphQL endpoints.

Basically, there's a new context parameter apiName that can be passed to useQuery or useSuspenseQuery that can decided which GraphQL endpoint a query will be executed against. For example:

  const { data, error } = useQuery(GetContractsInfo, {
    variables: { addresses },
    context: { apiName: "celoExplorer" },
    skip: !addresses.length,
  });

How to test

  1. Start a local server (or use the Vercel auto-generated URL after it's been deployed)
  2. Navigate to a proposal details page (the one titled "Send 100 tokens to super devs" has real calldata)
  3. See that the target and calldata have been decoded and are in human-readable form now
  4. Review the code, specifically around the new GraphQL structure

Copy link

vercel bot commented Feb 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
governance-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2024 4:43pm

Copy link
Contributor

@tplocic20 tplocic20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

celo explorer only has a graphql api so we need to
add an additional endpoint to our graphql setup that
is separate from our mento subgraph on the graph
if a calldata target is verified on celo explorer, pull name + abi
and decode the calldata. if not, show raw calldata
we need it in the codegen config where nextjs auto-loading of
.env files is not available
i feel obligated to say that i was very surprised to
read that nextjs explicitly says to check .env in to
version control which i find highly unusual but that's
the way they want it: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#default-environment-variables
this will dynamically load the righ celo explorer
api url depending on the current chain id
@chapati23 chapati23 merged commit 4ec1821 into develop Feb 29, 2024
3 checks passed
@chapati23 chapati23 deleted the feat/decode-execution-code branch February 29, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants