Skip to content

Commit acae9f2

Browse files
authored
Update docusaurus (#378)
1 parent 894e90c commit acae9f2

File tree

15 files changed

+6464
-3473
lines changed

15 files changed

+6464
-3473
lines changed

website/docs/basics/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To write CashScript smart contracts locally you use a code editor. For the best
3636
:::
3737

3838
:::tip
39-
To set up your CashScript developer environment, see the [Syntax Highlighting](/docs/guides/syntax-highlighting) guide.
39+
To set up your CashScript developer environment, see the [Syntax Highlighting](/docs/language/syntax-highlighting) guide.
4040
:::
4141

4242
### Installing the CashScript compiler

website/docs/guides/adversarial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ If DEXes don't cleverly aggregate their prices across blocks, then it can be eco
6161
Because having a more advantageous (older) price state or ratio might be very profitable, it is worth it for the adversarial actor to pay the high fee "miner bribe" to attempt this double spend transaction.
6262

6363
:::tip
64-
We list some possible mitigations which smart contract systems can implement in the section on ['Avoiding MEV'](#avoiding-mev)
64+
We list some possible mitigations which smart contract systems can implement in the section on ['Avoiding MEV'](#mev-avoidance-strategies)
6565
:::
6666

6767

website/docs/guides/cashtokens.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ While CashTokens might seem overwhelming at first, realize that in contracts you
5656

5757
and their equivalent for outputs:
5858

59-
- **`bytes tx.outputs[i].tokenCategory`** - `tokenCategory` + `tokenCapability` of a specific output. (see [below](#1-tokencategory-contains-the-nft-capability)).
59+
- **`bytes tx.outputs[i].tokenCategory`** - `tokenCategory` + `tokenCapability` of a specific output. (see [below](#tokencategory-contains-the-nft-capability)).
6060
- **`bytes tx.outputs[i].nftCommitment`** - NFT commitment data of a specific output
6161
- **`int tx.outputs[i].tokenAmount`** - Amount of fungible tokens of a specific output.
6262

@@ -70,7 +70,7 @@ The [Jedex demo](https://github.com/bitjson/jedex) also introduces very advanced
7070

7171
Below we'll create a short list of the use cases which will be the most important to know about:
7272

73-
- **Covenant tracking tokens** - this is what enables unique authentication of contract deployments
73+
- **Covenant tracking tokens** - this is what enables unique authentication of contract deployments
7474
- **Commitment-based state management** - this is what `mutable` nfts are extremely useful for
7575
- **Depository covenants/token pools** - which we would call token sidecars
7676
- **Role tokens** - these are authentication tokens for admins
@@ -171,7 +171,7 @@ const contract = new Contract(artifact, [reverseHex(tokenId)], { provider })
171171
Most end-user CashTokens wallets expect CashTokens UTXOs to only hold a tiny amount of BCH like 1000 sats. Deviating from the expectation might cause unforeseen problems with user's wallets.
172172

173173
:::tip
174-
You can hard code in your contract that any user token output should have exactly `1000` sats, this avoids possible complicating freedom during transaction building.
174+
You can hard code in your contract that any user token output should have exactly `1000` sats, this avoids possible complicating freedom during transaction building.
175175
:::
176176

177177
However when constructing a transaction with user owned UTXOs, you should always make sure to check whether you handle the edge case of users with combined BCH + CashTokens UTXOs correctly in change output handling both for BCH and the tokens.

website/docs/guides/covenants.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,6 @@ With contracts holding minting NFTs, all outputs need to be carefully controlled
325325
## Conclusion
326326
We have discussed the main uses for covenants as they exist on Bitcoin Cash today. We've seen how we can achieve different use cases by combining transaction output restrictions to `P2SH` and `P2PKH` outputs. We also touched on more advanced subjects such as keeping local state in NFTs. Covenants and CashTokens are the **main differentiating factor** for BCH smart contracts when compared to BTC, while keeping the same **efficient, atomic verification**.
327327

328-
Keeping local state in NFTs and issuing NFTs as receipts are two strategies which can be used to create much more sophisticated decentralized applications. You can read more of these advanced CashTokens use cases in our [dedicated guide](/docs/guides/cashtokens#cashtokens-usecases)!
328+
Keeping local state in NFTs and issuing NFTs as receipts are two strategies which can be used to create much more sophisticated decentralized applications. You can read more of these advanced CashTokens use cases in our [dedicated guide](/docs/guides/cashtokens#cashtokens-use-cases)!
329329

330330
[bitcoin-covenants]: https://fc16.ifca.ai/bitcoin/papers/MES16.pdf

website/docs/language/types.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ See the following table for information on which types can be cast to other whic
182182
| sig | bytes | bytes |
183183
| datasig | bytes | bytes |
184184

185+
:::caution
186+
Casting from `int` to `bool` does not currently change the value of the integer. This can have unexpected consequences in boolean comparisons.
187+
188+
```solidity
189+
if (bool(7)) { ...} // This works as expected
190+
if (bool(7) == true) { ... } // This does not work as expected
191+
```
192+
193+
:::
194+
185195
### Int to Byte Casting
186196

187197
When casting integer types to bytes of a certain size, the integer value is padded with zeros, e.g. `bytes4(0) == 0x00000000`. It is also possible to pad with a variable number of zeros by passing in a `size` parameter, which indicates the size of the output, e.g. `bytes(0, 4 - 2) == 0x0000`.

website/docs/releases/release-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ CashScript used to be very tightly coupled with BITBOX. This proved to be proble
386386
- :boom: Remove `Sig` alias for `SignatureTemplate` that was deprecated in v0.4.1.
387387
- :boom: **BREAKING**: Refactor contract instantiation flow
388388
- A contract is now instantiated by providing a compiled artifact, constructor arguments and an optional network provider.
389-
- Anyone can implement the NetworkProvider interface to create a custom provider. The CashScript SDK offers three providers out of the box: one based on electrum-cash (default), one based on FullStack.cash' infrastructure, and one based on BITBOX. See the [NetworkProvider docs](/docs/sdk/instantiation#networkprovider) for details.
389+
- Anyone can implement the NetworkProvider interface to create a custom provider. The CashScript SDK offers three providers out of the box: one based on electrum-cash (default), one based on FullStack.cash' infrastructure, and one based on BITBOX. See the [NetworkProvider docs](/docs/sdk/network-provider) for details.
390390
- See the [migration notes](/docs/releases/migration-notes#v04-to-v05) for details on migrating from the old contract instantiation flow.
391391
- :boom: **BREAKING**: Remove the artifacts `'networks'` field and `.deployed()` functionality, This proved to be confusing and is better suited to be handled outside of the CashScript SDK.
392392
- :boom: **BREAKING**: `.send()` now returns a libauth Transaction instead of a BITBOX Transaction object. Alternatively a `raw` flag can be passed into the function to return a raw hex string.

website/docs/sdk/instantiation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ contract.address: string
6464
A contract's regular address (without token-support) can be retrieved through the `address` member field.
6565

6666
:::note
67-
Wallets will not allow you to send CashTokens to this address. For that you must use the [tokenAddress](#tokenAddress) below. Wallets which have not upgraded might not recognize this new address type.
67+
Wallets will not allow you to send CashTokens to this address. For that you must use the [tokenAddress](#tokenaddress) below. Wallets which have not upgraded might not recognize this new address type.
6868
:::
6969

7070
#### Example

website/docs/sdk/transaction-builder.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ import { aliceTemplate, aliceAddress, bobAddress, contract, provider } from './s
203203

204204
const contractUtxos = await contract.getUtxos();
205205
const aliceUtxos = await provider.getUtxos(aliceAddress);
206+
const maximumFeeSatoshis = 1000n;
206207

207-
const txDetails = await new TransactionBuilder({ provider })
208+
const txDetails = await new TransactionBuilder({ provider, maximumFeeSatoshis })
208209
.addInput(contractUtxos[0], contract.unlock.spend(aliceTemplate, 1000n))
209210
.addInput(aliceUtxos[0], aliceTemplate.unlockP2PKH())
210211
.addOutput({ to: bobAddress, amount: 100_000n })
211212
.addOpReturnOutput(['0x6d02', 'Hello World!'])
212-
.setMaxFee(2000n)
213213
.send()
214214
```
215215

@@ -226,13 +226,13 @@ import { aliceTemplate, aliceAddress, bobAddress, contract, provider } from './s
226226

227227
const contractUtxos = await contract.getUtxos();
228228
const aliceUtxos = await provider.getUtxos(aliceAddress);
229+
const maximumFeeSatoshis = 1000n;
229230

230-
const txHex = new TransactionBuilder({ provider })
231+
const txHex = new TransactionBuilder({ provider, maximumFeeSatoshis })
231232
.addInput(contractUtxos[0], contract.unlock.spend(aliceTemplate, 1000n))
232233
.addInput(aliceUtxos[0], aliceTemplate.unlockP2PKH())
233234
.addOutput({ to: bobAddress, amount: 100_000n })
234235
.addOpReturnOutput(['0x6d02', 'Hello World!'])
235-
.setMaxFee(2000n)
236236
.build()
237237
```
238238

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
module.exports = {
1+
import { themes as prismThemes } from 'prism-react-renderer';
2+
import type { Config } from '@docusaurus/types';
3+
import type { Options as ClassicPresetOptions } from '@docusaurus/preset-classic';
4+
5+
const config: Config = {
26
title: 'CashScript',
37
tagline: 'Smart contracts for Bitcoin Cash',
48
url: 'https://cashscript.org',
@@ -8,8 +12,8 @@ module.exports = {
812
projectName: 'cashscript',
913
themeConfig: {
1014
prism: {
11-
theme: require('prism-react-renderer').themes.nightOwlLight,
12-
darkTheme: require('prism-react-renderer').themes.nightOwl,
15+
theme: prismThemes.nightOwlLight,
16+
darkTheme: prismThemes.nightOwl,
1317
additionalLanguages: ['solidity', 'antlr4'],
1418
},
1519
image: 'img/logo.svg',
@@ -19,7 +23,7 @@ module.exports = {
1923
src: 'img/logo.svg',
2024
},
2125
items: [
22-
{to: '/docs/basics/about', label: 'Docs', position: 'right'},
26+
{ to: '/docs/basics/about', label: 'Docs', position: 'right' },
2327
{
2428
href: 'https://playground.cashscript.org',
2529
label: 'Playground',
@@ -99,15 +103,15 @@ module.exports = {
99103
},
100104
presets: [
101105
[
102-
'@docusaurus/preset-classic',
106+
'classic',
103107
{
104108
theme: {
105-
customCss: require.resolve('./src/css/custom.css'),
109+
customCss: './src/css/custom.css',
106110
},
107111
docs: {
108-
sidebarPath: './sidebars.js',
112+
sidebarPath: './sidebars.ts',
109113
},
110-
},
114+
} as ClassicPresetOptions,
111115
],
112116
],
113117
plugins: [
@@ -116,7 +120,7 @@ module.exports = {
116120
{
117121
fromExtensions: ['html'],
118122
redirects: [
119-
{ from: ['/docs', '/docs/about', '/docs/basics'], to: '/docs/basics/about'},
123+
{ from: ['/docs', '/docs/about', '/docs/basics'], to: '/docs/basics/about' },
120124
{ from: '/docs/language', to: '/docs/language/contracts' },
121125
{ from: '/docs/sdk', to: '/docs/sdk/instantiation' },
122126
{ from: '/docs/sdk/transactions-advanced', to: '/docs/sdk/transaction-builder' },
@@ -130,3 +134,5 @@ module.exports = {
130134
['@branchup/docusaurus-plugin-simple-analytics', {}],
131135
],
132136
};
137+
138+
export default config;

website/package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
},
1111
"dependencies": {
1212
"@branchup/docusaurus-plugin-simple-analytics": "^1.1.0",
13-
"@docusaurus/core": "^2.4.1",
14-
"@docusaurus/plugin-client-redirects": "^2.4.1",
15-
"@docusaurus/preset-classic": "^2.4.1",
16-
"classnames": "^2.3.2",
17-
"prism-react-renderer": "^2.0.4",
18-
"react": "^18.2.0",
19-
"react-dom": "^18.2.0"
13+
"@docusaurus/core": "^3.9.2",
14+
"@docusaurus/plugin-client-redirects": "^3.9.2",
15+
"@docusaurus/preset-classic": "^3.9.2",
16+
"classnames": "^2.5.1",
17+
"prism-react-renderer": "^2.4.1",
18+
"react": "^19.2.3",
19+
"react-dom": "^19.2.3"
20+
},
21+
"devDependencies": {
22+
"@docusaurus/tsconfig": "^3.9.2",
23+
"typescript": "^5.9.2"
2024
},
2125
"browserslist": {
2226
"production": [

0 commit comments

Comments
 (0)