Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit e2d6e5a

Browse files
authored
Merge pull request #28 from substrate-developer-hub/ricardo-improve-tutorial
Improve add a pallet
2 parents 8ec2271 + ac65851 commit e2d6e5a

File tree

1 file changed

+14
-15
lines changed
  • tuts/add-a-pallet/v2.0.0-alpha.6

1 file changed

+14
-15
lines changed

tuts/add-a-pallet/v2.0.0-alpha.6/index.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ error[E0425]: cannot find function `memory_new` in module `sandbox`
157157
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-sandbox-0.8.0-alpha.6/src/../without_std.rs:72:18
158158
|
159159
72 | match sandbox::memory_new(initial, maximum) {
160-
|
160+
|
161161

162162
...
163163
```
@@ -170,14 +170,14 @@ cargo check
170170

171171
## Adding the Contracts Pallet
172172

173-
Now that we have successfully imported the Contracts pallet crate, we need to add it to our Runtime. Different pallets will require you to `use` different thing. For the contracts pallet we will use the `Gas` type. Add this line along with the other `pub use` statements at the beginning of your runtime.
173+
Now that we have successfully imported the Contracts pallet crate, we need to add it to our Runtime. Different pallets will require you to `use` different thing. For the contracts pallet we will use the `Schedule` type. Add this line along with the other `pub use` statements at the beginning of your runtime.
174174

175175
**`runtime/src/lib.rs`**
176176

177177
```rust
178178
/*** Add This Line ***/
179-
/// Importing the contracts Gas type
180-
pub use contracts::Gas;
179+
/// Importing the contracts Schedule type.
180+
pub use contracts::Schedule as ContractsSchedule;
181181
```
182182

183183
### Implementing the Contract Trait
@@ -444,7 +444,7 @@ Genesis configurations are controlled in `node/src/chain_spec.rs`. We need to mo
444444
**`node/src/chain_spec.rs`**
445445

446446
```rust
447-
use node_template_runtime::{ContractsConfig, MILLICENTS};
447+
use node_template_runtime::{ContractsConfig, ContractsSchedule, MILLICENTS};
448448
```
449449

450450
Then inside the `testnet_genesis` function we need to add the contract configuration to the returned `GenesisConfig` object as followed:
@@ -457,20 +457,19 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
457457
root_key: AccountId,
458458
endowed_accounts: Vec<AccountId>,
459459
_enable_println: bool) -> GenesisConfig {
460-
/*** Add This Block ***/
461-
let mut contracts_config = ContractsConfig {
462-
current_schedule: Default::default(),
463-
gas_price: 1 * MILLICENTS,
464-
};
465-
// IMPORTANT: println should only be enabled on development chains!
466-
contracts_config.current_schedule.enable_println = _enable_println;
467-
/*** End Added Block ***/
468460

469461
GenesisConfig {
470462
/* --snip-- */
471463

472-
/*** Add This Line ***/
473-
contracts: Some(contracts_config),
464+
/*** Add This Block ***/
465+
contracts: Some(ContractsConfig {
466+
current_schedule: ContractsSchedule {
467+
enable_println,
468+
..Default::default()
469+
},
470+
gas_price: 1 * MILLICENTS,
471+
}),
472+
/*** End Added Block ***/
474473
}
475474
}
476475
```

0 commit comments

Comments
 (0)