Unverified Commit c5722689 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #710 from ethereum/yann300-patch-1

use solc for linking library
parents 00629a0b 33c1dd1c
...@@ -3,6 +3,8 @@ var ethJSABI = require('ethereumjs-abi') ...@@ -3,6 +3,8 @@ var ethJSABI = require('ethereumjs-abi')
var helper = require('./txHelper') var helper = require('./txHelper')
var executionContext = require('./execution-context') var executionContext = require('./execution-context')
var asyncJS = require('async') var asyncJS = require('async')
var solcLinker = require('solc/linker')
var ethJSUtil = require('ethereumjs-util')
module.exports = { module.exports = {
...@@ -226,14 +228,7 @@ module.exports = { ...@@ -226,14 +228,7 @@ module.exports = {
}, },
linkLibrary: function (libraryName, address, bytecodeToLink) { linkLibrary: function (libraryName, address, bytecodeToLink) {
var libLabel = '__' + libraryName + Array(39 - libraryName.length).join('_') return solcLinker.linkBytecode(bytecodeToLink, { [libraryName]: ethJSUtil.addHexPrefix(address) })
if (bytecodeToLink.indexOf(libLabel) === -1) return bytecodeToLink
address = Array(40 - address.length + 1).join('0') + address
while (bytecodeToLink.indexOf(libLabel) >= 0) {
bytecodeToLink = bytecodeToLink.replace(libLabel, address)
}
return bytecodeToLink
}, },
decodeResponse: function (response, fnabi) { decodeResponse: function (response, fnabi) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment