Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit 34c0867

Browse files
committed
Add start script and show env vars when you run it
1 parent 234d184 commit 34c0867

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

new_project/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
yarn-error.log
2+
node_modules/

new_project/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
"name": "new_project",
33
"version": "0.1.0",
44
"private": true,
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "DOTENV_CONFIG_PATH=$HOME/.create-comit-app/env node -r dotenv/config ./src/index.js"
8+
},
59
"dependencies": {
6-
"comit-sdk": "^0.7.0"
10+
"comit-sdk": "^0.7.1",
11+
"dotenv": "^8.2.0",
12+
"readline-sync": "^1.4.10"
713
}
814
}

new_project/src/index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const fs = require("fs");
2+
3+
const configPath = process.env.DOTENV_CONFIG_PATH;
4+
5+
if (fs.existsSync(configPath)) {
6+
console.log("Environment configuration:");
7+
8+
// Bitcoin HD keys with address funded during environment set-up.
9+
// Used to initialize Bitcoin wallets with funds.
10+
console.log("Bitcoin HD keys:");
11+
console.log("1. ", process.env.BITCOIN_HD_KEY_0);
12+
console.log("2. ", process.env.BITCOIN_HD_KEY_1);
13+
14+
// The URI of the regtest Bitcoin node created during environment set-up.
15+
// Used to initialize Bitcoin wallets connected to the correct local network.
16+
console.log("Bitcoin node P2P URI: ", process.env.BITCOIN_P2P_URI);
17+
18+
// Ethereum private keys with address funded during environment set-up.
19+
// Used to initialize Ethereum wallets with funds.
20+
console.log("Ethereum private keys:");
21+
console.log("1. ", process.env.ETHEREUM_KEY_0);
22+
console.log("2. ", process.env.ETHEREUM_KEY_1);
23+
24+
// The URL for the HTTP API of the regtest Ethereum node created during environment set-up.
25+
// Used to initialize Ethereum wallets connected to the correct local network.
26+
console.log("Ethereum node HTTP URL: ", process.env.ETHEREUM_NODE_HTTP_URL);
27+
28+
// The contract address of the ERC20 token deployed on the regtest network during environment set-up.
29+
// Used to identify the ERC20 token when performing swaps.
30+
console.log(
31+
"ERC20 token contract address: ",
32+
process.env.ERC20_CONTRACT_ADDRESS
33+
);
34+
35+
// HTTP API URLs for the instances of cnd created during environment set-up.
36+
// Used to interact with said instances of cnd. In particular, it allows for
37+
// instantiating `ComitClient`s when using `comit-sdk`.
38+
console.log("cnd HTTP API URLs:");
39+
console.log("1. ", process.env.HTTP_URL_CND_0);
40+
console.log("2. ", process.env.HTTP_URL_CND_1);
41+
} else {
42+
console.log(
43+
"Could not find file %s. Did you run `yarn create comit-app start-env`?",
44+
configPath
45+
);
46+
}

0 commit comments

Comments
 (0)