UNPKG

@kubiklabs/wasmkit

Version:

Wasmkit is a development environment to compile, deploy, test, run cosmwasm contracts on different networks.

74 lines (73 loc) 2.9 kB
import type { EnvironmentExtender, Network, ResolvedConfig, RunTaskFunction, RuntimeArgs, TasksMap, WasmkitRuntimeEnvironment } from "../../types"; export declare class Environment implements WasmkitRuntimeEnvironment { readonly config: ResolvedConfig; readonly runtimeArgs: RuntimeArgs; readonly tasks: TasksMap; private static readonly _BLACKLISTED_PROPERTIES; network: Network; private readonly _extenders; /** * Initializes the WasmKit Runtime Environment and the given * extender functions. * * @remarks The extenders' execution order is given by the order * of the requires in the WasmKit's config file and its plugins. * * @param config The WasmKit's config object. * @param runtimeArgs The parsed WasmKit's arguments. * @param tasks A map of tasks. * @param extenders A list of extenders. * @param networkRequired if true it will assert that a requested network is defined. */ constructor(config: ResolvedConfig, runtimeArgs: RuntimeArgs, tasks: TasksMap, extenders?: EnvironmentExtender[], networkRequired?: boolean); /** * Executes the task with the given name. * * @param name The task's name. * @param taskArguments A map of task's arguments. * * @throws a WASMKIT303 if there aren't any defined tasks with the given name. * @returns a promise with the task's execution result. */ readonly run: RunTaskFunction; /** * Injects the properties of `this` (the WasmKit Runtime Environment) into the global scope. * * @param blacklist a list of property names that won't be injected. * * @returns a function that restores the previous environment. */ injectToGlobal(blacklist?: string[]): () => void; private _runTaskDefinition; /** * Check that task arguments are within TaskDefinition defined params constraints. * Also, populate missing, non-mandatory arguments with default param values (if any). * * @private * @throws WasmkitError if any of the following are true: * > a required argument is missing * > an argument's value's type doesn't match the defined param type * * @param taskDefinition * @param taskArguments * @returns resolvedTaskArguments */ private _resolveValidTaskArguments; /** * Resolves an argument according to a ParamDefinition rules. * * @param paramDefinition * @param argumentValue * @private */ private _resolveArgument; /** * Checks if value is valid for the specified param definition. * * @param paramDefinition {ParamDefinition} - the param definition for validation * @param argumentValue - the value to be validated * @private * @throws WASMKIT301 if value is not valid for the param type */ private _checkTypeValidation; }