Expanded solutions (10 new industries) and products (Compliance & Data section) to cover full docs.lux.financial capability surface.
93 lines
2.7 KiB
Bash
Executable File
93 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
network="${1:-}"
|
|
state_dir="${2:-${HOME}/work/lux/state}"
|
|
|
|
if [[ -z "${network}" ]]; then
|
|
echo "usage: $0 <network> [state-dir]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo "jq is required to deploy tracked chains" >&2
|
|
exit 0
|
|
fi
|
|
|
|
if ! command -v lux >/dev/null 2>&1; then
|
|
echo "lux CLI not found; skipping tracked chain deploy" >&2
|
|
exit 0
|
|
fi
|
|
|
|
case "${network}" in
|
|
mainnet)
|
|
network_flag="--mainnet"
|
|
chain_dirs=("zoo-mainnet" "hanzo-mainnet" "spc-mainnet" "pars-mainnet")
|
|
;;
|
|
testnet)
|
|
network_flag="--testnet"
|
|
chain_dirs=("zoo-testnet" "hanzo-testnet" "spc-testnet" "pars-testnet")
|
|
;;
|
|
devnet)
|
|
network_flag="--devnet"
|
|
chain_dirs=("zoo-mainnet" "hanzo-mainnet" "spc-mainnet" "pars-mainnet")
|
|
;;
|
|
*)
|
|
echo "unsupported network: ${network}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "Ensuring tracked chains on ${network}: zoo, hanzo, spc, pars"
|
|
|
|
for chain_dir in "${chain_dirs[@]}"; do
|
|
config_dir="${state_dir}/chains/${chain_dir}"
|
|
sidecar_file="${config_dir}/sidecar.json"
|
|
genesis_file="${config_dir}/genesis.json"
|
|
|
|
if [[ ! -f "${sidecar_file}" || ! -f "${genesis_file}" ]]; then
|
|
echo " skip ${chain_dir} (missing sidecar/genesis in ${config_dir})"
|
|
continue
|
|
fi
|
|
|
|
chain_name="$(jq -r '.Name // empty' "${sidecar_file}" 2>/dev/null || true)"
|
|
if [[ -z "${chain_name}" ]]; then
|
|
echo " skip ${chain_dir} (invalid Name in sidecar)"
|
|
continue
|
|
fi
|
|
|
|
target_dir="${HOME}/.lux/chains/${chain_name}"
|
|
mkdir -p "${target_dir}"
|
|
cp "${genesis_file}" "${target_dir}/genesis.json"
|
|
# Normalize sidecar IDs for CLI compatibility before deploy.
|
|
# Some source sidecars use numeric ChainID placeholders (e.g. "200200"),
|
|
# but CLI migrations expect base58-form IDs.
|
|
jq '
|
|
.Chain = (.Chain // .Name) |
|
|
.Networks = (.Networks // {}) |
|
|
.ChainID = (
|
|
if (.ChainID | type != "string") or ((.ChainID | test("^[1-9A-HJ-NP-Za-km-z]{20,}$")) | not)
|
|
then "11111111111111111111111111111111LpoYY"
|
|
else .ChainID
|
|
end
|
|
) |
|
|
.BlockchainID = (
|
|
if (.BlockchainID | type != "string") or ((.BlockchainID | test("^[1-9A-HJ-NP-Za-km-z]{20,}$")) | not)
|
|
then "11111111111111111111111111111111LpoYY"
|
|
else .BlockchainID
|
|
end
|
|
)
|
|
' "${sidecar_file}" > "${target_dir}/sidecar.json"
|
|
if [[ -f "${config_dir}/chainspec.json" ]]; then
|
|
cp "${config_dir}/chainspec.json" "${target_dir}/chainspec.json"
|
|
fi
|
|
|
|
log_file="/tmp/lux-track-${network}-${chain_name}.log"
|
|
if RUN_E2E=true lux chain deploy "${chain_name}" "${network_flag}" >"${log_file}" 2>&1; then
|
|
echo " deploy ${chain_name}: ok"
|
|
else
|
|
tail -n 2 "${log_file}" 2>/dev/null | sed 's/^/ /' || true
|
|
echo " deploy ${chain_name}: skipped/failed"
|
|
fi
|
|
done
|