bestinslot-xyz / OPI

Open Protocol Indexer, OPI, is the best-in-slot open-source indexing client for meta-protocols on Bitcoin.
Apache License 2.0
202 stars 110 forks source link

May I ask when Runes Indexer will officially support #38

Closed Meteriox closed 4 months ago

Meteriox commented 6 months ago

i have seen there is runes api and runes index dir in this repo, you guys are working on this. i wonder when you guys will support runes officially or i can use this repo to index runes txs currently.

nathanddrake commented 5 months ago

Hi @yibishufange, yes you can use it to index runes now and in the future 👍

Meteriox commented 5 months ago

Hi @yibishufange, yes you can use it to index runes now and in the future 👍

okay, thanks for reply. however, i have another question, i have tried brc20 indexer already, and i can get activities on certain block, so i can recognize who has trasfered brc20 to my wallet address, and also amount tick info etc. but when i tried runes indexer, i cannot find corresponding api to do so, as /v1/runes/activity_on_block api does not return the same as brc20 does. so i wonder how can i get such info as from address, amount, rune name via indexing a certain block?

samedcildir commented 5 months ago

API in the repository is actually added as a reference guide to build API using OPI indexer. It is not a complete API but it has some building blocks which can be extended by adding new endpoints. Also the event structure of BRC-20 and Runes are very different so the response cannot be in the same structure.

However, you can simply change:

    select event_type, outpoint, pkscript, rune_id, amount
                  from runes_events re
                  where block_height = $1
                  order by id asc;
    let res = await query_db(query, [block_height])
    let result = []
    for (const row of res.rows) {
      result.push({
        event_type: event_type_id_to_name[row.event_type],
        outpoint: row.outpoint,
        pkscript: row.pkscript,
        rune_id: row.rune_id,
        amount: row.amount
      })
    }

to:

    select event_type, outpoint, pkscript, wallet_addr, rune_id, amount
                  from runes_events re
                  where block_height = $1
                  order by id asc;
    let res = await query_db(query, [block_height])
    let result = []
    for (const row of res.rows) {
      result.push({
        event_type: event_type_id_to_name[row.event_type],
        outpoint: row.outpoint,
        pkscript: row.pkscript,
        wallet_addr: row.wallet_addr,
        rune_id: row.rune_id,
        amount: row.amount
      })
    }

to include wallet_addr information in the response of this endpoint.