tangle-network / relayer

🕸️ The Webb Relayer Network
https://webb-tools.github.io/relayer/
Apache License 2.0
22 stars 13 forks source link

[TASK] Convert the Websocket endpoint into a HTTP POST endpoint #536

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Overview

We want to remove the support of websockets in the relayer and instead of that we define a new API endpoint for our supported system that accepts the same payload we originally used in websockets and respond back immediately with a txhash that the caller can use for tracking the progress of the tx. (See #535 for more)

Motivation

This technically would allow the relayer to be more stateless that we could use to run on serverless infrastructure and easier to maintain. Another thing is it is much simpler this way, from the user respective or anyone wants to build on top of the relayer.

Task Checklist

Example of Valid payload

POST /api/v1/send/substrate/1081/6
{
  "extData": {
    "recipient": "0x306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20",
    "relayer": "0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22",
    "extAmount": "-32e976941b78c20c6d",
    "fee": "0x00000000000000034c5319aa65ddf393",
    "refund": "0x00000000000000000000000000000000",
    "token": 0,
    "encryptedOutput1": "0x84e190004e5a43dde02d3f172fb54a1171cb04e7599baa4b98666df3ca2a717a626f0828e23f9d84278786034793c5a6ef9fe8b3b6595c2e2224f5baa9dcb170ef79a2c6a5604d7d18995d6758a8140abd71c7cb7dde469b132ea3fedbfd33363672224f2dd7923ae681cab59fb24aa6e1e18edb3b58c48ab32b6fa5c25d5bbde58854945f6fb3d150fb0aeeaa313a54540de6ecc5556d417464df959214956f983e0c399666637c",
    "encryptedOutput2": "0x5aace9d7c642b3a67ed92d266e5b5b4c51581b3cef1d2869ca24a6971752d198624a66e5c456db7e7009b7727980ddc278e82c4287c8e81eebb06a4c13a11669382bfe24253c78bc6919ea5864b2cf3369d90bc8faa618c69a97aeee7ddafbe1f1753c5339face258d129565771ad5681ff76c6fef0586823d307098ea9bea68883fdb33fa11afbb67427bc0014dbcdf01b9498f49b3dd62d613dc09764a2a56df97c903eb68571f"
  },
  "proofData": {
    "proof": "0x107210365314564a7e2cfe0471f8e3a3390b01796c843d7d5f4973d6621654e1246f4ff88fc44c91c392491bd0ba603dd7b6b459664882c6d2a5fa1e4f3f87df2d14edc4999a85755d12f12703544f9b00b964781c086317059a06b07d5906d321cdbb2c9fbd87a87c1de18940c5b2ca9419f80686eb1ea784736e98d995f8371fab9e8b65e0faf6923db10158477fc8d647e049e5e8ecdb0540031f7edbac2426fbaa73bd0bb2a7690a5778301313c17549edbd4fad5c6a65e30c788d681d350b5fd5bdd5ad451f2cdc9ae33a4473cfc697cec2925eb3303e3c33ad6e45d6211ce6d2bbf973bc8a71f74c7a0fdc9327ff45edda4eb8c2f261484121f05568d1",
    "extDataHash": "0x0ba90a0ff6fbb0b35b99f5828bb17a9a90d9d4608973294d2b9d885c411325bd",
    "publicAmount": "0x30644e72e131a029b85045b68181585d2833e84879b9705b0e1847ce11600001",
    "roots": [
      "0x0a10b873a48008d5d39808fab818591815ce2a83b20ad384a6bb26474a4dbc37",
      "0x23ab323453748129f2765f79615022f5bebd6f4096a796300aab049a60b0f187"
    ],
    "extensionRoots": [],
    "outputCommitments": [
      "0x09bcfab435d5e9bbfb3cc5ad879d8354700a0a3aa6d5a5a247c9264e5e03c0b0",
      "0x202fc1611fbb99fcec34ae1362185d9ce1cafc1d9b53a636b3a530a29015f4c6"
    ],
    "inputNullifiers": [
      "0x270ac8f4c30e21372a0b692617788c8d2da0cc6864513f6d5225c57ffcd2062a",
      "0x02ad7bfd630e3965db175940d38f2e8f74b38e387d1daf5aa2d725aef363dd08"
    ]
  }
}