Created
March 22, 2020 07:08
-
-
Save EtDu/3961f423261bcc8a7ff7066fd6c8ec3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reclaimLeaseDeposit() public { | |
Lease storage lease = tenantLease[msg.sender]; | |
require(lease.leaseFullyPaid, "Lease must be fully paid to take back lease deposit"); | |
require(lease.leaseDepositUsd > 0, "Lease deposit has already been removed"); | |
tenantAddress = msg.sender; | |
workingState = State.reclaimingLeaseDeposit; | |
fetchUsdRate(); | |
} | |
function _reclaimLeaseDeposit() internal { | |
workingState = State.idle; | |
Lease storage lease = tenantLease[tenantAddress]; | |
uint leaseDeposit = lease.leaseDepositUsd; | |
lease.leaseDepositUsd = 0; | |
tenantAddress.transfer(leaseDeposit.div(ETHUSD).mul(1e18)); | |
emit leaseDepositReclaimed( | |
tenantAddress, | |
leaseDeposit | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment