UNPKG

scryptlib

Version:

Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.

104 lines (103 loc) 3.55 kB
export declare enum SymbolType { ScryptType = "ScryptType", Contract = "Contract", Library = "Library", Struct = "Struct", Unknown = "Unknown" } export type TypeInfo = { info?: unknown; generic: boolean; finalType: string; symbolType: SymbolType; }; export type TypeResolver = (type: string) => TypeInfo; export declare enum ScryptType { BOOL = "bool", INT = "int", BYTES = "bytes", PUBKEY = "PubKey", PRIVKEY = "PrivKey", SIG = "Sig", RIPEMD160 = "Ripemd160", SHA1 = "Sha1", SHA256 = "Sha256", SIGHASHTYPE = "SigHashType", SIGHASHPREIMAGE = "SigHashPreimage", OPCODETYPE = "OpCodeType" } export interface Flavoring<FlavorT> { _type?: FlavorT; } export type Flavor<T, FlavorT> = T & Flavoring<FlavorT>; export type Int = Flavor<bigint, 'int'>; export type Bool = Flavor<boolean, 'bool'>; export type Bytes = Flavor<string, 'bytes'>; export type PrivKey = Int & { __type: 'PrivKey'; }; export type PubKey = Bytes & { __type: 'PubKey'; }; export type Sig = Bytes & { __type: 'Sig'; }; export type Ripemd160 = Bytes & { __type: 'Ripemd160'; }; export type PubKeyHash = Ripemd160; export type Sha1 = Bytes & { __type: 'Sha1'; }; export type Sha256 = Bytes & { __type: 'Sha256'; }; export type SigHashType = Bytes & { __type: 'SigHashType'; }; export type SigHashPreimage = Bytes & { __type: 'SigHashPreimage'; }; export type OpCodeType = Bytes & { __type: 'OpCodeType'; }; export type HashedSet = Flavor<Set<SupportedParamType>, 'HashedSet'>; export type HashedMap = Flavor<Map<SupportedParamType, SupportedParamType>, 'HashedMap'>; export declare function Int(n: number | bigint | string): Int; export declare function Bool(b: boolean): Bool; export declare function Bytes(b: string): Bytes; export declare function PrivKey(n: Int): PrivKey; export declare function PubKey(b: Bytes): PubKey; export declare function Sig(b: Bytes): Sig; export declare function Ripemd160(b: Bytes): Ripemd160; export declare function PubKeyHash(b: Bytes): PubKeyHash; export declare function Sha1(b: Bytes): Sha1; export declare function Sha256(b: Bytes): Sha256; export declare function HashedSet(set: Set<SupportedParamType>): HashedSet; export declare function HashedMap(map: Map<SupportedParamType, SupportedParamType>): HashedMap; export declare enum SignatureHashType { ALL = 65, NONE = 66, SINGLE = 67, ANYONECANPAY_ALL = 193, ANYONECANPAY_NONE = 194, ANYONECANPAY_SINGLE = 195 } export declare function SigHashType(s: SignatureHashType | 0): SigHashType; export declare function SigHashPreimage(b: Bytes): SigHashPreimage; export declare function OpCodeType(b: Bytes): OpCodeType; export type SortedItem<T> = { idx: bigint; item: T; }; export declare function getSortedItem<K, V>(collection: Map<K, V> | Set<K>, k: K): SortedItem<K>; export type PrimitiveTypes = Int | Bool | Bytes | PrivKey | PubKey | Sig | Sha256 | Sha1 | SigHashType | Ripemd160 | OpCodeType | HashedMap | HashedSet; export type SubBytes = PubKey | Sig | Sha256 | Sha1 | SigHashType | Ripemd160 | OpCodeType; export interface StructObject { [key: string]: SupportedParamType; } export type SupportedParamType = PrimitiveTypes | StructObject | SupportedParamType[]; export declare function getValidatedHexString(hex: string, allowEmpty?: boolean): string; export declare function isScryptType(type: string): boolean; export declare function isSubBytes(type: string): boolean; export declare function isBytes(type: string): boolean;