From 4e1145c66fab9c7369a914769c9b25c98e10d931 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 16 Apr 2020 21:29:22 +0200 Subject: [PATCH] FAQ entry for Weight adjustment (#2188) * FAQ entry for Weight adjustment * CHANGELOG entry for rxjs Observable exposure * Event decoding --- CHANGELOG.md | 3 ++- docs/cookbook/storage.md | 2 +- docs/start/FAQ.md | 6 ++++++ docs/start/api.query.other.md | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d7e75cc0..c61b8dc46e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 1.11.0-beta.x -- **Important** Substrate master has an updated `Weight` (to `u64`), on older chains apply `Weight: 'u32'` (This does affect `DispatchInfo` decoding if wrongly set) +- **Important** Substrate master has an updated `Weight` (to `u64`), on older chains apply `Weight: 'u32'` (This does affect event decoding if wrongly set) +- Allow user type augmentation to work with different versions of rxjs (Thanks to https://github.com/monitz87) - Align augmented generation with camelCase (Thanks to https://github.com/monitz87) - Fix bitfield endian encoding (Thanks to investigation by https://github.com/xlc) - Fix entries decoding for `Option` (& simplify, decoding correctly on rpc layer) diff --git a/docs/cookbook/storage.md b/docs/cookbook/storage.md index 34c56b255b..c5eb97b7ec 100644 --- a/docs/cookbook/storage.md +++ b/docs/cookbook/storage.md @@ -51,5 +51,5 @@ While we can retrieve only the keys for a specific era, using a argument for the const slashedKeys = await api.query.staking.nominatorSlashInEra.keys(652); // key args still contains [EraIndex, AccountId] decoded -console.log(`slashed: ${slashedKeys.map(({ args: [era, nominatorId]}) => nominatorId.toString())`); +console.log(`slashed: ${slashedKeys.map(({ args: [era, nominatorId] }) => nominatorId)`); ``` diff --git a/docs/start/FAQ.md b/docs/start/FAQ.md index bd34837abe..85c38d0718 100644 --- a/docs/start/FAQ.md +++ b/docs/start/FAQ.md @@ -57,3 +57,9 @@ The API always injects the default type definitions as specified by the Substrat The Substrate node-template has added customizations for some types in the default template, specifically around the `Address` and `Lookup` types, removing any lookups based on indices. This means that the transaction payload saves 2 bytes for a transfer and is an approach followed by other chains as well, notably Polkadot & Kusama. Due to these customizations and differences that bleed through to the transaction formats, out-of-the-box chains based on the node-template will have issues when sending transactions. To fix this, you would need to add [the customized Address types into your API](types.extend.md#impact-on-extrinsics) instances (or UIs), allowing the API to have the information required to adjust the encoding. + +## Using a non-current-master node, I have issues parsing events + +Recently Substrate master updated the `Weight` type from `u32` -> `u64`. This type is used in the `DispatchInfo` struct in the `system.ExtrinsicSuccess` events, to return the applied call weights as well as the resulting fees. Since the API master branch tracks Substrate master, this means the change has been applied by default, with the defaul set to `u64`. + +If you are on a chain that has been upgraded yet, you need to add `Weight: 'u32'` to your types to allow for successful parsing of all events. Without this override, parsing will fail. As soon as one event in the `Vec` structure fails to parse, all subsequent events are affected and the decoding will return an error. diff --git a/docs/start/api.query.other.md b/docs/start/api.query.other.md index a49cbca20b..743608e69f 100644 --- a/docs/start/api.query.other.md +++ b/docs/start/api.query.other.md @@ -85,7 +85,7 @@ In the first example we are querying a double-map, so we supply 1 argument. No a const keys = await api.query.staking.nominators.keys(); // extract the first key argument [AccountId] as string -const nominatorIds = keys.map(({ args: [nominatorId]) => nominatorId); +const nominatorIds = keys.map(({ args: [nominatorId] }) => nominatorId); console.log('all nominators:', nominatorIds.join(', ')); ```