Skip to content

Commit

Permalink
near-sdk-macros: delete the metadata module
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed Aug 18, 2023
1 parent 4c5b679 commit b6b6f47
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 315 deletions.
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

0 comments on commit b6b6f47

Please sign in to comment.