Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 211235c

Browse files
committed
improvements and fixes to docker dev
1 parent 722f34c commit 211235c

11 files changed

+21
-44
lines changed

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
# misc
44
.DS_Store
55

6-
contracts/exportAddresses\.sh
7-
8-
**/exportAddresses\.sh
9-
106
!*.gitkeep
117

128
node_modules

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ Please follow detail instruction [here](https://github.com/appliedblockchain/lau
7070

7171
### Run this app with Docker Dev
7272

73-
1. Install docker and docker compose
74-
2. In a terminal, run `source docker-aliases.sh`
75-
3. You might need to run `npm i && npm run compile` in the contracts folder if you haven't already.
73+
1. Cd into `stack`
74+
2. Run `source docker-aliases.sh`
75+
3. You might need to run `npm i && npm run compile` in the contracts directory if you haven't already.
7676
4. Start parity only: `launchpad-compose up parity`
7777
5. While parity is running, deploy the contracts(run `npm run deploy` from the contracts folder).
7878
6. Run `launchpad-compose build` to build the api and react images
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"PORT": "PORT",
33
"ETHEREUM_JSONRPC_ENDPOINT": "ETHEREUM_JSONRPC_ENDPOINT",
4-
"CONTRACT_ADDRESS": "CONTRACT_ADDRESS",
4+
"CONTRACT_ADDRESSES": "CONTRACT_ADDRESSES",
55
"ELASTICSEARCH": "ELASTICSEARCH",
66
"API_MNEMONIC": "API_MNEMONIC"
77
}

api/run.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
const runApp = require('./src/app')
44
const logger = require('./src/logger')
55
const config = require('config')
6+
const { join } = require('path')
67

78
const NODE_ENV = config.get('NODE_ENV')
89
const PORT = config.get('PORT')
910

10-
const contracts = require('../contracts/build/contractABIs.json')
11+
const contractAbisPath = join(__dirname, './contracts/build/contractABIs.json')
12+
const contracts = require(contractAbisPath)
13+
console.log(`Contracts loaded: ${JSON.stringify(Object.keys(contracts))}`)
1114

1215
const getCtrAddress = (contractName) => (
1316
contracts[contractName].address

api/src/util/web3.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ const Web3 = require('web3')
22
const abiDecoder = require('abi-decoder')
33
const config = require('config')
44
const ETHEREUM_JSONRPC_ENDPOINT = config.get('ETHEREUM_JSONRPC_ENDPOINT')
5+
const { join } = require('path')
56

6-
const contractsJSON = require('../../../contracts/build/contractABIs.json')
7+
console.log('DIRNAME', __dirname)
8+
const contractAbisPath = join(__dirname, './contracts/build/contractABIs.json')
9+
const contractsJSON = require(contractAbisPath)
10+
console.log(`Contracts loaded: ${JSON.stringify(Object.keys(contractsJSON))}`)
711

812
const web3 = new Web3(ETHEREUM_JSONRPC_ENDPOINT)
913

contracts/bin/deploy.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const { readdirSync, readFileSync, writeFileSync } = require('fs')
55
const { join } = require('path')
66
const Web3 = require('web3')
7+
const { remove } = require('lodash')
78

89
const contractsDirectory = join(__dirname, '../build/contracts')
910
const contractsFilenames = readdirSync(contractsDirectory).filter(f => /\.json$/.test(f))
@@ -43,10 +44,6 @@ const deployContracts = async ({ ctrNames, contracts, defaultAddress, eth }) =>
4344
const contractName = ctrNames[i]
4445
console.log(`Deploying contract: ${contractName}....\n`)
4546

46-
if (contractName === 'Migrations') {
47-
continue
48-
}
49-
5047
const { abi, bytecode } = contracts[contractName]
5148
const sendParams = buildSendParams(defaultAddress)
5249

@@ -76,7 +73,8 @@ const deploy = () => {
7673
// const address = await web3.eth.getAccounts()[0]
7774
// console.log(`current 'from' address: ${address}`)
7875

79-
const ctrNames = Object.keys(contracts)
76+
let ctrNames = Object.keys(contracts)
77+
ctrNames = remove('Migrations', ctrNames)
8078
console.log(`Contracts deployment - contracts: ${ctrNames.join(', ')}`)
8179

8280
const contractABIs = await deployContracts({ ctrNames, contracts, defaultAddress, eth })

contracts/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"compile": "rm -rf ./build/* && truffle compile",
77
"version": "truffle version",
88
"deploy": "mkdir -p build/contracts && node ./bin/deploy",
9-
"export-addresses": "source ./exportAddresses.sh",
109
"install-contracts": "cp -f ./build/contractABIs.json ../api/contracts/contractABIs.json"
1110
},
1211
"dependencies": {

docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ services:
1717
- NODE_ENV=staging
1818
- PROVIDER=http://parity1:8545
1919
- SENTRY_DSN=http://6f20a6d7d8154e1f93593c634f943f7d@sentry-web:9000/3
20-
- CONTRACT_ADDRESS=$CONTRACT_ADDRESS
2120
networks:
2221
- main
2322
ports:

stack/compose.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22
cd "$(dirname "$0")" || exit 1
33

4+
set -xe
5+
46
configArgs=""
57
configPathList=(docker-compose-dev.yml)
68
npmrcPath="$HOME/.npmrc"
@@ -49,12 +51,9 @@ if [[ -z $npmToken ]]; then
4951
fi
5052
fi
5153

52-
53-
# TODO: remove this, not needed anymore
54-
# echo 'installing contracts in app folders(shared_modules)'
55-
# npm --prefix ../contracts run install-contracts
54+
CTR_ADDR_PATH=../contracts/build/contractAddresses.json
5655

5756
echo 'Loading contracts addresses in env'
58-
source ../api/contracts/exportAddresses.sh
57+
CONTRACT_ADDRESSES=$(cat $CTR_ADDR_PATH)
5958

6059
env COMPOSE_PROJECT_NAME="lauchpad" NPM_TOKEN="$npmToken" docker-compose $configArgs $@

stack/docker-compose-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ services:
2626
environment:
2727
NODE_ENV: development
2828
ETHEREUM_JSONRPC_ENDPOINT: http://parity:8545
29-
CONTRACT_ADDRESS: "$CONTRACT_ADDRESS"
29+
CONTRACT_ADDRESSES: "$CONTRACT_ADDRESSES"
3030
networks:
3131
- main
3232
ports:

stack/package-lock.json

-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)