scryptlib
Advanced tools
Comparing version 0.2.20 to 0.2.21
# CHANGELOG | ||
## 0.2.20 | ||
* add literal2ScryptType | ||
* add parseLiteral | ||
* deprecated literal2Asm | ||
## 0.2.19 | ||
@@ -4,0 +11,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
const SYNTAX_ERR_REG = /(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+):\n([^\n]+\n){3}(unexpected (?<unexpected>[^\n]+)\nexpecting (?<expecting>[^\n]+)|(?<message>[^\n]+))/g; | ||
const SEMANTIC_ERR_REG = /Error:\s*(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+)\n(?<message>[^\n]+)\n/g; | ||
const SEMANTIC_ERR_REG = /Error:\s*(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+):(?<line1>\d+):(?<column1>\d+)\n(?<message>[^\n]+)\n/g; | ||
const IMPORT_ERR_REG = /Syntax error:\s*(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+):\n([^\n]+\n){3}File not found: (?<fileName>[^\s]+)/g; | ||
@@ -15,0 +15,0 @@ var CompileErrorType; |
@@ -76,2 +76,20 @@ "use strict"; | ||
} | ||
get asmVars() { | ||
const regex = /(\$\S+)/g; | ||
const vars = Contract.asm.match(regex); | ||
if (vars === null) { | ||
return null; | ||
} | ||
const asmArray = Contract.asm.split(/\s/g); | ||
const lsASMArray = this.scriptedConstructor.toASM().split(/\s/g); | ||
const result = {}; | ||
for (let i = 0; i < asmArray.length; i++) { | ||
for (let j = 0; j < vars.length; j++) { | ||
if (vars[j] === asmArray[i]) { | ||
result[vars[j].replace('$', '')] = lsASMArray[i]; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
}; | ||
@@ -78,0 +96,0 @@ ContractClass.contractName = desc.contract; |
export { buildContractClass, VerifyResult } from './contract'; | ||
export { compile } from './compilerWrapper'; | ||
export { bsv, signTx, toHex, getPreimage, num2bin, bin2num, bool2Asm, int2Asm, parseLiteral, bytes2Literal, bytesToHexString, getValidatedHexString, literal2ScryptType, VariableType } from './utils'; | ||
export { bsv, signTx, toHex, getPreimage, num2bin, bin2num, bool2Asm, int2Asm, parseLiteral, bytes2Literal, bytesToHexString, getValidatedHexString, literal2ScryptType, VariableType, literal2Asm } from './utils'; | ||
export { serializeState, deserializeState, State, STATE_LEN_2BYTES, STATE_LEN_4BYTES } from './serializer'; | ||
export { Int, Bool, Bytes, PrivKey, PubKey, Sig, Ripemd160, Sha1, Sha256, SigHashType, SigHashPreimage, OpCodeType, SingletonParamType, SupportedParamType, ScryptType, ValueType } from './scryptTypes'; |
@@ -22,2 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "VariableType", { enumerable: true, get: function () { return utils_1.VariableType; } }); | ||
Object.defineProperty(exports, "literal2Asm", { enumerable: true, get: function () { return utils_1.literal2Asm; } }); | ||
var serializer_1 = require("./serializer"); | ||
@@ -24,0 +25,0 @@ Object.defineProperty(exports, "serializeState", { enumerable: true, get: function () { return serializer_1.serializeState; } }); |
@@ -65,2 +65,3 @@ export declare type ValueType = number | bigint | boolean | string; | ||
index: number; | ||
hex: string; | ||
} | ||
@@ -67,0 +68,0 @@ export declare class SigHashPreimage extends ScryptType { |
@@ -185,5 +185,10 @@ "use strict"; | ||
get outpoint() { | ||
const buf = this._buf.slice(68, 68 + 32 + 4); | ||
const hex = buf.toString('hex'); | ||
const index = this.getReader(buf.slice(32, 32 + 4)).readUInt32LE(); | ||
const hash = Buffer.from(buf.slice(0, 32)).reverse().toString('hex'); | ||
return { | ||
hash: this._buf.slice(68, 68 + 32).toString('hex'), | ||
index: this.getReader(this._buf.slice(68 + 32, 68 + 32 + 4)).readUInt32LE() | ||
hash, | ||
index, | ||
hex | ||
}; | ||
@@ -190,0 +195,0 @@ } |
@@ -22,2 +22,5 @@ "use strict"; | ||
function serializeString(str) { | ||
if (str === '') { | ||
return '00'; | ||
} | ||
const buf = Buffer.from(str, 'utf8'); | ||
@@ -122,3 +125,6 @@ return buf.toString('hex'); | ||
} | ||
return this.op.buf.toString(arg).trim(); | ||
if (this.op.buf[0] === 0) { | ||
return ''; | ||
} | ||
return this.op.buf.toString(arg); | ||
} | ||
@@ -125,0 +131,0 @@ } |
@@ -49,1 +49,6 @@ /// <reference types="node" /> | ||
export declare function uri2path(uri: string): string; | ||
/** | ||
* @deprecated | ||
* convert literals to script ASM format | ||
*/ | ||
export declare function literal2Asm(l: string): [string, string]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.uri2path = exports.path2uri = exports.bin2num = exports.num2bin = exports.getPreimage = exports.toHex = exports.signTx = exports.getValidatedHexString = exports.hexStringToBytes = exports.bytesToHexString = exports.bytes2Literal = exports.literal2ScryptType = exports.parseLiteral = exports.VariableType = exports.intValue2hex = exports.int2Value = exports.int2Asm = exports.bool2Asm = exports.DEFAULT_SIGHASH_TYPE = exports.DEFAULT_FLAGS = exports.bsv = void 0; | ||
exports.literal2Asm = exports.uri2path = exports.path2uri = exports.bin2num = exports.num2bin = exports.getPreimage = exports.toHex = exports.signTx = exports.getValidatedHexString = exports.hexStringToBytes = exports.bytesToHexString = exports.bytes2Literal = exports.literal2ScryptType = exports.parseLiteral = exports.VariableType = exports.intValue2hex = exports.int2Value = exports.int2Asm = exports.bool2Asm = exports.DEFAULT_SIGHASH_TYPE = exports.DEFAULT_FLAGS = exports.bsv = void 0; | ||
const url_1 = require("url"); | ||
@@ -345,2 +345,11 @@ const scryptTypes_1 = require("./scryptTypes"); | ||
exports.uri2path = uri2path; | ||
/** | ||
* @deprecated | ||
* convert literals to script ASM format | ||
*/ | ||
function literal2Asm(l) { | ||
const [asm, _, type] = parseLiteral(l); | ||
return [asm, type]; | ||
} | ||
exports.literal2Asm = literal2Asm; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "scryptlib", | ||
"version": "0.2.20", | ||
"version": "0.2.21", | ||
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.", | ||
@@ -5,0 +5,0 @@ "engines": { |
# scryptlib | ||
Javascript/TypeScript SDK for integration of Bitcoin SV Smart Contracts written in the sCrypt language. | ||
[![Build Status](https://travis-ci.com/scrypt-sv/scryptlib.svg?branch=master)](https://travis-ci.com/scrypt-sv/scryptlib) | ||
[![Build Status](https://travis-ci.com/sCrypt-Inc/scryptlib.svg?branch=master)](https://travis-ci.com/sCrypt-Inc/scryptlib) | ||
@@ -6,0 +6,0 @@ You can install `scryptlib` in your project as below: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79552
1735