Last active
September 6, 2018 14:08
-
-
Save apalepu23/ff43e741cbe3e204a910d514f95b76ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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