scryptlib
Advanced tools
Comparing version 2.1.27 to 2.1.28
@@ -149,3 +149,3 @@ import { LibraryEntity, ParamEntity } from '.'; | ||
setDataPartInHex(hex: string): void; | ||
setNOPScript(inscription: NOPScript | null): void; | ||
setNOPScript(nopScript: NOPScript | null): void; | ||
getNOPScript(): NOPScript | null; | ||
@@ -152,0 +152,0 @@ get codePart(): Script; |
@@ -411,4 +411,7 @@ "use strict"; | ||
}; | ||
AbstractContract.prototype.setNOPScript = function (inscription) { | ||
this.nopScript = inscription; | ||
AbstractContract.prototype.setNOPScript = function (nopScript) { | ||
if (nopScript instanceof internal_1.bsv.Script) { | ||
(0, internal_1.checkNOPScript)(nopScript); | ||
} | ||
this.nopScript = nopScript; | ||
}; | ||
@@ -415,0 +418,0 @@ AbstractContract.prototype.getNOPScript = function () { |
@@ -76,1 +76,2 @@ /// <reference types="node" /> | ||
export declare function md5(s: string): string; | ||
export declare function checkNOPScript(nopScript: bsv.Script): void; |
@@ -66,3 +66,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.md5 = exports.findSrcInfoV1 = exports.findSrcInfoV2 = exports.JSONStringify = exports.JSONParserSync = exports.JSONParser = exports.structSign = exports.librarySign = exports.parseAbiFromUnlockingScript = exports.buildContractCode = exports.stripAnsi = exports.ansiRegex = exports.resolveConstValue = 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; | ||
exports.checkNOPScript = exports.md5 = exports.findSrcInfoV1 = exports.findSrcInfoV2 = exports.JSONStringify = exports.JSONParserSync = exports.JSONParser = exports.structSign = exports.librarySign = exports.parseAbiFromUnlockingScript = exports.buildContractCode = exports.stripAnsi = exports.ansiRegex = exports.resolveConstValue = 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; | ||
var json_ext_1 = require("@discoveryjs/json-ext"); | ||
@@ -564,2 +564,18 @@ var bsv = require("bsv"); | ||
exports.md5 = md5; | ||
function checkNOPScript(nopScript) { | ||
bsv.Script.Interpreter.MAX_SCRIPT_ELEMENT_SIZE = Number.MAX_SAFE_INTEGER; | ||
bsv.Script.Interpreter.MAXIMUM_ELEMENT_SIZE = Number.MAX_SAFE_INTEGER; | ||
var bsi = new bsv.Script.Interpreter(); | ||
var tx = new bsv.Transaction().from({ | ||
txId: 'a477af6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458', | ||
outputIndex: 0, | ||
script: '', | ||
satoshis: 1 | ||
}); | ||
var result = bsi.verify(new bsv.Script(""), nopScript, tx, 0, exports.DEFAULT_FLAGS, new bsv.crypto.BN(1)); | ||
if (result || bsi.errstr !== "SCRIPT_ERR_EVAL_FALSE_NO_RESULT") { | ||
throw new Error("NopScript should be a script that does not affect the Bitcoin virtual machine stack."); | ||
} | ||
} | ||
exports.checkNOPScript = checkNOPScript; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "scryptlib", | ||
"version": "2.1.27", | ||
"version": "2.1.28", | ||
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.", | ||
@@ -5,0 +5,0 @@ "engines": { |
974625
24013