From 7ad2229114340b4e3f88f09760a756fce56fcebe Mon Sep 17 00:00:00 2001 From: Matthew Kelly Date: Thu, 20 Feb 2020 17:19:23 +0800 Subject: [PATCH] - Added eosio_docker foler containing the notechain application - Added scripts to set up blockchain, frontend and backend - Updated dependencies in 'server' --- .gitignore | 3 + Dockerfile | 7 + README.md | 8 +- constant.sh | 4 + .../contracts/notechain/notechain.cpp | 85 +++++++ eosio_docker/scripts/accounts.json | 9 + eosio_docker/scripts/continue_blockchain.sh | 29 +++ eosio_docker/scripts/create_accounts.sh | 29 +++ eosio_docker/scripts/deploy_contract.sh | 25 ++ eosio_docker/scripts/init_blockchain.sh | 69 ++++++ first_time_setup.sh | 49 ++++ quick_start.sh | 34 +++ server/package.json | 6 +- server/yarn.lock | 230 ++++++++++-------- start_backend.sh | 7 + start_eosio_docker.sh | 28 +++ start_frontend.sh | 7 + 17 files changed, 528 insertions(+), 101 deletions(-) create mode 100755 Dockerfile create mode 100755 constant.sh create mode 100755 eosio_docker/contracts/notechain/notechain.cpp create mode 100755 eosio_docker/scripts/accounts.json create mode 100755 eosio_docker/scripts/continue_blockchain.sh create mode 100755 eosio_docker/scripts/create_accounts.sh create mode 100755 eosio_docker/scripts/deploy_contract.sh create mode 100755 eosio_docker/scripts/init_blockchain.sh create mode 100755 first_time_setup.sh create mode 100755 quick_start.sh create mode 100755 start_backend.sh create mode 100755 start_eosio_docker.sh create mode 100755 start_frontend.sh diff --git a/.gitignore b/.gitignore index fc41bf8..e27f56e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* + +#blockchain data +**/data/* diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..094e93f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y wget sudo curl +RUN wget https://github.com/EOSIO/eosio.cdt/releases/download/v1.6.2/eosio.cdt_1.6.2-1-ubuntu-18.04_amd64.deb +RUN apt-get update && sudo apt install -y ./eosio.cdt_1.6.2-1-ubuntu-18.04_amd64.deb +RUN wget https://github.com/EOSIO/eos/releases/download/v2.0.0/eosio_2.0.0-1-ubuntu-18.04_amd64.deb +RUN apt-get update && sudo apt install -y ./eosio_2.0.0-1-ubuntu-18.04_amd64.deb diff --git a/README.md b/README.md index 562a656..061fbce 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Server Side Rendering Boilerplate POC -This repo contains two folders, `app` and `server`: +## To set everything up at once, you can run `quick_start.sh`. + +This repo contains three folders, `eosio_docker`, `app` and `server`: + +## eosio_docker + +`eosio_docker` contains everything needed to set up the local blockchain containing the `notechain` application. ## app `app` contains a Next.js / Redux app with a few pages showing some different features, including: diff --git a/constant.sh b/constant.sh new file mode 100755 index 0000000..da01db9 --- /dev/null +++ b/constant.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +readonly DOCKER_IMAGE_NAME="eosio-notechain" +readonly DOCKER_IMAGE_TAG="eos2.0.0-cdt1.6.2" diff --git a/eosio_docker/contracts/notechain/notechain.cpp b/eosio_docker/contracts/notechain/notechain.cpp new file mode 100755 index 0000000..d927cbf --- /dev/null +++ b/eosio_docker/contracts/notechain/notechain.cpp @@ -0,0 +1,85 @@ +#include +#include + +using namespace eosio; + +// Smart Contract Name: notechain +// Table struct: +// notestruct: multi index table to store the notes +// prim_key(uint64): primary key +// user(name): account name for the user +// note(string): the note message +// timestamp(uint64): the store the last update block time +// Public method: +// isnewuser => to check if the given account name has note in table or not +// Public actions: +// update => put the note into the multi-index table and sign by the given account + +// Replace the contract class name when you start your own project +CONTRACT notechain : public eosio::contract { + private: + bool isnewuser( name user ) { + // get notes by using secordary key + auto note_index = _notes.get_index(); + auto note_iterator = note_index.find(user.value); + + return note_iterator == note_index.end(); + } + + TABLE notestruct { + uint64_t prim_key; // primary key + name user; // account name for the user + std::string note; // the note message + block_timestamp timestamp; // the store the last update block time + + // primary key + auto primary_key() const { return prim_key; } + // secondary key + // only supports uint64_t, uint128_t, uint256_t, double or long double + uint64_t get_by_user() const { return user.value; } + }; + + // create a multi-index table and support secondary key + typedef eosio::multi_index< name("notestruct"), notestruct, + indexed_by< name("getbyuser"), const_mem_fun > + > note_table; + + note_table _notes; + + public: + using contract::contract; + + // constructor + notechain( name receiver, name code, datastream ds ): + contract( receiver, code, ds ), + _notes( receiver, receiver.value ) {} + + ACTION update( name user, std::string& note ) { + // to sign the action with the given account + require_auth( user ); + + // create new / update note depends whether the user account exist or not + if (isnewuser(user)) { + // insert new note + _notes.emplace( _self, [&]( auto& new_user ) { + new_user.prim_key = _notes.available_primary_key(); + new_user.user = user; + new_user.note = note; + new_user.timestamp = eosio::current_block_time(); + }); + } else { + // get object by secordary key + auto note_index = _notes.get_index(); + auto ¬e_entry = note_index.get(user.value); + // update existing note + _notes.modify( note_entry, _self, [&]( auto& modified_user ) { + modified_user.note = note; + modified_user.timestamp = eosio::current_block_time(); + }); + } + } + +}; + +// specify the contract name, and export a public action: update +EOSIO_DISPATCH( notechain, (update) ) diff --git a/eosio_docker/scripts/accounts.json b/eosio_docker/scripts/accounts.json new file mode 100755 index 0000000..f9b94ca --- /dev/null +++ b/eosio_docker/scripts/accounts.json @@ -0,0 +1,9 @@ +[ + {"name":"useraaaaaaaa", "privateKey":"5K7mtrinTFrVTduSxizUc5hjXJEtTjVTsqSHeBHes1Viep86FP5", "publicKey":"EOS6kYgMTCh1iqpq9XGNQbEi8Q6k5GujefN9DSs55dcjVyFAq7B6b"}, + {"name":"useraaaaaaab", "privateKey":"5KLqT1UFxVnKRWkjvhFur4sECrPhciuUqsYRihc1p9rxhXQMZBg", "publicKey":"EOS78RuuHNgtmDv9jwAzhxZ9LmC6F295snyQ9eUDQ5YtVHJ1udE6p"}, + {"name":"useraaaaaaac", "privateKey":"5K2jun7wohStgiCDSDYjk3eteRH1KaxUQsZTEmTGPH4GS9vVFb7", "publicKey":"EOS5yd9aufDv7MqMquGcQdD6Bfmv6umqSuh9ru3kheDBqbi6vtJ58"}, + {"name":"useraaaaaaad", "privateKey":"5KNm1BgaopP9n5NqJDo9rbr49zJFWJTMJheLoLM5b7gjdhqAwCx", "publicKey":"EOS8LoJJUU3dhiFyJ5HmsMiAuNLGc6HMkxF4Etx6pxLRG7FU89x6X"}, + {"name":"useraaaaaaae", "privateKey":"5KE2UNPCZX5QepKcLpLXVCLdAw7dBfJFJnuCHhXUf61hPRMtUZg", "publicKey":"EOS7XPiPuL3jbgpfS3FFmjtXK62Th9n2WZdvJb6XLygAghfx1W7Nb"}, + {"name":"useraaaaaaaf", "privateKey":"5KaqYiQzKsXXXxVvrG8Q3ECZdQAj2hNcvCgGEubRvvq7CU3LySK", "publicKey":"EOS5btzHW33f9zbhkwjJTYsoyRzXUNstx1Da9X2nTzk8BQztxoP3H"}, + {"name":"useraaaaaaag", "privateKey":"5KFyaxQW8L6uXFB6wSgC44EsAbzC7ideyhhQ68tiYfdKQp69xKo", "publicKey":"EOS8Du668rSVDE3KkmhwKkmAyxdBd73B51FKE7SjkKe5YERBULMrw"} +] diff --git a/eosio_docker/scripts/continue_blockchain.sh b/eosio_docker/scripts/continue_blockchain.sh new file mode 100755 index 0000000..4f7801c --- /dev/null +++ b/eosio_docker/scripts/continue_blockchain.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -o errexit + +# this file is used to continue the stopped blockchain + +echo "=== start blockchain with ===" + +# set PATH +PATH="$PATH:/opt/eosio/bin" + +set -m + +# start nodeos ( local node of blockchain ) +# run it in a background job such that docker run could continue +nodeos -e -p eosio -d /mnt/dev/data \ + --config-dir /mnt/dev/config \ + --hard-replay \ + --http-validate-host=false \ + --plugin eosio::producer_plugin \ + --plugin eosio::chain_api_plugin \ + --plugin eosio::http_plugin \ + --http-server-address=0.0.0.0:8888 \ + --access-control-allow-origin=* \ + --contracts-console \ + --verbose-http-errors + +# `--hard-replay` option is needed +# because the docker stop signal is not being passed to nodeos process directly +# as we run the init_blockchain.sh as PID 1. diff --git a/eosio_docker/scripts/create_accounts.sh b/eosio_docker/scripts/create_accounts.sh new file mode 100755 index 0000000..ef23053 --- /dev/null +++ b/eosio_docker/scripts/create_accounts.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -o errexit + +echo "=== start deploy data ===" + +# set PATH +PATH="$PATH:/opt/eosio/bin" + +# change to script directory +cd "$(dirname "$0")" + +echo "=== start create accounts in blockchain ===" + +# download jq for json reader, we use jq here for reading the json file ( accounts.json ) +mkdir -p ~/bin && curl -sSL -o ~/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && chmod +x ~/bin/jq && export PATH=$PATH:~/bin + +# loop through the array in the json file, import keys and create accounts +# these pre-created accounts will be used for saving / erasing notes +# we hardcoded each account name, public and private key in the json. +# NEVER store the private key in any source code in your real life developmemnt +# This is just for demo purpose + +jq -c '.[]' accounts.json | while read i; do + name=$(jq -r '.name' <<< "$i") + pub=$(jq -r '.publicKey' <<< "$i") + + # to simplify, we use the same key for owner and active key of each account + cleos create account eosio $name $pub $pub +done diff --git a/eosio_docker/scripts/deploy_contract.sh b/eosio_docker/scripts/deploy_contract.sh new file mode 100755 index 0000000..4e92044 --- /dev/null +++ b/eosio_docker/scripts/deploy_contract.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -o errexit + +# set PATH +PATH="$PATH:/opt/eosio/bin" + +CONTRACTSPATH="$( pwd -P )/contracts" + +# make new directory for compiled contract files +mkdir -p ./compiled_contracts +mkdir -p ./compiled_contracts/$1 + +COMPILEDCONTRACTSPATH="$( pwd -P )/compiled_contracts" + +# unlock the wallet, ignore error if already unlocked +if [ ! -z $3 ]; then cleos wallet unlock -n $3 --password $4 || true; fi + +# compile smart contract to wasm and abi files using EOSIO.CDT (Contract Development Toolkit) +# https://github.com/EOSIO/eosio.cdt +( + eosio-cpp -abigen "$CONTRACTSPATH/$1/$1.cpp" -o "$COMPILEDCONTRACTSPATH/$1/$1.wasm" --contract "$1" +) && + +# set (deploy) compiled contract to blockchain +cleos set contract $2 "$COMPILEDCONTRACTSPATH/$1/" --permission $2 diff --git a/eosio_docker/scripts/init_blockchain.sh b/eosio_docker/scripts/init_blockchain.sh new file mode 100755 index 0000000..1f0a9ce --- /dev/null +++ b/eosio_docker/scripts/init_blockchain.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -o errexit + +echo "=== setup blockchain accounts and smart contract ===" + +# set PATH +PATH="$PATH:/opt/eosio/bin:/opt/eosio/bin/scripts" + +set -m + +# start nodeos ( local node of blockchain ) +# run it in a background job such that docker run could continue +nodeos -e -p eosio -d /mnt/dev/data \ + --config-dir /mnt/dev/config \ + --http-validate-host=false \ + --plugin eosio::producer_plugin \ + --plugin eosio::chain_api_plugin \ + --plugin eosio::http_plugin \ + --http-server-address=0.0.0.0:8888 \ + --access-control-allow-origin=* \ + --contracts-console \ + --verbose-http-errors & +sleep 1s +until curl localhost:8888/v1/chain/get_info +do + sleep 1s +done + +# Sleep for 2 to allow time 4 blocks to be created so we have blocks to reference when sending transactions +sleep 2s +echo "=== setup wallet: eosiomain ===" +# First key import is for eosio system account +cleos wallet create -n eosiomain --to-console | tail -1 | sed -e 's/^"//' -e 's/"$//' > eosiomain_wallet_password.txt +cleos wallet import -n eosiomain --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 + +echo "=== setup wallet: notechainwal ===" +# key for eosio account and export the generated password to a file for unlocking wallet later +cleos wallet create -n notechainwal --to-console | tail -1 | sed -e 's/^"//' -e 's/"$//' > notechain_wallet_password.txt +# Owner key for notechainwal wallet +cleos wallet import -n notechainwal --private-key 5JpWT4ehouB2FF9aCfdfnZ5AwbQbTtHBAwebRXt94FmjyhXwL4K +# Active key for notechainwal wallet +cleos wallet import -n notechainwal --private-key 5JD9AGTuTeD5BXZwGQ5AtwBqHK21aHmYnTetHgk1B3pjj7krT8N + +# * Replace "notechainwal" by your own wallet name when you start your own project + +# create account for notechainacc with above wallet's public keys +cleos create account eosio notechainacc EOS6PUh9rs7eddJNzqgqDx1QrspSHLRxLMcRdwHZZRL4tpbtvia5B EOS8BCgapgYA2L4LJfCzekzeSr3rzgSTUXRXwNi8bNRoz31D14en9 + +# * Replace "notechainacc" by your own account name when you start your own project + +echo "=== deploy smart contract ===" +# $1 smart contract name +# $2 account holder name of the smart contract +# $3 wallet for unlock the account +# $4 password for unlocking the wallet +deploy_contract.sh notechain notechainacc notechainwal $(cat notechain_wallet_password.txt) + +echo "=== create user accounts ===" +# script for create data into blockchain +create_accounts.sh + +# * Replace the script with different form of data that you would pushed into the blockchain when you start your own project + +echo "=== end of setup blockchain accounts and smart contract ===" +# create a file to indicate the blockchain has been initialized +touch "/mnt/dev/data/initialized" + +# put the background nodeos job to foreground for docker run +fg %1 diff --git a/first_time_setup.sh b/first_time_setup.sh new file mode 100755 index 0000000..8c25fb0 --- /dev/null +++ b/first_time_setup.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +source constant.sh + +echo "=== start of first time setup ===" + +# change to script's directory +cd "$(dirname "$0")" +SCRIPTPATH="$( pwd -P )" + +# make sure Docker and Node.js is installed +if [ ! -x "$(command -v docker)" ] || + [ ! -x "$(command -v npm)" ]; then + echo "" + echo -e "\033[0;31m[Error with Exception]\033[0m" + echo "Please make sure Docker and Node.js are installed" + echo "" + echo "Install Docker: https://docs.docker.com/docker-for-mac/install/" + echo "Install Node.js: https://nodejs.org/en/" + echo "" + exit +fi + +# build docker image, if necessary +if [[ "$(docker images -q $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG)" == "" ]]; then + echo "=== Build docker image $DOCKER_IMAGE_NAME version $DOCKER_IMAGE_TAG, this will take some time for the first time run ===" + docker build -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG . +else + echo "=== Docker image already exists, skip building ===" +fi + +# force remove the perivous container if any +# create a clean data folder in eosio_docker to preserve block data +echo "=== setup/reset data for eosio_docker ===" +docker rm --force eosio_notechain_container +rm -rf "./eosio_docker/data" +mkdir -p "./eosio_docker/data" + +# set up node_modules for frontend +echo "=== yarn install package for backend react app ===" +# change directory to ./server +cd "$SCRIPTPATH/server" +yarn + +# set up node_modules for frontend +echo "=== yarn install package for frontend react app ===" +# change directory to ./app +cd "$SCRIPTPATH/app" +yarn diff --git a/quick_start.sh b/quick_start.sh new file mode 100755 index 0000000..e5ed3f8 --- /dev/null +++ b/quick_start.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# make sure everything is clean and well setup +echo "[quick_start.sh] First time setup" +./first_time_setup.sh + +# start blockchain and put in background +echo "[quick_start.sh] Starting eosio docker" +./start_eosio_docker.sh --nolog + +# wait until eosio blockchain to be started +until $(curl --output /dev/null \ + --silent \ + --head \ + --fail \ + localhost:8888/v1/chain/get_info) +do + echo "Waiting eosio blockchain to be started..." + sleep 2s +done + +# An extra sleep is added here to make sure the note contract is deployed before the front end is launched +sleep 5s + +echo "[quick_start.sh] Starting backend react app" +./start_backend.sh & + +#start frontend react app +echo "[quick_start.sh] Starting frontend react app" +./start_frontend.sh & +P1=$! + +# wait $P1 +wait $P1 diff --git a/server/package.json b/server/package.json index fe8a36d..c0dd0f9 100644 --- a/server/package.json +++ b/server/package.json @@ -8,9 +8,9 @@ "dependencies": { "cookie-parser": "~1.4.4", "cors": "^2.8.5", - "debug": "~2.6.9", - "express": "~4.16.1", - "http-errors": "~1.6.3", + "debug": "~4.1.1", + "express": "~4.17.1", + "http-errors": "~1.7.3", "jade": "~1.11.0", "jsonwebtoken": "^8.5.1", "morgan": "~1.9.1" diff --git a/server/yarn.lock b/server/yarn.lock index 03ebff4..ea445ec 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -accepts@~1.3.5: +accepts@~1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== @@ -58,31 +58,31 @@ basic-auth@~2.0.0: dependencies: safe-buffer "5.1.2" -body-parser@1.18.3: - version "1.18.3" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.3.tgz#5b292198ffdd553b3a0f20ded0592b956955c8b4" - integrity sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ= +body-parser@1.19.0: + version "1.19.0" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" + integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== dependencies: - bytes "3.0.0" + bytes "3.1.0" content-type "~1.0.4" debug "2.6.9" depd "~1.1.2" - http-errors "~1.6.3" - iconv-lite "0.4.23" + http-errors "1.7.2" + iconv-lite "0.4.24" on-finished "~2.3.0" - qs "6.5.2" - raw-body "2.3.3" - type-is "~1.6.16" + qs "6.7.0" + raw-body "2.4.0" + type-is "~1.6.17" buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" integrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk= -bytes@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" - integrity sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= +bytes@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" + integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== camelcase@^1.0.2: version "1.2.1" @@ -138,10 +138,12 @@ constantinople@~3.0.1: dependencies: acorn "^2.1.0" -content-disposition@0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" - integrity sha1-DPaLud318r55YcOoUXjLhdunjLQ= +content-disposition@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" + integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g== + dependencies: + safe-buffer "5.1.2" content-type@~1.0.4: version "1.0.4" @@ -166,6 +168,11 @@ cookie@0.3.1: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= +cookie@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" + integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== + cors@^2.8.5: version "2.8.5" resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" @@ -192,13 +199,20 @@ css@~1.0.8: css-parse "1.0.4" css-stringify "1.0.5" -debug@2.6.9, debug@~2.6.9: +debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== dependencies: ms "2.0.0" +debug@~4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + decamelize@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -241,53 +255,53 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= -express@~4.16.1: - version "4.16.4" - resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e" - integrity sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg== +express@~4.17.1: + version "4.17.1" + resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" + integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== dependencies: - accepts "~1.3.5" + accepts "~1.3.7" array-flatten "1.1.1" - body-parser "1.18.3" - content-disposition "0.5.2" + body-parser "1.19.0" + content-disposition "0.5.3" content-type "~1.0.4" - cookie "0.3.1" + cookie "0.4.0" cookie-signature "1.0.6" debug "2.6.9" depd "~1.1.2" encodeurl "~1.0.2" escape-html "~1.0.3" etag "~1.8.1" - finalhandler "1.1.1" + finalhandler "~1.1.2" fresh "0.5.2" merge-descriptors "1.0.1" methods "~1.1.2" on-finished "~2.3.0" - parseurl "~1.3.2" + parseurl "~1.3.3" path-to-regexp "0.1.7" - proxy-addr "~2.0.4" - qs "6.5.2" - range-parser "~1.2.0" + proxy-addr "~2.0.5" + qs "6.7.0" + range-parser "~1.2.1" safe-buffer "5.1.2" - send "0.16.2" - serve-static "1.13.2" - setprototypeof "1.1.0" - statuses "~1.4.0" - type-is "~1.6.16" + send "0.17.1" + serve-static "1.14.1" + setprototypeof "1.1.1" + statuses "~1.5.0" + type-is "~1.6.18" utils-merge "1.0.1" vary "~1.1.2" -finalhandler@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.1.tgz#eebf4ed840079c83f4249038c9d703008301b105" - integrity sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg== +finalhandler@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" + integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== dependencies: debug "2.6.9" encodeurl "~1.0.2" escape-html "~1.0.3" on-finished "~2.3.0" - parseurl "~1.3.2" - statuses "~1.4.0" + parseurl "~1.3.3" + statuses "~1.5.0" unpipe "~1.0.0" forwarded@~0.1.2: @@ -305,20 +319,32 @@ fresh@0.5.2: resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU= -http-errors@1.6.3, http-errors@~1.6.2, http-errors@~1.6.3: - version "1.6.3" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" - integrity sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0= +http-errors@1.7.2: + version "1.7.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" + integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== dependencies: depd "~1.1.2" inherits "2.0.3" - setprototypeof "1.1.0" - statuses ">= 1.4.0 < 2" + setprototypeof "1.1.1" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.0" -iconv-lite@0.4.23: - version "0.4.23" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" - integrity sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA== +http-errors@~1.7.2, http-errors@~1.7.3: + version "1.7.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" + integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw== + dependencies: + depd "~1.1.2" + inherits "2.0.4" + setprototypeof "1.1.1" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.0" + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== dependencies: safer-buffer ">= 2.1.2 < 3" @@ -327,6 +353,11 @@ inherits@2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +inherits@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + ipaddr.js@1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.0.tgz#37df74e430a0e47550fe54a2defe30d8acd95f65" @@ -483,10 +514,10 @@ mime-types@~2.1.24: dependencies: mime-db "1.43.0" -mime@1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" - integrity sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ== +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== minimist@0.0.8: version "0.0.8" @@ -516,6 +547,11 @@ ms@2.0.0: resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= +ms@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" @@ -550,7 +586,7 @@ optimist@~0.3.5: dependencies: wordwrap "~0.0.2" -parseurl@~1.3.2: +parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== @@ -574,7 +610,7 @@ promise@~2.0: dependencies: is-promise "~1" -proxy-addr@~2.0.4: +proxy-addr@~2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.5.tgz#34cbd64a2d81f4b1fd21e76f9f06c8a45299ee34" integrity sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ== @@ -582,24 +618,24 @@ proxy-addr@~2.0.4: forwarded "~0.1.2" ipaddr.js "1.9.0" -qs@6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== +qs@6.7.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" + integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== -range-parser@~1.2.0: +range-parser@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== -raw-body@2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3" - integrity sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw== +raw-body@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" + integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== dependencies: - bytes "3.0.0" - http-errors "1.6.3" - iconv-lite "0.4.23" + bytes "3.1.0" + http-errors "1.7.2" + iconv-lite "0.4.24" unpipe "1.0.0" repeat-string@^1.5.2: @@ -634,10 +670,10 @@ semver@^5.6.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -send@0.16.2: - version "0.16.2" - resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1" - integrity sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw== +send@0.17.1: + version "0.17.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" + integrity sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg== dependencies: debug "2.6.9" depd "~1.1.2" @@ -646,27 +682,27 @@ send@0.16.2: escape-html "~1.0.3" etag "~1.8.1" fresh "0.5.2" - http-errors "~1.6.2" - mime "1.4.1" - ms "2.0.0" + http-errors "~1.7.2" + mime "1.6.0" + ms "2.1.1" on-finished "~2.3.0" - range-parser "~1.2.0" - statuses "~1.4.0" + range-parser "~1.2.1" + statuses "~1.5.0" -serve-static@1.13.2: - version "1.13.2" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1" - integrity sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw== +serve-static@1.14.1: + version "1.14.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" + integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg== dependencies: encodeurl "~1.0.2" escape-html "~1.0.3" - parseurl "~1.3.2" - send "0.16.2" + parseurl "~1.3.3" + send "0.17.1" -setprototypeof@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" - integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== +setprototypeof@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" + integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== source-map@0.4.x: version "0.4.4" @@ -687,15 +723,15 @@ source-map@~0.5.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -"statuses@>= 1.4.0 < 2": +"statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= -statuses@~1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" - integrity sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew== +toidentifier@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" + integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== transformers@2.1.0: version "2.1.0" @@ -706,7 +742,7 @@ transformers@2.1.0: promise "~2.0" uglify-js "~2.2.5" -type-is@~1.6.16: +type-is@~1.6.17, type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== diff --git a/start_backend.sh b/start_backend.sh new file mode 100755 index 0000000..a0e2147 --- /dev/null +++ b/start_backend.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# change to script's directory +cd "$(dirname "$0")/server" + +echo "=== yarn start ===" +yarn start diff --git a/start_eosio_docker.sh b/start_eosio_docker.sh new file mode 100755 index 0000000..610fcfe --- /dev/null +++ b/start_eosio_docker.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -o errexit + +source constant.sh + +# change to script's directory +cd "$(dirname "$0")/eosio_docker" + +if [ -e "data/initialized" ] +then + script="./scripts/continue_blockchain.sh" +else + script="./scripts/init_blockchain.sh" +fi + +echo "=== run docker container from the $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG image ===" +docker run --rm --name eosio_notechain_container -d \ +-p 8888:8888 -p 9876:9876 \ +--mount type=bind,src="$(pwd)"/contracts,dst=/opt/eosio/bin/contracts \ +--mount type=bind,src="$(pwd)"/scripts,dst=/opt/eosio/bin/scripts \ +--mount type=bind,src="$(pwd)"/data,dst=/mnt/dev/data \ +-w "/opt/eosio/bin/" $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG /bin/bash -c "$script" + +if [ "$1" != "--nolog" ] +then + echo "=== follow eosio_notechain_container logs ===" + docker logs eosio_notechain_container --follow +fi diff --git a/start_frontend.sh b/start_frontend.sh new file mode 100755 index 0000000..2f1a7ff --- /dev/null +++ b/start_frontend.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# change to script's directory +cd "$(dirname "$0")/app" + +echo "=== yarn dev ===" +yarn dev