@@ -131,7 +131,7 @@ To add the `node-authorization` pallet to the Substrate runtime:
131
131
132
132
``` toml
133
133
[dependencies ]
134
- pallet-node-authorization = { default-features = false , version = " 4.0.0-dev " , git = " https://github.com/paritytech/substrate .git" , branch = " polkadot-v1.0 .0" }
134
+ pallet-node-authorization = { git = " https://github.com/paritytech/polkadot-sdk .git" , tag = " polkadot-v1.9 .0" , default-features = false }
135
135
```
136
136
137
137
This line imports the ` pallet-node-authorization ` crate as a dependency and specifies the following configuration details for the crate:
@@ -222,19 +222,34 @@ To implement the `node-authorization` pallet in your runtime:
222
222
}
223
223
```
224
224
225
- 1 . Add the pallet to the ` construct_runtime ` macro with the following line of code :
225
+ 1 . Locate the ` construct_runtime ` macro:
226
226
227
227
``` rust
228
- construct_runtime! (
229
- pub enum Runtime where
230
- Block = Block ,
231
- NodeBlock = opaque :: Block ,
232
- UncheckedExtrinsic = UncheckedExtrinsic
233
- {
234
- /*** Add This Line ***/
235
- NodeAuthorization : pallet_node_authorization :: {Pallet , Call , Storage , Event <T >, Config <T >},
236
- }
237
- );
228
+ #[frame_support:: runtime]
229
+ mod runtime {
230
+ #[runtime:: runtime]
231
+ #[runtime:: derive(
232
+ RuntimeCall ,
233
+ RuntimeEvent ,
234
+ RuntimeError ,
235
+ RuntimeOrigin ,
236
+ RuntimeFreezeReason ,
237
+ RuntimeHoldReason ,
238
+ RuntimeSlashReason ,
239
+ RuntimeLockId ,
240
+ RuntimeTask
241
+ )]
242
+ pub struct Runtime ;
243
+
244
+ #[runtime:: pallet_index(0)]
245
+ pub type System = frame_system ;
246
+ ```
247
+
248
+ 1 . Add the Node Authorization pallet inside the ` construct_runtime! ` macro with the following code:
249
+
250
+ ``` rust
251
+ #[runtime:: pallet_index(x)] // *** Change pallet index ***//
252
+ pub type NodeAuthorization = pallet_node_authorization ;
238
253
```
239
254
240
255
1 . Save your changes and close the file.
@@ -270,40 +285,37 @@ To configure genesis storage for authorized nodes:
270
285
271
286
``` rust
272
287
use sp_core :: OpaquePeerId ; // A struct wraps Vec<u8> to represent the node `PeerId`.
273
- use node_template_runtime :: NodeAuthorizationConfig ; // The genesis config that serves the pallet.
274
288
```
275
289
276
290
1 . Locate the ` testnet_genesis ` function that configures initial storage state for FRAME modules.
277
291
278
292
For example:
279
293
280
294
``` rust
281
- /// Configure initial storage state for FRAME modules.
282
- fn testnet_genesis (
283
- wasm_binary : & [u8 ],
284
- initial_authorities : Vec <(AuraId , GrandpaId )>,
285
- root_key : AccountId ,
286
- endowed_accounts : Vec <AccountId >,
287
- _enable_println : bool ,
288
- ) -> GenesisConfig {
289
-
295
+ /// Configure initial storage state for FRAME modules.
296
+ fn testnet_genesis (
297
+ initial_authorities : Vec <(AuraId , GrandpaId )>,
298
+ root_key : AccountId ,
299
+ endowed_accounts : Vec <AccountId >,
300
+ _enable_println : bool ,
301
+ ) -> serde_json :: Value {
290
302
```
291
303
292
- 1 . Within the ` GenesisConfig ` declaration, add the following code block:
304
+ 1 . Within the ` serde_json::Value ` declaration, add the following code block:
293
305
294
306
``` rust
295
- node_authorization : NodeAuthorizationConfig {
296
- nodes : vec! [
297
- (
298
- OpaquePeerId (bs58 :: decode (" 12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2" ). into_vec (). unwrap ()),
299
- endowed_accounts [0 ]. clone ()
300
- ),
301
- (
302
- OpaquePeerId (bs58 :: decode (" 12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust" ). into_vec (). unwrap ()),
303
- endowed_accounts [1 ]. clone ()
304
- ),
305
- ],
306
- },
307
+ " nodeAuthorization " : {
308
+ " nodes" : vec! [
309
+ (
310
+ OpaquePeerId (bs58 :: decode (" 12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2" ). into_vec (). unwrap ()),
311
+ endowed_accounts [0 ]. clone ()
312
+ ),
313
+ (
314
+ OpaquePeerId (bs58 :: decode (" 12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust" ). into_vec (). unwrap ()),
315
+ endowed_accounts [1 ]. clone ()
316
+ ),
317
+ ],
318
+ },
307
319
```
308
320
309
321
In this code, ` NodeAuthorizationConfig ` contains a ` nodes ` property, which is a vector with a tuple of two elements.
0 commit comments