├── .dockerignore ├── public ├── favicon.ico ├── manifest.json └── index.html ├── src ├── index.css ├── models │ ├── UTXO.js │ ├── Transaction.js │ ├── UTXOPool.js │ ├── Block.js │ └── Blockchain.js ├── App.test.js ├── network.js ├── index.js ├── server.js ├── components │ ├── AddIdentity.js │ ├── DetailBlock.js │ ├── IdentityListItem.js │ ├── Key.js │ ├── BlockInfo.js │ ├── UTXOPoolTable.js │ ├── TransactionTable.js │ ├── BlockchainWelcome.js │ ├── walkthrough.js │ ├── NewBlock.js │ ├── WelcomeUTXOPoolTable.js │ ├── BlockchainTree.js │ ├── NewBlockTransactionList.js │ ├── NewBlockHeader.js │ ├── Signature.js │ └── NewTransaction.js ├── App.css ├── crypto.js ├── logo.svg ├── store.js ├── registerServiceWorker.js └── App.js ├── helm-chart ├── Chart.yaml └── templates │ ├── client-service.yaml │ ├── server-service.yaml │ ├── client-ingress.yaml │ ├── client-deployment.yaml │ └── server-deployment.yaml ├── Dockerfile.server ├── Dockerfile.client ├── docker-compose.yml ├── .gitignore ├── package.json ├── nginx.conf └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /screencaps 3 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nambrot/blockchain-in-js/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /helm-chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | description: A Helm chart blockchain-in-js 3 | name: blockchain-in-js 4 | version: 0.1.0 5 | -------------------------------------------------------------------------------- /src/models/UTXO.js: -------------------------------------------------------------------------------- 1 | export default class UTXO { 2 | constructor(publicKey, amount) { 3 | this.publicKey = publicKey 4 | this.amount = amount 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Dockerfile.server: -------------------------------------------------------------------------------- 1 | FROM node:6 2 | RUN npm install -g yarn 3 | RUN yarn add express 4 | RUN yarn add socket.io 5 | 6 | # COPY package.json yarn.lock ./ 7 | # RUN yarn --pure-lockfile 8 | 9 | COPY ./src ./src 10 | CMD node src/server.js 11 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | }); 9 | -------------------------------------------------------------------------------- /Dockerfile.client: -------------------------------------------------------------------------------- 1 | FROM node:6.9.1 2 | RUN npm install -g yarn 3 | 4 | COPY package.json yarn.lock ./ 5 | RUN yarn --pure-lockfile 6 | 7 | COPY src src 8 | COPY public public 9 | 10 | RUN yarn run build 11 | 12 | FROM nginx 13 | COPY --from=0 build /usr/share/nginx/html 14 | COPY nginx.conf /etc/nginx/nginx.conf 15 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | client: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile.client 7 | ports: 8 | - "80:80" 9 | links: 10 | - socketio-server 11 | socketio-server: 12 | build: 13 | context: . 14 | dockerfile: Dockerfile.server 15 | ports: 16 | - "4000:4000" 17 | -------------------------------------------------------------------------------- /src/network.js: -------------------------------------------------------------------------------- 1 | import io from 'socket.io-client'; 2 | const socket = io(); 3 | 4 | export const subscribeTo = (type, callback) => { 5 | socket.on('channel', function(data){ 6 | if (data.type === type) { 7 | callback(data.payload) 8 | } 9 | }) 10 | } 11 | 12 | export const publish = (type, payload) => { 13 | socket.emit('channel', { type, payload }) 14 | } 15 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | /screencaps 12 | 13 | # misc 14 | .DS_Store 15 | .env.local 16 | .env.development.local 17 | .env.test.local 18 | .env.production.local 19 | 20 | npm-debug.log* 21 | yarn-debug.log* 22 | yarn-error.log* 23 | -------------------------------------------------------------------------------- /helm-chart/templates/client-service.yaml: -------------------------------------------------------------------------------- 1 | # web-service.yml 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: client-service 6 | labels: 7 | name: client-service 8 | namespace: blockchain-in-js-{{ .Values.step_name }} 9 | spec: 10 | type: ClusterIP 11 | ports: 12 | - port: 80 13 | targetPort: 80 14 | protocol: TCP 15 | selector: 16 | name: client-deployment 17 | -------------------------------------------------------------------------------- /helm-chart/templates/server-service.yaml: -------------------------------------------------------------------------------- 1 | # web-service.yml 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: socketio-server 6 | labels: 7 | name: socketio-server 8 | namespace: blockchain-in-js-{{ .Values.step_name }} 9 | spec: 10 | type: ClusterIP 11 | ports: 12 | - port: 4000 13 | targetPort: 4000 14 | protocol: TCP 15 | selector: 16 | name: server-deployment 17 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 2 | import {action, state} from './store'; 3 | import {subscribeTo, publish} from './network' 4 | action({}) 5 | 6 | subscribeTo('BLOCKCHAIN_BROADCAST', (names) => { 7 | action({ type: 'BLOCKCHAIN_BROADCAST', names }) 8 | }) 9 | 10 | subscribeTo('BLOCKCHAIN_BROADCAST_REQUEST', () => { 11 | publish('BLOCKCHAIN_BROADCAST', state.blockchains.map((b) => b.name)) 12 | }) 13 | 14 | publish('BLOCKCHAIN_BROADCAST_REQUEST', {}) 15 | -------------------------------------------------------------------------------- /src/server.js: -------------------------------------------------------------------------------- 1 | var app = require('express')(); 2 | var http = require('http').Server(app); 3 | var io = require('socket.io')(http); 4 | 5 | // app.get('/', function(req, res){ 6 | // res.sendFile(__dirname + '/index.html'); 7 | // }); 8 | 9 | io.on('connection', function(socket){ 10 | socket.on('channel', function(msg){ 11 | io.emit('channel', msg); 12 | }); 13 | }); 14 | 15 | http.listen(4000, function(){ 16 | console.log('listening on *:4000'); 17 | }); 18 | -------------------------------------------------------------------------------- /src/components/AddIdentity.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { Button } from "@blueprintjs/core"; 3 | import { action } from "../store"; 4 | 5 | export default class AddIdentity extends Component { 6 | render() { 7 | return ( 8 |