{"action":"created","comment":{"url":"https://api.github.com/repos/rahafoundation/blockchain/pulls/comments/177665223","pull_request_review_id":107569974,"id":177665223,"diff_hunk":"@@ -0,0 +1,147 @@\n+/**\n+ * Creates the next block in the Raha Blockchain from unapplied operations in Firestore.\n+ *\n+ * Example usage:\n+ * node dist/createBlock.js > newBlock.json\n+ */\n+\n+import { getBlockchain } from './RahaBlockchain';\n+import { operationsCollectionFilters as filters, get, operationsCollection } from './RahaFirestore';\n+import { BLOCKCHAIN_VERSION_NO, Block, StellarMetadata, IpfsBlock, Operation, RequestInvite, Trust } from './schema';\n+\n+/**\n+ * A map of functions that build the data component of Blockchain Operations from\n+ * the data component of Firestore Operations.\n+ */\n+const bcOpDataBuilders = {\n+    'REQUEST_INVITE': (fsOpData): RequestInvite => ({\n+        full_name: fsOpData.full_name,\n+        to_mid: fsOpData.to_mid,\n+        video_url: fsOpData.video_url,\n+    }),\n+    'TRUST': (operationData): Trust => ({\n+        to_mid: operationData.to_mid,\n+    }),\n+}\n+\n+/**\n+ * Filter new operations are invalid within the context of the current blockchain.\n+ * This means:\n+ *   * users cannot perform operations on nonexistent users.\n+ *   * // TODO: there must exist a trust path from a user who joined in a previous block to any user who performs a new TRUST operation\n+ */\n+function filterBcOpsAgainstBlockchain(blockchain, bcOps) {\n+    // Create a set of creator_mid on all REQUEST_INVITE operations in blockchain and bcOps.\n+    // Check if to_mid, from_mid is included in above set.\n+    // TODO;\n+    return bcOps;\n+}\n+\n+/**\n+ * TODO.\n+ */\n+function validateBcOp(bcOp) {\n+    return true;\n+}\n+\n+/**\n+ * Build a Blockchain Operation from a Firestore Operation. Returns undefined if the operation is invalid.\n+ */\n+function buildBcOpFromFsOp(\n+        fsOp, index: number): Operation|void {\n+    const opCode = fsOp.get('op_code');\n+    const operationDataBuilder = bcOpDataBuilders[opCode];","path":"src/createBlock.ts","position":53,"original_position":53,"commit_id":"246148a6763dedc1a196dcb71c67c6e962547b3f","original_commit_id":"246148a6763dedc1a196dcb71c67c6e962547b3f","user":{"login":"osdiab","id":1890926,"avatar_url":"https://avatars0.githubusercontent.com/u/1890926?v=4","gravatar_id":"","url":"https://api.github.com/users/osdiab","html_url":"https://github.com/osdiab","followers_url":"https://api.github.com/users/osdiab/followers","following_url":"https://api.github.com/users/osdiab/following{/other_user}","gists_url":"https://api.github.com/users/osdiab/gists{/gist_id}","starred_url":"https://api.github.com/users/osdiab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osdiab/subscriptions","organizations_url":"https://api.github.com/users/osdiab/orgs","repos_url":"https://api.github.com/users/osdiab/repos","events_url":"https://api.github.com/users/osdiab/events{/privacy}","received_events_url":"https://api.github.com/users/osdiab/received_events","type":"User","site_admin":false},"body":"Can also just do it explicitly with \r\n\r\n```\r\nif (!(opCode in bcOpDataBuilders)) {\r\n  return undefined;\r\n}\r\n```\r\n\r\nand then `operationDataBuilder` will automatically be inferred to have the proper type","created_at":"2018-03-28T07:55:00Z","updated_at":"2018-03-28T08:01:52Z","html_url":"https://github.com/rahafoundation/blockchain/pull/6#discussion_r177665223","pull_request_url":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/rahafoundation/blockchain/pulls/comments/177665223"},"html":{"href":"https://github.com/rahafoundation/blockchain/pull/6#discussion_r177665223"},"pull_request":{"href":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6","id":177922342,"html_url":"https://github.com/rahafoundation/blockchain/pull/6","diff_url":"https://github.com/rahafoundation/blockchain/pull/6.diff","patch_url":"https://github.com/rahafoundation/blockchain/pull/6.patch","issue_url":"https://api.github.com/repos/rahafoundation/blockchain/issues/6","number":6,"state":"open","locked":false,"title":"Script to output the contents of a new block in the blockchain.","user":{"login":"rahulgi","id":2237985,"avatar_url":"https://avatars1.githubusercontent.com/u/2237985?v=4","gravatar_id":"","url":"https://api.github.com/users/rahulgi","html_url":"https://github.com/rahulgi","followers_url":"https://api.github.com/users/rahulgi/followers","following_url":"https://api.github.com/users/rahulgi/following{/other_user}","gists_url":"https://api.github.com/users/rahulgi/gists{/gist_id}","starred_url":"https://api.github.com/users/rahulgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahulgi/subscriptions","organizations_url":"https://api.github.com/users/rahulgi/orgs","repos_url":"https://api.github.com/users/rahulgi/repos","events_url":"https://api.github.com/users/rahulgi/events{/privacy}","received_events_url":"https://api.github.com/users/rahulgi/received_events","type":"User","site_admin":false},"body":"*depends on PR #5. Land that first.*","created_at":"2018-03-28T03:43:58Z","updated_at":"2018-03-28T08:01:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c17ba7dcdbf234d21abd229aea71532a03a54560","assignee":null,"assignees":[],"requested_reviewers":[{"login":"tinaroh","id":1296389,"avatar_url":"https://avatars3.githubusercontent.com/u/1296389?v=4","gravatar_id":"","url":"https://api.github.com/users/tinaroh","html_url":"https://github.com/tinaroh","followers_url":"https://api.github.com/users/tinaroh/followers","following_url":"https://api.github.com/users/tinaroh/following{/other_user}","gists_url":"https://api.github.com/users/tinaroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tinaroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinaroh/subscriptions","organizations_url":"https://api.github.com/users/tinaroh/orgs","repos_url":"https://api.github.com/users/tinaroh/repos","events_url":"https://api.github.com/users/tinaroh/events{/privacy}","received_events_url":"https://api.github.com/users/tinaroh/received_events","type":"User","site_admin":false},{"login":"markulrich","id":6357579,"avatar_url":"https://avatars3.githubusercontent.com/u/6357579?v=4","gravatar_id":"","url":"https://api.github.com/users/markulrich","html_url":"https://github.com/markulrich","followers_url":"https://api.github.com/users/markulrich/followers","following_url":"https://api.github.com/users/markulrich/following{/other_user}","gists_url":"https://api.github.com/users/markulrich/gists{/gist_id}","starred_url":"https://api.github.com/users/markulrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markulrich/subscriptions","organizations_url":"https://api.github.com/users/markulrich/orgs","repos_url":"https://api.github.com/users/markulrich/repos","events_url":"https://api.github.com/users/markulrich/events{/privacy}","received_events_url":"https://api.github.com/users/markulrich/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6/commits","review_comments_url":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6/comments","review_comment_url":"https://api.github.com/repos/rahafoundation/blockchain/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rahafoundation/blockchain/issues/6/comments","statuses_url":"https://api.github.com/repos/rahafoundation/blockchain/statuses/246148a6763dedc1a196dcb71c67c6e962547b3f","head":{"label":"rahafoundation:rg-create-block","ref":"rg-create-block","sha":"246148a6763dedc1a196dcb71c67c6e962547b3f","user":{"login":"rahafoundation","id":35645362,"avatar_url":"https://avatars1.githubusercontent.com/u/35645362?v=4","gravatar_id":"","url":"https://api.github.com/users/rahafoundation","html_url":"https://github.com/rahafoundation","followers_url":"https://api.github.com/users/rahafoundation/followers","following_url":"https://api.github.com/users/rahafoundation/following{/other_user}","gists_url":"https://api.github.com/users/rahafoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/rahafoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahafoundation/subscriptions","organizations_url":"https://api.github.com/users/rahafoundation/orgs","repos_url":"https://api.github.com/users/rahafoundation/repos","events_url":"https://api.github.com/users/rahafoundation/events{/privacy}","received_events_url":"https://api.github.com/users/rahafoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":126923063,"name":"blockchain","full_name":"rahafoundation/blockchain","owner":{"login":"rahafoundation","id":35645362,"avatar_url":"https://avatars1.githubusercontent.com/u/35645362?v=4","gravatar_id":"","url":"https://api.github.com/users/rahafoundation","html_url":"https://github.com/rahafoundation","followers_url":"https://api.github.com/users/rahafoundation/followers","following_url":"https://api.github.com/users/rahafoundation/following{/other_user}","gists_url":"https://api.github.com/users/rahafoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/rahafoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahafoundation/subscriptions","organizations_url":"https://api.github.com/users/rahafoundation/orgs","repos_url":"https://api.github.com/users/rahafoundation/repos","events_url":"https://api.github.com/users/rahafoundation/events{/privacy}","received_events_url":"https://api.github.com/users/rahafoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rahafoundation/blockchain","description":"Modules for interacting with the Raha blockchain.","fork":false,"url":"https://api.github.com/repos/rahafoundation/blockchain","forks_url":"https://api.github.com/repos/rahafoundation/blockchain/forks","keys_url":"https://api.github.com/repos/rahafoundation/blockchain/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rahafoundation/blockchain/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rahafoundation/blockchain/teams","hooks_url":"https://api.github.com/repos/rahafoundation/blockchain/hooks","issue_events_url":"https://api.github.com/repos/rahafoundation/blockchain/issues/events{/number}","events_url":"https://api.github.com/repos/rahafoundation/blockchain/events","assignees_url":"https://api.github.com/repos/rahafoundation/blockchain/assignees{/user}","branches_url":"https://api.github.com/repos/rahafoundation/blockchain/branches{/branch}","tags_url":"https://api.github.com/repos/rahafoundation/blockchain/tags","blobs_url":"https://api.github.com/repos/rahafoundation/blockchain/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rahafoundation/blockchain/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rahafoundation/blockchain/git/refs{/sha}","trees_url":"https://api.github.com/repos/rahafoundation/blockchain/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rahafoundation/blockchain/statuses/{sha}","languages_url":"https://api.github.com/repos/rahafoundation/blockchain/languages","stargazers_url":"https://api.github.com/repos/rahafoundation/blockchain/stargazers","contributors_url":"https://api.github.com/repos/rahafoundation/blockchain/contributors","subscribers_url":"https://api.github.com/repos/rahafoundation/blockchain/subscribers","subscription_url":"https://api.github.com/repos/rahafoundation/blockchain/subscription","commits_url":"https://api.github.com/repos/rahafoundation/blockchain/commits{/sha}","git_commits_url":"https://api.github.com/repos/rahafoundation/blockchain/git/commits{/sha}","comments_url":"https://api.github.com/repos/rahafoundation/blockchain/comments{/number}","issue_comment_url":"https://api.github.com/repos/rahafoundation/blockchain/issues/comments{/number}","contents_url":"https://api.github.com/repos/rahafoundation/blockchain/contents/{+path}","compare_url":"https://api.github.com/repos/rahafoundation/blockchain/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rahafoundation/blockchain/merges","archive_url":"https://api.github.com/repos/rahafoundation/blockchain/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rahafoundation/blockchain/downloads","issues_url":"https://api.github.com/repos/rahafoundation/blockchain/issues{/number}","pulls_url":"https://api.github.com/repos/rahafoundation/blockchain/pulls{/number}","milestones_url":"https://api.github.com/repos/rahafoundation/blockchain/milestones{/number}","notifications_url":"https://api.github.com/repos/rahafoundation/blockchain/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rahafoundation/blockchain/labels{/name}","releases_url":"https://api.github.com/repos/rahafoundation/blockchain/releases{/id}","deployments_url":"https://api.github.com/repos/rahafoundation/blockchain/deployments","created_at":"2018-03-27T03:23:42Z","updated_at":"2018-03-28T04:10:59Z","pushed_at":"2018-03-28T05:47:28Z","git_url":"git://github.com/rahafoundation/blockchain.git","ssh_url":"git@github.com:rahafoundation/blockchain.git","clone_url":"https://github.com/rahafoundation/blockchain.git","svn_url":"https://github.com/rahafoundation/blockchain","homepage":null,"size":76,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"rahafoundation:master","ref":"master","sha":"3059fce4ce760d93c4b231293a901457849b4e3b","user":{"login":"rahafoundation","id":35645362,"avatar_url":"https://avatars1.githubusercontent.com/u/35645362?v=4","gravatar_id":"","url":"https://api.github.com/users/rahafoundation","html_url":"https://github.com/rahafoundation","followers_url":"https://api.github.com/users/rahafoundation/followers","following_url":"https://api.github.com/users/rahafoundation/following{/other_user}","gists_url":"https://api.github.com/users/rahafoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/rahafoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahafoundation/subscriptions","organizations_url":"https://api.github.com/users/rahafoundation/orgs","repos_url":"https://api.github.com/users/rahafoundation/repos","events_url":"https://api.github.com/users/rahafoundation/events{/privacy}","received_events_url":"https://api.github.com/users/rahafoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":126923063,"name":"blockchain","full_name":"rahafoundation/blockchain","owner":{"login":"rahafoundation","id":35645362,"avatar_url":"https://avatars1.githubusercontent.com/u/35645362?v=4","gravatar_id":"","url":"https://api.github.com/users/rahafoundation","html_url":"https://github.com/rahafoundation","followers_url":"https://api.github.com/users/rahafoundation/followers","following_url":"https://api.github.com/users/rahafoundation/following{/other_user}","gists_url":"https://api.github.com/users/rahafoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/rahafoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahafoundation/subscriptions","organizations_url":"https://api.github.com/users/rahafoundation/orgs","repos_url":"https://api.github.com/users/rahafoundation/repos","events_url":"https://api.github.com/users/rahafoundation/events{/privacy}","received_events_url":"https://api.github.com/users/rahafoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rahafoundation/blockchain","description":"Modules for interacting with the Raha blockchain.","fork":false,"url":"https://api.github.com/repos/rahafoundation/blockchain","forks_url":"https://api.github.com/repos/rahafoundation/blockchain/forks","keys_url":"https://api.github.com/repos/rahafoundation/blockchain/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rahafoundation/blockchain/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rahafoundation/blockchain/teams","hooks_url":"https://api.github.com/repos/rahafoundation/blockchain/hooks","issue_events_url":"https://api.github.com/repos/rahafoundation/blockchain/issues/events{/number}","events_url":"https://api.github.com/repos/rahafoundation/blockchain/events","assignees_url":"https://api.github.com/repos/rahafoundation/blockchain/assignees{/user}","branches_url":"https://api.github.com/repos/rahafoundation/blockchain/branches{/branch}","tags_url":"https://api.github.com/repos/rahafoundation/blockchain/tags","blobs_url":"https://api.github.com/repos/rahafoundation/blockchain/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rahafoundation/blockchain/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rahafoundation/blockchain/git/refs{/sha}","trees_url":"https://api.github.com/repos/rahafoundation/blockchain/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rahafoundation/blockchain/statuses/{sha}","languages_url":"https://api.github.com/repos/rahafoundation/blockchain/languages","stargazers_url":"https://api.github.com/repos/rahafoundation/blockchain/stargazers","contributors_url":"https://api.github.com/repos/rahafoundation/blockchain/contributors","subscribers_url":"https://api.github.com/repos/rahafoundation/blockchain/subscribers","subscription_url":"https://api.github.com/repos/rahafoundation/blockchain/subscription","commits_url":"https://api.github.com/repos/rahafoundation/blockchain/commits{/sha}","git_commits_url":"https://api.github.com/repos/rahafoundation/blockchain/git/commits{/sha}","comments_url":"https://api.github.com/repos/rahafoundation/blockchain/comments{/number}","issue_comment_url":"https://api.github.com/repos/rahafoundation/blockchain/issues/comments{/number}","contents_url":"https://api.github.com/repos/rahafoundation/blockchain/contents/{+path}","compare_url":"https://api.github.com/repos/rahafoundation/blockchain/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rahafoundation/blockchain/merges","archive_url":"https://api.github.com/repos/rahafoundation/blockchain/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rahafoundation/blockchain/downloads","issues_url":"https://api.github.com/repos/rahafoundation/blockchain/issues{/number}","pulls_url":"https://api.github.com/repos/rahafoundation/blockchain/pulls{/number}","milestones_url":"https://api.github.com/repos/rahafoundation/blockchain/milestones{/number}","notifications_url":"https://api.github.com/repos/rahafoundation/blockchain/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rahafoundation/blockchain/labels{/name}","releases_url":"https://api.github.com/repos/rahafoundation/blockchain/releases{/id}","deployments_url":"https://api.github.com/repos/rahafoundation/blockchain/deployments","created_at":"2018-03-27T03:23:42Z","updated_at":"2018-03-28T04:10:59Z","pushed_at":"2018-03-28T05:47:28Z","git_url":"git://github.com/rahafoundation/blockchain.git","ssh_url":"git@github.com:rahafoundation/blockchain.git","clone_url":"https://github.com/rahafoundation/blockchain.git","svn_url":"https://github.com/rahafoundation/blockchain","homepage":null,"size":76,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6"},"html":{"href":"https://github.com/rahafoundation/blockchain/pull/6"},"issue":{"href":"https://api.github.com/repos/rahafoundation/blockchain/issues/6"},"comments":{"href":"https://api.github.com/repos/rahafoundation/blockchain/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/rahafoundation/blockchain/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rahafoundation/blockchain/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/rahafoundation/blockchain/statuses/246148a6763dedc1a196dcb71c67c6e962547b3f"}},"author_association":"OWNER"}}
{"actor":{"display_login":"osdiab"}}