File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ function keccak256 (input) {
4
4
return keccak ( 'keccak256' ) . update ( input ) . digest ( ) ;
5
5
}
6
6
7
+ function libraryHashPlaceholder ( input ) {
8
+ return '$' + keccak256 ( input ) . toString ( 'hex' ) . slice ( 0 , 34 ) + '$' ;
9
+ }
10
+
7
11
var linkBytecode = function ( bytecode , libraries ) {
8
12
// NOTE: for backwards compatibility support old compiler which didn't use file names
9
13
var librariesComplete = { } ;
@@ -45,7 +49,7 @@ var linkBytecode = function (bytecode, libraries) {
45
49
} ;
46
50
47
51
replace ( libraryName ) ;
48
- replace ( keccak256 ( libraryName ) . toString ( 'hex' ) ) ;
52
+ replace ( libraryHashPlaceholder ( libraryName ) ) ;
49
53
}
50
54
51
55
return bytecode ;
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ tape('Linking', function (t) {
141
141
} ) ;
142
142
143
143
t . test ( 'hashed placeholder' , function ( st ) {
144
- var bytecode = '6060604052341561000__cb901161e812ceb78cfe30ca65050c433771__66606060606060 ' ;
144
+ var bytecode = '6060604052341561000__$cb901161e812ceb78cfe30ca65050c4337$__66606060606060 ' ;
145
145
bytecode = linker . linkBytecode ( bytecode , { 'lib2.sol:L' : '0x123456' } ) ;
146
146
st . equal ( bytecode , '6060604052341561000000000000000000000000000000000000012345666606060606060' ) ;
147
147
st . end ( ) ;
You can’t perform that action at this time.
0 commit comments