2024-12-16 18:53:52 +00:00
set -eu
echo "Loading Keyfork by mnemonic"
export KEYFORKD_SOCKET_PATH = /tmp/keyforkd.sock
( keyfork recover mnemonic & )
while test ! -e $KEYFORKD_SOCKET_PATH ; do sleep 1; done
echo "Waiting for inputs from online system..."
while test ! -f /data/input.json; do sleep 1; done
from_address = " $( jq -r .from_address /data/input.json) "
to_address = " $( jq -r .to_address /data/input.json) "
token_name = " $( jq -r .token_name /data/input.json) "
token_amount = " $( jq -r .token_amount /data/input.json) "
blockhash = " $( jq -r .blockhash /data/input.json) "
2024-12-17 20:32:28 +00:00
token_address = " $( icepick sol get-token-info " $token_name " | jq -r .blob.token_address) "
token_decimals = " $( icepick sol get-token-info " $token_name " | jq -r .blob.token_decimals) "
2024-12-16 18:53:52 +00:00
jq . /data/input.json
2024-12-16 18:56:34 +00:00
echo "Do these values look correct? If not, press ctrl-c. Otherwise, press Enter."
2024-12-16 18:53:52 +00:00
read _
echo "Creating and signing transaction"
2024-12-17 20:16:13 +00:00
icepick sol transfer-token " $token_amount " " $token_address " " $to_address " " $from_address " " $token_decimals " | icepick sol sign " $blockhash " > /data/output.json.tmp
2024-12-16 21:26:29 +00:00
mv /data/output.json.tmp /data/output.json