gear-tech / sails

Framework for ultimate experience of writing programs powered by Gear protocol
Apache License 2.0
17 stars 4 forks source link

Inner types of ignored external types are generated anyway #557

Open gshep opened 1 week ago

gshep commented 1 week ago

Problem

Not sufficient however would be nice to fix it. Generated Rust code contains redundant entities however they are inner types of ignored external ones.

Steps

  1. the same as in #556
  2. generated idl_external_type_client.rs will contain the Inner struct. The file excerpt is attached.

Possible Solution

The basic idea is to make two passes. During the first pass populate inner external_types map. On the second pass the current logic is kept.

Notes

No response

Relevant Log Output

Click to expand/collapse

```rust #[derive(PartialEq, Debug, Encode, Decode, TypeInfo)] #[codec(crate = sails_rs::scale_codec)] #[scale_info(crate = sails_rs::scale_info)] pub struct Message(pub Data); #[derive(PartialEq, Debug, Encode, Decode, TypeInfo)] #[codec(crate = sails_rs::scale_codec)] #[scale_info(crate = sails_rs::scale_info)] pub struct Inner(pub u32); pub mod traits { ```

DennisInSky commented 6 days ago

We can't skip generating types as IDL is used for generating clients not just for Rust, but for other languages as well where external Rust crates are unavailable

gshep commented 6 days ago

reopened since we discussed it in dm

DennisInSky commented 6 days ago

A possible solution would be recursively marking a type as external provided it is referenced from another type marked as external.

gshep commented 5 days ago

It would be also nice to prefix such external types with pub