Skip to content
Permalink
Browse files

[DDW 727] Frontend only laucnher & macOS integration instructions

  • Loading branch information...
Sam-Jeston committed Jul 12, 2019
1 parent d5eac7a commit d06d295b60417e73b4e1cdfa0fdb5b0ea889e8e0
@@ -90,3 +90,6 @@ package-lock.json
# cardano public keys
public.key
public.key.lock

# Frontend launcher state
frontend-only-launcher/state
@@ -43,14 +43,27 @@ required dependencies for development.

## V2 API Integration Guide

### Linux
1. Ensure Docker and Docker Compose are installed on your machine
2. Clone the following repo: `git clone git@github.com:Sam-Jeston/cardano-byron-docker.git`
3. Start the demo cluster from the root of `cardano-byron-docker` by running `./daedalus/start-demo-cluster.sh` (NB: Run all commands from the root folder of `cardano-byron-docker`). The initial pull is big, but after that the containers will start straight away. The size of these images is far from optimized
4. Run `nix-shell` from `daedalus`
5. Run `yarn dev` from the `nix-shell`
6. If required, import some funded wallets from `cardano-byron-docker` by running `./daedalus/import-wallets.sh`. This can only be done once `yarn dev` has been run as this script leverages the Wallet API that Daedalus starts.

### macOS
**There are no working macOS options for cardano-wallet. Nix or otherwise (except building from source with `stack`, which we consider to not be an option).**

To get around this, I have created the `yarn frontend` command and a complete Docker stack to start the integration. This runs Daedalus in frontendOnly mode, and hits a wallet running in a docker-compose stack**

1. _As above_
2. _As above_
3. Start the demo cluster from the root of `cardano-byron-docker` by running `./start.sh`. This command includes an edge node and instance of cardano-wallet.
4. From Daedalus, run `yarn frontend`. This prints the start command to the terminal.
5. Run the command printed to the terminal.

### V2 State of Affairs
- No macOS build options. While this remains the case, it will be impossible for most of the team to develop or test the new process management configuration.
- It doesn't appear possible to connect `cardano-http-bridge` to the local demo cluster when using `cardano-wallet launcher`. For now, we are using `cardano-http-bridge` declared in the docker stack, and using the `cardano-wallet serve` command instead.
- `cardano-wallet launcher` is not accepting the `--random-port` argument
- Lots of things have been temporarily commented out or mocked to get the integration started. As such using `git push --no-verify`. This will be cleaned up once more routes become available.
@@ -0,0 +1,5 @@
A nix free mode of operation for integrating with cardano-wallet, while macOS nix builds are broken

We put the state folder here un `/state` for ease of access and debugging during development.

This is a development tool only.
@@ -0,0 +1,37 @@
const fs = require('fs')
const rimraf = require('./lib/rimraf')
const createAndWriteX509 = require('./lib/x509')

// Declare our state directory for logging and tls certs
const stateDir = `${process.cwd()}/frontend-only-launcher/state`

// Cleanup previous state directory
rimraf(stateDir)

// Create empty state dir
fs.mkdirSync(stateDir)

// Create TLS certificate location
fs.mkdirSync(`${stateDir}/tls`)
fs.mkdirSync(`${stateDir}/tls/client`)

// Create the logging directory
fs.mkdirSync(`${stateDir}/Logs`)

// Create TLS cert file (see below) in ${stateDir}/tls/client
// ca.crt client.key client.pem
createAndWriteX509(`${stateDir}/tls/client`)

// Specific env vars
const cardanoTlsPath = `${stateDir}/tls`

console.log(`
Start command:
CARDANO_TLS_PATH=${cardanoTlsPath} \\
CARDANO_HOST=localhost \\
CARDANO_PORT=8088 \\
LAUNCHER_CONFIG=${process.cwd()}/frontend-only-launcher/launcher-config-base.yaml \\
STATE_DIR=${stateDir} \\
yarn dev
`)
@@ -0,0 +1,27 @@
walletLogging: false
nodeArgs:
- NA
statePath: ${STATE_DIR}
walletPath: daedalus-frontend
nodePath: NA
launcherLogsPrefix: ${STATE_DIR}/Logs/
walletArgs: []
nodeDbPath: NA
updaterPath: NA
workingDir: ${STATE_DIR}
frontendOnlyMode: false
nodeLogPath: null
updaterArgs: []
logsPrefix: ${STATE_DIR}/Logs
# This is related to the legacy node
configuration:
seed: null
filePath: NA
key: NANA
systemStart: null
updateArchive: NA
nodeLogConfig: NA
nodeTimeoutSec: 60
updateWindowsRunner: null
tlsPath: ${STATE_DIR}/tls
x509ToolPath: NA
@@ -0,0 +1,17 @@
const fs = require('fs')
const path = require('path')

