0xStation / proposer

1 stars 0 forks source link

Moralis #754

Closed mcgingras closed 1 year ago

mcgingras commented 1 year ago

WARNING DO NOT RUN MIGRATIONS UNTIL THE SEED SCRIPT IS RUN TO PRESERVE TRANSACTION HASHES

What's included in this pr + description

Adding moralis webhook support, so gnosis payments are automatically responded to. There are two different flavors of actions we are listening to now -- a successful payment, or a rejection. This PR includes an API endpoint to listen to the webhook, and UI changes responded to such actions, including the ability to re-queue rejected payments.

Motivation & Context

Our old code for handling gnosis transactions was janky and running in the client. This runs as an API endpoint to immediately respond to changes, and also offers improved UI to show rejections and allow re-queuing.

Steps to test

This one can be a bit tricky to test locally, because of the webhooks. I would recommend downloading ngrok so you can funnel online requests to something running locally. https://ngrok.com/

Once you have ngrok running, you'll need to add the url it spits out to the .env file under NEXT_PUBLIC_MORALIS_WEBHOOK_URL

You will also need the NEXT_PUBLIC_MORALIS_API_KEY which I can share.

If we are testing on staging, this should not be an issue, since the env variables are set up automatically.

Test steps

  1. create a new proposal with payment to a gnosis safe
  2. approve it, queue the tx
  3. reject the first transaction on gnosis
  4. see that the UI says it was rejected
  5. click "re-queue"
  6. see a new transaction on gnosis
  7. approve the transaction on gnosis
  8. check the UI, it should show the approved tx

Cases to test

  1. gnosis singer, approve on first try ✅
  2. gnosis signer, reject first tx, requeue, approve ✅
  3. wallet signer, pay on first try (no such thing as rejecting here, but we want to make sure history is working) ✅
  4. wallet signer, attach tx ✅
  5. gnosis signer, attach tx ✅
  6. gnosis signer, reject first tx, attach tx for second tx ❌ (overriding the failed transaction)

Screenshots and/or loom video

Screenshot 2022-11-21 at 7 06 01 PM

Outstanding issues

After execution, the data is stale. The webhook response should ideally revalidate the data so it is immediately fresh on the UI. Not sure if it's possible though for backend APIs to call client side invalidation

Relevant docs

Conner as a resource for Gnosis/solidity lol

vercel[bot] commented 1 year ago

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

Name Status Preview Updated
web ✅ Ready (Inspect) Visit Preview Nov 24, 2022 at 0:40AM (UTC)
what-the-diff[bot] commented 1 year ago