-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
rand-extension
example (#793)
* Update `rand-extension` example * Fix nightly clippy error
- Loading branch information
Michael Müller
authored
May 17, 2021
1 parent
aeca169
commit 4f229fc
Showing
3 changed files
with
44 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
# Chain-side Extension | ||
|
||
Use this as an implementation of the trait `ChainExtension` in Substrate | ||
and use it as the associated type `ChainExtension` of the trait `pallet_contracts::Config`. | ||
To integrate this example into Substrate you need to do two things: | ||
|
||
* Use the code in [`chain-extension-example.rs`](./chain-extension-example.rs) as an implementation for | ||
the trait `ChainExtension` in Substrate. | ||
You can just copy/paste the content of that file into e.g. your `runtime/src/lib.rs`. | ||
|
||
* Use the implementation as the associated type `ChainExtension` of the trait | ||
`pallet_contracts::Config`: | ||
```rust | ||
impl pallet_contracts::Config for Runtime { | ||
… | ||
type ChainExtension = FetchRandomExtension; | ||
… | ||
} | ||
``` |
46 changes: 28 additions & 18 deletions
46
examples/rand-extension/runtime/chain-extension-example.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters