{"action":"opened","issue":{"url":"https://api.github.com/repos/AugurProject/augur/issues/303","repository_url":"https://api.github.com/repos/AugurProject/augur","labels_url":"https://api.github.com/repos/AugurProject/augur/issues/303/labels{/name}","comments_url":"https://api.github.com/repos/AugurProject/augur/issues/303/comments","events_url":"https://api.github.com/repos/AugurProject/augur/issues/303/events","html_url":"https://github.com/AugurProject/augur/issues/303","id":134483012,"number":303,"title":"Only use BigNumbers for math","user":{"login":"tinybike","id":2637020,"avatar_url":"https://avatars.githubusercontent.com/u/2637020?v=3","gravatar_id":"","url":"https://api.github.com/users/tinybike","html_url":"https://github.com/tinybike","followers_url":"https://api.github.com/users/tinybike/followers","following_url":"https://api.github.com/users/tinybike/following{/other_user}","gists_url":"https://api.github.com/users/tinybike/gists{/gist_id}","starred_url":"https://api.github.com/users/tinybike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinybike/subscriptions","organizations_url":"https://api.github.com/users/tinybike/orgs","repos_url":"https://api.github.com/users/tinybike/repos","events_url":"https://api.github.com/users/tinybike/events{/privacy}","received_events_url":"https://api.github.com/users/tinybike/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"tinybike","id":2637020,"avatar_url":"https://avatars.githubusercontent.com/u/2637020?v=3","gravatar_id":"","url":"https://api.github.com/users/tinybike","html_url":"https://github.com/tinybike","followers_url":"https://api.github.com/users/tinybike/followers","following_url":"https://api.github.com/users/tinybike/following{/other_user}","gists_url":"https://api.github.com/users/tinybike/gists{/gist_id}","starred_url":"https://api.github.com/users/tinybike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinybike/subscriptions","organizations_url":"https://api.github.com/users/tinybike/orgs","repos_url":"https://api.github.com/users/tinybike/repos","events_url":"https://api.github.com/users/tinybike/events{/privacy}","received_events_url":"https://api.github.com/users/tinybike/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2016-02-18T05:06:25Z","updated_at":"2016-02-18T05:06:25Z","closed_at":null,"body":"The UI presently uses BigNumbers for a variety of things where they are unhelpful or inappropriate (e.g., market IDs are sometimes BigNumbers, sometimes hex strings).  I think we should minimize BigNumber use for the following reasons:\r\n\r\n1. BigNumbers must be serialized to be sent over the wire.  This is inefficient and adds another thing that can break to an already complex scheme.  The middleware should be lean, mean, and not bogged down by unnecessary data transformations.\r\n2. BigNumbers cannot be passed to the Decimal constructor, which we use for involved mathematical calculations.\r\n3. BigNumbers do not by default print in an easily-readable form.  For example, naively passing an array of BigNumbers to console.log will give you a screenful of entries that look like `{ [String: '-5.4917889867110182400182506605075850537547051241964636844222872410989124212006e+76'] s: -1, e: 76, c: [Object] }`.\r\n4. BigNumbers are incompatible with the [clone](https://github.com/pvorb/node-clone) library, which we use for fast object deep-cloning.  Cloned BigNumbers become non-BigNumber objects, with the same field names, which has led to several incredibly hard-to-diagnose bugs.\r\n\r\nInappropriate use of BigNumbers has led to a number of utterly avoidable bugs during the alpha.  To prevent any more unforced errors, I'd like to propose the following rules for BigNumber use:\r\n\r\n- BigNumbers should **only** be used when performing mathematical operations.\r\n- Labels -- addresses, market IDs, event IDs, etc. -- should **always** be stored as hex strings, not BigNumbers.\r\n- Integers should be stored as **JavaScript numbers**, not BigNumbers.\r\n- Decimals should be stored as **stringified numbers**, not BigNumbers.\r\n\r\nPlease post any questions about or objections to these rules here."}}