Repository navigation
Releases
v0.10.1
v0.11.0
💥 Breaking Changes
Typed Paths (#403)
Paths are now typed. Paths in the storage domain have type StoragePath, in the private domain PrivatePath, and in the public domain PublicPath. PrivatePath and PublicPath are subtypes of CapabilityPath. Both StoragePath and CapabilityPath are subtypes of Path.
| Path | |||
| CapabilityPath | StoragePath | ||
| PrivatePath | PublicPath | ||
Storage API (#403)
With paths being typed, it was possible to make the Storage API type-safer and easier to use: It is now statically checked if the correct type of path is given to a function, instead of at run-time, and therefore capability return types can now be non-optional.
The changes are as follows:
For PublicAccount:
-
old:
fun getCapability<T>(_ path: Path): Capability<T>?
new:fun getCapability<T>(_ path: PublicPath): Capability<T> -
old:
fun getLinkTarget(_ path: Path): Path?
new:fun getLinkTarget(_ path: CapabilityPath): Path?
For AuthAccount:
-
old:
fun save<T>(_ value: T, to: Path)
new:fun save<T>(_ value: T, to: StoragePath) -
old:
fun load<T>(from: Path): T?
new:fun load<T>(from: StoragePath): T? -
old:
fun copy<T: AnyStruct>(from: Path): T?
new:fun copy<T: AnyStruct>(from: StoragePath): T? -
old:
fun borrow<T: &Any>(from: Path): T?
new:fun borrow<T: &Any>(from: StoragePath): T? -
old:
fun link<T: &Any>(_ newCapabilityPath: Path, target: Path): Capability<T>?
new:fun link<T: &Any>(_ newCapabilityPath: CapabilityPath, target: Path): Capability<T>? -
old:
fun getCapability<T>(_ path: Path): Capability<T>?
new:fun getCapability<T>(_ path: CapabilityPath): Capability<T> -
old:
fun getLinkTarget(_ path: Path): Path?
new:fun getLinkTarget(_ path: CapabilityPath): Path? -
old:
fun unlink(_ path: Path)
new:fun unlink(_ path: CapabilityPath)
⭐ Features
-
Add a hash function to the crypto contract (#379)
-
Added npm packages for components of Cadence. This eases the development of developer tools for Cadence:
cadence-language-server: The Cadence Language Servermonaco-languageclient-cadence: Language Server Protocol client for the the Monaco editorcadence-parser: The Cadence parser
In addition, there are also examples for the language server and the parser that demonstrate the use of the packages.
-
Add a command to the language server that allows getting the entry point (transaction or script) parameters (#406)
🛠 Improvements
- Allow references to be returned from from scripts (#400)
- Panic with a dedicated error for out of bounds array index (#396)
📖 Documentation
📦 Dependencies
- The changes to the CBOR library have been merged, so the
replacestatement that was necessary in the last release must be removed.
v0.9.2
v0.10.0
💥 Breaking Changes
Contract Deployment
This release adds support for deploying multiple contracts per account.
The API for deploying has changed:
-
The functions
AuthAccount.setCodeandAuthAccount.unsafeNotInitializingSetCodewere removed (#390). -
A new contract management API has been added, which allows adding, updating, and removing multiple contracts per account (#333, #352).
See the updated documentation for details and examples.
⭐ Features
Enumerations
This release adds support for enumerations (#344).
For example, a days-of-the-week enum can be declared though:
enum Day: UInt8 {
case Monday
case Tuesday
case Wednesday
case Thursday
case Friday
case Saturday
case Sunday
}See the documentation for further details and examples.
Switch Statement
This release adds support for switch statements (#365).
fun describe(number: Int): String {
switch number {
case 1:
return "one"
case 2:
return "two"
default:
return "other"
}
}See the documentation for further details and examples.
Code Formatter
Development of a code formatter has started, in form of a plugin for Prettier (#348).
If you would like to contribute, please let us know!
🛠 Improvements
- Limitations on data structure complexity are now enforced when decoding and also when encoding storage data, e.g number of array elements, number of dictionary entries, etc. (#370)
- Using the force-unwrap operator on a non-optional is no longer an error, but a hint is reported suggesting the removal of the unnecessary operation (#347)
- Language Server: The features requiring a Flow client connection are now optional. This allows using the language server in editors other than Visual Studio Code, such as Emacs, Vim, etc. (#303)
🐞 Bug Fixes
- Fixed the encoding of bignums in storage (#370)
- Fixed the timing of recording composite-type explicit-conformances (#356)
- Added support for exporting and JSON encoding/decoding of type values and capabilities (#374)
- Added support for exporting/importing and JSON encoding/decoding of path values (#319)
- Fixed the handling of empty integer literals in the checker (#354)
- Fixed the non-storable fields error (#350)
📖 Documentation
- Added a roadmap describing planned features and ideas (#367)
- Various documentation improvements (#385). Thanks to @andrejtokarcik for contributing this!
📦 Dependencies
This release depends on a fork of the CBOR library that Cadence uses.
When importing Cadence in another Go codebase, add the following statement to the go.mod file:
replace github.com/fxamacker/cbor/v2 => github.com/turbolent/cbor/v2 v2.2.1-0.20200911003300-cac23af49154
v0.9.0
🛠 Improvements
- Add struct as supported event parameter type (#364)
- Make recursive types storable (#329)
- Suggest replacing number conversion function calls (#346)
⭐ Features
- Add
mapfunction for optionals (#299)
💥 Breaking Changes
- Require an explicit type annotation for variable declarations with empty literal expressions (#345)
🐞 Bug Fixes
- Fix parsing of right bitwise shift and function invocation where type argument is instantiation (#378)
📖 Documentation
-
Refactor the documentation (#380).
The new documentation is more accessible and available at https://docs.onflow.org/cadence/language
v0.8.2
v0.8.1
v0.8.0
This release focuses on improvements, bug fixes, and bringing the documentation up-to-date.
🛠 Improvements
-
Improved support on Windows: Treat carriage returns as space (#304)
-
Improved JSON marshalling for more AST elements (#292, #286)
-
Recursively check if assignment target expression is valid, don't copy returned values (#288)
-
Consider existing prefix when suggesting completion items (#285)
-
Include available declarations in "not declared" error (#280)
-
Enforce the requirement for types to be storable in more places:
- Transaction/script parameter types (#305)
- Script return type (#291)
- Arguments passed to the account
loadandstorefunctions (#251)
Previously, using non-storable failed at run-time, now the programs are rejected statically.
⭐ Features
- Add a version constant (#289)
- Language Server: Include error notes as related information in diagnostic (#276)
🐞 Bug Fixes
- Don't return an error when a location type is not supported (#290)
- Handle incomplete types in checker (#284)
- Fix the suggestion in the error when an interface is used as a type (#281)
📖 Documentation
- Brought the documentation up-to-date, include all new language features and API changes (#275, #277, #279)
💥 Breaking Changes
-
Arguments passed to
cadence.Value#WithTypeare now typed as pointers (*cadence.Type) rather than values (cadence.Type)Example:
myEventType := cadence.EventType{...}) // this 👇 myEvent := cadence.NewEvent(...).WithType(myEventType) // changes to this 👇 myEvent := cadence.NewEvent(...).WithType(&myEventType)
v0.7.0
This release contains a lot of improvements to the language server, which improve the development experience in the Visual Studio Code extension, and will also soon be integrated into the Flow Playground.
⭐ Features
-
Added member completion to the language server (#257)
-
Enabled running the language server in the browser by compiling it to WebAssembly (#242)
-
Added support for pragmas to the parser (#239)
-
Started a source compatibility suite (#226, #270).
Cadence will be regularly checked for compatibility with existing code to ensure it does not regress in source compatibility and performance. As a start, the Fungible Token standard and Non-Fungible Token standard repositories are checked.
Consider requesting your repository to be included in the compatibility suite!
-
Added a simple minifier (#252)
🛠 Improvements
- Made embedding the language server easier (#274, #262)
- Extended the JSON serialization for Cadence values and types (#260, #264, #265, #266, #271, #273)
- Improved conformance checking (#245). Made return types covariant, i.e. allow subtypes for return types of functions to satisfy interface conformance.
💥 Breaking Changes
- Made strings immutable (#269)
- Moved the Visual Studio Code extension to a new repository: https://github.com/onflow/vscode-flow (#244)
- Added a magic prefix to stored data (#236).
This allows versioning the data. Existing data without a prefix is migrated automatically - Changed the order in which fields in values and types are exported to declaration order (#272)
🐞 Bug Fixes
- Removed the service account from the list of usable accounts in the language server (#261)
- Fixed a parsing ambiguity for return types (#267)
- Fixed non-composite reference subtyping (#253)
🧰 Maintenance
- Removed the old parser (#249)
v0.6.0
This is a small release with some bug fixes, internal improvements, and one breaking change for code that embeds Cadence.
💥 Breaking Changes
-
Removed the unused
controllerparameter from the storage interface methods:-
func GetValue(owner, controller, key []byte) (value []byte, err error)
→func GetValue(owner, key []byte) (value []byte, err error) -
SetValue(owner, controller, key, value []byte) (err error)
→SetValue(owner, key, value []byte) (err error) -
ValueExists(owner, controller, key []byte) (exists bool, err error)
→ValueExists(owner, key []byte) (exists bool, err error)
This is only a breaking change in the implementation of Cadence, i.e for code that embeds Cadence, not in the Cadence language, i.e. for users of Cadence.
-
⭐ Features
-
Added an optional callback for writes with high-level values to the interface:
type HighLevelStorage interface { // HighLevelStorageEnabled should return true // if the functions of HighLevelStorage should be called, // e.g. SetCadenceValue HighLevelStorageEnabled() bool // SetCadenceValue sets a value for the given key in the storage, owned by the given account. SetCadenceValue(owner Address, key string, value cadence.Value) (err error) }
This is a feature in the implementation of Cadence, i.e for code that embeds Cadence, not in the Cadence language, i.e. for users of Cadence.
🛠 Improvements
- Don't report an error for a restriction with an invalid type
- Record the occurrences of types. This enables the "Go to definition" feature for types in the language server
- Parse member expressions without a name. This allows the checker to run. This will enable adding code completion support or members in the future.
🐞 Bug Fixes
- Fixed a crash when checking the invocation of a function on an undeclared variable
- Fixed handling of functions in composite values in the JSON-CDC encoding
- Fixed a potential stack overflow when checking member storability