import BN from 'bn.js' ; import { Artifacts } from './artifacts' ; import { NetworkConfig , RedspotConfig } from './config' ; import { AccountSigner , ApiPromise , Keyring , LocalKeyringPair , Registry , Signer , WsProvider } from './provider' ; /**
 * This class is used to dynamically validate task's argument types.
 */ export interface ArgumentType < T > { /**
     * The type's name.
     */ name : string ; param argName { string } param argumentValue throws validate ( argName , argumentValue ) : void ; } /**
 * This is a special case of ArgumentType.
 *
 * These types must have a human-friendly string representation, so that they
 * can be used as command line arguments.
 */ export interface CLIArgumentType < T > extends ArgumentType < T > { param argName param strValue parse ( argName , strValue ) : T ; } export interface ConfigurableTaskDefinition { setDescription ( description ) : this ; setAction ( action ) : this ; addParam < T > ( name , description ? , defaultValue ? , type ? , isOptional ? ) : this ; addOptionalParam < T > ( name , description ? , defaultValue ? , type ? ) : this ; addPositionalParam < T > ( name , description ? , defaultValue ? , type ? , isOptional ? ) : this ; addOptionalPositionalParam < T > ( name , description ? , defaultValue ? , type ? ) : this ; addVariadicPositionalParam < T > ( name , description ? , defaultValue ? , type ? , isOptional ? ) : this ; addOptionalVariadicPositionalParam < T > ( name , description ? , defaultValue ? , type ? ) : this ; addFlag ( name , description ? ) : this ; } export interface ParamDefinition < T > { name : string ; defaultValue ? : T ; type : ArgumentType < T > ; description ? : string ; isOptional : boolean ; isFlag : boolean ; isVariadic : boolean ; } export interface OptionalParamDefinition < T > extends ParamDefinition < T > { defaultValue : T ; isOptional : true ; } export interface CLIOptionalParamDefinition < T > extends OptionalParamDefinition < T > { type : CLIArgumentType < T > ; } export interface ParamDefinitionsMap { [ paramName ] : ParamDefinition < any > ; } export interface TaskDefinition extends ConfigurableTaskDefinition { readonly name : string ; readonly description ? : string ; readonly action : ActionType < TaskArguments > ; readonly isSubtask : boolean ; readonly paramDefinitions : ParamDefinitionsMap ; readonly positionalParamDefinitions : Array < ParamDefinition < any > > ; } type TaskArguments export type TaskArguments = any ; export interface RunSuperFunction < ArgT extends TaskArguments > { ( taskArguments ? ) : Promise < any > ; isDefined : boolean ; } export type ActionType < ArgsT extends TaskArguments > = ( taskArgs : ArgsT , env : RedspotRuntimeEnvironment , runSuper : RunSuperFunction < ArgsT > ) => Promise < any > ; export interface RedspotArguments { network ? : string ; showStackTraces : boolean ; version : boolean ; help : boolean ; config ? : string ; verbose : boolean ; logLevel : string ; maxMemory ? : number ; tsconfig ? : string ; release : boolean ; } export type RedspotParamDefinitions = { [ param in keyof Required < RedspotArguments > ] : CLIOptionalParamDefinition < RedspotArguments [ param ] > ; } ; export interface TasksMap { [ name ] : TaskDefinition ; } export type RunTaskFunction = ( name : string , taskArguments ? : TaskArguments ) => Promise < any > ; export interface RuntimeEnvironment { readonly config : RedspotConfig ; readonly redspotArguments : RedspotArguments ; readonly tasks : TasksMap ; readonly run : RunTaskFunction ; readonly network : Network ; readonly artifacts : Artifacts ; } export interface RedspotRuntimeEnvironment { readonly config : RedspotConfig ; readonly redspotArguments : RedspotArguments ; readonly tasks : TasksMap ; readonly run : RunTaskFunction ; readonly network : Network ; readonly artifacts : Artifacts ; } export interface Network { name : string ; config : NetworkConfig ; provider : WsProvider ; api : ApiPromise ; registry : Registry ; keyring : Keyring ; getSigners ( ) : Promise < Signer [ ] > ; getAddresses ( ) : Promise < string [ ] > ; signer : AccountSigner ; createSigner ( pair ) : Signer ; addPair ( pair ) : LocalKeyringPair ; gasLimit ? : BN ; utils : { encodeSalt ( salt ? , signerAddress ? ) : Promise < Uint8Array > ; } ; } /**
 * A function that receives a RedspotRuntimeEnvironment and
 * modify its properties or add new ones.
 */ export type EnvironmentExtender = ( env : RuntimeEnvironment ) => void ;