Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Adds error messages (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmcmichael authored Sep 10, 2020
1 parent eaac994 commit 22b949f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions libexec/mcd/mcd
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ config-init() {
for e in $exports; do export "$e"; done
}

rpc-verify() {
if test -z "$ETH_RPC_URL"
then
echo "Please set the ETH_RPC_URL to an ethereum endpoint."
exit 1
fi
}

chain-verify() {
EXPECTED="$1"
ACTUAL="$(seth rpc net_version)"
if [ "$EXPECTED" != "$ACTUAL" ]; then
echo "Ethereum network version is incorrect."
echo "Verify ETH_RPC_URL is set to $MCD_CHAIN (Expected $EXPECTED, got $ACTUAL)"
exit 1
fi
}

mcd-init() {
# If MCD_CHAIN is unset but SETH_CHAIN is, set to SETH_CHAIN
if [ -z "$MCD_CHAIN" ]; then MCD_CHAIN="$SETH_CHAIN"; fi
Expand All @@ -100,10 +118,14 @@ mcd-init() {
mainnet)
config-init "${0%/*}/conf/mainnet.json";
export SETH_CHAIN=mainnet
rpc-verify
chain-verify "1"
;;
kovan)
config-init "${0%/*}/conf/kovan.json";
export SETH_CHAIN=kovan
rpc-verify
chain-verify "42"
;;
testnet) # local dapp testnet
config-init "${MCD_CONFIG:-$TESTNET/8545/config/addresses.json}"
Expand Down Expand Up @@ -137,10 +159,4 @@ if ! [[ $MCD_INIT ]]; then
mcd-init
fi

if test -z "$ETH_RPC_URL"
then
echo "Please set the ETH_RPC_URL to an ethereum endpoint."
exit 1
fi

"${0##*/}-${1-help}" "${@:2}"
2 changes: 1 addition & 1 deletion libexec/mcd/mcd-ilks
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ else
writeData
fi

awk -F'|' '{printf "%-8s %8s %5s %s\n", $1, $2, $3, $4}' "$FILEPATH"
awk -F'|' '{printf "%-9s %8s %5s %s\n", $1, $2, $3, $4}' "$FILEPATH"

0 comments on commit 22b949f

Please sign in to comment.