#!/bin/bash # Storage Layout Validation Script for eMoneyToken Upgrades set -e echo "🔍 Validating storage layout for eMoneyToken upgrade..." # Check if forge is installed if ! command -v forge &> /dev/null; then echo "❌ Error: forge not found. Please install Foundry." exit 1 fi # Build contracts echo "đŸ“Ļ Building contracts..." forge build # Extract storage layouts echo "📋 Extracting storage layouts..." STORAGE_LAYOUT=$(forge inspect eMoneyToken storage-layout --pretty) if [ -z "$STORAGE_LAYOUT" ]; then echo "❌ Error: Could not extract storage layout" exit 1 fi echo "$STORAGE_LAYOUT" > storage-layout-current.txt echo "✅ Storage layout saved to storage-layout-current.txt" # If reference layout exists, compare if [ -f "storage-layout-reference.txt" ]; then echo "đŸ”Ŧ Comparing with reference layout..." if diff -u storage-layout-reference.txt storage-layout-current.txt > storage-layout-diff.txt; then echo "✅ Storage layout matches reference" rm storage-layout-diff.txt else echo "âš ī¸ Storage layout differs from reference. See storage-layout-diff.txt" cat storage-layout-diff.txt exit 1 fi else echo "â„šī¸ No reference layout found. Saving current layout as reference..." cp storage-layout-current.txt storage-layout-reference.txt fi echo "✅ Validation complete"