Skip to content

Commit 83bf05b

Browse files
committed
fixing formatting issues through check-fmt
1 parent 8cd29de commit 83bf05b

File tree

14 files changed

+112
-210
lines changed

14 files changed

+112
-210
lines changed

sdk/rust/examples/authorization_management.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ async fn main() -> Result<()> {
5858

5959
// Authorize Bob's account
6060
println!("⏳ Authorizing account...");
61-
let receipt = client
62-
.authorize_account(bob_account.clone(), transactions, bytes)
63-
.await?;
61+
let receipt = client.authorize_account(bob_account.clone(), transactions, bytes).await?;
6462

6563
println!("✅ Account authorized!");
6664
println!(" Block hash: {}", receipt.block_hash);
@@ -79,9 +77,7 @@ async fn main() -> Result<()> {
7977

8078
// Authorize this specific preimage
8179
println!("\n⏳ Authorizing preimage...");
82-
let receipt = client
83-
.authorize_preimage(content_hash, data.len() as u64)
84-
.await?;
80+
let receipt = client.authorize_preimage(content_hash, data.len() as u64).await?;
8581

8682
println!("✅ Preimage authorized!");
8783
println!(" Block hash: {}", receipt.block_hash);
@@ -91,18 +87,14 @@ async fn main() -> Result<()> {
9187
println!("═══ Refresh Authorization Example ═══\n");
9288

9389
println!("🔄 Refreshing Bob's account authorization...");
94-
let receipt = client
95-
.refresh_account_authorization(bob_account.clone())
96-
.await?;
90+
let receipt = client.refresh_account_authorization(bob_account.clone()).await?;
9791

9892
println!("✅ Authorization refreshed!");
9993
println!(" Block hash: {}", receipt.block_hash);
10094
println!(" Tx hash: {}\n", receipt.extrinsic_hash);
10195

10296
println!("🔄 Refreshing preimage authorization...");
103-
let receipt = client
104-
.refresh_preimage_authorization(content_hash)
105-
.await?;
97+
let receipt = client.refresh_preimage_authorization(content_hash).await?;
10698

10799
println!("✅ Preimage authorization refreshed!");
108100
println!(" Block hash: {}", receipt.block_hash);

sdk/rust/examples/chunked_store.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ async fn main() -> Result<()> {
4040
println!("📁 Reading file: {}", file_path);
4141

4242
// 2. Read file data
43-
let data = fs::read(file_path).map_err(|e| {
44-
Error::StorageFailed(format!("Failed to read file: {:?}", e))
45-
})?;
43+
let data = fs::read(file_path)
44+
.map_err(|e| Error::StorageFailed(format!("Failed to read file: {:?}", e)))?;
4645

4746
println!("📊 File size: {} bytes ({:.2} MB)\n", data.len(), data.len() as f64 / 1_048_576.0);
4847

@@ -80,12 +79,11 @@ async fn main() -> Result<()> {
8079
None, // use default config
8180
StoreOptions::default(),
8281
Some(|event| match event {
83-
ProgressEvent::ChunkStarted { index, total } => {
82+
ProgressEvent::ChunkStarted { index, total } =>
8483
if total_chunks == 0 {
8584
total_chunks = total;
8685
println!("🔨 Starting upload of {} chunks...", total);
87-
}
88-
},
86+
},
8987
ProgressEvent::ChunkCompleted { index, total, cid } => {
9088
chunks_completed += 1;
9189
let progress = (chunks_completed as f32 / total as f32) * 100.0;

sdk/rust/examples/simple_store.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ impl TransactionSubmitter for SubxtSubmitter {
7070
transactions: u32,
7171
bytes: u64,
7272
) -> Result<TransactionReceipt> {
73-
let tx = bulletin_runtime::tx()
74-
.transaction_storage()
75-
.authorize_account(who, transactions, bytes);
73+
let tx = bulletin_runtime::tx().transaction_storage().authorize_account(
74+
who,
75+
transactions,
76+
bytes,
77+
);
7678

7779
let result = self
7880
.api
@@ -141,9 +143,7 @@ impl TransactionSubmitter for SubxtSubmitter {
141143
&self,
142144
who: AccountId32,
143145
) -> Result<TransactionReceipt> {
144-
let tx = bulletin_runtime::tx()
145-
.transaction_storage()
146-
.refresh_account_authorization(who);
146+
let tx = bulletin_runtime::tx().transaction_storage().refresh_account_authorization(who);
147147

148148
let result = self
149149
.api

sdk/rust/src/async_client.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ impl<S: TransactionSubmitter> AsyncBulletinClient<S> {
6767

6868
/// Create a client with custom configuration.
6969
pub fn with_config(submitter: S, config: AsyncClientConfig) -> Self {
70-
Self {
71-
config,
72-
auth_manager: AuthorizationManager::new(),
73-
submitter,
74-
}
70+
Self { config, auth_manager: AuthorizationManager::new(), submitter }
7571
}
7672

7773
/// Set the authorization manager.

sdk/rust/src/authorization.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ pub struct AuthorizationManager {
3939

4040
impl Default for AuthorizationManager {
4141
fn default() -> Self {
42-
Self {
43-
default_scope: AuthorizationScope::Account,
44-
auto_refresh: false,
45-
}
42+
Self { default_scope: AuthorizationScope::Account, auto_refresh: false }
4643
}
4744
}
4845

@@ -54,18 +51,12 @@ impl AuthorizationManager {
5451

5552
/// Create an authorization manager with account-based authorization.
5653
pub fn with_account_auth() -> Self {
57-
Self {
58-
default_scope: AuthorizationScope::Account,
59-
auto_refresh: false,
60-
}
54+
Self { default_scope: AuthorizationScope::Account, auto_refresh: false }
6155
}
6256

6357
/// Create an authorization manager with preimage-based authorization.
6458
pub fn with_preimage_auth() -> Self {
65-
Self {
66-
default_scope: AuthorizationScope::Preimage,
67-
auto_refresh: false,
68-
}
59+
Self { default_scope: AuthorizationScope::Preimage, auto_refresh: false }
6960
}
7061

7162
/// Enable auto-refresh of authorizations.
@@ -146,7 +137,11 @@ pub mod helpers {
146137
/// Build authorization request parameters for account-based auth.
147138
///
148139
/// Returns: (transactions, max_size)
149-
pub fn build_account_auth_params(data_size: u64, num_chunks: usize, include_manifest: bool) -> (u32, u64) {
140+
pub fn build_account_auth_params(
141+
data_size: u64,
142+
num_chunks: usize,
143+
include_manifest: bool,
144+
) -> (u32, u64) {
150145
let manager = AuthorizationManager::new();
151146
manager.calculate_requirements(data_size, num_chunks, include_manifest)
152147
}
@@ -229,7 +224,8 @@ mod tests {
229224
assert_eq!(txs, 10);
230225

231226
// With manifest
232-
let (txs_with_manifest, bytes_with_manifest) = manager.estimate_authorization(10_000_000, true);
227+
let (txs_with_manifest, bytes_with_manifest) =
228+
manager.estimate_authorization(10_000_000, true);
233229
assert_eq!(txs_with_manifest, 11);
234230
assert!(bytes_with_manifest > bytes);
235231
}

sdk/rust/src/chunker.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
66
extern crate alloc;
77

8-
use alloc::vec::Vec;
98
use crate::types::{Chunk, ChunkerConfig, Error, Result};
9+
use alloc::vec::Vec;
1010

1111
/// Maximum chunk size allowed (8 MiB, matches pallet limit).
1212
pub const MAX_CHUNK_SIZE: usize = 8 * 1024 * 1024;
@@ -51,9 +51,7 @@ impl FixedSizeChunker {
5151

5252
/// Create a chunker with default configuration.
5353
pub fn default_config() -> Self {
54-
Self {
55-
config: ChunkerConfig::default(),
56-
}
54+
Self { config: ChunkerConfig::default() }
5755
}
5856

5957
/// Get the chunk size.
@@ -99,9 +97,11 @@ pub fn reassemble_chunks(chunks: &[Chunk]) -> Result<Vec<u8>> {
9997
// Validate chunk indices are sequential
10098
for (i, chunk) in chunks.iter().enumerate() {
10199
if chunk.index != i as u32 {
102-
return Err(Error::ChunkingFailed(
103-
alloc::format!("Chunk index mismatch: expected {}, got {}", i, chunk.index),
104-
));
100+
return Err(Error::ChunkingFailed(alloc::format!(
101+
"Chunk index mismatch: expected {}, got {}",
102+
i,
103+
chunk.index
104+
)));
105105
}
106106
}
107107

@@ -124,11 +124,7 @@ mod tests {
124124
#[test]
125125
fn test_fixed_size_chunker_single_chunk() {
126126
let data = vec![1u8; 100];
127-
let config = ChunkerConfig {
128-
chunk_size: 1024,
129-
max_parallel: 8,
130-
create_manifest: true,
131-
};
127+
let config = ChunkerConfig { chunk_size: 1024, max_parallel: 8, create_manifest: true };
132128

133129
let chunker = FixedSizeChunker::new(config).unwrap();
134130
let chunks = chunker.chunk(&data).unwrap();
@@ -142,11 +138,7 @@ mod tests {
142138
#[test]
143139
fn test_fixed_size_chunker_multiple_chunks() {
144140
let data = vec![1u8; 2500];
145-
let config = ChunkerConfig {
146-
chunk_size: 1000,
147-
max_parallel: 8,
148-
create_manifest: true,
149-
};
141+
let config = ChunkerConfig { chunk_size: 1000, max_parallel: 8, create_manifest: true };
150142

151143
let chunker = FixedSizeChunker::new(config).unwrap();
152144
let chunks = chunker.chunk(&data).unwrap();
@@ -165,11 +157,7 @@ mod tests {
165157
#[test]
166158
fn test_reassemble_chunks() {
167159
let original_data = vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10];
168-
let config = ChunkerConfig {
169-
chunk_size: 3,
170-
max_parallel: 8,
171-
create_manifest: true,
172-
};
160+
let config = ChunkerConfig { chunk_size: 3, max_parallel: 8, create_manifest: true };
173161

174162
let chunker = FixedSizeChunker::new(config).unwrap();
175163
let chunks = chunker.chunk(&original_data).unwrap();

sdk/rust/src/cid.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ pub fn hash_algorithm_to_pallet(algo: HashAlgorithm) -> HashingAlgorithm {
3636

3737
/// Create a CidConfig from SDK types.
3838
pub fn create_config(codec: CidCodec, hash_algo: HashAlgorithm) -> CidConfig {
39-
CidConfig {
40-
codec: codec_to_u64(codec),
41-
hashing: hash_algorithm_to_pallet(hash_algo),
42-
}
39+
CidConfig { codec: codec_to_u64(codec), hashing: hash_algorithm_to_pallet(hash_algo) }
4340
}
4441

4542
/// Calculate CID for data using SDK configuration types.
@@ -49,7 +46,8 @@ pub fn calculate_cid_with_config(
4946
hash_algo: HashAlgorithm,
5047
) -> Result<CidData> {
5148
let config = create_config(codec, hash_algo);
52-
calculate_cid(data, Some(config)).map_err(|_| Error::InvalidCid("Failed to calculate CID".into()))
49+
calculate_cid(data, Some(config))
50+
.map_err(|_| Error::InvalidCid("Failed to calculate CID".into()))
5351
}
5452

5553
/// Calculate CID with default configuration (raw codec, blake2b-256).

sdk/rust/src/client.rs

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
99
extern crate alloc;
1010

11-
use alloc::vec::Vec;
1211
use crate::{
1312
authorization::AuthorizationManager,
1413
chunker::{Chunker, FixedSizeChunker},
1514
dag::{DagBuilder, UnixFsDagBuilder},
1615
storage::{BatchStorageOperation, StorageOperation},
17-
types::{
18-
ChunkerConfig, Error, ProgressCallback, ProgressEvent, Result,
19-
StoreOptions,
20-
},
16+
types::{ChunkerConfig, Error, ProgressCallback, ProgressEvent, Result, StoreOptions},
2117
};
18+
use alloc::vec::Vec;
2219

2320
/// Configuration for the Bulletin client.
2421
#[derive(Debug, Clone)]
@@ -58,18 +55,12 @@ pub struct BulletinClient {
5855
impl BulletinClient {
5956
/// Create a new Bulletin client with default configuration.
6057
pub fn new() -> Self {
61-
Self {
62-
config: ClientConfig::default(),
63-
auth_manager: AuthorizationManager::new(),
64-
}
58+
Self { config: ClientConfig::default(), auth_manager: AuthorizationManager::new() }
6559
}
6660

6761
/// Create a client with custom configuration.
6862
pub fn with_config(config: ClientConfig) -> Self {
69-
Self {
70-
config,
71-
auth_manager: AuthorizationManager::new(),
72-
}
63+
Self { config, auth_manager: AuthorizationManager::new() }
7364
}
7465

7566
/// Set the authorization manager.
@@ -175,9 +166,7 @@ pub mod async_client {
175166
impl AsyncBulletinClient {
176167
/// Create a new async client.
177168
pub fn new(config: ClientConfig) -> Self {
178-
Self {
179-
client: BulletinClient::with_config(config),
180-
}
169+
Self { client: BulletinClient::with_config(config) }
181170
}
182171

183172
/// Store data (placeholder - requires subxt integration).
@@ -196,7 +185,11 @@ pub mod async_client {
196185
/// // Process result and return StoreResult
197186
/// }
198187
/// ```
199-
pub async fn store_placeholder(&self, _data: Vec<u8>, _options: StoreOptions) -> Result<()> {
188+
pub async fn store_placeholder(
189+
&self,
190+
_data: Vec<u8>,
191+
_options: StoreOptions,
192+
) -> Result<()> {
200193
// Placeholder - users should implement with their subxt setup
201194
Err(Error::StorageFailed(
202195
"This is a placeholder. Implement with subxt integration.".into(),
@@ -241,11 +234,8 @@ mod tests {
241234
fn test_prepare_store_chunked() {
242235
let client = BulletinClient::new();
243236
let data = vec![1u8; 5000];
244-
let config = Some(ChunkerConfig {
245-
chunk_size: 2000,
246-
max_parallel: 8,
247-
create_manifest: true,
248-
});
237+
let config =
238+
Some(ChunkerConfig { chunk_size: 2000, max_parallel: 8, create_manifest: true });
249239
let options = StoreOptions::default();
250240

251241
let result = client.prepare_store_chunked(&data, config, options, None);
@@ -260,11 +250,8 @@ mod tests {
260250
fn test_prepare_store_chunked_no_manifest() {
261251
let client = BulletinClient::new();
262252
let data = vec![1u8; 5000];
263-
let config = Some(ChunkerConfig {
264-
chunk_size: 2000,
265-
max_parallel: 8,
266-
create_manifest: false,
267-
});
253+
let config =
254+
Some(ChunkerConfig { chunk_size: 2000, max_parallel: 8, create_manifest: false });
268255
let options = StoreOptions::default();
269256

270257
let result = client.prepare_store_chunked(&data, config, options, None);

0 commit comments

Comments
 (0)