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

Transitioned scripts to libbfa.sh

parent 1893ff19
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# 20180626 Robert Martin-Legene <robert@nic.ar>
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/libbfa.sh ?" >&2; exit 1; fi
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
config node
bfaconfig node
geth attach ipc:${BFANODEDIR}/geth.ipc
#!/bin/bash
# 20180618 Robert Martin-Legene <robert@nic.ar>
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/libbfa.sh ?" >&2; exit 1; fi
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
function create
......@@ -29,7 +29,7 @@ var address = rcpt.contractAddress;
var pubcontract = mycontract.at(address);
console.log( pubcontract.address );
EOT
echo '*** Creating contract. Will take 16-30 seconds'
echo '*** Creating contract. This will take at least 16 seconds.'
outfile=$( geth_exec_js $js )
if [ ` wc -l < $outfile ` = 2 -a `tail -1 < $outfile` = "true" ]
then
......@@ -60,6 +60,6 @@ contractname=${filename%%.sol}
contractname=${contractname##*/}
contractname=${contractname##contract.}
contractname=${contractname%.*}
config max
bfaconfig max
prereq jq solc geth
create
#!/bin/bash
# 20180619 Robert Martin-Legene <robert@nic.ar>
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/libbfa.sh ?" >&2; exit 1; fi
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
config max
bfaconfig max
prereq tput
# rpcport is set per node, in a file. Default is port 8545.
rpcport=8545
......
#!/bin/bash
# $BFAHOME must point to a directory. Did you source $BFAHOME/bin/env ?
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
trap "echo Argh;exit 1" ERR
cd $( dirname $0 )
in=$1
test -n "$in" || in="Hello World!"
account=` ls -1dl node1/keystore/* | head -1 | sed 's/.*--//' `
test -n "$account"
contract=$( readlink contracts/TimestampDocument )
abi=$( cat contracts/${contract}/abi )
cleanup g1.js
cat > g1.js <<EOT
var mycontract = eth.contract(JSON.parse($abi))
var thecontract = mycontract.at("$contract");
console.log ( thecontract.storeDocument.sendTransaction( "${in}", {from: eth.accounts[0], gas: 1000000} ) )
contract=$1
text=$2
test -n "${contract}" ||
contract="TimestampDocument"
if [ ! -e "${contract}" -a -r "${BFANETWORKDIR}/contracts/${contract}" ]
then
contract=${BFANETWORKDIR}/contracts/${contract}
fi
test -L "${contract}" &&
contract=$( readlink "${contract}" )
test -n "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${contract}/abi )
test -n "${abi}"
test -n "$text" || text="Hello World!"
js=$( bfamktemp )
cat > $js <<EOT
var mycontract = eth.contract(JSON.parse(${abi}))
var thecontract = mycontract.at("${basecontract}");
console.log ( thecontract.storeDocument.sendTransaction( "${text}", {from: eth.accounts[0], gas: 1000000} ) )
EOT
cleanup out1
geth --datadir node1 --exec 'loadScript("g1.js")' attach ipc:node1/geth.ipc > out1
if [ ` wc -l < out1 ` = 2 -a `tail -1 < out1` = "true" ]
out=$( bfamktemp )
geth --datadir node1 --exec "loadScript(\"${js}\")" attach ipc:node1/geth.ipc > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
conf=` head -1 < out1 `
echo "Sent document in transaction ${conf}."
trans=` head -1 < ${out} `
echo "Sent document in transaction ${trans}."
else
cat g1.js
echo
echo ' ***'
echo
cat out1
(
cat ${js}
echo
echo ' ***'
echo
cat ${out}
) >&2
exit 1
fi
# This should only be sourced, not executed directly.
# 20180626 Robert Martin-Legene <robert@nic.ar>
fatal()
trap "echo Argh! ; exit 1" ERR
function fatal()
{
echo "$@" >&2
exit 1
}
trap "echo Argh! ; exit 1" ERR
trap "fatal Argh!" ERR
test "$( basename $SHELL 2>/dev/null )" = "bash" ||
fatal "This file must be source(d) from bash."
test "$( caller 2>/dev/null | awk '{print $1}' )" != "0" ||
......@@ -100,7 +102,7 @@ function account
test -n "$account"
}
function config
function bfaconfig
{
case "$1" in
network)
......
#!/bin/sh
#!/bin/bash
# $BFAHOME must point to a directory. Did you source $BFAHOME/bin/env ?
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
test -n "$1" ||
......
#!/bin/bash
# 20180619 Robert Martin-Legene <robert@nic.ar>
# $BFAHOME must point to a directory. Did you source $BFAHOME/bin/env ?
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
in=$1
test -n "$in" || in="Hello World!"
cd $( dirname $0 )
account=` ls -1dl node1/keystore/* | head -1 | sed 's/.*--//' `
test -n "$account"
contract=$( readlink contracts/TimestampDocument )
abi=$( cat contracts/${contract}/abi )
cleanup g1.js
cat > g1.js <<EOT
var mycontract = eth.contract(JSON.parse($abi))
var thecontract = mycontract.at("$contract");
console.log ( thecontract.checkDocument.call( "${in}" ) )
contract=$1
text=$2
test -n "${contract}" ||
contract="TimestampDocument"
if [ ! -e "${contract}" -a -r "${BFANETWORKDIR}/contracts/${contract}" ]
then
contract=${BFANETWORKDIR}/contracts/${contract}
fi
test -L "${contract}" &&
contract=$( readlink "${contract}" )
test -n "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${contract}/abi )
test -n "${abi}"
test -n "$text" || text="Hello World!"
js=$( bfamktemp )
cat > ${js} <<EOT
var mycontract = eth.contract(JSON.parse(${abi}))
var thecontract = mycontract.at("${basecontract}");
console.log ( thecontract.checkDocument.call( "${text}" ) )
EOT
cleanup out1
geth --datadir node1 --exec 'loadScript("g1.js")' attach ipc:node1/geth.ipc > out1
if [ ` wc -l < out1 ` = 2 -a `tail -1 < out1` = "true" ]
out=$( bfamktemp )
geth --datadir node1 --exec "loadScript(\"${js}\")" attach ipc:node1/geth.ipc > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
block=` head -1 < out1 `
if [ "$block" = "0" ]
block=` head -1 < $out `
if [ "${block}" -gt "0" ]
then
echo "The checksum of this document has not been stored in the smart contract (yet?)."
else
echo "Document first seen in block ${block}"
else
echo "The checksum of this document has not been stored in the smart contract (yet?)."
exit 1
fi
else
cat g1.js
echo
echo ' ***'
echo
cat out1
(
cat ${js}
echo
echo ' ***'
echo
cat ${out}
) >&2
fi
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