Skip to content

Commit

Permalink
fix(bolt-cli): don't panic when stake is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen committed Dec 12, 2024
1 parent 5e77002 commit 831bf7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 26 additions & 2 deletions bolt-cli/src/commands/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,19 @@ impl OperatorsCommand {
let mut total_collateral = Uint::from(0);
for (name, address) in deployments.collateral {
let stake =
bolt_manager.getOperatorStake(address, address).call().await?._0;
match bolt_manager.getOperatorStake(address, address).call().await {
Ok(stake) => stake._0,
Err(e) => match try_parse_contract_error::<
BoltEigenLayerMiddlewareErrors,
>(e)?
{
BoltEigenLayerMiddlewareErrors::KeyNotFound(_) => Uint::from(0),
other => unreachable!(
"Unexpected error with selector {:?}",
other.selector()
),
},
};
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token = %name, amount = ?stake, "Operator has collateral");
Expand Down Expand Up @@ -420,7 +432,19 @@ impl OperatorsCommand {
let mut total_collateral = Uint::from(0);
for (name, address) in deployments.collateral {
let stake =
bolt_manager.getOperatorStake(address, address).call().await?._0;
match bolt_manager.getOperatorStake(address, address).call().await {
Ok(stake) => stake._0,
Err(e) => match try_parse_contract_error::<
BoltSymbioticMiddlewareErrors,
>(e)?
{
BoltSymbioticMiddlewareErrors::KeyNotFound(_) => Uint::from(0),
other => unreachable!(
"Unexpected error with selector {:?}",
other.selector()
),
},
};
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token = %name, amount = ?stake, "Operator has collateral");
Expand Down
2 changes: 2 additions & 0 deletions bolt-cli/src/contracts/bolt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ sol! {
error AlreadyRegistered();
error NotOperator();
error NotRegistered();
error KeyNotFound();
}

#[allow(missing_docs)]
Expand All @@ -87,5 +88,6 @@ sol! {
error AlreadyRegistered();
error NotOperator();
error NotRegistered();
error KeyNotFound();
}
}

0 comments on commit 831bf7a

Please sign in to comment.