diff --git a/util/rich-indexer/src/indexer/insert.rs b/util/rich-indexer/src/indexer/insert.rs index c9c4160fba..9c8831b347 100644 --- a/util/rich-indexer/src/indexer/insert.rs +++ b/util/rich-indexer/src/indexer/insert.rs @@ -386,8 +386,7 @@ pub(crate) async fn bulk_insert_tx_association_cell_dep_table( tx_association_cell_dep_rows.push(vec![ tx_id.into(), output_id.into(), - (u8::try_from(cell_dep.dep_type()).expect("cell_dep to u8 should be OK") as i16) - .into(), + (u8::from(cell_dep.dep_type()) as i16).into(), ]); } } @@ -521,13 +520,13 @@ pub(crate) fn build_output_cell_rows( cell_capacity as i64, ( cell.lock().code_hash().raw_data().to_vec(), - u8::try_from(cell.lock().hash_type()).expect("hash_type to u8 should be OK") as i16, + u8::from(cell.lock().hash_type()) as i16, cell.lock().args().raw_data().to_vec(), ), (cell.type_().to_opt().map(|type_script| { ( type_script.code_hash().raw_data().to_vec(), - u8::try_from(type_script.hash_type()).expect("hash_type to u8 should be OK") as i16, + u8::from(type_script.hash_type()) as i16, type_script.args().raw_data().to_vec(), ) })), @@ -543,7 +542,7 @@ pub(crate) async fn build_script_set( let lock_script = cell.lock(); let lock_script_row = ( lock_script.code_hash().raw_data().to_vec(), - u8::try_from(lock_script.hash_type()).expect("hash_type to u8 should be OK") as i16, + u8::from(lock_script.hash_type()) as i16, lock_script.args().raw_data().to_vec(), ); script_row.insert(lock_script_row); @@ -551,7 +550,7 @@ pub(crate) async fn build_script_set( if let Some(type_script) = cell.type_().to_opt() { let type_script_row = ( type_script.code_hash().raw_data().to_vec(), - u8::try_from(type_script.hash_type()).expect("hash_type to u8 should be OK") as i16, + u8::from(type_script.hash_type()) as i16, type_script.args().raw_data().to_vec(), ); script_row.insert(type_script_row); diff --git a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs index 4f0be3f8a5..e4de2a9c80 100644 --- a/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs +++ b/util/rich-indexer/src/indexer_handle/async_indexer_handle/get_transactions.rs @@ -146,7 +146,7 @@ pub async fn get_tx_with_cell( ) -> Result, u16, u32)>, Error> { let sql_union = build_tx_with_cell_union_sub_query(db_driver, &search_key)?; - let mut query_builder = SqlBuilder::select_from(&format!("{} AS res", sql_union)); + let mut query_builder = SqlBuilder::select_from(format!("{} AS res", sql_union)); query_builder.field("tx_id, block.block_number, ckb_transaction.tx_index, ckb_transaction.tx_hash, io_type, io_index"); query_builder .join("ckb_transaction") @@ -254,7 +254,7 @@ pub async fn get_tx_with_cells( ) -> Result, Vec<(u16, u32)>)>, Error> { let sql_union = build_tx_with_cell_union_sub_query(db_driver, &search_key)?; - let mut query_builder = SqlBuilder::select_from(&format!("{} AS res_union", sql_union)); + let mut query_builder = SqlBuilder::select_from(format!("{} AS res_union", sql_union)); query_builder .field("tx_id, block.block_number, ckb_transaction.tx_index, ckb_transaction.tx_hash, io_type, io_index") .join("ckb_transaction") @@ -274,7 +274,7 @@ pub async fn get_tx_with_cells( .trim_end_matches(';') .to_string(); - let mut query_builder = SqlBuilder::select_from(&format!("{} AS res", sql)); + let mut query_builder = SqlBuilder::select_from(format!("{} AS res", sql)); query_builder .field("tx_id") .field("block_number") diff --git a/util/rich-indexer/src/tests/query.rs b/util/rich-indexer/src/tests/query.rs index 3e04971c6c..d9e0c52a26 100644 --- a/util/rich-indexer/src/tests/query.rs +++ b/util/rich-indexer/src/tests/query.rs @@ -94,7 +94,7 @@ async fn get_cells() { search_key, IndexerOrder::Asc, 100u32.into(), - Some(vec![5u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), + Some([5u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), ) .await .unwrap(); @@ -153,7 +153,7 @@ async fn get_cells() { search_key, IndexerOrder::Asc, 10u32.into(), - Some(vec![1u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), + Some([1u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), ) .await .unwrap(); @@ -198,7 +198,7 @@ async fn get_cells_filter_data() { search_key, IndexerOrder::Asc, 100u32.into(), - Some(vec![2u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), + Some([2u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), ) .await .unwrap(); @@ -245,7 +245,7 @@ async fn get_cells_by_cursor() { search_key, IndexerOrder::Asc, 3u32.into(), - Some(vec![0u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), + Some([0u8, 0, 0, 0, 0, 0, 0, 0].pack().into()), ) .await .unwrap();