Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scryptlib

Package Overview
Dependencies
Maintainers
3
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scryptlib - npm Package Compare versions

Comparing version 2.0.0-beta.4 to 2.0.0-beta.5

6

dist/abi.d.ts

@@ -0,5 +1,5 @@

import { ABIEntity } from './compilerWrapper';
import { AbstractContract, AsmVarValues, TxContext, VerifyResult } from './contract';
import { SupportedParamType, TypeResolver } from './scryptTypes';
import { bsv } from './utils';
import { AbstractContract, TxContext, VerifyResult, AsmVarValues } from './contract';
import { SupportedParamType, TypeResolver } from './scryptTypes';
import { ABIEntity } from './compilerWrapper';
export declare type Script = bsv.Script;

@@ -6,0 +6,0 @@ export declare type FileUri = string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ABICoder = exports.FunctionCall = void 0;
const utils_1 = require("./utils");
const builtins_1 = require("./builtins");
const compilerWrapper_1 = require("./compilerWrapper");
const contract_1 = require("./contract");
const compilerWrapper_1 = require("./compilerWrapper");
const typeCheck_1 = require("./typeCheck");
const deserializer_1 = require("./deserializer");
const serializer_1 = require("./serializer");
const builtins_1 = require("./builtins");
const stateful_1 = require("./stateful");
const deserializer_1 = require("./deserializer");
const typeCheck_1 = require("./typeCheck");
const utils_1 = require("./utils");
class FunctionCall {

@@ -13,0 +13,0 @@ constructor(methodName, binding) {

/// <reference types="node" />
import { Int, bsv, Ripemd160, Bytes } from '.';
import { bsv, Bytes, Int, Ripemd160 } from '.';
/**

@@ -4,0 +4,0 @@ * bigint can be converted to string with pack

/// <reference types="node" />
import { ChildProcess } from 'child_process';
import { ContractDescription, TypeResolver } from './internal';
import { ContractArtifact, TypeResolver } from './internal';
export declare const SOURCE_REG: RegExp;

@@ -79,3 +79,3 @@ export declare enum CompileErrorType {

dbgFile?: string;
toDesc(): ContractDescription;
toArtifact(): ContractArtifact;
}

@@ -154,3 +154,3 @@ export declare enum DebugModeTag {

debug?: boolean;
desc?: boolean;
artifact?: boolean;
outputDir?: string;

@@ -223,5 +223,5 @@ outputToFiles?: boolean;

export declare function getStaticDeclaration(astRoot: unknown, dependencyAsts: unknown): Array<StaticEntity>;
export declare function loadSourceMapfromDesc(desc: ContractDescription): Array<{
export declare function loadSourceMapfromArtifact(artifact: ContractArtifact): Array<{
pos: Pos | undefined;
opcode: string;
}>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadSourceMapfromDesc = exports.getStaticDeclaration = exports.getAliasDeclaration = exports.getContractDeclaration = exports.getLibraryDeclaration = exports.getStructDeclaration = exports.getABIDeclaration = exports.getContractName = exports.getFullFilePath = exports.compilerVersion = exports.handleCompilerOutput = exports.compile = exports.settings2cmd = exports.compileAsync = exports.doCompileAsync = exports.ABIEntityType = exports.DebugModeTag = exports.CompileResult = exports.BuildType = exports.CompileErrorType = exports.SOURCE_REG = void 0;
const path_1 = require("path");
exports.loadSourceMapfromArtifact = exports.getStaticDeclaration = exports.getAliasDeclaration = exports.getContractDeclaration = exports.getLibraryDeclaration = exports.getStructDeclaration = exports.getABIDeclaration = exports.getContractName = exports.getFullFilePath = exports.compilerVersion = exports.handleCompilerOutput = exports.compile = exports.settings2cmd = exports.compileAsync = exports.doCompileAsync = exports.ABIEntityType = exports.DebugModeTag = exports.CompileResult = exports.BuildType = exports.CompileErrorType = exports.SOURCE_REG = void 0;
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const path_1 = require("path");
const internal_1 = require("./internal");
const rimraf = require("rimraf");
const JSONbig = require("json-bigint");
const internal_1 = require("./internal");
const SYNTAX_ERR_REG = /(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+):\n([^\n]+\n){3}(unexpected (?<unexpected>[^\n]+)\nexpecting (?<expecting>[^\n]+)|(?<message>[^\n]+))/g;

@@ -36,5 +36,5 @@ const SEMANTIC_ERR_REG = /Error:(\s|\n)*(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+):(?<line1>\d+):(?<column1>\d+):*\n(?<message>[^\n]+)\n/g;

}
toDesc() {
const description = {
version: internal_1.CURRENT_CONTRACT_DESCRIPTION_VERSION,
toArtifact() {
const artifact = {
version: internal_1.CURRENT_CONTRACT_ARTIFACT_VERSION,
compilerVersion: this.compilerVersion || '0.0.0',

@@ -56,3 +56,3 @@ contract: this.contract || '',

};
return description;
return artifact;
}

@@ -72,4 +72,4 @@ }

})(ABIEntityType = exports.ABIEntityType || (exports.ABIEntityType = {}));
function toOutputDir(descDir, sourcePath) {
return path_1.join(descDir, path_1.basename(sourcePath) + '-' + internal_1.hash160(sourcePath, 'utf-8').substring(0, 10));
function toOutputDir(artifactsDir, sourcePath) {
return path_1.join(artifactsDir, path_1.basename(sourcePath) + '-' + internal_1.hash160(sourcePath, 'utf-8').substring(0, 10));
}

@@ -129,3 +129,3 @@ function doCompileAsync(source, settings, callback) {

debug: false,
desc: false,
artifact: false,
outputDir: '',

@@ -143,6 +143,6 @@ outputToFiles: false,

const srcDir = path_1.dirname(sourcePath);
//dir that store desc file
const descDir = settings.outputDir || srcDir;
//dir that store artifact file
const artifactDir = settings.outputDir || srcDir;
//dir that store ast,asm file
const outputDir = toOutputDir(descDir, sourcePath);
const outputDir = toOutputDir(artifactDir, sourcePath);
const cmdPrefix = settings.cmdPrefix || internal_1.findCompiler();

@@ -152,3 +152,3 @@ let outOption = `-o "${outputDir}"`;

outOption = '--stdout';
return `${cmdPrefix} compile ${settings.asm || settings.desc ? '--asm' : ''} ${settings.hex ? '--hex' : ''} ${settings.ast || settings.desc ? '--ast' : ''} ${settings.debug == true ? '--debug' : ''} -r ${outOption} ${settings.cmdArgs ? settings.cmdArgs : ''}`;
return `${cmdPrefix} compile ${settings.asm || settings.artifact ? '--asm' : ''} ${settings.hex ? '--hex' : ''} ${settings.ast || settings.artifact ? '--ast' : ''} ${settings.debug == true ? '--debug' : ''} -r ${outOption} ${settings.cmdArgs ? settings.cmdArgs : ''}`;
}

@@ -160,3 +160,3 @@ else {

}
return `${cmdPrefix} compile ${settings.hex ? '--hex' : ''} ${settings.ast || settings.desc ? '--ast' : ''} ${settings.debug == true ? '--debug' : ''} ${settings.sourceMap == true ? '--source-map' : ''} -r ${outOption} ${settings.cmdArgs ? settings.cmdArgs : ''}`;
return `${cmdPrefix} compile ${settings.hex ? '--hex' : ''} ${settings.ast || settings.artifact ? '--ast' : ''} ${settings.debug == true ? '--debug' : ''} ${settings.sourceMap == true ? '--source-map' : ''} -r ${outOption} ${settings.cmdArgs ? settings.cmdArgs : ''}`;
}

@@ -167,3 +167,3 @@ exports.settings2cmd = settings2cmd;

const srcDir = path_1.dirname(sourcePath);
//dir that store desc file
//dir that stores artifact file
const curWorkingDir = settings.cwd || srcDir;

@@ -182,4 +182,4 @@ settings = Object.assign({}, defaultCompilingSettings, settings);

const sourceFileName = path_1.basename(sourcePath);
const descDir = settings.outputDir || srcDir;
const outputDir = toOutputDir(descDir, sourcePath);
const artifactsDir = settings.outputDir || srcDir;
const outputDir = toOutputDir(artifactsDir, sourcePath);
const outputFiles = {};

@@ -208,3 +208,3 @@ try {

else {
if (settings.ast || settings.desc) {
if (settings.ast || settings.artifact) {
const outputFilePath = getOutputFilePath(outputDir, 'ast');

@@ -217,3 +217,3 @@ const astFile = outputFilePath.replace('stdin', path_1.basename(sourcePath, '.scrypt'));

}
if (settings.hex || settings.desc) {
if (settings.hex || settings.artifact) {
const outputFilePath = getOutputFilePath(outputDir, 'hex');

@@ -227,4 +227,4 @@ const hexFile = outputFilePath.replace('stdin', path_1.basename(sourcePath, '.scrypt'));

const outputFilePath = getOutputFilePath(outputDir, 'map');
if (settings.desc) {
const dist = getOutputFilePath(descDir, 'map');
if (settings.artifact) {
const dist = getOutputFilePath(artifactsDir, 'map');
const sourceMapFile = dist.replace('stdin', path_1.basename(sourcePath, '.scrypt'));

@@ -247,7 +247,7 @@ fs_1.renameSync(outputFilePath, sourceMapFile);

}
if (settings.desc) {
const outputFilePath = getOutputFilePath(descDir, 'desc');
const descFile = outputFilePath.replace('stdin', path_1.basename(sourcePath, '.scrypt'));
const description = result.toDesc();
fs_1.writeFileSync(descFile, JSON.stringify(description, (key, value) => {
if (settings.artifact) {
const outputFilePath = getOutputFilePath(artifactsDir, 'artifact');
const artifactFile = outputFilePath.replace('stdin', path_1.basename(sourcePath, '.scrypt'));
const artifact = result.toArtifact();
fs_1.writeFileSync(artifactFile, JSON.stringify(artifact, (key, value) => {
//ignore deprecated fields

@@ -328,2 +328,5 @@ if (key == 'sources' || key == 'sourceMap' || key === 'asm')

}
else if (target === 'artifact') {
return path_1.join(baseDir, 'stdin.json');
}
return path_1.join(baseDir, `stdin_${target}.json`);

@@ -805,10 +808,10 @@ }

}
function loadSourceMapfromDesc(desc) {
const sources = desc.sources;
const asm = desc.asm.split(' ');
if (!desc.sourceMap || desc.sourceMap.length == 0) {
function loadSourceMapfromArtifact(artifact) {
const sources = artifact.sources;
const asm = artifact.asm.split(' ');
if (!artifact.sourceMap || artifact.sourceMap.length == 0) {
return [];
}
return asm.map((opcode, index) => {
const item = desc.sourceMap[index];
const item = artifact.sourceMap[index];
const match = exports.SOURCE_REG.exec(item);

@@ -831,3 +834,3 @@ if (match && match.groups) {

}
exports.loadSourceMapfromDesc = loadSourceMapfromDesc;
exports.loadSourceMapfromArtifact = loadSourceMapfromArtifact;
//# sourceMappingURL=compilerWrapper.js.map
import { LibraryEntity, ParamEntity } from '.';
import { ContractEntity, OpCode, StaticEntity } from './compilerWrapper';
import { ABICoder, Arguments, FunctionCall, Script, bsv, TypeResolver, StructEntity, ABIEntity, CompileResult, AliasEntity } from './internal';
import { SupportedParamType, HashedMap, HashedSet, Bytes } from './scryptTypes';
import { ABICoder, ABIEntity, AliasEntity, Arguments, bsv, CompileResult, FunctionCall, Script, StructEntity, TypeResolver } from './internal';
import { Bytes, HashedMap, HashedSet, SupportedParamType } from './scryptTypes';
export interface TxContext {

@@ -22,5 +22,5 @@ tx: bsv.Transaction;

}
export declare const CURRENT_CONTRACT_DESCRIPTION_VERSION = 9;
export declare const CURRENT_CONTRACT_ARTIFACT_VERSION = 9;
export declare const SUPPORTED_MINIMUM_VERSION = 8;
export interface ContractDescription {
export interface ContractArtifact {
version: number;

@@ -48,3 +48,3 @@ compilerVersion: string;

export declare class AbstractContract {
static desc: ContractDescription;
static artifact: ContractArtifact;
static opcodes?: OpCode[];

@@ -135,4 +135,4 @@ static hex: string;

}
export declare function buildContractClass(desc: ContractDescription | CompileResult): typeof AbstractContract;
export declare function buildTypeResolverFromDesc(desc: ContractDescription): TypeResolver;
export declare function buildContractClass(artifact: ContractArtifact | CompileResult): typeof AbstractContract;
export declare function buildTypeResolverFromArtifact(artifact: ContractArtifact): TypeResolver;
export declare function buildTypeResolver(contract: string, alias: AliasEntity[], structs: StructEntity[], library: LibraryEntity[], contracts?: ContractEntity[], statics?: StaticEntity[]): TypeResolver;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildTypeResolver = exports.buildTypeResolverFromDesc = exports.buildContractClass = exports.AbstractContract = exports.SUPPORTED_MINIMUM_VERSION = exports.CURRENT_CONTRACT_DESCRIPTION_VERSION = void 0;
exports.buildTypeResolver = exports.buildTypeResolverFromArtifact = exports.buildContractClass = exports.AbstractContract = exports.SUPPORTED_MINIMUM_VERSION = exports.CURRENT_CONTRACT_ARTIFACT_VERSION = void 0;
const path_1 = require("path");
const _1 = require(".");

@@ -8,6 +9,5 @@ const compilerWrapper_1 = require("./compilerWrapper");

const scryptTypes_1 = require("./scryptTypes");
const path_1 = require("path");
const stateful_1 = require("./stateful");
const typeCheck_1 = require("./typeCheck");
const stateful_1 = require("./stateful");
exports.CURRENT_CONTRACT_DESCRIPTION_VERSION = 9;
exports.CURRENT_CONTRACT_ARTIFACT_VERSION = 9;
exports.SUPPORTED_MINIMUM_VERSION = 8;

@@ -39,20 +39,20 @@ class AbstractContract {

get sourceMapFile() {
const desc = Object.getPrototypeOf(this).constructor.desc;
return desc.sourceMapFile;
const artifact = Object.getPrototypeOf(this).constructor.artifact;
return artifact.sourceMapFile;
}
get file() {
const desc = Object.getPrototypeOf(this).constructor.desc;
return desc.file;
const artifact = Object.getPrototypeOf(this).constructor.artifact;
return artifact.file;
}
get contractName() {
const desc = Object.getPrototypeOf(this).constructor.desc;
return desc.contract;
const artifact = Object.getPrototypeOf(this).constructor.artifact;
return artifact.contract;
}
get stateProps() {
const desc = Object.getPrototypeOf(this).constructor.desc;
return desc.stateProps || [];
const artifact = Object.getPrototypeOf(this).constructor.artifact;
return artifact.stateProps || [];
}
get version() {
const desc = Object.getPrototypeOf(this).constructor.desc;
return desc.version || 0;
const artifact = Object.getPrototypeOf(this).constructor.artifact;
return artifact.version || 0;
}

@@ -189,4 +189,4 @@ addFunctionCall(f) {

else if (this.version <= 8) {
const desc = Object.getPrototypeOf(this).constructor.desc;
const sourceMap = compilerWrapper_1.loadSourceMapfromDesc(desc);
const artifact = Object.getPrototypeOf(this).constructor.artifact;
const sourceMap = compilerWrapper_1.loadSourceMapfromArtifact(artifact);
if (sourceMap.length > 0) {

@@ -475,20 +475,20 @@ // the complete script may have op_return and data, but compiled output does not have it. So we need to make sure the index is in boundary.

'txContext'];
function buildContractClass(desc) {
if (desc instanceof internal_1.CompileResult) {
desc = desc.toDesc();
function buildContractClass(artifact) {
if (artifact instanceof internal_1.CompileResult) {
artifact = artifact.toArtifact();
}
if (!desc.contract) {
throw new Error('missing field `contract` in description');
if (!artifact.contract) {
throw new Error('Missing field `contract` in artifact');
}
if (!desc.version) {
throw new Error('missing field `version` in description');
if (!artifact.version) {
throw new Error('Missing field `version` in artifact');
}
if (desc.version < exports.SUPPORTED_MINIMUM_VERSION) {
throw new Error(`Contract description version deprecated, The minimum version number currently supported is ${exports.SUPPORTED_MINIMUM_VERSION}`);
if (artifact.version < exports.SUPPORTED_MINIMUM_VERSION) {
throw new Error(`Contract artifact version deprecated, The minimum version number currently supported is ${exports.SUPPORTED_MINIMUM_VERSION}`);
}
if (!desc.abi) {
throw new Error('missing field `abi` in description');
if (!artifact.abi) {
throw new Error('Missing field `abi` in artifact');
}
if (!desc.hex) {
throw new Error('missing field `hex` in description');
if (!artifact.hex) {
throw new Error('Missing field `hex` in artifact');
}

@@ -503,8 +503,8 @@ const ContractClass = class extends AbstractContract {

};
ContractClass.desc = desc;
ContractClass.resolver = buildTypeResolverFromDesc(desc);
ContractClass.abi = desc.abi;
ContractClass.hex = desc.hex;
ContractClass.abiCoder = new internal_1.ABICoder(desc.abi, ContractClass.resolver);
ContractClass.stateProps = desc.stateProps || [];
ContractClass.artifact = artifact;
ContractClass.resolver = buildTypeResolverFromArtifact(artifact);
ContractClass.abi = artifact.abi;
ContractClass.hex = artifact.hex;
ContractClass.abiCoder = new internal_1.ABICoder(artifact.abi, ContractClass.resolver);
ContractClass.stateProps = artifact.stateProps || [];
ContractClass.abi.forEach((entity) => {

@@ -556,10 +556,10 @@ if (entity.type === _1.ABIEntityType.CONSTRUCTOR) {

exports.buildContractClass = buildContractClass;
function buildTypeResolverFromDesc(desc) {
const alias = desc.alias || [];
const library = desc.library || [];
const structs = desc.structs || [];
const contract = desc.contract;
function buildTypeResolverFromArtifact(artifact) {
const alias = artifact.alias || [];
const library = artifact.library || [];
const structs = artifact.structs || [];
const contract = artifact.contract;
return buildTypeResolver(contract, alias, structs, library);
}
exports.buildTypeResolverFromDesc = buildTypeResolverFromDesc;
exports.buildTypeResolverFromArtifact = buildTypeResolverFromArtifact;
// build a resolver witch can only resolve type

@@ -566,0 +566,0 @@ function buildTypeResolver(contract, alias, structs, library, contracts = [], statics = []) {

import { Argument, ParamEntity, TypeResolver } from '.';
import { Bytes, SupportedParamType, StructObject } from './scryptTypes';
import { Bytes, StructObject, SupportedParamType } from './scryptTypes';
/**

@@ -4,0 +4,0 @@ * little-endian signed magnitude to int

@@ -5,4 +5,4 @@ "use strict";

const _1 = require(".");
const scryptTypes_1 = require("./scryptTypes");
const stateful_1 = require("./stateful");
const scryptTypes_1 = require("./scryptTypes");
const utils_1 = require("./utils");

@@ -9,0 +9,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findCompiler = exports.getPlatformScryptc = void 0;
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const minimist = require("minimist");
const os = require("os");
const path_1 = require("path");
const minimist = require("minimist");
const fs_1 = require("fs");
const compareVersions = require("compare-versions");
const child_process_1 = require("child_process");
const os = require("os");
const showNoCompilerFound = require("../util/showerror");

@@ -11,0 +11,0 @@ function getPlatformScryptc() {

export { buildContractClass, compile, compileAsync, compileContract, doCompileAsync, getPreimage, signTx, handleCompilerOutput, compileContractAsync, CompilingSettings } from './internal';
export { bsv, toHex, bin2num, int2Asm, bytes2Literal, bytesToHexString, getValidatedHexString, findStructByType, findStructByName, isArrayType, arrayTypeAndSize, newCall, getNameByType, genLaunchConfigFile, subArrayType, isGenericType, parseGenericType, readLaunchJson, getLowSPreimage, readBytes, parseAbiFromUnlockingScript, findConstStatic, findStatic, resolveConstValue, arrayTypeAndSizeStr, toLiteralArrayType, librarySign, structSign, resolveGenericType, canAssignProperty, buildTypeResolver, getStructDeclaration, getABIDeclaration, typeOfArg, compilerVersion, parseLiteral, isEmpty, JSONParser, getFullFilePath, path2uri, uri2path, md5, FunctionCall, stringToBytes, isScryptType, isSubBytes, toJSON } from './internal';
export { Int, Bool, Bytes, PrivKey, PubKey, Sig, Ripemd160, Sha1, Sha256, SigHashType, SigHashPreimage, OpCodeType, SupportedParamType, PubKeyHash, TxContext, ContractClass, Contract, StructObject, TypeResolver, PrimitiveTypes, AsmVarValues, Arguments, Argument, StructEntity, LibraryEntity, ABIEntity, ABIEntityType, ABI, ParamEntity, BuildType, RelatedInformation, ContractDescription, VerifyResult, VerifyError, AbstractContract, DebugInfo, DebugModeTag, ContractEntity, TypeInfo, SymbolType, DEFAULT_FLAGS } from './internal';
export { Int, Bool, Bytes, PrivKey, PubKey, Sig, Ripemd160, Sha1, Sha256, SigHashType, SigHashPreimage, OpCodeType, SupportedParamType, PubKeyHash, TxContext, ContractClass, Contract, StructObject, TypeResolver, PrimitiveTypes, AsmVarValues, Arguments, Argument, StructEntity, LibraryEntity, ABIEntity, ABIEntityType, ABI, ParamEntity, BuildType, RelatedInformation, ContractArtifact, VerifyResult, VerifyError, AbstractContract, DebugInfo, DebugModeTag, ContractEntity, TypeInfo, SymbolType, DEFAULT_FLAGS } from './internal';
export { hash160, sha256, hash256, and, or, xor, invert, num2bin, buildOpreturnScript, len, buildPublicKeyHashScript, writeVarint, toLEUnsigned } from './internal';
export { getPlatformScryptc, findCompiler } from './internal';
export { partialSha256, sha256ByPartialHash } from './internal';
import { AbstractContract, Arguments } from '.';
import { Int, Bytes, SupportedParamType, TypeResolver } from './scryptTypes';
import { Bytes, Int, SupportedParamType, TypeResolver } from './scryptTypes';
export default class Stateful {

@@ -4,0 +4,0 @@ static readonly CURRENT_STATE_VERSION = 0n;

/// <reference types="node" />
import * as bsv from 'bsv';
export { bsv };
import { SupportedParamType, StructEntity, CompileResult, AliasEntity, AbstractContract, AsmVarValues, TxContext, DebugLaunch, FileUri, Script } from './internal';
import { ABIEntity, LibraryEntity, TypeInfo } from '.';
import { OpCode, StaticEntity } from './compilerWrapper';
import { VerifyError } from './contract';
import { ABIEntity, LibraryEntity, TypeInfo } from '.';
import { AbstractContract, AliasEntity, AsmVarValues, CompileResult, DebugLaunch, FileUri, Script, StructEntity, SupportedParamType, TxContext } from './internal';
export declare const DEFAULT_FLAGS: number;

@@ -44,7 +44,7 @@ export declare const DEFAULT_SIGHASH_TYPE: number;

sourceMap?: boolean;
desc?: boolean;
artifact?: boolean;
}): CompileResult;
export declare function compileContractAsync(file: string, options?: {
out?: string;
desc?: boolean;
artifact?: boolean;
sourceMap?: boolean;

@@ -51,0 +51,0 @@ }): Promise<CompileResult>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.md5 = exports.findSrcInfoV1 = exports.findSrcInfoV2 = exports.JSONStringify = exports.JSONParserSync = exports.JSONParser = exports.canAssignProperty = exports.structSign = exports.librarySign = exports.resolveGenericType = exports.parseAbiFromUnlockingScript = exports.readLaunchJson = exports.parseGenericType = exports.isGenericType = exports.readBytes = exports.buildContractCode = exports.findStatic = exports.findConstStatic = exports.stripAnsi = exports.ansiRegex = exports.resolveType = exports.resolveConstValue = exports.genLaunchConfigFile = exports.newCall = exports.compileContractAsync = exports.compileContract = exports.isEmpty = exports.readFileByLine = exports.subscript = exports.toGenericType = exports.findStructByType = exports.getNameByType = exports.isArrayType = exports.findStructByName = exports.uri2path = exports.path2uri = exports.isNode = exports.getLowSPreimage = exports.hashIsPositiveNumber = exports.getPreimage = exports.signTx = exports.hexStringToBytes = exports.bytesToHexString = exports.bytes2Literal = exports.utf82Hex = exports.toHex = exports.uint82hex = exports.asm2int = exports.int2Asm = exports.DEFAULT_SIGHASH_TYPE = exports.DEFAULT_FLAGS = exports.bsv = void 0;
const url_1 = require("url");
const fs = require("fs");
const crypto = require("crypto");
const json_ext_1 = require("@discoveryjs/json-ext");
const bsv = require("bsv");
exports.bsv = bsv;
const crypto = require("crypto");
const fs = require("fs");
const os_1 = require("os");
const path_1 = require("path");
const os_1 = require("os");
const json_ext_1 = require("@discoveryjs/json-ext");
const sourcemap_codec_1 = require("sourcemap-codec");
const url_1 = require("url");
const _1 = require(".");
const compilerWrapper_1 = require("./compilerWrapper");
const internal_1 = require("./internal");
const compilerWrapper_1 = require("./compilerWrapper");
const _1 = require(".");
const typeCheck_1 = require("./typeCheck");

@@ -272,3 +272,3 @@ const BN = bsv.crypto.BN;

sourceMap: false,
desc: false,
artifact: false,
}, options);

@@ -282,3 +282,3 @@ if (!fs.existsSync(file)) {

const result = internal_1.compile({ path: file }, {
desc: options.desc, outputDir: options.out,
artifact: options.artifact, outputDir: options.out,
sourceMap: options.sourceMap,

@@ -295,3 +295,3 @@ cmdPrefix: internal_1.findCompiler()

sourceMap: false,
desc: false,
artifact: false,
}, options);

@@ -305,3 +305,3 @@ if (!fs.existsSync(file)) {

return compilerWrapper_1.compileAsync({ path: file }, {
desc: options.desc, outputDir: options.out,
artifact: options.artifact, outputDir: options.out,
sourceMap: options.sourceMap,

@@ -318,3 +318,3 @@ hex: true,

function genLaunchConfigFile(constructorArgs, pubFuncArgs, pubFunc, name, program, txContext, asmArgs) {
// some desc without sourceMap will not have file property.
// some artifact without sourceMap will not have file property.
if (!program) {

@@ -321,0 +321,0 @@ return '';

{
"name": "scryptlib",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.",

@@ -5,0 +5,0 @@ "engines": {

@@ -20,7 +20,7 @@ # scryptlib

## Contract Description File
## Contract Artifact File
The compiler output results in a JSON file. It’s a representation used to build locking and unlocking scripts. We call this file a [**contract description file**](docs/counter_debug_desc.json).
The compiler output results in a JSON file. It’s a representation used to build locking and unlocking scripts. We call this file a [**contract artifact file**](docs/counter_debug.json).
There are three ways to generate this file (named as `xxx_desc.json`):
There are three ways to generate this file (named as `<contract_name>.json`):

@@ -39,3 +39,3 @@ 1. Use [**sCrypt VS Code extension**](https://marketplace.visualstudio.com/items?itemName=bsv-scrypt.sCrypt) to compile manually;

{
desc: true // set this flag to be `true` to get the description file output
artifact: true // set this flag to be `true` to get the artifact file output
asm: true // set this flag to be `true` to get the asm file output

@@ -146,3 +146,3 @@ optimize: false //set this flag to be `true` to get optimized asm opcode

const PersonContract = buildContractClass(loadDescription('person_desc.json'));
const PersonContract = buildContractClass(loadArtifact('person.json'));

@@ -203,3 +203,3 @@ /*Person is structure and Male, Female are type aliases */

const Test = buildContractClass(loadDescription('test_desc.json'));
const Test = buildContractClass(loadArtifact('test.json'));

@@ -223,5 +223,5 @@ const { L } = buildTypeClasses(Test);

### 1. Get Locking and Unlocking Script
You can use the description file to build a reflected contract class in Javascript/TypeScript like this:
You can use the artifact file to build a reflected contract class in Javascript/TypeScript like this:
```typescript
const MyContract = buildContractClass(JSON.parse(descFileContent));
const MyContract = buildContractClass(JSON.parse(artifactFileContent));
```

@@ -359,3 +359,3 @@ To create an instance of the contract class, for example:

const Counter = buildContractClass(loadDesc("counter_debug_desc.json"));
const Counter = buildContractClass(loadArtifact("counter_debug.json"));
let response = await axios.get("https://api.whatsonchain.com/v1/bsv/test/tx/7b9bc5c67c91a3caa4b3212d3a631a4b61e5c660f0369615e6e3a969f6bef4de/hex")

@@ -362,0 +362,0 @@ // constructor from raw Transaction.

@@ -30,3 +30,3 @@ var fs = require('fs')

outputDir: out,
desc: true,
artifact: true,
hex: true,

@@ -46,3 +46,3 @@ optimize: false,

const output = path.join(out, `${path.basename(sourcePath, '.scrypt')}_desc.json`);
const output = path.join(out, `${path.basename(sourcePath, '.scrypt')}.json`);

@@ -49,0 +49,0 @@ console.log(`${chalk.green("✔")} ${chalk.green.bold("Compiling succeeded")} with output: ${output}`);

@@ -1,2 +0,2 @@

# Contract Description Version
# Contract Artifact Version

@@ -3,0 +3,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc