Skip to content

Commit

Permalink
Renames frame crate to polkadot-sdk-frame (#3813)
Browse files Browse the repository at this point in the history
Step in #3155

Needed for paritytech/eng-automation#6

This PR renames `frame` crate to `polkadot-sdk-frame` as `frame` is not
available on crates.io

---------

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
  • Loading branch information
codekitz and kianenigma authored Apr 4, 2024
1 parent 0f4e849 commit 3836376
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 78 deletions.
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.11.1", 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
24 changes: 14 additions & 10 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@
//!
//! In short, this crate only re-exports types and traits from multiple sources. All of these
//! sources are listed (and re-exported again) in [`deps`].
//!
//! ## Usage
//!
//! Please note that this crate can only be imported as `polkadot-sdk-frame` or `frame`.

#![cfg_attr(not(feature = "std"), no_std)]
#![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 +79,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 +88,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 +116,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 +145,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 +190,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 +334,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
Loading

0 comments on commit 3836376

Please sign in to comment.