Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alloc feature removed from codec, cleanup #1672

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions contracts/feature-tests/alloc-features/src/echo_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ multiversx_sc::imports!();

use crate::types::*;

// String is not part of the standard imports because we want to discourage its use
use multiversx_sc::types::String;

/// Test serialization for heap-allocated types.
#[multiversx_sc::module]
pub trait EchoAllocTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

multiversx_sc::imports!();

use multiversx_sc::types::String;

/// Legacy, deprecated macros. Will b removed once they get removed.
///
/// Error conversions should be moved to corresponding new formatter-based error tests.
Expand Down
1 change: 0 additions & 1 deletion data/codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ categories = ["no-std", "wasm", "cryptography::cryptocurrencies", "development-t

[features]
derive = ["multiversx-sc-codec-derive"]
alloc = []

[dependencies.multiversx-sc-codec-derive]
path = "../codec-derive"
Expand Down
4 changes: 0 additions & 4 deletions data/codec/src/multi_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ mod multi_value_optional;
mod multi_value_placeholder;
mod multi_value_tuple;
mod multi_value_unit;

#[cfg(feature = "alloc")]
mod multi_value_vec;

pub use multi_value_ignore::IgnoreValue;
pub use multi_value_optional::OptionalValue;
pub use multi_value_placeholder::*;
pub use multi_value_tuple::*;

#[cfg(feature = "alloc")]
pub use multi_value_vec::MultiValueVec;
2 changes: 1 addition & 1 deletion framework/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ all-features = true

[features]
num-bigint = ["multiversx-sc-codec/num-bigint"]
alloc = ["multiversx-sc-codec/alloc"]
alloc = []
managed-buffer-builder-cached = []
esdt-token-payment-legacy-decode = []

Expand Down
2 changes: 0 additions & 2 deletions framework/base/src/abi/type_abi_impl_codec_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ use crate::{
codec::multi_types::{IgnoreValue, OptionalValue},
};

#[cfg(feature = "alloc")]
impl<T, U> TypeAbiFrom<crate::codec::multi_types::MultiValueVec<U>>
for crate::codec::multi_types::MultiValueVec<T>
where
T: TypeAbiFrom<U>,
{
}

#[cfg(feature = "alloc")]
impl<T: TypeAbi> TypeAbi for crate::codec::multi_types::MultiValueVec<T> {
type Unmanaged = crate::codec::multi_types::MultiValueVec<T::Unmanaged>;

Expand Down
1 change: 0 additions & 1 deletion framework/base/src/types/managed/basic/managed_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ impl<M: ManagedTypeApi> core::fmt::Debug for ManagedBuffer<M> {
}
}

#[cfg(feature = "alloc")]
impl<M: ManagedTypeApi> core::fmt::Display for ManagedBuffer<M> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
use crate::contract_base::ErrorHelper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use unwrap_infallible::UnwrapInfallible;

use crate::codec::multi_types::MultiValueVec;
use crate::{
abi::{TypeAbi, TypeAbiFrom, TypeDescriptionContainer, TypeName},
api::{ErrorApi, ManagedTypeApi},
Expand Down Expand Up @@ -244,12 +245,8 @@ where
M: ManagedTypeApi,
T: TypeAbi,
{
#[cfg(feature = "alloc")]
type Unmanaged = MultiValueVec<T::Unmanaged>;

#[cfg(not(feature = "alloc"))]
type Unmanaged = Self;

fn type_name() -> TypeName {
crate::abi::type_name_variadic::<T>()
}
Expand All @@ -267,10 +264,6 @@ where
}
}

#[cfg(feature = "alloc")]
use crate::codec::multi_types::MultiValueVec;

#[cfg(feature = "alloc")]
impl<M, T, U> TypeAbiFrom<MultiValueVec<T>> for MultiValueEncoded<M, U>
where
M: ManagedTypeApi + ErrorApi,
Expand All @@ -279,7 +272,6 @@ where
{
}

#[cfg(feature = "alloc")]
impl<M, T, U> TypeAbiFrom<MultiValueEncoded<M, T>> for MultiValueVec<U>
where
M: ManagedTypeApi + ErrorApi,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use multiversx_sc_codec::multi_types::MultiValueVec;

use crate::{
abi::{TypeAbi, TypeAbiFrom, TypeDescriptionContainer, TypeName},
api::ManagedTypeApi,
Expand Down Expand Up @@ -222,11 +224,7 @@ where
M: ManagedTypeApi,
T: ManagedVecItem,
{
#[cfg(feature = "alloc")]
type Unmanaged = multiversx_sc_codec::multi_types::MultiValueVec<T::Unmanaged>;

#[cfg(not(feature = "alloc"))]
type Unmanaged = Self;
type Unmanaged = MultiValueVec<T::Unmanaged>;

fn type_name() -> TypeName {
crate::abi::type_name_variadic::<T>()
Expand Down
11 changes: 0 additions & 11 deletions framework/base/src/types/managed/wrapped/managed_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,8 @@ impl<M> TypeAbi for ManagedAddress<M>
where
M: ManagedTypeApi,
{
#[cfg(feature = "alloc")]
type Unmanaged = crate::types::heap::Address;

#[cfg(not(feature = "alloc"))]
type Unmanaged = Self;

/// `"Address"` instead of `"array32<u8>"`.
fn type_name() -> TypeName {
Address::type_name()
Expand Down Expand Up @@ -274,14 +270,7 @@ impl<M: ManagedTypeApi> core::fmt::Debug for ManagedAddress<M> {

impl<M> TypeAbiFrom<[u8; 32]> for ManagedAddress<M> where M: ManagedTypeApi {}

#[cfg(feature = "alloc")]
impl<M> TypeAbiFrom<Address> for ManagedAddress<M> where M: ManagedTypeApi {}

#[cfg(feature = "alloc")]
impl<M> TypeAbiFrom<&Address> for ManagedAddress<M> where M: ManagedTypeApi {}

#[cfg(feature = "alloc")]
impl<M> TypeAbiFrom<ManagedAddress<M>> for Address where M: ManagedTypeApi {}

#[cfg(feature = "alloc")]
impl<M> TypeAbiFrom<&ManagedAddress<M>> for Address where M: ManagedTypeApi {}
Loading