Skip to content

Commit c308a6d

Browse files
committed
chore: clippy fixes
Signed-off-by: aeryz <[email protected]>
1 parent fef1a73 commit c308a6d

File tree

3 files changed

+19
-97
lines changed

3 files changed

+19
-97
lines changed
Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,18 @@
1-
use std::str::FromStr;
2-
3-
use alloy::{primitives::Keccak256, sol_types::SolValue};
1+
use alloy::sol_types::SolValue;
42
use anyhow::Result;
53
use clap::{Args, Subcommand};
6-
use serde::Serialize;
74
use ucs03_zkgm::com::{
8-
Batch, Instruction, SolverMetadata, TokenMetadata, TokenOrderV1, TokenOrderV2, INSTR_VERSION_0,
9-
INSTR_VERSION_1, INSTR_VERSION_2, OP_BATCH, OP_TOKEN_ORDER, TOKEN_ORDER_KIND_INITIALIZE,
10-
TOKEN_ORDER_KIND_SOLVE,
11-
};
12-
use unionlabs::{
13-
encoding::Decode,
14-
primitives::{encoding::HexUnprefixed, Bytes, H256, U256},
5+
Instruction, SolverMetadata, TokenOrderV1, TokenOrderV2, INSTR_VERSION_1, INSTR_VERSION_2,
6+
OP_TOKEN_ORDER, TOKEN_ORDER_KIND_SOLVE,
157
};
8+
use unionlabs::primitives::{Bytes, U256};
169

1710
#[derive(Debug, Subcommand)]
1811
pub enum Cmd {
1912
V1(TokenOrderV1V1Args),
2013
V2Sui(TokenOrderV2ArgsSui),
2114
}
2215

23-
#[derive(Debug, Serialize, Clone, Args)]
24-
pub struct SuiMetadata {
25-
#[arg(long)]
26-
name: String,
27-
#[arg(long)]
28-
symbol: String,
29-
#[arg(long)]
30-
decimals: u8,
31-
#[arg(long, default_value_t = Default::default())]
32-
owner: H256,
33-
#[arg(long)]
34-
icon_url: Option<String>,
35-
#[arg(long)]
36-
description: String,
37-
}
38-
3916
#[derive(Debug, Args)]
4017
pub struct TokenOrderV2Base {
4118
#[arg(long)]
@@ -56,10 +33,10 @@ pub struct TokenOrderV2Base {
5633
pub struct TokenOrderV2ArgsSui {
5734
#[arg(long)]
5835
channel: u32,
36+
#[arg(long)]
37+
solver_address: Bytes,
5938
#[clap(flatten)]
6039
base: TokenOrderV2Base,
61-
#[clap(flatten)]
62-
metadata: SuiMetadata,
6340
}
6441

6542
#[derive(Debug, Args)]
@@ -114,34 +91,8 @@ impl Cmd {
11491
println!("{instruction}");
11592
}
11693
Cmd::V2Sui(fao) => {
117-
// let metadata = TokenMetadata {
118-
// implementation: Default::default(),
119-
// initializer: bcs::to_bytes(&fao.metadata).unwrap().into(),
120-
// }
121-
// .abi_encode_params()
122-
// .into();
123-
124-
// let quote_token = match fao.base.quote_token {
125-
// Some(qt) => qt.into(),
126-
// None => {
127-
// let mut h = Keccak256::new();
128-
// h.update(&metadata);
129-
// predict_wrapped_token_sui(
130-
// U256::ZERO,
131-
// fao.channel,
132-
// fao.base.base_token.clone().into(),
133-
// h.finalize().to_vec(),
134-
// )
135-
// .into()
136-
// }
137-
// };
138-
13994
let metadata = SolverMetadata {
140-
solverAddress: Bytes::<HexUnprefixed>::from_str(
141-
"c113302f2d081c65299ac245ce043c124368af79b5a9ce38d86855841b64d386",
142-
)
143-
.unwrap()
144-
.into(),
95+
solverAddress: fao.solver_address.into(),
14596
metadata: Default::default(),
14697
}
14798
.abi_encode_params()
@@ -166,37 +117,10 @@ impl Cmd {
166117
.abi_encode_params()
167118
.into();
168119

169-
// let batch: Bytes = Instruction {
170-
// version: INSTR_VERSION_0,
171-
// opcode: OP_BATCH,
172-
// operand: Batch {
173-
// instructions: vec![instruction.clone(), instruction],
174-
// }
175-
// .abi_encode_params()
176-
// .into(),
177-
// }
178-
// .abi_encode_params()
179-
// .into();
180-
//
181-
182120
println!("{instruction}");
183121
}
184122
}
185123

186124
Ok(())
187125
}
188126
}
189-
190-
fn predict_wrapped_token_sui(
191-
path: U256,
192-
channel: u32,
193-
base_token: Vec<u8>,
194-
metadata_image: Vec<u8>,
195-
) -> Vec<u8> {
196-
let mut h = Keccak256::new();
197-
h.update(bcs::to_bytes(&path.to_le_bytes()).unwrap());
198-
h.update(bcs::to_bytes(&channel).unwrap());
199-
h.update(base_token);
200-
h.update(metadata_image);
201-
h.finalize().to_vec()
202-
}

