Files
Igor Lins e Silva 279f5d9474 merge 3.3.5 to master
2022-09-11 03:42:18 -03:00

62 lines
1.4 KiB
TypeScript

import {FastifyInstance} from "fastify";
import {HyperionAction} from "../interfaces/hyperion-action";
import {HyperionDelta} from "../interfaces/hyperion-delta";
interface HyperionActionHandler {
action: string;
contract: string;
mappings?: any;
handler: (action: HyperionAction) => Promise<void>;
}
interface HyperionDeltaHandler {
table: string;
contract: string;
mappings?: any;
handler: (delta: HyperionDelta) => Promise<void>;
}
interface HyperionStreamEvent {
}
export interface HyperionStreamHandler {
event: string;
code?: string;
account?: string;
name?: string;
table?: string;
handler: (streamEvent: any) => Promise<void>;
}
export abstract class HyperionPlugin {
internalPluginName: string = '';
indexerPlugin: boolean;
apiPlugin: boolean;
actionHandlers: HyperionActionHandler[] = [];
deltaHandlers: HyperionDeltaHandler[] = [];
streamHandlers: HyperionStreamHandler[] = [];
dynamicContracts: string[] = [];
hasApiRoutes: boolean = false;
baseConfig: any;
chainName: string = '';
protected constructor(config?: any) {
if (config) {
this.baseConfig = config;
}
}
abstract addRoutes(server: FastifyInstance): void;
// abstract processActionData(input: any): Promise<any>;
initOnce() {
// called only once
}
initHandlerMap(): any {
return {};
}
}