CosmWasm / sylvia

CosmWasm smart contract framework
Apache License 2.0
93 stars 14 forks source link

Remove `ExecC` and `QueryC` #294

Open jawoznia opened 7 months ago

jawoznia commented 7 months ago

Once we will support associated types we might consider removing additional support for ExecC and QueryC associated types and allow users to specify their own types as custom using the sv::custom() attribute.

Motivation

Currently our API allows interface to be defined in two ways:

Since we already forward the associated types I think it would make sense to simplify the API by allowing the user to use only the sv::custom attribute with either solid type or the associated type.

I see the benefit of using standardized type names for better clarity when implementing the interface which type is responsible for what, but I think that it would be easier for user to look in a single place to determine the custom types. This also has a benefit of simplifying sylvia code.

#[interface]
#[sv::custom(msg=Exec, query=Query)]
pub trait MyInterface {
    type Error;
    type Exec: CustomMsg;
    type Query: CustomQuery;
}
hashedone commented 6 months ago

I'm good with that, but:

#[interface]
#[sv::custom(msg=Self::Exec, query=Self::Query)]
pub trait MyInterface {
    type Error;
    type Exec: CustomMsg;
    type Query: CustomQuery;
}
kulikthebird commented 4 months ago

If this becomes a mandatory attribute, let's consider something like this:

#[interface(custom_msg=Self::Exec, custom_query=Self::Query))]
pub trait MyInterface {
    type Error;
    type Exec: CustomMsg;
    type Query: CustomQuery;
}