paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.77k stars 632 forks source link

Old version support ("polkadot-v1.0.0") (as the tut said) #5171

Closed zzz6519003 closed 1 month ago

zzz6519003 commented 1 month ago

as the tut, https://docs.substrate.io/tutorials/collectibles-workshop/03-create-pallet/

what should I do if I want to use

[dependencies]
frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "polkadot-v1.0.0"}
frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "polkadot-v1.0.0" }
gui1117 commented 1 month ago

it should be added the Cargo.toml of your crate.

what is the question?

zzz6519003 commented 1 month ago

Thx for reply, can’t find the url.

install fail cuz link broken, no branch name called this

ggwpez commented 1 month ago

1.0 was still released before we had the mono-repo in the old substrate repo.

Adding these crates with a specific branch is very old school, i will try to update that tutorial. Nowadays we have the polkadot-sdk, docs (umbrella) crate, that bundles all other crates with compatible versions.

zzz6519003 commented 1 month ago

Is there a walk around of this? Thx!

ggwpez commented 1 month ago

The work-around is to either use the new versions from crates-io, or use the polkadot-sdk-frame crate to simplify the process.
Either way, some more up-to-date docs are here https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html. It also mentions some templates that you can use to get started.

If you still want to use this older tutorial, try:

frame-support = { version = "36.0.0", default-features = false }
frame-system = { version = "36.0.0", default-features = false }
zzz6519003 commented 1 month ago

The guide is awesome, but it’s not like a step-by-step tut.

thx for saving my day!

zzz6519003 commented 1 month ago

after I change it to

frame-support = { version = "36.0.0", default-features = false }
frame-system = { version = "36.0.0", default-features = false }

the code in tut is like

[features]
default = ["std"]
std = [
  "frame-support/std",
  "frame-system/std",
  "codec/std",
  "scale-info/std",
]
#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;

#[frame_support::pallet(dev_mode)]
pub mod pallet {
    use frame_support::pallet_prelude::*;
    use frame_system::pallet_prelude::*;

    #[pallet::pallet]
    #[pallet::generate_store(pub(super) trait Store)]
    pub struct Pallet<T>(_);

    #[pallet::config]
    pub trait Config: frame_system::Config {
    }
}

it get

  1. unresolved import palletrustcClick for full compiler diagnostic

  2. it can't find pallet::generate_store & pallet::pallet

ggwpez commented 1 month ago

We have a minimal example pallet here: https://github.com/paritytech/polkadot-sdk/blob/02e50adf7ba6cc65a9ef5c332b3e2974c8d23f48/templates/minimal/pallets/template/src/lib.rs#L14

It does use the frame crate though, but maybe it helps. The line with the generate_store should be removed.

zzz6519003 commented 1 month ago

sweet as Jesus, btw what is shell pallet

ggwpez commented 1 month ago

A "shell" like nothing inside. Just a blank pallet.

Happy that it worked 😄