Unverified Commit 2b3d47c7 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Minor improvements (#710)

* Fix nightly clippy warning: `inconsistent_struct_constructor`

* Provide suggestion for fixing unitialized execution context

* Ensure consistent versioning

* Fix typos
parent 71d38166
Pipeline #126461 failed with stages
in 41 minutes and 55 seconds
......@@ -257,7 +257,7 @@ impl<E, Callee, TransferredValue, Args, RetType>
where
E: Environment,
{
/// Sets the maximumly allowed gas costs for the call.
/// Sets the maximum allowed gas costs for the call.
#[inline]
pub fn gas_limit(
self,
......
......@@ -43,12 +43,15 @@ use core::convert::TryInto;
use ink_primitives::Key;
use num_traits::Bounded;
const UNITIALIZED_EXEC_CONTEXT: &str = "unitialized execution context: \
a possible source of error could be that you are using `#[test]` instead of `#[ink::test]`.";
impl EnvInstance {
/// Returns the callee account.
fn callee_account(&self) -> &Account {
let callee = self
.exec_context()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.callee
.clone();
self.accounts
......@@ -60,7 +63,7 @@ impl EnvInstance {
fn callee_account_mut(&mut self) -> &mut Account {
let callee = self
.exec_context()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.callee
.clone();
self.accounts
......@@ -163,9 +166,7 @@ impl EnvBackend for EnvInstance {
where
R: scale::Encode,
{
let ctx = self
.exec_context_mut()
.expect("uninitialized execution context");
let ctx = self.exec_context_mut().expect(UNITIALIZED_EXEC_CONTEXT);
ctx.output = Some(return_value.encode());
std::process::exit(flags.into_u32() as i32)
}
......@@ -284,7 +285,7 @@ impl EnvInstance {
impl TypedEnvBackend for EnvInstance {
fn caller<T: Environment>(&mut self) -> Result<T::AccountId> {
self.exec_context()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.caller::<T>()
.map_err(|_| scale::Error::from("could not decode caller"))
.map_err(Into::into)
......@@ -292,7 +293,7 @@ impl TypedEnvBackend for EnvInstance {
fn transferred_balance<T: Environment>(&mut self) -> Result<T::Balance> {
self.exec_context()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.transferred_value::<T>()
.map_err(|_| scale::Error::from("could not decode transferred balance"))
.map_err(Into::into)
......@@ -313,7 +314,7 @@ impl TypedEnvBackend for EnvInstance {
fn gas_left<T: Environment>(&mut self) -> Result<T::Balance> {
self.exec_context()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.gas::<T>()
.map_err(|_| scale::Error::from("could not decode gas left"))
.map_err(Into::into)
......@@ -321,7 +322,7 @@ impl TypedEnvBackend for EnvInstance {
fn block_timestamp<T: Environment>(&mut self) -> Result<T::Timestamp> {
self.current_block()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.timestamp::<T>()
.map_err(|_| scale::Error::from("could not decode block time"))
.map_err(Into::into)
......@@ -329,7 +330,7 @@ impl TypedEnvBackend for EnvInstance {
fn account_id<T: Environment>(&mut self) -> Result<T::AccountId> {
self.exec_context()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.callee::<T>()
.map_err(|_| scale::Error::from("could not decode callee"))
.map_err(Into::into)
......@@ -351,7 +352,7 @@ impl TypedEnvBackend for EnvInstance {
fn block_number<T: Environment>(&mut self) -> Result<T::BlockNumber> {
self.current_block()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.number::<T>()
.map_err(|_| scale::Error::from("could not decode block number"))
.map_err(Into::into)
......@@ -453,7 +454,7 @@ impl TypedEnvBackend for EnvInstance {
T: Environment,
{
self.current_block()
.expect("uninitialized execution context")
.expect(UNITIALIZED_EXEC_CONTEXT)
.random::<T>(subject)
.map_err(Into::into)
}
......
......@@ -80,7 +80,7 @@ where
{
/// Initializes the topics builder and informs it about how many topics it must expect to serialize.
///
/// The number of expected topics is given implicitely by the `E` type parameter.
/// The number of expected topics is given implicitly by the `E` type parameter.
pub fn build<Event: Topics>(
mut self,
) -> TopicsBuilder<<Event as Topics>::RemainingTopics, E, B> {
......
......@@ -468,7 +468,7 @@ where
return None
}
// At this point we know that the entry is occupied with a value.
let new_vacant_entry = Entry::Vacant(VacantEntry { prev, next });
let new_vacant_entry = Entry::Vacant(VacantEntry { next, prev });
let taken_entry = core::mem::replace(entry_mut, new_vacant_entry);
self.update_neighboring_vacant_entry_links(prev, next, at);
// Take the value out of the taken occupied entry and return it.
......@@ -514,7 +514,7 @@ where
// Precompute prev and next vacant entries as we might need them later.
// Due to borrow checker constraints we cannot have this at a later stage.
let (prev, next) = self.fetch_prev_and_next_vacant_entry(at);
let new_vacant_entry = Entry::Vacant(VacantEntry { prev, next });
let new_vacant_entry = Entry::Vacant(VacantEntry { next, prev });
self.entries.put(at, Some(new_vacant_entry));
self.update_neighboring_vacant_entry_links(prev, next, at);
use core::cmp::min;
......
[package]
name = "contract_terminate"
version = "3.0.0-rc1"
version = "3.0.0-rc2"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
ink_primitives = { version = "3.0.0-rc1", path = "../../crates/primitives", default-features = false }
ink_metadata = { version = "3.0.0-rc1", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc1", path = "../../crates/env", default-features = false }
ink_storage = { version = "3.0.0-rc1", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc1", path = "../../crates/lang", default-features = false }
ink_primitives = { version = "3.0.0-rc2", path = "../../crates/primitives", default-features = false }
ink_metadata = { version = "3.0.0-rc2", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc2", path = "../../crates/env", default-features = false }
ink_storage = { version = "3.0.0-rc2", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
......
[package]
name = "contract_transfer"
version = "3.0.0-rc1"
version = "3.0.0-rc2"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
ink_primitives = { version = "3.0.0-rc1", path = "../../crates/primitives", default-features = false }
ink_metadata = { version = "3.0.0-rc1", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc1", path = "../../crates/env", default-features = false }
ink_storage = { version = "3.0.0-rc1", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc1", path = "../../crates/lang", default-features = false }
ink_primitives = { version = "3.0.0-rc2", path = "../../crates/primitives", default-features = false }
ink_metadata = { version = "3.0.0-rc2", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc2", path = "../../crates/env", default-features = false }
ink_storage = { version = "3.0.0-rc2", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment