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

Fix proxy #1518

Merged
merged 13 commits into from
Apr 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ where
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> CrowdfundingProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
}

#[rustfmt::skip]
impl<Env, From, To, Gas> CrowdfundingProxyMethods<Env, From, To, Gas>
where
Expand Down
11 changes: 0 additions & 11 deletions contracts/examples/digital-cash/src/digital_cash_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ where
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> DigitalCashProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
}

#[rustfmt::skip]
impl<Env, From, To, Gas> DigitalCashProxyMethods<Env, From, To, Gas>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ where
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> SeedNftMinterProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
}

#[rustfmt::skip]
impl<Env, From, To, Gas> SeedNftMinterProxyMethods<Env, From, To, Gas>
where
Expand Down
22 changes: 0 additions & 22 deletions contracts/feature-tests/abi-tester/src/abi_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,28 +459,6 @@ pub struct OnlyShowsUpAsNested06 {
pub struct OnlyShowsUpAsNested07 {
}

#[derive(TopDecode, TopEncode, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug, Copy)]
pub enum EsdtLocalRole {
None,
Mint,
Burn,
NftCreate,
NftAddQuantity,
NftBurn,
NftAddUri,
NftUpdateAttributes,
Transfer,
}

#[derive(TopDecode, TopEncode, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug, ManagedVecItem)]
pub enum EsdtTokenType {
Fungible,
NonFungible,
SemiFungible,
Meta,
Invalid,
}

#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub struct OnlyShowsUpAsNestedInSingleValueMapper {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ where
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> ChildProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
}

#[rustfmt::skip]
impl<Env, From, To, Gas> ChildProxyMethods<Env, From, To, Gas>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ where
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> RecursiveCallerProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
}

#[rustfmt::skip]
impl<Env, From, To, Gas> RecursiveCallerProxyMethods<Env, From, To, Gas>
where
Expand Down
11 changes: 0 additions & 11 deletions contracts/feature-tests/panic-message-features/tests/pmf_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ where
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> PanicMessageFeaturesProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
}

#[rustfmt::skip]
impl<Env, From, To, Gas> PanicMessageFeaturesProxyMethods<Env, From, To, Gas>
where
Expand Down
20 changes: 1 addition & 19 deletions framework/derive/src/type_abi_derive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::parse::attributes::extract_macro_attributes;

use super::parse::attributes::extract_doc;
use quote::{quote, ToTokens};
use quote::quote;

pub struct ExplicitDiscriminant {
pub variant_index: usize,
Expand Down Expand Up @@ -122,17 +122,11 @@ pub fn type_abi_derive(input: proc_macro::TokenStream) -> proc_macro2::TokenStre
let name = &ast.ident;
let name_str = name.to_string();
let (impl_generics, ty_generics, where_clause) = &ast.generics.split_for_impl();
let name_rust = extract_rust_type(ty_generics, name_str.clone());
quote! {
impl #impl_generics multiversx_sc::abi::TypeAbi for #name #ty_generics #where_clause {
fn type_name() -> multiversx_sc::abi::TypeName {
#name_str.into()
}

fn type_name_rust() -> multiversx_sc::abi::TypeName {
#name_rust.into()
}

#type_description_impl
}
}
Expand Down Expand Up @@ -189,15 +183,3 @@ pub fn get_discriminant(

quote! { #next_value}
}

fn extract_rust_type(ty_generics: &syn::TypeGenerics<'_>, mut output_name: String) -> String {
let mut ty_generics_tokens = proc_macro2::TokenStream::new();
ty_generics.to_tokens(&mut ty_generics_tokens);

if ty_generics_tokens.to_string().is_empty() {
return output_name;
}

output_name.push_str("<$API>");
output_name
}
4 changes: 1 addition & 3 deletions framework/meta/src/cmd/contract/generate_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pub mod proxy_crate_gen;
pub mod proxy_gen_main;
pub mod proxy_gen_struct_enum;
mod proxy_generator;
mod proxy_naming;
pub mod proxy_sc_functions_gen;
pub mod proxy_template_gen;
38 changes: 10 additions & 28 deletions framework/meta/src/cmd/contract/generate_proxy/proxy_gen_main.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
use std::fs::File;

use multiversx_sc::abi::ContractAbi;

use super::{
super::meta_config::MetaConfig,
proxy_crate_gen::create_file,
proxy_gen_struct_enum::write_types,
proxy_sc_functions_gen::write_content,
proxy_template_gen::{
write_header, write_impl_for_tx_proxy, write_struct_tx_proxy_methods,
write_tx_proxy_type_def,
},
super::meta_config::MetaConfig, proxy_crate_gen::create_file, proxy_generator::ProxyGenerator,
};

const OUTPUT_PROXY_PATH: &str = "/output/proxy.rs";

impl MetaConfig {
pub fn generate_proxy(&self) {
write_proxy_with_explicit_path(OUTPUT_PROXY_PATH, &self.original_contract_abi);
for path in &self.sc_config.proxy_paths {
write_proxy_with_explicit_path(path, &self.original_contract_abi);
pub fn generate_proxy(&mut self) {
write_proxy_with_explicit_path(OUTPUT_PROXY_PATH, self);
let proxy_paths = self.sc_config.proxy_paths.clone();
for path in proxy_paths {
write_proxy_with_explicit_path(&path, self);
}
}
}

fn write_proxy_with_explicit_path(path: &str, abi: &ContractAbi) {
let file = create_file(path);
write_proxy_to_file(file, abi);
}

fn write_proxy_to_file(mut file: File, abi: &ContractAbi) {
write_header(&mut file);
write_tx_proxy_type_def(&mut file, &abi.name);
write_impl_for_tx_proxy(&mut file, &abi.name);
write_struct_tx_proxy_methods(&mut file, &abi.name);
write_content(&mut file, abi.clone());
write_types(&mut file, &abi.type_descriptions);
fn write_proxy_with_explicit_path(path: &str, meta_config: &mut MetaConfig) {
let mut file = create_file(path);
let mut proxy_generator = ProxyGenerator::new(meta_config, &mut file);
proxy_generator.write_proxy_to_file();
}

This file was deleted.

Loading
Loading