- Set minimum Rust version to 1.66.
- Fix bug in
StateMap::get_mut
, which allowed multiple mutable references to the state to coexist.- The signature has changed using
&self
to using&mut self
.
- The signature has changed using
- Deprecate the
test_infrastructure
module in favour of concordium-smart-contract-testing.- Several traits are also deprecated as they are only needed when using the
test_infrastructure
for testing. - Among the traits are
HasHost
,HasStateApi
,HasInitContext
,HasReceiveContext
.- They are replaced by concrete types, e.g.
Host
,StateApi
, etc. in the documentation and nearly all example contracts.
- They are replaced by concrete types, e.g.
- Add a section in the library documentation about how to migrate your contracts and tests.
- Several traits are also deprecated as they are only needed when using the
- Support adding attribute
#[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 attribute
#[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. - Support protocol 6 smart contract extensions. In particular the
HasHost
trait is extended with two additional host operations,account_public_keys
andcheck_account_signature
corresponding to the two new host functions available in protocol 6. Two new types were added to support these operations,AccountSignatures
andAccountPublicKeys
. - Contract state no longer needs to implement
StateClone
trait in order to work with test infrastructure.StateClone
itself is completely removed
- Set minimum Rust version to 1.65.
- Move
MetadataUrl
from the CIS-2 library toconcordium-std
along with the schema and serialization to make it available to other CIS standards. - Change the
MetadataUrl
schema: use hex string representation forhash
. - Introduce a new method
block_time
as an alias toslot_time
in theHasChainMetadata
trait.
- Add
write_root
helper function to write the root of the state trie. This is useful in migrations when upgrading smart contracts. - Bump Rust edition to
2021
. - Remove the use of
alloc_error_handler
since the feature is no longer available in recent nightly builds of the compiler. This can increase the smart contract size slightly. - Set minimum Rust version to 1.60.
- Bump contracts-common to 5.3.1.
- 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
field 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
. - Add
StateBuilder::new_state_container
method which allows contract developers to use their own container types atop blockchain storage - Move the type
AccountBalance
toconcordium-contracts-common
.
- Fix testing of crypto primitives using secp256k1 signature scheme.
wee_alloc
is no longer set as the allocator inconcordium-std
but can be enabled via the featurewee_alloc
. The consequence is that unlessstd
feature is enabled eitherwee_alloc
must be enabled, or another global allocator must be set in the smart contract. Instd
builds, unlesswee_alloc
feature is used, the allocator provided by the Rust standard library is used.
- Add a new primitive
get_random
for generating random numbers in Wasm code testing;get_random
can be used in tests only, not available for smart contracts on the chain. - Fix a linking issue when compiling contracts to native code on Windows and OSX.
- Add
upgrade
method toHasHost
for upgrading a smart contract instance to use a new smart contract module. - Support mocking
upgrade
calls inTestHost
. Anupgrade
is mocked by specifying a module reference and aUpgradeResult
as the outcome of upgrading to this module. - Add the chain queries
account_balance
,contract_balance
andexchange_rates
toHasHost
for querying balances and the current exchange rates. - Support mocking chain queries
account_balance
,contract_balance
andexchange_rates
inTestHost
. For each parameter a corresponding response can be setup.
- Add rollback functionality to the
TestHost
.- Add a function
TestHost::with_rollback
for calling receive functions, which rolls back the host and state if the receive function returns an error. - Add a
StateClone
trait.- The
TestHost
requires theState
to implementStateClone
(breaking change). StateClone
is implemented for allClone
types, and can be derived similarly toDeserialWithState
.
- The
- Add the method
cursor_position
to theSeek
trait.
- Add a function
- Change SchemaType implementation for cryptographic primitives to ByteArray, meaning that the primitives(e.g., hashes and signatures) are now supplied as hex strings in JSON.
- Add
Seek
requirement forHasParameter
. - Implement
Seek
forExternParameter
. - Add wrapper type
TestParameterCursor
instead of exposingCursor
directly, when usingTestContext
. This is changing the type returned byparameter_cursor
forTestContext
, but provides the same interface. - Make using policies more ergonomic
- Add
attributes
method toHasPolicy
that gives an iterator over(AttributeTag, AttributeValue)
. - Change
OwnedPolicy
to useAttributeValue
instead ofOwnedAttributeValue
(breaking change)
- Add
- Remove support for v0 smart contracts and add support for v1:
- Replace message passing with synchronous calls:
- Remove the
Action
type. - Add
HasHost
, which has (synchronous) functions for making transfers,invoke_transfer
, and calling other contracts,invoke_contract
.
- Remove the
- Enable arbitary, serializable, return values for contract functions.
- Overhaul test infrastructure to support v1 contracts:
- Add ability to mock contract invocations.
- Add a number of helper functions and types to ease testing.
- Change of the contract state works
- Make the state a tree of byte arrays instead of a bytearray.
- Remove the 16kb limit to state size.
- Introduce high-level abstractions over the new state, including the
StateBuilder
,StateMap
,StateSet
, andStateBox
. - Add new traits for the low-level state interaction:
HasStateApi
andHasStateEntry
.
- The Seek trait now works with i32 instead of i64. This is more efficient, and sufficient for the target architecture.
- Replace message passing with synchronous calls:
- Expose the module of primitive host functions with an unsafe API.
- Add cryptographic primitives:
- Add a new attribute
crypto-primitives
(on both init and receive functions), which gives the function an additional parameter,&impl HasCryptoPrimitives
. - Add the trait
HasCryptoPrimitives
with two implementations (host-backed + test). - For the test implementation, the default option uses mocks. But the actual implementations can be used if you enable the feature
crypto-primitives
. - Add new feature flag
crypto-primitives
.
- Add a new attribute
- Update references to token to match token name (CCD).
- Improve
claim_eq
andclaim_ne
macros such that:- Arguments are only evaluated once.
- Type inference works as you would expect.
- Add error codes for the new cases in NewContractNameError and NewReceiveNameError:
NewContractNameError::ContainsDot
is mapped toi32::MIN + 9
NewContractNameError::InvalidCharacters
is mapped toi32::MIN + 10
NewReceiveNameError::InvalidCharacters
is mapped toi32::MIN + 11
- Change error code for when a contract that was not marked as payable received
tokens. The error code is now
i32::MIN + 12
, changed from the previous-1
. - Export
HashMap
andHashSet
fromcontract-common
incollections
module. - Added implementation of
SerialCtx
forVec
. - Export
Box
when nostd
feature. - Bump minimum supported Rust version to 1.51.
- Deriving SchemaType supports types with generics.
- Make Write implementation for ContractStateTest resize the state automatically to be consistent with the Write implementation for ContractState.
- Use little-endian encoding for sender contract addresses in receive contexts. This reverts the change in concordium-std 0.4.1.
- Change the
receive_name
parameter ofHasActions::send
to useReceiveName
instead ofstr
. - Rename
send
tosend_raw
inHasActions
. - Rename
log_bytes
tolog_raw
inHasLogger
. - Add
send
, a wrapper forHasActions::send_raw
, which automatically serializesparameter
(usingSerial
). - Allow init and receive methods to return custom error codes that will be displayed to the user if a smart-contract invocation fails.
- Add i128 and u128 support to serialization and schema.
- Fix endianness mismatch when getting the sender contract address.
- Add PhantomData Serial/Deserial implementation.
- Add ContractStateTest wrapper with a HasContractState implemenation to enable testing with a low-level interface.
- Remove some chain details from ChainMetadata. Only the slot time remains.
-
A trait
ExpectErrReport
with a methodexpect_err_report
that works analogously to the expect_err and expect_none methods on the Result and Option types, respectively, except it invokes the fail macro instead of panic.