PizzaDAO / pizza-smartcontract

Repository for Rare Pizzas smart contracts
GNU General Public License v3.0
17 stars 4 forks source link

Create blockchain follower #88

Open AddressXception opened 1 year ago

AddressXception commented 1 year ago

This issue is to create a nodejs blockchain follower that can listen for events on the OrderAPIConsumer and call the backend api to execute a render.

This follower will replace the chainlink node in the existing infrastructure, but we do not want to make many changes to the python rendering api if we can avoid it, so we'd like to use the same process/workflow.

Today, when a new request comes in (see #86 and #87 ) the chainlink node should process the incoming request and call the api with the information it parses from the on-chain request event. It also provides a callback url for the python api to call when it is completed so that the chainlink node can post back the encoded IPFS hash to fulfill the request.

We want to kepe that same process but simplify it.

Implementation Details

  1. create a nodejs command line application that is configurable with an env file
  2. using ethers.js and alchemy, listen to the orderapi consumer contract abi for requested events
  3. when a request is received, call the order pizza api found here
  4. ☝️ be sure to include a callback url in the request model
  5. when the callback comes in, create a transaction using the authorized singing account that fulfills the request with the ipfs hash of the pizza

note because of size limits, ur ipfs encoding strips off the first two checksum bytes so that the data payload fits into the 31 byte limit of a single parameter slot. those implementation details exist in the current implementation and are documented in the code.

AddressXception commented 1 year ago

oh one more thing to note, the current chainlink implementation relies on an inbound and outbound bearer auth token to authenticate comms between the rendering api and the chainlink node. in theory we dont need to do this since this follower will only be running in a closed environment and will not be addressable from the outside world. just something to be aware of because the render api does expect that value to exist, iirc