Traits for cross-blueprint interactions
Enhancement/Feature Request to use traits in Scrypto similarly to how they are used in plain Rust.
This is to continue the discussion started in https://github.com/radixdlt/community-scrypto/pull/24 with the naive implementation there of the blueprint_stub macro which converted a trait into a "hidden" blueprint with an empty implementation.
But if this kind of thing were part of Scrypto I would imagine that maybe a better way would be to duplicate some code from the existing blueprint! macro but only generate the minimal amount of API stubs, and not actually make the entire blueprint. It could also generate a real Rust trait in such a way that a blueprint could implement it to get static checks that the "receiving" side of the function/method calls have all the right methods.
Just wanted to add that trait support is still on our backlog. We should be able to contribute to this thread more once we start working on it.
Yes, this would be a great feature. It would be great if one component could implement multiple traits and that these traits are then used for cross-component calls (especially with type checks).
One use case would be for example a price oracle trait with e.g. a function get_price (and/or more complex variants with twap). Different blueprint AMM pools can implement that trait which would make interoperability between different dapps much smoother. The same applies to a trait for a swap function.
In general making cross-component interaction more type safe is desirable.
In the end it could maybe even make sense to publish traits for blueprints as first class member in the blueprint catalog. Then you can get traits and blueprints from the on-ledger catalog.
Addressed via means other than traits