mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
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:
+7
-3
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user