From 33c1dd1c6372786176b213270e49efb0bbce03e4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 28 Feb 2018 08:40:49 +0100 Subject: [PATCH] use solc for linking librairy --- remix-lib/src/execution/txFormat.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/remix-lib/src/execution/txFormat.js b/remix-lib/src/execution/txFormat.js index d32e5ad3fc..54426b175c 100644 --- a/remix-lib/src/execution/txFormat.js +++ b/remix-lib/src/execution/txFormat.js @@ -3,6 +3,8 @@ var ethJSABI = require('ethereumjs-abi') var helper = require('./txHelper') var executionContext = require('./execution-context') var asyncJS = require('async') +var solcLinker = require('solc/linker') +var ethJSUtil = require('ethereumjs-util') module.exports = { @@ -226,14 +228,7 @@ module.exports = { }, linkLibrary: function (libraryName, address, bytecodeToLink) { - var libLabel = '__' + libraryName + Array(39 - libraryName.length).join('_') - 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 + return solcLinker.linkBytecode(bytecodeToLink, { [libraryName]: ethJSUtil.addHexPrefix(address) }) }, decodeResponse: function (response, fnabi) {