Skip to content

Commit

Permalink
chore: Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Aug 19, 2024
1 parent dd7e0f9 commit 4ff2a42
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sylvia-derive/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a> ContractInput<'a> {
}
}

/// Process the input and generate the contract code.
/// Processes the input and generates the contract code.
pub fn process(&self) -> TokenStream {
let Self {
item,
Expand Down
5 changes: 4 additions & 1 deletion sylvia-derive/src/contract/communication/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use crate::types::msg_field::MsgField;
use crate::types::msg_variant::{MsgVariant, MsgVariants};
use crate::utils::SvCasing;

/// Emits execute helper
/// Emits [execute helper](https://cosmwasm-docs.vercel.app/sylvia/macros/generated-types/communication#executor-helpers).
///
/// Generates trait containing methods for each execute message variant and implements it on
/// `sylvia::types::ExecutorBuilder<EmptyExecutorBuilderState>`.
pub struct Executor<'a> {
generics: Generics,
self_ty: Type,
Expand Down
5 changes: 4 additions & 1 deletion sylvia-derive/src/contract/communication/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use crate::types::msg_field::MsgField;
use crate::types::msg_variant::{MsgVariant, MsgVariants};
use crate::utils::SvCasing;

/// Emits query helper
/// Emits [query helper](https://cosmwasm-docs.vercel.app/sylvia/macros/generated-types/communication#query-helpers).
///
/// Generates trait containing methods for each query message variant and implements it on
/// `sylvia::types::BoundQuerier<Contract>`.
pub struct Querier<'a> {
generics: Generics,
self_ty: Type,
Expand Down
5 changes: 4 additions & 1 deletion sylvia-derive/src/contract/communication/wrapper_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use syn::spanned::Spanned;
use syn::{Ident, ItemImpl, Type};

/// Glue message is the message composing Exec/Query/Sudo messages from several traits and a
/// contract
/// contract.
///
/// It's required for the contract to receive all possible message variants in the entry points.
/// More info [here](https://cosmwasm-docs.vercel.app/sylvia/macros/generated-types/message-types).
#[derive(Debug)]
pub struct GlueMessage<'a> {
source: &'a ItemImpl,
Expand Down
2 changes: 2 additions & 0 deletions sylvia-derive/src/contract/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ fn get_ident_from_type(contract_name: &Type) -> &Ident {
}

/// Emits helpers for testing contract messages using MultiTest.
///
/// More info here: [MultiTest helpers](https://cosmwasm-docs.vercel.app/sylvia/macros/generated-types/multitest).
pub struct MtHelpers<'a> {
error_type: Type,
contract_name: &'a Type,
Expand Down
5 changes: 4 additions & 1 deletion sylvia-derive/src/entry_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> EntryPointInput<'a> {
Self { item, args }
}

/// Process the input and generate the interface code.
/// Process the input and generate the entry points code.
pub fn process(&self) -> TokenStream {
let Self { item, args } = self;

Expand All @@ -56,6 +56,9 @@ impl<'a> EntryPointInput<'a> {
}

/// Defines logic for generating entry points.
///
/// By default generates entry points for `instantiate`, `execute`, `query` and `sudo` messages.
/// Generates `reply` and `migrate` entry points if respective messages are defined.
pub struct EntryPoints<'a> {
source: &'a ItemImpl,
name: Type,
Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a> InterfaceInput<'a> {
}
}

/// Process the input and generate the interface code.
/// Processes the input and generates the interface code.
pub fn process(&self) -> TokenStream {
let Self {
associated_types,
Expand Down
4 changes: 4 additions & 0 deletions sylvia-derive/src/interface/communication/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use quote::quote;
use syn::ItemTrait;

/// Emits `InterfaceMessagesApi` trait.
///
/// The `InterfaceMessagesApi` is a helper trait to access messages generated by the `interface`
/// macro.
/// It ease the dispatch of generic types.
pub struct Api<'a> {
source: &'a ItemTrait,
associated_types: &'a AssociatedTypes<'a>,
Expand Down
5 changes: 4 additions & 1 deletion sylvia-derive/src/interface/communication/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use crate::types::msg_field::MsgField;
use crate::types::msg_variant::{MsgVariant, MsgVariants};
use crate::utils::SvCasing;

/// Emits query helper
/// Emits [query helper](https://cosmwasm-docs.vercel.app/sylvia/macros/generated-types/communication#query-helpers).
///
/// Generates trait containing methods for each query message variant and implements it on
/// `sylvia::types::BoundQuerier<Contract>`.
pub struct Querier<'a, Generic> {
variants: &'a MsgVariants<'a, Generic>,
associated_types: &'a AssociatedTypes<'a>,
Expand Down
12 changes: 4 additions & 8 deletions sylvia-derive/src/types/associated_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,12 @@ impl<'a> AssociatedTypes<'a> {
trait_name: &Ident,
type_name: &str,
) -> Option<Type> {
match self
.as_names()
self.as_names()
.find(|name| name.to_string().as_str() == type_name)
{
Some(name) => {
.map(|name| {
let type_name = Ident::new(type_name, name.span());
Some(parse_quote! { <ContractT as #trait_name>:: #type_name})
}
None => None,
}
parse_quote! { <ContractT as #trait_name>:: #type_name}
})
}
}

Expand Down

0 comments on commit 4ff2a42

Please sign in to comment.