diff --git a/initShyftGeth.sh b/shyft-cli/initShyftGeth.sh similarity index 62% rename from initShyftGeth.sh rename to shyft-cli/initShyftGeth.sh index c6a8d115e1..222a23e052 100755 --- a/initShyftGeth.sh +++ b/shyft-cli/initShyftGeth.sh @@ -1,2 +1,2 @@ #!/bin/sh -./build/bin/geth --identity "ShyftTestnetNode" --keystore ./ --datadir "./shyftData" init ShyftNetwork.json \ No newline at end of file +./build/bin/geth --identity "ShyftTestnetNode" --keystore ./ --datadir "./shyftData" init ShyftNetwork.json diff --git a/shyftDb/postgres_setup/create_shyftdb.psql b/shyft-cli/postgres_setup/create_shyftdb.psql similarity index 100% rename from shyftDb/postgres_setup/create_shyftdb.psql rename to shyft-cli/postgres_setup/create_shyftdb.psql diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql similarity index 100% rename from shyftDb/postgres_setup/create_tables.psql rename to shyft-cli/postgres_setup/create_tables.psql diff --git a/shyftDb/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql similarity index 100% rename from shyftDb/postgres_setup/drop_tables.psql rename to shyft-cli/postgres_setup/drop_tables.psql diff --git a/shyftDb/postgres_setup/drop_tables.sh b/shyft-cli/postgres_setup/drop_tables.sh similarity index 52% rename from shyftDb/postgres_setup/drop_tables.sh rename to shyft-cli/postgres_setup/drop_tables.sh index 576637538a..b0d91aa52e 100644 --- a/shyftDb/postgres_setup/drop_tables.sh +++ b/shyft-cli/postgres_setup/drop_tables.sh @@ -1 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup psql -U postgres -d shyftdb -f drop_tables.psql \ No newline at end of file diff --git a/shyftDb/postgres_setup/init_tables.sh b/shyft-cli/postgres_setup/init_tables.sh similarity index 53% rename from shyftDb/postgres_setup/init_tables.sh rename to shyft-cli/postgres_setup/init_tables.sh index 988ad56700..50dfb4e695 100644 --- a/shyftDb/postgres_setup/init_tables.sh +++ b/shyft-cli/postgres_setup/init_tables.sh @@ -1 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup psql -U postgres -d shyftdb -f create_tables.psql diff --git a/shyft-cli/postgres_setup/initdb.sh b/shyft-cli/postgres_setup/initdb.sh new file mode 100644 index 0000000000..de2cf1c295 --- /dev/null +++ b/shyft-cli/postgres_setup/initdb.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd ./shyft-cli/postgres_setup +psql -U postgres -f create_shyftdb.psql diff --git a/resetShyftGeth.sh b/shyft-cli/resetShyftGeth.sh similarity index 100% rename from resetShyftGeth.sh rename to shyft-cli/resetShyftGeth.sh diff --git a/run_js_in_geth.sh b/shyft-cli/runJs.sh similarity index 80% rename from run_js_in_geth.sh rename to shyft-cli/runJs.sh index b4a6649154..5c7f3e4fbd 100644 --- a/run_js_in_geth.sh +++ b/shyft-cli/runJs.sh @@ -1,4 +1,4 @@ file=$1 -echo $file +echo Executing "${file}"... runthing="./build/bin/geth --exec 'loadScript(\""$file"\")' attach http://127.0.0.1:8545" eval $runthing diff --git a/shyft-cli/setup.sh b/shyft-cli/setup.sh new file mode 100644 index 0000000000..dfb23704ee --- /dev/null +++ b/shyft-cli/setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then # Check if db is instantiated + echo Creating postgres db... + sh ./shyft-cli/postgres_setup/initdb.sh && # Init DB + echo Successfully created postgres db! && + sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables + sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data + sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth +else + echo Postgres DB found! + sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables + sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables + sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data + sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth +fi + diff --git a/shyft-cli/shyftFullReset.sh b/shyft-cli/shyftFullReset.sh new file mode 100644 index 0000000000..5dc4563468 --- /dev/null +++ b/shyft-cli/shyftFullReset.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if ! psql -lqt | cut -d \| -f 1 | grep -qw shyftdb; then + echo Creating postgres db... + sh ./shyft-cli/postgres_setup/initdb.sh && + echo Successfully created postgres db! +fi + +sh ./shyft-cli/postgres_setup/drop_tables.sh && # Drop tables +sh ./shyft-cli/postgres_setup/init_tables.sh && # Init tables +sh ./shyft-cli/resetShyftGeth.sh && # Reset geth data +sh ./shyft-cli/initShyftGeth.sh # Init Shyft Geth \ No newline at end of file diff --git a/startShyftGeth.sh b/shyft-cli/startShyftGeth.sh similarity index 100% rename from startShyftGeth.sh rename to shyft-cli/startShyftGeth.sh diff --git a/simulations/checkbalances.js b/shyft-cli/web3/checkbalances.js similarity index 100% rename from simulations/checkbalances.js rename to shyft-cli/web3/checkbalances.js diff --git a/simulations/deployContract.js b/shyft-cli/web3/deployContract.js similarity index 100% rename from simulations/deployContract.js rename to shyft-cli/web3/deployContract.js diff --git a/simulations/getGreeting.js b/shyft-cli/web3/getGreeting.js similarity index 100% rename from simulations/getGreeting.js rename to shyft-cli/web3/getGreeting.js diff --git a/simulations/sendTransactions.js b/shyft-cli/web3/sendTransactions.js similarity index 100% rename from simulations/sendTransactions.js rename to shyft-cli/web3/sendTransactions.js diff --git a/simulations/token_test/README.md b/shyft-cli/web3/token_test/README.md similarity index 100% rename from simulations/token_test/README.md rename to shyft-cli/web3/token_test/README.md diff --git a/simulations/token_test/callGreeterFnsTest.js b/shyft-cli/web3/token_test/callGreeterFnsTest.js similarity index 100% rename from simulations/token_test/callGreeterFnsTest.js rename to shyft-cli/web3/token_test/callGreeterFnsTest.js diff --git a/simulations/token_test/call_greeter_fns.js b/shyft-cli/web3/token_test/call_greeter_fns.js similarity index 100% rename from simulations/token_test/call_greeter_fns.js rename to shyft-cli/web3/token_test/call_greeter_fns.js diff --git a/simulations/token_test/calltx.js b/shyft-cli/web3/token_test/calltx.js similarity index 100% rename from simulations/token_test/calltx.js rename to shyft-cli/web3/token_test/calltx.js diff --git a/simulations/token_test/deploy.js b/shyft-cli/web3/token_test/deploy.js similarity index 100% rename from simulations/token_test/deploy.js rename to shyft-cli/web3/token_test/deploy.js diff --git a/simulations/token_test/deploy_greeter_contracts.js b/shyft-cli/web3/token_test/deploy_greeter_contracts.js similarity index 100% rename from simulations/token_test/deploy_greeter_contracts.js rename to shyft-cli/web3/token_test/deploy_greeter_contracts.js diff --git a/simulations/token_test/package.json b/shyft-cli/web3/token_test/package.json similarity index 100% rename from simulations/token_test/package.json rename to shyft-cli/web3/token_test/package.json diff --git a/simulations/token_test/token.sol b/shyft-cli/web3/token_test/token.sol similarity index 100% rename from simulations/token_test/token.sol rename to shyft-cli/web3/token_test/token.sol diff --git a/shyft-geth.sh b/shyft-geth.sh new file mode 100755 index 0000000000..5104f01844 --- /dev/null +++ b/shyft-geth.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +illegalCommands=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + --setup) + sh ./shyft-cli/setup.sh + shift # past argument + ;; + --start) + sh ./shyft-cli/startShyftGeth.sh + shift # past argument + ;; + --js) + sh ./shyft-cli/runJs.sh ./shyft-cli/web3/$2 + shift # past argument + shift # past argument + ;; + --reset) + sh ./shyft-cli/shyftFullReset.sh + shift # past argument + ;; + *) # unknown option + illegalCommands+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done + +if [[ "${#illegalCommands[@]}" -gt "0" ]] ; then + echo The following commands are not supported: "${illegalCommands[*]}" +fi + diff --git a/shyftDb/postgres_setup/initdb.sh b/shyftDb/postgres_setup/initdb.sh deleted file mode 100644 index 1fb7d829c5..0000000000 --- a/shyftDb/postgres_setup/initdb.sh +++ /dev/null @@ -1 +0,0 @@ -psql -U postgres -f create_shyftdb.psql diff --git a/shyftFullReset.sh b/shyftFullReset.sh deleted file mode 100644 index 6fbcbc1683..0000000000 --- a/shyftFullReset.sh +++ /dev/null @@ -1,5 +0,0 @@ -cd ./shyftDb/postgres_setup -sh drop_tables.sh && sh init_tables.sh -cd .. -cd .. -sh resetShyftGeth.sh && sh initShyftGeth.sh \ No newline at end of file