style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -147,8 +147,9 @@ impl<AccountId, Call: Dispatchable, Extension: TransactionExtension<Call>>
|
||||
pub fn extension_weight(&self) -> Weight {
|
||||
match &self.format {
|
||||
ExtrinsicFormat::Bare => Weight::zero(),
|
||||
ExtrinsicFormat::Signed(_, ext) | ExtrinsicFormat::General(_, ext) =>
|
||||
ext.weight(&self.function),
|
||||
ExtrinsicFormat::Signed(_, ext) | ExtrinsicFormat::General(_, ext) => {
|
||||
ext.weight(&self.function)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,11 +356,13 @@ impl<'a> DigestItemRef<'a> {
|
||||
/// return the opaque data it contains.
|
||||
pub fn try_as_raw(&self, id: OpaqueDigestItemId) -> Option<&'a [u8]> {
|
||||
match (id, self) {
|
||||
(OpaqueDigestItemId::Consensus(w), &Self::Consensus(v, s)) |
|
||||
(OpaqueDigestItemId::Seal(w), &Self::Seal(v, s)) |
|
||||
(OpaqueDigestItemId::PreRuntime(w), &Self::PreRuntime(v, s))
|
||||
(OpaqueDigestItemId::Consensus(w), &Self::Consensus(v, s))
|
||||
| (OpaqueDigestItemId::Seal(w), &Self::Seal(v, s))
|
||||
| (OpaqueDigestItemId::PreRuntime(w), &Self::PreRuntime(v, s))
|
||||
if v == w =>
|
||||
Some(s),
|
||||
{
|
||||
Some(s)
|
||||
},
|
||||
(OpaqueDigestItemId::Other, &Self::Other(s)) => Some(s),
|
||||
_ => None,
|
||||
}
|
||||
@@ -445,14 +447,18 @@ mod tests {
|
||||
let check = |digest_item_type: DigestItemType| {
|
||||
let (variant_name, digest_item) = match digest_item_type {
|
||||
DigestItemType::Other => ("Other", DigestItem::Other(Default::default())),
|
||||
DigestItemType::Consensus =>
|
||||
("Consensus", DigestItem::Consensus(Default::default(), Default::default())),
|
||||
DigestItemType::Seal =>
|
||||
("Seal", DigestItem::Seal(Default::default(), Default::default())),
|
||||
DigestItemType::PreRuntime =>
|
||||
("PreRuntime", DigestItem::PreRuntime(Default::default(), Default::default())),
|
||||
DigestItemType::RuntimeEnvironmentUpdated =>
|
||||
("RuntimeEnvironmentUpdated", DigestItem::RuntimeEnvironmentUpdated),
|
||||
DigestItemType::Consensus => {
|
||||
("Consensus", DigestItem::Consensus(Default::default(), Default::default()))
|
||||
},
|
||||
DigestItemType::Seal => {
|
||||
("Seal", DigestItem::Seal(Default::default(), Default::default()))
|
||||
},
|
||||
DigestItemType::PreRuntime => {
|
||||
("PreRuntime", DigestItem::PreRuntime(Default::default(), Default::default()))
|
||||
},
|
||||
DigestItemType::RuntimeEnvironmentUpdated => {
|
||||
("RuntimeEnvironmentUpdated", DigestItem::RuntimeEnvironmentUpdated)
|
||||
},
|
||||
};
|
||||
let encoded = digest_item.encode();
|
||||
let variant = variants
|
||||
|
||||
@@ -105,8 +105,8 @@ impl Encode for Era {
|
||||
Self::Immortal => output.push_byte(0),
|
||||
Self::Mortal(period, phase) => {
|
||||
let quantize_factor = (*period as u64 >> 12).max(1);
|
||||
let encoded = (period.trailing_zeros() - 1).clamp(1, 15) as u16 |
|
||||
((phase / quantize_factor) << 4) as u16;
|
||||
let encoded = (period.trailing_zeros() - 1).clamp(1, 15) as u16
|
||||
| ((phase / quantize_factor) << 4) as u16;
|
||||
encoded.encode_to(output);
|
||||
},
|
||||
}
|
||||
|
||||
@@ -421,8 +421,9 @@ where
|
||||
format: ExtrinsicFormat::General(extension_version, tx_ext),
|
||||
function: self.function,
|
||||
},
|
||||
Preamble::Bare(_) =>
|
||||
CheckedExtrinsic { format: ExtrinsicFormat::Bare, function: self.function },
|
||||
Preamble::Bare(_) => {
|
||||
CheckedExtrinsic { format: ExtrinsicFormat::Bare, function: self.function }
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -443,8 +444,9 @@ where
|
||||
format: ExtrinsicFormat::General(extension_version, tx_ext),
|
||||
function: self.function,
|
||||
},
|
||||
Preamble::Bare(_) =>
|
||||
CheckedExtrinsic { format: ExtrinsicFormat::Bare, function: self.function },
|
||||
Preamble::Bare(_) => {
|
||||
CheckedExtrinsic { format: ExtrinsicFormat::Bare, function: self.function }
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,8 +529,8 @@ impl Verify for AnySignature {
|
||||
let msg = msg.get();
|
||||
sr25519::Signature::try_from(self.0.as_fixed_bytes().as_ref())
|
||||
.map(|s| s.verify(msg, signer))
|
||||
.unwrap_or(false) ||
|
||||
ed25519::Signature::try_from(self.0.as_fixed_bytes().as_ref())
|
||||
.unwrap_or(false)
|
||||
|| ed25519::Signature::try_from(self.0.as_fixed_bytes().as_ref())
|
||||
.map(|s| match ed25519::Public::from_slice(signer.as_ref()) {
|
||||
Err(()) => false,
|
||||
Ok(signer) => s.verify(msg, &signer),
|
||||
@@ -693,8 +693,9 @@ impl DispatchError {
|
||||
/// Return the same error but without the attached message.
|
||||
pub fn stripped(self) -> Self {
|
||||
match self {
|
||||
DispatchError::Module(ModuleError { index, error, message: Some(_) }) =>
|
||||
DispatchError::Module(ModuleError { index, error, message: None }),
|
||||
DispatchError::Module(ModuleError { index, error, message: Some(_) }) => {
|
||||
DispatchError::Module(ModuleError { index, error, message: None })
|
||||
},
|
||||
m => m,
|
||||
}
|
||||
}
|
||||
@@ -770,8 +771,9 @@ impl From<TokenError> for &'static str {
|
||||
TokenError::UnknownAsset => "The asset in question is unknown",
|
||||
TokenError::Frozen => "Funds exist but are frozen",
|
||||
TokenError::Unsupported => "Operation is not supported by the asset",
|
||||
TokenError::CannotCreateHold =>
|
||||
"Account cannot be created for recording amount on hold",
|
||||
TokenError::CannotCreateHold => {
|
||||
"Account cannot be created for recording amount on hold"
|
||||
},
|
||||
TokenError::NotExpendable => "Account that is desired to remain would die",
|
||||
TokenError::Blocked => "Account cannot receive the assets",
|
||||
}
|
||||
@@ -973,8 +975,8 @@ pub fn verify_encoded_lazy<V: Verify, T: codec::Encode>(
|
||||
macro_rules! assert_eq_error_rate {
|
||||
($x:expr, $y:expr, $error:expr $(,)?) => {
|
||||
assert!(
|
||||
($x >= $crate::Saturating::saturating_sub($y, $error)) &&
|
||||
($x <= $crate::Saturating::saturating_add($y, $error)),
|
||||
($x >= $crate::Saturating::saturating_sub($y, $error))
|
||||
&& ($x <= $crate::Saturating::saturating_add($y, $error)),
|
||||
"{:?} != {:?} (with error rate {:?})",
|
||||
$x,
|
||||
$y,
|
||||
|
||||
@@ -222,8 +222,8 @@ impl<B: BlockNumberProvider> Lockable for BlockAndTime<B> {
|
||||
type Deadline = BlockAndTimeDeadline<B>;
|
||||
|
||||
fn deadline(&self) -> Self::Deadline {
|
||||
let block_number = <B as BlockNumberProvider>::current_block_number() +
|
||||
self.expiration_block_number_offset.into();
|
||||
let block_number = <B as BlockNumberProvider>::current_block_number()
|
||||
+ self.expiration_block_number_offset.into();
|
||||
BlockAndTimeDeadline {
|
||||
timestamp: offchain::timestamp().add(self.expiration_duration),
|
||||
block_number,
|
||||
@@ -231,8 +231,8 @@ impl<B: BlockNumberProvider> Lockable for BlockAndTime<B> {
|
||||
}
|
||||
|
||||
fn has_expired(deadline: &Self::Deadline) -> bool {
|
||||
offchain::timestamp() > deadline.timestamp &&
|
||||
<B as BlockNumberProvider>::current_block_number() > deadline.block_number
|
||||
offchain::timestamp() > deadline.timestamp
|
||||
&& <B as BlockNumberProvider>::current_block_number() > deadline.block_number
|
||||
}
|
||||
|
||||
fn snooze(deadline: &Self::Deadline) {
|
||||
|
||||
@@ -107,8 +107,9 @@ impl From<TrieError> for &'static str {
|
||||
match e {
|
||||
TrieError::InvalidStateRoot => "The state root is not in the database.",
|
||||
TrieError::IncompleteDatabase => "A trie item was not found in the database.",
|
||||
TrieError::ValueAtIncompleteKey =>
|
||||
"A value was found with a key that is not byte-aligned.",
|
||||
TrieError::ValueAtIncompleteKey => {
|
||||
"A value was found with a key that is not byte-aligned."
|
||||
},
|
||||
TrieError::DecoderError => "A corrupt trie item was encountered.",
|
||||
TrieError::InvalidHash => "The hash does not match the expected value.",
|
||||
TrieError::DuplicateKey => "The proof contains duplicate keys.",
|
||||
|
||||
+3
-2
@@ -115,8 +115,9 @@ where
|
||||
source,
|
||||
) {
|
||||
// After validation, some origin must have been authorized.
|
||||
Ok((_, _, origin)) if !origin.is_transaction_authorized() =>
|
||||
Err(InvalidTransaction::UnknownOrigin.into()),
|
||||
Ok((_, _, origin)) if !origin.is_transaction_authorized() => {
|
||||
Err(InvalidTransaction::UnknownOrigin.into())
|
||||
},
|
||||
res => res,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,18 +109,23 @@ impl From<InvalidTransaction> for &'static str {
|
||||
InvalidTransaction::BadProof => "Transaction has a bad signature",
|
||||
InvalidTransaction::AncientBirthBlock => "Transaction has an ancient birth block",
|
||||
InvalidTransaction::ExhaustsResources => "Transaction would exhaust the block limits",
|
||||
InvalidTransaction::Payment =>
|
||||
"Inability to pay some fees (e.g. account balance too low)",
|
||||
InvalidTransaction::BadMandatory =>
|
||||
"A call was labelled as mandatory, but resulted in an Error.",
|
||||
InvalidTransaction::MandatoryValidation =>
|
||||
"Transaction dispatch is mandatory; transactions must not be validated.",
|
||||
InvalidTransaction::Payment => {
|
||||
"Inability to pay some fees (e.g. account balance too low)"
|
||||
},
|
||||
InvalidTransaction::BadMandatory => {
|
||||
"A call was labelled as mandatory, but resulted in an Error."
|
||||
},
|
||||
InvalidTransaction::MandatoryValidation => {
|
||||
"Transaction dispatch is mandatory; transactions must not be validated."
|
||||
},
|
||||
InvalidTransaction::Custom(_) => "InvalidTransaction custom error",
|
||||
InvalidTransaction::BadSigner => "Invalid signing address",
|
||||
InvalidTransaction::IndeterminateImplicit =>
|
||||
"The implicit data was unable to be calculated",
|
||||
InvalidTransaction::UnknownOrigin =>
|
||||
"The transaction extension did not authorize any origin",
|
||||
InvalidTransaction::IndeterminateImplicit => {
|
||||
"The implicit data was unable to be calculated"
|
||||
},
|
||||
InvalidTransaction::UnknownOrigin => {
|
||||
"The transaction extension did not authorize any origin"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,10 +145,12 @@ pub enum UnknownTransaction {
|
||||
impl From<UnknownTransaction> for &'static str {
|
||||
fn from(unknown: UnknownTransaction) -> &'static str {
|
||||
match unknown {
|
||||
UnknownTransaction::CannotLookup =>
|
||||
"Could not lookup information required to validate the transaction",
|
||||
UnknownTransaction::NoUnsignedValidator =>
|
||||
"Could not find an unsigned validator for the unsigned transaction",
|
||||
UnknownTransaction::CannotLookup => {
|
||||
"Could not lookup information required to validate the transaction"
|
||||
},
|
||||
UnknownTransaction::NoUnsignedValidator => {
|
||||
"Could not find an unsigned validator for the unsigned transaction"
|
||||
},
|
||||
UnknownTransaction::Custom(_) => "UnknownTransaction custom error",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user