Skip to content

Commit 89e580d

Browse files
mr-zwetsrkalis
authored andcommitted
improve docs MockNetworkProvider
1 parent 921f921 commit 89e580d

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

website/docs/guides/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const uri = await transactionBuilder.bitauthUri();
4949
```
5050

5151
:::caution
52-
It is unsafe to debug transactions on mainnet as private keys will be exposed to BitAuth IDE and transmitted over the network.
52+
It is unsafe to debug transactions on mainnet using the BitAuth IDE as private keys will be exposed to BitAuth IDE and transmitted over the network.
5353
:::
5454

5555
The Bitauth IDE will show you the two-way mapping between the CashScript contract code generated opcodes. Here is [a Bitauth IDE link][BitauthIDE] for the basic `TransferWithTimeout` contract as an example:

website/docs/releases/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This release also contains several breaking changes, please refer to the [migrat
1919
- Output BitAuth IDE URI for debugging when transaction is rejected.
2020
- Libauth template generation and debugging for multi-contract transactions
2121
- :sparkles: Debugging now supports using the optimised contract bytecode (when compiled with `cashc@0.11.0` or later).
22+
- :sparkles: Add `setBlockHeight()` method to `MockNetworkProvider`
2223
- :sparkles: Config-free usage of the CashScript SDK with Vite or Webpack
2324
- :hammer_and_wrench: Update debug tooling to use the new `BCH_2025_05` instruction set.
2425
- :hammer_and_wrench: Deprecate the simple transaction builder. You can still use the simple transaction builder with the current SDK, but this support will be removed in a future release.

website/docs/sdk/other-network-providers.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ The CashScript SDK needs to connect to the BCH network to perform certain operat
99
new MockNetworkProvider()
1010
```
1111

12-
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. You can read more about the `MockNetworkProvider` and automated tests on the [testing setup](/docs/sdk/testing-setup) page.
12+
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.
13+
14+
The `MockNetworkProvider` has extra methods to enable this local emulation such as `.addUtxo()` and `.setBlockHeight()`.
15+
You can read more about the `MockNetworkProvider` and automated tests on the [testing setup](/docs/sdk/testing-setup) page.
1316

1417
#### Example
1518
```ts
@@ -18,7 +21,7 @@ const newUtxo = randomUtxo({satoshis: 10_000n})
1821
provider.addUtxo(contractAddress, newUtxo);
1922
```
2023

21-
The network type of the `MockNetworkProvider`.
24+
The network type of the `MockNetworkProvider` is `'mocknet'`.
2225

2326
## Other NetworkProviders
2427

website/docs/sdk/testing-setup.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ For a quick start with a CashScript testing setup, check out the [example testin
1010

1111
## MockNetworkProvider
1212

13-
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. To create a new virtual UTXO use `provider.addUtxo()`.
13+
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.
14+
15+
To create a new virtual UTXO use `provider.addUtxo(address, uxto)`. You can use the helper functions `randomUtxo()`, `randomToken()` and `randomNFT()` to generate random partial Utxo info which you can be overwritten with custom values.
1416

1517
#### Example
1618

@@ -27,7 +29,7 @@ const aliceUtxo = provider.addUtxo(aliceAddress, randomUtxo({
2729
```
2830

2931
:::note
30-
The `MockNetworkProvider` only evaluates the transactions locally, so any UTXOs added to a transaction still count as "unspent", even after mocking a `sendTransaction` using the provider.
32+
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.
3133
:::
3234

3335
## Automated testing

website/docs/sdk/transaction-builder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ If you prefer a lower-level debugging experience, you can call the `bitauthUri()
247247
You can read more about debugging transactions on the [debugging page](/docs/guides/debugging).
248248

249249
:::caution
250-
It is unsafe to debug transactions on mainnet as private keys will be exposed to BitAuth IDE and transmitted over the network.
250+
It is unsafe to debug transactions on mainnet using the BitAuth IDE as private keys will be exposed to BitAuth IDE and transmitted over the network.
251251
:::
252252

253253
## Transaction errors

website/docs/sdk/transactions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ If you prefer a lower-level debugging experience, you can call the `bitauthUri()
257257
You can read more about debugging transactions on the [debugging page](/docs/guides/debugging).
258258

259259
:::caution
260-
It is unsafe to debug transactions on mainnet as private keys will be exposed to BitAuth IDE and transmitted over the network.
260+
It is unsafe to debug transactions on mainnet using the BitAuth IDE as private keys will be exposed to BitAuth IDE and transmitted over the network.
261261
:::
262262

263263
## Transaction errors

0 commit comments

Comments
 (0)