Commit 2e4182cb authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

script: serve state dump (#229)

* script: serve state dump

* feat: python2

* cleanup

* yarn: add serve script
parent 3d763eaa
#!/bin/bash
# Run this script to serve the latest state dump from
# an http server. This is useful to serve the state dump
# to a local instance of the sequencer/verifier during
# development. The state dump can be found at
# `GET /state-dump.latest.json`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
PYTHON=${PYTHON:-python}
HOST=${HOST:-0.0.0.0}
PORT=${PORT:-8081}
DIRECTORY=$DIR/../build/dumps
if [ ! command -v $PYTHON&>/dev/null ]; then
echo "Please install python"
exit 1
fi
VERSION=$($PYTHON --version 2>&1 \
| cut -d ' ' -f2 \
| sed -Ee's#([^/]).([^/]).([^/])#\1#')
if [[ $VERSION == 3 ]]; then
$PYTHON -m http.server \
--bind $HOST $PORT \
--directory $DIRECTORY
else
(
echo "Serving HTTP on $HOST port $PORT"
cd $DIRECTORY
$PYTHON -c \
'import BaseHTTPServer as bhs, SimpleHTTPServer as shs; bhs.HTTPServer(("'$HOST'", '"$PORT"'), shs.SimpleHTTPRequestHandler).serve_forever()'
)
fi
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
"lint:fix": "yarn run lint:fix:typescript", "lint:fix": "yarn run lint:fix:typescript",
"lint:fix:typescript": "prettier --config prettier-config.json --write \"hardhat.config.ts\" \"{src,test}/**/*.ts\"", "lint:fix:typescript": "prettier --config prettier-config.json --write \"hardhat.config.ts\" \"{src,test}/**/*.ts\"",
"clean": "rm -rf ./artifacts ./build ./cache", "clean": "rm -rf ./artifacts ./build ./cache",
"deploy": "./bin/deploy.js" "deploy": "./bin/deploy.js",
"serve": "./bin/serve_dump.sh"
}, },
"dependencies": { "dependencies": {
"@ethersproject/abstract-provider": "^5.0.8", "@ethersproject/abstract-provider": "^5.0.8",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment