Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/components/clarit…
Browse files Browse the repository at this point in the history
…y-vscode/word-wrap-1.2.4
  • Loading branch information
smcclellan authored Jul 20, 2023
2 parents 3e53d86 + b28d5e9 commit f6ea4ee
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 72 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- main
- develop
- rc/next
paths-ignore:
- '**/CHANGELOG.md'
- 'docs/**'

workflow_dispatch:

jobs:
Expand Down
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ For a detailed video description on how you can create a new project, please see
Clarinet can handle adding a new contract and its configuration to your project with the following command:

```bash
$ clarinet contract new bbtc
clarinet contract new bbtc
```

Clarinet will add 2 files to your project: the contract file in the `contracts` directory, and the contract test file
Expand Down Expand Up @@ -175,7 +175,7 @@ to `Clarinet.toml` in order for Clarinet to recognize the contracts.
Clarinet provides syntax and semantics checkers for Clarity, which enable you to check if the Clarity code in your project is valid by using the following command:

```bash
$ clarinet check
clarinet check
```

This command uses the `Clarinet.toml` file to locate and analyze all of the contracts in the project. If the Clarity code is valid, the command will indicate success with the following message:
Expand All @@ -189,7 +189,7 @@ The checker may also report warnings that indicate the code is valid; however, y
You may also perform syntax-check on a single file by using the following command.

```bash
$ clarinet check <path/to/file.clar>
clarinet check <path/to/file.clar>
```

If there are no syntax errors, the output of the command will be a success message similar to the example below.
Expand Down Expand Up @@ -354,7 +354,7 @@ This annotation tells the check-checker to consider the specified variables to b
Clarinet provides a testing harness based on Deno that can enable you to create automated unit tests or pseudo-integration tests using Typescript.

```bash
$ clarinet test
clarinet test
```

