From 5fd8db44c2670568bc221035cbe12052e2b2d2e1 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 22 Nov 2024 13:32:08 +0200 Subject: [PATCH 1/5] deprecated TypeAbi derive --- framework/derive/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/derive/src/lib.rs b/framework/derive/src/lib.rs index 515aa3fc7d..8c4966cc1f 100644 --- a/framework/derive/src/lib.rs +++ b/framework/derive/src/lib.rs @@ -44,6 +44,7 @@ pub fn proxy( macro_proxy::process_proxy(args, input) } +#[deprecated(since = "0.54.3", note = "Replace with attribute #[type_abi], which should be placed **before** all derives.")] #[proc_macro_derive(TypeAbi)] pub fn type_abi_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { type_abi_derive::type_abi_derive(input).into() From a52669a04d3a158e7fbac12bab20e34621f51a17 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 22 Nov 2024 14:23:38 +0200 Subject: [PATCH 2/5] replaced derive TypeAbi in contracts --- .../large-storage/src/large_storage.rs | 7 +++++-- .../benchmark-common/src/example_struct.rs | 3 ++- .../src/function_selector.rs | 5 ++--- .../kitty-auction/src/auction.rs | 3 ++- .../esdt-transfer-with-fee/src/fee.rs | 3 ++- contracts/examples/multisig/src/user_role.rs | 3 ++- contracts/examples/nft-minter/src/lib.rs | 3 ++- .../examples/nft-minter/src/nft_module.rs | 3 ++- .../examples/order-book/factory/src/lib.rs | 3 ++- .../examples/order-book/pair/src/common.rs | 20 +++++++++++------- .../seed-nft-minter/src/nft_module.rs | 3 ++- .../seed-nft-minter/src/seed_nft_minter.rs | 3 ++- .../token-release/src/contract_data.rs | 6 ++++-- .../feature-tests/abi-tester/src/abi_enum.rs | 9 +++++--- .../src/types/large_boxed_byte_array.rs | 3 ++- .../src/types/struct_example_alloc.rs | 3 ++- .../src/fwd_call_async_legacy.rs | 3 ++- .../forwarder-legacy/src/fwd_nft_legacy.rs | 6 ++++-- .../local-esdt-and-nft/src/lib.rs | 3 ++- .../promises-features/src/common.rs | 3 ++- .../src/crowdfunding_erc20.rs | 3 ++- .../erc1155-marketplace/src/lib.rs | 6 ++++-- .../lottery-erc20/src/lottery_info.rs | 3 ++- .../lottery-erc20/src/status.rs | 3 ++- .../src/exchange_features.rs | 11 ++-------- .../rust-snippets-generator-test/src/lib.rs | 5 ++--- .../use-module/src/token_merge_mod_impl.rs | 3 ++- .../bonding_curve/curves/linear_function.rs | 3 ++- .../src/bonding_curve/utils/structs.rs | 9 +++++--- .../src/governance/governance_proposal.rs | 21 ++++++++++++------- contracts/modules/src/subscription.rs | 3 ++- .../wrapped/egld_or_esdt_token_payment.rs | 7 +++---- .../wrapped/egld_or_multi_esdt_payment.rs | 7 +++---- framework/derive/src/lib.rs | 5 ++++- 34 files changed, 111 insertions(+), 73 deletions(-) diff --git a/contracts/benchmarks/large-storage/src/large_storage.rs b/contracts/benchmarks/large-storage/src/large_storage.rs index 46e62ceedb..3e47dc0e01 100644 --- a/contracts/benchmarks/large-storage/src/large_storage.rs +++ b/contracts/benchmarks/large-storage/src/large_storage.rs @@ -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 { pub field1: ManagedBuffer, pub field2: SampleEnum, diff --git a/contracts/benchmarks/mappers/benchmark-common/src/example_struct.rs b/contracts/benchmarks/mappers/benchmark-common/src/example_struct.rs index 23bb9b8cda..9193ef2a9c 100644 --- a/contracts/benchmarks/mappers/benchmark-common/src/example_struct.rs +++ b/contracts/benchmarks/mappers/benchmark-common/src/example_struct.rs @@ -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 where M: ManagedTypeApi, diff --git a/contracts/examples/bonding-curve-contract/src/function_selector.rs b/contracts/examples/bonding-curve-contract/src/function_selector.rs index 218a490c9c..511285ea4c 100644 --- a/contracts/examples/bonding-curve-contract/src/function_selector.rs +++ b/contracts/examples/bonding-curve-contract/src/function_selector.rs @@ -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 { Linear(LinearFunction), CustomExample(BigUint), diff --git a/contracts/examples/crypto-kitties/kitty-auction/src/auction.rs b/contracts/examples/crypto-kitties/kitty-auction/src/auction.rs index 261def0cf0..67f3035870 100644 --- a/contracts/examples/crypto-kitties/kitty-auction/src/auction.rs +++ b/contracts/examples/crypto-kitties/kitty-auction/src/auction.rs @@ -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, diff --git a/contracts/examples/esdt-transfer-with-fee/src/fee.rs b/contracts/examples/esdt-transfer-with-fee/src/fee.rs index 67c88d8742..2f3a9d3b0b 100644 --- a/contracts/examples/esdt-transfer-with-fee/src/fee.rs +++ b/contracts/examples/esdt-transfer-with-fee/src/fee.rs @@ -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 where M: ManagedTypeApi, diff --git a/contracts/examples/multisig/src/user_role.rs b/contracts/examples/multisig/src/user_role.rs index b92b2dea30..d8230fe68c 100644 --- a/contracts/examples/multisig/src/user_role.rs +++ b/contracts/examples/multisig/src/user_role.rs @@ -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, diff --git a/contracts/examples/nft-minter/src/lib.rs b/contracts/examples/nft-minter/src/lib.rs index 4148f368c2..bf73acee3a 100644 --- a/contracts/examples/nft-minter/src/lib.rs +++ b/contracts/examples/nft-minter/src/lib.rs @@ -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, } diff --git a/contracts/examples/nft-minter/src/nft_module.rs b/contracts/examples/nft-minter/src/nft_module.rs index 12f2c3b868..ab4fd22504 100644 --- a/contracts/examples/nft-minter/src/nft_module.rs +++ b/contracts/examples/nft-minter/src/nft_module.rs @@ -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 { pub token: EgldOrEsdtTokenIdentifier, pub nonce: u64, diff --git a/contracts/examples/order-book/factory/src/lib.rs b/contracts/examples/order-book/factory/src/lib.rs index fb83863ae3..8208737a71 100644 --- a/contracts/examples/order-book/factory/src/lib.rs +++ b/contracts/examples/order-book/factory/src/lib.rs @@ -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 { first_token_id: TokenIdentifier, second_token_id: TokenIdentifier, diff --git a/contracts/examples/order-book/pair/src/common.rs b/contracts/examples/order-book/pair/src/common.rs index 1c4b2e893c..7728e4c364 100644 --- a/contracts/examples/order-book/pair/src/common.rs +++ b/contracts/examples/order-book/pair/src/common.rs @@ -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, @@ -26,27 +27,29 @@ pub struct Transfer { pub payment: Payment, } -#[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 { pub fee_type: FeeConfigEnum, pub fixed_fee: BigUint, 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 { pub amount: BigUint, pub match_provider: ManagedAddress, @@ -54,7 +57,8 @@ pub struct OrderInputParams { pub deal_config: DealConfig, } -#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)] +#[type_abi] +#[derive(ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] pub struct Order { pub id: u64, pub creator: ManagedAddress, diff --git a/contracts/examples/seed-nft-minter/src/nft_module.rs b/contracts/examples/seed-nft-minter/src/nft_module.rs index a65a4175d7..3580ecedb5 100644 --- a/contracts/examples/seed-nft-minter/src/nft_module.rs +++ b/contracts/examples/seed-nft-minter/src/nft_module.rs @@ -7,7 +7,8 @@ use multiversx_sc_modules::default_issue_callbacks; const NFT_AMOUNT: u32 = 1; const ROYALTIES_MAX: u32 = 10_000; // 100% -#[derive(TypeAbi, TopEncode, TopDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct PriceTag { pub token: EgldOrEsdtTokenIdentifier, pub nonce: u64, diff --git a/contracts/examples/seed-nft-minter/src/seed_nft_minter.rs b/contracts/examples/seed-nft-minter/src/seed_nft_minter.rs index 1a6ac5ffe2..f0cff643c6 100644 --- a/contracts/examples/seed-nft-minter/src/seed_nft_minter.rs +++ b/contracts/examples/seed-nft-minter/src/seed_nft_minter.rs @@ -9,7 +9,8 @@ mod nft_module; use distribution_module::Distribution; use multiversx_sc_modules::default_issue_callbacks; -#[derive(TypeAbi, TopEncode, TopDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct ExampleAttributes { pub creation_timestamp: u64, } diff --git a/contracts/examples/token-release/src/contract_data.rs b/contracts/examples/token-release/src/contract_data.rs index d224761986..4b65ba599f 100644 --- a/contracts/examples/token-release/src/contract_data.rs +++ b/contracts/examples/token-release/src/contract_data.rs @@ -2,7 +2,8 @@ use multiversx_sc::{api::ManagedTypeApi, types::BigUint}; use multiversx_sc::derive_imports::*; -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, TypeAbi, Clone)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, Clone)] pub enum UnlockType { FixedAmount { period_unlock_amount: BigUint, @@ -16,7 +17,8 @@ pub enum UnlockType { }, } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, TypeAbi, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone)] pub struct Schedule { pub group_total_amount: BigUint, pub unlock_type: UnlockType, diff --git a/contracts/feature-tests/abi-tester/src/abi_enum.rs b/contracts/feature-tests/abi-tester/src/abi_enum.rs index 3b8db35407..8278907db7 100644 --- a/contracts/feature-tests/abi-tester/src/abi_enum.rs +++ b/contracts/feature-tests/abi-tester/src/abi_enum.rs @@ -2,7 +2,8 @@ use crate::only_nested::*; multiversx_sc::derive_imports!(); /// Its only purpose is to test that the ABI generator works fine. -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub enum AbiEnum { Nothing, Something(i32), @@ -11,7 +12,8 @@ pub enum AbiEnum { } /// An enum with similar explicit discriminants -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub enum ExplicitDiscriminant { Zero, Thirty = 30, @@ -21,7 +23,8 @@ pub enum ExplicitDiscriminant { } /// An enum with different explicit discriminants -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] #[repr(u8)] pub enum ExplicitDiscriminantMixed { Zero, diff --git a/contracts/feature-tests/alloc-features/src/types/large_boxed_byte_array.rs b/contracts/feature-tests/alloc-features/src/types/large_boxed_byte_array.rs index 5eddcbdeb6..c2c105fcc6 100644 --- a/contracts/feature-tests/alloc-features/src/types/large_boxed_byte_array.rs +++ b/contracts/feature-tests/alloc-features/src/types/large_boxed_byte_array.rs @@ -3,5 +3,6 @@ multiversx_sc::derive_imports!(); const ARRAY_SIZE: usize = 512; -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub struct LargeBoxedByteArray(Box<[u8; ARRAY_SIZE]>); diff --git a/contracts/feature-tests/alloc-features/src/types/struct_example_alloc.rs b/contracts/feature-tests/alloc-features/src/types/struct_example_alloc.rs index 3aca49df3b..d450253125 100644 --- a/contracts/feature-tests/alloc-features/src/types/struct_example_alloc.rs +++ b/contracts/feature-tests/alloc-features/src/types/struct_example_alloc.rs @@ -3,7 +3,8 @@ multiversx_sc::derive_imports!(); /// Example serialization for a structure that uses the heap allocator. /// Also checking nested serialization of basic types. -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub struct StructExampleAlloc { pub int: u16, diff --git a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_async_legacy.rs b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_async_legacy.rs index 8826c2db48..3e199f2ede 100644 --- a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_async_legacy.rs +++ b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_async_legacy.rs @@ -1,7 +1,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -#[derive(TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct CallbackData { callback_name: ManagedBuffer, token_identifier: EgldOrEsdtTokenIdentifier, diff --git a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs index 0cd0b57f4e..8e04da46a1 100644 --- a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs +++ b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs @@ -4,14 +4,16 @@ multiversx_sc::derive_imports!(); use super::fwd_storage_legacy; // used as mock attributes for NFTs -#[derive(TopEncode, TopDecode, TypeAbi, Clone, Copy, PartialEq, Debug)] +#[type_abi] +#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Debug)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, } -#[derive(TopEncode, TopDecode, TypeAbi, PartialEq, Eq, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone)] pub struct ComplexAttributes { pub biguint: BigUint, pub vec_u8: ManagedBuffer, diff --git a/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs b/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs index 0291d36131..e0cf22ab74 100644 --- a/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs +++ b/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs @@ -4,7 +4,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); // used as mock attributes for NFTs -#[derive(TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct Color { r: u8, g: u8, diff --git a/contracts/feature-tests/composability/promises-features/src/common.rs b/contracts/feature-tests/composability/promises-features/src/common.rs index 9d0e245fb9..46208c937a 100644 --- a/contracts/feature-tests/composability/promises-features/src/common.rs +++ b/contracts/feature-tests/composability/promises-features/src/common.rs @@ -1,7 +1,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -#[derive(TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct CallbackData { pub callback_name: ManagedBuffer, pub token_identifier: EgldOrEsdtTokenIdentifier, diff --git a/contracts/feature-tests/erc-style-contracts/crowdfunding-erc20/src/crowdfunding_erc20.rs b/contracts/feature-tests/erc-style-contracts/crowdfunding-erc20/src/crowdfunding_erc20.rs index 019ec560a5..48cb45e1d9 100644 --- a/contracts/feature-tests/erc-style-contracts/crowdfunding-erc20/src/crowdfunding_erc20.rs +++ b/contracts/feature-tests/erc-style-contracts/crowdfunding-erc20/src/crowdfunding_erc20.rs @@ -5,7 +5,8 @@ multiversx_sc::derive_imports!(); pub mod erc20_proxy; -#[derive(TopEncode, TopDecode, PartialEq, Eq, TypeAbi, Clone, Copy)] +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] pub enum Status { FundingPeriod, Successful, diff --git a/contracts/feature-tests/erc-style-contracts/erc1155-marketplace/src/lib.rs b/contracts/feature-tests/erc-style-contracts/erc1155-marketplace/src/lib.rs index 7aa633d71c..01a093c164 100644 --- a/contracts/feature-tests/erc-style-contracts/erc1155-marketplace/src/lib.rs +++ b/contracts/feature-tests/erc-style-contracts/erc1155-marketplace/src/lib.rs @@ -7,7 +7,8 @@ pub mod erc1155_proxy; const PERCENTAGE_TOTAL: u8 = 100; -#[derive(TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct Auction { pub token_identifier: EgldOrEsdtTokenIdentifier, pub min_bid: BigUint, @@ -18,7 +19,8 @@ pub struct Auction { pub current_winner: ManagedAddress, } -#[derive(TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct AuctionArgument { pub token_identifier: EgldOrEsdtTokenIdentifier, pub min_bid: BigUint, diff --git a/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/lottery_info.rs b/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/lottery_info.rs index 809bfaa662..f89fa26ee8 100644 --- a/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/lottery_info.rs +++ b/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/lottery_info.rs @@ -4,7 +4,8 @@ use multiversx_sc::{ }; multiversx_sc::derive_imports!(); -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub struct LotteryInfo { pub ticket_price: BigUint, pub tickets_left: u32, diff --git a/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/status.rs b/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/status.rs index 3cd6d6cfa9..a0d2617b5b 100644 --- a/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/status.rs +++ b/contracts/feature-tests/erc-style-contracts/lottery-erc20/src/status.rs @@ -1,6 +1,7 @@ multiversx_sc::derive_imports!(); -#[derive(TopEncode, TopDecode, TypeAbi, PartialEq, Eq, Clone, Copy)] +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] pub enum Status { Inactive, Running, diff --git a/contracts/feature-tests/exchange-features/src/exchange_features.rs b/contracts/feature-tests/exchange-features/src/exchange_features.rs index fd048e72c8..65d5f8974e 100644 --- a/contracts/feature-tests/exchange-features/src/exchange_features.rs +++ b/contracts/feature-tests/exchange-features/src/exchange_features.rs @@ -3,16 +3,9 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); +#[type_abi] #[derive( - ManagedVecItem, - TopEncode, - TopDecode, - NestedEncode, - NestedDecode, - TypeAbi, - Clone, - PartialEq, - Debug, + ManagedVecItem, TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, PartialEq, Debug, )] pub struct TokenAttributes { pub amount: BigUint, diff --git a/contracts/feature-tests/rust-snippets-generator-test/src/lib.rs b/contracts/feature-tests/rust-snippets-generator-test/src/lib.rs index 375a54fd18..5426018c0a 100644 --- a/contracts/feature-tests/rust-snippets-generator-test/src/lib.rs +++ b/contracts/feature-tests/rust-snippets-generator-test/src/lib.rs @@ -16,9 +16,8 @@ multiversx_sc::derive_imports!(); // version = "0.54.3" // path = "../../../../framework/snippets" -#[derive( - TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem, Debug, Clone, -)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem, Debug, Clone)] pub struct MyCoolStruct { pub awesome: BigUint, } diff --git a/contracts/feature-tests/use-module/src/token_merge_mod_impl.rs b/contracts/feature-tests/use-module/src/token_merge_mod_impl.rs index 617cce5ad6..b5d7711481 100644 --- a/contracts/feature-tests/use-module/src/token_merge_mod_impl.rs +++ b/contracts/feature-tests/use-module/src/token_merge_mod_impl.rs @@ -10,7 +10,8 @@ use multiversx_sc_modules::token_merge::{ merged_token_instances::MergedTokenInstances, }; -#[derive(TypeAbi, TopEncode, TopDecode, PartialEq, Debug)] +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Debug)] pub struct CustomAttributes { pub first: u32, pub second: u64, diff --git a/contracts/modules/src/bonding_curve/curves/linear_function.rs b/contracts/modules/src/bonding_curve/curves/linear_function.rs index 698d1757fd..fe2105310c 100644 --- a/contracts/modules/src/bonding_curve/curves/linear_function.rs +++ b/contracts/modules/src/bonding_curve/curves/linear_function.rs @@ -3,7 +3,8 @@ multiversx_sc::derive_imports!(); use crate::bonding_curve::{curves::curve_function::CurveFunction, utils::structs::CurveArguments}; -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, PartialEq, Eq, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone)] pub struct LinearFunction { pub initial_price: BigUint, pub linear_coefficient: BigUint, diff --git a/contracts/modules/src/bonding_curve/utils/structs.rs b/contracts/modules/src/bonding_curve/utils/structs.rs index 59836befc1..9d020c48c6 100644 --- a/contracts/modules/src/bonding_curve/utils/structs.rs +++ b/contracts/modules/src/bonding_curve/utils/structs.rs @@ -3,7 +3,8 @@ use crate::bonding_curve::curves::curve_function::CurveFunction; multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, PartialEq, Eq, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone)] pub struct CurveArguments { pub available_supply: BigUint, pub balance: BigUint, @@ -15,7 +16,8 @@ impl CurveArguments { } } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, PartialEq, Eq, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone)] pub struct BondingCurve< M: ManagedTypeApi, T: CurveFunction + TopEncode + TopDecode + NestedEncode + NestedDecode + TypeAbi, @@ -39,7 +41,8 @@ impl< } } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, PartialEq, Eq, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Eq, Clone)] pub struct TokenOwnershipData { pub token_nonces: ManagedVec, pub owner: ManagedAddress, diff --git a/contracts/modules/src/governance/governance_proposal.rs b/contracts/modules/src/governance/governance_proposal.rs index e251a43830..60d0fa27f0 100644 --- a/contracts/modules/src/governance/governance_proposal.rs +++ b/contracts/modules/src/governance/governance_proposal.rs @@ -7,7 +7,8 @@ pub type ProposalId = usize; pub type GovernanceActionAsMultiArg = MultiValue4, ManagedBuffer, ManagedVec>>; -#[derive(TypeAbi, TopEncode, TopDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub enum VoteType { UpVote, DownVote, @@ -15,7 +16,8 @@ pub enum VoteType { AbstainVote, } -#[derive(TypeAbi, TopEncode, TopDecode, PartialEq, Eq)] +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq)] pub enum GovernanceProposalStatus { None, Pending, @@ -26,19 +28,22 @@ pub enum GovernanceProposalStatus { WaitingForFees, } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] pub struct ProposalFees { pub total_amount: BigUint, pub entries: ManagedVec>, } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] pub struct FeeEntry { pub depositor_addr: ManagedAddress, pub tokens: EsdtTokenPayment, } -#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode)] pub struct GovernanceAction { pub gas_limit: u64, pub dest_address: ManagedAddress, @@ -58,7 +63,8 @@ impl GovernanceAction { } } -#[derive(TypeAbi, TopEncode, TopDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct GovernanceProposal { pub proposer: ManagedAddress, pub actions: ArrayVec, MAX_GOVERNANCE_PROPOSAL_ACTIONS>, @@ -66,7 +72,8 @@ pub struct GovernanceProposal { pub fees: ProposalFees, } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode)] pub struct ProposalVotes { pub up_votes: BigUint, pub down_votes: BigUint, diff --git a/contracts/modules/src/subscription.rs b/contracts/modules/src/subscription.rs index 3f142abbe4..536956b90d 100644 --- a/contracts/modules/src/subscription.rs +++ b/contracts/modules/src/subscription.rs @@ -24,7 +24,8 @@ multiversx_sc::derive_imports!(); /// * cancelling a subscription /// * getting the expiration /// -#[derive(TypeAbi, TopEncode, TopDecode)] +#[type_abi] +#[derive(TopEncode, TopDecode)] pub struct SubscriptionAttributes { pub expiration: u64, pub attributes: T, diff --git a/framework/base/src/types/managed/wrapped/egld_or_esdt_token_payment.rs b/framework/base/src/types/managed/wrapped/egld_or_esdt_token_payment.rs index 2e702a0701..e87d520981 100644 --- a/framework/base/src/types/managed/wrapped/egld_or_esdt_token_payment.rs +++ b/framework/base/src/types/managed/wrapped/egld_or_esdt_token_payment.rs @@ -10,13 +10,12 @@ use crate::codec::{ }; use crate as multiversx_sc; // needed by the TypeAbi generated code -use crate::derive::TypeAbi; +use crate::derive::type_abi; use super::{EsdtTokenPayment, EsdtTokenPaymentRefs}; -#[derive( - TopDecode, TopEncode, NestedDecode, NestedEncode, TypeAbi, Clone, PartialEq, Eq, Debug, -)] +#[type_abi] +#[derive(TopDecode, TopEncode, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug)] pub struct EgldOrEsdtTokenPayment { pub token_identifier: EgldOrEsdtTokenIdentifier, pub token_nonce: u64, diff --git a/framework/base/src/types/managed/wrapped/egld_or_multi_esdt_payment.rs b/framework/base/src/types/managed/wrapped/egld_or_multi_esdt_payment.rs index 4c3187e3c9..88534f95c1 100644 --- a/framework/base/src/types/managed/wrapped/egld_or_multi_esdt_payment.rs +++ b/framework/base/src/types/managed/wrapped/egld_or_multi_esdt_payment.rs @@ -9,14 +9,13 @@ use crate::{ }; use crate as multiversx_sc; // needed by the TypeAbi generated code -use crate::derive::TypeAbi; +use crate::derive::type_abi; /// Encodes any type of payment, which either: /// - EGLD (can be zero in case of no payment whatsoever); /// - Multi-ESDT (one or more ESDT transfers). -#[derive( - TopDecode, TopEncode, TypeAbi, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug, -)] +#[type_abi] +#[derive(TopDecode, TopEncode, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug)] pub enum EgldOrMultiEsdtPayment { Egld(BigUint), MultiEsdt(ManagedVec>), diff --git a/framework/derive/src/lib.rs b/framework/derive/src/lib.rs index 8c4966cc1f..d0fdd36b5f 100644 --- a/framework/derive/src/lib.rs +++ b/framework/derive/src/lib.rs @@ -44,7 +44,10 @@ pub fn proxy( macro_proxy::process_proxy(args, input) } -#[deprecated(since = "0.54.3", note = "Replace with attribute #[type_abi], which should be placed **before** all derives.")] +#[deprecated( + since = "0.54.4", + note = "Replace with attribute #[type_abi], which should be placed before all derives. More about this: https://docs.multiversx.com/developers/transactions/tx-migration/#replace-derivetypeabi-with-type_abi" +)] #[proc_macro_derive(TypeAbi)] pub fn type_abi_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { type_abi_derive::type_abi_derive(input).into() From 404eea6461c2c6240f30816bf962c33ccf92c6ac Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 22 Nov 2024 17:03:29 +0200 Subject: [PATCH 3/5] type_abi attribute emits warning if no derive below --- contracts/feature-tests/abi-tester/src/abi_test_type.rs | 2 ++ .../basic-features/src/types/codec_err_test_type.rs | 1 + framework/derive/src/type_abi_derive.rs | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contracts/feature-tests/abi-tester/src/abi_test_type.rs b/contracts/feature-tests/abi-tester/src/abi_test_type.rs index fe5d3246d1..8a9ae4f8ab 100644 --- a/contracts/feature-tests/abi-tester/src/abi_test_type.rs +++ b/contracts/feature-tests/abi-tester/src/abi_test_type.rs @@ -38,12 +38,14 @@ pub struct AbiManagedVecItem { } #[type_abi] +#[derive(TopEncode, TopDecode)] pub struct OnlyShowsUpInEsdtAttr { #[allow(dead_code)] pub field: OnlyShowsUpAsNested10, } #[type_abi] +#[derive(TopEncode, TopDecode)] pub struct ManagedDecimalWrapper { #[allow(dead_code)] pub field: ManagedDecimal>, diff --git a/contracts/feature-tests/basic-features/src/types/codec_err_test_type.rs b/contracts/feature-tests/basic-features/src/types/codec_err_test_type.rs index 41c1524c41..44db572eca 100644 --- a/contracts/feature-tests/basic-features/src/types/codec_err_test_type.rs +++ b/contracts/feature-tests/basic-features/src/types/codec_err_test_type.rs @@ -9,6 +9,7 @@ use multiversx_sc::{ /// Helper type to explore encode/decode errors. #[type_abi] +#[derive(Clone, Copy)] pub struct CodecErrorTestType; impl TopEncode for CodecErrorTestType { diff --git a/framework/derive/src/type_abi_derive.rs b/framework/derive/src/type_abi_derive.rs index 8c70b56af8..fd7eff5cd4 100644 --- a/framework/derive/src/type_abi_derive.rs +++ b/framework/derive/src/type_abi_derive.rs @@ -46,8 +46,13 @@ fn fields_snippets(fields: &syn::Fields) -> Vec { pub fn type_abi_derive(input: proc_macro::TokenStream) -> proc_macro2::TokenStream { let ast: syn::DeriveInput = syn::parse(input).unwrap(); + let name = &ast.ident; + let name_str = name.to_string(); let type_docs = extract_doc(ast.attrs.as_slice()); let macro_attributes = extract_macro_attributes(ast.attrs.as_slice()); + if macro_attributes.is_empty() { + println!("Warning! {name_str} #[type_abi] implementation sees no derive traits. Make sure that the derive attribute comes after #[type_abi]"); + } let type_description_impl = match &ast.data { syn::Data::Struct(data_struct) => { @@ -119,8 +124,6 @@ pub fn type_abi_derive(input: proc_macro::TokenStream) -> proc_macro2::TokenStre syn::Data::Union(_) => panic!("Union not supported!"), }; - let name = &ast.ident; - let name_str = name.to_string(); let (impl_generics, ty_generics, where_clause) = &ast.generics.split_for_impl(); quote! { impl #impl_generics multiversx_sc::abi::TypeAbiFrom for #name #ty_generics #where_clause {} From e417051c3295a8b823a9364c0f4486e78f8f2551 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 22 Nov 2024 17:03:44 +0200 Subject: [PATCH 4/5] proxies re-generated --- .../examples/multisig/src/multisig_proxy.rs | 2 +- .../multisig/src/multisig_view_proxy.rs | 2 +- .../src/ping_pong_egld_proxy.rs | 263 ++++++++++++++++++ .../feature-tests/abi-tester/src/abi_proxy.rs | 6 +- 4 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs diff --git a/contracts/examples/multisig/src/multisig_proxy.rs b/contracts/examples/multisig/src/multisig_proxy.rs index 6e4b78df16..b4b691f91f 100644 --- a/contracts/examples/multisig/src/multisig_proxy.rs +++ b/contracts/examples/multisig/src/multisig_proxy.rs @@ -458,7 +458,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)] pub enum UserRole { None, Proposer, diff --git a/contracts/examples/multisig/src/multisig_view_proxy.rs b/contracts/examples/multisig/src/multisig_view_proxy.rs index f17bdc4212..6235f6dbbb 100644 --- a/contracts/examples/multisig/src/multisig_view_proxy.rs +++ b/contracts/examples/multisig/src/multisig_view_proxy.rs @@ -212,7 +212,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)] pub enum UserRole { None, Proposer, diff --git a/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs b/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs new file mode 100644 index 0000000000..ad8944411b --- /dev/null +++ b/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs @@ -0,0 +1,263 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct PingPongProxy; + +impl TxProxyTrait for PingPongProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = PingPongProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + PingPongProxyMethods { wrapped_tx: tx } + } +} + +pub struct PingPongProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + /// Necessary configuration when deploying: + /// `ping_amount` - the exact EGLD amount that needs to be sent when `ping`-ing. + /// `duration_in_seconds` - how much time (in seconds) until contract expires. + /// `opt_activation_timestamp` - optionally specify the contract to only activate at a later date. + /// `max_funds` - optional funding cap, no more funds than this can be added to the contract. + pub fn init< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + ping_amount: Arg0, + duration_in_seconds: Arg1, + opt_activation_timestamp: Arg2, + max_funds: Arg3, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&ping_amount) + .argument(&duration_in_seconds) + .argument(&opt_activation_timestamp) + .argument(&max_funds) + .original_result() + } +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + ping_amount: Arg0, + duration_in_seconds: Arg1, + opt_activation_timestamp: Arg2, + max_funds: Arg3, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .argument(&ping_amount) + .argument(&duration_in_seconds) + .argument(&opt_activation_timestamp) + .argument(&max_funds) + .original_result() + } +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + /// User sends some EGLD to be locked in the contract for a period of time. + /// Optional `_data` argument is ignored. + pub fn ping< + Arg0: ProxyArg, + >( + self, + _data: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("ping") + .argument(&_data) + .original_result() + } + + /// User can take back funds from the contract. + /// Can only be called after expiration. + pub fn pong( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pong") + .original_result() + } + + /// Send back funds to all users who pinged. + /// Returns + /// - `completed` if everything finished + /// - `interrupted` if run out of gas midway. + /// Can only be called after expiration. + pub fn pong_all( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pongAll") + .original_result() + } + + /// Lists the addresses of all users that have `ping`-ed, + /// in the order they have `ping`-ed + pub fn get_user_addresses( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getUserAddresses") + .original_result() + } + + /// Returns the current contract state as a struct + /// for faster fetching from external parties + pub fn get_contract_state( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getContractState") + .original_result() + } + + pub fn ping_amount( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getPingAmount") + .original_result() + } + + pub fn deadline( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getDeadline") + .original_result() + } + + /// Block timestamp of the block where the contract got activated. + /// If not specified in the constructor it is the the deploy block timestamp. + pub fn activation_timestamp( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActivationTimestamp") + .original_result() + } + + /// Optional funding cap. + pub fn max_funds( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMaxFunds") + .original_result() + } + + /// State of user funds. + /// 0 - user unknown, never `ping`-ed + /// 1 - `ping`-ed + /// 2 - `pong`-ed + pub fn user_status< + Arg0: ProxyArg, + >( + self, + user_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getUserStatus") + .argument(&user_id) + .original_result() + } + + /// Part of the `pongAll` status, the last user to be processed. + /// 0 if never called `pongAll` or `pongAll` completed. + pub fn pong_all_last_user( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pongAllLastUser") + .original_result() + } +} + +#[type_abi] +#[derive(TopEncode, TopDecode, Default)] +pub struct ContractState +where + Api: ManagedTypeApi, +{ + pub ping_amount: BigUint, + pub deadline: u64, + pub activation_timestamp: u64, + pub max_funds: Option>, + pub pong_all_last_user: usize, +} + +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] +pub enum UserStatus { + New, + Registered, + Withdrawn, +} diff --git a/contracts/feature-tests/abi-tester/src/abi_proxy.rs b/contracts/feature-tests/abi-tester/src/abi_proxy.rs index c13a4a4e2d..69fdfb2319 100644 --- a/contracts/feature-tests/abi-tester/src/abi_proxy.rs +++ b/contracts/feature-tests/abi-tester/src/abi_proxy.rs @@ -438,7 +438,7 @@ pub struct OnlyShowsUpAsNested02 { #[rustfmt::skip] #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub enum AbiEnum { Nothing, Something(i32), @@ -553,7 +553,7 @@ pub struct OnlyShowsUpInEsdtAttr { pub struct OnlyShowsUpAsNested10 {} #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub enum ExplicitDiscriminant { Zero, Thirty, @@ -564,7 +564,7 @@ pub enum ExplicitDiscriminant { #[rustfmt::skip] #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub enum ExplicitDiscriminantMixed { Zero, Unit, From c4c0a5368ad243b0546cc74bcdad7a8d2abd1552 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 22 Nov 2024 17:22:09 +0200 Subject: [PATCH 5/5] proxies re-generated --- .../feature-tests/basic-features/src/basic_features_proxy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/feature-tests/basic-features/src/basic_features_proxy.rs b/contracts/feature-tests/basic-features/src/basic_features_proxy.rs index ca53fd6e08..a17a5b27e2 100644 --- a/contracts/feature-tests/basic-features/src/basic_features_proxy.rs +++ b/contracts/feature-tests/basic-features/src/basic_features_proxy.rs @@ -165,7 +165,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(Clone, Copy)] pub struct CodecErrorTestType {} #[rustfmt::skip]