Skip to content

feat(cannon-3): draft var system changes for 3.0#1863

Open
saturn-dbeal wants to merge 15 commits intomainfrom
feat/cannon-3-var-system
Open

feat(cannon-3): draft var system changes for 3.0#1863
saturn-dbeal wants to merge 15 commits intomainfrom
feat/cannon-3-var-system

Conversation

@saturn-dbeal
Copy link
Contributor

This is a draft RFC for Cannon 3.0 breaking changes to the var system.

Summary

Variables can now be defined with type information, descriptions, and namespacing:

[var.main]
foobar.value = "my super variable"
foobar.type = "string"
foobar.description = "Super important variable documentation"

baz.type = "address"

Access via: <%= var.main.foobar %>

Key Features

  • Type validation: Required type field with validation for string, address, number, boolean, bytes
  • Optional value: If value is not defined, must be provided externally at build time
  • Descriptions: Optional description field for documentation
  • Namespacing: Vars are organized in namespaces (e.g., var.main, var.deploy)

Breaking Changes

  • type is now required for all vars
  • Vars output to var.namespace.varname in addition to settings.varname (backwards compat maintained)
  • Missing values without override will error instead of silently failing

RFC

This is a draft for discussion. The exact format and behavior may change based on feedback.


🤖 Generated with Cannon

dbeal-eth and others added 15 commits February 10, 2026 15:01
Co-authored-by: saturn <saturn@dbeal.dev>
Co-authored-by: dbeal <git@dbeal.dev>
Co-authored-by: Saturn <saturn@dbeal.dev>
This is a draft RFC for Cannon 3.0 breaking changes to the var system.

## Changes

### New var format
Variables can now be defined with type information, descriptions, and namespacing:

```toml
[var.main]
foobar.value = "my super variable"
foobar.type = "string"
foobar.description = "Super important variable documentation"

baz.type = "address"
```

Access via: `<%= var.main.foobar %>`

### Key features
- **Type validation**: Required `type` field with validation for string, address, number, boolean, bytes
- **Optional value**: If `value` is not defined, must be provided externally at build time
- **Descriptions**: Optional `description` field for documentation
- **Namespacing**: Vars are organized in namespaces (e.g., `var.main`, `var.deploy`)

### Breaking changes
- `type` is now required for all vars
- Vars output to `var.namespace.varname` in addition to `settings.varname` (backwards compat)
- Missing values without override will error instead of silently failing

### Internal changes
- Added `vars` to ChainBuilderContext type
- Updated varSchema to support nested VarDefinition structure
- Added type validation functions for address, number, boolean, bytes
- Updated context initialization in builder.ts, cli/helpers.ts, website hooks
- Added comprehensive tests for new format
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants