Skip to content

Commit

Permalink
fix: param parse
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencil-Yao committed Mar 19, 2024
1 parent 48b0ec7 commit 49be279
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/cmd/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ where
.value_parser(parse_position),
)
.handler(|_cmd, m, ctx| {
let mut data = m.get_one::<Vec<u8>>("address").unwrap().to_owned();
let addr = *m.get_one::<Address>("address").unwrap();
let mut data = addr.to_vec();
let content = m.get_one::<Vec<u8>>("content").unwrap().to_owned();
data.extend_from_slice(&content);
let quota = *m.get_one::<u64>("quota").unwrap();
Expand Down Expand Up @@ -243,7 +244,8 @@ where
.value_parser(parse_position),
)
.handler(|_cmd, m, ctx| {
let mut data = m.get_one::<Vec<u8>>("address").unwrap().to_owned();
let addr = *m.get_one::<Address>("address").unwrap();
let mut data = addr.to_vec();
let content = m.get_one::<Vec<u8>>("content").unwrap().to_owned();
data.extend_from_slice(&content);
let quota = *m.get_one::<u64>("quota").unwrap();
Expand Down Expand Up @@ -304,10 +306,11 @@ where
.value_parser(parse_position),
)
.handler(|_cmd, m, ctx| {
let mut data = m.get_one::<Vec<u8>>("address").unwrap().to_owned();
let key = m.get_one::<Vec<u8>>("key").unwrap().to_owned();
let addr = *m.get_one::<Address>("address").unwrap();
let mut data = addr.to_vec();
let key = m.get_one::<[u8; 32]>("key").unwrap().to_owned();
data.extend_from_slice(&key);
let value = m.get_one::<Vec<u8>>("value").unwrap().to_owned();
let value = m.get_one::<[u8; 32]>("value").unwrap().to_owned();
data.extend_from_slice(&value);
let quota = *m.get_one::<u64>("quota").unwrap();
let admin_signer = ctx.current_account()?;
Expand Down Expand Up @@ -343,7 +346,7 @@ where
Arg::new("balance")
.help("the balance be set")
.required(true)
.value_parser(parse_data),
.value_parser(parse_value),
)
.arg(
Arg::new("quota")
Expand All @@ -361,8 +364,9 @@ where
.value_parser(parse_position),
)
.handler(|_cmd, m, ctx| {
let mut data = m.get_one::<Vec<u8>>("address").unwrap().to_owned();
let balance = m.get_one::<Vec<u8>>("balance").unwrap().to_owned();
let addr = *m.get_one::<Address>("address").unwrap();
let mut data = addr.to_vec();
let balance = m.get_one::<[u8; 32]>("balance").unwrap().to_owned();
data.extend_from_slice(&balance);
let quota = *m.get_one::<u64>("quota").unwrap();
let admin_signer = ctx.current_account()?;
Expand Down

0 comments on commit 49be279

Please sign in to comment.