Skip to content

Commit

Permalink
fix scanner.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinyuchan committed Oct 7, 2023
1 parent bb41a6e commit 62a893b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion explorer/src/service/v2/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub async fn v2_get_txs(
}
if let Some(to_address) = to.0 {
params.push(format!(
"(receiver @? '$.items[*] ? (@==\"{}\")') ",
"(receiver @? '$.addrs[*] ? (@==\"{}\")') ",
to_address
));
}
Expand Down
73 changes: 39 additions & 34 deletions scanner/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use std::time::Duration;

#[derive(Serialize, Deserialize, Debug)]
pub struct Receivers {
pub items: Vec<String>,
pub addrs: Vec<String>,
}

pub struct TendermintRPC {
Expand Down Expand Up @@ -256,7 +256,7 @@ impl RPCCaller {
v = serde_json::to_value(&wrap_evm_tx).unwrap();
}
let r = Receivers {
items: addrs.clone(),
addrs: addrs.clone(),
};
let receivers_val = serde_json::to_value(&r).unwrap();
evm_txs.push(Transaction {
Expand Down Expand Up @@ -449,59 +449,64 @@ impl RPCCaller {
let pk = &opt.transfer_asset.body_signatures[0].address.key;
let signer = pubkey_to_fra_address(pk).unwrap();
for o in opt.transfer_asset.body.transfer.outputs {
let receiver: String;
let mut receiver: String = "".to_string();
let type_show_amount_show: core::result::Result<
OutputTypeShowAmountShow,
_,
> = serde_json::from_value(o.clone());

if type_show_amount_show.is_err() {
if let Ok(tsas) = type_show_amount_show {
// type show, amount show
let pk = tsas.public_key;
if pk.eq(&FRA_ASSET) {
continue;
}
receiver = pubkey_to_fra_address(&pk).unwrap();
} else {
// type show, amount hide
let type_show_amount_hide: core::result::Result<
OutputTypeShowAmountHide,
_,
> = serde_json::from_value(o.clone());
if type_show_amount_hide.is_err() {

if let Ok(tsah) = type_show_amount_hide {
let pk = tsah.public_key;
if pk.eq(&FRA_ASSET) {
continue;
}
ty_sub = FindoraTxType::TypeShowAmountHide as i32;
receiver = pubkey_to_fra_address(&pk).unwrap();
} else {
// type hide, amount show
let type_hide_amount_show: core::result::Result<
OutputTypeHideAmountShow,
_,
> = serde_json::from_value(o.clone());
if type_hide_amount_show.is_err() {
// type hide, amount hide
let type_hide_amount_hide: OutputTypeHideAmountHide =
serde_json::from_value(o).unwrap();
if type_hide_amount_hide.public_key.eq(&FRA_ASSET) {
continue;
}
ty_sub = FindoraTxType::TypeHideAmountHide as i32;
receiver = pubkey_to_fra_address(
&type_hide_amount_hide.public_key,
)
.unwrap();
} else {
let pk = type_hide_amount_show.unwrap().public_key;

if let Ok(thas) = type_hide_amount_show {
let pk = thas.public_key;
if pk.eq(&FRA_ASSET) {
continue;
}
ty_sub = FindoraTxType::TypeHideAmountShow as i32;
receiver = pubkey_to_fra_address(&pk).unwrap();
} else {
// type hide, amount hide
let type_hide_amount_hide: core::result::Result<
OutputTypeHideAmountHide,
_,
> = serde_json::from_value(o.clone());

if let Ok(thah) = type_hide_amount_hide {
if thah.public_key.eq(&FRA_ASSET) {
continue;
}
ty_sub = FindoraTxType::TypeHideAmountHide as i32;
receiver = pubkey_to_fra_address(&thah.public_key)
.unwrap();
}
}
} else {
let pk = type_show_amount_hide.unwrap().public_key;
if pk.eq(&FRA_ASSET) {
continue;
}
ty_sub = FindoraTxType::TypeShowAmountHide as i32;
receiver = pubkey_to_fra_address(&pk).unwrap();
}
} else {
// type show, amount show
let pk = type_show_amount_show.unwrap().public_key;
if pk.eq(&FRA_ASSET) {
continue;
}
receiver = pubkey_to_fra_address(&pk).unwrap();
}

addrs.push(receiver);
Expand All @@ -513,7 +518,7 @@ impl RPCCaller {
}

let r = Receivers {
items: addrs.clone(),
addrs: addrs.clone(),
};
let receivers_val = serde_json::to_value(&r).unwrap();
txs.push(Transaction {
Expand Down

0 comments on commit 62a893b

Please sign in to comment.