팔레트 가져오기
이 가이드는 런타임에 로컬 및 외부 팔레트를 빠르게 통합하는 방법을 보여줍니다. 더 자세한 단계별 지침은 런타임에 팔레트 추가하기를 참조하세요.
이 가이드에서는 다음을 설명합니다:
런타임에 이벤트와 호출을 구현하는 사용자 정의 로컬 팔레트를 포함하는 방법.
Crates.io에서 외부 팔레트를 포함하는 방법.
로컬 팔레트 생성
pallet_something이라는 로컬 팔레트를 생성하세요./runtime/src/lib.rs에 다음을 추가하여 이 팔레트를 가져옵니다:// 팔레트를 가져옵니다. pub use pallet_something;팔레트의 런타임 구현을 구성하세요. 로컬 팔레트가 런타임에 노출되는
Event와Call타입만 가지고 있다고 가정합니다./runtime/src/lib.rs에 다음을 추가하세요:// 팔레트를 구성합니다. impl pallet_something::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; }construct_runtime매크로에 팔레트를 선언하세요:construct_runtime!( pub enum Runtime where Block = Block, NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic { /* --snip-- */ Something: pallet_something, /* --snip-- */ } );/runtime/Cargo.toml을 업데이트하세요./runtime/Cargo.toml에서 팔레트를std의 로컬 종속성으로 포함하고runtime-benchmarks를 추가하세요. 예를 들어:# --snip-- pallet-something = { default-features = false, path = '../pallets/something' version = '3.0.0' # --snip-- [features] default = ['std'] runtime-benchmarks = [ # --snip-- 'pallet-something/runtime-benchmarks', ] std = [ 'pallet-something/std', # --snip-- ]
외부 팔레트 가져오기
외부 팔레트를 추가하려면 로컬 팔레트와 유사한 방법을 사용하지만, 팔레트가 노출하는 모든 타입을 포함해야 합니다. 또한 관련된 매개변수 타입과 상수를 포함해야 합니다. 매개변수와 상수를 선언하는 예는 pallet_timestamp를 참조하세요.
다음은 팔레트가 crates.parity.io에 호스팅되어 있는 경우 /runtime/Cargo.toml 종속성에 외부 팔레트를 추가하는 예입니다:
예시
관련 자료
Last updated