pinax-network / substreams-sink

Substreams Sink library
MIT License
4 stars 1 forks source link

Add `list` command to all default sinks #13

Closed DenisCarriere closed 11 months ago

DenisCarriere commented 1 year ago

Could be a good way to do this with @substreams/core

program.command('list')
    .showHelpAfterError()
    .description('List all compatible output modules for a given Substreams package')
    .argument('<spkg>', 'URL or IPFS hash of Substreams package')
    .action(async spkg => {
        const modules = await list(spkg)
        logger.info('list', {modules})
        process.stdout.write(JSON.stringify(modules) + '\n')
    })

export async function list(url: string) {
    const spkg = await readPackage(url)
    const compatible = []

    for (const { name, output } of getModules(spkg)) {
        if (!output) continue
        logger.info('module', { name, output })
        if (!MESSAGE_TYPE_NAMES.includes(output.type.replace('proto:', ''))) continue
        compatible.push(name)
    }

    return compatible
}
chamorin commented 1 year ago

Good idea, just wondering where the MESSAGE_TYPE_NAMES will come from ?

DenisCarriere commented 1 year ago

Oh, no idea 🤷‍♂️ forgot where this example comes from

The MESSAGE_TYPE_NAMES section could probably be removed I think?

chamorin commented 1 year ago

Good I removed it, pushed the changes to main branch 👍

DenisCarriere commented 11 months ago

Implemented:


$ substreams-sink list https://github.com/pinax-network/subtivity-substreams/releases/download/v0.3.0-starknet/subtivity-antelope-v0.3.0.spkg
["map_block_stats","prom_out","kv_out"]