#70 automating password input to neo-go commands

Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
anastasia prasolova 2021-06-01 21:18:46 +03:00 committed by Alex Vanin
parent 4a6d304b8f
commit d0094d8068
3 changed files with 25 additions and 4 deletions

View file

@ -7,9 +7,11 @@
# NeoGo binary path.
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
# Wallet files to change config value
# Wallet files to change config value
WALLET="${WALLET:-services/chain/node-wallet.json}"
WALLET_IMG="${WALLET_IMG:-wallets/node-wallet.json}"
# Wallet password that would be entered automatically; '-' means no password
PASSWD="one"
# NeoFS configuration record: key is a string and value is an int
KEY=${1}
@ -23,7 +25,7 @@ ADDR=`cat ${WALLET} | jq -r .accounts[2].address`
# Change config value in side chain
echo "Changing ${KEY} configration value to ${VALUE}"
${NEOGO} contract invokefunction \
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
-w ${WALLET_IMG} \
-a ${ADDR} \
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
@ -40,7 +42,7 @@ epoch | grep 'value' | awk -F'"' '{ print $4 }'`
# Update epoch to apply new configuartion value
echo "Updating NeoFS epoch to $((EPOCH+1))"
${NEOGO} contract invokefunction \
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
-w ${WALLET_IMG} \
-a ${ADDR} \
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \

View file

@ -8,6 +8,8 @@
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
# Wallet file to use for deposit GAS from
WALLET="${WALLET:-wallets/wallet.json}"
# Wallet password that would be entered automatically; '-' means no password
PASSWD="-"
# How much GAS to deposit. First cli argument or 50 by default
DEPOSIT="${1:-50}"
@ -16,7 +18,7 @@ ADDR=`cat ${WALLET} | jq -r .accounts[0].address`
CONTRACT_ADDR=`${NEOGO} util convert ${NEOFS_IR_CONTRACTS_NEOFS} | grep 'LE ScriptHash to Address' | awk '{print $5}' | grep -oP [A-z0-9]+`
# Make deposit
${NEOGO} wallet nep17 transfer \
./bin/passwd.exp ${PASSWD} ${NEOGO} wallet nep17 transfer \
-w ${WALLET} \
-r http://main_chain.${LOCAL_DOMAIN}:30333 \
--from ${ADDR} \

17
bin/passwd.exp Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/expect
set passwd [lindex $argv 0]
set args [lrange $argv 1 end]
spawn -noecho {*}$args
expect -re {^.*assword.*$}
if { $passwd == "-"} {
send -- "\r"
} else {
send -- "$passwd\r"
}
expect EOF
lassign [wait] pid spawnid os_error_flag value
exit $value