@inscriptionsplace/plugin-helper

1.0.1 • Public • Published

Inscriptions.place

Write your inscriptions indexer plugin with this interface

Usage

import Plugin from '@inscriptionsplace/plugin-helper';

class MyPlugin extends Plugin {

    //Initialize your plugin
    async init() {
        console.log('MyPlugin loaded')
    }

    //Start your plugin
    async start() {
        console.log('MyPlugin started')
    }

    //Process events
    async processProtocolEvent(protocol, event, data) {
        switch (protocol) {
            case 'eep20':
                switch (event) {
                    case 'transfer':
                        console.log('new eep20 transfer!:', data)
                        break;
                }
        }
    }

}

Custom protocol

import Plugin from '@inscriptionsplace/plugin-helper';



class BlockchainLogProtocolPlugin extends Plugin {

    //Initialize your plugin
    async init() {
        const bcLogProtocol = new BlockchainLogProtocol(this.storage, this.api, this.sqlIndex, this.processor);
        await this.registerProtocol('log', BlockchainLogProtocol);
    }

 

}

class BlockchainLogProtocol{
    
    async processTx(etx){
        let {op, log} = etx.protocolData;
        
        switch (op) {
            case 'log':
                console.log('new log event!:', log)
                break;
        }
    }
    
}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @inscriptionsplace/plugin-helper

      Weekly Downloads

      4

      Version

      1.0.1

      License

      ISC

      Unpacked Size

      7.96 kB

      Total Files

      5

      Last publish

      Collaborators

      • lailune