From c31fcd763905ab463d474c5f84d0a31b5dccba35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 6 Oct 2023 11:42:08 +0200 Subject: [PATCH] fill config variables that differ in environments from env vars --- bridge/cmd/bridge/config/config.toml | 10 +++--- bridge/cmd/bridge/entrypoint.sh | 49 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/bridge/cmd/bridge/config/config.toml b/bridge/cmd/bridge/config/config.toml index aa3f0cb..ca8e776 100644 --- a/bridge/cmd/bridge/config/config.toml +++ b/bridge/cmd/bridge/config/config.toml @@ -1,7 +1,7 @@ [Eth] Chain = "Ethereum" - NetworkAddress = "https://sepolia.infura.io/v3/fb44167f83e740898c90737b6ec456d8" # a network address - MultisigContractAddress = "0xe40E20514A67fB2E00213C8567070f690a03De3D" # the eth address for the bridge contract + NetworkAddress = "$ETH_NETWORK_ADDRESS" # a network address + MultisigContractAddress = "$ETH_CONTRACT_ADDRESS" # the eth address for the bridge contract SafeContractAddress = "0xC1056955eE4E81689Da6474F43284CfcF3a45317" PrivateKeyFile = "./wallets/ethereum/account-0.sk" # the path to the file containing the relayer eth private key GasLimitBase = 350000 @@ -22,8 +22,8 @@ GasPriceSelector = "SafeGasPrice" # selector used to provide the gas price [MultiversX] - NetworkAddress = "https://devnet-gateway.multiversx.com" # the network address - MultisigContractAddress = "erd1qqqqqqqqqqqqqpgqqquj96vuwnnwj2xarsrtdvdmazg7r3zu0z9qwa6jdk" # the multiversx address for the bridge contract + NetworkAddress = "$MVX_NETWORK_ADDRESS" # the network address + MultisigContractAddress = "$MVX_CONTRACT_ADDRESS" # the multiversx address for the bridge contract PrivateKeyFile = "./wallets/multiversx/account-0.pem" # the path to the pem file containing the relayer multiversx wallet IntervalToResendTxsInSeconds = 60 # the time in seconds between nonce reads MaxRetriesOnQuorumReached = 3 @@ -155,7 +155,7 @@ [BatchValidator] Enabled = false - URL = "https://devnet-bridge-api.multiversx.com/validateBatch" # batch validator URL. + URL = "$MVX_VALIDATOR_ADDRESS" # batch validator URL. RequestTimeInSeconds = 2 # maximum timeout (in seconds) for the batch validation request [PeersRatingConfig] diff --git a/bridge/cmd/bridge/entrypoint.sh b/bridge/cmd/bridge/entrypoint.sh index 71fd412..71ce7ef 100755 --- a/bridge/cmd/bridge/entrypoint.sh +++ b/bridge/cmd/bridge/entrypoint.sh @@ -2,12 +2,61 @@ echo "Writing keys to file system..." +if [ -z "$ETHER_KEY" ] +then + echo "\$ETHER_KEY is empty" + exit 1 +fi mkdir -p ./wallets/ethereum echo "$ETHER_KEY" > ./wallets/ethereum/account-0.sk +if [ -z "$MULTIVERSEX_KEY" ] +then + echo "\$MULTIVERSEX_KEY is empty" + exit 1 +fi mkdir -p ./wallets/multiversx echo "$MULTIVERSEX_KEY" > ./wallets/multiversx/account-0.pem + +echo "Injecting configuration values..." + +if [ -z "$ETH_NETWORK_ADDRESS" ] +then + echo "\$ETH_NETWORK_ADDRESS is empty" + exit 1 +fi +sed -i -e "s/\$ETH_NETWORK_ADDRESS/$ETH_NETWORK_ADDRESS/g" ./config/config.toml + +if [ -z "$ETH_CONTRACT_ADDRESS" ] +then + echo "\$ETH_CONTRACT_ADDRESS is empty" + exit 1 +fi +sed -i -e "s/\$ETH_CONTRACT_ADDRESS/$ETH_CONTRACT_ADDRESS/g" ./config/config.toml + +if [ -z "$MVX_NETWORK_ADDRESS" ] +then + echo "\$MVX_NETWORK_ADDRESS is empty" + exit 1 +fi +sed -i -e "s/\$MVX_NETWORK_ADDRESS/$MVX_NETWORK_ADDRESS/g" ./config/config.toml + +if [ -z "$MVX_CONTRACT_ADDRESS" ] +then + echo "\$MVX_CONTRACT_ADDRESS is empty" + exit 1 +fi +sed -i -e "s/\$MVX_CONTRACT_ADDRESS/$MVX_CONTRACT_ADDRESS/g" ./config/config.toml + +if [ -z "$MVX_VALIDATOR_ADDRESS" ] +then + echo "\$MVX_VALIDATOR_ADDRESS is empty" + exit 1 +fi +sed -i -e "s/\$MVX_VALIDATOR_ADDRESS/$MVX_VALIDATOR_ADDRESS/g" ./config/config.toml + + echo "Starting bridge..." ./bridge