{"action":"created","comment":{"url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/comments/186639987","pull_request_review_id":118255118,"id":186639987,"diff_hunk":"@@ -38,9 +50,116 @@ contract Gate is ProtocolVersioned {\n      *  Storage\n      */\n     address public workers; //TODO: update type once workers contract and interfaces are added to the repo.\n+\n+    // stake requests\n     mapping(address /*staker */ => StakeRequest) public stakeRequests;\n \n-    function Gate() public { //TODO: complete as necessary\n+    // bounty amount\n+    uint256 private bounty;\n+\n+    // utility token UUID\n+    bytes32 private uuid;\n+\n+    // OpenSTValue contract\n+    OpenSTValue private openSTValue;\n+\n+    /*\n+     *  Public functions\n+     */\n+    constructor(\n+        address _workers,\n+        uint256 _bounty,\n+        bytes32 _uuid,\n+        address _openSTValue)\n+        public\n+        ProtocolVersioned(_openSTValue)\n+    {\n+        require(_workers != address(0));\n+        require(_openSTValue != address(0));\n+        require(_uuid.length != 0);\n+\n+        // Should bounty with 0 amount be allowed ?\n+        //require(_bounty > 0);\n+\n+        workers = _workers;\n+        bounty = _bounty;\n+        uuid = _uuid;\n+        openSTValue = OpenSTValue(_openSTValue);\n+    }\n+\n+    function requestStake(\n+        uint256 _amount,\n+        address _beneficiary)\n+        external\n+        returns ( bool /* success */)\n+    {\n+\n+        require(_amount > 0);\n+        require(_beneficiary != address(0));\n+\n+        // check if the stake request does not exists\n+        require(stakeRequests[msg.sender].beneficiary == address(0));\n+\n+        require(openSTValue.valueToken().allowance(msg.sender, address(this)) >= _amount);\n+        require(openSTValue.valueToken().transferFrom(msg.sender, address(this), _amount));\n+\n+        stakeRequests[msg.sender] = StakeRequest({\n+            amount: _amount,\n+            beneficiary: _beneficiary,\n+            hashLock: 0,\n+            unlockHeight: 0\n+        });\n \n+        emit StakeRequested(msg.sender, _amount, _beneficiary);\n+\n+        return true;\n+    }\n+\n+    function revertStakeRequest()\n+        external\n+        returns (bool /* success */)\n+    {\n+        StakeRequest storage stakeRequest = stakeRequests[msg.sender];\n+\n+        // check if the stake request exists for the msg.sender\n+        require(stakeRequest.beneficiary != address(0));\n+\n+        // check if the stake request was not accepted\n+        require(stakeRequest.unlockHeight == 0);\n+\n+        require(openSTValue.valueToken().transfer(msg.sender, stakeRequest.amount));\n+\n+        delete stakeRequests[msg.sender];\n+\n+        emit StakeRequestReverted(msg.sender, stakeRequest.amount);\n+\n+        return true;\n     }\n+\n+    function rejectStakeRequest(address _staker)\n+        external\n+        returns (bool /* success */)\n+    {\n+        // check if the caller is whitelisted worker\n+        //require(workers.isWorker(msg.sender)); //TODO: revist this to add worker check\n+\n+        StakeRequest storage stakeRequest = stakeRequests[_staker];\n+\n+        // check if the stake request exists\n+        require(stakeRequest.beneficiary != address(0));\n+\n+        // check if the stake request was not accepted\n+        require(stakeRequest.unlockHeight == 0);","path":"contracts/Gate.sol","position":null,"original_position":129,"commit_id":"c78d60dafeb09374580f96853664ec276d792a68","original_commit_id":"a5c7c31828f1bc31fc52d25e5ff952d34872ae44","user":{"login":"deepesh-kn","id":17645038,"avatar_url":"https://avatars0.githubusercontent.com/u/17645038?v=4","gravatar_id":"","url":"https://api.github.com/users/deepesh-kn","html_url":"https://github.com/deepesh-kn","followers_url":"https://api.github.com/users/deepesh-kn/followers","following_url":"https://api.github.com/users/deepesh-kn/following{/other_user}","gists_url":"https://api.github.com/users/deepesh-kn/gists{/gist_id}","starred_url":"https://api.github.com/users/deepesh-kn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepesh-kn/subscriptions","organizations_url":"https://api.github.com/users/deepesh-kn/orgs","repos_url":"https://api.github.com/users/deepesh-kn/repos","events_url":"https://api.github.com/users/deepesh-kn/events{/privacy}","received_events_url":"https://api.github.com/users/deepesh-kn/received_events","type":"User","site_admin":false},"body":"changed to ``` hashLock = 0x0 ``` instead of unlockHeight","created_at":"2018-05-08T07:34:19Z","updated_at":"2018-05-08T07:34:19Z","html_url":"https://github.com/OpenSTFoundation/openst-protocol/pull/127#discussion_r186639987","pull_request_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/comments/186639987"},"html":{"href":"https://github.com/OpenSTFoundation/openst-protocol/pull/127#discussion_r186639987"},"pull_request":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127"}},"in_reply_to_id":186432524},"pull_request":{"url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127","id":185914584,"html_url":"https://github.com/OpenSTFoundation/openst-protocol/pull/127","diff_url":"https://github.com/OpenSTFoundation/openst-protocol/pull/127.diff","patch_url":"https://github.com/OpenSTFoundation/openst-protocol/pull/127.patch","issue_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/127","number":127,"state":"open","locked":false,"title":"Gate contract: requestStake, revertStakeRequest and rejectStakeRequest implementation ","user":{"login":"deepesh-kn","id":17645038,"avatar_url":"https://avatars0.githubusercontent.com/u/17645038?v=4","gravatar_id":"","url":"https://api.github.com/users/deepesh-kn","html_url":"https://github.com/deepesh-kn","followers_url":"https://api.github.com/users/deepesh-kn/followers","following_url":"https://api.github.com/users/deepesh-kn/following{/other_user}","gists_url":"https://api.github.com/users/deepesh-kn/gists{/gist_id}","starred_url":"https://api.github.com/users/deepesh-kn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepesh-kn/subscriptions","organizations_url":"https://api.github.com/users/deepesh-kn/orgs","repos_url":"https://api.github.com/users/deepesh-kn/repos","events_url":"https://api.github.com/users/deepesh-kn/events{/privacy}","received_events_url":"https://api.github.com/users/deepesh-kn/received_events","type":"User","site_admin":false},"body":"This includes: \r\n1. requestStake implementation\r\n2. revertStakeRequest implementation\r\n3. rejectRequest implementation.\r\n\r\n","created_at":"2018-05-04T07:59:44Z","updated_at":"2018-05-08T07:34:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a421a23eeff6f8f8eaed838523227fd1e125dbe8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127/commits","review_comments_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127/comments","review_comment_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/127/comments","statuses_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/statuses/c78d60dafeb09374580f96853664ec276d792a68","head":{"label":"OpenSTFoundation:deepesh/gate_20_23_24","ref":"deepesh/gate_20_23_24","sha":"c78d60dafeb09374580f96853664ec276d792a68","user":{"login":"OpenSTFoundation","id":31754790,"avatar_url":"https://avatars2.githubusercontent.com/u/31754790?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenSTFoundation","html_url":"https://github.com/OpenSTFoundation","followers_url":"https://api.github.com/users/OpenSTFoundation/followers","following_url":"https://api.github.com/users/OpenSTFoundation/following{/other_user}","gists_url":"https://api.github.com/users/OpenSTFoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenSTFoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenSTFoundation/subscriptions","organizations_url":"https://api.github.com/users/OpenSTFoundation/orgs","repos_url":"https://api.github.com/users/OpenSTFoundation/repos","events_url":"https://api.github.com/users/OpenSTFoundation/events{/privacy}","received_events_url":"https://api.github.com/users/OpenSTFoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":108171643,"name":"openst-protocol","full_name":"OpenSTFoundation/openst-protocol","owner":{"login":"OpenSTFoundation","id":31754790,"avatar_url":"https://avatars2.githubusercontent.com/u/31754790?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenSTFoundation","html_url":"https://github.com/OpenSTFoundation","followers_url":"https://api.github.com/users/OpenSTFoundation/followers","following_url":"https://api.github.com/users/OpenSTFoundation/following{/other_user}","gists_url":"https://api.github.com/users/OpenSTFoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenSTFoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenSTFoundation/subscriptions","organizations_url":"https://api.github.com/users/OpenSTFoundation/orgs","repos_url":"https://api.github.com/users/OpenSTFoundation/repos","events_url":"https://api.github.com/users/OpenSTFoundation/events{/privacy}","received_events_url":"https://api.github.com/users/OpenSTFoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenSTFoundation/openst-protocol","description":"OpenST Protocol allows to stake Simple Token on Ethereum to mint branded utility tokens","fork":false,"url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol","forks_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/forks","keys_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/teams","hooks_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/hooks","issue_events_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/events{/number}","events_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/events","assignees_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/assignees{/user}","branches_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/branches{/branch}","tags_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/tags","blobs_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/languages","stargazers_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/stargazers","contributors_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/contributors","subscribers_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/subscribers","subscription_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/subscription","commits_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/contents/{+path}","compare_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/merges","archive_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/downloads","issues_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues{/number}","pulls_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/labels{/name}","releases_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/releases{/id}","deployments_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/deployments","created_at":"2017-10-24T19:09:30Z","updated_at":"2018-05-04T01:51:27Z","pushed_at":"2018-05-08T07:31:46Z","git_url":"git://github.com/OpenSTFoundation/openst-protocol.git","ssh_url":"git@github.com:OpenSTFoundation/openst-protocol.git","clone_url":"https://github.com/OpenSTFoundation/openst-protocol.git","svn_url":"https://github.com/OpenSTFoundation/openst-protocol","homepage":"https://simpletoken.org","size":1723,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":13,"open_issues":12,"watchers":58,"default_branch":"master"}},"base":{"label":"OpenSTFoundation:gate/develop","ref":"gate/develop","sha":"672f77e31eccd43184c1079601c1d9b9c3fb4024","user":{"login":"OpenSTFoundation","id":31754790,"avatar_url":"https://avatars2.githubusercontent.com/u/31754790?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenSTFoundation","html_url":"https://github.com/OpenSTFoundation","followers_url":"https://api.github.com/users/OpenSTFoundation/followers","following_url":"https://api.github.com/users/OpenSTFoundation/following{/other_user}","gists_url":"https://api.github.com/users/OpenSTFoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenSTFoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenSTFoundation/subscriptions","organizations_url":"https://api.github.com/users/OpenSTFoundation/orgs","repos_url":"https://api.github.com/users/OpenSTFoundation/repos","events_url":"https://api.github.com/users/OpenSTFoundation/events{/privacy}","received_events_url":"https://api.github.com/users/OpenSTFoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":108171643,"name":"openst-protocol","full_name":"OpenSTFoundation/openst-protocol","owner":{"login":"OpenSTFoundation","id":31754790,"avatar_url":"https://avatars2.githubusercontent.com/u/31754790?v=4","gravatar_id":"","url":"https://api.github.com/users/OpenSTFoundation","html_url":"https://github.com/OpenSTFoundation","followers_url":"https://api.github.com/users/OpenSTFoundation/followers","following_url":"https://api.github.com/users/OpenSTFoundation/following{/other_user}","gists_url":"https://api.github.com/users/OpenSTFoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenSTFoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenSTFoundation/subscriptions","organizations_url":"https://api.github.com/users/OpenSTFoundation/orgs","repos_url":"https://api.github.com/users/OpenSTFoundation/repos","events_url":"https://api.github.com/users/OpenSTFoundation/events{/privacy}","received_events_url":"https://api.github.com/users/OpenSTFoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenSTFoundation/openst-protocol","description":"OpenST Protocol allows to stake Simple Token on Ethereum to mint branded utility tokens","fork":false,"url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol","forks_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/forks","keys_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/teams","hooks_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/hooks","issue_events_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/events{/number}","events_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/events","assignees_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/assignees{/user}","branches_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/branches{/branch}","tags_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/tags","blobs_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/languages","stargazers_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/stargazers","contributors_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/contributors","subscribers_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/subscribers","subscription_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/subscription","commits_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/contents/{+path}","compare_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/merges","archive_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/downloads","issues_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues{/number}","pulls_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/labels{/name}","releases_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/releases{/id}","deployments_url":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/deployments","created_at":"2017-10-24T19:09:30Z","updated_at":"2018-05-04T01:51:27Z","pushed_at":"2018-05-08T07:31:46Z","git_url":"git://github.com/OpenSTFoundation/openst-protocol.git","ssh_url":"git@github.com:OpenSTFoundation/openst-protocol.git","clone_url":"https://github.com/OpenSTFoundation/openst-protocol.git","svn_url":"https://github.com/OpenSTFoundation/openst-protocol","homepage":"https://simpletoken.org","size":1723,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":13,"open_issues":12,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127"},"html":{"href":"https://github.com/OpenSTFoundation/openst-protocol/pull/127"},"issue":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/127"},"comments":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/issues/127/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/pulls/127/commits"},"statuses":{"href":"https://api.github.com/repos/OpenSTFoundation/openst-protocol/statuses/c78d60dafeb09374580f96853664ec276d792a68"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"deepesh-kn"}}