diff --git a/lib/contracts/blockchain.js b/lib/contracts/blockchain.js new file mode 100644 index 00000000..46fc2793 --- /dev/null +++ b/lib/contracts/blockchain.js @@ -0,0 +1,10 @@ + +class Blockchain { + constructor(optiosn) { + this.plugins = options.plugins; + this.logger = options.logger; + } +} + +module.exports = Blockchain; + diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index 632596ba..9ae358f9 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -1,5 +1,6 @@ let async = require('async'); //require("../utils/debug_util.js")(__filename, async); +let utils = require('../utils/utils.js'); let RunCode = require('../core/runCode.js'); @@ -86,7 +87,7 @@ class Deploy { if (contract.address !== undefined) { try { - this.web3.utils.toChecksumAddress(contract.address); + utils.toChecksumAddress(contract.address); } catch(e) { self.logger.error(__("error deploying %s", contract.className)); self.logger.error(e.message); diff --git a/lib/contracts/deploy_tracker.js b/lib/contracts/deploy_tracker.js index 2497b2dc..2873c56a 100644 --- a/lib/contracts/deploy_tracker.js +++ b/lib/contracts/deploy_tracker.js @@ -1,4 +1,5 @@ let fs = require('../core/fs.js'); +let utils = require('../utils/utils.js'); class DeployTracker { constructor(options, cb) { @@ -37,14 +38,14 @@ class DeployTracker { } trackContract(contractName, code, args, address) { - this.currentChain.contracts[this.web3.utils.sha3(code + contractName + args.join(','))] = { + this.currentChain.contracts[utils.sha3(code + contractName + args.join(','))] = { name: contractName, address: address }; } getContract(contractName, code, args) { - let contract = this.currentChain.contracts[this.web3.utils.sha3(code + contractName + args.join(','))]; + let contract = this.currentChain.contracts[utils.sha3(code + contractName + args.join(','))]; if (contract && contract.address === undefined) { return false; } diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 0063c1ec..edcb5fa3 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -6,6 +6,7 @@ let https = require('follow-redirects').https; let shelljs = require('shelljs'); var tar = require('tar'); var propose = require('propose'); +var Web3 = require('web3'); const constants = require('../constants'); //let fs = require('../core/fs.js'); @@ -173,6 +174,14 @@ function getExternalContractUrl(file) { }; } +function toChecksumAddress(address) { + return Web3.utils.toChecksumAddress(address); +} + +function sha3(arg) { + return Web3.utils.sha3(arg); +} + module.exports = { joinPath: joinPath, filesMatchingPattern: filesMatchingPattern, @@ -190,5 +199,7 @@ module.exports = { extractTar: extractTar, proposeAlternative: proposeAlternative, pwd: pwd, - getExternalContractUrl + getExternalContractUrl, + toChecksumAddress: toChecksumAddress, + sha3: sha3 };