Skip to content

Commit 3475c1e

Browse files
wip debugging contracttype and type-reference incompats
1 parent a517098 commit 3475c1e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

soroban-sdk-macros/src/derive_event.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ impl ContractEventArgs {
3939

4040
pub fn derive_event(metadata: TokenStream2, input: TokenStream2) -> TokenStream2 {
4141
match derive_event_or_err(metadata, input) {
42-
Ok(tokens) => tokens,
42+
Ok(tokens) => {
43+
println!("{tokens}");
44+
tokens
45+
}
4346
Err(err) => err.write_errors(),
4447
}
4548
}
@@ -249,7 +252,7 @@ fn derive_event_inner<'a>(
249252
ScSpecEventDataFormat::Vec => (
250253
quote! {
251254
// TODO: Implement optional fields on contracttype.
252-
// TODO: #[#path::contracttype]
255+
#[#path::contracttype(export = false)]
253256
pub struct #data_type_ident<'a>(
254257
#(&'a #data_type_params_types,)*
255258
);
@@ -267,7 +270,7 @@ fn derive_event_inner<'a>(
267270
),
268271
ScSpecEventDataFormat::Map => (
269272
quote! {
270-
// TODO: #[#path::contracttype]
273+
#[#path::contracttype(export = false)]
271274
pub struct #data_type_ident<'a>{
272275
#(#data_type_params_idents: &'a #data_type_params_types,)*
273276
}

soroban-sdk-macros/src/map_type.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use stellar_xdr::{
55
};
66
use syn::{
77
spanned::Spanned, Error, Expr, ExprLit, GenericArgument, Lit, Path, PathArguments, PathSegment,
8-
Type, TypePath, TypeTuple,
8+
Type, TypePath, TypeReference, TypeTuple,
99
};
1010

1111
// These constants' values must match the definitions of the constants with the
@@ -174,7 +174,7 @@ pub fn map_type(t: &Type, allow_hash: bool) -> Result<ScSpecTypeDef, Error> {
174174
))?,
175175
}
176176
}
177-
_ => Err(Error::new(t.span(), "unsupported type"))?,
177+
_ => Err(Error::new(t.span(), "unsupported type: {t:#?}"))?,
178178
}
179179
}
180180
Type::Tuple(TypeTuple { elems, .. }) => {
@@ -194,6 +194,7 @@ pub fn map_type(t: &Type, allow_hash: bool) -> Result<ScSpecTypeDef, Error> {
194194
})?,
195195
})))
196196
}
197-
_ => Err(Error::new(t.span(), "unsupported type"))?,
197+
Type::Reference(TypeReference { elem: t, .. }) => map_type(t, allow_hash),
198+
_ => Err(Error::new(t.span(), format!("unsupported type: {t:#?}")))?,
198199
}
199200
}

0 commit comments

Comments
 (0)