scryptlib
Version:
Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.
79 lines (78 loc) • 4.37 kB
TypeScript
/// <reference types="node" />
import * as bsv from '@scrypt-inc/bsv';
export { bsv };
import { ABIEntity, LibraryEntity } from '.';
import { OpCode } from './compilerWrapper';
import { AbstractContract, CompileResult, Script, StructEntity, SupportedParamType } from './internal';
export declare const DEFAULT_FLAGS: number;
export declare const DEFAULT_SIGHASH_TYPE: number;
/**
* 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 | string;
export declare function uint82hex(val: number): string;
export declare function toHex(x: {
toString(format: 'hex'): string;
}): string;
export declare function utf82Hex(val: string): string;
export declare function bytes2Literal(bytearray: Buffer, type: string): string;
export declare function bytesToHexString(bytearray: Buffer): string;
export declare function hexStringToBytes(hex: string): number[];
export declare function signTx(tx: bsv.Transaction, privateKey: bsv.PrivateKey, lockingScript: Script, inputAmount: number, inputIndex?: number, sighashType?: number, flags?: number, hashCache?: bsv.HashCache): string;
export declare function getPreimage(tx: bsv.Transaction, lockingScript: Script, inputAmount: number, inputIndex?: number, sighashType?: number, flags?: number): string;
export declare function hashIsPositiveNumber(sighash: Buffer): boolean;
export declare function getLowSPreimage(tx: bsv.Transaction, lockingScript: Script, inputAmount: number, inputIndex?: number, sighashType?: number, flags?: number): string;
export declare function isNode(): boolean;
export declare function path2uri(path: string): string;
export declare function uri2path(uri: string): string;
export declare function findStructByName(name: string, s: StructEntity[]): StructEntity | undefined;
export declare function isArrayType(type: string): boolean;
export declare function getNameByType(type: string): string;
export declare function findStructByType(type: string, s: StructEntity[]): StructEntity | undefined;
export declare function toGenericType(name: string, genericTypes: Array<string>): string;
export declare function subscript(index: number, arraySizes: Array<number>): string;
export declare function readFileByLine(path: string, index: number): string;
export declare function isEmpty(obj: any): boolean;
export declare function compileContract(file: string, options?: {
out?: string;
sourceMap?: boolean;
artifact?: boolean;
optimize?: boolean;
}): CompileResult;
export declare function compileContractAsync(file: string, options?: {
out?: string;
artifact?: boolean;
sourceMap?: boolean;
optimize?: boolean;
}): Promise<CompileResult>;
export declare function newCall(Cls: typeof AbstractContract, args: Array<SupportedParamType>): AbstractContract;
export declare function resolveConstValue(node: any): string | undefined;
export declare function ansiRegex({ onlyFirst }?: {
onlyFirst?: boolean;
}): RegExp;
export declare function stripAnsi(string: string): string;
export declare function buildContractCode(hexTemplateArgs: Map<string, string>, hexTemplateInlineASM: Map<string, string>, hexTemplate: string): bsv.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 librarySign(genericEntity: LibraryEntity): string;
export declare function structSign(structEntity: StructEntity): string;
export declare function JSONParser(file: string): Promise<boolean>;
export declare function JSONParserSync(file: string): any;
export declare function JSONStringify(file: string, data: unknown): Promise<boolean>;
export declare function findSrcInfoV2(pc: number, sourceMap: unknown): number[] | undefined;
/**
* @deprecated use findSrcInfoV2
* @param opcodes OpCode[] from sourceMap
*/
export declare function findSrcInfoV1(opcodes: OpCode[], opcodesIndex: number): OpCode | undefined;
export declare function md5(s: string): string;
export declare function checkNOPScript(nopScript: bsv.Script): void;