Skip to content

Commit

Permalink
Merge pull request #1872 from multiversx/deprecate-type-abi-derive
Browse files Browse the repository at this point in the history
Deprecate `#[derive(TypeAbi)]`
  • Loading branch information
andrei-marinica authored Nov 22, 2024
2 parents de4b046 + c4c0a53 commit 01e0893
Show file tree
Hide file tree
Showing 42 changed files with 388 additions and 80 deletions.
7 changes: 5 additions & 2 deletions contracts/benchmarks/large-storage/src/large_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();

#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub enum SampleEnum {
Value1,
Value2,
}
#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]

#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub struct Structure<M: ManagedTypeApi> {
pub field1: ManagedBuffer<M>,
pub field2: SampleEnum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ multiversx_sc::derive_imports!();

pub type Nonce = u64;

#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub struct ExampleStruct<M>
where
M: ManagedTypeApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use crate::bonding_curve::{
utils::structs::CurveArguments,
};

#[derive(
TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, PartialEq, Eq, Clone, Default,
)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone, Default)]
pub enum FunctionSelector<M: ManagedTypeApi> {
Linear(LinearFunction<M>),
CustomExample(BigUint<M>),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use multiversx_sc::{
types::{BigUint, ManagedAddress},
};

#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)]
#[type_abi]
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub enum AuctionType {
Selling,
Siring,
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/esdt-transfer-with-fee/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use multiversx_sc::{derive_imports::*, imports::*};

pub(crate) const PERCENTAGE_DIVISOR: u32 = 10_000; // dividing the percentage fee by this number will result in a 2 decimal percentage

#[derive(TopEncode, TopDecode, TypeAbi, PartialEq, Eq, Clone)]
#[type_abi]
#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone)]
pub enum Fee<M>
where
M: ManagedTypeApi,
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/multisig/src/multisig_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ where
}

#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)]
pub enum UserRole {
None,
Proposer,
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/multisig/src/multisig_view_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ where
}

#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)]
pub enum UserRole {
None,
Proposer,
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/multisig/src/user_role.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use multiversx_sc::derive_imports::*;

#[derive(TopEncode, TopDecode, TypeAbi, Clone, Copy, PartialEq, Eq, Debug)]
#[type_abi]
#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)]
pub enum UserRole {
None,
Proposer,
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/nft-minter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use multiversx_sc::{derive_imports::*, imports::*};
pub mod nft_marketplace_proxy;
mod nft_module;

#[derive(TypeAbi, TopEncode, TopDecode)]
#[type_abi]
#[derive(TopEncode, TopDecode)]
pub struct ExampleAttributes {
pub creation_timestamp: u64,
}
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use multiversx_sc::{derive_imports::*, imports::*};
const NFT_AMOUNT: u32 = 1;
const ROYALTIES_MAX: u32 = 10_000;

#[derive(TypeAbi, TopEncode, TopDecode)]
#[type_abi]
#[derive(TopEncode, TopDecode)]
pub struct PriceTag<M: ManagedTypeApi> {
pub token: EgldOrEsdtTokenIdentifier<M>,
pub nonce: u64,
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/order-book/factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

use multiversx_sc::{derive_imports::*, imports::*};

#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub struct TokenIdPair<M: ManagedTypeApi> {
first_token_id: TokenIdentifier<M>,
second_token_id: TokenIdentifier<M>,
Expand Down
20 changes: 12 additions & 8 deletions contracts/examples/order-book/pair/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ pub const FEE_PENALTY_INCREASE_EPOCHS: u64 = 5;
pub const FEE_PENALTY_INCREASE_PERCENT: u64 = 1_000;
pub const FREE_ORDER_FROM_STORAGE_MIN_PENALTIES: u64 = 6;

#[type_abi]
#[derive(
ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, TypeAbi, Clone,
ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone,
)]
pub enum OrderType {
Buy,
Expand All @@ -26,35 +27,38 @@ pub struct Transfer<M: ManagedTypeApi> {
pub payment: Payment<M>,
}

#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)]
#[type_abi]
#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub enum FeeConfigEnum {
Fixed,
Percent,
}

#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)]
#[type_abi]
#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub struct FeeConfig<M: ManagedTypeApi> {
pub fee_type: FeeConfigEnum,
pub fixed_fee: BigUint<M>,
pub percent_fee: u64,
}

#[derive(
ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone, Default,
)]
#[type_abi]
#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, Default)]
pub struct DealConfig {
pub match_provider_percent: u64,
}

#[derive(TopEncode, TopDecode, TypeAbi, Clone)]
#[type_abi]
#[derive(TopEncode, TopDecode, Clone)]
pub struct OrderInputParams<M: ManagedTypeApi> {
pub amount: BigUint<M>,
pub match_provider: ManagedAddress<M>,
pub fee_config: FeeConfig<M>,
pub deal_config: DealConfig,
}

#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)]
#[type_abi]
#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)]
pub struct Order<M: ManagedTypeApi> {
pub id: u64,
pub creator: ManagedAddress<M>,
Expand Down
Loading

0 comments on commit 01e0893

Please sign in to comment.