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

[Fix] Contract source metadata compilation issue. #1118

Merged
merged 11 commits into from
Dec 20, 2023

Conversation

ruseinov
Copy link
Collaborator

Fixes #1117

@@ -116,6 +117,7 @@ pub fn near_bindgen(attr: TokenStream, item: TokenStream) -> TokenStream {

if let Ok(input) = syn::parse::<ItemStruct>(item.clone()) {
let metadata = core_impl::contract_source_metadata_const(attr);
let metadata_impl_gen = generate_metadata_impl(&input.ident, &input.generics);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the generated function will only be implemented on the contract struct, but not exposed as contract methods and ABI is not generated for it. This has to be fixed and also test added as we obviously could have missed it unless I happened to spot it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. That indeed needs to be pushed into input instead in order to be properly processed.
I'll add a test for that and add an issue to have an automated test later that would perhaps go through all the defined methods and check if the abi is generated for them. Gotta see if this can be easily implemented, but definitely out of scope of this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Merge contents of near-sdk-macros/src/core_impl/contract_metadata/mod.rs into this file
  • Rename this file to contract_metadata.rs
  • Rename generate_metadata_impl function to generate_contract_metadata_method

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory structure follows the same pattern as all the other traits that are being implemented via macro/codegen. I would argue that we should either convert all of them or none. I would personally find having those traits under code_generator a bit confusing.
The rename is not a problem though.

near-sdk-macros/src/lib.rs Outdated Show resolved Hide resolved
near-sdk-macros/src/lib.rs Outdated Show resolved Hide resolved
@frol frol marked this pull request as draft December 19, 2023 19:25
@ruseinov ruseinov requested a review from frol December 20, 2023 08:56
@ruseinov ruseinov marked this pull request as ready for review December 20, 2023 09:04
@frol frol merged commit 5f47ad6 into near:master Dec 20, 2023
14 checks passed
@frol frol mentioned this pull request Dec 20, 2023
@ruseinov ruseinov deleted the ru/fix/compilation-err branch January 12, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation error due to duplicate definitions for 'contract_source_metadata*
2 participants