diff --git a/content/_hidden/(local-development)/creating-a-clarinet-project.mdx b/content/_hidden/(local-development)/creating-a-clarinet-project.mdx index 1fcc812fa..6b49b3c8e 100644 --- a/content/_hidden/(local-development)/creating-a-clarinet-project.mdx +++ b/content/_hidden/(local-development)/creating-a-clarinet-project.mdx @@ -34,7 +34,7 @@ Created file counter/.gitignore Created directory counter/contracts Created directory counter/tests Created file counter/settings/Devnet.toml -Created file counter/settings/Mainnet.toml +Created file counter/settings/Mainnet.toml Created file counter/settings/Testnet.toml Created file counter/package.json Created file counter/tsconfig.json @@ -73,7 +73,7 @@ Your `Clarinet.toml` now includes: [contracts.counter] path = 'contracts/counter.clar' clarity_version = 2 -epoch = 2.5 +epoch = "latest" ``` ## Step 3: Write Your Smart Contract diff --git a/content/docs/tools/clarinet/(clarinet-cli)/clarity-formatter.mdx b/content/docs/tools/clarinet/(clarinet-cli)/clarity-formatter.mdx index 2a3efec68..7cac50a7d 100644 --- a/content/docs/tools/clarinet/(clarinet-cli)/clarity-formatter.mdx +++ b/content/docs/tools/clarinet/(clarinet-cli)/clarity-formatter.mdx @@ -142,6 +142,14 @@ Format with custom settings: $ clarinet format -i 4 -l 120 --in-place ``` +Check formatting in CI/CD pipelines: + +```terminal +$ clarinet format --check +``` + +The `--check` flag validates that all Clarity files are properly formatted without modifying them. This is perfect for continuous integration workflows where you want to ensure code style consistency. + ### Ignoring blocks of code Prevent formatting of specific code blocks: @@ -151,4 +159,4 @@ Prevent formatting of specific code blocks: (define-constant something (list 1 2 3 ;; Preserves custom spacing 4 5 )) -``` \ No newline at end of file +``` diff --git a/content/docs/tools/clarinet/(clarinet-cli)/cli-reference.mdx b/content/docs/tools/clarinet/(clarinet-cli)/cli-reference.mdx index 904a5ba9f..69a3e816f 100644 --- a/content/docs/tools/clarinet/(clarinet-cli)/cli-reference.mdx +++ b/content/docs/tools/clarinet/(clarinet-cli)/cli-reference.mdx @@ -365,14 +365,16 @@ $ clarinet format [OPTIONS] ``` ```terminal +$ clarinet format --check $ clarinet format --dry-run $ clarinet format --file contracts/token.clar --in-place ``` | Option | Short | Description | Required | |--------|-------|-------------|----------| -| `--dry-run` | | Only echo the result of formatting | Yes | -| `--in-place` | | Replace the contents of a file with the formatted code | Yes | +| `--check` | | Check if code is formatted without modifying files | No | +| `--dry-run` | | Only echo the result of formatting | No | +| `--in-place` | | Replace the contents of a file with the formatted code | No | | `--manifest-path ` | `-m` | Path to Clarinet.toml | No | | `--file ` | `-f` | If specified, format only this file | No | | `--max-line-length ` | `-l` | Maximum line length | No | diff --git a/content/docs/tools/clarinet/(clarinet-cli)/validation-and-analysis.mdx b/content/docs/tools/clarinet/(clarinet-cli)/validation-and-analysis.mdx index 8c8343e82..82e72ab1b 100644 --- a/content/docs/tools/clarinet/(clarinet-cli)/validation-and-analysis.mdx +++ b/content/docs/tools/clarinet/(clarinet-cli)/validation-and-analysis.mdx @@ -77,6 +77,8 @@ jobs: - uses: actions/checkout@v4 - name: Check Clarity contracts check run: clarinet check --use-on-disk-deployment-plan + - name: Check Clarity contracts format + run: clarinet format --check ``` ## Runtime analysis @@ -142,7 +144,7 @@ $ continue Debug navigation commands: - `step` or `s` - Step into sub-expressions - `finish` or `f` - Complete current expression -- `next` or `n` - Step over sub-expressions +- `next` or `n` - Step over sub-expressions - `continue` or `c` - Continue to next breakpoint ### **Using `::get_costs` for analyzing specific function costs** @@ -185,15 +187,15 @@ Master interactive debugging to quickly identify issues by starting a debugging $ clarinet console $ ::debug (contract-call? .counter count-up) ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.counter:9:3 - 6 + 6 7 ;; Increment the count for the caller 8 (define-public (count-up) -> 9 (ok (map-set counters tx-sender (+ (get-count tx-sender) u1))) ^ 10 ) - 11 + 11 12 ;; Get the current count for a user -(debug) +(debug) $ continue ``` diff --git a/content/docs/tools/clarinet/(overview)/project-structure.mdx b/content/docs/tools/clarinet/(overview)/project-structure.mdx index 3dc40a849..efd28b42e 100644 --- a/content/docs/tools/clarinet/(overview)/project-structure.mdx +++ b/content/docs/tools/clarinet/(overview)/project-structure.mdx @@ -51,12 +51,12 @@ description = "A counter smart contract" [contracts.traits] path = "contracts/traits.clar" clarity_version = 3 -epoch = 3.1 +epoch = "latest" [contracts.counter] path = 'contracts/counter.clar' clarity_version = 3 -epoch = 3.1 +epoch = "latest" ``` The manifest handles several critical functions: @@ -65,6 +65,20 @@ The manifest handles several critical functions: - **Stacks Epoch and Clarity version**: Specifies Clarity version and epoch for each contract - **Boot sequence**: Lists contracts to deploy on `clarinet devnet start` +### Epoch configuration + +You can specify the epoch in two ways: + +```toml +# Use a specific epoch version +epoch = 3.1 + +# Use the latest available epoch (default) +epoch = "latest" +``` + +Using `"latest"` ensures your contracts always use the newest Clarity features and optimizations available in your version of Clarinet. + ## Testing infrastructure ### Package configuration @@ -241,11 +255,11 @@ Never commit mainnet private keys or mnemonics. Use environment variables for pr ```toml Clarinet.toml [contracts.token] clarity_version = 3 - epoch = 3.1 # !mark + epoch = "latest" # !mark [contracts.pool] clarity_version = 3 - epoch = 3.1 # !mark + epoch = "latest" # !mark ``` Mismatched versions can cause deployment failures and unexpected behavior. Always upgrade all contracts together when moving to a new Clarity version.