stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
119 stars 69 forks source link

Explore ways to support contract extensibility #1326

Open leighmcculloch opened 4 weeks ago

leighmcculloch commented 4 weeks ago

We could explore ways to support extending an existing contract with new functionality.

A couple times people have asked for the ability to take an existing contract, or a template, and extend the contract with custom functionality.

Solidity supports this through inheritance.

leighmcculloch commented 4 weeks ago

Rust does not support inheritance, and the structure of the existing contract macros make it difficult to generate a contract from a partial representation extending a trait.

leighmcculloch commented 1 week ago

The main challenge of supporting extensibility is similar to the main challenge to support type reusability:

Both issues require coming up with a way to selectively export information (types, functions) that is defined in other crates. This is not trivial because the export information is generated as compile type into static variables that rustc destines for custom sections in the wasm.