indexsupply / shovel

An Ethereum to Postgres indexer
https://indexsupply.com/shovel
MIT License
172 stars 22 forks source link

validating columns: missing column for from #243

Closed wagmiwiz closed 7 months ago

wagmiwiz commented 7 months ago

Hi. I am trying to index two events into the same table (transfers of 721 and 1155 nfts).

First integration works fine but when I add the second integrations with the same table name I get a cryptic startup error: loading tasks: setting up main task: initializing integration: building abi integration: validating columns: missing column for from error. Any pointers what may be wrong in this config?

{
  "pg_url": "...",
  "eth_sources": [
    {
      "name": "mainnet",
      "chain_id": 1,
      "url": "...",
      "concurrency": 10,
      "batch_size": 100
    }
  ],
  "integrations": [
    {
      "name": "nft-transfers",
      "enabled": true,
      "sources": [
        {
          "name": "mainnet",
          "start": ...
        }
      ],
      "table": {
        "name": "transfers",
        "columns": [
          { "name": "chain_id", "type": "numeric" },
          { "name": "log_addr", "type": "bytea" },
          { "name": "block_time", "type": "numeric" },
          { "name": "tx_hash", "type": "bytea" },
          { "name": "f", "type": "bytea" },
          { "name": "t", "type": "bytea" },
          { "name": "id", "type": "numeric" },
          { "name": "quantity", "type": "numeric" }
        ]
      },
      "block": [
        { "name": "chain_id", "column": "chain_id" },
        { "name": "block_time", "column": "block_time" },
        { "name": "tx_hash", "column": "tx_hash" },
        {
          "name": "log_addr",
          "column": "log_addr",
          "filter_op": "contains",
          "filter_arg": [
            "...",
          ]
        }
      ],
      "event": {
        "anonymous": false,
        "inputs": [
          {
            "indexed": true,
            "internalType": "address",
            "name": "from",
            "type": "address",
            "column": "f"
          },
          {
            "indexed": true,
            "internalType": "address",
            "name": "to",
            "type": "address",
            "column": "t"
          },
          {
            "indexed": true,
            "internalType": "uint256",
            "name": "tokenId",
            "type": "uint256",
            "column": "id"
          }
        ],
        "name": "Transfer",
        "type": "event"
      }
    },
    {
      "name": "erc1155-single-transfers",
      "enabled": true,
      "sources": [
        {
          "name": "mainnet",
          "start": ...
        }
      ],
      "table": {
        "name": "transfers"
      },
      "block": [
        { "name": "chain_id", "column": "chain_id" },
        { "name": "block_time", "column": "block_time" },
        { "name": "tx_hash", "column": "tx_hash" },
        {
          "name": "log_addr",
          "column": "log_addr",
          "filter_op": "contains",
          "filter_arg": ["..."]
        }
      ],
      "event": {
        "anonymous": false,
        "inputs": [
          {
            "indexed": true,
            "internalType": "address",
            "name": "operator",
            "type": "address"
          },
          {
            "indexed": true,
            "internalType": "address",
            "name": "from",
            "type": "address",
            "column": "f"
          },
          {
            "indexed": true,
            "internalType": "address",
            "name": "to",
            "type": "address",
            "column": "t"
          },
          {
            "indexed": false,
            "internalType": "uint256",
            "name": "id",
            "type": "uint256",
            "column": "id"
          },
          {
            "indexed": false,
            "internalType": "uint256",
            "name": "value",
            "type": "uint256",
            "column": "quantity"
          }
        ],
        "name": "TransferSingle",
        "type": "event"
      }
    }
  ]
}
ryandotsmith commented 7 months ago

Hi. You will need to provide the complete table definition for the erc1155-single-transfers integration. As it stands, your config includes the table name but is missing the table columns. You can copy/paste the table definition from the nft-transfers integration.

OR, if you are using TS, you might find this package helpful for abstracting the config creation: https://jsr.io/@indexsupply/shovel-config

wagmiwiz commented 7 months ago

Thanks! The docs kinda alluded to one being able to re-use the name without copy pasting the whole table definition. The TS helper package looks great, will definitely use.

ryandotsmith commented 7 months ago

I took a pass at improving the docs for table. Let me know if this is helpful: https://indexsupply.com/shovel/docs/#table

wagmiwiz commented 7 months ago

Yup that's more clear, thanks!