Skip to content

Instantly share code, notes, and snippets.

@apalepu23
Last active September 6, 2018 14:08
Show Gist options
  • Save apalepu23/ff43e741cbe3e204a910d514f95b76ac to your computer and use it in GitHub Desktop.
Save apalepu23/ff43e741cbe3e204a910d514f95b76ac to your computer and use it in GitHub Desktop.
const http = require("http");
const MillionairesProblemFactory = artifacts.require(
"MillionairesProblemFactory.sol"
);
module.exports = function(deployer) {
return (
deployer
.then(() => {
return new Promise((resolve, reject) => {
/*
Obtain the Enigma contract address hosted at this port
upon enigma-docker-network launch
*/
const request = http.get(
"http://localhost:8081",
response => {
if (
response.statusCode < 200 ||
response.statusCode > 299
) {
reject(
new Error(
"Failed to load page, status code: " +
response.statusCode
)
);
}
const body = [];
response.on("data", chunk => body.push(chunk));
response.on("end", () => resolve(body.join("")));
}
);
request.on("error", err => reject(err));
});
})
// Deploy MillionairesProblemFactory with the Enigma contract address
.then(enigmaAddress => {
console.log("Got Enigma Contract address: " + enigmaAddress);
return deployer.deploy(
MillionairesProblemFactory,
enigmaAddress
);
})
.catch(err => console.error(err))
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment