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

Renames frame crate to polkadot-sdk-frame #3813

Merged
merged 32 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d8e6233
Initial changes
gupnik Mar 22, 2024
0e2f694
Further changes
gupnik Mar 26, 2024
5a2ec92
Adds PrDoc
gupnik Mar 26, 2024
458205d
Fmt
gupnik Mar 26, 2024
ca90b7f
Fixes frame example
gupnik Mar 26, 2024
550ab70
Fixes stg
gupnik Mar 26, 2024
6c9cb60
Fixes path
gupnik Mar 26, 2024
9cc892f
Fixes template
gupnik Mar 26, 2024
1eb6cfc
Updates doc links
gupnik Mar 26, 2024
33a6590
Updates doc links
gupnik Mar 26, 2024
0866b5f
Fmt
gupnik Mar 26, 2024
7aeb3d9
Merge branch 'master' into gupnik/frame-crate-rename
codekitz Mar 26, 2024
42df1ac
Fixes doc link
gupnik Mar 26, 2024
fd6bad2
Fixes doc link
gupnik Mar 26, 2024
7bdb934
Fixes doc link and taplo
gupnik Mar 26, 2024
2cf4e20
Adds ability to use either frame or polkadot-sdk-frame
gupnik Apr 1, 2024
7192bcc
Uses renamed crate in docs
gupnik Apr 1, 2024
77912f9
Uses renamed crate in template
gupnik Apr 1, 2024
69f5bbe
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gupn…
gupnik Apr 1, 2024
ba183b3
Removes changes in docs
gupnik Apr 1, 2024
01cd2c8
Removes changes in example
gupnik Apr 1, 2024
23f9c12
Removes changes in template node
gupnik Apr 1, 2024
8161793
Removes changes in stg
gupnik Apr 1, 2024
3971887
Adds bump in prdoc
gupnik Apr 1, 2024
c6333be
Update substrate/frame/support/procedural/tools/src/lib.rs
codekitz Apr 1, 2024
2dbd88d
Update substrate/frame/support/procedural/tools/src/lib.rs
codekitz Apr 1, 2024
f81bacb
Update substrate/utils/frame/rpc/support/src/lib.rs
codekitz Apr 1, 2024
c117a87
Addresses review comments
gupnik Apr 1, 2024
174bd64
Fmt
gupnik Apr 1, 2024
749eec3
Adds test and updates docs
gupnik Apr 3, 2024
40daf88
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gupn…
gupnik Apr 3, 2024
8af848e
Fmt
gupnik Apr 3, 2024
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
70 changes: 35 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workspace = true
# Needed for all FRAME-based code
parity-scale-codec = { version = "3.0.0", default-features = false }
scale-info = { version = "2.6.0", default-features = false }
frame = { path = "../../substrate/frame", features = [
frame = { package = "polkadot-sdk-frame", path = "../../substrate/frame", features = [
"experimental",
"runtime",
] }
Expand Down
14 changes: 14 additions & 0 deletions prdoc/pr_3813.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Renames `frame` crate to `polkadot-sdk-frame`

doc:
- audience: Runtime Dev
description: |
This PR renames `frame` crate to `polkadot-sdk-frame` as `frame` is not available on crates.io.
Please note that this crate can only be imported as `polkadot-sdk-frame` or `frame`.

crates:
- name: polkadot-sdk-frame
bump: major
2 changes: 1 addition & 1 deletion substrate/client/chain-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
//! <td>A JSON object that provides an explicit and comprehensive representation of the
//! <code>RuntimeGenesisConfig</code> struct, which is generated by <a
//! href="../frame_support_procedural/macro.construct_runtime.html"
//! ><code>frame::runtime::prelude::construct_runtime</code></a> macro (<a
//! ><code>polkadot_sdk_frame::runtime::prelude::construct_runtime</code></a> macro (<a
//! href="../substrate_test_runtime/struct.RuntimeGenesisConfig.html#"
//! >example of generated struct</a>). Must contain all the keys of
//! the genesis config, no defaults will be used.
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "frame"
version = "0.0.1-dev"
name = "polkadot-sdk-frame"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/examples/frame-crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }

frame = { path = "../..", default-features = false, features = ["experimental", "runtime"] }
frame = { package = "polkadot-sdk-frame", path = "../..", default-features = false, features = ["experimental", "runtime"] }


[features]
Expand Down
20 changes: 10 additions & 10 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
#![cfg(feature = "experimental")]

/// Exports the main pallet macro. This can wrap a `mod pallet` and will transform it into
/// being a pallet, eg `#[frame::pallet] mod pallet { .. }`.
/// being a pallet, eg `#[polkadot_sdk_frame::pallet] mod pallet { .. }`.
///
/// Note that this is not part of the prelude, in order to make it such that the common way to
/// define a macro is `#[frame::pallet] mod pallet { .. }`, followed by `#[pallet::foo]`,
/// `#[pallet::bar]` inside the mod.
/// define a macro is `#[polkadot_sdk_frame::pallet] mod pallet { .. }`, followed by
/// `#[pallet::foo]`, `#[pallet::bar]` inside the mod.
pub use frame_support::pallet;

pub use frame_support::pallet_macros::{import_section, pallet_section};
Expand All @@ -75,7 +75,7 @@ pub mod pallet_macros {
/// This prelude should almost always be the first line of code in any pallet or runtime.
///
/// ```
/// use frame::prelude::*;
/// use polkadot_sdk_frame::prelude::*;
///
/// // rest of your pallet..
/// mod pallet {}
Expand All @@ -84,7 +84,7 @@ pub mod prelude {
/// `frame_system`'s parent crate, which is mandatory in all pallets build with this crate.
///
/// Conveniently, the keyword `frame_system` is in scope as one uses `use
/// frame::prelude::*`
/// polkadot_sdk_frame::prelude::*`
#[doc(inline)]
pub use frame_system;

Expand Down Expand Up @@ -112,7 +112,7 @@ pub mod prelude {
/// A test setup typically starts with:
///
/// ```
/// use frame::testing_prelude::*;
/// use polkadot_sdk_frame::testing_prelude::*;
/// // rest of your test setup.
/// ```
#[cfg(feature = "std")]
Expand Down Expand Up @@ -141,7 +141,7 @@ pub mod runtime {
/// A runtime typically starts with:
///
/// ```
/// use frame::{prelude::*, runtime::prelude::*};
/// use polkadot_sdk_frame::{prelude::*, runtime::prelude::*};
/// ```
pub mod prelude {
/// All of the types related to the FRAME runtime executive.
Expand Down Expand Up @@ -186,7 +186,7 @@ pub mod runtime {
/// A non-testing runtime should have this enabled, as such:
///
/// ```
/// use frame::runtime::{prelude::*, apis::{*,}};
/// use polkadot_sdk_frame::runtime::{prelude::*, apis::{*,}};
/// ```
// TODO: This is because of wildcard imports, and it should be not needed once we can avoid
// that. Imports like that are needed because we seem to need some unknown types in the macro
Expand Down Expand Up @@ -330,8 +330,8 @@ pub mod derive {
/// In most cases, hopefully the answer is yes.
pub mod deps {
// TODO: It would be great to somehow instruct RA to prefer *not* suggesting auto-imports from
// these. For example, we prefer `frame::derive::CloneNoBound` rather than
// `frame::deps::frame_support::CloneNoBound`.
// these. For example, we prefer `polkadot_sdk_frame::derive::CloneNoBound` rather than
// `polkadot_sdk_frame::deps::frame_support::CloneNoBound`.
pub use frame_support;
pub use frame_system;

Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
"{}::macro_magic",
match generate_access_from_frame_or_crate("frame-support") {
Ok(path) => Ok(path),
Err(_) => generate_access_from_frame_or_crate("frame"),
Err(_) => generate_access_from_frame_or_crate("polkadot-sdk-frame"),
}
.expect("Failed to find either `frame-support` or `frame` in `Cargo.toml` dependencies.")
.expect("Failed to find either `frame-support` or `polkadot-sdk-frame` in `Cargo.toml` dependencies.")
.to_token_stream()
.to_string()
)
Expand Down Expand Up @@ -1181,9 +1181,9 @@ pub fn pallet_section(attr: TokenStream, tokens: TokenStream) -> TokenStream {
"{}::macro_magic",
match generate_access_from_frame_or_crate("frame-support") {
Ok(path) => Ok(path),
Err(_) => generate_access_from_frame_or_crate("frame"),
Err(_) => generate_access_from_frame_or_crate("polkadot-sdk-frame"),
}
.expect("Failed to find either `frame-support` or `frame` in `Cargo.toml` dependencies.")
.expect("Failed to find either `frame-support` or `polkadot-sdk-frame` in `Cargo.toml` dependencies.")
.to_token_stream()
.to_string()
)
Expand Down
33 changes: 21 additions & 12 deletions substrate/frame/support/procedural/src/pallet/parse/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ fn check_event_type(
}

/// Check that the path to `frame_system::Config` is valid, this is that the path is just
/// `frame_system::Config` or when using the `frame` crate it is `frame::xyz::frame_system::Config`.
/// `frame_system::Config` or when using the `frame` crate it is
/// `polkadot_sdk_frame::xyz::frame_system::Config`.
fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool {
// Check if `frame_system` is actually 'frame_system'.
if path.segments.iter().all(|s| s.ident != "frame_system") {
Expand All @@ -293,7 +294,7 @@ fn has_expected_system_config(path: syn::Path, frame_system: &syn::Path) -> bool
// `frame` re-exports it as such.
syn::parse2::<syn::Path>(quote::quote!(frame_system)).expect("is a valid path; qed"),
(_, _) =>
// They are either both `frame_system` or both `frame::xyz::frame_system`.
// They are either both `frame_system` or both `polkadot_sdk_frame::xyz::frame_system`.
frame_system.clone(),
};

Expand Down Expand Up @@ -517,52 +518,60 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_frame() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system)).unwrap();
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(frame_system::Config)).unwrap();
assert!(has_expected_system_config(path, &frame_system));
}

#[test]
fn has_expected_system_config_works_with_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system))
.unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system::Config))
.unwrap();
assert!(has_expected_system_config(path, &frame_system));
}

#[test]
fn has_expected_system_config_works_with_other_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system::Config))
.unwrap();
assert!(has_expected_system_config(path, &frame_system));
}

#[test]
fn has_expected_system_config_does_not_works_with_mixed_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system::Config))
.unwrap();
assert!(!has_expected_system_config(path, &frame_system));
}

#[test]
fn has_expected_system_config_does_not_works_with_other_mixed_frame_full_path() {
let frame_system =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system))
.unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::xyz::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::xyz::frame_system::Config))
.unwrap();
assert!(!has_expected_system_config(path, &frame_system));
}

#[test]
fn has_expected_system_config_does_not_work_with_frame_full_path_if_not_frame_crate() {
let frame_system = syn::parse2::<syn::Path>(quote::quote!(frame_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(frame::deps::frame_system::Config)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(polkadot_sdk_frame::deps::frame_system::Config))
.unwrap();
assert!(!has_expected_system_config(path, &frame_system));
}

Expand Down
Loading
Loading