Skip to content

Commit 0a920e5

Browse files
committed
handle underflow
1 parent 0943846 commit 0a920e5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

contracts/LostAndFound.cdc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,14 @@ access(all) contract LostAndFound {
555555
let uuid = ticket.uuid
556556
shelf.deposit(ticket: <-ticket, flowTokenRepayment: flowTokenRepayment)
557557

558-
let storageFee = FeeEstimator.storageUsedToFlowAmount(LostAndFound.account.storage.used - storageBefore)
559-
LostAndFound.storageFees[uuid] = storageFee
558+
if LostAndFound.account.storage.used > storageBefore {
559+
let storageFee = FeeEstimator.storageUsedToFlowAmount(LostAndFound.account.storage.used - storageBefore)
560+
LostAndFound.storageFees[uuid] = storageFee
560561

561-
let storagePaymentVault <- self.withdrawTokens(amount: storageFee)
562+
let storagePaymentVault <- self.withdrawTokens(amount: storageFee)
563+
receiver.deposit(from: <-storagePaymentVault)
564+
}
562565

563-
receiver.deposit(from: <-storagePaymentVault)
564566
return uuid
565567
}
566568

0 commit comments

Comments
 (0)