UNPKG

scryptlib

Version:

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

88 lines (87 loc) 3.15 kB
import { ABIEntity } from './compilerWrapper'; import { AbstractContract, AsmVarValues, TxContext, VerifyResult } from './contract'; import { SupportedParamType, TypeResolver } from './scryptTypes'; import { bsv } from './utils'; export type Script = bsv.Script; export type FileUri = string; /** * Configuration for a debug session. */ export interface DebugConfiguration { type: 'scrypt'; request: 'launch'; internalConsoleOptions: 'openOnSessionStart'; name: string; program: string; constructorArgs: SupportedParamType[]; pubFunc: string; pubFuncArgs: SupportedParamType[]; asmArgs?: AsmVarValues; txContext?: TxContext; } export interface DebugLaunch { version: '0.2.0'; configurations: DebugConfiguration[]; } export interface Argument { name: string; type: string; value: SupportedParamType; } export type Arguments = Argument[]; export declare class FunctionCall { methodName: string; readonly contract: AbstractContract; readonly args: Arguments; private _unlockingScript?; private _lockingScript?; get unlockingScript(): Script | undefined; get lockingScript(): Script | undefined; set lockingScript(s: Script | undefined); constructor(methodName: string, binding: { contract: AbstractContract; unlockingScript?: Script; lockingScript?: Script; args: Arguments; }); toASM(): string; toString(): string; toScript(): Script; toHex(): string; genLaunchConfig(txContext?: TxContext): FileUri; verify(txContext?: TxContext): VerifyResult; } /** * Calldata is the relevant information when the contract is called, such as the public function name and function arguments when the call occurs. */ export interface CallData { /** name of public function */ methodName: string; /** unlocking Script */ unlockingScript: bsv.Script; /** function arguments */ args: Arguments; } export declare class ABICoder { abi: ABIEntity[]; resolver: TypeResolver; contractName: string; constructor(abi: ABIEntity[], resolver: TypeResolver, contractName: string); encodeConstructorCall(contract: AbstractContract, hexTemplate: string, ...args: SupportedParamType[]): FunctionCall; encodeConstructorCallFromRawHex(contract: AbstractContract, hexTemplate: string, raw: string): FunctionCall; encodePubFunctionCall(contract: AbstractContract, name: string, args: SupportedParamType[]): FunctionCall; /** * build a FunctionCall by function name and unlocking script in hex. * @param contract * @param name name of public function * @param hex hex of unlocking script * @returns a FunctionCall which contains the function parameters that have been deserialized */ encodePubFunctionCallFromHex(contract: AbstractContract, hex: string): FunctionCall; /** * build a CallData by unlocking script in hex. * @param hex hex of unlocking script * @returns a CallData which contains the function parameters that have been deserialized */ parseCallData(hex: string): CallData; }