Remove poorly panickable unwraps

This commit is contained in:
emostov
2020-12-14 11:34:26 -08:00
parent a9899324ec
commit 633bd0fb6f
2 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ where
},
None => (Era::Immortal, genesis_hash)
};
let extra: T::Extra = T::Extra::new(spec_version, tx_version, nonce, genesis_hash, era_info);
let extra = T::Extra::new(spec_version, tx_version, nonce, genesis_hash, era_info);
let payload = SignedPayload::<T>::new(call, extra.extra())?;
let signed = signer.sign(payload).await?;
Ok(signed)
+6 -4
View File
@@ -199,7 +199,7 @@ pub struct Client<T: Runtime> {
}
/// Construction options for a signed extrinsic
#[derive(Clone)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct SignedOptions {
/// The period, measured in blocks, that transaction will live for, starting from a checkpoint
/// block. A good default is 64 (64 * 6secs = 6min 40sec).
@@ -473,9 +473,11 @@ impl<T: Runtime> Client<T> {
self.account(signer.account_id(), None).await?.nonce
};
let call = self.encode(call)?;
let era_opts = if opts.era_period.is_some() {
let era_period = opts.era_period.unwrap();
let current_block = self.block(None::<T::Hash>).await?.unwrap().block;
let era_opts = if let Some(era_period) = opts.era_period {
let current_block = match self.block(None::<T::Hash>).await? {
Some(signed_block) => signed_block.block,
None => return Err("RPC chain_getBlock returned None when Some(signed_block) was expected".into()),
};
let current_number = (*current_block.header().number()).saturated_into::<u64>();
let current_hash = current_block.hash();