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

scrypt-ts

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrypt-ts - npm Package Compare versions

Comparing version 0.1.3-alpha.4 to 0.1.3-alpha.5

.env

44

dist/builtins/functions.js

@@ -350,3 +350,3 @@ "use strict";

static fromLEUnsigned(bytes) {
return unpack(bytes + (0, types_1.b)('00'));
return unpack(bytes + (0, types_1.hex)('00'));
}

@@ -360,13 +360,13 @@ /*

let l = 0n;
let ret = (0, types_1.b)('');
let ret = (0, types_1.hex)('');
let header = buf.slice(0, 2);
if (header == (0, types_1.b)('fd')) {
if (header == (0, types_1.hex)('fd')) {
l = Utils.fromLEUnsigned(buf.slice(2, 6));
ret = buf.slice(6, 6 + Number(l * 2n));
}
else if (header == (0, types_1.b)('fe')) {
else if (header == (0, types_1.hex)('fe')) {
l = Utils.fromLEUnsigned(buf.slice(2, 10));
ret = buf.slice(10, 10 + Number(l * 2n));
}
else if (header == (0, types_1.b)('ff')) {
else if (header == (0, types_1.hex)('ff')) {
l = Utils.fromLEUnsigned(buf.slice(2, 18));

@@ -384,3 +384,3 @@ ret = buf.slice(18, 18 + Number(l * 2n));

let n = len(buf);
let header = (0, types_1.b)('');
let header = (0, types_1.hex)('');
if (n < 0xfd) {

@@ -390,9 +390,9 @@ header = Utils.toLEUnsigned(BigInt(n), 1n);

else if (n < 0x10000) {
header = (0, types_1.b)('fd') + Utils.toLEUnsigned(BigInt(n), 2n);
header = (0, types_1.hex)('fd') + Utils.toLEUnsigned(BigInt(n), 2n);
}
else if (n < 0x100000000) {
header = (0, types_1.b)('fe') + Utils.toLEUnsigned(BigInt(n), 4n);
header = (0, types_1.hex)('fe') + Utils.toLEUnsigned(BigInt(n), 4n);
}
else if (n < 0x10000000000000000) {
header = (0, types_1.b)('ff') + Utils.toLEUnsigned(BigInt(n), 8n);
header = (0, types_1.hex)('ff') + Utils.toLEUnsigned(BigInt(n), 8n);
}

@@ -465,3 +465,3 @@ return header + buf;

let l = len(preimage.toString());
return preimage.toString().slice(l * 2 - 80, l * 2 - 16);
return preimage.toString().slice(l * 2 - 16, l * 2 - 8);
}

@@ -499,3 +499,3 @@ static nLocktime(preimage) {

let buf = this.buf;
let ret = (0, types_1.b)('');
let ret = (0, types_1.hex)('');
let header = unpack(buf.slice(Number(this.pos * 2n), Number((this.pos + 1n) * 2n)));

@@ -532,3 +532,3 @@ this.pos++;

this.pos++;
return (0, types_1.b)('00') != buf;
return (0, types_1.hex)('00') != buf;
}

@@ -564,3 +564,3 @@ readInt() {

let n = BigInt(len(buf));
let header = (0, types_1.b)('');
let header = (0, types_1.hex)('');
if (n < 0x4c) {

@@ -570,9 +570,9 @@ header = Utils.toLEUnsigned(n, 1n);

else if (n < 0x100) {
header = (0, types_1.b)('4c') + Utils.toLEUnsigned(n, 1n);
header = (0, types_1.hex)('4c') + Utils.toLEUnsigned(n, 1n);
}
else if (n < 0x10000) {
header = (0, types_1.b)('4d') + Utils.toLEUnsigned(n, 2n);
header = (0, types_1.hex)('4d') + Utils.toLEUnsigned(n, 2n);
}
else if (n < 0x100000000) {
header = (0, types_1.b)('4e') + Utils.toLEUnsigned(n, 4n);
header = (0, types_1.hex)('4e') + Utils.toLEUnsigned(n, 4n);
}

@@ -587,7 +587,7 @@ else {

static writeBool(x) {
return x ? (0, types_1.b)('01') : (0, types_1.b)('00');
return x ? (0, types_1.hex)('01') : (0, types_1.hex)('00');
}
// bigint is little endian
static writeInt(x) {
return VarIntWriter.writeBytes(x == 0n ? (0, types_1.b)('00') : pack(x));
return VarIntWriter.writeBytes(x == 0n ? (0, types_1.hex)('00') : pack(x));
}

@@ -632,3 +632,3 @@ static serializeState(stateBuf) {

// rBigEndian must be mininally encoded, to conform to strict DER rule
let rb = (0, types_1.b)('30') + pack(l) + (0, types_1.b)('02') + pack(rlen) + rBigEndian + (0, types_1.b)('02') + pack(BigInt(slen)) + sBigEndian + sigHashType;
let rb = (0, types_1.hex)('30') + pack(l) + (0, types_1.hex)('02') + pack(rlen) + rBigEndian + (0, types_1.hex)('02') + pack(BigInt(slen)) + sBigEndian + sigHashType;
return new types_1.Sig(rb);

@@ -639,3 +639,3 @@ }

// append positive sign byte. This does not hurt even when sign bit is already positive
return unpack(reverseBytes(bytes, 32) + (0, types_1.b)('00'));
return unpack(reverseBytes(bytes, 32) + (0, types_1.hex)('00'));
}

@@ -665,3 +665,3 @@ // optimal pushtx

Tx.privKey = new types_1.PrivKey(0x26f00fe2340a84335ebdf30f57e9bb58487117b29355718f5e46bf5168d7df97n);
Tx.pubKey = new types_1.PubKey((0, types_1.b)('02ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382'));
Tx.pubKey = new types_1.PubKey((0, types_1.hex)('02ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382'));
// invK is the modular inverse of k, the ephemeral key

@@ -672,3 +672,3 @@ Tx.invK = 0xc8ffdbaa05d93aa4ede79ec58f06a72562048b775a3507c2bf44bde4f007c40an;

// rBigEndian is the signed magnitude representation of r, in big endian
Tx.rBigEndian = (0, types_1.b)('1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c');
Tx.rBigEndian = (0, types_1.hex)('1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c');
/**

@@ -675,0 +675,0 @@ * @category Standard Contracts

@@ -6,4 +6,9 @@ import { PubKey as PubKey_, Sig as Sig_, SigHashPreimage as SigHashPreimage_, Ripemd160 as Ripemd160_, PubKeyHash as PubKeyHash_, Sha256 as Sha256_, Sha1 as Sha1_, SigHashType as SigHashType_, OpCodeType as OpCodeType_, PrivKey as PrivKey_ } from "scryptlib";

*/
export declare function b(hexStr: string): string;
export declare function hex(hexStr: string): string;
/**
* Represents a hex literal string.
* @param {string} hexStr - should be in format of hex bytes, i.e. `/^([0-9a-fA-F]{2})*$/`
*/
export declare function u8hex(str: string): string;
/**
* The auto keyword specifies that the type of the variable, of basic type, declared will be automatically deducted from its initializer.

@@ -10,0 +15,0 @@ * @category Types

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrivKey = exports.OpCodeType = exports.SigHashType = exports.Sha1 = exports.Sha256 = exports.PubKeyHash = exports.Ripemd160 = exports.SigHashPreimage = exports.Sig = exports.PubKey = exports.b = void 0;
exports.PrivKey = exports.OpCodeType = exports.SigHashType = exports.Sha1 = exports.Sha256 = exports.PubKeyHash = exports.Ripemd160 = exports.SigHashPreimage = exports.Sig = exports.PubKey = exports.u8hex = exports.hex = void 0;
const scryptlib_1 = require("scryptlib");

@@ -9,3 +9,3 @@ /**

*/
function b(hexStr) {
function hex(hexStr) {
if (hexStr.indexOf(' ') > -1) {

@@ -25,5 +25,14 @@ throw new Error('can\'t contain space');

}
exports.b = b;
exports.hex = hex;
;
/**
* Represents a hex literal string.
* @param {string} hexStr - should be in format of hex bytes, i.e. `/^([0-9a-fA-F]{2})*$/`
*/
function u8hex(str) {
return scryptlib_1.String.toUtf8Hex(str);
}
exports.u8hex = u8hex;
;
/**
* a public key type.

@@ -30,0 +39,0 @@ * @category Types

@@ -42,4 +42,5 @@ /// <reference types="bsv" />

get codePart(): string;
clone(isGenesis?: boolean): this;
markAsGenesis(): void;
clone(): typeof this;
next(): typeof this;
markAsGenesis(): typeof this;
protected updateStateSigHashType(txPreimage: SigHashPreimage, amount: bigint, sigHashType: SigHashType): boolean;

@@ -46,0 +47,0 @@ protected getStateScript(): string;

@@ -143,11 +143,14 @@ "use strict";

}
clone(isGenesis) {
clone() {
let obj = (0, lodash_clonedeep_1.default)(this);
if (typeof isGenesis === 'boolean') {
obj.delegateInstance.isGenesis = isGenesis;
}
return obj;
}
next() {
const obj = (0, lodash_clonedeep_1.default)(this);
obj.delegateInstance.isGenesis = false;
return obj;
}
markAsGenesis() {
this.delegateInstance.isGenesis = true;
return this;
}

@@ -154,0 +157,0 @@ updateStateSigHashType(txPreimage, amount, sigHashType) {

@@ -34,2 +34,3 @@ "use strict";

const os_1 = require("os");
const fs_1 = require("fs");
const DEFAULT_AST_COMPILE_OPTS = Object.freeze({

@@ -185,4 +186,5 @@ ast: true,

});
const tmpDir = (0, fs_1.mkdtempSync)(path.join((0, os_1.tmpdir)(), "scrypt-ts-"));
const astResult = (0, scryptlib_1.compile)({
path: (0, os_1.tmpdir)(),
path: tmpDir,
content: result.getCode()

@@ -570,7 +572,17 @@ }, settings);

let text = e.getText();
if (text.startsWith("'") && text.endsWith("'")) {
toSection.append(`"${text.substring(1, text.length - 1)}"`, srcLoc);
text = text.substring(1, text.length - 1); //remove ' or "
if (e.parent.kind === ts.SyntaxKind.CallExpression) {
let parent = e.parent;
if (parent.expression.getText() === "hex") {
toSection.append(`b'${text}'`, srcLoc);
}
else if (parent.expression.getText() === "u8hex") {
toSection.append(`"${text}"`, srcLoc);
}
else {
throw new TranspileError(`untransfomable StringLiteral: ${node.getText()}`, this.getLocation(node.pos));
}
}
else {
toSection.append(`${text}`, srcLoc);
throw new TranspileError(`untransfomable StringLiteral: ${node.getText()}`, this.getLocation(node.pos));
}

@@ -639,6 +651,15 @@ break;

let isNumberConvert = e.expression.getText() === "BigInt" || e.expression.getText() === "Number";
let isBytesLiteral = e.expression.kind === ts.SyntaxKind.Identifier && e.expression.getText() === 'b';
let isBytesLiteral = e.expression.kind === ts.SyntaxKind.Identifier && (e.expression.getText() === 'hex' || e.expression.getText() === 'u8hex');
let isCheckPreimage = e.expression.kind === ts.SyntaxKind.PropertyAccessExpression && e.expression.name.getText() === 'checkPreimage';
let isCheckPreimageSigHashType = e.expression.kind === ts.SyntaxKind.PropertyAccessExpression && e.expression.name.getText() === 'checkPreimageSigHashType';
const isStillCallExpr = !isSerialize && !isToString && !isBytesLiteral && !isNumberConvert;
if (isBytesLiteral) {
e.arguments.forEach((arg) => {
toSection
.appendWith(this, toSec => {
return this.transformExpression(arg, toSec);
});
});
break;
}
// transform the callee's identifier

@@ -674,5 +695,2 @@ toSection.appendWith(this, toSec => {

}
else if (isBytesLiteral) {
toSection.append("'");
}
else if (isStillCallExpr) {

@@ -691,7 +709,2 @@ toSection.append("(");

}
else if (isBytesLiteral) {
let argTxt = arg.getText();
// remove around single or double quotes
toSection.append(argTxt.slice(1, argTxt.length - 1), this.getCoordinates(arg.pos));
}
else if (!isToString && !isSerialize) {

@@ -715,5 +728,2 @@ toSection.appendWith(this, toSec => {

}
else if (isBytesLiteral) {
toSection.append("'");
}
else if (isStillCallExpr) {

@@ -720,0 +730,0 @@ toSection.append(")");

{
"name": "scrypt-ts",
"version": "0.1.3-alpha.4",
"version": "0.1.3-alpha.5",
"description": "A toolset for building sCrypt smart contract applications on Bitcoin SV network written in typescript.",

@@ -12,3 +12,5 @@ "main": "dist/index.js",

"pretest": "npm run build && npm run clean-test-out && cross-env TS_NODE_PROJECT=test/tsconfig.json NODE_ENV=test tsc -p test",
"test": "mocha 'test/out/**/*.test.js' --timeout 1200000",
"test": "cd test && mocha 'out/test/local/**/*.test.js' --timeout 1200000",
"pretestnet": "cross-env TS_NODE_PROJECT=test/tsconfig.json tsc test/testnet/counter.ts",
"testnet": "cd test && node out/test/testnet/counter.js",
"single-test": "npm run build && npm run clean-test-out && cross-env TS_NODE_PROJECT=test/tsconfig.json NODE_ENV=test mocha -r ts-node/register"

@@ -29,2 +31,4 @@ },

"@types/mocha": "^10.0.0",
"@types/node": "^18.11.10",
"axios": "=1.1.3",
"chai": "^4.3.6",

@@ -37,7 +41,5 @@ "cross-env": "^7.0.3",

"typedoc": "^0.23.21",
"typedoc-plugin-markdown": "^3.13.6",
"axios": "=1.1.3"
"typedoc-plugin-markdown": "^3.13.6"
},
"dependencies": {
"@types/node": "^18.8.3",
"@phenomnomnominal/tsquery": "^5.0.0",

@@ -44,0 +46,0 @@ "lodash.clonedeep": "^4.5.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