Skip to content

Commit

Permalink
chore: Remove msg_type method from MsgVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Sep 17, 2024
1 parent d4d5ba8 commit 64daae9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 8 additions & 4 deletions sylvia-derive/src/contract/communication/struct_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,24 @@ impl<'a> StructMessage<'a> {
let bracketed_unused_generics = emit_bracketed_generics(unused_generics);

let ret_type = variant
.msg_attr()
.msg_type()
.emit_result_type(&custom.msg_or_default(), &error.error);
let name = variant.msg_type().emit_msg_name();
let name = variant.msg_attr().msg_type().emit_msg_name();

Check warning on line 102 in sylvia-derive/src/contract/communication/struct_msg.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/contract/communication/struct_msg.rs#L102

Added line #L102 was not covered by tests
let function_name = variant.function_name();
let mut msg_name = variant.msg_type().emit_msg_name();
let mut msg_name = variant.msg_attr().msg_type().emit_msg_name();

Check warning on line 104 in sylvia-derive/src/contract/communication/struct_msg.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/contract/communication/struct_msg.rs#L104

Added line #L104 was not covered by tests
msg_name.set_span(function_name.span());

let ctx_type = variant.msg_type().emit_ctx_type(&custom.query_or_default());
let ctx_type = variant

Check warning on line 107 in sylvia-derive/src/contract/communication/struct_msg.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/contract/communication/struct_msg.rs#L107

Added line #L107 was not covered by tests
.msg_attr()
.msg_type()
.emit_ctx_type(&custom.query_or_default());

Check warning on line 110 in sylvia-derive/src/contract/communication/struct_msg.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/contract/communication/struct_msg.rs#L110

Added line #L110 was not covered by tests
let fields_names: Vec<_> = variant.fields().iter().map(MsgField::name).collect();
let parameters = variant.fields().iter().map(MsgField::emit_method_field);
let fields = variant.fields().iter().map(MsgField::emit_pub);

let msg_attrs_to_forward = msg_attrs_to_forward.iter().map(|attr| &attr.attrs);
let derive_call = variant.msg_type().emit_derive_call();
let derive_call = variant.msg_attr().msg_type().emit_derive_call();

Check warning on line 116 in sylvia-derive/src/contract/communication/struct_msg.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/contract/communication/struct_msg.rs#L116

Added line #L116 was not covered by tests

quote! {
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
8 changes: 4 additions & 4 deletions sylvia-derive/src/contract/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,10 @@ impl EmitMethods for MsgVariant<'_> {
.map(|field| field.emit_method_field_folded())
.collect();
let arguments = self.as_fields_names();
let type_name = self.msg_type().as_accessor_name();
let type_name = self.msg_attr().msg_type().as_accessor_name();
let name = name.to_case(Case::Snake);

match self.msg_type() {
match self.msg_attr().msg_type() {
MsgType::Exec => quote! {
#[track_caller]
fn #name (&self, #(#params,)* ) -> #sylvia ::multitest::ExecProxy::< #error_type, #api :: #type_name, #mt_app, #custom_msg> {
Expand Down Expand Up @@ -721,10 +721,10 @@ impl EmitMethods for MsgVariant<'_> {
.iter()
.map(|field| field.emit_method_field_folded())
.collect();
let type_name = self.msg_type().as_accessor_name();
let type_name = self.msg_attr().msg_type().as_accessor_name();
let name = name.to_case(Case::Snake);

match self.msg_type() {
match self.msg_attr().msg_type() {
MsgType::Exec => quote! {
fn #name (&self, #(#params,)* ) -> #sylvia ::multitest::ExecProxy::< #error_type, #api:: #type_name, MtApp, #custom_msg>;
},
Expand Down
8 changes: 4 additions & 4 deletions sylvia-derive/src/interface/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ impl EmitMethods for MsgVariant<'_> {
.map(|field| field.emit_method_field_folded())
.collect();
let arguments = self.as_fields_names();
let type_name = self.msg_type().as_accessor_name();
let type_name = self.msg_attr().msg_type().as_accessor_name();
let name = name.to_case(Case::Snake);

match self.msg_type() {
match self.msg_attr().msg_type() {
MsgType::Exec => quote! {
#[track_caller]
fn #name (&self, #(#params,)* ) -> #sylvia ::multitest::ExecProxy::< #error_type, #api :: #type_name, #mt_app, #custom_msg> {
Expand Down Expand Up @@ -261,10 +261,10 @@ impl EmitMethods for MsgVariant<'_> {
.iter()
.map(|field| field.emit_method_field_folded())
.collect();
let type_name = self.msg_type().as_accessor_name();
let type_name = self.msg_attr().msg_type().as_accessor_name();
let name = name.to_case(Case::Snake);

match self.msg_type() {
match self.msg_attr().msg_type() {
MsgType::Exec => quote! {
fn #name (&self, #(#params,)* ) -> #sylvia ::multitest::ExecProxy::< #error_type, #api:: #type_name, MtApp, #custom_msg>;
},
Expand Down
4 changes: 0 additions & 4 deletions sylvia-derive/src/types/msg_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ impl<'a> MsgVariant<'a> {
&self.fields
}

pub fn msg_type(&self) -> MsgType {
self.msg_attr.msg_type()
}

pub fn msg_attr(&self) -> &MsgAttr {
&self.msg_attr
}
Expand Down

0 comments on commit 64daae9

Please sign in to comment.