Releases: Concordium/concordium-contracts-common
concordium-contracts-common 8.0.0
Summary
This release adds support for new types and operations available in protocol 6, as well as other minor improvements.
Changes
- Add signature and key types to
concordium-contracts-common
. - Add
Display
trait toVersionedModuleSchema
to display theVersionedModuleSchema
as a JSON template. - Add
Display
trait toSchemaType
to display theSchemaType
as a JSON template. - Add associated function
from_base64_str
toVersionedModuleSchema
to easily parse from base64 - Add
NonZeroThresholdU8
, and derivedAccountThreshold
andSignatureThreshold
types. - Bump version of
concordium-contracts-common-derive
to 4.
concordium-contracts-common-derive 4.0.0
Summary
This major release adds new convenience features to derive macros that reduce the amount of boilerplate needed in many common scenarios, and removes the StateClone
derive macro.
Changes
- Fix a bug in derivation macros for
Serial
,Deserial
,DeserialWithState
andSchemaType
which incorrectly handled the case where the type hadwhere
predicates in its definition. - Support adding
#[concordium(repr(u))]
for enum types, whereu
is eitheru8
oru16
. Setting this changes the integer serialization used for the variant tags in derive macros such asSerial
,Deserial
,DeserialWithState
andSchemaType
. - Support adding
#[concordium(tag = n)]
for enum variants, wheren
is some unsigned integer literal. Setting this attribute on a variant overrides the tag used in derive macros such asSerial
,Deserial
,DeserialWithState
andSchemaType
. Note that setting#[concordium(repr(u*))]
is required when using this attribute. - Support adding
#[concordium(forward = n)]
, for enum variants, wheren
is either an unsigned integer literal,cis2_events
,cis3_events
,cis4_events
or an array of the same options.
Setting this attribute on a variant overrides the (de)serialization to flatten with the (de)serialization of the inner field when using derive macros such asSerial
,Deserial
,DeserialWithState
andSchemaType
.
Note that setting#[concordium(repr(u*))]
is required when using this attribute. derive(StateClone)
removed completely, asStateClone
trait is removed fromconcordium-std
concordium-contracts-common 7.0.0
Summary
This release brings a number of convenience improvements and error reporting.
In particular when converting JSON and binary formats using schemas, the error reporting is much improved.
Changes
- Implement
serde::Serialize
andserde::Deserialize
forDuration
using
FromStr
andDisplay
implementations, when featurederive-serde
is
enabled. - Implement Serialize any
HashBytes<Purpose>
over anyPurpose
. - Add
TryFrom
implementation to convertTimestamp
tochrono::DateTime
. - Add a
Serial
implementation for any&A
ifA: Serial
. - Set minimum Rust version to 1.65.
- Add
smart-contract
feature to enable the macros which are only suitable for smart contract development usingconcordium-std
. The feature is not enabled by default. - Add macros
Reject
,DeserialWithState
,SchemaType
,StateClone
andDeletable
,init
,receive
,concordium_test
,concordium_cfg_test
,concordium_cfg_not_test
andconcordium_quickcheck
fromconcordium_std_derive
with their related featureswasm-test
,build-schema
andconcordium-quickcheck
.
Breaking changes
- Add a new error type
ToJsonError
, which is returned when deserializing a schema type fails. - Add the member
JsonError::TraceError
toJsonError
, which has trace information for the error produced when serializing a schema type fails.
concordium-contracts-common-derive 3.0.0
Summary
This release brings a number of additions to the schema deriving macros to reduce the need for manual instances.
Changes
- Set minimum Rust version to 1.65.
- Add derive macros for
Reject
,DeserialWithState
,SchemaType
,StateClone
andDeletable
fromconcordium_std_derive
. - Add attribute macros
init
,receive
,concordium_test
,concordium_cfg_test
,concordium_cfg_not_test
andconcordium_quickcheck
fromconcordium_std_derive
with their related featureswasm-test
,build-schema
andconcordium-quickcheck
. - Deriving
Serial
,Deserial
,DeserialWithState
andSchemaType
now produces an implementation which adds a bound to each of the type parameters to implement the relevant trait.
Note thatSerial
andDeserialWithState
skips this bound forstate_parameter
when/if this is provided. This is not the behavior ofDeserial
andSchemaType
since they are incompatible withDeserialWithState
and thereforestate_parameter
is never present in these cases. - Deriving
SchemaType
will now produce an implementation even without thebuild-schema
feature being enabled. - Support adding attribute
#[concordium(transparent)]
to newtype structs causing a derivedSchemaType
to use the implementation of the single field and thereby hiding the newtype struct in the schema. - Fix error message for deriving
Deserial
andDeserialWithState
, for types with an invalid field attribute.
concordium-contracts-common 6.0.0
Summary
This release brings additional functionality and removes the sdk
feature.
The use of the library through concordium-std is unaffected, but uses through concordium-rust-sdk have
to be adapted. See changes below for details.
Changes
- Remove the
Copy
requirement for deserialization of BTreeMap and BTreeSet.
This allows using non-copyable (and non-clonable) types as map keys or set
values. - Add the method
serial_for_smart_contracts
toOwnedPolicy
, which serializes the policy for easy consumption by smart contracts. - Set minimum Rust version to 1.60.
- Set Rust edition to 2021.
- Remove the
sdk
feature.- Migrate by adding
use concordium_rust_sdk::types::smart_contracts::concordium_contracts_common as concordium_std;
in the files where you deriveSerial
orDeserial
with the help from this crate.
- Migrate by adding
concordium-contracts-common-derive 2.0.0
Summary
This release removes the sdk
feature. The use of the derive crate inside concordium-std is unaffected,
but uses through concordium-rust-sdk have to be adjusted. See changes for details.
Changes
- Set minimum Rust version to 1.60.
- Set Rust edition to 2021.
- Remove the
sdk
feature.- Migrate by adding
use concordium_rust_sdk::types::smart_contracts::concordium_contracts_common as concordium_std;
in the files where you deriveSerial
orDeserial
with the help from this crate.
- Migrate by adding
concordium-contracts-common 5.3.1
This is a minor release that adds minor helper functionality both for on and off-chain use and fixes a bug in schema JSON parsing.
Changelog
- Fix schema JSON deserialization of negative signed numbers.
- Add PartialEq implementations for comparing ReceiveName, ContractName, and EntrypointName and their owned variants to str.
concordium-contracts-common 5.3.0
This is a minor release that adds minor helper functionality both for on and off-chain use.
There are a few breaking changes, but they are minor so only the minor version is bumped. The changelog below describes the migration path if you are affected by these changes.
Changelog
- Add
Display
implementation forOwnedParameter
andParameter
, which uses
hex encoding. - Replace
From<Vec<u8>>
instance forOwnedParameter
/Parameter
with aTryFrom
,
which ensures a valid length, and the unchecked methodnew_unchecked
.- Migrate from
From
/Into
: Usenew_unchecked
instead (if known to be
valid length).
- Migrate from
- Make inner field in
OwnedParameter
/Parameter
private, but add aFrom
implementation for getting the raw bytes.- Migrate from
parameter.0
: useparameter.into()
instead (for both of the affected
types).
- Migrate from
- For
ModuleReference
, replaceAsRef<[u8;32]>
withAsRef<[u8]>
and make
innerbytes
public.- The change was necessary for internal reasons.
- Migrate from
module_reference.as_ref()
: use&module_reference.bytes
instead.
- Replace
OwnedParameter::new
withOwnedParameter::from_serial
, which also
ensures a valid length.- Migrate from
new(x)
: Usefrom_serial(x).unwrap()
(if known to be valid length).
- Migrate from
- Add an
empty
method for bothOwnedParameter
andParameter
. - Implement
Default
forParameter
. - Move
AccountBalance
from concordium-std. - Add
to_owned
method toEntrypointName
andContractName
types. - Implement
Serial
/Deserial
instances for tuples with 4, 5, and 6 elements. - Add
checked_sub
to Amount type.
concordium-contracts-common 5.2.0
This is a minor release with bugfixes for off-chain functionality and quality of life improvements.
concordium-contracts-common 5.2.0 (2023-02-08)
- Add methods
serial_value
andserial_value_into
on theType
.
They are more ergonomic to use thanwrite_bytes_from_json_schema_type
which
is marked as deprecated and will be removed in future versions. - Fix schema's
to_json
for contract addresses to that it outputs a value in
the correct{"index": ..., "subindex": ...}
format. - Add
Display
implementations forContractName
,ReceiveName
, and their
owned variants.
Release concordium-contracts-common 5.1.0
concordium-contracts-common 5.1.0 (2022-12-14)
- Implement
quickcheck::Arbitrary
forTimestamp
,AccountAddress
,ContractAddress
,Address
,ChainMetadata
,AttributeTag
,AttributeValue
andOwnedPolicy
.