# MetaMask Integration Submodule Guide

**Date**: $(date)  
**Submodule**: `metamask-integration`  
**Repository**: [Defi-Oracle-Meta-Blockchain/metamask-integration](https://github.com/Defi-Oracle-Meta-Blockchain/metamask-integration.git)

---

## 📋 Overview

The MetaMask integration has been set up as a git submodule to keep it as a separate, versioned repository while maintaining integration with the main project.

---

## 🔧 Submodule Setup

### Current Configuration

The submodule is configured in `.gitmodules`:

```ini
[submodule "metamask-integration"]
	path = metamask-integration
	url = https://github.com/Defi-Oracle-Meta-Blockchain/metamask-integration.git
```

### Location

- **Path**: `metamask-integration/`
- **Remote**: `https://github.com/Defi-Oracle-Meta-Blockchain/metamask-integration.git`
- **Branch**: `main`

---

## 📁 Submodule Structure

```
metamask-integration/
├── docs/                    # Documentation
│   ├── METAMASK_QUICK_START_GUIDE.md
│   ├── METAMASK_TROUBLESHOOTING_GUIDE.md
│   ├── METAMASK_FULL_INTEGRATION_REQUIREMENTS.md
│   ├── METAMASK_ORACLE_INTEGRATION.md
│   ├── METAMASK_TOKEN_LIST_HOSTING.md
│   ├── METAMASK_WETH9_DISPLAY_BUG.md
│   ├── METAMASK_WETH9_FIX_INSTRUCTIONS.md
│   ├── METAMASK_INTEGRATION_COMPLETE.md
│   ├── METAMASK_NETWORK_CONFIG.json
│   └── METAMASK_TOKEN_LIST.json
├── scripts/                 # Automation scripts
│   ├── setup-metamask-integration.sh
│   ├── test-metamask-integration.sh
│   └── host-token-list.sh
├── examples/                # Example dApps
│   ├── wallet-connect.html
│   └── metamask-price-feed.html
├── config/                  # Configuration files
│   └── token-list.json
└── README.md
```

---

## 🚀 Working with the Submodule

### Initial Clone (For New Users)

When cloning the main repository, include submodules:

```bash
# Clone with submodules
git clone --recurse-submodules https://github.com/your-org/proxmox.git

# Or if already cloned
git submodule update --init --recursive
```

### Updating the Submodule

```bash
# Navigate to submodule
cd metamask-integration

# Pull latest changes
git pull origin main

# Return to parent repo
cd ..

# Commit submodule update
git add metamask-integration
git commit -m "Update MetaMask integration submodule"
```

### Making Changes to Submodule

```bash
# Navigate to submodule
cd metamask-integration

# Make changes
# ... edit files ...

# Commit in submodule
git add .
git commit -m "Update MetaMask integration"

# Push to remote
git push origin main

# Return to parent repo and update reference
cd ..
git add metamask-integration
git commit -m "Update MetaMask integration submodule reference"
git push
```

### Checking Submodule Status

```bash
# Check submodule status
git submodule status

# Check if submodule has uncommitted changes
cd metamask-integration
git status
```

---

## 📝 Submodule Commands Reference

### Initialize Submodules
```bash
git submodule init
git submodule update
# Or combined:
git submodule update --init --recursive
```

### Update Submodule to Latest
```bash
git submodule update --remote metamask-integration
```

### Remove Submodule (if needed)
```bash
# Remove submodule entry
git submodule deinit metamask-integration
git rm metamask-integration
rm -rf .git/modules/metamask-integration
```

### Sync Submodule URL (if remote changed)
```bash
git submodule sync metamask-integration
```

---

## 🔗 Accessing Files

### From Parent Repository

Reference files in the submodule:

```bash
# Documentation
cat metamask-integration/docs/METAMASK_QUICK_START_GUIDE.md

# Scripts
bash metamask-integration/scripts/setup-metamask-integration.sh

# Examples
open metamask-integration/examples/metamask-price-feed.html
```

### From Submodule Directory

Work directly in the submodule:

```bash
cd metamask-integration
# Now you're in the submodule repository
# All git commands work here
```

---

## ✅ Verification

### Check Submodule is Configured

```bash
# Verify .gitmodules
cat .gitmodules | grep metamask-integration

# Verify submodule exists
ls -la metamask-integration/

# Check submodule status
git submodule status metamask-integration
```

### Verify Remote Connection

```bash
cd metamask-integration
git remote -v
# Should show:
# origin  https://github.com/Defi-Oracle-Meta-Blockchain/metamask-integration.git (fetch)
# origin  https://github.com/Defi-Oracle-Meta-Blockchain/metamask-integration.git (push)
```

---

## 🎯 Benefits of Submodule

1. **Separation of Concerns**: MetaMask integration is a separate, versioned project
2. **Reusability**: Can be used in other projects
3. **Independent Updates**: Update MetaMask integration without affecting main repo
4. **Version Control**: Track specific versions of the integration
5. **Collaboration**: Multiple projects can use the same integration

---

## 📚 Related Documentation

- [MetaMask Integration Complete](../metamask-integration/docs/METAMASK_INTEGRATION_COMPLETE.md)
- [Quick Start Guide](/docs/01-getting-started/METAMASK_QUICK_START_GUIDE.md)
- [Submodule README](/docs/01-getting-started/README.md)

---

## 🔧 Troubleshooting

### Submodule Shows as Modified

If `git status` shows the submodule as modified:

```bash
cd metamask-integration
git status
# Check for uncommitted changes or different commit
```

### Submodule Not Initialized

```bash
git submodule update --init metamask-integration
```

### Submodule Points to Wrong Commit

```bash
cd metamask-integration
git checkout main
git pull origin main
cd ..
git add metamask-integration
git commit -m "Update submodule to latest"
```

---

**Last Updated**: $(date)

