dcSpark / carp

A modular indexer for Cardano with an SQL Postgres backend (an alternative to the well known cardano-db-sync)
MIT License
105 stars 22 forks source link

mintBurnHistory endpoint: add addresses (credentials) to the output #179

Closed ecioppettini closed 7 months ago

ecioppettini commented 7 months ago

context here: https://github.com/PaimaStudios/paima-engine/issues/326

I'm not super convinced about the query yet (it works, but I'm not sure about the distinct), but I want to define the api first.

This adds two fields to the response in the mint burn history endpoint.

The idea is that burns would look like this:

  {
    "assets": {
      "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe": {
        "546f6b656e31": "-500"
      }
    },
    "actionSlot": 733071,
    "metadata": "...",
    "txId": "58e4166f029f8da36172db20d9089b5930109584fc4331641a694438a513090d",
    "block": "3bf59edcb5114d492ecd8e41792cd8fd4bf14a8569e80bf93d7141cf9621729c",
    "inputAddresses": {
      "8200581ca44a4b45469f41af5f61fcfe2098e3230b935ee074fcf0f202654c62": [
        {
          "policyId": "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe",
          "assetName": "546f6b656e31",
          "amount": "500"
        }
      ]
    },
    "outputAddresses": {}
  }

while mints would look like:

  {
    "assets": {
      "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe": {
        "546f6b656e4d6574616461746132": "1",
        "546f6b656e4d6574616461746131": "1"
      }
    },
    "actionSlot": 733097,
    "metadata": "...",
    "txId": "98a9eeb50ee68a2dcb461bbcdf115ee5b395ff797f2904c6ddca7ffb449dc2ec",
    "block": "0425becb95ea75aa7c6e19b7a36046dc9d976ddfc239b30126fabd306a96ecf1",
    "inputAddresses": {},
    "outputAddresses": {
      "8200581c4b2e7295ac876cfdf70e82c1cb8df3ee5cb23d93949e3322230fc447": [
        {
          "policyId": "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe",
          "assetName": "546f6b656e4d6574616461746131",
          "amount": "1"
        }
      ],
      "8200581c9f07ae02672368b23c0ea38fe4272e3a8fe5c7a34948121ad2489968": [
        {
          "policyId": "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe",
          "assetName": "546f6b656e4d6574616461746132",
          "amount": "1"
        }
      ]
    }
  }

Currently the order in the two mappings is unspecified. I'm not really sure if it matters or not. The amount are included mostly because I think there could be extra non-minting inputs, for example, and that makes it more clear?