import * as ethers from "ethers"; import * as solana from "@solana/web3.js"; import * as sui from "@mysten/sui.js"; import { CosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { ChainId, EVMChainId, ParsedVaa, SignedVaa } from "@certusone/wormhole-sdk"; import * as winston from "winston"; export interface CommonPluginEnv { supportedChains: ChainConfigInfo[]; wormholeRpc: string; } export interface ChainConfigInfo { chainId: ChainId; chainName: string; nodeUrl: string; } export interface Workflow { id: WorkflowId; pluginName: string; scheduledAt?: Date; scheduledBy?: string; retryCount: number; maxRetries?: number; data: D; failedAt?: Date; errorMessage?: string; errorStacktrace?: string; completedAt?: Date; startedProcessingAt?: Date; processingBy?: string; emitterChain?: number; emitterAddress?: string; sequence?: string; } export interface ActionExecutor { (action: Action): Promise; onSolana(f: ActionFunc): Promise; onEVM(action: Action): Promise; onSui(action: Action): Promise; } export type ActionFunc = (walletToolBox: WalletToolBox, chaindId: ChainId) => Promise; export interface Action { chainId: ChainId; f: ActionFunc; } export type WorkflowId = string; export type UntypedProvider = { rpcUrl: string; }; export type EVMWallet = ethers.Wallet; export type UntypedWallet = UntypedProvider & { privateKey: string; }; export type SolanaWallet = { conn: solana.Connection; payer: solana.Keypair; }; export type Wallet = EVMWallet | SolanaWallet | UntypedWallet; export interface WalletToolBox extends Providers { wallet: T; } export interface Providers { untyped: Partial>; evm: Partial>; solana: solana.Connection; sui: sui.JsonRpcProvider; sei: CosmWasmClient; } export interface ParsedVaaWithBytes extends ParsedVaa { bytes: SignedVaa; } export type EngineInitFn = (engineConfig: CommonPluginEnv, logger: winston.Logger) => PluginType; export interface WorkflowOptions { maxRetries?: number; } export interface Plugin { pluginName: string; pluginConfig: any; shouldSpy: boolean; shouldRest: boolean; maxRetries?: number; afterSetup?(providers: Providers, listenerResources?: { eventSource: EventSource; db: StagingAreaKeyLock; }): Promise; getFilters(): ContractFilter[]; consumeEvent(// Function to be defined in plug-in that takes as input a VAA outputs a list of actions vaa: ParsedVaaWithBytes, stagingArea: StagingAreaKeyLock, providers: Providers, extraData?: any[]): Promise<{ workflowData: WorkflowData; workflowOptions?: WorkflowOptions; } | undefined>; handleWorkflow(workflow: Workflow, providers: Providers, execute: ActionExecutor): Promise; } export type EventSource = (event: SignedVaa, extraData?: any[]) => Promise; export type ContractFilter = { emitterAddress: string; chainId: ChainId; doNotTransform?: boolean; }; export interface StagingAreaKeyLock { withKey>(keys: string[], f: (kvs: KV, ctx: OpaqueTx) => Promise<{ newKV: KV; val: T; }>, tx?: OpaqueTx): Promise; getKeys>(keys: string[]): Promise; } export type OpaqueTx = never;