Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rustfmt #189

Merged
merged 3 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 14 additions & 15 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn load_spec(
#[cfg(not(feature = "with-bifrost-runtime"))]
return Err("Bifrost runtime is not available. Please compile the node with `--features with-bifrost-runtime` to enable it.".into());
}
}
},
})
}

Expand Down Expand Up @@ -273,7 +273,7 @@ pub fn run() -> Result<()> {
.await
.map_err(Into::into)
})
}
},
Some(Subcommand::Inspect(cmd)) => {
let runner = cli.create_runner(cmd)?;

Expand All @@ -289,8 +289,8 @@ pub fn run() -> Result<()> {
config,
);
});
}
Some(Subcommand::Benchmark(cmd)) => {
},
Some(Subcommand::Benchmark(cmd)) =>
if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?;

Expand All @@ -306,36 +306,35 @@ pub fn run() -> Result<()> {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
}
}
},
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
Some(Subcommand::Sign(cmd)) => cmd.run(),
Some(Subcommand::Verify(cmd)) => cmd.run(),
Some(Subcommand::Vanity(cmd)) => cmd.run(),
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
}
},
Some(Subcommand::CheckBlock(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue))
})
}
},
Some(Subcommand::ExportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, config.database))
})
}
},
Some(Subcommand::ExportState(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, config.chain_spec))
})
}
},
Some(Subcommand::ImportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue))
})
}
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;

Expand All @@ -356,12 +355,12 @@ pub fn run() -> Result<()> {

cmd.run(config, polkadot_config)
})
}
},
Some(Subcommand::Revert(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.backend))
})
}
},
Some(Subcommand::ExportGenesisState(params)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
Expand All @@ -385,7 +384,7 @@ pub fn run() -> Result<()> {
}

Ok(())
}
},
Some(Subcommand::ExportGenesisWasm(params)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
Expand All @@ -406,7 +405,7 @@ pub fn run() -> Result<()> {
}

Ok(())
}
},
}
}

Expand Down
4 changes: 2 additions & 2 deletions node/inspect/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ impl InspectCmd {
let res = inspect.block(input).map_err(|e| format!("{}", e))?;
println!("{}", res);
Ok(())
}
},
InspectSubCmd::Extrinsic { input } => {
let input = input.parse()?;
let res = inspect.extrinsic(input).map_err(|e| format!("{}", e))?;
println!("{}", res);
Ok(())
}
},
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions node/inspect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<TBlock: Block, TPrinter: PrettyPrinter<TBlock>> Inspector<TBlock, TPrinter>
let header =
self.chain.header(id)?.ok_or_else(|| Error::NotFound(not_found.clone()))?;
TBlock::new(header, body)
}
},
BlockAddress::Hash(hash) => {
let id = BlockId::hash(hash);
let not_found = format!("Could not find block {:?}", id);
Expand All @@ -167,7 +167,7 @@ impl<TBlock: Block, TPrinter: PrettyPrinter<TBlock>> Inspector<TBlock, TPrinter>
let header =
self.chain.header(id)?.ok_or_else(|| Error::NotFound(not_found.clone()))?;
TBlock::new(header, body)
}
},
})
}

Expand All @@ -192,7 +192,7 @@ impl<TBlock: Block, TPrinter: PrettyPrinter<TBlock>> Inspector<TBlock, TPrinter>
index, block
))
})?
}
},
ExtrinsicAddress::Bytes(bytes) => TBlock::Extrinsic::decode(&mut &*bytes)?,
};

Expand Down
6 changes: 3 additions & 3 deletions pallets/bancor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl<T: Config> Pallet<T> {
pool_info.token_ceiling =
pool_info.token_ceiling.saturating_add(increase_amount);
Ok(())
}
},
_ => Err(Error::<T>::BancorPoolNotExist),
}
})?;
Expand All @@ -392,7 +392,7 @@ impl<T: Config> Pallet<T> {
pool_info.token_pool = pool_info.token_pool.saturating_sub(token_amount);
pool_info.vstoken_pool = pool_info.vstoken_pool.saturating_sub(vstoken_amount);
Ok(())
}
},
_ => Err(Error::<T>::BancorPoolNotExist),
}
})?;
Expand All @@ -416,7 +416,7 @@ impl<T: Config> Pallet<T> {
pool_info.token_pool = pool_info.token_pool.saturating_add(token_amount);
pool_info.vstoken_pool = pool_info.vstoken_pool.saturating_add(vstoken_amount);
Ok(())
}
},
_ => Err(Error::<T>::BancorPoolNotExist),
}
})?;
Expand Down
5 changes: 2 additions & 3 deletions pallets/bid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,10 @@ impl<T: Config> Module<T> {
balance_order_vec.binary_search_by_key(&annual_roi, |(roi, _odr_id)| roi);

match index_wrapped {
Ok(index) | Err(index) => {
Ok(index) | Err(index) =>
if index < (T::TokenOrderROIListLength::get() as usize) {
balance_order_vec.insert(index, (*annual_roi, new_order_id));
}
}
},
}