module.exports = function rimraf(dir) {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach((file) => {
const filePath = path.join(dir, file)
if (fs.lstatSync(filePath).isDirectory()) {
rimraf(filePath)
} else {
fs.unlinkSync(filePath)
}
})

fs.rmdirSync(dir)
}
}
@@ -0,0 +1,80 @@
const { pki } = require('node-forge')
const fs = require('fs')

module.exports = function createAndWriteX509Cert(folder) {
const keys = pki.rsa.generateKeyPair(2048)
const cert = pki.createCertificate()
cert.publicKey = keys.publicKey

cert.serialNumber = '01'
cert.validity.notBefore = new Date()
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);

const attrs = [{
name: 'commonName',
value: 'daedalus'
}, {
name: 'countryName',
value: 'HK'
}, {
shortName: 'ST',
value: 'NA'
}, {
name: 'localityName',
value: 'NA'
}, {
name: 'organizationName',
value: 'IOHK'
}, {
shortName: 'OU',
value: 'NA'
}]

cert.setSubject(attrs)
cert.setIssuer(attrs)
cert.setExtensions([{
name: 'basicConstraints',
cA: true
}, {
name: 'keyUsage',
keyCertSign: true,
digitalSignature: true,
nonRepudiation: true,
keyEncipherment: true,
dataEncipherment: true
}, {
name: 'extKeyUsage',
serverAuth: true,
clientAuth: true,
codeSigning: true,
emailProtection: true,
timeStamping: true
}, {
name: 'nsCertType',
client: true,
server: true,
email: true,
objsign: true,
sslCA: true,
emailCA: true,
objCA: true
}, {
name: 'subjectAltName',
altNames: [{
type: 7, // IP
ip: '127.0.0.1'
}]
}])

// self-sign certificate
cert.sign(keys.privateKey)

// convert a Forge certificate to PEM
const crt = pki.certificateToPem(cert)
const key = pki.privateKeyToPem(keys.privateKey)
const pem = `${key}${crt}`

fs.writeFileSync(`${folder}/ca.crt`, crt)
fs.writeFileSync(`${folder}/client.key`, key)
fs.writeFileSync(`${folder}/client.pem`, pem)
}
@@ -30,7 +30,8 @@
"storybook:build": "build-storybook -c storybook -o dist/storybook",
"clear:cache": "gulp clear:cache",
"nix:dev": "nix-shell --arg autoStartBackend true --arg allowFaultInjection true --arg systemStart",
"nix:staging": "nix-shell --arg autoStartBackend true --argstr cluster staging"
"nix:staging": "nix-shell --arg autoStartBackend true --argstr cluster staging",
"frontend": "node frontend-only-launcher/index.js"
},
"bin": {
"electron": "./node_modules/.bin/electron"
@@ -97,6 +98,7 @@
"mini-css-extract-plugin": "0.5.0",
"minimist": "1.2.0",
"mobx-react-devtools": "6.0.3",
"node-forge": "^0.8.5",
"node-libs-browser": "2.1.0",
"node-sass": "4.11.0",
"nodemon": "1.18.9",
@@ -7685,6 +7685,11 @@ node-fetch@^2.2.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"

node-forge@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.8.5.tgz#57906f07614dc72762c84cef442f427c0e1b86ee"
integrity sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q==

node-gyp-build@~3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-3.4.0.tgz#f8f62507e65f152488b28aac25d04b9d79748cf7"
@@ -9171,13 +9176,13 @@ react-number-format@3.0.3:
react-polymorph@0.8.7:
version "0.8.7"
resolved "https://registry.yarnpkg.com/react-polymorph/-/react-polymorph-0.8.7.tgz#1f31c509006736bf1334ed2fa2386b4c74f19e3b"
integrity sha512-0/JwkTb3btzFdnUY9mOJzFKEGIuzGCxQPW2TIOyqpeIvON73G36111ykxq3S2Sx+l37SRF90J5ClFYbZi0nP+g==
dependencies:
create-react-context "0.2.2"
create-react-ref "0.1.0"
filter-react-dom-props "0.0.2"
postinstall-build "5.0.1"
react-modal "3.1.12"
integrity sha512-0/JwkTb3btzFdnUY9mOJzFKEGIuzGCxQPW2TIOyqpeIvON73G36111ykxq3S2Sx+l37SRF90J5ClFYbZi0nP+g==

react-resize-detector@~2.3.0:
version "2.3.0"
@@ -11950,6 +11955,11 @@ yargs@^7.0.0, yargs@^7.0.2, yargs@^7.1.0:
y18n "^3.2.1"
yargs-parser "^5.0.0"

yarn@^1.16.0:
version "1.16.0"
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.16.0.tgz#5701b58ac555ff91f7b889b7d791b3dc86f8f999"
integrity sha512-cfemyGlnWKA1zopUUgebTPf8C4WkPIZ+TJmklwcEAJ4u6oWPtJeAzrsamaGGh/+b1XWe8W51yzAImC4AWbWR1g==

yauzl@2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"

0 comments on commit d06d295

Please sign in to comment.
You can’t perform that action at this time.