|
1 | 1 | import assert from 'assert';
|
2 | 2 | import { keccak256 } from 'js-sha3';
|
3 | 3 | import { isNil, isObject } from './common/helpers';
|
| 4 | +import { LibraryAddresses, LinkReferences } from './common/types'; |
4 | 5 |
|
5 | 6 | /**
|
6 | 7 | * Generates a new-style library placeholder from a fully-qualified library name.
|
@@ -57,12 +58,12 @@ function replacePlaceholder (bytecode, label, address) {
|
57 | 58 | * @returns bytecode Hex-encoded bytecode string with placeholders replaced with addresses.
|
58 | 59 | * Note that some placeholders may remain in the bytecode if `libraries` does not provide addresses for all of them.
|
59 | 60 | */
|
60 |
| -function linkBytecode (bytecode, libraries) { |
| 61 | +function linkBytecode (bytecode: string, libraries: LibraryAddresses): string { |
61 | 62 | assert(typeof bytecode === 'string');
|
62 | 63 | assert(typeof libraries === 'object');
|
63 | 64 |
|
64 | 65 | // NOTE: for backwards compatibility support old compiler which didn't use file names
|
65 |
| - const librariesComplete = {}; |
| 66 | + const librariesComplete: { [fullyQualifiedLibraryName: string]: string } = {}; |
66 | 67 |
|
67 | 68 | for (const [fullyQualifiedLibraryName, libraryObjectOrAddress] of Object.entries(libraries)) {
|
68 | 69 | if (isNil(libraryObjectOrAddress)) {
|
@@ -136,12 +137,12 @@ function linkBytecode (bytecode, libraries) {
|
136 | 137 | * offsets and lengths refer to the *binary* (not hex-encoded) bytecode, just
|
137 | 138 | * like in `evm.bytecode.linkReferences`.
|
138 | 139 | */
|
139 |
| -function findLinkReferences (bytecode) { |
| 140 | +function findLinkReferences (bytecode: string): LinkReferences { |
140 | 141 | assert(typeof bytecode === 'string');
|
141 | 142 |
|
142 | 143 | // find 40 bytes in the pattern of __...<36 digits>...__
|
143 | 144 | // e.g. __Lib.sol:L_____________________________
|
144 |
| - const linkReferences = {}; |
| 145 | + const linkReferences: LinkReferences = {}; |
145 | 146 |
|
146 | 147 | let offset = 0;
|
147 | 148 |
|
|
0 commit comments