Skip to content

Transfer Ownership

Transfer Ownership #2

name: Transfer Ownership
on:
workflow_dispatch:
inputs:
network:
description: 'Network'
required: true
type: choice
options:
- arbitrumSepolia
default: 'arbitrumSepolia'
new-owner:
description: 'New Owner Address (0x...)'
required: true
type: string
dry-run:
description: 'Dry Run (fork test only, no actual transfer)'
required: true
type: boolean
default: true
jobs:
pre-transfer:
uses: ./.github/workflows/main.yml
transfer-ownership:
needs: pre-transfer
runs-on: ubuntu-latest
environment: ${{ inputs.network }}
permissions:
contents: read
steps:
- name: Validate new owner address
run: |
if ! [[ "${{ inputs.new-owner }}" =~ ^0x[a-fA-F0-9]{40}$ ]]; then
echo "Error: Invalid Ethereum address format. Expected 0x followed by 40 hexadecimal characters."
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
- name: Set up Nodejs
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm' # Cache dependencies
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run fork test (dry run)
if: inputs.dry-run == true
env:
# Note: it is required to define both private key env variables when calling Hardhat.
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }}
NEW_OWNER: ${{ inputs.new-owner }}
run: |
echo "Running ownership transfer in fork test mode (dry run)..."
echo "Network: ${{ inputs.network }}"
echo "New Owner: ${{ inputs.new-owner }}"
if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
export ARBITRUM_SEPOLIA_FORK=true
elif [ "${{ inputs.network }}" == "arbitrum" ]; then
export ARBITRUM_FORK=true
fi
# Start the fork in the background
npx hardhat node --no-deploy > /dev/null 2>&1 &
HARDHAT_PID=$!
echo "Hardhat node started with PID $HARDHAT_PID"
# Wait for the node to be ready
sleep 10
# Run the transfer script on localhost (fork)
npx hardhat run scripts/transfer-ownership.ts --network localhost
# Kill the Hardhat node
kill $HARDHAT_PID || true
- name: Execute ownership transfer on live network
if: inputs.dry-run == false
env:
# Note: it is required to define both private key env variables when calling Hardhat.
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }}
RPC_URL: ${{ secrets.RPC_URL }}
NEW_OWNER: ${{ inputs.new-owner }}
run: |
echo "⚠️ WARNING: Executing LIVE ownership transfer!"
echo "Network: ${{ inputs.network }}"
echo "New Owner: ${{ inputs.new-owner }}"
echo "This action is IRREVERSIBLE. Proceeding in 5 seconds..."
sleep 5
npx hardhat run scripts/transfer-ownership.ts --network ${{ inputs.network }}
- name: Summary
if: always()
run: |
echo "## Ownership Transfer Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Network**: ${{ inputs.network }}" >> $GITHUB_STEP_SUMMARY
echo "- **New Owner**: \`${{ inputs.new-owner }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Mode**: ${{ inputs.dry-run == true && 'Dry Run (Fork Test)' || '🔴 LIVE EXECUTION' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.dry-run }}" == "false" ]; then
echo "### ⚠️ IMPORTANT" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Ownership has been transferred on **LIVE** network. Verify the new owner:" >> $GITHUB_STEP_SUMMARY
echo "- Diamond Proxy" >> $GITHUB_STEP_SUMMARY
echo "- App Registry" >> $GITHUB_STEP_SUMMARY
echo "- Dataset Registry" >> $GITHUB_STEP_SUMMARY
echo "- Workerpool Registry" >> $GITHUB_STEP_SUMMARY
fi