Skip to content

Commit 8ea2f98

Browse files
authored
Switch to rust edition 2024 (#885)
* Naive test with just updating the version without any changes. * Mark extern and no_mangle as unsafe * Apply new formatting rules * Remove redundant parenthesis * Simplify if * Simplify if-structure * Use new syntax "use bound" syntax for generics * Use `match` instead of `if let` * Use `expr_2021` in macros
1 parent fa4424a commit 8ea2f98

83 files changed

Lines changed: 170 additions & 174 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "substrate-api-client"
33
version = "1.22.0"
44
authors = ["Supercomputing Systems AG <info@scs.ch>"]
55
license = "Apache-2.0"
6-
edition = "2021"
6+
edition = "2024"
77
repository = "https://github.com/scs/substrate-api-client"
88
description = "Json-rpc client with helper functions compatible with any Substrate node"
99
readme = "../README.md"

api-client/src/api/api_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
*/
1313

1414
use crate::{
15+
GetAccountInformation,
1516
api::error::{Error, Result},
1617
rpc::Request,
1718
runtime_api::RuntimeApiClient,
18-
GetAccountInformation,
1919
};
2020
use ac_compose_macros::rpc_params;
2121
use ac_node_api::metadata::Metadata;
@@ -272,7 +272,7 @@ mod tests {
272272
use ac_primitives::{
273273
DefaultRuntimeConfig, GenericAdditionalParams, GenericExtrinsicParams, PlainTip,
274274
};
275-
use frame_metadata::{v14::ExtrinsicMetadata, RuntimeMetadata};
275+
use frame_metadata::{RuntimeMetadata, v14::ExtrinsicMetadata};
276276
use scale_info::form::PortableForm;
277277
use sp_core::H256;
278278
use std::{collections::HashMap, fs};

api-client/src/api/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
*/
1717

18-
use crate::{api::UnexpectedTxStatus, rpc::Error as RpcClientError, ExtrinsicReport};
18+
use crate::{ExtrinsicReport, api::UnexpectedTxStatus, rpc::Error as RpcClientError};
1919
use ac_node_api::{
2020
error::DispatchError,
2121
metadata::{MetadataConversionError, MetadataError},

api-client/src/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
use crate::error::FailedExtrinsicError;
19-
use ac_node_api::{events::RawEventDetails, EventDetails, Metadata};
19+
use ac_node_api::{EventDetails, Metadata, events::RawEventDetails};
2020
use alloc::{string::String, vec::Vec};
2121
use codec::{Decode, Encode};
2222
use serde::{Deserialize, Serialize};

api-client/src/api/rpc_api/author.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
//! Interface to common author rpc functions and helpers thereof.
1515
1616
use crate::{
17-
api::{rpc_api::events::FetchEvents, Error, Result},
18-
rpc::{HandleSubscription, Request, Subscribe},
1917
Api, ExtrinsicReport, TransactionStatus, XtStatus,
18+
api::{Error, Result, rpc_api::events::FetchEvents},
19+
rpc::{HandleSubscription, Request, Subscribe},
2020
};
2121
use ac_compose_macros::rpc_params;
22-
use ac_primitives::{config::Config, UncheckedExtrinsic};
22+
use ac_primitives::{UncheckedExtrinsic, config::Config};
2323
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2424
use alloc::boxed::Box;
2525
use codec::{Decode, Encode};

api-client/src/api/rpc_api/chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
*/
1313

1414
use crate::{
15+
Error,
1516
api::{Api, Result},
1617
rpc::{Request, Subscribe},
17-
Error,
1818
};
1919
use ac_compose_macros::rpc_params;
2020
use ac_primitives::config::Config;
@@ -37,7 +37,7 @@ pub trait GetChainInfo {
3737
async fn get_header(&self, hash: Option<Self::Hash>) -> Result<Option<Self::Header>>;
3838

3939
async fn get_block_hash(&self, number: Option<Self::BlockNumber>)
40-
-> Result<Option<Self::Hash>>;
40+
-> Result<Option<Self::Hash>>;
4141

4242
/// Returns the genesis block
4343
async fn get_genesis_block(&self) -> Result<Self::Block>;

api-client/src/api/rpc_api/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
*/
1313

1414
use crate::{
15+
GetChainInfo, GetStorage,
1516
api::{Api, Error, Result},
1617
rpc::{HandleSubscription, Request, Subscribe},
17-
GetChainInfo, GetStorage,
1818
};
1919
use ac_compose_macros::rpc_params;
20-
use ac_node_api::{metadata::Metadata, EventDetails, EventRecord, Events, Phase};
20+
use ac_node_api::{EventDetails, EventRecord, Events, Phase, metadata::Metadata};
2121
use ac_primitives::config::Config;
2222
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2323
use alloc::boxed::Box;
@@ -238,10 +238,10 @@ mod tests {
238238
use frame_metadata::RuntimeMetadataPrefixed;
239239
use rococo_runtime::{BalancesCall, RuntimeCall, UncheckedExtrinsic};
240240
use scale_info::TypeInfo;
241-
use sp_core::{crypto::Ss58Codec, sr25519, Bytes, H256};
241+
use sp_core::{Bytes, H256, crypto::Ss58Codec, sr25519};
242242
use sp_runtime::{
243-
generic::{Block, SignedBlock},
244243
AccountId32, MultiAddress,
244+
generic::{Block, SignedBlock},
245245
};
246246
use sp_storage::StorageData;
247247
use sp_version::RuntimeVersion;

api-client/src/api/rpc_api/frame_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
rpc::Request,
1919
};
2020
use ac_compose_macros::rpc_params;
21-
use ac_primitives::{config::Config, AccountInfo};
21+
use ac_primitives::{AccountInfo, config::Config};
2222
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2323
use alloc::boxed::Box;
2424
use alloc::{string::String, vec::Vec};

api-client/src/api/rpc_api/pallet_transaction_payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
rpc::Request,
1616
};
1717
use ac_compose_macros::rpc_params;
18-
use ac_primitives::{config::Config, FeeDetails, InclusionFee, NumberOrHex, RuntimeDispatchInfo};
18+
use ac_primitives::{FeeDetails, InclusionFee, NumberOrHex, RuntimeDispatchInfo, config::Config};
1919
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
2020
use alloc::boxed::Box;
2121
use core::str::FromStr;

api-client/src/api/rpc_api/runtime_update.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
13-
use crate::{api::Error, rpc::Subscribe, rpc_api::EventSubscriptionFor, Result};
13+
use crate::{Result, api::Error, rpc::Subscribe, rpc_api::EventSubscriptionFor};
1414
use alloc::sync::Arc;
1515
use codec::{Decode, Encode};
1616
use core::sync::atomic::{AtomicBool, Ordering};
@@ -49,10 +49,10 @@ where
4949
#[maybe_async::maybe_async(?Send)]
5050
pub async fn detect_runtime_update(&mut self) -> Result<bool> {
5151
'outer: loop {
52-
if let Some(canceled) = &self.external_cancellation {
53-
if canceled.load(Ordering::SeqCst) {
54-
return Ok(false)
55-
}
52+
if let Some(canceled) = &self.external_cancellation
53+
&& canceled.load(Ordering::SeqCst)
54+
{
55+
return Ok(false)
5656
}
5757
let event_records = self
5858
.subscription

0 commit comments

Comments
 (0)