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

Delete the metadata module from near-sdk-macros #1072

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 0 additions & 119 deletions near-sdk-macros/src/core_impl/metadata/metadata_generator.rs

This file was deleted.

159 changes: 0 additions & 159 deletions near-sdk-macros/src/core_impl/metadata/metadata_visitor.rs

This file was deleted.

2 changes: 0 additions & 2 deletions near-sdk-macros/src/core_impl/metadata/mod.rs

This file was deleted.

2 changes: 0 additions & 2 deletions near-sdk-macros/src/core_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ pub(crate) mod abi;
mod code_generator;
mod event;
mod info_extractor;
mod metadata;
mod utils;
pub(crate) use code_generator::*;
pub(crate) use event::{get_event_version, near_events};
pub(crate) use info_extractor::*;
pub(crate) use metadata::metadata_visitor::MetadataVisitor;
34 changes: 1 addition & 33 deletions near-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use proc_macro::TokenStream;
use self::core_impl::*;
use proc_macro2::Span;
use quote::{quote, ToTokens};
use syn::visit::Visit;
use syn::{parse_quote, File, ItemEnum, ItemImpl, ItemStruct, ItemTrait, WhereClause};
use syn::{parse_quote, ItemEnum, ItemImpl, ItemStruct, ItemTrait, WhereClause};

/// This attribute macro is used on a struct and its implementations
/// to generate the necessary code to expose `pub` methods from the contract as well
Expand Down Expand Up @@ -245,37 +244,6 @@ pub fn init(_attr: TokenStream, item: TokenStream) -> TokenStream {
item
}

/// `metadata` generates the metadata method and should be placed at the very end of the `lib.rs` file.
// TODO: Once Rust allows inner attributes and custom procedural macros for modules we should switch this
// to be `#![metadata]` attribute at the top of the contract file instead. https://github.com/rust-lang/rust/issues/54727
#[deprecated(
since = "4.1.0",
note = "metadata macro is no longer used. Use https://github.com/near/abi to generate a contract schema"
)]
#[proc_macro]
pub fn metadata(item: TokenStream) -> TokenStream {
if let Ok(input) = syn::parse::<File>(item) {
let mut visitor = MetadataVisitor::new();
visitor.visit_file(&input);
let generated = match visitor.generate_metadata_method() {
Ok(x) => x,
Err(err) => return TokenStream::from(err.to_compile_error()),
};
TokenStream::from(quote! {
#input
#generated
})
} else {
TokenStream::from(
syn::Error::new(
Span::call_site(),
"Failed to parse code decorated with `metadata!{}` macro. Only valid Rust is supported.",
)
.to_compile_error(),
)
}
}

#[cfg(feature = "abi")]
#[proc_macro_derive(NearSchema, attributes(abi, serde, borsh_skip, schemars, validate))]
pub fn derive_near_schema(input: TokenStream) -> TokenStream {
Expand Down
36 changes: 0 additions & 36 deletions near-sdk/src/private/metadata.rs

This file was deleted.

3 changes: 0 additions & 3 deletions near-sdk/src/private/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ pub use near_abi::{
#[cfg(feature = "abi")]
pub use schemars;

mod metadata;
pub use metadata::{Metadata, MethodMetadata};

use crate::IntoStorageKey;
use borsh::BorshSerialize;

Expand Down
Loading