Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit fb971e6

Browse files
authored
cleanup log message content around contract balance (#478)
1 parent 5f87787 commit fb971e6

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

crates/worker/src/operations/provider.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ impl ProviderOperations {
6969
match stake_manager.get_stake(provider_address).await {
7070
Ok(stake) => {
7171
if first_check || stake != last_stake {
72-
Console::info("🔄 Chain Sync - Provider stake", &format!("{} tokens", stake / U256::from(10u128.pow(18))));
72+
Console::info("🔄 Chain Sync - Provider stake", &format!("{}", stake / U256::from(10u128.pow(18))));
7373
if !first_check {
7474
if stake < last_stake {
75-
Console::warning(&format!("Stake decreased - possible slashing detected: From {} to {} tokens",
75+
Console::warning(&format!("Stake decreased - possible slashing detected: From {} to {}",
7676
last_stake / U256::from(10u128.pow(18)),
7777
stake / U256::from(10u128.pow(18))
7878
));
7979
if stake == U256::ZERO {
80-
Console::warning("Stake is 0 - you might have to restart the node to increase your stake (if you still have tokens left)");
80+
Console::warning("Stake is 0 - you might have to restart the node to increase your stake (if you still have balance left)");
8181
}
8282
} else {
83-
Console::info("🔄 Chain Sync - Stake changed", &format!("From {} to {} tokens",
83+
Console::info("🔄 Chain Sync - Stake changed", &format!("From {} to {}",
8484
last_stake / U256::from(10u128.pow(18)),
8585
stake / U256::from(10u128.pow(18))
8686
));
@@ -96,13 +96,13 @@ impl ProviderOperations {
9696
}
9797
};
9898

99-
// Monitor AI token balance
99+
// Monitor balance
100100
match contracts.ai_token.balance_of(provider_address).await {
101101
Ok(balance) => {
102102
if first_check || balance != last_balance {
103-
Console::info("🔄 Chain Sync - AI Token Balance", &format!("{} tokens", balance / U256::from(10u128.pow(18))));
103+
Console::info("🔄 Chain Sync - Balance", &format!("{}", balance / U256::from(10u128.pow(18))));
104104
if !first_check {
105-
Console::info("🔄 Chain Sync - Balance changed", &format!("From {} to {} tokens",
105+
Console::info("🔄 Chain Sync - Balance changed", &format!("From {} to {}",
106106
last_balance / U256::from(10u128.pow(18)),
107107
balance / U256::from(10u128.pow(18))
108108
));
@@ -112,7 +112,7 @@ impl ProviderOperations {
112112
Some(balance)
113113
},
114114
Err(e) => {
115-
error!("Failed to get AI token balance: {}", e);
115+
error!("Failed to get balance: {}", e);
116116
None
117117
}
118118
};
@@ -223,29 +223,29 @@ impl ProviderOperations {
223223

224224
if !provider_exists {
225225
Console::info(
226-
"AI Token Balance",
227-
&format!("{} tokens", balance / U256::from(10u128.pow(18))),
226+
"Balance",
227+
&format!("{}", balance / U256::from(10u128.pow(18))),
228228
);
229229
Console::info(
230230
"ETH Balance",
231231
&format!("{:.6} ETH", { f64::from(eth_balance) / 10f64.powf(18.0) }),
232232
);
233233
if balance < stake {
234234
Console::user_error(&format!(
235-
"Insufficient AI Token balance for stake: {} tokens",
235+
"Insufficient balance for stake: {}",
236236
stake / U256::from(10u128.pow(18))
237237
));
238238
return Err(ProviderError::InsufficientBalance);
239239
}
240240
if !self.prompt_user_confirmation(&format!(
241-
"Do you want to approve staking {} tokens?",
241+
"Do you want to approve staking {}?",
242242
stake / U256::from(10u128.pow(18))
243243
)) {
244244
Console::info("Operation cancelled by user", "Staking approval declined");
245245
return Err(ProviderError::UserCancelled);
246246
}
247247

248-
Console::progress("Approving AI Token for Stake transaction");
248+
Console::progress("Approving for Stake transaction");
249249
self.contracts
250250
.ai_token
251251
.approve(stake)
@@ -274,29 +274,29 @@ impl ProviderOperations {
274274

275275
if !provider_exists {
276276
Console::info(
277-
"AI Token Balance",
278-
&format!("{} tokens", balance / U256::from(10u128.pow(18))),
277+
"Balance",
278+
&format!("{}", balance / U256::from(10u128.pow(18))),
279279
);
280280
Console::info(
281281
"ETH Balance",
282282
&format!("{:.6} ETH", { f64::from(eth_balance) / 10f64.powf(18.0) }),
283283
);
284284
if balance < stake {
285285
Console::user_error(&format!(
286-
"Insufficient AI Token balance for stake: {} tokens",
286+
"Insufficient balance for stake: {}",
287287
stake / U256::from(10u128.pow(18))
288288
));
289289
return Err(ProviderError::InsufficientBalance);
290290
}
291291
if !self.prompt_user_confirmation(&format!(
292-
"Do you want to approve staking {} tokens?",
292+
"Do you want to approve staking {}?",
293293
stake / U256::from(10u128.pow(18))
294294
)) {
295295
Console::info("Operation cancelled by user", "Staking approval declined");
296296
return Err(ProviderError::UserCancelled);
297297
}
298298

299-
Console::progress("Approving AI Token for Stake transaction");
299+
Console::progress("Approving Stake transaction");
300300
self.contracts
301301
.ai_token
302302
.approve(stake)
@@ -323,7 +323,9 @@ impl ProviderOperations {
323323

324324
let provider_exists = provider.provider_address != Address::default();
325325
if !provider_exists {
326-
Console::user_error("Provider could not be registered. Please ensure your token balance is high enough.");
326+
Console::user_error(
327+
"Provider could not be registered. Please ensure your balance is high enough.",
328+
);
327329
return Err(ProviderError::Other);
328330
}
329331

@@ -348,28 +350,28 @@ impl ProviderOperations {
348350
.map_err(|_| ProviderError::Other)?;
349351

350352
Console::info(
351-
"Current AI Token Balance",
352-
&format!("{} tokens", balance / U256::from(10u128.pow(18))),
353+
"Current Balance",
354+
&format!("{}", balance / U256::from(10u128.pow(18))),
353355
);
354356
Console::info(
355357
"Additional stake amount",
356358
&format!("{}", additional_stake / U256::from(10u128.pow(18))),
357359
);
358360

359361
if balance < additional_stake {
360-
Console::user_error("Insufficient token balance for stake increase");
362+
Console::user_error("Insufficient balance for stake increase");
361363
return Err(ProviderError::Other);
362364
}
363365

364366
if !self.prompt_user_confirmation(&format!(
365-
"Do you want to approve staking {} additional tokens?",
367+
"Do you want to approve staking {} additional funds?",
366368
additional_stake / U256::from(10u128.pow(18))
367369
)) {
368370
Console::info("Operation cancelled by user", "Staking approval declined");
369371
return Err(ProviderError::UserCancelled);
370372
}
371373

372-
Console::progress("Approving AI Token for additional stake");
374+
Console::progress("Approving additional stake");
373375
let approve_tx = self
374376
.contracts
375377
.ai_token
@@ -427,7 +429,7 @@ impl fmt::Display for ProviderError {
427429
Self::NotWhitelisted => write!(f, "Provider is not whitelisted"),
428430
Self::UserCancelled => write!(f, "Operation cancelled by user"),
429431
Self::Other => write!(f, "Provider could not be registered"),
430-
Self::InsufficientBalance => write!(f, "Insufficient AI Token balance for stake"),
432+
Self::InsufficientBalance => write!(f, "Insufficient balance for stake"),
431433
}
432434
}
433435
}

0 commit comments

Comments
 (0)