Summary: I have a trait which can be implemented by any contract. I have a contract which has initialize method which takes contract address as parameter. This contract address should have implemented trait. How can I call method on that contract address ?
Description:
I have a trait called ITrait which has verify method
fn verify(&self, _metadata: Bytes, _message: Bytes) -> bool;
}```
This trait can be implemented by any contract that wants to implement verify method.
For e.g.
```impl ITrait for Contract1 {
fn verify(&self, _metadata: Bytes, _message: Bytes) -> bool {
...some logic here...
}
}```
Now main contract's initialize method looks like this
```impl MainContract {
pub fn initialize(env: Env, address: Address) {
env.storage().instance().set(&TRAIT_CONTRACT, &address);
}
pub fn someMethod(env: Env) {
const address = env.storage().instance().get(&TRAIT_CONTRACT);
// I want to call method here dynamically so that it doesn't throw any type error
// address.verify(metadata, message)
}
}```
In `someMethod` I want to call that contract's `verify` method.
I also want to make sure that address passed in `initialize` is `contract address` and has `verify` method
How can I achieve that in Soroban ? I am new to soroban, so not sure whether this is possible or not. Let me know if there is any another approach that can handle this.
Thank you