OffchainLabs / stylus-sdk-rs

Rust Smart Contracts on Arbitrum
239 stars 79 forks source link

feature: Solidity struct type support in `sol_interface!` macro #74

Open akirillo opened 1 year ago

akirillo commented 1 year ago

Hi there, I'm trying to define an interface using the sol_interface! macro, in which a function returns a custom type (struct). Ideally, I would like to be able to use the sol! macro from alloy-sol-types to define my struct. When I try this, for example:

use stylus_sdk::prelude::*;
use alloy_sol_types::sol;

sol! {
  struct MyStruct {
    uint256 myNum;
  }
}

sol_interface! {
  interface IMyInterface {
    function doThing() returns (MyStruct);
  }
}

I get the error:

proc macro panicked
message: not yet implemented: Solidity type SolChallenges is not yet implemented in sol_interface!

I dug around in the code a bit, and it seems that sol_interface! can't interpret any struct types.

The ability to do so (particularly in tandem with the sol! macro) would be amazing, as currently, I believe my only option is to return a tuple type and manually deserialize it.