scrypt-ts
Advanced tools
Comparing version 0.1.6-test.9 to 0.1.6-test.10
@@ -53,2 +53,5 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -58,3 +61,3 @@ exports.WhatsonchainProvider = void 0; | ||
var abstract_provider_1 = require("../abstract-provider"); | ||
var superagent = require('superagent'); | ||
var axios_1 = __importDefault(require("axios")); | ||
var WhatsonchainProvider = /** @class */ (function (_super) { | ||
@@ -102,9 +105,3 @@ __extends(WhatsonchainProvider, _super); | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, superagent.post("".concat(this.apiPrefix, "/tx/raw")) | ||
.timeout({ | ||
response: timeout, | ||
deadline: 60000, // but allow 1 minute for the file to finish loading. | ||
}) | ||
.set('Content-Type', 'application/json') | ||
.send({ txhex: rawTxHex })]; | ||
return [4 /*yield*/, axios_1.default.post("".concat(this.apiPrefix, "/tx/raw"), { txhex: rawTxHex }, { timeout: timeout })]; | ||
case 2: | ||
@@ -132,3 +129,3 @@ res = _a.sent(); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, superagent.get("".concat(this.apiPrefix, "/address/").concat(address, "/unspent"))]; | ||
case 0: return [4 /*yield*/, axios_1.default.get("".concat(this.apiPrefix, "/address/").concat(address, "/unspent"))]; | ||
case 1: | ||
@@ -135,0 +132,0 @@ data = (_a.sent()).data; |
@@ -17,2 +17,3 @@ import { Signer, SignatureRequest, SignatureResponse, SignTransactionOptions } from "../abstract-signer"; | ||
get addresses(): string[]; | ||
pushPrivateKey(privateKey: bsv.PrivateKey | bsv.PrivateKey[]): void; | ||
getDefaultAddress(): Promise<bsv.Address>; | ||
@@ -19,0 +20,0 @@ getDefaultPubKey(): Promise<bsv.PublicKey>; |
@@ -92,2 +92,7 @@ "use strict"; | ||
}); | ||
TestWallet.prototype.pushPrivateKey = function (privateKey) { | ||
var _a; | ||
var keys = privateKey instanceof Array ? privateKey : [privateKey]; | ||
(_a = this._privateKeys).push.apply(_a, keys); | ||
}; | ||
TestWallet.prototype.getDefaultAddress = function () { | ||
@@ -94,0 +99,0 @@ return Promise.resolve(this._defaultPrivateKey.toAddress()); |
import { prop, method } from './smart-contract/decorators'; | ||
import { SmartContract, TxOutputRef, TxInputRef, MergedArtifact } from './smart-contract/contract'; | ||
import { SmartContract, TxOutputRef, TxInputRef } from './smart-contract/contract'; | ||
import { SmartContractLib } from './smart-contract/library'; | ||
@@ -8,3 +8,3 @@ export * from './smart-contract/builtins/types'; | ||
export * from './transformation/utils'; | ||
export { prop, method, SmartContract, SmartContractLib, TxOutputRef, TxInputRef, MergedArtifact }; | ||
export { prop, method, SmartContract, SmartContractLib, TxOutputRef, TxInputRef }; | ||
export { bsv, toHex, buildPublicKeyHashScript, buildOpreturnScript, ContractArtifact, TxContext, VerifyResult, FunctionCall } from 'scryptlib'; | ||
@@ -11,0 +11,0 @@ export * from './bsv/types'; |
@@ -6,20 +6,16 @@ import { SigHashType, Ripemd160, Sha256, Sha1 } from "scryptlib"; | ||
/** | ||
* bigint can be converted to string with pack | ||
* bigint can be converted to string with int2ByteString. | ||
* If `size` is not passed, the number `n` is converted to a ByteString with as few bytes as possible. | ||
* Otherwise, converts the number `n` to a ByteString of the specified size, including the sign bit. Fails if the number cannot be accommodated. | ||
* @param n - a number being converts | ||
* @param size - the size of the ByteString | ||
* @category Bytes Operations | ||
*/ | ||
export declare function pack(n: bigint): ByteString; | ||
export declare function int2ByteString(n: bigint, size?: bigint): ByteString; | ||
/** | ||
* ByteString can be converted to bigint using function unpack. | ||
* ByteString can be converted to bigint using function byteString2Int. | ||
* @category Bytes Operations | ||
*/ | ||
export declare function unpack(a: ByteString): bigint; | ||
export declare function byteString2Int(a: ByteString): bigint; | ||
/** | ||
* Converts a number num into a ByteString of certain size, including the sign bit. It fails if the number cannot be accommodated. | ||
* @category Bytes Operations | ||
* @param num - a number being converts | ||
* @param size - the size of the ByteString | ||
* @returns {ByteString} A ByteString . | ||
*/ | ||
export declare function int2str(num: bigint, size: bigint): ByteString; | ||
/** | ||
* Returns the length of the ByteString. Not the length of the string. | ||
@@ -32,9 +28,10 @@ * @category Bytes Operations | ||
/** | ||
* Returns reversed bytes of b, which is of size bytes. Note size must be a compile time constant. It is often useful when converting a number between little-endian and big-endian. | ||
* Returns reversed bytes of b, which is of size bytes. Note size must be a compiled-time constant. | ||
* It is often useful when converting a number between little-endian and big-endian. | ||
* @category Bytes Operations | ||
* @param b - a ByteString to be reversed | ||
* @param size - the size of the ByteString. | ||
* @returns {ByteString} The length of the reverse ByteString. | ||
* @returns {ByteString} reversed ByteString. | ||
*/ | ||
export declare function reverseBytes(b: ByteString, size: number): ByteString; | ||
export declare function reverseByteString(b: ByteString, size: number): ByteString; | ||
/** | ||
@@ -41,0 +38,0 @@ * Compares the first signature against each public key until it finds an ECDSA match. Starting with the subsequent public key, it compares the second signature against each remaining public key until it finds an ECDSA match. The process is repeated until all signatures have been checked or not enough public keys remain to produce a successful result. All signatures need to match a public key. Because public keys are not checked again if they fail any signature comparison, signatures must be placed in the scriptSig using the same order as their corresponding public keys were placed in the scriptPubKey or redeemScript. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack. |
"use strict"; | ||
// build-in function | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Constants = exports.Tx = exports.VarIntWriter = exports.VarIntReader = exports.SigHash = exports.Utils = exports.OpCode = exports.asm = exports.rshift = exports.lshift = exports.pow2 = exports.assert = exports.hash256 = exports.hash160 = exports.sha256 = exports.sha1 = exports.ripemd160 = exports.within = exports.max = exports.min = exports.abs = exports.exit = exports.checkMultiSig = exports.reverseBytes = exports.len = exports.int2str = exports.unpack = exports.pack = exports.getSortedItem = exports.invert = exports.or = exports.xor = exports.and = void 0; | ||
exports.Constants = exports.Tx = exports.VarIntWriter = exports.VarIntReader = exports.SigHash = exports.Utils = exports.OpCode = exports.asm = exports.rshift = exports.lshift = exports.pow2 = exports.assert = exports.hash256 = exports.hash160 = exports.sha256 = exports.sha1 = exports.ripemd160 = exports.within = exports.max = exports.min = exports.abs = exports.exit = exports.checkMultiSig = exports.reverseByteString = exports.len = exports.byteString2Int = exports.int2ByteString = exports.getSortedItem = exports.invert = exports.or = exports.xor = exports.and = void 0; | ||
var scryptlib_1 = require("scryptlib"); | ||
@@ -15,31 +15,26 @@ var types_1 = require("./types"); | ||
/** | ||
* bigint can be converted to string with pack | ||
* bigint can be converted to string with int2ByteString. | ||
* If `size` is not passed, the number `n` is converted to a ByteString with as few bytes as possible. | ||
* Otherwise, converts the number `n` to a ByteString of the specified size, including the sign bit. Fails if the number cannot be accommodated. | ||
* @param n - a number being converts | ||
* @param size - the size of the ByteString | ||
* @category Bytes Operations | ||
*/ | ||
function pack(n) { | ||
var num = new scryptlib_1.bsv.crypto.BN(n); | ||
return num.toSM({ endian: 'little' }).toString('hex'); | ||
function int2ByteString(n, size) { | ||
if (size === undefined) { | ||
var num = new scryptlib_1.bsv.crypto.BN(n); | ||
return num.toSM({ endian: 'little' }).toString('hex'); | ||
} | ||
return (0, scryptlib_1.num2bin)(n, Number(size)); | ||
} | ||
exports.pack = pack; | ||
exports.int2ByteString = int2ByteString; | ||
/** | ||
* ByteString can be converted to bigint using function unpack. | ||
* ByteString can be converted to bigint using function byteString2Int. | ||
* @category Bytes Operations | ||
*/ | ||
function unpack(a) { | ||
function byteString2Int(a) { | ||
return BigInt((0, scryptlib_1.bin2num)(a)); | ||
} | ||
exports.unpack = unpack; | ||
; | ||
exports.byteString2Int = byteString2Int; | ||
/** | ||
* Converts a number num into a ByteString of certain size, including the sign bit. It fails if the number cannot be accommodated. | ||
* @category Bytes Operations | ||
* @param num - a number being converts | ||
* @param size - the size of the ByteString | ||
* @returns {ByteString} A ByteString . | ||
*/ | ||
function int2str(num, size) { | ||
return (0, scryptlib_1.num2bin)(num, Number(size)); | ||
} | ||
exports.int2str = int2str; | ||
/** | ||
* Returns the length of the ByteString. Not the length of the string. | ||
@@ -53,17 +48,17 @@ * @category Bytes Operations | ||
/** | ||
* Returns reversed bytes of b, which is of size bytes. Note size must be a compile time constant. It is often useful when converting a number between little-endian and big-endian. | ||
* Returns reversed bytes of b, which is of size bytes. Note size must be a compiled-time constant. | ||
* It is often useful when converting a number between little-endian and big-endian. | ||
* @category Bytes Operations | ||
* @param b - a ByteString to be reversed | ||
* @param size - the size of the ByteString. | ||
* @returns {ByteString} The length of the reverse ByteString. | ||
* @returns {ByteString} reversed ByteString. | ||
*/ | ||
function reverseBytes(b, size) { | ||
function reverseByteString(b, size) { | ||
var l = len(b); | ||
if (l != size) { | ||
throw new Error("reverseBytes error, expected c = ".concat(l)); | ||
throw new Error("reverseByteString error, expected c = ".concat(l)); | ||
} | ||
return b.match(/[a-fA-F0-9]{2}/g).reverse().join(''); | ||
} | ||
exports.reverseBytes = reverseBytes; | ||
; | ||
exports.reverseByteString = reverseByteString; | ||
/** | ||
@@ -393,3 +388,3 @@ * Compares the first signature against each public key until it finds an ECDSA match. Starting with the subsequent public key, it compares the second signature against each remaining public key until it finds an ECDSA match. The process is repeated until all signatures have been checked or not enough public keys remain to produce a successful result. All signatures need to match a public key. Because public keys are not checked again if they fail any signature comparison, signatures must be placed in the scriptSig using the same order as their corresponding public keys were placed in the scriptPubKey or redeemScript. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack. | ||
Utils.toLEUnsigned = function (n, l) { | ||
var m = int2str(n, l + (0, scryptlib_1.Int)(1)); | ||
var m = int2ByteString(n, l + (0, scryptlib_1.Int)(1)); | ||
// remove sign byte | ||
@@ -400,3 +395,3 @@ return m.slice(0, len(m) * 2 - 2); | ||
Utils.fromLEUnsigned = function (bytes) { | ||
return unpack(bytes + (0, types_1.toByteString)('00')); | ||
return byteString2Int(bytes + (0, types_1.toByteString)('00')); | ||
}; | ||
@@ -450,7 +445,7 @@ /* | ||
Utils.buildOutput = function (outputScript, outputSatoshis) { | ||
return int2str(outputSatoshis, Constants.OutputValueLen) + Utils.writeVarint(outputScript); | ||
return int2ByteString(outputSatoshis, Constants.OutputValueLen) + Utils.writeVarint(outputScript); | ||
}; | ||
// build P2PKH script from PubKeyHash | ||
Utils.buildPublicKeyHashScript = function (pubKeyHash) { | ||
return (0, types_1.toByteString)(OpCode.OP_DUP) + (0, types_1.toByteString)(OpCode.OP_HASH160) + pack(Constants.PubKeyHashLen /* "OP_PUSHDATA0" */) | ||
return (0, types_1.toByteString)(OpCode.OP_DUP) + (0, types_1.toByteString)(OpCode.OP_HASH160) + int2ByteString(Constants.PubKeyHashLen /* "OP_PUSHDATA0" */) | ||
+ pubKeyHash + (0, types_1.toByteString)(OpCode.OP_EQUALVERIFY) + (0, types_1.toByteString)(OpCode.OP_CHECKSIG); | ||
@@ -552,3 +547,3 @@ }; | ||
var ret = (0, types_1.toByteString)(''); | ||
var header = unpack(buf.slice(Number(this.pos * (0, scryptlib_1.Int)(2)), Number((this.pos + (0, scryptlib_1.Int)(1)) * (0, scryptlib_1.Int)(2)))); | ||
var header = byteString2Int(buf.slice(Number(this.pos * (0, scryptlib_1.Int)(2)), Number((this.pos + (0, scryptlib_1.Int)(1)) * (0, scryptlib_1.Int)(2)))); | ||
this.pos++; | ||
@@ -587,3 +582,3 @@ if (header < (0, scryptlib_1.Int)(0x4c)) { | ||
VarIntReader.prototype.readInt = function () { | ||
return unpack(this.readBytes()); | ||
return byteString2Int(this.readBytes()); | ||
}; | ||
@@ -597,3 +592,3 @@ VarIntReader.getStateStart = function (scriptCode) { | ||
var lb = scriptCode.slice(Number(start * (0, scryptlib_1.Int)(2)), Number(end * (0, scryptlib_1.Int)(2))); | ||
var stateLen = unpack(lb); | ||
var stateLen = byteString2Int(lb); | ||
// TODO: check version is as expected | ||
@@ -645,8 +640,8 @@ return scriptLen - stateLen - VarIntReader.StateLen - VarIntReader.VersionLen; | ||
VarIntWriter.writeInt = function (x) { | ||
return VarIntWriter.writeBytes(x == (0, scryptlib_1.Int)(0) ? (0, types_1.toByteString)('00') : pack(x)); | ||
return VarIntWriter.writeBytes(x == (0, scryptlib_1.Int)(0) ? (0, types_1.toByteString)('00') : int2ByteString(x)); | ||
}; | ||
VarIntWriter.serializeState = function (stateBuf) { | ||
// locking script: code + opreturn + data(state + state_len + version) | ||
var lenBuf = int2str(BigInt(len(stateBuf)), VarIntReader.StateLen); | ||
return stateBuf + lenBuf + int2str(VarIntReader.Version, VarIntReader.VersionLen); | ||
var lenBuf = int2ByteString(BigInt(len(stateBuf)), VarIntReader.StateLen); | ||
return stateBuf + lenBuf + int2ByteString(VarIntReader.Version, VarIntReader.VersionLen); | ||
}; | ||
@@ -683,9 +678,9 @@ return VarIntWriter; | ||
var rlen = BigInt(len(rBigEndian)); | ||
var slen = len(pack(s)); | ||
// we convert s to 32 bytes, otherwise reverseBytes(, 32) fails when s is strictly less than 31 bytes (note: 31 bytes works) | ||
var slen = len(int2ByteString(s)); | ||
// we convert s to 32 bytes, otherwise reverseByteString(, 32) fails when s is strictly less than 31 bytes (note: 31 bytes works) | ||
// slice it after reversing to remove extra leading zeros, otherwise strict DER rule fails it due to not minimally encoded | ||
var sBigEndian = reverseBytes(int2str(s, (0, scryptlib_1.Int)(32)), 32).slice(32 * 2 - slen * 2); | ||
var sBigEndian = reverseByteString(int2ByteString(s, (0, scryptlib_1.Int)(32)), 32).slice(32 * 2 - slen * 2); | ||
var l = (0, scryptlib_1.Int)(4) + rlen + BigInt(slen); | ||
// rBigEndian must be mininally encoded, to conform to strict DER rule | ||
var rb = (0, types_1.toByteString)('30') + pack(l) + (0, types_1.toByteString)('02') + pack(rlen) + rBigEndian + (0, types_1.toByteString)('02') + pack(BigInt(slen)) + sBigEndian + (0, types_1.toByteString)(sigHashType); | ||
var rb = (0, types_1.toByteString)('30') + int2ByteString(l) + (0, types_1.toByteString)('02') + int2ByteString(rlen) + rBigEndian + (0, types_1.toByteString)('02') + int2ByteString(BigInt(slen)) + sBigEndian + (0, types_1.toByteString)(sigHashType); | ||
return (0, types_1.Sig)(rb); | ||
@@ -696,3 +691,3 @@ }; | ||
// append positive sign byte. This does not hurt even when sign bit is already positive | ||
return unpack(reverseBytes(bytes, 32) + (0, types_1.toByteString)('00')); | ||
return byteString2Int(reverseByteString(bytes, 32) + (0, types_1.toByteString)('00')); | ||
}; | ||
@@ -699,0 +694,0 @@ // optimal pushtx |
@@ -1,3 +0,3 @@ | ||
import { Bytes, SigHashPreimage, AbstractContract, Int } from "scryptlib"; | ||
import { SubBytes, SupportedParamType } from "scryptlib/dist/scryptTypes"; | ||
import { Bytes, AbstractContract, Int } from "scryptlib"; | ||
import { SupportedParamType } from "scryptlib/dist/scryptTypes"; | ||
export { PubKey, Sig, SigHashPreimage, PrivKey, Ripemd160, PubKeyHash, Sha256, Sha1, OpCodeType, SigHashType } from "scryptlib"; | ||
@@ -15,12 +15,10 @@ export { SubBytes } from "scryptlib/dist/scryptTypes"; | ||
/** | ||
* Converts a hex literal to string. | ||
* @param {string} hexStr - should be in format of hex literal, i.e. `/^([0-9a-fA-F]{2})*$/` | ||
* Converts a literal to ByteString. | ||
* If not passing `isUtf8`, then `str` should be in the format of hex literal, i.e. `/^([0-9a-fA-F]{2})*$/` | ||
* Otherwise, `str` should be in the format of utf8 literal, i.e. `hello world` | ||
* @param {string} str literal string, can be hex literal or utf8 literal, depends on isUtf8 marker | ||
* @param {boolean} isUtf8 marker indicating whether `str` is utf8 or hex | ||
*/ | ||
export declare function toByteString<T extends string>(str: HexType<T> | SubBytes | SigHashPreimage): ByteString; | ||
export declare function toByteString<T extends string>(str: HexType<T> | string, isUtf8?: true): ByteString; | ||
/** | ||
* Converts a utf8 literal to string. | ||
* @param {string} hexStr - should be in format of utf8 literal, i.e. `hello world` | ||
*/ | ||
export declare function utf8ToByteString(str: string): ByteString; | ||
/** | ||
* The auto keyword specifies that the type of the variable, of basic type, declared will be automatically deducted from its initializer. | ||
@@ -27,0 +25,0 @@ * @category Types |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HashedSet = exports.HashedMap = exports.equals = exports.utf8ToByteString = exports.toByteString = exports.SigHashType = exports.OpCodeType = exports.Sha1 = exports.Sha256 = exports.PubKeyHash = exports.Ripemd160 = exports.PrivKey = exports.SigHashPreimage = exports.Sig = exports.PubKey = void 0; | ||
exports.HashedSet = exports.HashedMap = exports.equals = exports.toByteString = exports.SigHashType = exports.OpCodeType = exports.Sha1 = exports.Sha256 = exports.PubKeyHash = exports.Ripemd160 = exports.PrivKey = exports.SigHashPreimage = exports.Sig = exports.PubKey = void 0; | ||
var scryptlib_1 = require("scryptlib"); | ||
@@ -18,19 +18,15 @@ var functions_1 = require("./functions"); | ||
/** | ||
* Converts a hex literal to string. | ||
* @param {string} hexStr - should be in format of hex literal, i.e. `/^([0-9a-fA-F]{2})*$/` | ||
* Converts a literal to ByteString. | ||
* If not passing `isUtf8`, then `str` should be in the format of hex literal, i.e. `/^([0-9a-fA-F]{2})*$/` | ||
* Otherwise, `str` should be in the format of utf8 literal, i.e. `hello world` | ||
* @param {string} str literal string, can be hex literal or utf8 literal, depends on isUtf8 marker | ||
* @param {boolean} isUtf8 marker indicating whether `str` is utf8 or hex | ||
*/ | ||
function toByteString(str) { | ||
function toByteString(str, isUtf8) { | ||
if (isUtf8) { | ||
return (0, scryptlib_1.stringToBytes)(str); | ||
} | ||
return (0, scryptlib_1.Bytes)(str); | ||
} | ||
exports.toByteString = toByteString; | ||
; | ||
/** | ||
* Converts a utf8 literal to string. | ||
* @param {string} hexStr - should be in format of utf8 literal, i.e. `hello world` | ||
*/ | ||
function utf8ToByteString(str) { | ||
return (0, scryptlib_1.stringToBytes)(str); | ||
} | ||
exports.utf8ToByteString = utf8ToByteString; | ||
; | ||
function equalsArray(a, b) { | ||
@@ -101,4 +97,5 @@ if (Array.isArray(a[0])) { | ||
// Note: low & high are both 256 bits, so they can not be converted to the same number unless they are the same. | ||
// Not working if their size are not equal due to non-minimal number format, ex. unpack('7180') == unpack('710080') | ||
return (0, functions_1.unpack)(low) < (0, functions_1.unpack)(high); | ||
// Not working if their size are not equal due to non-minimal number format, | ||
// ex. byteString2Int('7180') == byteString2Int('710080') | ||
return (0, functions_1.byteString2Int)(low) < (0, functions_1.byteString2Int)(high); | ||
}; | ||
@@ -242,4 +239,5 @@ // insert / update (`key`, `val`) at `idx`, return false if `idx` is invalid or hash256ed' `key` is not in ascending order | ||
// Note: low & high are both 256 bits, so they can not be converted to the same number unless they are the same. | ||
// Not working if their size are not equal due to non-minimal number format, ex. unpack('7180') == unpack('710080') | ||
return (0, functions_1.unpack)(low) < (0, functions_1.unpack)(high); | ||
// Not working if their size are not equal due to non-minimal number format, | ||
// ex. byteString2Int('7180') == byteString2Int('710080') | ||
return (0, functions_1.byteString2Int)(low) < (0, functions_1.byteString2Int)(high); | ||
}; | ||
@@ -246,0 +244,0 @@ // add / update element `elem` at `idx`, return false if `idx` is invalid or hash256ed' `elem` is not in ascending order |
@@ -78,10 +78,2 @@ import "reflect-metadata"; | ||
/** | ||
* ContractArtifact is the compiler output results in a JSON. It’s a representation used to build locking and unlocking scripts. | ||
* We call this file a contract artifact file. A merged contract artifact is a contract artifact that incorporates transform information. | ||
* Usually produced by the [scrypt-cli]{@link https://github.com/sCrypt-Inc/scrypt-cli} compile command. | ||
*/ | ||
export declare type MergedArtifact = ContractArtifact & { | ||
transformer: TransformInfo; | ||
}; | ||
/** | ||
* The main contract class. To write a contract, extend this class as such: | ||
@@ -112,6 +104,7 @@ * @example | ||
* This function is usually called on the frontend. | ||
* The contract class needs to call this function before instantiating. | ||
* @param artifact a merged contract artifact object | ||
* The contract class needs to call this function to initialize before instantiating. | ||
* @param transform a object that contains transform infos | ||
* @param artifact a contract artifact object | ||
*/ | ||
static init(artifact: MergedArtifact): void; | ||
static init(transform: TransformInfo, artifact: ContractArtifact): void; | ||
private static _getTransform; | ||
@@ -118,0 +111,0 @@ private static _getScryptFile; |
@@ -194,13 +194,9 @@ "use strict"; | ||
* This function is usually called on the frontend. | ||
* The contract class needs to call this function before instantiating. | ||
* @param artifact a merged contract artifact object | ||
* The contract class needs to call this function to initialize before instantiating. | ||
* @param transform a object that contains transform infos | ||
* @param artifact a contract artifact object | ||
*/ | ||
SmartContract.init = function (artifact) { | ||
if (typeof artifact.transformer === 'object') { | ||
this.transformInfo = artifact.transformer; | ||
this.DelegateClazz = (0, scryptlib_1.buildContractClass)(artifact); | ||
} | ||
else { | ||
throw new Error('artifact is not merged!'); | ||
} | ||
SmartContract.init = function (transform, artifact) { | ||
this.transformInfo = transform; | ||
this.DelegateClazz = (0, scryptlib_1.buildContractClass)(artifact); | ||
}; | ||
@@ -207,0 +203,0 @@ SmartContract._getTransform = function () { |
@@ -77,2 +77,4 @@ import * as ts from 'typescript'; | ||
private isAssertStatement; | ||
private isConsoleLogStatement; | ||
private verifyLastAssertStatement; | ||
private hasAccessCtx; | ||
@@ -79,0 +81,0 @@ private hasAccessStateProperty; |
{ | ||
"name": "scrypt-ts", | ||
"version": "0.1.6-test.9", | ||
"version": "0.1.6-test.10", | ||
"description": "A toolset for building sCrypt smart contract applications on Bitcoin SV network written in typescript.", | ||
@@ -38,4 +38,4 @@ "main": "dist/index.js", | ||
"chai": "^4.3.6", | ||
"chai-exclude": "^2.1.0", | ||
"chai-as-promised": "^7.1.1", | ||
"chai-exclude": "^2.1.0", | ||
"cross-env": "^7.0.3", | ||
@@ -48,2 +48,3 @@ "dotenv": "^16.0.3", | ||
"ts-node": "^10.9.1", | ||
"tsconfig-paths": "^4.1.0", | ||
"typedoc": "^0.23.21", | ||
@@ -54,8 +55,8 @@ "typedoc-plugin-markdown": "^3.13.6" | ||
"@phenomnomnominal/tsquery": "^5.0.0", | ||
"fast-diff": "^1.2.0", | ||
"clone": "^2.1.2", | ||
"fast-diff": "^1.2.0", | ||
"axios": "=1.1.3", | ||
"reflect-metadata": "^0.1.13", | ||
"scryptlib": "^2.1.2", | ||
"scryptlib": "=2.1.1", | ||
"sourcemap-codec": "^1.4.8", | ||
"superagent": "^8.0.9", | ||
"ts-patch": "^2.0.2", | ||
@@ -62,0 +63,0 @@ "typescript": "=4.8.4" |
Sorry, the diff of this file is too big to display
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
343869
20
39
7020
+ Addedaxios@=1.1.3
- Removedsuperagent@^8.0.9
- Removed@discoveryjs/json-ext@0.5.7(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@scrypt-inc/bsv@1.0.4(transitive)
- Removedaes-js@3.1.2(transitive)
- Removedagent-base@7.1.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedasap@2.0.6(transitive)
- Removedassert@2.1.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbignumber.js@9.1.2(transitive)
- Removedbraces@3.0.3(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcliui@8.0.1(transitive)
- Removedclone-deep@4.0.1(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedconfig-chain@1.1.13(transitive)
- Removedcookiejar@2.1.4(transitive)
- Removeddata-uri-to-buffer@4.0.1(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddetect-file@1.0.0(transitive)
- Removeddezalgo@1.0.4(transitive)
- Removedelliptic@6.5.4(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedescalade@3.2.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexpand-tilde@2.0.2(transitive)
- Removedfast-safe-stringify@2.1.1(transitive)
- Removedfetch-blob@3.2.0(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfind-node-modules@2.1.3(transitive)
- Removedfindup-sync@4.0.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedform-data@4.0.1(transitive)
- Removedformdata-polyfill@4.0.10(transitive)
- Removedformidable@2.1.2(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedget-proxy-settings@0.1.13(transitive)
- Removedglobal-modules@1.0.0(transitive)
- Removedglobal-prefix@1.0.2(transitive)
- Removedgopd@1.1.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhexoid@1.0.0(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedhttps-proxy-agent@7.0.5(transitive)
- Removedieee754@1.2.1(transitive)
- Removedinherits@2.0.3(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-nan@1.3.2(transitive)
- Removedis-number@7.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisobject@3.0.1(transitive)
- Removedjson-bigint@1.0.0(transitive)
- Removedmerge@2.1.1(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedmime@2.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedms@2.1.3(transitive)
- Removednode-domexception@1.0.0(transitive)
- Removednode-fetch@3.3.2(transitive)
- Removednpm-conf@1.1.3(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedparse-passwd@1.0.0(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedpify@3.0.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedproto-list@1.2.4(transitive)
- Removedqs@6.13.1(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedresolve-dir@1.0.1(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedscryptlib@2.2.4(transitive)
- Removedsemver@7.6.3(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedshallow-clone@3.0.1(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedsuperagent@8.1.2(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedunorm@1.4.1(transitive)
- Removedutil@0.12.5(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)
- Removedwhich-typed-array@1.1.16(transitive)
- Removedwrap-ansi@7.0.0(transitive)
- Removedy18n@5.0.8(transitive)
- Removedyargs@17.7.2(transitive)
- Removedyargs-parser@21.1.1(transitive)
Updatedscryptlib@=2.1.1