/// import mvc = require('mvc-lib'); import ECIES = require('mvc-lib/ecies'); export { mvc }; export { ECIES }; import { Bytes, Sig, Ripemd160, SigHashPreimage, ScryptType, ValueType, Struct, SupportedParamType, VariableType, TypeResolver, StructEntity, CompileResult, AliasEntity, AbstractContract, AsmVarValues, TxContext, DebugLaunch, FileUri, Arguments, Argument, Script, ParamEntity } from './internal'; import { StaticEntity } from './compilerWrapper'; import { HashedMap, HashedSet, Library, ScryptTypeResolver } from './scryptTypes'; import { VerifyError } from './contract'; import { ABIEntity, LibraryEntity } from '.'; export declare const DEFAULT_FLAGS: number; export declare const DEFAULT_SIGHASH_TYPE: number; export declare function bool2Asm(str: string): string; /** * decimal or hex int to little-endian signed magnitude */ export declare function int2Asm(str: string): string; /** * convert asm string to number or bigint */ export declare function asm2int(str: string): number | bigint | string; /** * decimal int or hex str to number or bigint */ export declare function int2Value(str: string): number | bigint | string; export declare function intValue2hex(val: number | bigint): string; export declare function parseLiteral(l: string): [string, ValueType, VariableType]; export declare function isStringLiteral(l: string): boolean; /** * convert literals to Scrypt Type */ export declare function literal2ScryptType(l: string): ScryptType; export declare function asm2ScryptType(type: string, asm: string): ScryptType; export declare function bytes2Literal(bytearray: number[], type: string): string; export declare function bytesToHexString(bytearray: number[]): string; export declare function hexStringToBytes(hex: string): number[]; export declare function getValidatedHexString(hex: string, allowEmpty?: boolean): string; export declare function signTx(tx: mvc.Transaction, privateKey: mvc.PrivateKey, lockingScript: Script, inputAmount: number, inputIndex?: number, sighashType?: number, flags?: number): Sig; export declare function toHex(x: { toString(format: 'hex'): string; }): string; export declare function getPreimage(tx: mvc.Transaction, lockingScript: Script, inputAmount: number, inputIndex?: number, sighashType?: number, flags?: number): SigHashPreimage; export declare function getLowSPreimage(tx: mvc.Transaction, lockingScript: Script, inputAmount: number, inputIndex?: number, sighashType?: number, flags?: number): SigHashPreimage; export declare function num2bin(n: number | bigint | mvc.crypto.BN, dataLen: number): string; export declare function bin2num(s: string | Buffer): number | string; export declare function isNode(): boolean; export declare function path2uri(path: string): string; export declare function uri2path(uri: string): string; /** * @deprecated * convert literals to script ASM format */ export declare function literal2Asm(l: string): [string, string]; export declare function findStructByName(name: string, s: StructEntity[]): StructEntity; export declare function findLibraryByGeneric(type: string): string; export declare function isStructOrLibraryType(type: string): boolean; export declare function isStructType(type: string): boolean; export declare function isLibraryType(type: string): boolean; export declare function isArrayType(type: string): boolean; export declare function isStructArrayType(type: string): boolean; export declare function isLibraryArrayType(type: string): boolean; export declare function isGenericArrayType(type: string): boolean; export declare function getNameByType(type: string): string; export declare function getLibraryNameByType(type: string): string; export declare function findStructByType(type: string, s: StructEntity[]): StructEntity | undefined; export declare function checkStructField(s: StructEntity, param: ParamEntity, arg: SupportedParamType, typeResolver: TypeResolver): void; export declare function checkStruct(s: StructEntity, arg: Struct, typeResolver: TypeResolver): void; export declare function checkSupportedParamType(arg: SupportedParamType, param: ParamEntity, resolver: TypeResolver): Error | undefined; /** * return eg. int[N][N][4] => ['int', ["N","N","4"]] * @param arrayTypeName */ export declare function arrayTypeAndSizeStr(arrayTypeName: string): [string, Array]; /** * return eg. int[2][3][4] => ['int', [2,3,4]] * @param arrayTypeName eg. int[2][3][4] */ export declare function arrayTypeAndSize(arrayTypeName: string): [string, Array]; export declare function toLiteralArrayType(elemTypeName: string, sizes: Array): string; export declare function toGenericType(library: string, genericTypes: Array): string; /** * return eg. int[2][3][4] => int[3][4] * @param arrayTypeName eg. int[2][3][4] */ export declare function subArrayType(arrayTypeName: string): string; export declare function subscript(index: number, arraySizes: Array): string; export declare function flatternArray(arg: SupportedParamType[], name: string, finalType: string): Arguments; export declare function flatternStruct(arg: SupportedParamType, name: string): Arguments; export declare function flatternLibrary(arg: SupportedParamType, name: string): Arguments; export declare function flatternLibraryState(arg: SupportedParamType, name: string): Arguments; export declare function flatternCtorArgs(args: Arguments, finalTypeResolver: TypeResolver): Arguments; export declare function flatternStateArgs(args: Arguments, finalTypeResolver: TypeResolver): Arguments; export declare function flatternParams(params: Array, resolver: ScryptTypeResolver): Arguments; export declare function typeOfArg(arg: SupportedParamType): string; export declare function shortType(finalType: string): string; export declare function typeNameOfArg(arg: SupportedParamType): string; export declare function readFileByLine(path: string, index: number): string; export declare function isEmpty(obj: unknown): boolean; export declare function compileContract(file: string, options?: { out?: string; sourceMap?: boolean; }): CompileResult; export declare function newCall(Cls: typeof AbstractContract, args: Array): AbstractContract; export declare function genLaunchConfigFile(constructorArgs: SupportedParamType[], pubFuncArgs: SupportedParamType[], pubFunc: string, name: string, program: string, txContext: TxContext, asmArgs: AsmVarValues): FileUri; export declare function resolveConstValue(node: any): string | undefined; export declare function resolveType(type: string, originTypes: Record, contract: string, statics: StaticEntity[], alias: AliasEntity[], librarys: LibraryEntity[]): string; export declare function resolveArrayType(contract: string, type: string, statics: StaticEntity[]): string; /*** * resolve type */ export declare function resolveAliasType(alias: AliasEntity[], type: string): string; export declare function ansiRegex({ onlyFirst }?: { onlyFirst?: boolean; }): RegExp; export declare function stripAnsi(string: string): string; export declare function createStruct(resolver: ScryptTypeResolver, param: ParamEntity, opcodesMap: Map): Struct; export declare function createLibrary(resolver: ScryptTypeResolver, param: ParamEntity, opcodesMap: Map): Library; export declare function createLibraryProperties(resolver: ScryptTypeResolver, param: ParamEntity, opcodesMap: Map): Record; export declare function createDefaultLibrary(resolver: ScryptTypeResolver, param: ParamEntity): Library; export declare function createArray(resolver: ScryptTypeResolver, type: string, name: string, opcodesMap: Map): SupportedParamType; export declare function toLiteral(value: SupportedParamType): string; export declare function isInteger(x: unknown): boolean; export declare function findConstStatic(statics: StaticEntity[], name: string): StaticEntity; export declare function findStatic(statics: StaticEntity[], name: string): StaticEntity; export declare function buildContractCodeASM(asmTemplateArgs: Map, asmTemplate: string): string; /** * only used for state contract * @param args * @param firstCall * @param finalTypeResolver * @returns */ export declare function buildContractState(args: Arguments, firstCall: boolean, finalTypeResolver: TypeResolver): string; export declare function buildDefaultStateProps(contract: AbstractContract): Arguments; export declare function readBytes(br: mvc.encoding.BufferReader): { data: string; opcodenum: number; }; export declare function deserializeArgfromASM(resolver: ScryptTypeResolver, arg: Argument, opcodesMap: Map): Argument; export declare function deserializeArgfromState(resolver: ScryptTypeResolver, arg: Argument, opcodesMap: Map): Argument; export declare function flattenSha256(data: SupportedParamType): string; export declare function sortmap(map: Map): Map; export declare function sortset(set: Set): Set; export declare function findKeyIndex(collection: Map | Set, key: SupportedParamType): number; export declare function toData(collection: Map | Set): Bytes; export declare function toHashedMap(collection: Map): HashedMap; export declare function toHashedSet(collection: Map): HashedSet; /** * check if a type is generic type * @param type * @returns */ export declare function isGenericType(type: string): boolean; /** * * @param type eg. HashedMap * @param eg. ["HashedMap", ["int", "int"]}] An array generic types returned by @getGenericDeclaration * @returns {"K": "int", "V": "int"} */ export declare function parseGenericType(type: string): [string, Array]; export declare function hash160(hexstr: string): string; export declare function sha256(hexstr: string): string; export declare function hash256(hexstr: string): string; export declare function readLaunchJson(error: VerifyError): DebugLaunch | undefined; export declare function len(hexstr: string): number; export declare function toLEUnsigned(n: number, l: number): string; export declare function writeVarint(b: string): string; export declare function buildOpreturnScript(data: string): Script; export declare function buildPublicKeyHashScript(pubKeyHash: Ripemd160): Script; /** * Parse out which public function is called through unlocking script * @param contract * @param hex hex of unlocking script * @returns return ABIEntity of the public function which is call by the unlocking script */ export declare function parseAbiFromUnlockingScript(contract: AbstractContract, hex: string): ABIEntity; export declare function toScryptType(a: SupportedParamType): ScryptType; export declare function arrayToScryptType(a: SupportedParamType[]): ScryptType[]; export declare function cloneArray(a: SupportedParamType[]): ScryptType[]; export declare function inferrType(a: SupportedParamType): string; export declare function resolveGenericType(genericTypeMap: Record, type: string): string; export declare function librarySign(genericEntity: LibraryEntity): string; export declare function structSign(structEntity: StructEntity): string; export declare function arrayToLiteral(a: SupportedParamType[]): string; export declare function canAssignProperty(libraryAst: LibraryEntity): boolean;