Skip to content

Commit

Permalink
Merge pull request #139 from OffchainLabs/sol-interface-struct
Browse files Browse the repository at this point in the history
Allow struct references within sol_interface macro
  • Loading branch information
rory-ocl authored Aug 6, 2024
2 parents e986088 + b43f0fe commit 15d7cfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stylus-proc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ pub fn sol_storage(input: TokenStream) -> TokenStream {
/// Observe the casing change. [`sol_interface!`] computes the selector based on the exact name passed in,
/// which should almost always be `CamelCase`. For aesthetics, the rust functions will instead use `snake_case`.
///
/// Note that structs may be used, as return types for example. Trying to reference structs using
/// the Solidity path separator (`module.MyStruct`) is not currently supported and will fail at
/// build-time.
///
/// # Reentrant calls
///
/// Contracts that opt into reentrancy via the `reentrant` feature flag require extra care.
Expand Down
4 changes: 4 additions & 0 deletions stylus-proc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ pub fn solidity_type_info(ty: &Type) -> (Cow<'static, str>, Cow<'static, str>) {
(path.into(), abi.into())
}
}
Type::Custom(path) => {
let path: Cow<'static, str> = path.to_string().into();
(path.clone(), path)
}
_ => todo!("Solidity type {ty} is not yet implemented in sol_interface!"),
}
}
Expand Down

0 comments on commit 15d7cfe

Please sign in to comment.