Skip to content

Commit 4a6abde

Browse files
committed
deploy all contracts works
1 parent 8103df8 commit 4a6abde

4 files changed

Lines changed: 22 additions & 23 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dav-cli": "bin/dav-cli.js"
1717
},
1818
"scripts": {
19-
"start": "./bin/dav-cli.js",
19+
"start": "./bin/dav-cli.js --start",
2020
"test": "echo \"Error: no test specified\" && exit 1"
2121
},
2222
"dependencies": {

src/controllers/blockchain.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
const ganache = require('ganache-cli');
22
const { deployContracts } = require('../lib/contracts');
33
const chalk = require('chalk');
4+
const util = require('util');
45

56
const startTestnet = (port = 8545) => {
67
const server = ganache.server();
7-
server.listen(port, () => {
8-
console.log(
9-
'Local Ethereum testnet started on ' +
10-
chalk.blue.bold.underline(`http://localhost:${port}`),
11-
);
8+
server.listen(port, async () => {
9+
try {
10+
console.log(
11+
'Local Ethereum testnet started on ' +
12+
chalk.blue.bold.underline(`http://localhost:${port}`)
13+
);
1214

13-
const Web3 = require('web3');
14-
const web3 = new Web3(
15-
new Web3.providers.HttpProvider(`http://localhost:${port}`),
16-
);
15+
const Web3 = require('web3');
16+
const web3 = new Web3(
17+
new Web3.providers.HttpProvider(`http://localhost:${port}`)
18+
);
1719

18-
deployContracts(web3);
20+
await deployContracts(web3);
21+
} catch (err) {
22+
console.error(util.inspect(err));
23+
process.exit(0);
24+
}
1925
});
2026
};
2127

2228
module.exports = {
23-
startTestnet,
29+
startTestnet
2430
};

src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env node
2-
31
const program = require('commander');
42
const version = require('./lib/version');
53
const { EOL } = require('os');

src/lib/contracts.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const chalk = require('chalk');
2-
const util = require('util');
32

43
const deployContract = async (web3, contractDetails, args) => {
54
const deployingAccount = (await web3.eth.getAccounts())[0];
@@ -17,7 +16,7 @@ const deployContract = async (web3, contractDetails, args) => {
1716
// Deploy contract
1817
return await contract.deploy({ arguments: args }).send({
1918
from: deployingAccount,
20-
gasLimit: gasLimit
19+
gasLimit: gasLimit * 3
2120
});
2221
};
2322

@@ -26,13 +25,9 @@ const contractJsonIdentity = require('../../contracts/Identity.json');
2625
const contractJsonBasicMission = require('../../contracts/BasicMission.json');
2726

2827
const deployContracts = async web3 => {
29-
try {
30-
const contractDAVToken = await deploySingleContract(web3, contractJsonDAVToken, null);
31-
const contractIdentity = await deploySingleContract(web3, contractJsonIdentity, [contractDAVToken.options.address]);
32-
const contractBasicMission = await deploySingleContract(web3, contractJsonBasicMission, [contractIdentity.options.address, contractDAVToken.options.address]);
33-
} catch (err) {
34-
console.error(util.inspect(err));
35-
}
28+
const contractDAVToken = await deploySingleContract(web3, contractJsonDAVToken, null);
29+
const contractIdentity = await deploySingleContract(web3, contractJsonIdentity, [contractDAVToken.options.address]);
30+
const contractBasicMission = await deploySingleContract(web3, contractJsonBasicMission, [contractIdentity.options.address, contractDAVToken.options.address]);
3631
};
3732

3833
async function deploySingleContract(web3, contractJson, args) {

0 commit comments

Comments
 (0)