voyager/plugins/sui-ibc-app/src/zkgm.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn begin_recv_call(
5555
p.source_channel_id,
5656
p.destination_channel_id,
5757
p.data.clone(),
58-
0 as u64,
58+
0,
5959
p.timeout_timestamp,
6060
)
6161
})
@@ -176,7 +176,7 @@ pub fn begin_ack_call(
176176
p.source_channel_id,
177177
p.destination_channel_id,
178178
p.data.clone(),
179-
0 as u64,
179+
0,
180180
p.timeout_timestamp,
181181
)
182182
})
@@ -345,7 +345,7 @@ pub async fn publish_new_coin(
345345
bcs::to_bytes(&SuiAddress::from(&pk.public())).unwrap(),
346346
))
347347
.unwrap();
348-
let _ = ptb.command(Command::TransferObjects(vec![res.clone()], arg));
348+
let _ = ptb.command(Command::TransferObjects(vec![res], arg));
349349

350350
let transaction_response =
351351
voyager_transaction_plugin_sui::send_transactions(&module.sui_client, pk, ptb.finish())
@@ -414,7 +414,7 @@ pub async fn get_registered_wrapped_token(
414414
module.zkgm_config.wrapped_token_to_t,
415415
DynamicFieldName {
416416
type_: TypeTag::Vector(Box::new(TypeTag::U8)),
417-
value: serde_json::to_value(&wrapped_token).expect("serde will work"),
417+
value: serde_json::to_value(wrapped_token).expect("serde will work"),
418418
},
419419
)
420420
.await
@@ -440,15 +440,15 @@ pub async fn get_registered_wrapped_token(
440440
);
441441
}
442442

443-
return Ok(Some(
443+
Ok(Some(
444444
StructTag {
445445
address: AccountAddress::from_str(fields[0]).expect("address is valid"),
446446
module: Identifier::new(fields[1]).expect("module name is valid"),
447447
name: Identifier::new(fields[2]).expect("name is valid"),
448448
type_params: vec![],
449449
}
450450
.into(),
451-
));
451+
))
452452
}
453453
SuiParsedData::Package(_) => panic!("this should never be a package"),
454454
}
@@ -524,6 +524,7 @@ struct SuiFungibleAssetMetadata {
524524
description: String,
525525
}
526526

527+
#[allow(clippy::too_many_arguments)]
527528
/// Deploy and register the token if needed in `ZKGM`
528529
pub async fn register_token_if_zkgm(
529530
module: &Module,

voyager/plugins/transaction/sui/src/main.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl Module {
211211
move_api::channel_open_ack(
212212
&mut ptb_builder,
213213
self,
214-
try_parse_port(&self.graphql_url, &port_id.as_bytes()).await?,
214+
try_parse_port(&self.graphql_url, port_id.as_bytes()).await?,
215215
port_id,
216216
data,
217217
)?
@@ -221,9 +221,8 @@ impl Module {
221221
self,
222222
try_parse_port(
223223
&self.graphql_url,
224-
&move_api::get_port_id(self, data.channel_id)
224+
move_api::get_port_id(self, data.channel_id)
225225
.await?
226-
.as_str()
227226
.as_bytes(),
228227
)
229228
.await?,
@@ -233,8 +232,7 @@ impl Module {
233232
let port_id =
234233
move_api::get_port_id(self, data.packets[0].destination_channel_id).await?;
235234

236-
let module_info =
237-
try_parse_port(&self.graphql_url, &port_id.as_bytes()).await?;
235+
let module_info = try_parse_port(&self.graphql_url, port_id.as_bytes()).await?;
238236

239237
let channel_version = voyager_client
240238
.query_ibc_state(
@@ -287,8 +285,7 @@ impl Module {
287285
let port_id =
288286
move_api::get_port_id(self, data.packets[0].source_channel_id).await?;
289287

290-
let module_info =
291-
try_parse_port(&self.graphql_url, &port_id.as_bytes()).await?;
288+
let module_info = try_parse_port(&self.graphql_url, port_id.as_bytes()).await?;
292289

293290
let channel_version = voyager_client
294291
.query_ibc_state(
@@ -397,7 +394,7 @@ impl PluginServer<ModuleCall, ModuleCallback> for Module {
397394
.await
398395
.unwrap();
399396

400-
let _ = send_transactions(&self.sui_client, &pk, ptb).await?;
397+
let _ = send_transactions(&self.sui_client, pk, ptb).await?;
401398
Ok(noop())
402399
})
403400
})

0 commit comments

Comments
 (0)