{"action":"created","issue":{"url":"https://api.github.com/repos/zeppelinos/zos/issues/751","repository_url":"https://api.github.com/repos/zeppelinos/zos","labels_url":"https://api.github.com/repos/zeppelinos/zos/issues/751/labels{/name}","comments_url":"https://api.github.com/repos/zeppelinos/zos/issues/751/comments","events_url":"https://api.github.com/repos/zeppelinos/zos/issues/751/events","html_url":"https://github.com/zeppelinos/zos/issues/751","id":415837641,"node_id":"MDU6SXNzdWU0MTU4Mzc2NDE=","number":751,"title":"Error when linking more than a single solidity library to the same contract","user":{"login":"spalladino","id":429604,"node_id":"MDQ6VXNlcjQyOTYwNA==","avatar_url":"https://avatars2.githubusercontent.com/u/429604?v=4","gravatar_id":"","url":"https://api.github.com/users/spalladino","html_url":"https://github.com/spalladino","followers_url":"https://api.github.com/users/spalladino/followers","following_url":"https://api.github.com/users/spalladino/following{/other_user}","gists_url":"https://api.github.com/users/spalladino/gists{/gist_id}","starred_url":"https://api.github.com/users/spalladino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spalladino/subscriptions","organizations_url":"https://api.github.com/users/spalladino/orgs","repos_url":"https://api.github.com/users/spalladino/repos","events_url":"https://api.github.com/users/spalladino/events{/privacy}","received_events_url":"https://api.github.com/users/spalladino/received_events","type":"User","site_admin":false},"labels":[{"id":1016457902,"node_id":"MDU6TGFiZWwxMDE2NDU3OTAy","url":"https://api.github.com/repos/zeppelinos/zos/labels/kind:bug","name":"kind:bug","color":"ee0701","default":false},{"id":1154193965,"node_id":"MDU6TGFiZWwxMTU0MTkzOTY1","url":"https://api.github.com/repos/zeppelinos/zos/labels/priority:high","name":"priority:high","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/zeppelinos/zos/milestones/6","html_url":"https://github.com/zeppelinos/zos/milestone/6","labels_url":"https://api.github.com/repos/zeppelinos/zos/milestones/6/labels","id":4053930,"node_id":"MDk6TWlsZXN0b25lNDA1MzkzMA==","number":6,"title":"v2.3.0","description":"","creator":{"login":"facuspagnuolo","id":6967192,"node_id":"MDQ6VXNlcjY5NjcxOTI=","avatar_url":"https://avatars1.githubusercontent.com/u/6967192?v=4","gravatar_id":"","url":"https://api.github.com/users/facuspagnuolo","html_url":"https://github.com/facuspagnuolo","followers_url":"https://api.github.com/users/facuspagnuolo/followers","following_url":"https://api.github.com/users/facuspagnuolo/following{/other_user}","gists_url":"https://api.github.com/users/facuspagnuolo/gists{/gist_id}","starred_url":"https://api.github.com/users/facuspagnuolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facuspagnuolo/subscriptions","organizations_url":"https://api.github.com/users/facuspagnuolo/orgs","repos_url":"https://api.github.com/users/facuspagnuolo/repos","events_url":"https://api.github.com/users/facuspagnuolo/events{/privacy}","received_events_url":"https://api.github.com/users/facuspagnuolo/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":6,"state":"open","created_at":"2019-02-13T13:05:40Z","updated_at":"2019-03-01T20:53:51Z","due_on":"2019-03-29T07:00:00Z","closed_at":null},"comments":1,"created_at":"2019-02-28T21:44:51Z","updated_at":"2019-03-05T01:48:36Z","closed_at":null,"author_association":"MEMBER","body":"Given a contract that uses more than a single _external_ solidity library (ie a library with non-internal functions, that needs to be linked), `zos push` fails to deploy them since linking fails.\r\n\r\nThe reported error is the following, since `zos` does not check that all pending links have been replaced before deploying (see #250):\r\n```\r\n[Error] Error: Contract deployment failed with error: The data field must be HEX encoded data.\r\n```\r\n\r\nThis happens because `Contract#link` in `zos-lib` iterates over the set of libraries to replace, but sets the linkedbytecode to the result of replacing the library by its address _on the original bytecode_, and not on the linkedbytecode being accumulated. This causes only the last library to be actually linked.\r\n\r\n```typescript\r\n  instance.link = function(libraries: { [libAlias: string]: string }): void {\r\n    Object.keys(libraries).forEach((name: string) => {\r\n      const address = libraries[name].replace(/^0x/, '');\r\n      const regex = new RegExp(`__${name}_+`, 'g');\r\n      instance.schema.linkedBytecode = instance.schema.bytecode.replace(regex, address); // Should be replacing over linkedBytecode, initialized to bytecode!\r\n      instance.schema.linkedDeployedBytecode = instance.schema.deployedBytecode.replace(regex, address); // Same here\r\n    });\r\n  };\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/zeppelinos/zos/issues/comments/469501534","html_url":"https://github.com/zeppelinos/zos/issues/751#issuecomment-469501534","issue_url":"https://api.github.com/repos/zeppelinos/zos/issues/751","id":469501534,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2OTUwMTUzNA==","user":{"login":"siromivel","id":7109332,"node_id":"MDQ6VXNlcjcxMDkzMzI=","avatar_url":"https://avatars2.githubusercontent.com/u/7109332?v=4","gravatar_id":"","url":"https://api.github.com/users/siromivel","html_url":"https://github.com/siromivel","followers_url":"https://api.github.com/users/siromivel/followers","following_url":"https://api.github.com/users/siromivel/following{/other_user}","gists_url":"https://api.github.com/users/siromivel/gists{/gist_id}","starred_url":"https://api.github.com/users/siromivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siromivel/subscriptions","organizations_url":"https://api.github.com/users/siromivel/orgs","repos_url":"https://api.github.com/users/siromivel/repos","events_url":"https://api.github.com/users/siromivel/events{/privacy}","received_events_url":"https://api.github.com/users/siromivel/received_events","type":"User","site_admin":false},"created_at":"2019-03-05T01:48:36Z","updated_at":"2019-03-05T01:48:36Z","author_association":"NONE","body":"While the fix here seems trivial I'm having a hard time writing a regression test - do these libraries need to be completely external to the project(e.g., other zos packages)? "}}
{"actor":{"display_login":"siromivel"}}