Skip to content

Commit

Permalink
Merge pull request #244 from sCrypt-Inc/checkNOPScript
Browse files Browse the repository at this point in the history
rename
  • Loading branch information
zhfnjust authored Sep 18, 2023
2 parents 1e9f95b + 92bd2c4 commit 56707f6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 2.1.29

- rename `this.setNOPScript()` to `this.prependNOPScript()`


## 2.1.28

- check nopscript when call `this.setNOPScript()`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scryptlib",
"version": "2.1.28",
"version": "2.1.29",
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.",
"engines": {
"node": ">=14.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,15 @@ export class AbstractContract {
}
}

setNOPScript(nopScript: NOPScript | null): void {
prependNOPScript(nopScript: NOPScript | null): void {
if (nopScript instanceof bsv.Script) {
checkNOPScript(nopScript);
}

this.nopScript = nopScript;
}

getNOPScript(): NOPScript | null {
getPrependNOPScript(): NOPScript | null {
return this.nopScript;
}

Expand Down
4 changes: 2 additions & 2 deletions test/counterNOP.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('test.Counter with NOPScript', () => {
let counter = new Counter()

counter.setDataPartInASM('00')
counter.setNOPScript(nopScript)
counter.prependNOPScript(nopScript)


expect(counter.lockingScript.toASM().startsWith("OP_NOP")).to.true
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('test.Counter with NOPScript', () => {
let nopScript = bsv.Script.fromASM("OP_NOP");

counter.setDataPartInASM('00')
counter.setNOPScript(nopScript)
counter.prependNOPScript(nopScript)

let callTx = new bsv.Transaction()
.addDummyInput(counter.lockingScript, 1000)
Expand Down
6 changes: 3 additions & 3 deletions test/p2pkhNOP.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('test.P2PKH with NOP', () => {
const DemoP2PKH = buildContractClass(loadArtifact('p2pkh.json'))
let p2pkh = new DemoP2PKH(Ripemd160(toHex(publicKeyHash)))
let nopScript = bsv.Script.fromASM("OP_NOP");
p2pkh.setNOPScript(nopScript)
p2pkh.prependNOPScript(nopScript)

const inputIndex = 0;
expect(p2pkh.lockingScript.toASM().startsWith("OP_NOP")).to.true
Expand Down Expand Up @@ -44,12 +44,12 @@ describe('test.P2PKH with NOP', () => {
const DemoP2PKH = buildContractClass(loadArtifact('p2pkh.json'))
let p2pkh = new DemoP2PKH(Ripemd160(toHex(publicKeyHash)))
expect(() => {
p2pkh.setNOPScript(bsv.Script.fromASM("OP_1 OP_IF OP_1 OP_ENDIF"))
p2pkh.prependNOPScript(bsv.Script.fromASM("OP_1 OP_IF OP_1 OP_ENDIF"))
}).to.throw(/NopScript should be a script that does not affect the Bitcoin virtual machine stack\./)


expect(() => {
p2pkh.setNOPScript(bsv.Script.fromASM("OP_1 OP_RETURN"))
p2pkh.prependNOPScript(bsv.Script.fromASM("OP_1 OP_RETURN"))
}).to.throw(/NopScript should be a script that does not affect the Bitcoin virtual machine stack\./)
})
})

0 comments on commit 56707f6

Please sign in to comment.