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

fix: pipeline if no approval values #57

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions bot/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ pub async fn get_domains_ready_for_renewal(
let renewer_and_erc20: Vec<(String, String)> = results
.iter()
.map(|result| {
let test = config
.renewers_mapping
.get(&result.auto_renew_contract)
.unwrap();
(
result.renewer_address.clone(),
// get the erc20 address for the given auto_renew_contract
Expand Down Expand Up @@ -207,7 +211,7 @@ async fn process_aggregate_result(
}

let renewer_addr = FieldElement::from_hex_be(&result.renewer_address).unwrap();
// map the vec of approval_values to get tha approval_value for the erc20_addr selected
// map the vec of approval_values to get the approval_value for the erc20_addr selected
let erc20_allowance = if let Some(approval_value) = result
.approval_values
.iter()
Expand Down Expand Up @@ -270,7 +274,7 @@ async fn process_aggregate_result(
.unwrap();
println!(
"[OK] Domain {}.stark can be renewed by {}",
domain_name, renewer_addr
domain_name, to_hex(renewer_addr)
);
Some(AggregateResult {
domain: domain_encoded,
Expand Down
4 changes: 2 additions & 2 deletions bot/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub_struct!(Clone, Deserialize; Server {
starknetid_api: String,
});

pub_struct!(Clone, Deserialize; Altcoin {
pub_struct!(Clone, Deserialize; Renewer {
address: FieldElement,
renewal_contract: FieldElement,
});
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'de> Deserialize<'de> for Config {
rpc: Rpc,
watchtower: Watchtower,
server: Server,
renewers: HashMap<String, Altcoin>,
renewers: HashMap<String, Renewer>,
}

let OuterConfig {
Expand Down
2 changes: 1 addition & 1 deletion bot/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct DomainAggregateResult {
pub meta_hash: Option<String>,
pub _cursor: Cursor,
pub auto_renew_contract: FieldElement,
pub approval_values: Vec<AutoRenewAllowance>,
pub approval_values: Vec<AutoRenewAllowance>
}

pub struct AggregateResult {
Expand Down
8 changes: 3 additions & 5 deletions bot/src/pipelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub async fn get_auto_renewal_data(
"auto_renew_contract": { "$first": "$auto_renew_contract" },
"approval_values": {
"$push": {
"approval_value": "$approval_info.allowance",
"approval_value": { "$ifNull": [ "$approval_info.allowance", "0x0" ] },
"erc20_addr": erc20_addr
}
},
Expand Down Expand Up @@ -163,8 +163,8 @@ pub async fn get_auto_renewal_altcoins_data(
"auto_renew_contract": { "$first": "$auto_renew_contract" },
"approval_values": {
"$push": {
"approval_value": "$approval_info.allowance",
"erc20_addr": "$approval_info.erc20_addr"
"approval_value": { "$ifNull": [ "$approval_info.allowance", "0x0" ] },
"erc20_addr": { "$ifNull": [ "$approval_info.erc20_addr", "0x0" ] },
}
},
}},
Expand Down Expand Up @@ -195,7 +195,5 @@ pub async fn get_auto_renewal_altcoins_data(
// Check if the conversion was successful
let results = results?;

println!("results: {:?}", results);

Ok(results)
}
Loading