{"action":"opened","number":2,"pull_request":{"url":"https://api.github.com/repos/urbit/constitution-js/pulls/2","id":216188464,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2MTg4NDY0","html_url":"https://github.com/urbit/constitution-js/pull/2","diff_url":"https://github.com/urbit/constitution-js/pull/2.diff","patch_url":"https://github.com/urbit/constitution-js/pull/2.patch","issue_url":"https://api.github.com/repos/urbit/constitution-js/issues/2","number":2,"state":"open","locked":false,"title":"Refactor 2: Refactor Harder","user":{"login":"jtobin","id":1414434,"node_id":"MDQ6VXNlcjE0MTQ0MzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1414434?v=4","gravatar_id":"","url":"https://api.github.com/users/jtobin","html_url":"https://github.com/jtobin","followers_url":"https://api.github.com/users/jtobin/followers","following_url":"https://api.github.com/users/jtobin/following{/other_user}","gists_url":"https://api.github.com/users/jtobin/gists{/gist_id}","starred_url":"https://api.github.com/users/jtobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtobin/subscriptions","organizations_url":"https://api.github.com/users/jtobin/orgs","repos_url":"https://api.github.com/users/jtobin/repos","events_url":"https://api.github.com/users/jtobin/events{/privacy}","received_events_url":"https://api.github.com/users/jtobin/received_events","type":"User","site_admin":false},"body":"Per @Fang-'s comment on #1, this is (also) a big one.\r\n\r\n(Context: I approached this library as something I inherited, in order to jack it into Bridge.  I obviously haven't tried to be incremental at all here, instead opting to replace one reconstitution with another.)\r\n\r\nThis PR restructures the library again, mostly keeping @Fang-'s broad changes but exposing them via a purely-functional API where state passing is explicit.  Additionally I've changed the internal structure of the library somewhat -- functions in `/internal` modules are intended to maintain a one-to-one mapping with the actual contract APIs (to stay utterly \"close to the contracts\"), while other modules are free to expose their own implementations of these (only notable at present via the type-generic `ships` API -- functions in which can often take ship objects, and avoid hitting the network).\r\n\r\nFor the user, the manual state-passing (typically of a `contracts` object, or occasionally `web3` in the case of transactions) is the biggest change.  Previously we would have:\r\n\r\n```javascript\r\nconstitution.createGalaxy(galaxy, account)\r\n```\r\n\r\nwhereas now we need to pass the contract (actually, all relevant contracts) explicitly as the first argument:\r\n\r\n```javascript\r\ncreateGalaxy(contracts, galaxy, account)\r\n```\r\n\r\nSimilarly, at no point is there the concept of the \"current account\" -- accounts must be passed explicitly, where required.  The `from` field of transactions is derived from the private key used to sign them -- not from the (implicit) current state of web3 objects.\r\n\r\nThis all makes the library easier to modify (there is never the need to assume the existence of a web3 or contract instance in library code, for example), but to the user, it otherwise feels much the same.  Pass in state, get result.  There are also other changes: additional supported contract functions, bug fixes, deriving addresses from HD nodes directly, making more use of `ethereumjs-util` functions, handling private keys as buffers, etc.\r\n\r\nI've begun to use this code in my work on Bridge and find it plays very well with things in that setting.  Someone should let me know if there are any obvious problems with it as they see it being used elsewhere! 😁 ","created_at":"2018-09-18T05:40:47Z","updated_at":"2018-09-18T05:40:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/urbit/constitution-js/pulls/2/commits","review_comments_url":"https://api.github.com/repos/urbit/constitution-js/pulls/2/comments","review_comment_url":"https://api.github.com/repos/urbit/constitution-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urbit/constitution-js/issues/2/comments","statuses_url":"https://api.github.com/repos/urbit/constitution-js/statuses/1f51cc95b08031486007fdead037d3b746b1ba6f","head":{"label":"jtobin:master","ref":"master","sha":"1f51cc95b08031486007fdead037d3b746b1ba6f","user":{"login":"jtobin","id":1414434,"node_id":"MDQ6VXNlcjE0MTQ0MzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1414434?v=4","gravatar_id":"","url":"https://api.github.com/users/jtobin","html_url":"https://github.com/jtobin","followers_url":"https://api.github.com/users/jtobin/followers","following_url":"https://api.github.com/users/jtobin/following{/other_user}","gists_url":"https://api.github.com/users/jtobin/gists{/gist_id}","starred_url":"https://api.github.com/users/jtobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtobin/subscriptions","organizations_url":"https://api.github.com/users/jtobin/orgs","repos_url":"https://api.github.com/users/jtobin/repos","events_url":"https://api.github.com/users/jtobin/events{/privacy}","received_events_url":"https://api.github.com/users/jtobin/received_events","type":"User","site_admin":false},"repo":{"id":147392909,"node_id":"MDEwOlJlcG9zaXRvcnkxNDczOTI5MDk=","name":"constitution-js","full_name":"jtobin/constitution-js","private":false,"owner":{"login":"jtobin","id":1414434,"node_id":"MDQ6VXNlcjE0MTQ0MzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1414434?v=4","gravatar_id":"","url":"https://api.github.com/users/jtobin","html_url":"https://github.com/jtobin","followers_url":"https://api.github.com/users/jtobin/followers","following_url":"https://api.github.com/users/jtobin/following{/other_user}","gists_url":"https://api.github.com/users/jtobin/gists{/gist_id}","starred_url":"https://api.github.com/users/jtobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtobin/subscriptions","organizations_url":"https://api.github.com/users/jtobin/orgs","repos_url":"https://api.github.com/users/jtobin/repos","events_url":"https://api.github.com/users/jtobin/events{/privacy}","received_events_url":"https://api.github.com/users/jtobin/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jtobin/constitution-js","description":"npm module for interacting with the Urbit constitution","fork":true,"url":"https://api.github.com/repos/jtobin/constitution-js","forks_url":"https://api.github.com/repos/jtobin/constitution-js/forks","keys_url":"https://api.github.com/repos/jtobin/constitution-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jtobin/constitution-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jtobin/constitution-js/teams","hooks_url":"https://api.github.com/repos/jtobin/constitution-js/hooks","issue_events_url":"https://api.github.com/repos/jtobin/constitution-js/issues/events{/number}","events_url":"https://api.github.com/repos/jtobin/constitution-js/events","assignees_url":"https://api.github.com/repos/jtobin/constitution-js/assignees{/user}","branches_url":"https://api.github.com/repos/jtobin/constitution-js/branches{/branch}","tags_url":"https://api.github.com/repos/jtobin/constitution-js/tags","blobs_url":"https://api.github.com/repos/jtobin/constitution-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jtobin/constitution-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jtobin/constitution-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/jtobin/constitution-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jtobin/constitution-js/statuses/{sha}","languages_url":"https://api.github.com/repos/jtobin/constitution-js/languages","stargazers_url":"https://api.github.com/repos/jtobin/constitution-js/stargazers","contributors_url":"https://api.github.com/repos/jtobin/constitution-js/contributors","subscribers_url":"https://api.github.com/repos/jtobin/constitution-js/subscribers","subscription_url":"https://api.github.com/repos/jtobin/constitution-js/subscription","commits_url":"https://api.github.com/repos/jtobin/constitution-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/jtobin/constitution-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/jtobin/constitution-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/jtobin/constitution-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/jtobin/constitution-js/contents/{+path}","compare_url":"https://api.github.com/repos/jtobin/constitution-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jtobin/constitution-js/merges","archive_url":"https://api.github.com/repos/jtobin/constitution-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jtobin/constitution-js/downloads","issues_url":"https://api.github.com/repos/jtobin/constitution-js/issues{/number}","pulls_url":"https://api.github.com/repos/jtobin/constitution-js/pulls{/number}","milestones_url":"https://api.github.com/repos/jtobin/constitution-js/milestones{/number}","notifications_url":"https://api.github.com/repos/jtobin/constitution-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jtobin/constitution-js/labels{/name}","releases_url":"https://api.github.com/repos/jtobin/constitution-js/releases{/id}","deployments_url":"https://api.github.com/repos/jtobin/constitution-js/deployments","created_at":"2018-09-04T18:41:43Z","updated_at":"2018-09-18T04:59:05Z","pushed_at":"2018-09-18T04:59:02Z","git_url":"git://github.com/jtobin/constitution-js.git","ssh_url":"git@github.com:jtobin/constitution-js.git","clone_url":"https://github.com/jtobin/constitution-js.git","svn_url":"https://github.com/jtobin/constitution-js","homepage":"","size":2695,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"urbit:master","ref":"master","sha":"74f0742b90b204b8086f575fad1c3a57d1723e22","user":{"login":"urbit","id":5237680,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUyMzc2ODA=","avatar_url":"https://avatars3.githubusercontent.com/u/5237680?v=4","gravatar_id":"","url":"https://api.github.com/users/urbit","html_url":"https://github.com/urbit","followers_url":"https://api.github.com/users/urbit/followers","following_url":"https://api.github.com/users/urbit/following{/other_user}","gists_url":"https://api.github.com/users/urbit/gists{/gist_id}","starred_url":"https://api.github.com/users/urbit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urbit/subscriptions","organizations_url":"https://api.github.com/users/urbit/orgs","repos_url":"https://api.github.com/users/urbit/repos","events_url":"https://api.github.com/users/urbit/events{/privacy}","received_events_url":"https://api.github.com/users/urbit/received_events","type":"Organization","site_admin":false},"repo":{"id":139600375,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk2MDAzNzU=","name":"constitution-js","full_name":"urbit/constitution-js","private":false,"owner":{"login":"urbit","id":5237680,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUyMzc2ODA=","avatar_url":"https://avatars3.githubusercontent.com/u/5237680?v=4","gravatar_id":"","url":"https://api.github.com/users/urbit","html_url":"https://github.com/urbit","followers_url":"https://api.github.com/users/urbit/followers","following_url":"https://api.github.com/users/urbit/following{/other_user}","gists_url":"https://api.github.com/users/urbit/gists{/gist_id}","starred_url":"https://api.github.com/users/urbit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urbit/subscriptions","organizations_url":"https://api.github.com/users/urbit/orgs","repos_url":"https://api.github.com/users/urbit/repos","events_url":"https://api.github.com/users/urbit/events{/privacy}","received_events_url":"https://api.github.com/users/urbit/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/urbit/constitution-js","description":"npm module for interacting with the Urbit constitution","fork":false,"url":"https://api.github.com/repos/urbit/constitution-js","forks_url":"https://api.github.com/repos/urbit/constitution-js/forks","keys_url":"https://api.github.com/repos/urbit/constitution-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urbit/constitution-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urbit/constitution-js/teams","hooks_url":"https://api.github.com/repos/urbit/constitution-js/hooks","issue_events_url":"https://api.github.com/repos/urbit/constitution-js/issues/events{/number}","events_url":"https://api.github.com/repos/urbit/constitution-js/events","assignees_url":"https://api.github.com/repos/urbit/constitution-js/assignees{/user}","branches_url":"https://api.github.com/repos/urbit/constitution-js/branches{/branch}","tags_url":"https://api.github.com/repos/urbit/constitution-js/tags","blobs_url":"https://api.github.com/repos/urbit/constitution-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urbit/constitution-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urbit/constitution-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/urbit/constitution-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urbit/constitution-js/statuses/{sha}","languages_url":"https://api.github.com/repos/urbit/constitution-js/languages","stargazers_url":"https://api.github.com/repos/urbit/constitution-js/stargazers","contributors_url":"https://api.github.com/repos/urbit/constitution-js/contributors","subscribers_url":"https://api.github.com/repos/urbit/constitution-js/subscribers","subscription_url":"https://api.github.com/repos/urbit/constitution-js/subscription","commits_url":"https://api.github.com/repos/urbit/constitution-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/urbit/constitution-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/urbit/constitution-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/urbit/constitution-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/urbit/constitution-js/contents/{+path}","compare_url":"https://api.github.com/repos/urbit/constitution-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urbit/constitution-js/merges","archive_url":"https://api.github.com/repos/urbit/constitution-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urbit/constitution-js/downloads","issues_url":"https://api.github.com/repos/urbit/constitution-js/issues{/number}","pulls_url":"https://api.github.com/repos/urbit/constitution-js/pulls{/number}","milestones_url":"https://api.github.com/repos/urbit/constitution-js/milestones{/number}","notifications_url":"https://api.github.com/repos/urbit/constitution-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urbit/constitution-js/labels{/name}","releases_url":"https://api.github.com/repos/urbit/constitution-js/releases{/id}","deployments_url":"https://api.github.com/repos/urbit/constitution-js/deployments","created_at":"2018-07-03T15:04:24Z","updated_at":"2018-09-02T17:54:10Z","pushed_at":"2018-09-02T17:54:08Z","git_url":"git://github.com/urbit/constitution-js.git","ssh_url":"git@github.com:urbit/constitution-js.git","clone_url":"https://github.com/urbit/constitution-js.git","svn_url":"https://github.com/urbit/constitution-js","homepage":"","size":2821,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urbit/constitution-js/pulls/2"},"html":{"href":"https://github.com/urbit/constitution-js/pull/2"},"issue":{"href":"https://api.github.com/repos/urbit/constitution-js/issues/2"},"comments":{"href":"https://api.github.com/repos/urbit/constitution-js/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/urbit/constitution-js/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/urbit/constitution-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urbit/constitution-js/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/urbit/constitution-js/statuses/1f51cc95b08031486007fdead037d3b746b1ba6f"}},"author_association":"MEMBER","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":26,"additions":4013,"deletions":149626,"changed_files":786}}
{"actor":{"display_login":"jtobin"}}