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

Fix nightly clippy errors (#921)

* Fix `clippy::derivable_impls`

* Fix `dead_code`

The `struct` is only a public-facing API.

* Get rid of `allow(dead_code)`

* Revert "Get rid of `allow(dead_code)`"

This reverts commit 6b9a95f9.

* Revert "Fix `dead_code`"

This reverts commit 42ab18be.

* New approach to fix `dead_code`

* Fix naming

* Reflect that `return_type` never needs to be read

* Fix typo
parent ca40fe4c
Pipeline #157785 failed with stages
in 17 minutes and 46 seconds
......@@ -33,16 +33,11 @@ use crate::{
use ink_primitives::Key;
/// The flags to indicate further information about the end of a contract execution.
#[derive(Default)]
pub struct ReturnFlags {
value: u32,
}
impl Default for ReturnFlags {
fn default() -> Self {
Self { value: 0 }
}
}
impl ReturnFlags {
/// Sets the bit to indicate that the execution is going to be reverted.
pub fn set_reverted(mut self, has_reverted: bool) -> Self {
......
......@@ -41,17 +41,11 @@ where
/// The transferred value for the call.
transferred_value: E::Balance,
/// The expected return type.
return_type: ReturnType<R>,
_return_type: ReturnType<R>,
/// The inputs to the execution which is a selector and encoded arguments.
exec_input: ExecutionInput<Args>,
}
#[cfg(
// We do not currently support cross-contract calling in the off-chain
// environment so we do not have to provide these getters in case of
// off-chain environment compilation.
all(not(feature = "std"), target_arch = "wasm32")
)]
impl<E, Args, R> CallParams<E, Args, R>
where
E: Environment,
......@@ -395,7 +389,7 @@ where
transferred_value: self
.transferred_value
.unwrap_or_else(|| E::Balance::from(0u32)),
return_type: Default::default(),
_return_type: Default::default(),
exec_input: self.exec_input.value(),
}
}
......
......@@ -67,54 +67,47 @@ where
/// The salt for determining the hash for the contract account ID.
salt_bytes: Salt,
/// The type of the instantiated contract.
return_type: ReturnType<R>,
_return_type: ReturnType<R>,
}
cfg_if::cfg_if! {
// We do not currently support cross-contract instantiation in the off-chain
// environment so we do not have to provide these getters in case of
// off-chain environment compilation.
if #[cfg(all(not(feature = "std"), target_arch = "wasm32"))] {
impl<E, Args, Salt, R> CreateParams<E, Args, Salt, R>
where
E: Environment,
{
/// The code hash of the contract.
#[inline]
pub(crate) fn code_hash(&self) -> &E::Hash {
&self.code_hash
}
impl<E, Args, Salt, R> CreateParams<E, Args, Salt, R>
where
E: Environment,
{
/// The code hash of the contract.
#[inline]
pub(crate) fn code_hash(&self) -> &E::Hash {
&self.code_hash
}
/// The gas limit for the contract instantiation.
#[inline]
pub(crate) fn gas_limit(&self) -> u64 {
self.gas_limit
}
/// The gas limit for the contract instantiation.
#[inline]
pub(crate) fn gas_limit(&self) -> u64 {
self.gas_limit
}
/// The endowment for the instantiated contract.
#[inline]
pub(crate) fn endowment(&self) -> &E::Balance {
&self.endowment
}
/// The endowment for the instantiated contract.
#[inline]
pub(crate) fn endowment(&self) -> &E::Balance {
&self.endowment
}
/// The raw encoded input data.
#[inline]
pub(crate) fn exec_input(&self) -> &ExecutionInput<Args> {
&self.exec_input
}
}
/// The raw encoded input data.
#[inline]
pub(crate) fn exec_input(&self) -> &ExecutionInput<Args> {
&self.exec_input
}
}
impl<E, Args, Salt, R> CreateParams<E, Args, Salt, R>
where
E: Environment,
Salt: AsRef<[u8]>,
{
/// The salt for determining the hash for the contract account ID.
#[inline]
pub(crate) fn salt_bytes(&self) -> &Salt {
&self.salt_bytes
}
}
impl<E, Args, Salt, R> CreateParams<E, Args, Salt, R>
where
E: Environment,
Salt: AsRef<[u8]>,
{
/// The salt for determining the hash for the contract account ID.
#[inline]
pub(crate) fn salt_bytes(&self) -> &Salt {
&self.salt_bytes
}
}
......@@ -369,7 +362,7 @@ where
endowment: self.endowment.value(),
exec_input: self.exec_input.value(),
salt_bytes: self.salt.value(),
return_type: self.return_type,
_return_type: self.return_type,
}
}
}
......
......@@ -352,14 +352,15 @@ impl TypedEnvBackend for EnvInstance {
self.engine.set_rent_allowance(buffer)
}
fn invoke_contract<T, Args>(
&mut self,
_call_params: &CallParams<T, Args, ()>,
) -> Result<()>
fn invoke_contract<T, Args>(&mut self, params: &CallParams<T, Args, ()>) -> Result<()>
where
T: Environment,
Args: scale::Encode,
{
let _gas_limit = params.gas_limit();
let _callee = params.callee();
let _transferred_value = params.transferred_value();
let _input = params.exec_input();
unimplemented!("off-chain environment does not support contract invocation")
}
......@@ -377,13 +378,18 @@ impl TypedEnvBackend for EnvInstance {
fn instantiate_contract<T, Args, Salt, C>(
&mut self,
_params: &CreateParams<T, Args, Salt, C>,
params: &CreateParams<T, Args, Salt, C>,
) -> Result<T::AccountId>
where
T: Environment,
Args: scale::Encode,
Salt: AsRef<[u8]>,
{
let _code_hash = params.code_hash();
let _gas_limit = params.gas_limit();
let _endowment = params.endowment();
let _input = params.exec_input();
let _salt_bytes = params.salt_bytes();
unimplemented!("off-chain environment does not support contract instantiation")
}
......
......@@ -442,14 +442,15 @@ impl TypedEnvBackend for EnvInstance {
.expect("could not encode rent allowance")
}
fn invoke_contract<T, Args>(
&mut self,
_call_params: &CallParams<T, Args, ()>,
) -> Result<()>
fn invoke_contract<T, Args>(&mut self, params: &CallParams<T, Args, ()>) -> Result<()>
where
T: Environment,
Args: scale::Encode,
{
let _gas_limit = params.gas_limit();
let _callee = params.callee();
let _transferred_value = params.transferred_value();
let _input = params.exec_input();
unimplemented!("off-chain environment does not support contract invocation")
}
......@@ -467,12 +468,18 @@ impl TypedEnvBackend for EnvInstance {
fn instantiate_contract<T, Args, Salt, C>(
&mut self,
_params: &CreateParams<T, Args, Salt, C>,
params: &CreateParams<T, Args, Salt, C>,
) -> Result<T::AccountId>
where
T: Environment,
Args: scale::Encode,
Salt: AsRef<[u8]>,
{
let _code_hash = params.code_hash();
let _gas_limit = params.gas_limit();
let _endowment = params.endowment();
let _input = params.exec_input();
let _salt_bytes = params.salt_bytes();
unimplemented!("off-chain environment does not support contract instantiation")
}
......
......@@ -373,7 +373,7 @@ where
self.len
}
/// Returns he number of cells each element in the array layout consists of.
/// Returns the number of cells each element in the array layout consists of.
pub fn cells_per_elem(&self) -> u64 {
self.cells_per_elem
}
......
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