Skip to content

Commit

Permalink
Remove feature gated code
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Dec 5, 2024
1 parent b195f58 commit aba84ba
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 993 deletions.
8 changes: 0 additions & 8 deletions crates/engine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ use crate::{
BlockTimestamp,
},
};
#[cfg(not(feature = "revive"))]
pub use pallet_contracts_uapi::ReturnErrorCode as Error;
#[cfg(feature = "revive")]
pub use pallet_revive_uapi::ReturnErrorCode as Error;
use scale::Encode;
use std::panic::panic_any;
Expand Down Expand Up @@ -323,11 +320,6 @@ impl Engine {
set_output(output, &block_timestamp[..])
}

#[cfg(not(feature = "revive"))]
pub fn gas_left(&self, _output: &mut &mut [u8]) {
unimplemented!("off-chain environment does not yet support `gas_left`");
}

/// Returns the minimum balance that is required for creating an account
/// (i.e. the chain's existential deposit).
pub fn minimum_balance(&self, output: &mut &mut [u8]) {
Expand Down
94 changes: 0 additions & 94 deletions crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@

//! The public raw interface towards the host Wasm engine.
#[cfg(not(feature = "revive"))]
use crate::call::{
CallV1,
LimitParamsV1,
};
use crate::{
backend::{
EnvBackend,
Expand Down Expand Up @@ -47,9 +42,6 @@ use crate::{
Result,
};
use ink_storage_traits::Storable;
#[cfg(not(feature = "revive"))]
use pallet_contracts_uapi::ReturnFlags;
#[cfg(feature = "revive")]
use pallet_revive_uapi::ReturnFlags;

/// Returns the address of the caller of the executed contract.
Expand Down Expand Up @@ -94,21 +86,6 @@ where
})
}

/// Returns the amount of gas left for the contract execution.
///
/// # Errors
///
/// If the returned value cannot be properly decoded.
#[cfg(not(feature = "revive"))]
pub fn gas_left<E>() -> Gas
where
E: Environment,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::gas_left::<E>(instance)
})
}

/// Returns the current block timestamp.
///
/// # Errors
Expand Down Expand Up @@ -268,38 +245,6 @@ where
})
}

/// Invokes a contract message and returns its result.
///
/// # Note
///
/// This is a low level way to evaluate another smart contract.
/// Prefer to use the ink! guided and type safe approach to using this.
///
/// **This will call into the original version of the host function. It is recommended to
/// use [`invoke_contract`] to use the latest version if the target runtime supports it.**
///
/// # Errors
///
/// - If the called account does not exist.
/// - If the called account is not a contract.
/// - If arguments passed to the called contract message are invalid.
/// - If the called contract execution has trapped.
/// - If the called contract ran out of gas upon execution.
/// - If the returned value failed to decode properly.
#[cfg(not(feature = "revive"))]
pub fn invoke_contract_v1<E, Args, R>(
params: &CallParams<E, CallV1<E>, Args, R>,
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
R: scale::Decode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::invoke_contract_v1::<E, Args, R>(instance, params)
})
}

/// Invokes a contract message and returns its result.
///
/// # Note
Expand Down Expand Up @@ -395,45 +340,6 @@ where
})
}

/// Instantiates another contract.
///
/// # Note
///
/// This is a low level way to instantiate another smart contract, calling the legacy
/// `instantiate_v1` host function.
///
/// Prefer to use methods on a `ContractRef` or the
/// [`CreateBuilder`](`crate::call::CreateBuilder`)
/// through [`build_create`](`crate::call::build_create`) instead.
///
/// # Errors
///
/// - If the code hash is invalid.
/// - If the arguments passed to the instantiation process are invalid.
/// - If the instantiation process traps.
/// - If the instantiation process runs out of gas.
/// - If given insufficient endowment.
/// - If the returned account ID failed to decode properly.
#[cfg(not(feature = "revive"))]
pub fn instantiate_contract_v1<E, ContractRef, Args, Salt, R>(
params: &CreateParams<E, ContractRef, LimitParamsV1, Args, Salt, R>,
) -> Result<
ink_primitives::ConstructorResult<<R as ConstructorReturnType<ContractRef>>::Output>,
>
where
E: Environment,
ContractRef: FromAccountId<E>,
Args: scale::Encode,
Salt: AsRef<[u8]>,
R: ConstructorReturnType<ContractRef>,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::instantiate_contract_v1::<E, ContractRef, Args, Salt, R>(
instance, params,
)
})
}

