Skip to content

Commit

Permalink
Merge pull request #57 from starknet-id/feat/add_altcoins_support
Browse files Browse the repository at this point in the history
fix: pipeline if no approval values
  • Loading branch information
Th0rgal authored Mar 28, 2024
2 parents 16c6ef2 + ce3b360 commit 950e70a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
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)
}

0 comments on commit 950e70a

Please sign in to comment.