From ac1a1936ad1a470bce67e09d6077543f2778515f Mon Sep 17 00:00:00 2001 From: Eason Chai Date: Sat, 24 Oct 2020 14:41:01 +0800 Subject: [PATCH 1/2] start contractWithdraw --- contracts/Decentramall.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contracts/Decentramall.sol b/contracts/Decentramall.sol index 9a464b8..cca129e 100644 --- a/contracts/Decentramall.sol +++ b/contracts/Decentramall.sol @@ -295,4 +295,14 @@ contract Decentramall is ERC721 { admin = newAdmin; emit ChangeAdmin(newAdmin); } + + /** + * @dev Withdraw DAI from contract + * @param toWithdraw address to withdraw to + * @param amount amount to withdraw + **/ + function contractWithdraw(address toWithdraw, uint256 amount) public isAdmin{ + admin = newAdmin; + emit ChangeAdmin(newAdmin); + } } \ No newline at end of file From 1d540488a22240c07e8eb8dc55645204755ba38c Mon Sep 17 00:00:00 2001 From: Eason Chai Date: Sat, 24 Oct 2020 14:45:11 +0800 Subject: [PATCH 2/2] Added withdraw method --- contracts/Decentramall.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/Decentramall.sol b/contracts/Decentramall.sol index cca129e..05e59f2 100644 --- a/contracts/Decentramall.sol +++ b/contracts/Decentramall.sol @@ -56,6 +56,7 @@ contract Decentramall is ERC721 { event CancelRent(address renter, uint256 tokenId); event ChangeDai(address newDai); event ChangeAdmin(address newAdmin); + event ContractWithdraw(address to, uint256 amount); constructor( int256 _currentLimit, @@ -302,7 +303,7 @@ contract Decentramall is ERC721 { * @param amount amount to withdraw **/ function contractWithdraw(address toWithdraw, uint256 amount) public isAdmin{ - admin = newAdmin; - emit ChangeAdmin(newAdmin); + IERC20(dai).transfer(toWithdraw, amount); + emit ContractWithdraw(toWithdraw, amount); } } \ No newline at end of file