Skip to content

Odra 0.8.0: Business Class

Compare
Choose a tag to compare
@zie1ony zie1ony released this 06 Feb 15:34
6c92428

Changed

  • Replaced contract_env:: with self.env() in the contract context (of type ContractEnv).
    For example, instead of contract_env::caller() use self.env.caller().
  • Replaced test_env with odra_test::env() in the test context (of type HostEnv).
  • 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>> use allowances: Mapping<(Address, Address), U256>.
  • Ref has been divided into two: HostRef and ContractRef 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 now balance_of(address: &Address).
  • Modules needs to be wrapped in SubModule<> when used in another module.
  • HostRef (formerly Ref) methods parameters accept values even if endpoints expect references.
  • unwrap_or_revert and unwrap_or_revert_with now require &HostEnv as a first parameter.
  • Variable has been renamed to Var.
  • 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 to Vec<U256>
    in on_erc1155_batch_received method.
  • get_block_time() now returns u64 instead of wrapped type Blocktime(u64).
  • The name property in Odra.toml is not required anymore.
  • odra-casper-backend crate is now odra-casper-wasm-env
  • odra-mock-vm crate is now odra-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 named init.
  • Removed emit() method from events. Use self.env.emit_event(event) instead.
  • Removed assert_events! macro. Use env.emitted_event and similar methods instead.
  • Removed native_token_metadata() and its respective structs.
  • Removed assert_exception! macro. Use try_ prefix for endpoints instead. It returns a Result
    which can be used with a regular assert_eq! macro.`
  • Removed odra(using) macro.
  • Removed default() method from Deployer. Use init() instead.
  • Removed StaticInstance and DynamicInstance traits. Use Module instead.
  • Removed Node trait.
  • Removed odra-types, odra-ir, odra-codegen, odra-casper-backend, odra-casper-shared, odra-utils crates.
  • Removed OdraEvent trait, odra reexports casper_event_standard crate instead.

Added

  • last_call() in test env with ContractCallResult 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 providing HostEnv for testing purposes.
  • odra-core crate providing framework core functionalities.
  • odra-casper-rcp-client crate providing CasperClient 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 of InitArgs for empty/none (no constructor) arguments.

Very Brief Upgrade Path

  • Copy bin folder and build.rs files from a freshly generated project
    using cargo-odra at version at least0.1.0.
  • Update Cargo.toml by removing features and adding [[bin]] sections (See Cargo.toml from generated project).
  • Update the code to reflect changes in the framework.

Full Changelog: 0.7.1...0.8.0