Skip to content

Commit 51d8ad0

Browse files
mr-zwetsrkalis
authored andcommitted
add to docs & release notes
1 parent c362875 commit 51d8ad0

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

website/docs/compiler/compiler.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ To have the best TypeScript integration, we recommend generating the artifact in
4242
cashc ./Contract.cash --output ./artifact.ts --format ts
4343
```
4444

45+
```bash
46+
cashc ./Contract.cash --size --opcount
47+
```
48+
49+
:::info
50+
The size outputs of the `cashc` compiler are based on the bytecode without constructor arguments. This means they are always an underestimate, as the contract hasn't been initialized with contract arguments.
51+
:::
52+
4553
## JavaScript Compilation
4654
Generally CashScript contracts are compiled to an Artifact JSON file using the CLI compiler. As an alternative to this, CashScript contracts can be compiled from within JavaScript apps using the `cashc` package. This package exports two compilation functions.
4755

website/docs/guides/infrastructure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Both the `Electrum` and `Chaingraph` indexers allow you to create websocket subs
6565
Contract-related events are when you want to update the server state to reflect changes on-chain, for example new contracts being created or existing contracts changing their state in an important way. So contract related events often don't trigger an on-chain transaction directly, but they update the information about the contracts tracked for time/oracle events by the server.
6666

6767
:::tip
68-
Only the `Chaingraph` indexer allows for subscriptions to arbitrary on-chain events, with `Electrum` you can create subscriptions for changes in the transaction history of a specific (contract) address.
68+
With `Electrum` you can create subscriptions to transactions for a specific (contract) address, with `Chaingraph` you can create subscriptions to arbitrary on-chain events.
6969
:::
7070

7171
### Oracle-related events

website/docs/language/types.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ If you do need to pad bytes to a specific length, you can convert the bytes to `
208208

209209
#### Example
210210
```solidity
211-
bytes data = nftCommitment.split(10)[0]; // (type = bytes, content = 10 bytes)
212-
bytes20 paddedData = bytes20(int(data)); // (type = bytes20, content = 20 bytes)
211+
bytes10 data = nftCommitment.split(10)[0];
212+
// First convert 'bytes' type to 'int' to cast with padding
213+
bytes20 paddedData = bytes20(int(data));
213214
require(storedContractState == paddedData);
214215
```
215216

@@ -219,7 +220,8 @@ When casting unbounded `bytes` types to bounded `bytes` types (such as `bytes20`
219220

220221
#### Example
221222
```solidity
222-
bytes pkh = nftCommitment.split(20)[0]; // (type = bytes, content = 20 bytes)
223+
bytes pkh = tx.inputs[0].nftCommitment; // (type = bytes, content = 20 bytes)
224+
// Typecast the variable to be able to use it for 'new LockingBytecodeP2PKH()'
223225
bytes20 bytes20Pkh = bytes20(pkh); // (type = bytes20, content = 20 bytes)
224226
bytes25 lockingBytecode = new LockingBytecodeP2PKH(bytes20Pkh);
225227
```

website/docs/releases/release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ title: Release Notes
66

77
#### cashc compiler
88
- :sparkles: Add `.slice(start, end)` operator for bytes and strings.
9+
- :sparkles: Add bounded bytes typing and bounds checking for `.split()`
10+
- :bug: Disallow incorrect bounded bytes typing when using `.split()`
911

1012
#### CashScript SDK
1113
- :bug: Fix bug with where `ElectrumNetworkProvider` would disconnect in browser on visibility change of the page

website/docs/sdk/electrum-network-provider.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ By default, the ElectrumNetworkProvider will automatically connect and disconnec
116116
const provider = new ElectrumNetworkProvider('chipnet', { manualConnectionManagement: true });
117117
```
118118

119+
:::tip
120+
If you're providing an `ElectrumClient` and using it to subscribe to address or blockheader events, you need to enable `manualConnectionManagement` to overwrite the default of connecting and disconnecting for each separate request.
121+
:::
122+
119123
#### connect()
120124
```ts
121125
provider.connect(): Promise<void>;

website/docs/sdk/instantiation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ contract.bytesize: number
103103

104104
The size of the contract's bytecode in bytes can be retrieved through the `bytesize` member field. This is useful to ensure that the contract is not too big, since Bitcoin Cash smart contracts can be 1,650 bytes at most.
105105

106-
:::info
107-
The size outputs of the `cashc` compiler are based on the bytecode without constructor arguments. This means they will always be an underestimate, as the contract hasn't been initialized with contract arguments.
106+
:::tip
107+
Using `contract.bytesize` is the best way to get the size of contract bytecode, as it includes the constructor arguments.
108+
The size outputs of the `cashc` compiler are based on the bytecode without constructor arguments so are always an underestimate.
108109
:::
109110

110111
#### Example

0 commit comments

Comments
 (0)