A core library for developing plugins for Hyperion - a scalable Full History API Solution for EOSIO-based blockchains.
Hyperion Plugin Core provides the base classes and interfaces needed to develop custom plugins for the Hyperion History API. This package allows developers to extend Hyperion's functionality by creating plugins that can process blockchain actions, deltas, and stream events.
npm install @eosrio/hyperion-plugin-core
- Node.js 16+
- Fastify 5.4.0+ (peer dependency)
import { HyperionPlugin, HyperionAction, HyperionDelta } from '@eosrio/hyperion-plugin-core';
import { FastifyInstance } from 'fastify';
class MyCustomPlugin extends HyperionPlugin {
constructor(config?: any) {
super(config);
// Set plugin properties
this.internalPluginName = 'my-custom-plugin';
this.indexerPlugin = true; // Set to true if this plugin processes indexer data
this.apiPlugin = true; // Set to true if this plugin adds API routes
// Register action handlers
this.actionHandlers.push({
action: 'transfer',
contract: 'eosio.token',
handler: this.handleTransfer.bind(this)
});
// Register delta handlers
this.deltaHandlers.push({
table: 'accounts',
contract: 'eosio.token',
handler: this.handleAccountDelta.bind(this)
});
}
// Implement required abstract method
addRoutes(server: FastifyInstance): void {
server.get('/my-plugin/data', async (request, reply) => {
// Handle API request
return { success: true, data: 'Your plugin data' };
});
}
// Custom action handler
async handleTransfer(action: HyperionAction): Promise<void> {
// Process transfer action
console.log(`Transfer: ${action.act.data.from} -> ${action.act.data.to}`);
}
// Custom delta handler
async handleAccountDelta(delta: HyperionDelta): Promise<void> {
// Process account delta
console.log(`Account delta for ${delta.scope}`);
}
}
export default MyCustomPlugin;
In your Hyperion configuration, you would reference your plugin:
{
"plugins": [
{
"name": "my-custom-plugin",
"args": {
"option1": "value1",
"option2": "value2"
}
}
]
}
The base class for all Hyperion plugins.
internalPluginName
: String identifier for the pluginindexerPlugin
: Boolean flag indicating if the plugin processes indexer dataapiPlugin
: Boolean flag indicating if the plugin adds API routesactionHandlers
: Array of action handlersdeltaHandlers
: Array of delta handlersstreamHandlers
: Array of stream event handlersdynamicContracts
: Array of contract names to dynamically trackhasApiRoutes
: Boolean flag indicating if the plugin has API routesbaseConfig
: Configuration object passed to the pluginchainName
: Name of the blockchain
constructor(config?: any)
: Initialize the plugin with optional configurationabstract addRoutes(server: FastifyInstance): void
: Add API routes to the Fastify serverinitOnce()
: Called once during plugin initializationinitHandlerMap()
: Initialize and return a handler map
HyperionActionHandler
: Interface for handling blockchain actionsHyperionDeltaHandler
: Interface for handling table deltasHyperionStreamHandler
: Interface for handling stream eventsHyperionAction
: Interface representing a blockchain actionHyperionDelta
: Interface representing a table delta
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
To publish a new version of the package to npm:
- Update the version in
package.json
- Update the
CHANGELOG.md
with the changes - Run the publish script:
npm run publish
This will automatically build the package and publish it to npm with public access.
Developed and maintained by EOS Rio.