Skip to content

Commit

Permalink
fix: warp plugin return type
Browse files Browse the repository at this point in the history
  • Loading branch information
asiaziola committed Dec 30, 2022
1 parent 67a9a18 commit fc1246e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/core/Warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ import { HandlerApi } from './modules/impl/HandlerExecutorFactory';
import { InteractionsLoader } from './modules/InteractionsLoader';
import { EvalStateResult, StateEvaluator } from './modules/StateEvaluator';
import { WarpBuilder } from './WarpBuilder';
import { WarpPluginType, WarpPlugin, knownWarpPlugins, knownWarpPluginsPartial } from './WarpPlugin';
import {
WarpPluginType,
WarpPlugin,
knownWarpPlugins,
knownWarpPluginsPartial,
WarpKnownPluginType
} from './WarpPlugin';
import { SortKeyCache } from '../cache/SortKeyCache';
import { ContractDefinition, SrcCache } from './ContractDefinition';
import { SignatureType } from '../contract/Signature';
Expand Down Expand Up @@ -159,6 +165,8 @@ export class Warp {
}

private isPluginType(value: string): value is WarpPluginType {
return knownWarpPlugins.includes(value as WarpPluginType) || knownWarpPluginsPartial.some((p) => value.match(p));
return (
knownWarpPlugins.includes(value as WarpKnownPluginType) || knownWarpPluginsPartial.some((p) => value.match(p))
);
}
}
7 changes: 4 additions & 3 deletions src/core/WarpPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ export const knownWarpPlugins = [
'subscription',
'ivm-handler-api',
'evaluation-progress',
'fetch-options',
...knownWarpPluginsPartial
'fetch-options'
] as const;
export type WarpPluginType = typeof knownWarpPlugins[number];
type WarpPluginPartialType = `smartweave-extension-${string}`;
export type WarpKnownPluginType = typeof knownWarpPlugins[number];
export type WarpPluginType = WarpKnownPluginType | WarpPluginPartialType;

export interface WarpPlugin<T, R> {
type(): WarpPluginType;
Expand Down

0 comments on commit fc1246e

Please sign in to comment.