From 22718646d22ad716ad132a7fb67289b7e8e9ff8b Mon Sep 17 00:00:00 2001 From: andytudhope Date: Wed, 29 May 2019 11:24:41 +0200 Subject: [PATCH 1/2] Fixes paths, updates contract --- .gitignore | 1 + contracts/Discover.sol | 2 +- embark.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0e97b3b..8a78aba 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ config/development/mnemonic config/livenet/password config/production/password coverage +src/embarkArtifacts embarkArtifacts node_modules package-lock.json diff --git a/contracts/Discover.sol b/contracts/Discover.sol index f14cf1e..43d0b46 100644 --- a/contracts/Discover.sol +++ b/contracts/Discover.sol @@ -42,7 +42,7 @@ contract Discover is ApproveAndCallFallBack, BancorFormula { Data[] public dapps; mapping(bytes32 => uint) public id2index; - mapping(bytes32 => bool) existingIDs; + mapping(bytes32 => bool) public existingIDs; event DAppCreated(bytes32 indexed id, uint newEffectiveBalance); event Upvote(bytes32 indexed id, uint newEffectiveBalance); diff --git a/embark.json b/embark.json index 870cde6..f2ddad9 100644 --- a/embark.json +++ b/embark.json @@ -22,5 +22,5 @@ "optimize-runs": 200 } }, - "generationDir": "embarkArtifacts" + "generationDir": "src/embarkArtifacts" } \ No newline at end of file From 4805add080bbb6c4be33245f1f6505640b01c25b Mon Sep 17 00:00:00 2001 From: andytudhope Date: Wed, 29 May 2019 11:34:38 +0200 Subject: [PATCH 2/2] Adds withdrawMax view function for use in UI --- contracts/Discover.sol | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/contracts/Discover.sol b/contracts/Discover.sol index 43d0b46..c3cbdcb 100644 --- a/contracts/Discover.sol +++ b/contracts/Discover.sol @@ -96,6 +96,17 @@ contract Discover is ApproveAndCallFallBack, BancorFormula { _downvote(msg.sender, _id, _amount); } + /** + * @dev Developers can withdraw an amount not more than what was available of the + SNT they originally staked minus what they have already received back in downvotes. + * @param _id bytes32 unique identifier. + * @return max SNT that can be withdrawn == available SNT for DApp. + */ + function withdrawMax(bytes32 _id) external view returns(uint) { + Data storage d = _getDAppById(_id); + return d.available; + } + /** * @dev Developers can withdraw an amount not more than what was available of the SNT they originally staked minus what they have already received back in downvotes.