Skip to content

Commit 4ea94fb

Browse files
committed
Use __$...$__ for placeholder.
1 parent f4068ec commit 4ea94fb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

linker.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ function keccak256 (input) {
44
return keccak('keccak256').update(input).digest();
55
}
66

7+
function libraryHashPlaceholder (input) {
8+
return '$' + keccak256(input).toString('hex').slice(0, 34) + '$';
9+
}
10+
711
var linkBytecode = function (bytecode, libraries) {
812
// NOTE: for backwards compatibility support old compiler which didn't use file names
913
var librariesComplete = {};
@@ -45,7 +49,7 @@ var linkBytecode = function (bytecode, libraries) {
4549
};
4650

4751
replace(libraryName);
48-
replace(keccak256(libraryName).toString('hex'));
52+
replace(libraryHashPlaceholder(libraryName));
4953
}
5054

5155
return bytecode;

test/linker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ tape('Linking', function (t) {
141141
});
142142

143143
t.test('hashed placeholder', function (st) {
144-
var bytecode = '6060604052341561000__cb901161e812ceb78cfe30ca65050c433771__66606060606060';
144+
var bytecode = '6060604052341561000__$cb901161e812ceb78cfe30ca65050c4337$__66606060606060';
145145
bytecode = linker.linkBytecode(bytecode, { 'lib2.sol:L': '0x123456' });
146146
st.equal(bytecode, '6060604052341561000000000000000000000000000000000000012345666606060606060');
147147
st.end();

0 commit comments

Comments
 (0)