/// import type { Account as AccountSDK } from "algosdk"; import * as algosdk from "algosdk"; import { DeepReadonly, StrictOmit } from "ts-essentials"; import * as z from 'zod'; import * as types from "./internal/core/params/argument-types"; import { ASADefSchema, ASADefsSchema } from "./types-input"; export interface Account extends AccountSDK { name: string; } export interface HDAccount { mnemonic: string; initialIndex?: number; count?: number; path: string; } export interface MnemonicAccount { name: string; addr: string; mnemonic: string; } export declare type AccountDef = MnemonicAccount | HDAccount | Account; interface CommonNetworkConfig { accounts: Account[]; chainName?: string; } export interface AlgobChainCfg extends CommonNetworkConfig { throwOnTransactionFailures?: boolean; throwOnCallFailures?: boolean; loggingEnabled?: boolean; initialDate?: string; } export interface HttpNetworkConfig extends CommonNetworkConfig { host: string; port: number; token: string; httpHeaders?: { [name: string]: string; }; } export declare type NetworkConfig = AlgobChainCfg | HttpNetworkConfig; export interface Networks { [networkName: string]: NetworkConfig; } /** * The project paths: * * root: the project's root. * * configFile: the algob's config filepath. * * cache: project's cache directory. * * artifacts: artifact's directory. * * sources: project's sources directory. * * tests: project's tests directory. */ export interface ProjectPaths { root: string; configFile: string; cache: string; artifacts: string; sources: string; tests: string; } export declare type UserPaths = StrictOmit, "configFile">; export interface AlgobConfig { networks?: Networks; paths?: UserPaths; mocha?: Mocha.MochaOptions; } export interface ResolvedAlgobConfig extends AlgobConfig { paths?: ProjectPaths; networks: Networks; } /** * A function that receives a AlgobRuntimeEnv and * modify its properties or add new ones. */ export declare type EnvironmentExtender = (env: AlgobRuntimeEnv) => void; export declare type ConfigExtender = (config: ResolvedAlgobConfig, userConfig: DeepReadonly) => void; export interface TasksMap { [name: string]: TaskDefinition; } export interface ConfigurableTaskDefinition { setDescription: (description: string) => this; setAction: (action: ActionType) => this; addParam: (name: string, description?: string, defaultValue?: T, type?: types.ArgumentType, isOptional?: boolean) => this; addOptionalParam: (name: string, description?: string, defaultValue?: T, type?: types.ArgumentType) => this; addPositionalParam: (name: string, description?: string, defaultValue?: T, type?: types.ArgumentType, isOptional?: boolean) => this; addOptionalPositionalParam: (name: string, description?: string, defaultValue?: T, type?: types.ArgumentType) => this; addVariadicPositionalParam: (name: string, description?: string, defaultValue?: T[], type?: types.ArgumentType, isOptional?: boolean) => this; addOptionalVariadicPositionalParam: (name: string, description?: string, defaultValue?: T[], type?: types.ArgumentType) => this; addFlag: (name: string, description?: string) => this; } export interface ParamDefinition { name: string; shortName?: string; defaultValue?: T; type: types.ArgumentType; description?: string; isOptional: boolean; isFlag: boolean; isVariadic: boolean; } export declare type ParamDefinitionAny = ParamDefinition; export interface OptionalParamDefinition extends ParamDefinition { defaultValue: T; isOptional: true; } export interface ParamDefinitionsMap { [paramName: string]: ParamDefinitionAny; } /** * Algob arguments: * * network: the network to be used (default="default"). * * showStackTraces: flag to show stack traces. * * version: flag to show algob's version. * * help: flag to show algob's help message. * * config: used to specify algob's config file. */ export interface RuntimeArgs { network: string; showStackTraces: boolean; version: boolean; help: boolean; config?: string; verbose: boolean; } export declare type AlgobParamDefinitions = { [param in keyof Required]: OptionalParamDefinition; }; export interface AlgobShortParamSubstitutions { [name: string]: string; } export interface TaskDefinition extends ConfigurableTaskDefinition { readonly name: string; readonly description?: string; readonly action: ActionType; readonly isInternal: boolean; readonly paramDefinitions: ParamDefinitionsMap; readonly positionalParamDefinitions: ParamDefinitionAny[]; } /** * @type TaskArguments {object-like} - the input arguments for a task. * * TaskArguments type is set to 'any' because it's interface is dynamic. * It's impossible in TypeScript to statically specify a variadic * number of fields and at the same time define specific types for\ * the argument values. * * For example, we could define: * type TaskArguments = Record; * * ...but then, we couldn't narrow the actual argument value's type in compile time, * thus we have no other option than forcing it to be just 'any'. */ export declare type TaskArguments = any; export declare type RunTaskFunction = (name: string, taskArguments?: TaskArguments) => PromiseAny; export interface RunSuperFunction { (taskArguments?: ArgT): PromiseAny; isDefined: boolean; } export declare type ActionType = (taskArgs: ArgsT, env: AlgobRuntimeEnv, runSuper: RunSuperFunction) => PromiseAny; export interface Network { name: string; config: NetworkConfig; } export interface AlgobRuntimeEnv { readonly config: ResolvedAlgobConfig; readonly runtimeArgs: RuntimeArgs; readonly tasks: TasksMap; readonly run: RunTaskFunction; readonly network: Network; } export interface Artifact { contractName: string; abi: any; bytecode: string; deployedBytecode: string; linkReferences: LinkReferences; deployedLinkReferences: LinkReferences; } export interface LinkReferences { [libraryFileName: string]: { [libraryName: string]: Array<{ length: number; start: number; }>; }; } declare type AccountAddress = string; export interface DeployedAssetInfo { creator: AccountAddress; txId: string; confirmedRound: number; } export interface ASAInfo extends DeployedAssetInfo { assetIndex: number; } export interface ASCInfo extends DeployedAssetInfo { contractAddress: string; logicSignature: string; } export interface CheckpointRepo { precedingCP: Checkpoints; strippedCP: Checkpoints; allCPs: Checkpoints; merge: (curr: Checkpoints, scriptName: string) => CheckpointRepo; mergeToGlobal: (curr: Checkpoints, scriptName: string) => CheckpointRepo; putMetadata: (networkName: string, key: string, value: string) => CheckpointRepo; getMetadata: (networkName: string, key: string) => string | undefined; registerASA: (networkName: string, name: string, info: ASAInfo) => CheckpointRepo; registerASC: (networkName: string, name: string, info: ASCInfo) => CheckpointRepo; isDefined: (networkName: string, name: string) => boolean; networkExistsInCurrentCP: (networkName: string) => boolean; } export interface Checkpoints { [network: string]: Checkpoint; } export interface Checkpoint { timestamp: number; metadata: Map; asa: Map; asc: Map; } export declare type ASADef = z.infer; export declare type ASADefs = z.infer; export interface TxParams { feePerByte?: number; totalFee?: number; firstValid?: number; validRounds?: number; lease?: string; note?: string; noteb64?: string; } export interface ASADeploymentFlags extends TxParams { creator: Account; } export interface ASCDeploymentFlags { funder: Account; fundingMicroAlgo: number; } export interface AssetScriptMap { [assetName: string]: string; } export declare type Accounts = Map; export interface AlgobDeployer { isDeployMode: boolean; accounts: Account[]; accountsByName: Accounts; putMetadata: (key: string, value: string) => void; getMetadata: (key: string) => string | undefined; deployASA: (name: string, flags: ASADeploymentFlags) => Promise; deployASC: (name: string, scParams: Object, flags: ASCDeploymentFlags, payFlags: TxParams) => Promise; /** Returns true if ASA or ACS were deployed in any script. Checks even for checkpoints out of from the execution session which are not obtainable using get methods. */ isDefined: (name: string) => boolean; asa: Map; asc: Map; algodClient: algosdk.Algodv2; waitForConfirmation: (txId: string) => Promise; optInToASA: (name: string, accountName: string, flags: ASADeploymentFlags) => Promise; log: (msg: string, obj: any) => void; } export interface ASCCache { filename: string; timestamp: number; compiled: string; compiledHash: string; srcHash: number; } export interface StrMap { [key: string]: string; } export interface AnyMap { [key: string]: any; } export declare type PromiseAny = Promise; export {};