scrypt-ts
Advanced tools
Comparing version 1.3.9-test.2 to 1.3.9
# CHANGELOG | ||
## 1.3.9 | ||
- support attaching a NOP script (like 1sat ordinal) to a contract instance. | ||
**example:** | ||
```ts | ||
const demo = new Demo(1n, 2n) | ||
// connect to a signer | ||
await demo.connect(getDefaultSigner()) | ||
const nopScript = bsv.Script.fromASM("OP_FALSE OP_IF ... OP_ENDIF"); | ||
demo.setNOPScript(nopScript) | ||
// contract deployment | ||
const deployTx = await demo.deploy(1) | ||
console.log('Demo contract deployed: ', deployTx.id) | ||
// create instance from transaction | ||
let currentInstance = Demo.fromTx(deployTx, 0, {}, nopScript); | ||
``` | ||
- add build-ins function `this.timeLock()`, see https://docs.scrypt.io/tutorials/timeLock | ||
**example:** | ||
```ts | ||
assert(this.timeLock(this.locktime0), 'time lock for locktime0 failed') | ||
``` | ||
## 1.3.8 | ||
@@ -4,0 +39,0 @@ |
@@ -946,15 +946,28 @@ import { SigHashType, Ripemd160, Sha256, Sha1 } from "scryptlib"; | ||
/** | ||
* build P2PKH script from PubKeyHash | ||
* @param {PubKeyHash} pubKeyHash recipient's pubKeyHash | ||
* @returns {ByteString} a `ByteString` that represents P2PKH script | ||
* constructs a P2PKH script from a given PubKeyHash | ||
* @param {PubKeyHash} pubKeyHash - the recipient's public key hash | ||
* @returns {ByteString} a `ByteString` representing the P2PKH script | ||
*/ | ||
static buildPublicKeyHashScript(pubKeyHash: PubKeyHash): ByteString; | ||
/** | ||
* build P2PKH output from PubKeyHash | ||
* @param pubKeyHash the address to receive change coin | ||
* @param amount satoshi amount | ||
* @returns a P2PKH output | ||
* constructs a P2PKH output from a given PubKeyHash and satoshi amount | ||
* @param {PubKeyHash} pubKeyHash - the recipient's public key hash | ||
* @param {bigint} amount - the satoshi amount | ||
* @returns {ByteString} a `ByteString` representing the P2PKH output | ||
*/ | ||
static buildPublicKeyHashOutput(pubKeyHash: PubKeyHash, amount: bigint): ByteString; | ||
/** | ||
* constructs a standard payment (P2PKH) script from a given address | ||
* @param {Addr} addr - the recipient's address | ||
* @returns {ByteString} a `ByteString` representing the P2PKH script | ||
*/ | ||
static buildAddressScript(addr: Addr): ByteString; | ||
/** | ||
* constructs a standard payment (P2PKH) output from a given address and satoshi amount | ||
* @param {Addr} addr - the recipient's address | ||
* @param {bigint} amount - the satoshi amount | ||
* @returns {ByteString} a `ByteString` representing the P2PKH output | ||
*/ | ||
static buildAddressOutput(addr: Addr, amount: bigint): ByteString; | ||
/** | ||
* build `OP_FALSE OP_RETURN` script from data payload | ||
@@ -961,0 +974,0 @@ * @param {ByteString} data the data payload |
@@ -1102,5 +1102,5 @@ "use strict"; | ||
/** | ||
* build P2PKH script from PubKeyHash | ||
* @param {PubKeyHash} pubKeyHash recipient's pubKeyHash | ||
* @returns {ByteString} a `ByteString` that represents P2PKH script | ||
* constructs a P2PKH script from a given PubKeyHash | ||
* @param {PubKeyHash} pubKeyHash - the recipient's public key hash | ||
* @returns {ByteString} a `ByteString` representing the P2PKH script | ||
*/ | ||
@@ -1112,6 +1112,6 @@ static buildPublicKeyHashScript(pubKeyHash) { | ||
/** | ||
* build P2PKH output from PubKeyHash | ||
* @param pubKeyHash the address to receive change coin | ||
* @param amount satoshi amount | ||
* @returns a P2PKH output | ||
* constructs a P2PKH output from a given PubKeyHash and satoshi amount | ||
* @param {PubKeyHash} pubKeyHash - the recipient's public key hash | ||
* @param {bigint} amount - the satoshi amount | ||
* @returns {ByteString} a `ByteString` representing the P2PKH output | ||
*/ | ||
@@ -1122,2 +1122,19 @@ static buildPublicKeyHashOutput(pubKeyHash, amount) { | ||
/** | ||
* constructs a standard payment (P2PKH) script from a given address | ||
* @param {Addr} addr - the recipient's address | ||
* @returns {ByteString} a `ByteString` representing the P2PKH script | ||
*/ | ||
static buildAddressScript(addr) { | ||
return Utils.buildPublicKeyHashScript(addr); | ||
} | ||
/** | ||
* constructs a standard payment (P2PKH) output from a given address and satoshi amount | ||
* @param {Addr} addr - the recipient's address | ||
* @param {bigint} amount - the satoshi amount | ||
* @returns {ByteString} a `ByteString` representing the P2PKH output | ||
*/ | ||
static buildAddressOutput(addr, amount) { | ||
return Utils.buildPublicKeyHashOutput(addr, amount); | ||
} | ||
/** | ||
* build `OP_FALSE OP_RETURN` script from data payload | ||
@@ -1124,0 +1141,0 @@ * @param {ByteString} data the data payload |
@@ -151,2 +151,8 @@ import "reflect-metadata"; | ||
private _initDelegateInstance; | ||
/** | ||
* Only inherited classes can call this function. | ||
* Direct subclasses of `SmartContract` do not need to call this function. | ||
* @param args constructor parameters of inherited classes | ||
* @onchain | ||
*/ | ||
setConstructor(...args: any[]): void; | ||
@@ -291,2 +297,17 @@ /** | ||
/** | ||
* Implements a time-based lock on a transaction until a specified `locktime` has been reached. | ||
* The lock can be based on either block height or a UNIX timestamp. | ||
* | ||
* If the `locktime` is below 500,000,000, it's interpreted as a block height. Otherwise, | ||
* it's interpreted as a UNIX timestamp. This function checks and ensures that the transaction's | ||
* nSequence is less than `UINT_MAX`, and that the provided `locktime` has been reached or passed. | ||
* | ||
* @param {bigint} locktime - The block height or timestamp until which the transaction should be locked. | ||
* @returns If `true` is returned, nlockTime and sequence in `this.ctx` are valid, otherwise they are invalid. | ||
* @onchain | ||
* @category Time Lock | ||
* @see https://docs.scrypt.io/tutorials/timeLock | ||
*/ | ||
timeLock(locktime: bigint): boolean; | ||
/** | ||
* Get the amount of the change output for `to.tx`. | ||
@@ -494,3 +515,3 @@ * @onchain | ||
*/ | ||
static fromLockingScript(script: string, offchainValues?: Record<string, any>): SmartContract; | ||
static fromLockingScript(script: string, offchainValues?: Record<string, any>, nopScript?: bsv.Script): SmartContract; | ||
/** | ||
@@ -504,3 +525,3 @@ * recover a `SmartContract` instance from the transaction | ||
*/ | ||
static fromTx<T extends SmartContract>(this: new (...args: any[]) => T, tx: bsv.Transaction, atOutputIndex: number, offchainValues?: Record<string, any>): T; | ||
static fromTx<T extends SmartContract>(this: new (...args: any[]) => T, tx: bsv.Transaction, atOutputIndex: number, offchainValues?: Record<string, any>, nopScript?: bsv.Script): T; | ||
/** @ignore */ | ||
@@ -526,6 +547,5 @@ private static dummySignMultiCallTx; | ||
private static autoPayfee; | ||
setNOPScript(nopScript: bsv.Script | null): void; | ||
private static getNOPScript; | ||
getNOPScript(): bsv.Script | null; | ||
prependNOPScript(nopScript: bsv.Script | null): void; | ||
getPrependNOPScript(): bsv.Script | null; | ||
} | ||
export {}; |
{ | ||
"name": "scrypt-ts", | ||
"version": "1.3.9-test.2", | ||
"version": "1.3.9", | ||
"description": "A toolset for building sCrypt smart contract applications on Bitcoin SV network written in typescript.", | ||
@@ -60,3 +60,3 @@ "main": "dist/index.js", | ||
"reflect-metadata": "^0.1.13", | ||
"scryptlib": "^2.1.26", | ||
"scryptlib": "^2.1.29", | ||
"socket.io-client": "^4.6.1", | ||
@@ -63,0 +63,0 @@ "superagent": "^8.0.9" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
672617
11385
1
+ Addedgopd@1.0.1(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
- Removedgopd@1.1.0(transitive)
- Removedis-regex@1.2.0(transitive)
- Removedwhich-typed-array@1.1.16(transitive)
Updatedscryptlib@^2.1.29