-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinker.js
More file actions
61 lines (55 loc) · 1.88 KB
/
Copy pathlinker.js
File metadata and controls
61 lines (55 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
console.log("Into the linker");
var AssemblyArtifact = require("./artifacts/Assembly.json");
var VotingArtifact = require("./artifacts/Voting.json");
var SignedArtifact = require("./artifacts/Signed.json");
var linker = require("solc/linker");
const path = require("path");
const fs = require("fs");
module.exports = async (
LibVotingAddress,
LibAssemblyAddress,
LibSignAddress,
network
) => {
console.log("Starting the linking process");
const AssemblyFilePath = `/artifacts/${network}/Assembly.json`;
const VotingFilePath = `/artifacts/${network}/Voting.json`;
const SignedFilePath = `/artifacts/${network}/Signed.json`;
var votingLinkedBytecode = linker.linkBytecode(VotingArtifact.bytecode, {
LibVoting: LibVotingAddress,
});
VotingArtifact.bytecode = votingLinkedBytecode;
fs.writeFile(
path.join(__dirname, VotingFilePath),
JSON.stringify(VotingArtifact),
function (err) {
if (err) return console.log(err);
console.log("Writing updated Voting bytecode to " + VotingFilePath);
}
);
var assemblyLinkedBytecode = linker.linkBytecode(AssemblyArtifact.bytecode, {
LibAssembly: LibAssemblyAddress
});
AssemblyArtifact.bytecode = assemblyLinkedBytecode;
fs.writeFile(
path.join(__dirname, AssemblyFilePath),
JSON.stringify(AssemblyArtifact),
function (err) {
if (err) return console.log(err);
console.log("Writing updated Assembly bytecode to " + AssemblyFilePath);
}
);
var signedLinkedBytecode = linker.linkBytecode(SignedArtifact.bytecode, {
LibSign: LibSignAddress,
});
SignedArtifact.bytecode = signedLinkedBytecode;
fs.writeFile(
path.join(__dirname, SignedFilePath),
JSON.stringify(SignedArtifact),
function (err) {
if (err) return console.log(err);
console.log("Writing updated Signed bytecode to " + SignedFilePath);
}
);
console.log("Linking process is finished");
};