-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
7 changed files
with
13,526 additions
and
1,137 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,20 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "dav-cli", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"program": "${workspaceFolder}/src/index.js", | ||
"args": [ | ||
"--start" | ||
] | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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 |
---|---|---|
|
@@ -34,4 +34,4 @@ | |
"prettier": "^1.17.0" | ||
}, | ||
"preferGlobal": true | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,35 +1,47 @@ | ||
const chalk = require('chalk'); | ||
const util = require('util'); | ||
|
||
const deployContract = async (web3, contractDetails) => { | ||
const deployContract = async (web3, contractDetails, args) => { | ||
const deployingAccount = (await web3.eth.getAccounts())[0]; | ||
|
||
// Create contract instance | ||
const contract = new web3.eth.Contract(contractDetails.abi, { | ||
data: contractDetails.bytecode, | ||
data: contractDetails.bytecode | ||
}); | ||
|
||
// Estimate gas | ||
const gasLimit = await web3.eth.estimateGas({ | ||
data: contractDetails.bytecode, | ||
data: contractDetails.bytecode | ||
}); | ||
|
||
// Deploy contract | ||
return await contract.deploy().send({ | ||
return await contract.deploy({ arguments: args }).send({ | ||
from: deployingAccount, | ||
gasLimit: gasLimit, | ||
gasLimit: gasLimit | ||
}); | ||
}; | ||
|
||
const contractJsonDAVToken = require('../../contracts/DAVToken.json'); | ||
const contractJsonIdentity = require('../../contracts/Identity.json'); | ||
const contractJsonBasicMission = require('../../contracts/BasicMission.json'); | ||
|
||
const deployContracts = async web3 => { | ||
const DAVToken = await deployContract( | ||
web3, | ||
require('../../contracts/DAVToken.json'), | ||
); | ||
console.log( | ||
'DAVToken contract: ' + chalk.green.bold(DAVToken.options.address), | ||
); | ||
try { | ||
const contractDAVToken = await deploySingleContract(web3, contractJsonDAVToken, null); | ||
const contractIdentity = await deploySingleContract(web3, contractJsonIdentity, [contractDAVToken.options.address]); | ||
const contractBasicMission = await deploySingleContract(web3, contractJsonBasicMission, [contractIdentity.options.address, contractDAVToken.options.address]); | ||
} catch (err) { | ||
console.error(util.inspect(err)); | ||
} | ||
}; | ||
|
||
async function deploySingleContract(web3, contractJson, args) { | ||
console.log(`Deploying ${contractJson.contractName}...`); | ||
const contract = await deployContract(web3, contractJson, args); | ||
console.log(`${contractJson.contractName} contract: ${chalk.green.bold(contract.options.address)}`); | ||
return contract; | ||
} | ||
|
||
module.exports = { | ||
deployContracts, | ||
deployContracts | ||
}; |