Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default 0 equity for missing token #74

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions crates/zk-por-core/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,22 @@ pub fn parse_account_state(parsed_data: &Map<String, Value>, tokens: &Vec<String
.unwrap();
let mut parsed_equities = Vec::new();
for token in tokens.iter() {
let mut parsed_equity = F::ZERO;
if let Some(val) = equities.get(token) {
let parsed_equity =
F::from_canonical_u64(val.as_str().unwrap().parse::<u64>().unwrap());
parsed_equities.push(parsed_equity);
} else {
panic!("fail to find equity for token: {:?} in accountID {:?}", token, account_id);
parsed_equity = F::from_canonical_u64(val.as_str().unwrap().parse::<u64>().unwrap());
}
parsed_equities.push(parsed_equity);
cliff0412 marked this conversation as resolved.
Show resolved Hide resolved
}

let mut parsed_debts = Vec::new();
if let Some(debts) = parsed_data.get("debt") {
let debts = debts.as_object().unwrap();
for token in tokens.iter() {
let mut parsed_debt = F::ZERO;
if let Some(val) = debts.get(token) {
let parsed_debt =
F::from_canonical_u64(val.as_str().unwrap().parse::<u64>().unwrap());
parsed_debts.push(parsed_debt);
} else {
panic!("fail to find debt for token: {:?} in accountID {:?}", token, account_id);
parsed_debt = F::from_canonical_u64(val.as_str().unwrap().parse::<u64>().unwrap());
}
parsed_debts.push(parsed_debt);
}
} else {
// if there is no debt, we fill it with zero
Expand Down