Skip to content
Snippets Groups Projects
Commit cab694f9 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Contract support moving into libbfa.sh

parent 015f88a3
No related branches found
No related tags found
No related merge requests found
...@@ -35,19 +35,28 @@ function cleanup ...@@ -35,19 +35,28 @@ function cleanup
function geth_attach function geth_attach
{ {
bfaconfig node bfaconfig node
geth --cache 0 "$@" attach ipc:${BFANODEDIR}/geth.ipc local cat=cat
if echo $- | grep -q x
then
cat="tee /dev/tty |"
fi
$cat | geth --cache 0 "$@" attach ipc:${BFANODEDIR}/geth.ipc
} }
function geth_exec_js function geth_exec_js
{ {
test -r "$1" test -r "$1"
geth_attach --exec "loadScript(\"$1\")" if echo $- | grep -q x
then
sed "s//input: /" "$1"
fi
geth_attach --exec "loadScript(\"$1\")" </dev/null
} }
function geth_exec function geth_exec
{ {
test -n "$1" test -n "$1"
geth_attach --exec "$1" geth_attach --exec "$1" </dev/null
} }
function geth_rpc function geth_rpc
...@@ -288,3 +297,36 @@ function gen_genesis ...@@ -288,3 +297,36 @@ function gen_genesis
} }
EOCONF EOCONF
} }
function contract
{
bfaconfig network
local contract="${BFANETWORKDIR}/contracts/${1}"
local realdir=$( realpath "${contract}" )
test -r "${realdir}"
local address=$( basename "${realdir}" )
test -n "${address}"
abi=$( cat ${contract}/abi )
test -n "${abi}"
echo "eth.contract(${abi}).at(\"${address}\")"
}
function contractCall
{
local name=$1
local func=$2
shift 2
echo "var contract = $( contract "${name}" );"
local args=
for x in $*
do
args="${args}, ${x}"
done
args="${args:1},"
if [ "$args" = "," ]
then
args=
fi
echo "contract.${func}.sendTransaction(${args} {from: eth.accounts[0], gas: 1000000} )"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment