1.0.1 • Published 3 months ago

@inscriptionsplace/plugin-helper v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

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;
        }
    }
    
}