2021-02-12 11:53:17 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-10-23 09:49:33 +00:00
|
|
|
|
2022-11-14 12:15:00 +00:00
|
|
|
echo "Running bin/deposit.sh"
|
|
|
|
|
2021-02-26 15:06:36 +00:00
|
|
|
# Source env settings
|
2020-10-23 09:49:33 +00:00
|
|
|
. .env
|
|
|
|
. services/ir/.ir.env
|
2022-06-10 08:32:20 +00:00
|
|
|
source bin/helper.sh
|
2020-10-23 09:49:33 +00:00
|
|
|
|
|
|
|
# NeoGo binary path.
|
2022-11-14 12:15:00 +00:00
|
|
|
NEOGO="${NEOGO:-docker exec main_chain neo-go}"
|
2020-10-23 09:49:33 +00:00
|
|
|
# Wallet file to use for deposit GAS from
|
2022-11-14 12:15:00 +00:00
|
|
|
WALLET="${WALLET:-services/chain/node-wallet.json}"
|
|
|
|
CONFIG="${CONFIG:-/wallets/config.yml}"
|
2020-10-23 09:49:33 +00:00
|
|
|
# How much GAS to deposit. First cli argument or 50 by default
|
|
|
|
DEPOSIT="${1:-50}"
|
|
|
|
|
|
|
|
# Internal variables
|
2022-06-10 08:32:20 +00:00
|
|
|
ADDR=$(jq -r .accounts[0].address < "${WALLET}" \
|
|
|
|
|| die "Cannot get address from wallet: ${WALLET}")
|
|
|
|
CONTRACT_ADDR=$(${NEOGO} util convert "${NEOFS_IR_CONTRACTS_NEOFS}" \
|
|
|
|
| grep 'LE ScriptHash to Address' \
|
|
|
|
| awk '{print $5}' \
|
|
|
|
| grep -oP "[A-z0-9]+" \
|
|
|
|
|| die "Cannot parse contract address: ${NEOFS_IR_CONTRACTS_NEOFS}")
|
2020-10-23 09:49:33 +00:00
|
|
|
|
|
|
|
# Make deposit
|
2022-06-10 08:32:20 +00:00
|
|
|
# shellcheck disable=SC2086
|
2022-11-14 12:15:00 +00:00
|
|
|
${NEOGO} wallet nep17 transfer \
|
|
|
|
--wallet-config ${CONFIG} \
|
2022-06-10 08:32:20 +00:00
|
|
|
-r http://main-chain.${LOCAL_DOMAIN}:30333 \
|
2022-11-14 12:15:00 +00:00
|
|
|
--from ${ADDR} --force \
|
2022-06-10 08:32:20 +00:00
|
|
|
--to ${CONTRACT_ADDR} \
|
|
|
|
--token GAS \
|
2022-12-21 12:34:14 +00:00
|
|
|
--amount ${DEPOSIT} || die "Cannot transfer GAS to FrostFS contract"
|