{"action":"created","issue":{"url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/issues/60","repository_url":"https://api.github.com/repos/MARKETProtocol/MARKET.js","labels_url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/issues/60/comments","events_url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/issues/60/events","html_url":"https://github.com/MARKETProtocol/MARKET.js/issues/60","id":337615895,"node_id":"MDU6SXNzdWUzMzc2MTU4OTU=","number":60,"title":"[Collateral] Validate deposit / withdraw prior to creating transaction","user":{"login":"pelsasser","id":15096737,"node_id":"MDQ6VXNlcjE1MDk2NzM3","avatar_url":"https://avatars1.githubusercontent.com/u/15096737?v=4","gravatar_id":"","url":"https://api.github.com/users/pelsasser","html_url":"https://github.com/pelsasser","followers_url":"https://api.github.com/users/pelsasser/followers","following_url":"https://api.github.com/users/pelsasser/following{/other_user}","gists_url":"https://api.github.com/users/pelsasser/gists{/gist_id}","starred_url":"https://api.github.com/users/pelsasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pelsasser/subscriptions","organizations_url":"https://api.github.com/users/pelsasser/orgs","repos_url":"https://api.github.com/users/pelsasser/repos","events_url":"https://api.github.com/users/pelsasser/events{/privacy}","received_events_url":"https://api.github.com/users/pelsasser/received_events","type":"User","site_admin":false},"labels":[{"id":918425231,"node_id":"MDU6TGFiZWw5MTg0MjUyMzE=","url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/labels/Bounty%20Attached","name":"Bounty Attached","color":"87edaa","default":false},{"id":918385848,"node_id":"MDU6TGFiZWw5MTgzODU4NDg=","url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/labels/Good%20First%20Issue","name":"Good First Issue","color":"7057ff","default":false},{"id":918385846,"node_id":"MDU6TGFiZWw5MTgzODU4NDY=","url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/labels/Help%20Wanted","name":"Help Wanted","color":"008672","default":false},{"id":918425233,"node_id":"MDU6TGFiZWw5MTg0MjUyMzM=","url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/labels/Priority:%20Medium","name":"Priority: Medium","color":"fbca04","default":false},{"id":918425234,"node_id":"MDU6TGFiZWw5MTg0MjUyMzQ=","url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/labels/Status:%20Available","name":"Status: Available","color":"bfe5bf","default":false},{"id":918425246,"node_id":"MDU6TGFiZWw5MTg0MjUyNDY=","url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/labels/Type:%20Enhancement","name":"Type: Enhancement","color":"84b6eb","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/milestones/1","html_url":"https://github.com/MARKETProtocol/MARKET.js/milestone/1","labels_url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/milestones/1/labels","id":3385889,"node_id":"MDk6TWlsZXN0b25lMzM4NTg4OQ==","number":1,"title":"Alpha Release","description":"","creator":{"login":"pelsasser","id":15096737,"node_id":"MDQ6VXNlcjE1MDk2NzM3","avatar_url":"https://avatars1.githubusercontent.com/u/15096737?v=4","gravatar_id":"","url":"https://api.github.com/users/pelsasser","html_url":"https://github.com/pelsasser","followers_url":"https://api.github.com/users/pelsasser/followers","following_url":"https://api.github.com/users/pelsasser/following{/other_user}","gists_url":"https://api.github.com/users/pelsasser/gists{/gist_id}","starred_url":"https://api.github.com/users/pelsasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pelsasser/subscriptions","organizations_url":"https://api.github.com/users/pelsasser/orgs","repos_url":"https://api.github.com/users/pelsasser/repos","events_url":"https://api.github.com/users/pelsasser/events{/privacy}","received_events_url":"https://api.github.com/users/pelsasser/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":18,"state":"open","created_at":"2018-05-30T00:23:03Z","updated_at":"2018-07-03T21:52:22Z","due_on":"2018-07-01T07:00:00Z","closed_at":null},"comments":1,"created_at":"2018-07-02T18:17:30Z","updated_at":"2018-07-04T01:03:57Z","closed_at":null,"author_association":"MEMBER","body":"## Before you `start work`\r\n\r\nPlease read our contribution [guidelines](https://docs.marketprotocol.io/#contributing) and if there is a bounty involved  please also see [here](https://docs.marketprotocol.io/#gitcoin-and-bounties)\r\n\r\nIf you have ongoing work from other bounties with us where funding has not been released, please do not pick up a new issue.  We would like to involve as many contributors as possible and parallelize the work flow as much as possible.\r\n\r\nPlease make sure to comment in the issue here immediately after starting work so we know your plans for implementation and a timeline.\r\n\r\nPlease also note that in order for work to be accepted, all code must be accompanied by test cases as well.\r\n\r\n### User Story\r\nAs a user, I would hope that all possible validations are done off chain, prior to creating an on chain transaction that is going to cost gas even if it reverts / fails\r\n\r\n### Why Is this Needed?\r\n\r\n*Summary*: Help with validation and error messaging.\r\n\r\n### Description\r\n\r\n[comment]: # (Feature or Bug? i.e Type: Bug)\r\n*Type*: Feature\r\n\r\n### Solution\r\n*Summary*: validate as much as possible before calling `depositCollateralAsync` or `withdrawCollateralAsync`\r\n\r\n\r\n### Definition of Done\r\n#### For `depositCollateralAsync`\r\n- [ ] Ensure caller is enabled for contract by calling mktTokenContract.isUserEnabledForContract() if not return MarketError.UserNotEnabledForContract\r\n- [ ] Ensure caller has sufficient ERC20 token balance, if not return a MarketError.InsufficientBalance error\r\n- [ ] Ensure caller has called ERC20.approve() for sufficient amount to allow for transaction to succeed, if not return a if not return a MarketError.InsufficientApproval error\r\n- [ ] Add tests for all scenarios and ensure proper errors are returned\r\n\r\n#### For `withdrawCollateralAsync`\r\n\r\n- [ ] Ensure user has sufficient balance in the collateral pool to withdraw, if not return MarketError.InsufficientBalance error\r\n- [ ] Add test for this scenario to ensure proper error is returned\r\n\r\n### Additional Information\r\nThe MarketError object has been created, but isn't released in a npm package yet - see here\r\nhttps://github.com/MARKETProtocol/types/blob/develop/types/MarketError.ts\r\n\r\nFor the time being, we can dupliacte the enum in this repo as needed for testing / dev - cc @eswarasai \r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/issues/comments/402332856","html_url":"https://github.com/MARKETProtocol/MARKET.js/issues/60#issuecomment-402332856","issue_url":"https://api.github.com/repos/MARKETProtocol/MARKET.js/issues/60","id":402332856,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjMzMjg1Ng==","user":{"login":"pelsasser","id":15096737,"node_id":"MDQ6VXNlcjE1MDk2NzM3","avatar_url":"https://avatars1.githubusercontent.com/u/15096737?v=4","gravatar_id":"","url":"https://api.github.com/users/pelsasser","html_url":"https://github.com/pelsasser","followers_url":"https://api.github.com/users/pelsasser/followers","following_url":"https://api.github.com/users/pelsasser/following{/other_user}","gists_url":"https://api.github.com/users/pelsasser/gists{/gist_id}","starred_url":"https://api.github.com/users/pelsasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pelsasser/subscriptions","organizations_url":"https://api.github.com/users/pelsasser/orgs","repos_url":"https://api.github.com/users/pelsasser/repos","events_url":"https://api.github.com/users/pelsasser/events{/privacy}","received_events_url":"https://api.github.com/users/pelsasser/received_events","type":"User","site_admin":false},"created_at":"2018-07-04T01:03:57Z","updated_at":"2018-07-04T01:03:57Z","author_association":"MEMBER","body":"@tommycox - awesome.  there is actually a bounty in flight that I posted when I left the office that may need some more gas to get processed with how congested the network is, but will make sure you have dibs.  LMK if I can help you get started in any way. "}}
{"actor":{"display_login":"pelsasser"}}