-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
80 lines (67 loc) · 2.39 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
```javascript
// Importing necessary libraries and tools
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');
// Importing blockchain configuration
const blockchainConfig = require('./blockchain_config');
// Importing API tooling
const APITooling = require('./api_tooling');
// Importing control panel
const controlPanel = require('./control_panel');
// Importing interactive builders
const interactiveBuilders = require('./interactive_builders');
// Function to execute a shell command
function executeCommand(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
console.warn(error);
}
resolve(stdout? stdout : stderr);
});
});
}
// Function to compile and deploy smart contracts
async function compileAndDeployContracts() {
// Compiling contracts
console.log('Compiling contracts...');
await executeCommand('solc --bin --abi -o ./build ./smart_contract_templates.sol');
// Deploying contracts
console.log('Deploying contracts...');
await executeCommand('truffle migrate --reset');
}
// Function to start the control panel
async function startControlPanel() {
console.log('Starting control panel...');
controlPanel.start();
}
// Function to start the interactive builders
async function startInteractiveBuilders() {
console.log('Starting interactive builders...');
interactiveBuilders.start();
}
// Function to initialize the blockchain
async function initializeBlockchain() {
console.log('Initializing blockchain...');
await blockchainConfig.createBlockchain(blockchainConfig.QUANTUM_UNITY_FRAMEWORK_CHAIN_ID);
await blockchainConfig.createBlockchain(blockchainConfig.GLOBAL_DIGITAL_CURRENCY_NETWORK_CHAIN_ID);
await blockchainConfig.createBlockchain(blockchainConfig.CONTUDO_CHAIN_ID);
}
// Function to initialize the API tooling
async function initializeAPITooling() {
console.log('Initializing API tooling...');
const apiTooling = new APITooling();
await apiTooling.initialize();
}
// Main function to run all scripts
async function main() {
await initializeBlockchain();
await compileAndDeployContracts();
await initializeAPITooling();
await startControlPanel();
await startInteractiveBuilders();
}
// Running the main function
main().catch(console.error);
```