Typed chain state queries over rpc. (#4079)

* Create typed client helpers for querying chain state storage items declared by
'decl_storage!'.

* Update substrate-rpc-custom functions to use async await syntax.

* The implementation of substrate-rpc-custom was a bit verbose and repetitive.
This commit makes the implementation simpler by intruducing a struct which
represents query for a typed value in storage. The new struct is called
StorageQuery. A StorageQuery wraps a raw StorageKey but is not directy
constructable. To construct a StorageQuery, the user must supply an
implementation of a srml_support::storage::generator trait such as
StorageValue or StorageMap.

A type implementing one of the generator traits can be aquired by:
A) marking a storage item as pub within a call to decl_storage (recommended)
or B) implementing one of the generator types manually.

While option B may sometimes me necessary, it's not recommended because
separate manual implementaions may lose sync with the original definition.

* drop unused dependency

* fmt

* Remove unnecessary pub from Authorities field in test-runtime storage
declaration.

This field was added to support a test in an earlier commit. The
test no longer relies on test-runtime so the change can be reverted.

* Move it to srml as support extension.

* Fix long lines.

* Fix.
This commit is contained in:
Tomasz Drwięga
2019-11-11 02:01:15 +01:00
committed by Bastian Köcher
parent bb0736cdba
commit 57ab3aeb82
5 changed files with 216 additions and 6 deletions
+1 -1
View File
@@ -57,6 +57,7 @@ members = [
"core/utils/wasm-builder-runner",
"core/wasm-interface",
"srml/support",
"srml/support/rpc",
"srml/support/procedural",
"srml/support/procedural/tools",
"srml/support/procedural/tools/derive",
@@ -112,4 +113,3 @@ members = [
[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"