From 65134e5adc7e412acd1010aaf830c788753ade9a Mon Sep 17 00:00:00 2001 From: Rosco Kalis Date: Wed, 6 Aug 2025 16:36:02 +0200 Subject: [PATCH 1/3] Small changes --- packages/cashscript/src/advanced/LibauthTemplate.ts | 2 +- packages/cashscript/test/e2e/P2PKH.test.ts | 2 +- packages/utils/src/types.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cashscript/src/advanced/LibauthTemplate.ts b/packages/cashscript/src/advanced/LibauthTemplate.ts index c1b7f587..5cbeb711 100644 --- a/packages/cashscript/src/advanced/LibauthTemplate.ts +++ b/packages/cashscript/src/advanced/LibauthTemplate.ts @@ -534,7 +534,7 @@ export const getLibauthTemplates = ( export const debugLibauthTemplate = (template: WalletTemplate, transaction: TransactionBuilder): DebugResults => { const allArtifacts = transaction.inputs .map(input => 'contract' in input.unlocker ? input.unlocker.contract : undefined) - .filter((contract): contract is Contract => !!contract) + .filter((contract): contract is Contract => Boolean(contract)) .map(contract => contract.artifact); return debugTemplate(template, allArtifacts); diff --git a/packages/cashscript/test/e2e/P2PKH.test.ts b/packages/cashscript/test/e2e/P2PKH.test.ts index 039b71f7..9e8085ce 100644 --- a/packages/cashscript/test/e2e/P2PKH.test.ts +++ b/packages/cashscript/test/e2e/P2PKH.test.ts @@ -97,7 +97,7 @@ describe('P2PKH-no-tokens', () => { // TODO: this fails on mocknet, because mocknet doesn't check inputs vs outputs, // we should add a sanity check in our own code - itOrSkip(!!process.env.TESTS_USE_CHIPNET, 'should fail when not enough satoshis are provided in utxos', async () => { + itOrSkip(Boolean(process.env.TESTS_USE_CHIPNET), 'should fail when not enough satoshis are provided in utxos', async () => { // given const to = p2pkhContract.address; const amount = 1000n; diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts index 14a6585e..a4d6f030 100644 --- a/packages/utils/src/types.ts +++ b/packages/utils/src/types.ts @@ -190,7 +190,7 @@ export function parseType(str: string): Type { } export function isPrimitive(type: Type): type is PrimitiveType { - return !!PrimitiveType[type.toString().toUpperCase() as keyof typeof PrimitiveType]; + return Boolean(PrimitiveType[type.toString().toUpperCase() as keyof typeof PrimitiveType]); } export interface LocationI { From d09d54b89fddca0a231a763f6006e4983d3cd8ae Mon Sep 17 00:00:00 2001 From: Rosco Kalis Date: Wed, 6 Aug 2025 16:46:49 +0200 Subject: [PATCH 2/3] Update docs for 0.11.4 release --- website/docs/releases/release-notes.md | 6 ++++++ website/docs/sdk/other-network-providers.md | 6 ++++-- website/docs/sdk/testing-setup.md | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/website/docs/releases/release-notes.md b/website/docs/releases/release-notes.md index 4534bcf2..2927db65 100644 --- a/website/docs/releases/release-notes.md +++ b/website/docs/releases/release-notes.md @@ -2,6 +2,12 @@ title: Release Notes --- +## v0.11.4 + +### CashScript SDK +- :sparkles: Add `updateUtxoSet` option to `MockNetworkProvider` to allow for updating the UTXO set after a transaction is sent. +- :bug: Fix bug where sending P2PKH-only transactions would throw `No placeholder scenario ID or script ID found`. + ## v0.11.3 #### cashc compiler diff --git a/website/docs/sdk/other-network-providers.md b/website/docs/sdk/other-network-providers.md index 6c9817c1..5e3233aa 100644 --- a/website/docs/sdk/other-network-providers.md +++ b/website/docs/sdk/other-network-providers.md @@ -6,14 +6,16 @@ The CashScript SDK needs to connect to the BCH network to perform certain operat ## MockNetworkProvider ```ts -new MockNetworkProvider() +new MockNetworkProvider(options?: { updateUtxoSet: boolean }) ``` -The `MockNetworkProvider` is a special network provider that allows you to evaluate transactions locally without interacting with the Bitcoin Cash network. This is useful when writing automated tests for your contracts, or when debugging your contract locally. +The `MockNetworkProvider` is a special network provider that allows you to evaluate transactions locally without interacting with the Bitcoin Cash network. This is useful when writing automated tests for your contracts, or when debugging your contract locally. The `MockNetworkProvider` has extra methods to enable this local emulation such as `.addUtxo()` and `.setBlockHeight()`. You can read more about the `MockNetworkProvider` and automated tests on the [testing setup](/docs/sdk/testing-setup) page. +The `updateUtxoSet` option is used to determine whether the UTXO set should be updated after a transaction is sent. If `updateUtxoSet` is `true`, the UTXO set will be updated to reflect the new state of the mock network. If `updateUtxoSet` is `false` (default), the UTXO set will not be updated. + #### Example ```ts const provider = new MockNetworkProvider(); diff --git a/website/docs/sdk/testing-setup.md b/website/docs/sdk/testing-setup.md index 4bd77d07..7b34c274 100644 --- a/website/docs/sdk/testing-setup.md +++ b/website/docs/sdk/testing-setup.md @@ -29,7 +29,7 @@ const aliceUtxo = provider.addUtxo(aliceAddress, randomUtxo({ ``` :::note -The `MockNetworkProvider` evaluates transactions locally but does not process the transaction updates. This means no UTXOs are consumed and no new UTXOs are created when mocking a transaction `send` using the provider. +By default, the `MockNetworkProvider` evaluates transactions locally but does not process the transaction updates. This means no UTXOs are consumed and no new UTXOs are created when mocking a transaction `send` using the provider. This can be configured by setting the `updateUtxoSet` option to `true`. ::: ## Automated testing From 860cb293a11b5226fbf9ef6f98449223c1c0887b Mon Sep 17 00:00:00 2001 From: Rosco Kalis Date: Wed, 6 Aug 2025 16:47:24 +0200 Subject: [PATCH 3/3] Bump version to 0.11.4 --- examples/package.json | 6 +++--- examples/testing-suite/package.json | 6 +++--- packages/cashc/package.json | 4 ++-- packages/cashc/src/index.ts | 2 +- packages/cashscript/package.json | 4 ++-- packages/utils/package.json | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/package.json b/examples/package.json index ef99c791..d93baffc 100644 --- a/examples/package.json +++ b/examples/package.json @@ -1,7 +1,7 @@ { "name": "cashscript-examples", "private": true, - "version": "0.11.3", + "version": "0.11.4", "description": "Usage examples of the CashScript SDK", "main": "p2pkh.js", "type": "module", @@ -13,8 +13,8 @@ "dependencies": { "@bitauth/libauth": "^3.1.0-next.2", "@types/node": "^22.17.0", - "cashc": "^0.11.3", - "cashscript": "^0.11.3", + "cashc": "^0.11.4", + "cashscript": "^0.11.4", "eslint": "^8.56.0", "typescript": "^5.9.2" } diff --git a/examples/testing-suite/package.json b/examples/testing-suite/package.json index b37d4b71..865bc8ed 100644 --- a/examples/testing-suite/package.json +++ b/examples/testing-suite/package.json @@ -1,6 +1,6 @@ { "name": "testing-suite", - "version": "0.11.3", + "version": "0.11.4", "description": "Example project to develop and test CashScript contracts", "main": "index.js", "type": "module", @@ -26,8 +26,8 @@ }, "dependencies": { "@bitauth/libauth": "^3.1.0-next.2", - "cashc": "^0.11.3", - "cashscript": "^0.11.3", + "cashc": "^0.11.4", + "cashscript": "^0.11.4", "url-join": "^5.0.0" }, "devDependencies": { diff --git a/packages/cashc/package.json b/packages/cashc/package.json index af82e758..69fe4f24 100644 --- a/packages/cashc/package.json +++ b/packages/cashc/package.json @@ -1,6 +1,6 @@ { "name": "cashc", - "version": "0.11.3", + "version": "0.11.4", "description": "Compile Bitcoin Cash contracts to Bitcoin Cash Script or artifacts", "keywords": [ "bitcoin", @@ -52,7 +52,7 @@ }, "dependencies": { "@bitauth/libauth": "^3.1.0-next.2", - "@cashscript/utils": "^0.11.3", + "@cashscript/utils": "^0.11.4", "antlr4": "^4.13.2", "commander": "^14.0.0", "semver": "^7.7.2" diff --git a/packages/cashc/src/index.ts b/packages/cashc/src/index.ts index 2ac835a8..2a5bf4c6 100644 --- a/packages/cashc/src/index.ts +++ b/packages/cashc/src/index.ts @@ -2,4 +2,4 @@ export * from './Errors.js'; export * as utils from '@cashscript/utils'; export { compileFile, compileString } from './compiler.js'; -export const version = '0.11.3'; +export const version = '0.11.4'; diff --git a/packages/cashscript/package.json b/packages/cashscript/package.json index 86bed541..a20f1781 100644 --- a/packages/cashscript/package.json +++ b/packages/cashscript/package.json @@ -1,6 +1,6 @@ { "name": "cashscript", - "version": "0.11.3", + "version": "0.11.4", "description": "Easily write and interact with Bitcoin Cash contracts", "keywords": [ "bitcoin cash", @@ -46,7 +46,7 @@ }, "dependencies": { "@bitauth/libauth": "^3.1.0-next.2", - "@cashscript/utils": "^0.11.3", + "@cashscript/utils": "^0.11.4", "@electrum-cash/network": "^4.1.3", "@mr-zwets/bchn-api-wrapper": "^1.0.1", "@types/node": "^22.17.0", diff --git a/packages/utils/package.json b/packages/utils/package.json index be5b6c10..dca99c67 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@cashscript/utils", - "version": "0.11.3", + "version": "0.11.4", "description": "CashScript utilities and types", "keywords": [ "bitcoin cash",