chore: sync all changes to Gitea
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- Config, docs, scripts, and backup manifests - Submodule refs unchanged (m = modified content in submodules) Made-with: Cursor
This commit is contained in:
51
scripts/truth-network/README.md
Normal file
51
scripts/truth-network/README.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Truth Network scripts
|
||||
|
||||
Scripts for deploying and registering Truth Network (TRUU) with Chain 138’s ChainRegistry and for fetching chain constants/ABIs.
|
||||
|
||||
## Environment
|
||||
|
||||
Set in `smom-dbis-138/.env` or repo `.env`:
|
||||
|
||||
- `RPC_URL_138` – Chain 138 RPC URL
|
||||
- `PRIVATE_KEY` – deployer key (no `0x` prefix)
|
||||
- `CHAIN_REGISTRY_ADDRESS_138` – ChainRegistry proxy on Chain 138 (set by one-shot deploy)
|
||||
- `TRUTH_ADAPTER_ADDRESS_138` – TruthNetworkAdapter on Chain 138 (set after deploying adapter)
|
||||
|
||||
## One-shot deploy and register
|
||||
|
||||
From repo root:
|
||||
|
||||
```bash
|
||||
./scripts/truth-network/deploy-chain-registry-and-truth.sh
|
||||
```
|
||||
|
||||
This will:
|
||||
|
||||
1. Deploy `ChainRegistry` on Chain 138 if `CHAIN_REGISTRY_ADDRESS_138` is not set, and append it to `smom-dbis-138/.env`.
|
||||
2. Deploy `TruthNetworkAdapter` and register Truth Network in ChainRegistry.
|
||||
|
||||
If the TruthNetworkAdapter step fails with “Could not parse deployed address”, Forge is running in dry-run (e.g. in CI/sandbox). Run the broadcast from your own terminal:
|
||||
|
||||
```bash
|
||||
cd smom-dbis-138 && forge create contracts/registry/TruthNetworkAdapter.sol:TruthNetworkAdapter \
|
||||
--rpc-url "$RPC_URL_138" --private-key "$PRIVATE_KEY" \
|
||||
--constructor-args 0x50c02710b06d6AdDb864D6b038010eF6fA1BCd92 \
|
||||
--with-gas-price 1000000000 --legacy --broadcast
|
||||
```
|
||||
|
||||
Then set `TRUTH_ADAPTER_ADDRESS_138` in `smom-dbis-138/.env` to the “Deployed to: 0x…” address and run only the register step:
|
||||
|
||||
```bash
|
||||
./scripts/truth-network/deploy-and-register-truth-on-chain138.sh --register-only
|
||||
```
|
||||
|
||||
## Other scripts
|
||||
|
||||
- **`deploy-and-register-truth-on-chain138.sh`** – Deploy TruthNetworkAdapter (if needed) and register Truth in ChainRegistry. Use `--register-only` to skip deploy.
|
||||
- **`register-truth-in-chain-registry.sh`** – Register Truth in ChainRegistry only (requires `TRUTH_ADAPTER_ADDRESS_138`).
|
||||
- **`fetch-truth-chain-constants.sh`** – Fetch Truth Network chain constants (WSS) into `config/truth-chain-constants.json`.
|
||||
- **`fetch-etherscan-abi.sh`** – Fetch verified ABIs for Truth Bridge and TRUU token from Etherscan.
|
||||
|
||||
## References
|
||||
|
||||
- `docs/07-ccip/TRUTH_NETWORK_BRIDGE_SPEC.md` – Bridge and integration spec.
|
||||
63
scripts/truth-network/deploy-and-register-truth-on-chain138.sh
Executable file
63
scripts/truth-network/deploy-and-register-truth-on-chain138.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# Deploy TruthNetworkAdapter on Chain 138 and register Truth in ChainRegistry.
|
||||
# Requires: RPC_URL_138, PRIVATE_KEY, CHAIN_REGISTRY_ADDRESS_138 in smom-dbis-138/.env or repo .env.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
SMOM="$REPO_ROOT/smom-dbis-138"
|
||||
REGISTER_ONLY="${1:-}"
|
||||
|
||||
if [[ -f "$SMOM/.env" ]]; then
|
||||
set -a
|
||||
source "$SMOM/.env"
|
||||
set +a
|
||||
elif [[ -f "$REPO_ROOT/.env" ]]; then
|
||||
set -a
|
||||
source "$REPO_ROOT/.env"
|
||||
set +a
|
||||
fi
|
||||
|
||||
RPC="${RPC_URL_138:-${CHAIN_138_RPC_URL:-}}"
|
||||
KEY="${PRIVATE_KEY:-}"
|
||||
REGISTRY="${CHAIN_REGISTRY_ADDRESS_138:-${CHAIN_REGISTRY_ADDRESS:-}}"
|
||||
ADAPTER="${TRUTH_ADAPTER_ADDRESS_138:-}"
|
||||
ETH_BRIDGE="0x50c02710b06d6AdDb864D6b038010eF6fA1BCd92"
|
||||
|
||||
if [[ -z "$RPC" ]]; then echo "Error: RPC_URL_138 not set."; exit 1; fi
|
||||
if [[ -z "$KEY" ]]; then echo "Error: PRIVATE_KEY not set."; exit 1; fi
|
||||
if [[ -z "$REGISTRY" ]]; then echo "Error: CHAIN_REGISTRY_ADDRESS_138 not set."; exit 1; fi
|
||||
|
||||
if [[ "$REGISTER_ONLY" != "--register-only" ]] && [[ -z "$ADAPTER" ]]; then
|
||||
echo "Deploying TruthNetworkAdapter on Chain 138..."
|
||||
cd "$SMOM"
|
||||
set +e
|
||||
FORGE_OUT="$SMOM/.forge-create-truth-adapter.log"
|
||||
forge create contracts/registry/TruthNetworkAdapter.sol:TruthNetworkAdapter \
|
||||
--rpc-url "$RPC" \
|
||||
--private-key "$KEY" \
|
||||
--constructor-args "$ETH_BRIDGE" \
|
||||
--with-gas-price 1000000000 \
|
||||
--legacy \
|
||||
--broadcast > "$FORGE_OUT" 2>&1
|
||||
OUT=$(cat "$FORGE_OUT" 2>/dev/null || true)
|
||||
set -e
|
||||
ADAPTER=$(echo "$OUT" | grep -i "deployed to:" | grep -oE "0x[a-fA-F0-9]{40}" | head -1) || true
|
||||
if [[ -z "$ADAPTER" ]]; then
|
||||
echo "Could not parse deployed address (forge may have run in dry-run). See $FORGE_OUT"
|
||||
tail -20 "$FORGE_OUT" 2>/dev/null || true
|
||||
echo ""
|
||||
echo "Run from your terminal to broadcast: cd $SMOM && forge create contracts/registry/TruthNetworkAdapter.sol:TruthNetworkAdapter --rpc-url \$RPC_URL_138 --private-key \$PRIVATE_KEY --constructor-args 0x50c02710b06d6AdDb864D6b038010eF6fA1BCd92 --with-gas-price 1000000000 --legacy --broadcast"
|
||||
exit 1
|
||||
fi
|
||||
echo "Deployed TruthNetworkAdapter at $ADAPTER"
|
||||
grep -q "TRUTH_ADAPTER_ADDRESS_138=" "$SMOM/.env" 2>/dev/null || echo "TRUTH_ADAPTER_ADDRESS_138=$ADAPTER" >> "$SMOM/.env"
|
||||
export TRUTH_ADAPTER_ADDRESS_138="$ADAPTER"
|
||||
fi
|
||||
|
||||
[[ -z "$ADAPTER" ]] && { echo "Error: TRUTH_ADAPTER_ADDRESS_138 not set."; exit 1; }
|
||||
export RPC_URL_138="$RPC"
|
||||
export CHAIN_REGISTRY_ADDRESS_138="$REGISTRY"
|
||||
export TRUTH_ADAPTER_ADDRESS_138="$ADAPTER"
|
||||
export PRIVATE_KEY="$KEY"
|
||||
"$SCRIPT_DIR/register-truth-in-chain-registry.sh"
|
||||
62
scripts/truth-network/deploy-chain-registry-and-truth.sh
Executable file
62
scripts/truth-network/deploy-chain-registry-and-truth.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# 1) Deploy ChainRegistry (if CHAIN_REGISTRY_ADDRESS_138 not set). 2) Deploy TruthNetworkAdapter and register Truth.
|
||||
# Requires: RPC_URL_138, PRIVATE_KEY in smom-dbis-138/.env or repo .env.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
SMOM="$REPO_ROOT/smom-dbis-138"
|
||||
|
||||
if [[ -f "$SMOM/.env" ]]; then
|
||||
set -a
|
||||
source "$SMOM/.env"
|
||||
set +a
|
||||
elif [[ -f "$REPO_ROOT/.env" ]]; then
|
||||
set -a
|
||||
source "$REPO_ROOT/.env"
|
||||
set +a
|
||||
fi
|
||||
|
||||
RPC="${RPC_URL_138:-${CHAIN_138_RPC_URL:-}}"
|
||||
KEY="${PRIVATE_KEY:-}"
|
||||
REGISTRY="${CHAIN_REGISTRY_ADDRESS_138:-${CHAIN_REGISTRY_ADDRESS:-}}"
|
||||
|
||||
if [[ -z "$RPC" ]] || [[ -z "$KEY" ]]; then
|
||||
echo "Error: RPC_URL_138 and PRIVATE_KEY required. Set in smom-dbis-138/.env or repo .env."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$REGISTRY" ]]; then
|
||||
echo "Deploying ChainRegistry on Chain 138..."
|
||||
cd "$SMOM"
|
||||
OUT=$(forge script script/deploy/DeployChainRegistry.s.sol:DeployChainRegistry \
|
||||
--rpc-url "$RPC" \
|
||||
--broadcast \
|
||||
--private-key "$KEY" \
|
||||
--with-gas-price 1000000000 \
|
||||
-vvv 2>&1)
|
||||
REGISTRY=$(echo "$OUT" | grep "CHAIN_REGISTRY_ADDRESS_138" | grep -oE "0x[a-fA-F0-9]{40}" | head -1)
|
||||
if [[ -z "$REGISTRY" ]]; then
|
||||
REGISTRY=$(echo "$OUT" | grep -oE "0x[a-fA-F0-9]{40}" | tail -1)
|
||||
fi
|
||||
if [[ -z "$REGISTRY" ]]; then
|
||||
echo "Could not parse ChainRegistry address."; echo "$OUT" | tail -50; exit 1
|
||||
fi
|
||||
echo "ChainRegistry deployed at $REGISTRY"
|
||||
export CHAIN_REGISTRY_ADDRESS_138="$REGISTRY"
|
||||
if [[ -f "$SMOM/.env" ]]; then
|
||||
if ! grep -q "CHAIN_REGISTRY_ADDRESS_138=" "$SMOM/.env" 2>/dev/null; then
|
||||
echo "" >> "$SMOM/.env"
|
||||
echo "CHAIN_REGISTRY_ADDRESS_138=$REGISTRY" >> "$SMOM/.env"
|
||||
echo "Appended CHAIN_REGISTRY_ADDRESS_138 to $SMOM/.env"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
export CHAIN_REGISTRY_ADDRESS_138="$REGISTRY"
|
||||
echo "Using existing CHAIN_REGISTRY_ADDRESS_138=$REGISTRY"
|
||||
fi
|
||||
|
||||
export RPC_URL_138="$RPC"
|
||||
export PRIVATE_KEY="$KEY"
|
||||
"$SCRIPT_DIR/deploy-and-register-truth-on-chain138.sh"
|
||||
echo "Done: ChainRegistry and Truth Network registration complete."
|
||||
13
scripts/truth-network/package.json
Normal file
13
scripts/truth-network/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "truth-network",
|
||||
"version": "1.0.0",
|
||||
"description": "Scripts for Truth Network (TRUU) bridge integration. See [docs/07-ccip/TRUTH_NETWORK_BRIDGE_SPEC.md](../../docs/07-ccip/TRUTH_NETWORK_BRIDGE_SPEC.md).",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs"
|
||||
}
|
||||
51
scripts/truth-network/register-truth-in-chain-registry.sh
Executable file
51
scripts/truth-network/register-truth-in-chain-registry.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Register Truth Network as non-EVM chain in ChainRegistry (on Chain 138).
|
||||
# Env: RPC_URL_138, CHAIN_REGISTRY_ADDRESS_138, TRUTH_ADAPTER_ADDRESS_138, PRIVATE_KEY
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
[[ -f "${SCRIPT_DIR}/../lib/load-project-env.sh" ]] && source "${SCRIPT_DIR}/../lib/load-project-env.sh" 2>/dev/null || true
|
||||
|
||||
RPC="${RPC_URL_138:-${CHAIN_138_RPC_URL:-https://rpc-core.d-bis.org}}"
|
||||
REGISTRY="${CHAIN_REGISTRY_ADDRESS_138:-${CHAIN_REGISTRY_ADDRESS:-}}"
|
||||
ADAPTER="${TRUTH_ADAPTER_ADDRESS_138:-}"
|
||||
KEY="${PRIVATE_KEY:-}"
|
||||
CHAIN_TYPE=15
|
||||
CHAIN_IDENTIFIER="truth-network"
|
||||
EXPLORER_URL="https://truth-network.io"
|
||||
MIN_CONFIRMATIONS=1
|
||||
AVG_BLOCK_TIME=6
|
||||
REQUIRES_ORACLE=true
|
||||
ADDITIONAL_DATA="0x"
|
||||
|
||||
if [[ -z "$REGISTRY" ]]; then
|
||||
echo "CHAIN_REGISTRY_ADDRESS_138 or CHAIN_REGISTRY_ADDRESS not set."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$ADAPTER" ]]; then
|
||||
echo "TRUTH_ADAPTER_ADDRESS_138 not set. Deploy TruthNetworkAdapter first."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$KEY" ]]; then
|
||||
echo "PRIVATE_KEY not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Registering Truth Network in ChainRegistry at $REGISTRY (Chain 138)..."
|
||||
cast send "$REGISTRY" \
|
||||
"registerNonEVMChain(string,uint8,address,string,uint256,uint256,bool,bytes)" \
|
||||
"$CHAIN_IDENTIFIER" \
|
||||
"$CHAIN_TYPE" \
|
||||
"$ADAPTER" \
|
||||
"$EXPLORER_URL" \
|
||||
"$MIN_CONFIRMATIONS" \
|
||||
"$AVG_BLOCK_TIME" \
|
||||
"$REQUIRES_ORACLE" \
|
||||
"$ADDITIONAL_DATA" \
|
||||
--rpc-url "$RPC" \
|
||||
--private-key "$KEY" \
|
||||
--gas-price 1000000000 \
|
||||
--gas-limit 500000
|
||||
|
||||
echo "Done. Truth Network registered as $CHAIN_IDENTIFIER with adapter $ADAPTER."
|
||||
Reference in New Issue
Block a user