Rc/evm signature (#249)

* feat: allow signing function only for bundled txs

* fix: after ppe review

* feat: add transaction verification

* feat: warp plugins system

* chore: removing lodash dep

* feat: isEvmSigned verification

* chore: useFastCopy fix in tests

* feat: evm signature - minor fixes

* fix: try-catch for evm sig verification

* v1.2.14-beta.5

* fix: await for sig verification

* v1.2.14-beta.6

* chore: restore original package version

Co-authored-by: asiaziola <ziola.jm@gmail.com>
This commit is contained in:
just_ppe
2022-11-07 15:16:33 +01:00
committed by GitHub
parent 9335023824
commit ef6a445a2e
20 changed files with 3194 additions and 169 deletions

View File

@@ -15,6 +15,7 @@ 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 } from './WarpPlugin';
export type WarpEnvironment = 'local' | 'testnet' | 'mainnet' | 'custom';
@@ -31,6 +32,8 @@ export class Warp {
readonly migrationTool: MigrationTool;
readonly testing: Testing;
private readonly plugins: Map<WarpPluginType, WarpPlugin<unknown, unknown>> = new Map();
constructor(
readonly arweave: Arweave,
readonly levelDb: LevelDbCache<EvalStateResult<unknown>>,
@@ -69,4 +72,26 @@ export class Warp {
pst(contractTxId: string): PstContract {
return new PstContractImpl(contractTxId, this);
}
use(plugin: WarpPlugin<unknown, unknown>): Warp {
const pluginType = plugin.type();
if (!knownWarpPlugins.some((p) => p == pluginType)) {
throw new Error(`Unknown plugin type ${pluginType}.`);
}
this.plugins.set(pluginType, plugin);
return this;
}
hasPlugin(type: WarpPluginType): boolean {
return this.plugins.has(type);
}
loadPlugin<P, Q>(type: WarpPluginType): WarpPlugin<P, Q> {
if (!this.hasPlugin(type)) {
throw new Error(`Plugin ${type} not registered.`);
}
return this.plugins.get(type) as WarpPlugin<P, Q>;
}
}