Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
138 lines
4.7 KiB
Bash
Executable File
138 lines
4.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test bridge transaction bypassing stuck nonce
|
|
set -euo pipefail
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
|
|
# Configuration
|
|
RPC_URL="http://192.168.11.211:8545"
|
|
DEPLOYER="0x4A666F96fC8764181194447A7dFdb7d471b301C8"
|
|
WETH9_ADDRESS="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
BRIDGE_ADDRESS="0x89dd12025bfCD38A168455A44B400e913ED33BE2"
|
|
TEST_AMOUNT="1000000000000000" # 0.001 ETH in wei
|
|
MAINNET_SELECTOR="5009297550715157269"
|
|
PRIVATE_KEY="${PRIVATE_KEY:-}"
|
|
|
|
if [ -z "$PRIVATE_KEY" ]; then
|
|
log_error "PRIVATE_KEY environment variable not set"
|
|
exit 1
|
|
fi
|
|
|
|
log_info "========================================"
|
|
log_info "Test Bridge with Fresh Nonce"
|
|
log_info "========================================"
|
|
echo ""
|
|
|
|
# Check connectivity
|
|
log_info "Checking RPC connectivity..."
|
|
if ! cast chain-id --rpc-url "$RPC_URL" >/dev/null 2>&1; then
|
|
log_error "RPC not accessible at $RPC_URL"
|
|
exit 1
|
|
fi
|
|
log_success "RPC is accessible"
|
|
|
|
# Get current nonce
|
|
log_info "Checking account nonce..."
|
|
CURRENT_NONCE=$(cast nonce "$DEPLOYER" --rpc-url "$RPC_URL")
|
|
log_info "Current nonce: $CURRENT_NONCE"
|
|
|
|
# Check balance
|
|
log_info "Checking ETH balance..."
|
|
ETH_BALANCE=$(cast balance "$DEPLOYER" --rpc-url "$RPC_URL" --ether)
|
|
log_info "ETH balance: $ETH_BALANCE ETH"
|
|
|
|
# Check WETH9 balance
|
|
log_info "Checking WETH9 balance..."
|
|
WETH9_BALANCE=$(cast call "$WETH9_ADDRESS" "balanceOf(address)(uint256)" "$DEPLOYER" --rpc-url "$RPC_URL")
|
|
WETH9_BALANCE_ETHER=$(cast --to-unit "$WETH9_BALANCE" ether 2>/dev/null || echo "0")
|
|
log_info "WETH9 balance: $WETH9_BALANCE_ETHER WETH9"
|
|
|
|
# If WETH9 balance is zero, wrap some ETH first
|
|
if [ "$WETH9_BALANCE" = "0" ]; then
|
|
log_warn "WETH9 balance is zero. Wrapping 0.001 ETH..."
|
|
log_info "Sending wrap transaction..."
|
|
|
|
TX_HASH=$(cast send "$WETH9_ADDRESS" "deposit()" \
|
|
--value "$TEST_AMOUNT" \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--rpc-url "$RPC_URL" \
|
|
--gas-limit 50000 \
|
|
--gas-price 1000000000 \
|
|
--nonce "$CURRENT_NONCE" 2>&1 | grep -i 'transactionHash\|0x' | head -1 | awk '{print $NF}')
|
|
|
|
if [ -n "$TX_HASH" ]; then
|
|
log_success "Wrap transaction sent: $TX_HASH"
|
|
log_info "Waiting for confirmation..."
|
|
sleep 10
|
|
|
|
# Increment nonce for next transaction
|
|
CURRENT_NONCE=$((CURRENT_NONCE + 1))
|
|
|
|
# Check new balance
|
|
WETH9_BALANCE=$(cast call "$WETH9_ADDRESS" "balanceOf(address)(uint256)" "$DEPLOYER" --rpc-url "$RPC_URL")
|
|
WETH9_BALANCE_ETHER=$(cast --to-unit "$WETH9_BALANCE" ether 2>/dev/null || echo "0")
|
|
log_success "New WETH9 balance: $WETH9_BALANCE_ETHER WETH9"
|
|
else
|
|
log_error "Failed to send wrap transaction"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Check WETH9 allowance
|
|
log_info "Checking WETH9 allowance for bridge..."
|
|
ALLOWANCE=$(cast call "$WETH9_ADDRESS" "allowance(address,address)(uint256)" "$DEPLOYER" "$BRIDGE_ADDRESS" --rpc-url "$RPC_URL")
|
|
log_info "Current allowance: $ALLOWANCE"
|
|
|
|
if [ "$ALLOWANCE" = "0" ] || [ $(echo "$ALLOWANCE < $TEST_AMOUNT" | bc 2>/dev/null || echo "1") = "1" ]; then
|
|
log_warn "Insufficient allowance. Approving bridge..."
|
|
|
|
TX_HASH=$(cast send "$WETH9_ADDRESS" "approve(address,uint256)" "$BRIDGE_ADDRESS" "$(cast max-uint)" \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--rpc-url "$RPC_URL" \
|
|
--gas-limit 50000 \
|
|
--gas-price 1000000000 \
|
|
--nonce "$CURRENT_NONCE" 2>&1 | grep -i 'transactionHash\|0x' | head -1 | awk '{print $NF}')
|
|
|
|
if [ -n "$TX_HASH" ]; then
|
|
log_success "Approval transaction sent: $TX_HASH"
|
|
log_info "Waiting for confirmation..."
|
|
sleep 10
|
|
CURRENT_NONCE=$((CURRENT_NONCE + 1))
|
|
else
|
|
log_error "Failed to send approval transaction"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
log_success "All prerequisites met!"
|
|
echo ""
|
|
log_info "========================================"
|
|
log_info "Ready to test bridge transaction"
|
|
log_info "========================================"
|
|
log_info "Next nonce to use: $CURRENT_NONCE"
|
|
log_info "Amount to bridge: 0.001 WETH9"
|
|
log_info "Destination: Ethereum Mainnet"
|
|
echo ""
|
|
log_warn "To execute bridge transaction, run:"
|
|
echo ""
|
|
echo "cast send $BRIDGE_ADDRESS \\"
|
|
echo " 'sendCrossChain(uint64,address,uint256)' \\"
|
|
echo " $MAINNET_SELECTOR \\"
|
|
echo " $DEPLOYER \\"
|
|
echo " $TEST_AMOUNT \\"
|
|
echo " --private-key \$PRIVATE_KEY \\"
|
|
echo " --rpc-url $RPC_URL \\"
|
|
echo " --gas-limit 200000 \\"
|
|
echo " --gas-price 1000000000 \\"
|
|
echo " --nonce $CURRENT_NONCE"
|