Skip to content

Commit debab3b

Browse files
authored
handle underflow (#50)
* handle underflow * fix run-tests script
1 parent 0943846 commit debab3b

2 files changed

Lines changed: 7 additions & 5 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

run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -e
44

5-
flow-c1 test --cover --covercode="contracts" --coverprofile="coverage.lcov" tests/*_tests.cdc
5+
flow test --cover --covercode="contracts" --coverprofile="coverage.lcov" tests/*_tests.cdc

0 commit comments

Comments
 (0)