Add hooks to register event types for decoding (#227)

* Global registration of type segmenters for event decoding

* Perform type sizes check when building client

* Introduce EventTypeRegistry for global runtime type sizes

* Fmt

* Register runtime type sizes on creation of EventTypeRegistry

* Register more default dispatch types

* Add missing type sizes

* fmt

* Fix up register_type_size builder method

* Update doc comments

* Make register_default_type_sizes public

* Don't allow duplicate registered types

* Remove call to supertraits type registration, done manually in Runtime

* Fix tests and warnings

* Fix duplicate type registration

* Fmt

* review: use is_empty()

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* Add panic docs

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
Andrew Jones
2021-02-18 10:28:40 +00:00
committed by GitHub
parent 2c8e5211aa
commit de859e7396
19 changed files with 436 additions and 280 deletions
+3 -3
View File
@@ -423,10 +423,10 @@ impl<T: Runtime> Rpc<T> {
}
/// Create and submit an extrinsic and return corresponding Event if successful
pub async fn submit_and_watch_extrinsic<E: Encode + 'static>(
pub async fn submit_and_watch_extrinsic<'a, E: Encode + 'static>(
&self,
extrinsic: E,
decoder: EventsDecoder<T>,
decoder: &'a EventsDecoder<T>,
) -> Result<ExtrinsicSuccess<T>, Error> {
let ext_hash = T::Hashing::hash_of(&extrinsic);
log::info!("Submitting Extrinsic `{:?}`", ext_hash);
@@ -465,7 +465,7 @@ impl<T: Runtime> Rpc<T> {
ext_hash,
))
})?;
let mut sub = EventSubscription::new(events_sub, decoder);
let mut sub = EventSubscription::new(events_sub, &decoder);
sub.filter_extrinsic(block_hash, ext_index);
let mut events = vec![];
while let Some(event) = sub.next().await {