-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed
contract_source_metadata
compilation issue when multiple…
… impl blocks are there (#1118)
- Loading branch information
Showing
7 changed files
with
115 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use proc_macro2::Ident; | ||
use quote::quote; | ||
use syn::Generics; | ||
|
||
/// Generates a view method to retrieve the source metadata. | ||
pub(crate) fn generate_contract_metadata_method( | ||
ident: &Ident, | ||
generics: &Generics, | ||
) -> proc_macro2::TokenStream { | ||
quote! { | ||
impl #generics #ident #generics { | ||
pub fn contract_source_metadata() { | ||
near_sdk::env::value_return(CONTRACT_SOURCE_METADATA.as_bytes()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use near_account_id::AccountIdRef; | ||
use near_sdk::near_bindgen; | ||
|
||
#[near_bindgen] | ||
struct Contract {} | ||
|
||
#[near_bindgen] | ||
impl Contract { | ||
pub fn anything() {} | ||
} | ||
|
||
#[near_bindgen] | ||
impl Contract { | ||
pub fn anything_else() {} | ||
} | ||
|
||
fn main() { | ||
let ext = Contract::ext(AccountIdRef::new_or_panic("0000").into()); | ||
ext.contract_source_metadata(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
error: Impl type parameters are not supported for smart contracts. | ||
--> $DIR/impl_generic.rs:15:6 | ||
--> compilation_tests/impl_generic.rs:10:20 | ||
| | ||
15 | impl<'a, T: 'a + std::fmt::Display> Incrementer<T> { | ||
10 | struct Incrementer<T> { | ||
| ^ | ||
|
||
error: Impl type parameters are not supported for smart contracts. | ||
--> compilation_tests/impl_generic.rs:16:6 | ||
| | ||
16 | impl<'a, T: 'a + std::fmt::Display> Incrementer<T> { | ||
| ^^ |