Releases: onflow/cadence
v0.10.3
v0.11.2
v0.10.2
v0.9.3
v0.11.1
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
replace
statement 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.setCode
andAuthAccount.unsafeNotInitializingSetCode
were 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
map
function 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