if balance_order_vec.len() > (T::TokenOrderROIListLength::get() as usize) {
Expand Down
6 changes: 3 additions & 3 deletions pallets/salp/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ fn dissolve_should_work() {
let contribute_account_num = remove_times * RemoveKeysLimit::get();

assert_ok!(Salp::create(Some(ALICE).into(), 3_000, 10_000, 1, SlotLength::get()));
for i in 0 .. contribute_account_num {
for i in 0..contribute_account_num {
let ract = AccountId::new([(i as u8); 32]);
assert_ok!(Salp::contribute(Some(ract.clone()).into(), 3_000, 10));
assert_ok!(Salp::confirm_contribute(Some(ALICE).into(), ract, 3_000, true));
Expand All @@ -1005,7 +1005,7 @@ fn dissolve_should_work() {

assert_eq!(Salp::redeem_pool(), (10 * contribute_account_num) as u128);

for _ in 0 .. remove_times {
for _ in 0..remove_times {
assert_ok!(Salp::dissolve(Some(ALICE).into(), 3_000));
}

Expand Down Expand Up @@ -1397,7 +1397,7 @@ fn release_from_redeem_to_bancor_should_work() {
#[test]
fn check_next_trie_index() {
new_test_ext().execute_with(|| {
for i in 0 .. 100 {
for i in 0..100 {
assert_eq!(Salp::current_trie_index(), i);
assert_ok!(Salp::next_trie_index());
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/vesting/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;

fn add_locks<T: Config>(who: &T::AccountId, n: u8) {
for id in 0 .. n {
for id in 0..n {
let lock_id = [id; 8];
let locked = 100u32;
let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE;
Expand Down
10 changes: 5 additions & 5 deletions pallets/vsbond-auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub mod pallet {
Some(list) => {
list.insert(order_id);
Ok(())
}
},
None => Err(Error::<T>::Unexpected),
})?;

Expand Down Expand Up @@ -277,7 +277,7 @@ pub mod pallet {
Some(list) => {
list.remove(&order_id);
Ok(())
}
},
None => Err(Error::<T>::Unexpected),
})?;
if !RevokedOrderIds::<T>::contains_key(&from) {
Expand All @@ -287,7 +287,7 @@ pub mod pallet {
Some(list) => {
list.insert(order_id);
Ok(())
}
},
None => Err(Error::<T>::Unexpected),
})?;

Expand Down Expand Up @@ -392,7 +392,7 @@ pub mod pallet {
Some(list) => {
list.remove(&order_id);
Ok(())
}
},
None => Err(Error::<T>::Unexpected),
},
)?;
Expand All @@ -408,7 +408,7 @@ pub mod pallet {
Some(list) => {
list.insert(order_id);
Ok(())
}
},
None => Err(Error::<T>::Unexpected),
},
)?;
Expand Down
2 changes: 1 addition & 1 deletion pallets/vsbond-auction/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn create_order_without_enough_vsbond_should_fail() {
#[test]
fn create_order_exceed_maximum_order_in_trade_should_fail() {
new_test_ext().execute_with(|| {
for _ in 0 .. MaximumOrderInTrade::get() {
for _ in 0..MaximumOrderInTrade::get() {
assert_ok!(Auction::create_order(Some(ALICE).into(), 3000, 13, 20, 1, 1.to_fixed()));
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/asgard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl InstanceFilter<Call> for ProxyType {
),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)))
}
},
}
}

Expand Down
5 changes: 2 additions & 3 deletions runtime/common/src/xcm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ impl<T: Get<ParaId>> Convert<CurrencyId, Option<MultiLocation>> for BifrostCurre
use CurrencyId::Token;
match id {
Token(TokenSymbol::KSM) | Token(TokenSymbol::DOT) => Some(X1(Parent)),
Token(TokenSymbol::ASG) | Token(TokenSymbol::BNC) => {
Some(native_currency_location(id, T::get()))
}
Token(TokenSymbol::ASG) | Token(TokenSymbol::BNC) =>
Some(native_currency_location(id, T::get())),
_ => None,
}
}
Expand Down
6 changes: 3 additions & 3 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ newline_style = "Unix"
normalize_comments = true
normalize_doc_attributes = true
# Misc
max_width = 100
comment_width = 100
chain_width = 80
wrap_comments = true
spaces_around_ranges = true
reorder_impl_items = true
match_arm_leading_pipes = "Preserve"
match_arm_blocks = false
match_block_trailing_comma = true
use_field_init_shorthand = true
binop_separator = "Back"
license_template_path = "HEADER-GPL3"
20 changes: 8 additions & 12 deletions xcm-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ enum Error {
impl From<Error> for XcmError {
fn from(e: Error) -> Self {
match e {
Error::FailedToMatchFungible => {
XcmError::FailedToTransactAsset("FailedToMatchFungible")
}
Error::AccountIdConversionFailed => {
XcmError::FailedToTransactAsset("AccountIdConversionFailed")
}
Error::CurrencyIdConversionFailed => {
XcmError::FailedToTransactAsset("CurrencyIdConversionFailed")
}
Error::FailedToMatchFungible =>
XcmError::FailedToTransactAsset("FailedToMatchFungible"),
Error::AccountIdConversionFailed =>
XcmError::FailedToTransactAsset("AccountIdConversionFailed"),
Error::CurrencyIdConversionFailed =>
XcmError::FailedToTransactAsset("CurrencyIdConversionFailed"),
}
}
}
Expand Down Expand Up @@ -128,10 +125,9 @@ impl<
Matcher::matches_fungible(&asset),
) {
// known asset
(Ok(who), Some(currency_id), Some(amount)) => {
(Ok(who), Some(currency_id), Some(amount)) =>
MultiCurrency::deposit(currency_id, &who, amount)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))
}
.map_err(|e| XcmError::FailedToTransactAsset(e.into())),
_ => Err(XcmError::AssetNotFound),
}
}
Expand Down
2 changes: 1 addition & 1 deletion xcm-support/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn encode_xcm(message: Xcm<()>, message_kind: MessageKind) -> Vec<u8> {
let encoded = VersionedXcm::<()>::from(message).encode();
outbound.extend_from_slice(&encoded[..]);
outbound
}
},
}
}

Expand Down