For more information on how to create unit tests using Typescript, see the [Writing Unit Tests Using Typescript](https://www.youtube.com/watch?v=Z4YEHUxHWuE&list=PL5Ujm489LoJaAz9kUJm8lYUWdGJ2AnQTb&index=7) YouTube video.
Expand All @@ -378,15 +378,15 @@ See the [billboard example](examples/billboard/tests/billboard_test.ts) for samp
To help maximize a smart contract's test coverage, Clarinet can produce a `lcov` report, using the following option:

```bash
$ clarinet test --coverage
clarinet test --coverage
```

From there, you can use the `lcov` tooling suite to produce HTML reports:

```bash
$ brew install lcov
$ genhtml --branch-coverage -o coverage coverage.lcov
$ open coverage/index.html
brew install lcov
genhtml --branch-coverage -o coverage coverage.lcov
open coverage/index.html
```

![lcov](docs/images/lcov.png)
Expand All @@ -396,7 +396,7 @@ $ open coverage/index.html
Clarinet can also be used to optimize costs. When executing a test suite, Clarinet will keep track of all the costs being computed when executing the `contract-call`, and display the most expensive ones in a table:

```bash
$ clarinet test --cost
clarinet test --cost
```

The `--cost` option can be used in conjunction with `--watch` and filters to maximize productivity, as illustrated here:
Expand All @@ -409,7 +409,7 @@ The Clarinet console is an interactive Clarity REPL environment that runs in-mem
automatically loaded into memory.

```bash
$ clarinet console
clarinet console
```

You can use the `::help` command in the console for a list of valid commands, which can control the state of the
Expand All @@ -427,7 +427,7 @@ You can use Clarinet to deploy your contracts to your own local offline environm
evaluation on a blockchain by using the following command:

```bash
$ clarinet integrate
clarinet integrate
```

**Note** Make sure you have a working installation of Docker running locally.
Expand Down Expand Up @@ -513,7 +513,7 @@ trusted_caller = false
callee_filter = false
```

As a next step we can generate a deployment plan for this project. If you are running `$ clarinet integrate` for the first time, this file should be created by Clarinet. In addition, you can run `$ clarinet deployment generate --devnet` to create or overwrite the file.
As a next step we can generate a deployment plan for this project. If you are running `clarinet integrate` for the first time, this file should be created by Clarinet. In addition, you can run `clarinet deployment generate --devnet` to create or overwrite the file.

```yaml
---
Expand Down Expand Up @@ -562,13 +562,13 @@ You can use Clarinet to publish your contracts to Devnet / Testnet / Mainnet env
The first step to deploy a contract is to generate a deployment plan, with the following command:

```bash
$ clarinet deployment generate --mainnet
clarinet deployment generate --mainnet
```

After **cautiously** reviewing (and updating if needed) the generated plan, you can use the command to handle the deployments of your contract, according to your deployment plan:

```bash
$ clarinet deployment apply -p <path-to-plan.yaml>
clarinet deployment apply -p <path-to-plan.yaml>
```

### Use Clarinet in your CI workflow as a GitHub Action
Expand Down Expand Up @@ -615,7 +615,7 @@ Clarinet can easily be extended by community members: open source contributions
Extensions are run with the following syntax:

```
$ clarinet run --allow-write https://deno.land/x/[email protected]/ext/stacksjs-helper-generator.ts
clarinet run --allow-write https://deno.land/x/[email protected]/ext/stacksjs-helper-generator.ts
```

An extension can be deployed as a standalone plugin on Deno, or may also be a local file if it includes sensitive / private setup informations.
Expand Down Expand Up @@ -740,7 +740,7 @@ This same file may also be used for customizing the subnet-node (miner, etc).
When running the command:

```bash
$ clarinet integrate
clarinet integrate
```

Clarinet will spin-up a subnet node. More documentation on how to use and interact with this incoming L2 can be found on the [Hyperchain repository](https://github.com/hirosystems/stacks-subnets).
Expand Down Expand Up @@ -792,23 +792,23 @@ To start contributing:
Here is an example of a bad message response:

```bash
$ git commit -m "bad message"
$ ⧗ input: bad message
$ ✖ subject may not be empty [subject-empty]
$ ✖ type may not be empty [type-empty]
$
$ ✖ found 2 problems, 0 warnings
$ ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
$
$ husky - commit-msg hook exited with code 1 (error)
git commit -m "bad message"
⧗ input: bad message
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
husky - commit-msg hook exited with code 1 (error)
```

Here is an example of a good message response:

```bash
$ git commit -m "fix: added missing dependency"
$ [my-branch 4c028af] fix: added missing dependency
$ 1 file changed, 50 insertions(+)
git commit -m "fix: added missing dependency"
[my-branch 4c028af] fix: added missing dependency
1 file changed, 50 insertions(+)
```

5. After making your changes, ensure the following:
Expand Down
31 changes: 19 additions & 12 deletions components/clarinet-cli/examples/cbtc/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# cBTC example

In this example we are exploring a naive and centralized but yet functional approach for wrapping / unwrapping BTC to SIP10 tokens.
In this example we are exploring a naive and centralized but, yet functional approach for wrapping / unwrapping BTC to SIP10 tokens.

By sending BTC to the `authority` address, a party would see an equivalent amount of cBTC being minted on the Stacks Blockchain.

When burning cBTC, a token owner will see some Bitcoin being transfered to his Bitcoin address.
When burning cBTC, a token owner will see some Bitcoin being transferred to his Bitcoin address.

This protocol was meant to illustrate possible interactions between Bitcoin and Stacks using a mechanism called `chainhooks`. The design of this protocol is limited (proofs not being checked, central trustee, etc) and should not be used in production.

Expand All @@ -13,36 +13,39 @@ This protocol was meant to illustrate possible interactions between Bitcoin and
Start a local Devnet with the command:

```bash
$ clarinet integrate
clarinet integrate
```

In another console, change the directory to `./serverless/`. After running

```bash
$ cd serverless
$ yarn global add serverless # Install serverless globally
$ yarn add --dev serverless-plugin-typescript@latest
$ yarn # Install dependencies
cd serverless
yarn global add serverless # Install serverless globally
yarn add --dev serverless-plugin-typescript@latest
yarn # Install dependencies
```

and making sure that the command `serverless` is available in your `$PATH`, the lambda functions can be started locally with the following command:

```bash
$ serverless offline --verbose
serverless offline --verbose
```

Once the message `Protocol deployed` appears on the screen, transfers tokens back and forth between the Bitcoin Blockchain and the Stacks Blockchain can be performed
thanks to the deployment plans:

- `deployments/wrap-btc.devnet-plan.yaml`: a BTC transaction is being performed, using the following parameters:

```yaml
- btc-transfer:
expected-sender: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d
recipient: mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC
sats-amount: 100000000
sats-per-byte: 10
```
A chainhook predicate, specified in `chainhooks/wrap-btc.json` is observing BTC transfers being performed to the address `mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC` thanks to the following configuration:

```json
"if_this": {
"scope": "outputs",
Expand All @@ -57,10 +60,12 @@ A chainhook predicate, specified in `chainhooks/wrap-btc.json` is observing BTC
}
}
```

In this protocol, this transaction assumes usage of p2pkh addresses, and sends the change back to the sender, using the same address. When minting the `cBTC` tokens, the authority is converting
the 2nd output of the transaction to a Stacks address, and sending the minted tokens to this address.

- `deployments/unwrap-btc.devnet-plan.yaml`: a contract call is being issued, using the following settings:

```yaml
- contract-call:
contract-id: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.cbtc-token
Expand All @@ -70,7 +75,9 @@ the 2nd output of the transaction to a Stacks address, and sending the minted to
- u100000
cost: 5960
```

Another chainhook predicate, specified in `chainhooks/unwrap-btc.json` is observing cBTC burn events occuring on the Stacks blockchain, thanks to the following configuration:

```json
"if_this": {
"scope": "ft_event",
Expand All @@ -86,17 +93,17 @@ Another chainhook predicate, specified in `chainhooks/unwrap-btc.json` is observ
}
}
```

When the authority process this chainhook occurences, it sends BTC from its reserve to `cBTC` burner, by assuming that a p2pkh is being used.

The wrap / unwrap deployment plans can both be respectively performed with the commands:

```bash
$ clarinet deployment apply -p deployments/wrap-btc.devnet-plan.yaml
clarinet deployment apply -p deployments/wrap-btc.devnet-plan.yaml
```

and
and

```bash
$ clarinet deployment apply -p deployments/unwrap-btc.devnet-plan.yaml
clarinet deployment apply -p deployments/unwrap-btc.devnet-plan.yaml
```

2 changes: 1 addition & 1 deletion components/clarinet-deno/ext/stacksjs-helper-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// can use in their frontend code.
//
// When running:
// $ clarinet run --allow-write scripts/stacksjs-helper-generator.ts
// clarinet run --allow-write scripts/stacksjs-helper-generator.ts
//
// This script will write a file at the path artifacts/contracts.ts:
//
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Clarinet integrate uses Docker to run Bitcoin, Stacks nodes, and other services.

#### **Where can I find the logs for Clarinet Integrate?**

If you're using Docker desktop, you can open the UI and select `stacks-node` container to see its logs.
If you're using Docker desktop, you can open the UI and select `stacks-node` container to see its logs.

If you are not using the Docker desktop, use the following command in your terminal:

Expand Down
1 change: 1 addition & 0 deletions docs/feature-guides/analyze-with-check-checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The check-checker is a static analysis pass you can use to help find potential v
* [Annotations](#annotations)

## Enable static analysis pass

To enable the static analysis pass, add the following lines to your Clarinet.toml file:

```toml
Expand Down
3 changes: 1 addition & 2 deletions docs/feature-guides/chainhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ title: Chainhooks

## Overview

Chainhooks are a powerful feature that enables you to automatically trigger an action based upon a predicate event occurring. Adhering to an event-based architecture, chainhooks allow you to pre-determine an underlying set of events that, when triggered, set into motion a logical series of follow-on steps and actions to address the specific event that was triggered.
Chainhooks are a powerful feature that enables you to automatically trigger an action based upon a predicate event occurring. Adhering to an event-based architecture, chainhooks allow you to pre-determine an underlying set of events that, when triggered, set into motion a logical series of follow-on steps and actions to address the specific event that was triggered.

*Topics covered in this guide*:

* [Chainhooks design](#design)
* [Use chainhooks](#using-chainhooks)
* [References](#references)


## Design

Chainhooks were designed with a very specific set of requirements and limitations to make them easy to work with in a development environment. These constraints include portability and performance.
Expand Down
2 changes: 0 additions & 2 deletions docs/feature-guides/clarinet-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Deployment Plans are reproducible deployment steps that publish a collection of
* [Plan primitives](#deployment-plan-primitives)
* [References](#references)


## Design

The default deployment plan of every Clarinet project is contained within specifications set inside certain files. In addition to this default deployment plan, the user can manually configure each plan, adding additional transactions or contract calls, across multiple Stacks or Bitcoin blocks.
Expand All @@ -29,7 +28,6 @@ You can commit, audit, and test contracts without including any secrets in the D
| wait for block | - Test or automate contract deployment across multiple Stacks or Bitcoin blocks |
| send STX | - send stacks to an address or contract |


## References

For a more detailed discussion of how to use Deployment Plans, please see the following resources:
Expand Down
7 changes: 4 additions & 3 deletions docs/feature-guides/extend-clarinet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ title: Extend Clarinet

Extend Clarinet to integrate clarity contracts with your own tooling and workflow.


*Topics covered in this guide*:

* [Use clarinet run command](#clarinet-run)
* [Standalone plugin deployment](#standalone-plugin)

## Clarinet run

| Name | wallet access | disk write | disk read | Deployment | Description |
| ------------------------- | ------------- | ---------- | --------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| stacksjs-helper-generator | no | yes | no | https://deno.land/x/[email protected]/ext/stacksjs-helper-generator.ts | Facilitates contract integration by generating some typescript constants that can be used with stacks.js. Never hard code a stacks address again! |
Expand All @@ -19,10 +19,11 @@ Extend Clarinet to integrate clarity contracts with your own tooling and workflo
Extensions are run with the following syntax:

```
$ clarinet run --allow-write https://deno.land/x/[email protected]/ext/stacksjs-helper-generator.ts
clarinet run --allow-write https://deno.land/x/[email protected]/ext/stacksjs-helper-generator.ts
```

## Standalone plugin
An extension can be deployed as a standalone plugin on [Deno](https://deno.land/), or can also just be a local file if it includes sensitive / private setup informations.

An extension can be deployed as a standalone plugin on [Deno](https://deno.land/), or can also just be a local file if it includes sensitive / private setup information.

As illustrated in the example above, permissions (wallet / disk read / disk write) are declared using command flags. If at runtime, the Clarinet extension is trying to write to disk, read disk, or access wallets without permission, the script will end up failing.
3 changes: 1 addition & 2 deletions docs/how-to-guides/how-to-add-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Clarinet can handle adding a new contract and its configuration to your project.
You can use the command below to add a new contract.

```bash
$ clarinet contract new bbtc
clarinet contract new bbtc
```

Clarinet will add two files to your project:
Expand Down Expand Up @@ -47,4 +47,3 @@ epoch = 2.4

You can add contracts to your project by adding the files manually; however, you must make sure to add the appropriate configuration
to `Clarinet.toml` for Clarinet to recognize the contracts.

Loading

0 comments on commit f6ea4ee

Please sign in to comment.