Odra 0.8.0: Business Class
Changed
- Replaced
contract_env::
withself.env()
in the contract context (of typeContractEnv
).
For example, instead ofcontract_env::caller()
useself.env.caller()
. - Replaced
test_env
withodra_test::env()
in the test context (of typeHostEnv
). - It is no longer possible to put a Mapping inside a Mapping. Use tuple keys instead, for example, instead of
allowances: Mapping<Address, Mapping<Address, U256>>
useallowances: Mapping<(Address, Address), U256>
. Ref
has been divided into two:HostRef
andContractRef
depending on the context.- Storage keys are constructed differently, keep that in mind when querying the storage outside the contract.
token_balance(address: Address)
in test context is nowbalance_of(address: &Address)
.- Modules needs to be wrapped in SubModule<> when used in another module.
HostRef
(formerlyRef
) methods parameters accept values even if endpoints expect references.unwrap_or_revert
andunwrap_or_revert_with
now require&HostEnv
as a first parameter.Variable
has been renamed toVar
.- Spent Gas is taken into account when checking an account balance.
This means that all calls appear to cost 0 gas to the test accounts,
but it is still possible to check the costs of the calls. - Various changes of method signatures in
odra-modules
, e.g.&[U256]
changed toVec<U256>
inon_erc1155_batch_received
method. get_block_time()
now returnsu64
instead of wrapped typeBlocktime(u64)
.- The
name
property inOdra.toml
is not required anymore. odra-casper-backend
crate is nowodra-casper-wasm-env
odra-mock-vm
crate is nowodra-vm
odra-proc-macros
is the only code generation point.
Removed
- Removed
#[odra::init]
macro - now only one method can be a constructor,
and it has to be namedinit
. - Removed
emit()
method from events. Useself.env.emit_event(event)
instead. - Removed
assert_events!
macro. Useenv.emitted_event
and similar methods instead. - Removed
native_token_metadata()
and its respective structs. - Removed
assert_exception!
macro. Usetry_
prefix for endpoints instead. It returns aResult
which can be used with a regularassert_eq!
macro.` - Removed
odra(using)
macro. - Removed
default()
method fromDeployer
. Useinit()
instead. - Removed
StaticInstance
andDynamicInstance
traits. UseModule
instead. - Removed
Node
trait. - Removed
odra-types
,odra-ir
,odra-codegen
,odra-casper-backend
,odra-casper-shared
,odra-utils
crates. - Removed
OdraEvent
trait,odra
reexportscasper_event_standard
crate instead.
Added
last_call()
in test env withContractCallResult
struct which holds all information about the last call.odra::prelude::*
module which reexports all basic types and traits.
It is recommended to use it in the module code.odra-test
crate providingHostEnv
for testing purposes.odra-core
crate providing framework core functionalities.odra-casper-rcp-client
crate providingCasperClient
for interacting with Casper node.odra-casper-livenet-env
crate providing a host environment fo for the Casper livenet.HostRef
trait - a host side reference to a contract.HostRefLoader
trait for loading a contract from the host environment.EntryPointsCallerProvider
trait.Deployer
trait - a struct implementing that trait can deploy a contract.InitArgs
trait - a struct implementing that trait can be used as a constructor argument.NoArgs
struct, an implementation ofInitArgs
for empty/none (no constructor) arguments.
Very Brief Upgrade Path
- Copy
bin
folder andbuild.rs
files from a freshly generated project
usingcargo-odra
at version at least0.1.0
. - Update
Cargo.toml
by removing features and adding [[bin]] sections (SeeCargo.toml
from generated project). - Update the code to reflect changes in the framework.
Full Changelog: 0.7.1...0.8.0