Skip to content

Commit

Permalink
check REMAINING_MIGRATION_COMPLETE_EVENT_SUB_SLOTS
Browse files Browse the repository at this point in the history
  • Loading branch information
luca992 committed Mar 31, 2023
1 parent 88bdf48 commit a4326f7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ pub fn register_to_notify_on_migration_complete(
{
return Err(contract_mode_error);
}
if let Some(remaining_slots) =
REMAINING_MIGRATION_COMPLETE_EVENT_SUB_SLOTS.may_load(deps.storage)?
{
if remaining_slots == 0 {
return Err(StdError::generic_err(
"No migration complete notification slots available",
));
}
REMAINING_MIGRATION_COMPLETE_EVENT_SUB_SLOTS.save(deps.storage, &(remaining_slots - 1))?
}
let validated = deps.api.addr_validate(address.as_str())?;
add_migration_complete_event_subscriber(
deps.storage,
Expand All @@ -69,6 +59,14 @@ pub fn add_migration_complete_event_subscriber(
address: &CanonicalAddr,
code_hash: &String,
) -> StdResult<()> {
if let Some(remaining_slots) = REMAINING_MIGRATION_COMPLETE_EVENT_SUB_SLOTS.may_load(storage)? {
if remaining_slots == 0 {
return Err(StdError::generic_err(
"No migration complete notification slots available",
));
}
REMAINING_MIGRATION_COMPLETE_EVENT_SUB_SLOTS.save(storage, &(remaining_slots - 1))?
}
let mut contracts = MIGRATION_COMPLETE_EVENT_SUBSCRIBERS
.may_load(storage)?
.unwrap_or_default();
Expand Down

0 comments on commit a4326f7

Please sign in to comment.