- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
134 lines
5.3 KiB
Bash
134 lines
5.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Emit the non-secret gas-lane env scaffold from the active GRU transport config.
|
|
# Safe defaults:
|
|
# - per-lane caps come from config/gru-transport-active.json gasAssetFamilies[].perLaneCaps
|
|
# - on-chain canonical totalSupply() is used for outstanding/escrowed defaults when readable
|
|
# - treasuryBacked / treasuryCap default to 0 unless already provided by env
|
|
# - active gas verifier envs are intentionally left commented until the live L1 bridge is attached
|
|
#
|
|
# Usage:
|
|
# bash scripts/verify/print-gas-runtime-env-canonical.sh
|
|
# RPC_URL_138=http://192.168.11.211:8545 bash scripts/verify/print-gas-runtime-env-canonical.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
ACTIVE_JSON="$PROJECT_ROOT/config/gru-transport-active.json"
|
|
CONTRACTS_JSON="$PROJECT_ROOT/config/smart-contracts-master.json"
|
|
|
|
# shellcheck source=/dev/null
|
|
source "$PROJECT_ROOT/scripts/lib/load-project-env.sh" >/dev/null 2>&1 || true
|
|
|
|
need_cmd() {
|
|
command -v "$1" >/dev/null 2>&1 || {
|
|
echo "Missing required command: $1" >&2
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
need_cmd node
|
|
need_cmd cast
|
|
|
|
RPC_URL="${RPC_URL_138:-${RPC_URL_138_PUBLIC:-http://192.168.11.211:8545}}"
|
|
|
|
node_output="$(
|
|
node - <<'NODE' "$ACTIVE_JSON" "$CONTRACTS_JSON"
|
|
const fs = require('fs');
|
|
const activeFile = process.argv[2];
|
|
const contractsFile = process.argv[3];
|
|
const active = JSON.parse(fs.readFileSync(activeFile, 'utf8'));
|
|
const contracts = JSON.parse(fs.readFileSync(contractsFile, 'utf8'));
|
|
|
|
const familiesByKey = new Map();
|
|
for (const family of active.gasAssetFamilies || []) {
|
|
if (family && family.familyKey) familiesByKey.set(String(family.familyKey), family);
|
|
}
|
|
|
|
const deployedVerifier = contracts?.chains?.['138']?.contracts?.CWAssetReserveVerifier || '';
|
|
const pairs = (active.transportPairs || [])
|
|
.filter((pair) => pair && pair.assetClass === 'gas_native' && pair.active !== false)
|
|
.map((pair) => {
|
|
const family = familiesByKey.get(String(pair.familyKey || '')) || {};
|
|
const chainId = Number(pair.destinationChainId);
|
|
const cap = family?.perLaneCaps?.[String(chainId)] || '';
|
|
return {
|
|
key: pair.key,
|
|
familyKey: String(pair.familyKey || ''),
|
|
canonicalSymbol: String(pair.canonicalSymbol || ''),
|
|
destinationChainId: chainId,
|
|
maxOutstandingEnv: pair?.maxOutstanding?.env || '',
|
|
supplyAccounting: pair?.supplyAccounting || {},
|
|
reserveVerifierKey: pair?.reserveVerifierKey || '',
|
|
cap,
|
|
canonicalAddress: pair?.canonicalAddress || '',
|
|
};
|
|
});
|
|
|
|
process.stdout.write(JSON.stringify({ deployedVerifier, pairs }));
|
|
NODE
|
|
)"
|
|
|
|
echo "# Canonical gas-lane runtime env scaffold"
|
|
echo "# Generated from config/gru-transport-active.json plus live canonical totalSupply() on Chain 138."
|
|
echo "# Active gas verifier envs remain commented until the live L1 bridge is explicitly attached."
|
|
echo
|
|
|
|
chain138_l1_bridge="${CHAIN138_L1_BRIDGE:-${CW_L1_BRIDGE:-${CW_L1_BRIDGE_CHAIN138:-}}}"
|
|
asset_reserve_verifier="$(
|
|
node -e 'const data=JSON.parse(process.argv[1]); process.stdout.write(data.deployedVerifier || "");' "$node_output"
|
|
)"
|
|
|
|
if [[ -n "$chain138_l1_bridge" ]]; then
|
|
printf 'CHAIN138_L1_BRIDGE=%s\n' "$chain138_l1_bridge"
|
|
fi
|
|
if [[ -n "${CW_L1_BRIDGE_CHAIN138:-}" ]]; then
|
|
printf 'CW_L1_BRIDGE_CHAIN138=%s\n' "$CW_L1_BRIDGE_CHAIN138"
|
|
fi
|
|
if [[ -n "$asset_reserve_verifier" ]]; then
|
|
printf 'CW_ASSET_RESERVE_VERIFIER_DEPLOYED_CHAIN138=%s\n' "$asset_reserve_verifier"
|
|
printf '# CW_GAS_STRICT_ESCROW_VERIFIER_CHAIN138=%s\n' "$asset_reserve_verifier"
|
|
printf '# CW_GAS_HYBRID_CAP_VERIFIER_CHAIN138=%s\n' "$asset_reserve_verifier"
|
|
else
|
|
printf '# CW_GAS_STRICT_ESCROW_VERIFIER_CHAIN138=\n'
|
|
printf '# CW_GAS_HYBRID_CAP_VERIFIER_CHAIN138=\n'
|
|
fi
|
|
printf 'CW_GAS_ESCROW_VAULT_CHAIN138=%s\n' "${CW_GAS_ESCROW_VAULT_CHAIN138:-}"
|
|
printf 'CW_GAS_TREASURY_SYSTEM=%s\n' "${CW_GAS_TREASURY_SYSTEM:-}"
|
|
echo
|
|
|
|
while IFS='|' read -r canonical_address max_outstanding_env cap outstanding_env escrowed_env treasury_backed_env treasury_cap_env; do
|
|
[[ -n "$canonical_address" ]] || continue
|
|
|
|
total_supply="$(cast call "$canonical_address" 'totalSupply()(uint256)' --rpc-url "$RPC_URL" 2>/dev/null || printf '0')"
|
|
[[ "$total_supply" =~ ^[0-9]+$ ]] || total_supply=0
|
|
|
|
if [[ -n "$max_outstanding_env" && -n "$cap" ]]; then
|
|
printf '%s=%s\n' "$max_outstanding_env" "${!max_outstanding_env:-$cap}"
|
|
elif [[ -n "$max_outstanding_env" ]]; then
|
|
printf '%s=%s\n' "$max_outstanding_env" "${!max_outstanding_env:-}"
|
|
fi
|
|
|
|
[[ -n "$outstanding_env" ]] && printf '%s=%s\n' "$outstanding_env" "${!outstanding_env:-$total_supply}"
|
|
[[ -n "$escrowed_env" ]] && printf '%s=%s\n' "$escrowed_env" "${!escrowed_env:-$total_supply}"
|
|
[[ -n "$treasury_backed_env" ]] && printf '%s=%s\n' "$treasury_backed_env" "${!treasury_backed_env:-0}"
|
|
[[ -n "$treasury_cap_env" ]] && printf '%s=%s\n' "$treasury_cap_env" "${!treasury_cap_env:-0}"
|
|
echo
|
|
done < <(
|
|
node -e '
|
|
const data = JSON.parse(process.argv[1]);
|
|
for (const pair of data.pairs) {
|
|
const supply = pair.supplyAccounting || {};
|
|
console.log([
|
|
pair.canonicalAddress || "",
|
|
pair.maxOutstandingEnv || "",
|
|
pair.cap || "",
|
|
supply?.outstanding?.env || "",
|
|
supply?.escrowed?.env || "",
|
|
supply?.treasuryBacked?.env || "",
|
|
supply?.treasuryCap?.env || "",
|
|
].join("|"));
|
|
}
|
|
' "$node_output"
|
|
)
|