-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
642fe63
commit dc93a1a
Showing
21 changed files
with
843 additions
and
239 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var jsonfile = require('jsonfile'); | ||
|
||
module.exports = { | ||
get: function() { | ||
return jsonfile.readFileSync(process.cwd() + '/addressbook.json'); | ||
}, | ||
add: function(contracts) { | ||
if(contracts[Object.keys(contracts)[0]].currentProvider.ganache === undefined) { | ||
const assign = require('assign-deep'); | ||
for (var contract in contracts) { | ||
var host = contracts[contract].currentProvider.host | ||
var network = /(?<=https:\/\/).*?(?=.infura.io)/.exec(host) | ||
const file = process.cwd() + '/addressbook.json'; | ||
var book = jsonfile.readFileSync(file) | ||
if(network === null){ | ||
var obj = { | ||
[host]:{ | ||
[contract]:contracts[contract].options.address | ||
} | ||
} | ||
}else { | ||
var obj = { | ||
[network]:{ | ||
[contract]:contracts[contract].options.address | ||
} | ||
} | ||
var result = assign(book, obj) } | ||
jsonfile.writeFileSync(file, result, { spaces:2 }) | ||
} | ||
} | ||
}, | ||
checkNetwork: function(network) { | ||
var book = require(process.cwd()+'/addressbook.json'); | ||
if(typeof book[network] === "undefined") { | ||
console.log(("There are no contracts registered for this network in your address book. Please make sure you deploy your contracts to " + network + " first").red) | ||
process.exit() | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
module.exports = { | ||
onCompiled: function (context, callback) { | ||
if(typeof this.compiled[context.source] === "array") { | ||
this.compiled[context.source].push(callback); | ||
} else { | ||
this.compiled[context.source] = [callback]; | ||
} | ||
}, | ||
compiled: {}, | ||
executeCompiled(compiledFileName) { | ||
for (fileName in this.compiled) { | ||
if (compiledFileName.startsWith(fileName)) { | ||
for (var i = 0; i < this.compiled[fileName].length; i++) { | ||
this.compiled[fileName][i](compiledFileName) | ||
} | ||
} | ||
} | ||
}, | ||
onDeployed: function (context, callback) { | ||
if(typeof this.deployed[context.source] === "array") { | ||
this.deployed[context.source].push(callback); | ||
} else { | ||
this.deployed[context.source] = [callback]; | ||
} | ||
}, | ||
deployed: {}, | ||
executeDeployed(contracts) { | ||
this.executeAllDeployed(contracts) | ||
for (contractName in contracts) { | ||
for (fileName in this.deployed) { | ||
if (contractName.startsWith(fileName)) { | ||
for (var i = 0; i < this.deployed[fileName].length; i++) { | ||
this.deployed[fileName][i](contracts[contractName], contractName) | ||
} | ||
|
||
} | ||
} | ||
} | ||
}, | ||
onAllDeployed: function (callback) { | ||
this.allDeployed.push(callback) | ||
}, | ||
allDeployed: [], | ||
executeAllDeployed: function(contracts){ | ||
for (var i = 0; i < this.allDeployed.length; i++) { | ||
this.allDeployed[i](contracts) | ||
} | ||
}, | ||
onError: function (context, callback) { | ||
if(typeof this.errors[context.source] === "array") { | ||
this.errors[context.source].push(callback); | ||
} else { | ||
this.errors[context.source] = [callback]; | ||
} | ||
}, | ||
errors: {}, | ||
executeErrors: function(errors) { | ||
var self = this; | ||
errors.forEach(function(error) { | ||
for (fileName in self.errors) { | ||
if (error.includes(fileName)) { | ||
for (var i = 0; i < self.errors[fileName].length; i++) { | ||
self.errors[fileName][i](error) | ||
} | ||
} | ||
} | ||
}) | ||
}, | ||
tests:{}, | ||
onTest: function (context, description, callback) { | ||
if(typeof this.tests[context.source] != "object") { | ||
this.tests[context.source] = {[description]: callback} | ||
} else { | ||
this.tests[context.source][description] = callback | ||
} | ||
}, | ||
} |
Oops, something went wrong.