Skip to content

Commit 2383998

Browse files
committed
Add assertions to the linker
1 parent 0c96f08 commit 2383998

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

linker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
var assert = require('assert');
12
var keccak256 = require('js-sha3').keccak256;
23

34
function libraryHashPlaceholder (input) {
45
return '$' + keccak256(input).slice(0, 34) + '$';
56
}
67

78
var linkBytecode = function (bytecode, libraries) {
9+
assert(typeof bytecode === 'string');
10+
assert(typeof libraries === 'object');
811
// NOTE: for backwards compatibility support old compiler which didn't use file names
912
var librariesComplete = {};
1013
for (var libraryName in libraries) {
@@ -52,6 +55,7 @@ var linkBytecode = function (bytecode, libraries) {
5255
};
5356

5457
var findLinkReferences = function (bytecode) {
58+
assert(typeof bytecode === 'string');
5559
// find 40 bytes in the pattern of __...<36 digits>...__
5660
// e.g. __Lib.sol:L_____________________________
5761
var linkReferences = {};

0 commit comments

Comments
 (0)