Releases: onflow/cadence
v1.0.0-preview-atree-register-inlining.24
What's Changed
π₯ Go API Breaking Chance
- Unexport fields to prevent access by index by @turbolent in #3290
- Remove Value.ToGoValue and NewValue by @turbolent in #3291
π Improvements
- Add runtime check for transaction value moves by @SupunS in #3298
- Add predicate function and test for atree's PersistentSlabStorage.FixLoadedBrokenReferences by @turbolent in #3300
Other Changes
- Merge
release/v1.0.0-preview.23
tomaster
by @github-actions in #3289 - Update update tool config by @turbolent in #3292
- Bump atree version in master branch by @fxamacker in #3293
- Bump atree version in feature/atree-register-inlining-v1.0 by @fxamacker in #3295
- Update atree inlining v1.0 feature branch by @turbolent in #3301
Full Changelog: v1.0.0-preview-atree-register-inlining.23...v1.0.0-preview-atree-register-inlining.24
v1.0.0-preview.24
What's Changed
π₯ Go API Breaking Chance
The API of the Go package cadence
improved. These changes only impact users of the Go API of Cadence. These changes had no impact on the language itself or programs written in Cadence.
-
It is no longer possible to access composite fields (
cadence.Composite
types, likecadence.Struct
,cadence.Resource
, etc) by index. TheFields
field got unexported.Details:
- Accessing fields by index makes code dependent on the order of fields in the Cadence type definition, which may change (order is insignificant)
- The order of fields of composite values returned from the chain (e.g. from a script) is planned to be made deterministic in the future. The Go API change prepares for this upcoming encoding change. For more details see #2952
- Accessing fields by name improves code, as it removes possibilities for extracting field values incorrectly (by wrong index)
- There are two ways to get the value of a composite field:
-
If multiple field values are needed from the composite value,
usecadence.FieldsMappedByName
, which returns amap[string]cadence.Value
.For example:
const fooTypeSomeIntFieldName = "someInt" const fooTypeSomeStringFieldName = "someString" // decodeFooEvent decodes the Cadence event: // // event Foo(someInt: Int, someString: String) // // It returns an error if the event does not have the expected fields. func decodeFooEvent(event cadence.Event) (someInt cadence.Int, someString cadence.String, err error) { fields := cadence.FieldsMappedByName(event) var ok bool someIntField := fields[fooTypeSomeIntFieldName] someInt, ok = someIntField.(cadence.Int) if !ok { return cadence.Int{}, "", fmt.Errorf("wrong field type: expected Int, got %T", someInt) } someStringField := fields[fooTypeSomeStringFieldName] someString, ok = someStringField.(cadence.String) if !ok { return cadence.Int{}, "", fmt.Errorf("wrong field type: expected String, got %T", someString) } return someInt, someString, nil }
-
If only a single field value is needed from the composite,
usecadence.SearchFieldByName
. As the name indicates, the function performs a linear search over all fields of the composite. PreferFieldsMappedByName
over repeated calls toSearchFieldByName
.
For example:const fooTypeSomeIntFieldName = "someInt" // fooEventSomeIntField gets the value of the someInt field of the Cadence event: // // event Foo(someInt: Int) // // It returns an error if the event does not have the expected field. func fooEventSomeIntField(event cadence.Event) (cadence.Int, error) { someIntField := cadence.SearchFieldByName(event, fooTypeSomeIntFieldName) someInt, ok := someIntField.(cadence.Int) if !ok { return cadence.Int{}, fmt.Errorf("wrong field type: expected Int, got %T", someInt) } return someInt, nil }
-
-
cadence.GetFieldByName
got renamed tocadence.SearchFieldByName
to make it clear that the function performs a linear search -
cadence.GetFieldsMappedByName
got renamed tocadence.FieldsMappedByName
, to better follow common Go style / naming guides, e.g. https://google.github.io/styleguide/go/decisions#getters -
The convenience method
ToGoValue
ofcadence.Value
, which converts acadence.Value
into a Go value (if possible), got removed. Likewise, the convenience functioncadence.NewValue
, which constructs a newcadence.Value
from the given Go value (if possible), got removed.Details:
- There are many different use cases and needs for methods that convert between Cadence and Go values. When attempting to convert an arbitrary Cadence value into a Go value, there is no "correct" Go type to return in all cases. Likewise, when attempting to convert an arbitrary Go value to Cadence, there might not be a βcorrectβ result type.
- Developers might expect a certain Go type to be returned. For example,
ToGoValue
ofcadence.Struct
returned a Go slice, but some developers might assume and want a Go map; andToGoValue
ofcadence.Dictionary
returned a Go map, but did not account for the case where dictionary keys in Cadence might be types that are invalid in Go maps. - As the return type of
ToGoValue
isany
, developers using the method need to cast to some expected Go type, and hope the returned value is what they expect. - Improvements in the implementation of
ToGoValue
, like in #2531, would have silently broken programs using the function, as the different return value would have no longer matched the developerβs expected type. - Even though these methods and functions got removed from the
cadence
package, developers can still perform the conversion that theToGoValue
methods performed. A future version of Cadence might re-introduce well-defined and strongly-typed conversion functions, that are also consistent with similar conversion functions in other languages (e.g. JavaScript SDK / FCL). - To see what the removed functions and methods did, have a look at the PR that removed them: https://github.com/onflow/cadence/pull/3291/files.
- If you feel like Cadence should re-gain this functionality, please open a feature request, or even consider contributing them through pull requests
π Improvements
- Add runtime check for transaction value moves by @SupunS in #3298
- Add predicate function and test for atree's PersistentSlabStorage.FixLoadedBrokenReferences by @turbolent in #3300
Other Changes
- Merge
release/v1.0.0-preview.23
tomaster
by @github-actions in #3289 - Update update tool config by @turbolent in #3292
- Bump atree version in master branch by @fxamacker in #3293
Full Changelog: v1.0.0-preview.23...v1.0.0-preview.24
v1.0.0-preview.23
What's Changed
β Features
π Improvements
π Bug Fixes
- Handle account types in contract update validator by @SupunS in #3284
- Fix restricted typed field updates by @SupunS in #3283
Other Changes
- Adding staged contracts migration output JSON from Apr 17 to migratio⦠by @j1010001 in #3273
- Merge
release/v1.0.0-preview.22
tomaster
by @github-actions in #3279 - Adjust branches of downstream dependency checks by @turbolent in #3280
- Replace colons in staged contract reports by @jribbink in #3281
- Adding migration result for Testnet state from Apr 24 by @j1010001 in #3285
- Add basic stats and section on newly failing contracts by @j1010001 in #3286
New Contributors
Full Changelog: v1.0.0-preview.22...v1.0.0-preview.23
v1.0.0-preview-atree-register-inlining.23
What's Changed
β Features
π Improvements
π Bug Fixes
- Handle account types in contract update validator by @SupunS in #3284
- Fix restricted typed field updates by @SupunS in #3283
Other Changes
- Adding staged contracts migration output JSON from Apr 17 to migratio⦠by @j1010001 in #3273
- Merge
release/v1.0.0-preview.22
tomaster
by @github-actions in #3279 - Adjust branches of downstream dependency checks by @turbolent in #3280
- Replace colons in staged contract reports by @jribbink in #3281
- Adding migration result for Testnet state from Apr 24 by @j1010001 in #3285
- Add basic stats and section on newly failing contracts by @j1010001 in #3286
New Contributors
Full Changelog: v1.0.0-preview-atree-register-inlining.22...v1.0.0-preview-atree-register-inlining.23
v1.0.0-preview.22
What's Changed
π₯ Language Breaking Changes
- Implement FLIP 242 by @dsainati1 in #3252
- Implement FLIP 262 by @turbolent in #3247
- Fix optional type ID ambiguity and migrate types by @dsainati1 in #3272
- Improve supported entitlements and entitlements inferrence in migration by @turbolent in #3266
π Improvements
- Improve conformance mismatch error by @turbolent in #3274
- Further improve conformance error by including location by @turbolent in #3277
- Remove unused parameter by @turbolent in #3278
- Cache results of entitlement type conversion by @dsainati1 in #3232
Other Changes
- Merge
release/v1.0.0-preview.21
tomaster
by @github-actions in #3269 - Adding migration result for staged contracts migration, testnet, Apri⦠by @j1010001 in #3263
Full Changelog: v1.0.0-preview.21...v1.0.0-preview.22
v1.0.0-preview-atree-register-inlining.22
What's Changed
π₯ Language Breaking Changes
- Implement FLIP 242 by @dsainati1 in #3252
- Implement FLIP 262 by @turbolent in #3247
- Fix optional type ID ambiguity and migrate types by @dsainati1 in #3272
- Improve supported entitlements and entitlements inferrence in migration by @turbolent in #3266
π Improvements
- Improve conformance mismatch error by @turbolent in #3274
- Further improve conformance error by including location by @turbolent in #3277
- Remove unused parameter by @turbolent in #3278
- Cache results of entitlement type conversion by @dsainati1 in #3232
Other Changes
Full Changelog: v1.0.0-preview-atree-register-inlining.21...v1.0.0-preview-atree-register-inlining.22
v1.0.0-preview.21
What's Changed
π Improvements
- Improve dictionary key conflict handling by @turbolent in #3240
- Improve supported entitlements by @turbolent in #3251
π Bug Fixes
- Introduce special self-variable by @SupunS in #3235
- Fix type indexing resource loss by @SupunS in #3257
- Fix resource-loss check in dictionary set-key by @SupunS in #3267
π§ͺ Testing
- Add a test case for non-public interface members by @turbolent in #3260
Other Changes
- Merge
release/v1.0.0-preview.20
tomaster
by @github-actions in #3239 - Tool for converting staged contracts migration report from JSON to Markdown by @SupunS in #3249
- Bump atree version in master branch by @fxamacker in #3254
- Fix staged contracts report printer - update JSON field names by @j1010001 in #3262
Full Changelog: v1.0.0-preview.20...v1.0.0-preview.21
v1.0.0-preview.20
What's Changed
π₯ Language Breaking Changes
- Remove ability to dereference arrays or dicts of structs by @dsainati1 in #3221
π Improvements
- Check resource loss in
CompositeValue.RemoveField
by @turbolent in #3224 - Check resource loss in all variable assignments by @turbolent in #3226
- Introduce a dedicated error for unreferenced slabs and expose the IDs by @turbolent in #3231
- Move conflicting dictionary key to new dictionary in unique storage path by @turbolent in #3227
π Bug Fixes
- Handle missing type arguments in type argument checks by @turbolent in #3234
- Clear
inAssignment
when recursing into subexpressions by @dsainati1 in #3236
Other Changes
- Merge
release/v1.0.0-preview.19
tomaster
by @github-actions in #3217
Full Changelog: v1.0.0-preview.19...v1.0.0-preview.20
v0.42.10
What's Changed
π Improvements
- Port #3231 to v0.42 by @turbolent in #3237
π Bug Fixes
- Handle optional storage references by @turbolent in #3094
Full Changelog: v0.42.9...v0.42.10
v1.0.0-preview.19
What's Changed
π Improvements
- Improve Cadence 1.0 state migration by @turbolent in #3211
π Bug Fixes
- Properly handle
Never
type argument toCapabilities.get
by @dsainati1 in #3203 - Add
TypeArgumentsCheck
s to certain builtin functions by @dsainati1 in #3208 - Proper type checking for resource use after validation on two-value transfers by @dsainati1 in #3176
- Convert references based on borrow type by @SupunS in #3213
- Fix migration of built-in types by @turbolent in #3205
- Resource Reference Invalidation Improvements by @dsainati1 in #3181
- Fix built-in type import by @turbolent in #3212
- Fix dereferencing non-reference type by @turbolent in #3216
- Port fixes of v0.42.8-patch.4 by @turbolent in #3079
Other Changes
- Merge
release/v1.0.0-preview.18
tomaster
by @github-actions in #3202
Full Changelog: v1.0.0-preview.18...v1.0.0-preview.19