Split subxt (#102)

* Proc macro improvements.

* Use proc-macros.

* Update examples.

* Fix build.

* Run rustfmt.

* Fix total issuance test.

* Remove gas limit from put code call.

* Handle runtime errors.

* Fix tests.

* Make test more reliable.

* Revert "Handle runtime errors."

This reverts commit 26f30a9f4cfcfddfb3e49308cded46cfe6468697.

* Use expect instead of unwrap.

* Parse marker type.

* Fetch doesn't fail.
This commit is contained in:
David Craven
2020-05-12 13:25:22 +02:00
committed by GitHub
parent 825f3ab64c
commit f861f3fac4
21 changed files with 697 additions and 564 deletions
+7 -3
View File
@@ -24,6 +24,7 @@ use std::{
use codec::{
Decode,
Encode,
Error as CodecError,
};
use frame_metadata::{
@@ -63,6 +64,9 @@ pub enum MetadataError {
/// Storage type does not match requested type.
#[error("Storage type error")]
StorageTypeError,
/// Default error.
#[error("Failed to decode default: {0}")]
DefaultError(CodecError),
}
/// Runtime metadata.
@@ -218,9 +222,9 @@ impl StorageMetadata {
bytes
}
pub fn default<V: Decode>(&self) -> Option<V> {
// substrate handles the default different for A => B vs A => Option<B>
Decode::decode(&mut &self.default[..]).ok()
pub fn default<V: Decode>(&self) -> Result<V, MetadataError> {
Decode::decode(&mut &self.default[..])
.map_err(|err| MetadataError::DefaultError(err))
}
pub fn hash(hasher: &StorageHasher, bytes: &[u8]) -> Vec<u8> {