Skip to content

Commit

Permalink
Merge pull request multiversx#824 from ElrondNetwork/add-substitution…
Browse files Browse the repository at this point in the history
…-rules

Add missing substitution rules
  • Loading branch information
andrei-marinica authored Sep 16, 2022
2 parents bc78ee8 + f0e9bec commit f48708f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@ pub trait ManagedVecFeatures {
mv.push(item);
mv
}

#[endpoint]
fn managed_ref_explicit(&self, mv: ManagedVec<BigUint>, index: usize) -> BigUint {
let value: ManagedRef<BigUint> = mv.get(index);
let with_explicit_lifetime: ManagedRef<'_, BigUint> = value;
(*with_explicit_lifetime).clone()
}
}
51 changes: 35 additions & 16 deletions elrond-wasm-derive/src/preprocessing/substitution_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,51 @@ fn add_managed_type_with_generics(
}

fn add_managed_types(substitutions: &mut SubstitutionsMap) {
// types::io
add_managed_type(substitutions, &quote!(ManagedSCError));

// types::interaction
add_managed_type(substitutions, &quote!(AsyncCall));

// types::managed::basic
add_managed_type(substitutions, &quote!(BigFloat));
add_managed_type(substitutions, &quote!(BigInt));
add_managed_type(substitutions, &quote!(BigUint));
add_managed_type(substitutions, &quote!(BigFloat));
add_managed_type(substitutions, &quote!(ManagedBuffer));
add_managed_type(substitutions, &quote!(EllipticCurveComponents));
add_managed_type(substitutions, &quote!(EllipticCurve));
add_managed_type(substitutions, &quote!(ManagedAddress));
add_managed_type(substitutions, &quote!(TokenIdentifier));
add_managed_type(substitutions, &quote!(EgldOrEsdtTokenIdentifier));
add_managed_type(substitutions, &quote!(ManagedSCError));
add_managed_type(substitutions, &quote!(AsyncCall));
add_managed_type(substitutions, &quote!(ManagedBuffer));

// types::managed::multi-value
add_managed_type(substitutions, &quote!(ManagedAsyncCallError));
add_managed_type(substitutions, &quote!(EsdtTokenPayment));
add_managed_type_with_generics(substitutions, &quote!(ManagedAsyncCallResult));
add_managed_type(substitutions, &quote!(EsdtTokenPaymentMultiArg));
add_managed_type(substitutions, &quote!(EsdtTokenPaymentMultiValue));

add_managed_type_with_generics(substitutions, &quote!(ManagedOption));
add_managed_type_with_generics(substitutions, &quote!(ManagedVec));
add_managed_type_with_generics(substitutions, &quote!(ManagedVecOwnedIterator));
add_managed_type_with_generics(substitutions, &quote!(ManagedMultiValue));
add_managed_type_with_generics(substitutions, &quote!(MultiValueEncodedIterator));
add_managed_type_with_generics(substitutions, &quote!(MultiValueEncoded));
add_managed_type_with_generics(substitutions, &quote!(ManagedVarArgs));
add_managed_type_with_generics(substitutions, &quote!(ManagedMultiResultVec));
add_managed_type_with_generics(substitutions, &quote!(ManagedAsyncCallResult));
add_managed_type_with_generics(substitutions, &quote!(MultiValueEncoded));
add_managed_type_with_generics(substitutions, &quote!(MultiValueManagedVec));
add_managed_type_with_generics(substitutions, &quote!(MultiValueManagedVecCounted));
add_managed_type_with_generics(substitutions, &quote!(ManagedCountedVarArgs));
add_managed_type_with_generics(substitutions, &quote!(ManagedCountedMultiResultVec));
add_managed_type_with_generics(substitutions, &quote!(MultiValueManagedVec));

// types::managed::wrapped
add_managed_type(substitutions, &quote!(EgldOrEsdtTokenIdentifier));
add_managed_type(substitutions, &quote!(EgldOrEsdtTokenPayment));
add_managed_type(substitutions, &quote!(EsdtTokenData));
add_managed_type(substitutions, &quote!(EsdtTokenPayment));
add_managed_type(substitutions, &quote!(ManagedAddress));
add_managed_type(substitutions, &quote!(ManagedBufferCachedBuilder));
add_managed_type_with_generics(substitutions, &quote!(ManagedByteArray));
add_managed_type_with_generics(substitutions, &quote!(ManagedOption));
add_managed_type_with_generics(substitutions, &quote!(ManagedRef));
add_managed_type_with_generics(substitutions, &quote!(ManagedVecOwnedIterator));
add_managed_type_with_generics(substitutions, &quote!(ManagedVecRefIterator));
add_managed_type_with_generics(substitutions, &quote!(ManagedVecRef));
add_managed_type_with_generics(substitutions, &quote!(ManagedVec));
add_managed_type_with_generics(substitutions, &quote!(PreloadedManagedBuffer));
add_managed_type_with_generics(substitutions, &quote!(RandomnessSource));
add_managed_type(substitutions, &quote!(TokenIdentifier));
}

fn add_storage_mapper_single_generic_arg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use elrond_codec::{

/// Argument or result that is made up of the argument count, followed by the arguments themselves.
/// Think of it as a `VarArgs` preceded by the count.
/// Unlike `ManagedMultiValue` it deserializes eagerly.
/// Unlike `MultiValueManagedVec` it deserializes eagerly.
#[derive(Clone, Default)]
pub struct MultiValueManagedVecCounted<M, T>
where
Expand Down

0 comments on commit f48708f

Please sign in to comment.