Skip to content

Commit 53e4537

Browse files
committed
chore: fix clippy isues
1 parent 28ebe52 commit 53e4537

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

bindings/swift/DojoEngineFFI.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_publish_message(uint64_t ptr
438438
RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_publish_message_batch(uint64_t ptr, RustBuffer messages, RustCallStatus *_Nonnull out_status
439439
);
440440
#endif
441+
#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SEARCH
442+
#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SEARCH
443+
RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_search(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status
444+
);
445+
#endif
441446
#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SQL
442447
#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_FN_METHOD_TORIICLIENT_SQL
443448
RustBuffer uniffi_dojo_uniffi_fn_method_toriiclient_sql(uint64_t ptr, RustBuffer query, RustCallStatus *_Nonnull out_status
@@ -852,6 +857,12 @@ uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message(void
852857
#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_PUBLISH_MESSAGE_BATCH
853858
uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_publish_message_batch(void
854859

860+
);
861+
#endif
862+
#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SEARCH
863+
#define UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SEARCH
864+
uint16_t uniffi_dojo_uniffi_checksum_method_toriiclient_search(void
865+
855866
);
856867
#endif
857868
#ifndef UNIFFI_FFIDEF_UNIFFI_DOJO_UNIFFI_CHECKSUM_METHOD_TORIICLIENT_SQL

crates/c/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,9 +2096,7 @@ mod ffi {
20962096
Ok(typed_data) => typed_data,
20972097
Err(err) => {
20982098
return Result::Err(Error {
2099-
message: CString::new(format!("Invalid typed data: {}", err))
2100-
.unwrap()
2101-
.into_raw(),
2099+
message: CString::new(format!("Invalid typed data: {err}")).unwrap().into_raw(),
21022100
});
21032101
}
21042102
};

crates/uniffi/src/bin/uniffi-bindgen-swift.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,19 @@ fn main() {
8484
let has_modulemap = args.contains(&"--modulemap".to_string());
8585
let has_xcframework = args.contains(&"--xcframework".to_string());
8686

87-
// Default to generating Swift sources if no specific flags are provided
88-
let generate_swift_sources = has_swift_sources || (!has_headers && !has_modulemap);
87+
// Default to generating Swift sources and headers if no specific flags are provided
88+
let generate_swift_sources =
89+
has_swift_sources || (!has_headers && !has_modulemap) || (has_headers);
90+
let generate_headers =
91+
has_headers || (!has_swift_sources && !has_modulemap) || has_swift_sources;
8992

9093
println!("Generating Swift bindings...");
9194
println!("Library: {}", library_path);
9295
println!("Output: {}", out_dir);
9396

9497
let options = SwiftBindingsOptions {
9598
generate_swift_sources,
96-
generate_headers: has_headers,
99+
generate_headers,
97100
generate_modulemap: has_modulemap,
98101
source: library_path,
99102
out_dir,

crates/wasm/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl TypedData {
217217

218218
self.0
219219
.message_hash(address)
220-
.map(|felt| format!("{:#x}", felt))
220+
.map(|felt| format!("{felt:#x}"))
221221
.map_err(|err| JsValue::from(err.to_string()))
222222
}
223223
}
@@ -260,7 +260,7 @@ impl Provider {
260260
.await;
261261

262262
match result {
263-
Ok(res) => Ok(res.iter().map(|f| JsValue::from(format!("{:#x}", f))).collect()),
263+
Ok(res) => Ok(res.iter().map(|f| JsValue::from(format!("{f:#x}"))).collect()),
264264
Err(e) => Err(JsValue::from_str(&e.to_string())),
265265
}
266266
}
@@ -291,7 +291,7 @@ impl Provider {
291291
#[wasm_bindgen(js_name = chainId)]
292292
pub async fn chain_id(&self) -> Result<String, JsValue> {
293293
let chain_id = self.0.chain_id().await.map_err(|e| JsValue::from(e.to_string()))?;
294-
Ok(format!("{:#x}", chain_id))
294+
Ok(format!("{chain_id:#x}"))
295295
}
296296
}
297297

@@ -355,7 +355,7 @@ impl Account {
355355
#[wasm_bindgen(js_name = address)]
356356
pub unsafe fn address(&self) -> Result<String, JsValue> {
357357
let address = self.0.address();
358-
Ok(format!("{:#x}", address))
358+
Ok(format!("{address:#x}"))
359359
}
360360

361361
/// Returns the account's chain ID
@@ -365,7 +365,7 @@ impl Account {
365365
#[wasm_bindgen(js_name = chainId)]
366366
pub unsafe fn chain_id(&self) -> Result<String, JsValue> {
367367
let chain_id = self.0.chain_id();
368-
Ok(format!("{:#x}", chain_id))
368+
Ok(format!("{chain_id:#x}"))
369369
}
370370

371371
/// Sets the block ID for subsequent operations
@@ -467,7 +467,7 @@ impl Account {
467467
#[wasm_bindgen(js_name = nonce)]
468468
pub async unsafe fn nonce(&self) -> Result<String, JsValue> {
469469
let nonce = self.0.get_nonce().await.map_err(|e| JsValue::from(e.to_string()))?;
470-
Ok(format!("{:#x}", nonce))
470+
Ok(format!("{nonce:#x}"))
471471
}
472472

473473
/// Gets the provider of the account
@@ -520,7 +520,7 @@ pub fn get_contract_address(
520520
deployer_address,
521521
);
522522

523-
Ok(format!("{:#x}", address))
523+
Ok(format!("{address:#x}"))
524524
}
525525

526526
/// Computes a selector from a tag string
@@ -533,7 +533,7 @@ pub fn get_contract_address(
533533
#[wasm_bindgen(js_name = getSelectorFromTag)]
534534
pub fn get_selector_from_tag(tag: &str) -> String {
535535
let selector = compute_selector_from_tag(tag);
536-
format!("{:#x}", selector)
536+
format!("{selector:#x}")
537537
}
538538

539539
#[wasm_bindgen]
@@ -561,7 +561,7 @@ impl ByteArray {
561561
#[wasm_bindgen(js_name = toRaw)]
562562
pub fn to_raw(&self) -> Result<Vec<String>, JsValue> {
563563
let felts = cairo_serde::ByteArray::cairo_serialize(&self.0);
564-
Ok(felts.iter().map(|f| format!("{:#x}", f)).collect())
564+
Ok(felts.iter().map(|f| format!("{f:#x}")).collect())
565565
}
566566

567567
/// Deserializes a Cairo byte array into a string
@@ -626,7 +626,7 @@ pub fn poseidon_hash(inputs: Vec<String>) -> Result<String, JsValue> {
626626
pub fn get_selector_from_name(name: &str) -> Result<String, JsValue> {
627627
let selector = starknet::core::utils::get_selector_from_name(name)
628628
.map_err(|e| JsValue::from(e.to_string()))?;
629-
Ok(format!("{:#x}", selector))
629+
Ok(format!("{selector:#x}"))
630630
}
631631

632632
/// Computes the Starknet variant of Keccak hash
@@ -641,7 +641,7 @@ pub fn starknet_keccak(inputs: js_sys::Uint8Array) -> Result<String, JsValue> {
641641
let inputs = inputs.to_vec();
642642

643643
let hash = starknet::core::utils::starknet_keccak(&inputs);
644-
Ok(format!("{:#x}", hash))
644+
Ok(format!("{hash:#x}"))
645645
}
646646

647647
/// Converts a short string to a Cairo field element
@@ -656,7 +656,7 @@ pub fn cairo_short_string_to_felt(str: &str) -> Result<String, JsValue> {
656656
let felt = starknet::core::utils::cairo_short_string_to_felt(str)
657657
.map_err(|e| JsValue::from(e.to_string()))?;
658658

659-
Ok(format!("{:#x}", felt))
659+
Ok(format!("{felt:#x}"))
660660
}
661661

662662
/// Parses a Cairo field element into a short string

crates/wasm/src/types.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ impl From<torii_proto::Token> for Token {
9999
fn from(value: torii_proto::Token) -> Self {
100100
Self {
101101
contract_address: format!("{:#x}", value.contract_address),
102-
token_id: value.token_id.map(|t| format!("0x{:x}", t)),
102+
token_id: value.token_id.map(|t| format!("0x{t:x}")),
103103
name: value.name.clone(),
104104
symbol: value.symbol.clone(),
105105
decimals: value.decimals,
106106
metadata: value.metadata.clone(),
107-
total_supply: value.total_supply.map(|t| format!("0x{:x}", t)),
107+
total_supply: value.total_supply.map(|t| format!("0x{t:x}")),
108108
}
109109
}
110110
}
@@ -129,7 +129,7 @@ impl From<torii_proto::TokenContract> for TokenContract {
129129
symbol: value.symbol.clone(),
130130
decimals: value.decimals,
131131
token_metadata: value.token_metadata.clone(),
132-
total_supply: value.total_supply.map(|t| format!("0x{:x}", t)),
132+
total_supply: value.total_supply.map(|t| format!("0x{t:x}")),
133133
metadata: value.metadata.clone(),
134134
}
135135
}
@@ -150,7 +150,7 @@ impl From<torii_proto::TokenBalance> for TokenBalance {
150150
balance: format!("0x{:x}", value.balance),
151151
account_address: format!("{:#x}", value.account_address),
152152
contract_address: format!("{:#x}", value.contract_address),
153-
token_id: value.token_id.map(|t| format!("0x{:x}", t)),
153+
token_id: value.token_id.map(|t| format!("0x{t:x}")),
154154
}
155155
}
156156
}
@@ -176,7 +176,7 @@ impl From<torii_proto::TokenTransfer> for TokenTransfer {
176176
from_address: format!("{:#x}", value.from_address),
177177
to_address: format!("{:#x}", value.to_address),
178178
amount: format!("0x{:x}", value.amount),
179-
token_id: value.token_id.map(|t| format!("0x{:x}", t)),
179+
token_id: value.token_id.map(|t| format!("0x{t:x}")),
180180
executed_at: value.executed_at.timestamp() as u64,
181181
event_id: value.event_id,
182182
}
@@ -294,15 +294,15 @@ impl From<torii_proto::Transaction> for Transaction {
294294
Transaction {
295295
transaction_hash: format!("{:#x}", val.transaction_hash),
296296
sender_address: format!("{:#x}", val.sender_address),
297-
calldata: val.calldata.into_iter().map(|c| format!("{:#x}", c)).collect(),
297+
calldata: val.calldata.into_iter().map(|c| format!("{c:#x}")).collect(),
298298
max_fee: format!("{:#x}", val.max_fee),
299-
signature: val.signature.into_iter().map(|s| format!("{:#x}", s)).collect(),
299+
signature: val.signature.into_iter().map(|s| format!("{s:#x}")).collect(),
300300
nonce: format!("{:#x}", val.nonce),
301301
block_number: val.block_number,
302302
transaction_type: val.transaction_type,
303303
block_timestamp: val.block_timestamp.timestamp() as u64,
304304
calls: val.calls.into_iter().map(|c| c.into()).collect(),
305-
unique_models: val.unique_models.into_iter().map(|m| format!("{:#x}", m)).collect(),
305+
unique_models: val.unique_models.into_iter().map(|m| format!("{m:#x}")).collect(),
306306
}
307307
}
308308
}
@@ -338,7 +338,7 @@ impl From<torii_proto::TransactionCall> for TransactionCall {
338338
TransactionCall {
339339
contract_address: format!("{:#x}", val.contract_address),
340340
entrypoint: val.entrypoint,
341-
calldata: val.calldata.into_iter().map(|c| format!("{:#x}", c)).collect(),
341+
calldata: val.calldata.into_iter().map(|c| format!("{c:#x}")).collect(),
342342
call_type: val.call_type.into(),
343343
caller_address: format!("{:#x}", val.caller_address),
344344
}
@@ -520,7 +520,7 @@ impl From<torii_proto::Contract> for Contract {
520520
head: value.head,
521521
tps: value.tps,
522522
last_block_timestamp: value.last_block_timestamp,
523-
last_pending_block_tx: value.last_pending_block_tx.map(|tx| format!("{:#x}", tx)),
523+
last_pending_block_tx: value.last_pending_block_tx.map(|tx| format!("{tx:#x}")),
524524
updated_at: value.updated_at.timestamp() as u64,
525525
created_at: value.created_at.timestamp() as u64,
526526
}

crates/wasm/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,29 @@ pub fn pad_to_hex(input: &str) -> Result<String, String> {
113113
// Parse hexadecimal with prefix
114114
match BigUint::from_str_radix(&input[2..], 16) {
115115
Ok(v) => v,
116-
Err(_) => return Err(format!("Invalid hexadecimal input: {}", input)),
116+
Err(_) => return Err(format!("Invalid hexadecimal input: {input}")),
117117
}
118118
} else if input.chars().all(|c| c.is_ascii_hexdigit())
119119
&& input.chars().any(|c| !c.is_ascii_digit())
120120
{
121121
// Input contains non-decimal digits (a-f, A-F) without 0x prefix, assume hex
122122
match BigUint::from_str_radix(input, 16) {
123123
Ok(v) => v,
124-
Err(_) => return Err(format!("Invalid hexadecimal input: {}", input)),
124+
Err(_) => return Err(format!("Invalid hexadecimal input: {input}")),
125125
}
126126
} else {
127127
// Assume decimal otherwise
128128
match input.parse::<BigUint>() {
129129
Ok(v) => v,
130-
Err(_) => return Err(format!("Invalid numeric input: {}", input)),
130+
Err(_) => return Err(format!("Invalid numeric input: {input}")),
131131
}
132132
};
133133

134134
// Convert to hex string without 0x prefix
135135
let hex_string = big_value.to_str_radix(16);
136136

137137
// Pad to 64 characters
138-
let padded_hex = format!("{:0>64}", hex_string);
138+
let padded_hex = format!("{hex_string:0>64}");
139139

140140
Ok(padded_hex)
141141
}

0 commit comments

Comments
 (0)