Skip to content

Commit

Permalink
update polkadot metadata/9300 westend/9320
Browse files Browse the repository at this point in the history
  • Loading branch information
paulormart committed Nov 11, 2022
1 parent 37d223e commit 117ecab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- WIP update to subxt v0.24.0

## [0.3.9] - 2022-11-11

### Changed

- Update metadata Polkadot runtime/9300
- Update metadata Westend runtime/9320

## [0.3.8] - 2022-11-08

### Changed
Expand Down
Binary file modified metadata/polkadot_metadata.scale
Binary file not shown.
Binary file modified metadata/westend_metadata.scale
Binary file not shown.
13 changes: 8 additions & 5 deletions src/runtimes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
- Polkadot
- Kusama
- Westend

TODO: Improve the runtimes implementation without the need of replicating the same functions for each runtime. Note that *RuntimeApi* is runtime specific. It gives access to api functions specific for each runtime.

TODO: Improve the runtimes implementation without the need of replicating the same functions for each runtime. Note that *RuntimeApi* is runtime specific. It gives access to api functions specific for each runtime.

## Generated files from subxt-cli
## Generated files from subxt-cli

Download metadata from a substrate node, for use with `subxt` codegen.

```bash
cargo run --release -p subxt-cli -- metadata --url https://kusama-rpc.polkadot.io -f bytes > kusama_metadata.scale
subxt metadata --url wss://westend-rpc.polkadot.io:443 -f bytes > westend_metadata.scale
subxt metadata --url wss://kusama-rpc.polkadot.io:443 -f bytes > kusama_metadata.scale
subxt metadata --url wss://rpc.polkadot.io:443 -f bytes > polkadot_metadata.scale
```

Generate runtime API client code from metadata.

```bash
cargo run --release -p subxt-cli -- codegen -f polkadot_metadata.scale | rustfmt --edition=2018 --emit=stdout > polkadot_runtime.rs
subxt codegen -f kusama_metadata.scale | rustfmt --edition=2018 --emit=stdout > kusama_runtime.rs
subxt codegen -f polkadot_metadata.scale | rustfmt --edition=2018 --emit=stdout > polkadot_runtime.rs
```
13 changes: 6 additions & 7 deletions src/runtimes/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ use node_runtime::{
democracy::events::Started,
im_online::events::SomeOffline,
runtime_types::{
sp_consensus_babe::digests::PreDigest,
sp_runtime::bounded::bounded_vec::BoundedVec,
sp_consensus_babe::digests::PreDigest, sp_core::bounded::bounded_vec::BoundedVec,
},
session::events::NewSession,
staking::events::Chilled,
Expand Down Expand Up @@ -347,7 +346,7 @@ async fn try_run_staking_chilled_hook(
// Try to run hooks for each stash
for v in validators.iter_mut() {
// Identify if the stash has been chilled
if event.0 == v.stash {
if event.stash == v.stash {
v.is_chilled = true;

// Try HOOK_VALIDATOR_CHILLED
Expand Down Expand Up @@ -491,7 +490,7 @@ async fn try_run_staking_slashed_hook(

// Try to run hooks for each stash
for v in validators.iter_mut() {
if event.0 == v.stash {
if event.staker == v.stash {
v.is_slashed = true;
}
}
Expand All @@ -501,7 +500,7 @@ async fn try_run_staking_slashed_hook(
let network = Network::load(&client).await?;
debug!("network {:?}", network);

let mut args = vec![event.0.to_string(), event.1.to_string()];
let mut args = vec![event.staker.to_string(), event.amount.to_string()];

if config.expose_network || config.expose_all {
args.push(network.name.to_string());
Expand All @@ -522,8 +521,8 @@ async fn try_run_staking_slashed_hook(

// Set slash info
let slash = Slash {
who: Some(event.0),
amount_value: event.1,
who: Some(event.staker),
amount_value: event.amount,
hook,
};

Expand Down

0 comments on commit 117ecab

Please sign in to comment.