-
Notifications
You must be signed in to change notification settings - Fork 249
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
Conversation
near-sdk-macros/src/lib.rs
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 togenerate_contract_metadata_method
There was a problem hiding this comment.
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.
4e6bbec
to
d33e537
Compare
31bd6f7
to
5598578
Compare
Fixes #1117