This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Extend PalletInfoAccess with module_name and crate_version method #9690
Merged
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6490874
Record pallet indices in CallMetadata
KiChjang edb7f2e
Resurrect PalletVersion infrastructure and rename as CrateVersion
KiChjang e9d8acc
cargo fmt
KiChjang c57286b
Add missing runtime generics to pallet struct
KiChjang 46b0b6e
Fix path to instance
KiChjang c24eccf
Fix test
KiChjang 748eb2d
Fix UI test expectations
KiChjang 08beeb8
Fix UI test expectations
KiChjang 4a338ab
Move crate_version function to PalletInfoAccess
KiChjang 7778c58
Update UI test expectations
KiChjang cd4c2b9
Add crate_name method to PalletInfo
KiChjang b2bf276
Convert path to module name instead of exposing crate name
KiChjang 41dacef
cargo fmt
KiChjang e9c3f6c
Keep the double colons when constructing the module name
KiChjang 3d73ba9
Remove unused import
KiChjang a7ae596
Update UI test expectations
KiChjang 9f02c4b
Update frame/support/src/traits/metadata.rs
KiChjang c7304b4
Merge branch 'master' into kckyeung/extend-call-metadata
KiChjang 49e439b
Merge remote-tracking branch 'origin' into kckyeung/extend-call-metadata
KiChjang 9727fb3
Update UI test expectations
KiChjang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2020-2021 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Implementation of macros related to crate versioning. | ||
|
|
||
| use frame_support_procedural_tools::generate_crate_access_2018; | ||
| use proc_macro2::{Span, TokenStream}; | ||
| use syn::{Error, Result}; | ||
| use super::get_cargo_env_var; | ||
|
|
||
| /// Create an error that will be shown by rustc at the call site of the macro. | ||
| fn create_error(message: &str) -> Error { | ||
| Error::new(Span::call_site(), message) | ||
| } | ||
|
|
||
| /// Implementation of the `crate_to_crate_version!` macro. | ||
| pub fn crate_to_crate_version(input: proc_macro::TokenStream) -> Result<TokenStream> { | ||
| if !input.is_empty() { | ||
| return Err(create_error("No arguments expected!")) | ||
| } | ||
|
|
||
| let major_version = get_cargo_env_var::<u16>("CARGO_PKG_VERSION_MAJOR") | ||
| .map_err(|_| create_error("Major version needs to fit into `u16`"))?; | ||
|
|
||
| let minor_version = get_cargo_env_var::<u8>("CARGO_PKG_VERSION_MINOR") | ||
| .map_err(|_| create_error("Minor version needs to fit into `u8`"))?; | ||
|
|
||
| let patch_version = get_cargo_env_var::<u8>("CARGO_PKG_VERSION_PATCH") | ||
| .map_err(|_| create_error("Patch version needs to fit into `u8`"))?; | ||
|
|
||
| let crate_ = generate_crate_access_2018("frame-support")?; | ||
|
|
||
| Ok(quote::quote! { | ||
| #crate_::traits::CrateVersion { | ||
| major: #major_version, | ||
| minor: #minor_version, | ||
| patch: #patch_version, | ||
| } | ||
| }) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.