Skip to content

Commit faae7ef

Browse files
committed
Add support for jsonio-compatible library list in linkBytecode
1 parent 9e6567e commit faae7ef

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

linker.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@ var linkBytecode = function (bytecode, libraries) {
22
// NOTE: for backwards compatibility support old compiler which didn't use file names
33
var librariesComplete = {};
44
for (var libraryName in libraries) {
5-
var parsed = libraryName.match(/^([^:]*):?(.*)$/);
6-
if (parsed) {
7-
librariesComplete[parsed[2]] = libraries[libraryName];
5+
if (typeof libraryName === 'object') {
6+
// API compatible with the standard JSON i/o
7+
for (var lib in libraries[libraryName]) {
8+
librariesComplete[lib] = libraries[libraryName][lib];
9+
librariesComplete[libraryName + ':' + lib] = libraries[libraryName][lib];
10+
}
11+
} else {
12+
// backwards compatible API for early solc-js verisons
13+
var parsed = libraryName.match(/^([^:]*):?(.*)$/);
14+
if (parsed) {
15+
librariesComplete[parsed[2]] = libraries[libraryName];
16+
}
17+
librariesComplete[libraryName] = libraries[libraryName];
818
}
9-
librariesComplete[libraryName] = libraries[libraryName];
1019
}
1120

1221
for (libraryName in librariesComplete) {

0 commit comments

Comments
 (0)