diff --git a/remix-lib/src/util.js b/remix-lib/src/util.js index 6a21090e63..15a0f7327e 100644 --- a/remix-lib/src/util.js +++ b/remix-lib/src/util.js @@ -175,6 +175,20 @@ module.exports = { return /a165627a7a72305820([0-9a-f]{64})0029$/ }, + /** + * return a regex which extract the swarmhash from the bytecode, from POC 0.3 + * + * @return {RegEx} + */ + swarmHashExtractionPOC3: function () { + return /a265627a7a72315820([0-9a-f]{64})64736f6c6343([0-9a-f]{6})0032$/ + }, + + extractSwarmHash: function (value) { + value = value.replace(this.swarmHashExtraction(), '') + value = value.replace(this.swarmHashExtractionPOC3(), '') + }, + /** * Compare bytecode. return true if the code is equal (handle swarm hash and library references) * @param {String} code1 - the bytecode that is actually deployed (contains resolved library reference and a potentially different swarmhash) @@ -198,8 +212,8 @@ module.exports = { code2 = replaceLibReference(code2, pos) code1 = replaceLibReference(code1, pos) } - code1 = code1.replace(this.swarmHashExtraction(), '') - code2 = code2.replace(this.swarmHashExtraction(), '') + code1 = this.extractSwarmHash(code1) + code2 = this.extractSwarmHash(code2) if (code1 && code2 && code1.indexOf(code2) === 0) { return true }