/// Terminates the existence of the currently executed smart contract.
///
/// This removes the calling account and transfers all remaining balance
Expand Down
49 changes: 0 additions & 49 deletions crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(not(feature = "revive"))]
use crate::call::{
CallV1,
LimitParamsV1,
};
use crate::{
call::{
Call,
Expand All @@ -36,9 +31,6 @@ use crate::{
Result,
};
use ink_storage_traits::Storable;
#[cfg(not(feature = "revive"))]
pub use pallet_contracts_uapi::ReturnFlags;
#[cfg(feature = "revive")]
pub use pallet_revive_uapi::ReturnFlags;

/// Environmental contract functionality that does not require `Environment`.
Expand Down Expand Up @@ -246,14 +238,6 @@ pub trait TypedEnvBackend: EnvBackend {
/// For more details visit: [`weight_to_fee`][`crate::weight_to_fee`]
fn weight_to_fee<E: Environment>(&mut self, gas: u64) -> E::Balance;

/// Returns the amount of gas left for the contract execution.
///
/// # Note
///
/// For more details visit: [`gas_left`][`crate::gas_left`]
#[cfg(not(feature = "revive"))]
fn gas_left<E: Environment>(&mut self) -> u64;

/// Returns the timestamp of the current block.
///
/// # Note
Expand Down Expand Up @@ -300,23 +284,6 @@ pub trait TypedEnvBackend: EnvBackend {
E: Environment,
Evt: Event;

/// Invokes a contract message and returns its result.
///
/// # Note
///
/// **This will call into the original `call` host function.**
///
/// For more details visit: [`invoke_contract`][`crate::invoke_contract_v1`]
#[cfg(not(feature = "revive"))]
fn invoke_contract_v1<E, Args, R>(
&mut self,
call_data: &CallParams<E, CallV1<E>, Args, R>,
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
R: scale::Decode;

/// Invokes a contract message and returns its result.
///
/// # Note
Expand Down Expand Up @@ -368,22 +335,6 @@ pub trait TypedEnvBackend: EnvBackend {
Salt: AsRef<[u8]>,
R: ConstructorReturnType<ContractRef>;

#[cfg(not(feature = "revive"))]
fn instantiate_contract_v1<E, ContractRef, Args, Salt, R>(
&mut self,
params: &CreateParams<E, ContractRef, LimitParamsV1, Args, Salt, R>,
) -> Result<
ink_primitives::ConstructorResult<
<R as ConstructorReturnType<ContractRef>>::Output,
>,
>
where
E: Environment,
ContractRef: FromAccountId<E>,
Args: scale::Encode,
Salt: AsRef<[u8]>,
R: ConstructorReturnType<ContractRef>;

/// Terminates a smart contract.
///
/// # Note
Expand Down
26 changes: 0 additions & 26 deletions crates/env/src/call/call_builder/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(not(feature = "revive"))]
use crate::call::CallV1;
use crate::{
call::{
common::{
Expand All @@ -31,9 +29,6 @@ use crate::{
Gas,
};
use num_traits::Zero;
#[cfg(not(feature = "revive"))]
use pallet_contracts_uapi::CallFlags;
#[cfg(feature = "revive")]
use pallet_revive_uapi::CallFlags;

/// The default call type for cross-contract calls, for calling into the latest `call_v2`
Expand Down Expand Up @@ -67,27 +62,6 @@ impl<E, Args, RetType> CallBuilder<E, Set<Call<E>>, Args, RetType>
where
E: Environment,
{
/// Switch to the original `call` host function API, which only allows the `gas_limit`
/// limit parameter (equivalent to the `ref_time_limit` in the latest `call_v2`).
///
/// This method instance is used to allow usage of the generated call builder methods
/// for messages which initialize the builder with the new [`Call`] type.
#[cfg(not(feature = "revive"))]
pub fn call_v1(self) -> CallBuilder<E, Set<CallV1<E>>, Args, RetType> {
let call_type = self.call_type.value();
CallBuilder {
call_type: Set(CallV1 {
callee: call_type.callee,
gas_limit: call_type.ref_time_limit,
transferred_value: call_type.transferred_value,
call_flags: call_type.call_flags,
}),
exec_input: self.exec_input,
return_type: self.return_type,
_phantom: Default::default(),
}
}

/// Sets the `ref_time_limit` part of the weight limit for the current cross-contract
/// call.
///
Expand Down
Loading

0 comments on commit aba84ba

Please sign in to comment.