{"action":"created","comment":{"url":"https://api.github.com/repos/iov-one/weave/pulls/comments/238598402","pull_request_review_id":181176412,"id":238598402,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODU5ODQwMg==","diff_hunk":"@@ -0,0 +1,69 @@\n+package blockchain\n+\n+import (\n+\t\"github.com/iov-one/weave\"\n+\t\"github.com/pkg/errors\"\n+)\n+\n+// Initializer fulfils the InitStater interface to load data from\n+// the genesis file\n+type Initializer struct {\n+}\n+\n+var _ weave.Initializer = (*Initializer)(nil)\n+\n+// FromGenesis will parse initial tokens information from the genesis and\n+// persist it in the database.\n+func (i *Initializer) FromGenesis(opts weave.Options, db weave.KVStore) error {\n+\tvar nfts struct {\n+\t\tBlockchains []genesisBlockchainToken `json:\"blockchains\"`\n+\t}\n+\tif err := opts.ReadOptions(\"nfts\", &nfts); err != nil {\n+\t\treturn errors.Wrap(err, \"read options\")\n+\t}\n+\treturn setTokens(db, nfts.Blockchains)\n+}\n+\n+type genesisBlockchainToken struct {\n+\tID    string `json:\"id\"`\n+\tOwner string `json:\"owner\"`\n+\tChain struct {\n+\t\tChainID      string `json:\"chain_id\"`\n+\t\tNetworkID    string `json:\"network_id\"`\n+\t\tName         string `json:\"name\"`\n+\t\tEnabled      bool   `json:\"enabled\"`\n+\t\tProduction   bool   `json:\"production\"`\n+\t\tMainTickerID string `json:\"main_ticker_id\"`\n+\t} `json:\"chain\"`\n+\tIOV struct {\n+\t\tCodec       string `json:\"codec\"`\n+\t\tCodecConfig string `json:\"codec_config\"`\n+\t} `json:\"iov\"`\n+}\n+\n+func setTokens(db weave.KVStore, tokens []genesisBlockchainToken) error {\n+\tbucket := NewBucket()\n+\tfor _, t := range tokens {\n+\t\tchain := Chain{\n+\t\t\tChainID:      t.Chain.ChainID,\n+\t\t\tNetworkID:    t.Chain.NetworkID,\n+\t\t\tName:         t.Chain.Name,\n+\t\t\tEnabled:      t.Chain.Enabled,\n+\t\t\tProduction:   t.Chain.Production,\n+\t\t\tMainTickerID: []byte(t.Chain.MainTickerID),\n+\t\t}\n+\n+\t\tiov := IOV{\n+\t\t\tCodec:       t.IOV.Codec,\n+\t\t\tCodecConfig: t.IOV.CodecConfig,\n+\t\t}\n+\t\tobj, err := bucket.Create(db, weave.Address(t.Owner), weave.Address(t.ID), nil, chain, iov)","path":"x/nft/blockchain/init.go","position":60,"original_position":60,"commit_id":"ef75495041824753ed21554aec72c4b44e119f84","original_commit_id":"ef75495041824753ed21554aec72c4b44e119f84","user":{"login":"husio","id":1517,"node_id":"MDQ6VXNlcjE1MTc=","avatar_url":"https://avatars1.githubusercontent.com/u/1517?v=4","gravatar_id":"","url":"https://api.github.com/users/husio","html_url":"https://github.com/husio","followers_url":"https://api.github.com/users/husio/followers","following_url":"https://api.github.com/users/husio/following{/other_user}","gists_url":"https://api.github.com/users/husio/gists{/gist_id}","starred_url":"https://api.github.com/users/husio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/husio/subscriptions","organizations_url":"https://api.github.com/users/husio/orgs","repos_url":"https://api.github.com/users/husio/repos","events_url":"https://api.github.com/users/husio/events{/privacy}","received_events_url":"https://api.github.com/users/husio/received_events","type":"User","site_admin":false},"body":"I cannot find any validation of neither `owner` nor `id`. Given value is not being converted or deserialized, but used as is. It's cast directly to `weave.Address`, which is raw bytes representation of the address.\r\n\r\nIf it makes it easier for you, I could make it accept only hex encoded value. I think that would make it easier to use and allow to ensure the data passed is right. What do you think?","created_at":"2018-12-04T10:09:41Z","updated_at":"2018-12-04T10:09:42Z","html_url":"https://github.com/iov-one/weave/pull/199#discussion_r238598402","pull_request_url":"https://api.github.com/repos/iov-one/weave/pulls/199","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/iov-one/weave/pulls/comments/238598402"},"html":{"href":"https://github.com/iov-one/weave/pull/199#discussion_r238598402"},"pull_request":{"href":"https://api.github.com/repos/iov-one/weave/pulls/199"}},"in_reply_to_id":237865796},"pull_request":{"url":"https://api.github.com/repos/iov-one/weave/pulls/199","id":233892853,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzODkyODUz","html_url":"https://github.com/iov-one/weave/pull/199","diff_url":"https://github.com/iov-one/weave/pull/199.diff","patch_url":"https://github.com/iov-one/weave/pull/199.patch","issue_url":"https://api.github.com/repos/iov-one/weave/issues/199","number":199,"state":"closed","locked":false,"title":"allow to initialize nft blockchain token with genesis","user":{"login":"husio","id":1517,"node_id":"MDQ6VXNlcjE1MTc=","avatar_url":"https://avatars1.githubusercontent.com/u/1517?v=4","gravatar_id":"","url":"https://api.github.com/users/husio","html_url":"https://github.com/husio","followers_url":"https://api.github.com/users/husio/followers","following_url":"https://api.github.com/users/husio/following{/other_user}","gists_url":"https://api.github.com/users/husio/gists{/gist_id}","starred_url":"https://api.github.com/users/husio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/husio/subscriptions","organizations_url":"https://api.github.com/users/husio/orgs","repos_url":"https://api.github.com/users/husio/repos","events_url":"https://api.github.com/users/husio/events{/privacy}","received_events_url":"https://api.github.com/users/husio/received_events","type":"User","site_admin":false},"body":"Provide initializer for nft extension, that will consume blockchain\r\ntoken declaration from a genesis declaration and store it in the\r\ndatabase.\r\n\r\nclose #184","created_at":"2018-11-27T12:28:54Z","updated_at":"2018-12-04T10:09:42Z","closed_at":"2018-11-28T10:37:38Z","merged_at":"2018-11-28T10:37:38Z","merge_commit_sha":"ac2f43f04b87e172ad6695f1e14e9e18d5c526de","assignee":null,"assignees":[],"requested_reviewers":[{"login":"alpe","id":28003,"node_id":"MDQ6VXNlcjI4MDAz","avatar_url":"https://avatars1.githubusercontent.com/u/28003?v=4","gravatar_id":"","url":"https://api.github.com/users/alpe","html_url":"https://github.com/alpe","followers_url":"https://api.github.com/users/alpe/followers","following_url":"https://api.github.com/users/alpe/following{/other_user}","gists_url":"https://api.github.com/users/alpe/gists{/gist_id}","starred_url":"https://api.github.com/users/alpe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alpe/subscriptions","organizations_url":"https://api.github.com/users/alpe/orgs","repos_url":"https://api.github.com/users/alpe/repos","events_url":"https://api.github.com/users/alpe/events{/privacy}","received_events_url":"https://api.github.com/users/alpe/received_events","type":"User","site_admin":false},{"login":"ethanfrey","id":5689864,"node_id":"MDQ6VXNlcjU2ODk4NjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5689864?v=4","gravatar_id":"","url":"https://api.github.com/users/ethanfrey","html_url":"https://github.com/ethanfrey","followers_url":"https://api.github.com/users/ethanfrey/followers","following_url":"https://api.github.com/users/ethanfrey/following{/other_user}","gists_url":"https://api.github.com/users/ethanfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/ethanfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethanfrey/subscriptions","organizations_url":"https://api.github.com/users/ethanfrey/orgs","repos_url":"https://api.github.com/users/ethanfrey/repos","events_url":"https://api.github.com/users/ethanfrey/events{/privacy}","received_events_url":"https://api.github.com/users/ethanfrey/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/iov-one/weave/pulls/199/commits","review_comments_url":"https://api.github.com/repos/iov-one/weave/pulls/199/comments","review_comment_url":"https://api.github.com/repos/iov-one/weave/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iov-one/weave/issues/199/comments","statuses_url":"https://api.github.com/repos/iov-one/weave/statuses/ef75495041824753ed21554aec72c4b44e119f84","head":{"label":"iov-one:blockchain_genesis","ref":"blockchain_genesis","sha":"ef75495041824753ed21554aec72c4b44e119f84","user":{"login":"iov-one","id":34400253,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NDAwMjUz","avatar_url":"https://avatars2.githubusercontent.com/u/34400253?v=4","gravatar_id":"","url":"https://api.github.com/users/iov-one","html_url":"https://github.com/iov-one","followers_url":"https://api.github.com/users/iov-one/followers","following_url":"https://api.github.com/users/iov-one/following{/other_user}","gists_url":"https://api.github.com/users/iov-one/gists{/gist_id}","starred_url":"https://api.github.com/users/iov-one/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iov-one/subscriptions","organizations_url":"https://api.github.com/users/iov-one/orgs","repos_url":"https://api.github.com/users/iov-one/repos","events_url":"https://api.github.com/users/iov-one/events{/privacy}","received_events_url":"https://api.github.com/users/iov-one/received_events","type":"Organization","site_admin":false},"repo":{"id":118366160,"node_id":"MDEwOlJlcG9zaXRvcnkxMTgzNjYxNjA=","name":"weave","full_name":"iov-one/weave","private":false,"owner":{"login":"iov-one","id":34400253,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NDAwMjUz","avatar_url":"https://avatars2.githubusercontent.com/u/34400253?v=4","gravatar_id":"","url":"https://api.github.com/users/iov-one","html_url":"https://github.com/iov-one","followers_url":"https://api.github.com/users/iov-one/followers","following_url":"https://api.github.com/users/iov-one/following{/other_user}","gists_url":"https://api.github.com/users/iov-one/gists{/gist_id}","starred_url":"https://api.github.com/users/iov-one/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iov-one/subscriptions","organizations_url":"https://api.github.com/users/iov-one/orgs","repos_url":"https://api.github.com/users/iov-one/repos","events_url":"https://api.github.com/users/iov-one/events{/privacy}","received_events_url":"https://api.github.com/users/iov-one/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/iov-one/weave","description":"Easy-to-use framework to build Tendermint ABCI applications","fork":false,"url":"https://api.github.com/repos/iov-one/weave","forks_url":"https://api.github.com/repos/iov-one/weave/forks","keys_url":"https://api.github.com/repos/iov-one/weave/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iov-one/weave/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iov-one/weave/teams","hooks_url":"https://api.github.com/repos/iov-one/weave/hooks","issue_events_url":"https://api.github.com/repos/iov-one/weave/issues/events{/number}","events_url":"https://api.github.com/repos/iov-one/weave/events","assignees_url":"https://api.github.com/repos/iov-one/weave/assignees{/user}","branches_url":"https://api.github.com/repos/iov-one/weave/branches{/branch}","tags_url":"https://api.github.com/repos/iov-one/weave/tags","blobs_url":"https://api.github.com/repos/iov-one/weave/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iov-one/weave/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iov-one/weave/git/refs{/sha}","trees_url":"https://api.github.com/repos/iov-one/weave/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iov-one/weave/statuses/{sha}","languages_url":"https://api.github.com/repos/iov-one/weave/languages","stargazers_url":"https://api.github.com/repos/iov-one/weave/stargazers","contributors_url":"https://api.github.com/repos/iov-one/weave/contributors","subscribers_url":"https://api.github.com/repos/iov-one/weave/subscribers","subscription_url":"https://api.github.com/repos/iov-one/weave/subscription","commits_url":"https://api.github.com/repos/iov-one/weave/commits{/sha}","git_commits_url":"https://api.github.com/repos/iov-one/weave/git/commits{/sha}","comments_url":"https://api.github.com/repos/iov-one/weave/comments{/number}","issue_comment_url":"https://api.github.com/repos/iov-one/weave/issues/comments{/number}","contents_url":"https://api.github.com/repos/iov-one/weave/contents/{+path}","compare_url":"https://api.github.com/repos/iov-one/weave/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iov-one/weave/merges","archive_url":"https://api.github.com/repos/iov-one/weave/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iov-one/weave/downloads","issues_url":"https://api.github.com/repos/iov-one/weave/issues{/number}","pulls_url":"https://api.github.com/repos/iov-one/weave/pulls{/number}","milestones_url":"https://api.github.com/repos/iov-one/weave/milestones{/number}","notifications_url":"https://api.github.com/repos/iov-one/weave/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iov-one/weave/labels{/name}","releases_url":"https://api.github.com/repos/iov-one/weave/releases{/id}","deployments_url":"https://api.github.com/repos/iov-one/weave/deployments","created_at":"2018-01-21T19:24:31Z","updated_at":"2018-12-04T01:32:39Z","pushed_at":"2018-12-04T10:08:17Z","git_url":"git://github.com/iov-one/weave.git","ssh_url":"git@github.com:iov-one/weave.git","clone_url":"https://github.com/iov-one/weave.git","svn_url":"https://github.com/iov-one/weave","homepage":null,"size":1809,"stargazers_count":1119,"watchers_count":1119,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":46,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17,"open_issues":46,"watchers":1119,"default_branch":"master"}},"base":{"label":"iov-one:master","ref":"master","sha":"63aa1b2d593807294e000d3a34b15533066739a0","user":{"login":"iov-one","id":34400253,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NDAwMjUz","avatar_url":"https://avatars2.githubusercontent.com/u/34400253?v=4","gravatar_id":"","url":"https://api.github.com/users/iov-one","html_url":"https://github.com/iov-one","followers_url":"https://api.github.com/users/iov-one/followers","following_url":"https://api.github.com/users/iov-one/following{/other_user}","gists_url":"https://api.github.com/users/iov-one/gists{/gist_id}","starred_url":"https://api.github.com/users/iov-one/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iov-one/subscriptions","organizations_url":"https://api.github.com/users/iov-one/orgs","repos_url":"https://api.github.com/users/iov-one/repos","events_url":"https://api.github.com/users/iov-one/events{/privacy}","received_events_url":"https://api.github.com/users/iov-one/received_events","type":"Organization","site_admin":false},"repo":{"id":118366160,"node_id":"MDEwOlJlcG9zaXRvcnkxMTgzNjYxNjA=","name":"weave","full_name":"iov-one/weave","private":false,"owner":{"login":"iov-one","id":34400253,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NDAwMjUz","avatar_url":"https://avatars2.githubusercontent.com/u/34400253?v=4","gravatar_id":"","url":"https://api.github.com/users/iov-one","html_url":"https://github.com/iov-one","followers_url":"https://api.github.com/users/iov-one/followers","following_url":"https://api.github.com/users/iov-one/following{/other_user}","gists_url":"https://api.github.com/users/iov-one/gists{/gist_id}","starred_url":"https://api.github.com/users/iov-one/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iov-one/subscriptions","organizations_url":"https://api.github.com/users/iov-one/orgs","repos_url":"https://api.github.com/users/iov-one/repos","events_url":"https://api.github.com/users/iov-one/events{/privacy}","received_events_url":"https://api.github.com/users/iov-one/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/iov-one/weave","description":"Easy-to-use framework to build Tendermint ABCI applications","fork":false,"url":"https://api.github.com/repos/iov-one/weave","forks_url":"https://api.github.com/repos/iov-one/weave/forks","keys_url":"https://api.github.com/repos/iov-one/weave/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iov-one/weave/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iov-one/weave/teams","hooks_url":"https://api.github.com/repos/iov-one/weave/hooks","issue_events_url":"https://api.github.com/repos/iov-one/weave/issues/events{/number}","events_url":"https://api.github.com/repos/iov-one/weave/events","assignees_url":"https://api.github.com/repos/iov-one/weave/assignees{/user}","branches_url":"https://api.github.com/repos/iov-one/weave/branches{/branch}","tags_url":"https://api.github.com/repos/iov-one/weave/tags","blobs_url":"https://api.github.com/repos/iov-one/weave/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iov-one/weave/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iov-one/weave/git/refs{/sha}","trees_url":"https://api.github.com/repos/iov-one/weave/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iov-one/weave/statuses/{sha}","languages_url":"https://api.github.com/repos/iov-one/weave/languages","stargazers_url":"https://api.github.com/repos/iov-one/weave/stargazers","contributors_url":"https://api.github.com/repos/iov-one/weave/contributors","subscribers_url":"https://api.github.com/repos/iov-one/weave/subscribers","subscription_url":"https://api.github.com/repos/iov-one/weave/subscription","commits_url":"https://api.github.com/repos/iov-one/weave/commits{/sha}","git_commits_url":"https://api.github.com/repos/iov-one/weave/git/commits{/sha}","comments_url":"https://api.github.com/repos/iov-one/weave/comments{/number}","issue_comment_url":"https://api.github.com/repos/iov-one/weave/issues/comments{/number}","contents_url":"https://api.github.com/repos/iov-one/weave/contents/{+path}","compare_url":"https://api.github.com/repos/iov-one/weave/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iov-one/weave/merges","archive_url":"https://api.github.com/repos/iov-one/weave/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iov-one/weave/downloads","issues_url":"https://api.github.com/repos/iov-one/weave/issues{/number}","pulls_url":"https://api.github.com/repos/iov-one/weave/pulls{/number}","milestones_url":"https://api.github.com/repos/iov-one/weave/milestones{/number}","notifications_url":"https://api.github.com/repos/iov-one/weave/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iov-one/weave/labels{/name}","releases_url":"https://api.github.com/repos/iov-one/weave/releases{/id}","deployments_url":"https://api.github.com/repos/iov-one/weave/deployments","created_at":"2018-01-21T19:24:31Z","updated_at":"2018-12-04T01:32:39Z","pushed_at":"2018-12-04T10:08:17Z","git_url":"git://github.com/iov-one/weave.git","ssh_url":"git@github.com:iov-one/weave.git","clone_url":"https://github.com/iov-one/weave.git","svn_url":"https://github.com/iov-one/weave","homepage":null,"size":1809,"stargazers_count":1119,"watchers_count":1119,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":46,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17,"open_issues":46,"watchers":1119,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iov-one/weave/pulls/199"},"html":{"href":"https://github.com/iov-one/weave/pull/199"},"issue":{"href":"https://api.github.com/repos/iov-one/weave/issues/199"},"comments":{"href":"https://api.github.com/repos/iov-one/weave/issues/199/comments"},"review_comments":{"href":"https://api.github.com/repos/iov-one/weave/pulls/199/comments"},"review_comment":{"href":"https://api.github.com/repos/iov-one/weave/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iov-one/weave/pulls/199/commits"},"statuses":{"href":"https://api.github.com/repos/iov-one/weave/statuses/ef75495041824753ed21554aec72c4b44e119f84"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"husio"}}