pub enum ContractSudoMsg<SomeGeneric>
where
SomeGeneric: sylvia::types::CustomMsg,
{
InterfaceAssoc(
<interface_assoc::sv::Api<
SomeGeneric,
> as sylvia::types::InterfaceApi>::Sudo,
),
ContractGeneric(SudoMsg),
}
In the code above the generics from sv::messages are passed to the Api structure in the contract main impl block by #[contract] macro.
Proposal
A new trait should be implemented by the #[inteface] macro:
mod some_interface {
mod sv {
// #[sylvia::interface] generates the new trait:
pub trait InterfaceApi {
type Sudo;
type Exec;
type Query;
}
// #[sylvia::interface] implements the above trait for every contract
// that impelments given interface, in this example `SomeInterface`
//
impl<Contract: SomeInterface> InterfaceApi for Contract {
type Sudo = SudoMsg<SomeInterface::SomeGeneric>
// type Exec = ExecMsg<SomeInterface::SomeGenericForExec>
// type Query = QueryMsg<SomeInterface::SomeGenericForQuery>
}
}
}
Now, the above example Sudo message could be transformed to something like the following:
pub enum ContractSudoMsg<Contract>
where
Contract: interface_assoc::sv::InterfaceApi,
// etc. for all other sv::messages
{
SomeInterface(
<Contract as some_interface::sv::InterfaceApi>::Sudo,
),
ContractGeneric(SudoMsg),
}
Summary:
sylvia::types::InterfaceApi and some_interface::sv::Api should be removed.
A trait InterfaceApi should be generated per interface in sv module.
A new InterfaceApi is implemented for every contract that implements the given interface SomeInterface.
Let's take Sudo message generation as example:
In the code above the generics from
sv::messages
are passed to theApi
structure in the contract main impl block by#[contract]
macro.Proposal
A new trait should be implemented by the
#[inteface]
macro:Now, the above example Sudo message could be transformed to something like the following:
Summary:
sylvia::types::InterfaceApi
andsome_interface::sv::Api
should be removed.InterfaceApi
should be generated per interface insv
module.InterfaceApi
is implemented for every contract that implements the given interfaceSomeInterface
.