From 7ee2ced907c96d23e544f6afc17db24265be2cd0 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 17 Dec 2024 14:14:47 +0100 Subject: [PATCH] Fix: don't fail if no rewards --- contracts/btc-finality/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/btc-finality/src/contract.rs b/contracts/btc-finality/src/contract.rs index 16cb443..b15ff58 100644 --- a/contracts/btc-finality/src/contract.rs +++ b/contracts/btc-finality/src/contract.rs @@ -261,7 +261,7 @@ fn handle_end_block( // On an epoch boundary, send rewards to Babylon through the babylon contract let params = PARAMS.load(deps.storage)?; if env.block.height > 0 && env.block.height % params.epoch_length == 0 { - let rewards = TOTAL_REWARDS.load(deps.storage)?; + let rewards = TOTAL_REWARDS.may_load(deps.storage)?.unwrap_or_default(); if rewards.u128() > 0 { let wasm_msg = send_rewards_msg(deps, rewards.u128(), &cfg)?; res = res.add_message(wasm_msg);