Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export_service macro should honor method name in #[ic_cdk_macros::query(name = "method_name")] #418

Closed
dansteren opened this issue Apr 12, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@dansteren
Copy link

Describe the bug
If a rust method is exposed to the IC under a different name using the name attribute in #[ic_cdk_macros::query(name = "method_name")], the export_service macro should also honor that name when generating the corresponding candid.

To Reproduce
Steps to reproduce the behavior:

  1. Annotate a canister method with #[candid::candid_method(query)] and #[ic_cdk_macros::query(name = "candid_method")]
  2. Call the export_service macro
  3. Notice that the generated candid exposes the native rust function name, not the name provided to ic_cdk_marcros::query.

OR

  1. Clone https://github.com/dansteren/export_service_bug
  2. Follow the steps to reproduce listed in the readme

Expected behavior
Calling the export_service macro should generate a candid file where the method matches the name passed to ic_cdk_marcros::query

@chenyan-dfinity
Copy link
Contributor

Ack. We are in the process of merging these two attributes. Before that, candid_method has a rename attribute. If you make it the same as query(name = "..."), it should work.

@dansteren
Copy link
Author

That worked, Thanks! Just added that rename attribute for now. E.g.

#[candid::candid_method(query, rename = "candid_method")]
#[ic_cdk_macros::query(name = "candid_method")]
pub fn rust_method() -> bool {
    true
}

If it's easy to add into the documenation that would be helpful for others in the future. Otherwise I look forward to the two attributes merging in the future. That will be much better.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants