Add Oracle Aggregator and CCIP Integration

- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
This commit is contained in:
defiQUG
2025-12-12 14:57:48 -08:00
parent a1466e4005
commit 1fb7266469
1720 changed files with 241279 additions and 16 deletions

View File

@@ -0,0 +1,57 @@
import React, { useState } from 'react';
interface AddTokenButtonProps {
address: string;
symbol: string;
decimals: number;
image?: string;
}
export function AddTokenButton({
address,
symbol,
decimals,
image,
}: AddTokenButtonProps) {
const [isAdding, setIsAdding] = useState(false);
const [error, setError] = useState<string | null>(null);
const addToken = async () => {
if (typeof window === 'undefined' || !window.ethereum) {
setError('MetaMask is not installed');
return;
}
setIsAdding(true);
setError(null);
try {
await window.ethereum.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address,
symbol,
decimals,
...(image && { image }),
},
},
});
} catch (err: any) {
setError(err.message || 'Failed to add token');
} finally {
setIsAdding(false);
}
};
return (
<div>
<button onClick={addToken} disabled={isAdding}>
{isAdding ? 'Adding...' : `Add ${symbol}`}
</button>
{error && <div style={{ color: 'red' }}>{error}</div>}
</div>
);
}

View File

@@ -0,0 +1,25 @@
import React from 'react';
import { Chain138Button } from './Chain138Button';
import { AddTokenButton } from './AddTokenButton';
function App() {
return (
<div style={{ padding: '20px' }}>
<h1>ChainID 138 MetaMask Integration Example</h1>
<h2>Network</h2>
<Chain138Button />
<h2>Tokens</h2>
<AddTokenButton
address="0xYourWETHAddress" // Update after deployment
symbol="WETH"
decimals={18}
image="https://explorer.d-bis.org/images/tokens/weth.png"
/>
</div>
);
}
export default App;

View File

@@ -0,0 +1,21 @@
import React from 'react';
import { useChain138 } from './useChain138';
export function Chain138Button() {
const { isConnected, isLoading, connect } = useChain138();
if (isLoading) {
return <button disabled>Loading...</button>;
}
if (isConnected) {
return <button disabled>Connected to ChainID 138</button>;
}
return (
<button onClick={connect}>
Connect to ChainID 138
</button>
);
}

View File

@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@@ -0,0 +1,95 @@
import { useState, useEffect } from 'react';
const CHAIN_ID = '0x8a';
interface UseChain138Return {
isConnected: boolean;
isLoading: boolean;
connect: () => Promise<void>;
chainId: string | null;
}
export function useChain138(): UseChain138Return {
const [isConnected, setIsConnected] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [chainId, setChainId] = useState<string | null>(null);
const checkConnection = async () => {
if (typeof window === 'undefined' || !window.ethereum) {
setIsConnected(false);
setIsLoading(false);
return;
}
try {
const currentChainId = await window.ethereum.request({
method: 'eth_chainId',
}) as string;
setChainId(currentChainId);
setIsConnected(currentChainId === CHAIN_ID);
} catch (error) {
setIsConnected(false);
} finally {
setIsLoading(false);
}
};
const connect = async () => {
if (typeof window === 'undefined' || !window.ethereum) {
throw new Error('MetaMask is not installed');
}
const networkMetadata = {
chainId: CHAIN_ID,
chainName: 'DeFi Oracle Meta Mainnet',
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18,
},
rpcUrls: ['https://rpc.d-bis.org'],
blockExplorerUrls: ['https://explorer.d-bis.org'],
};
try {
// Try to switch first
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: CHAIN_ID }],
});
} catch (error: any) {
// If switch fails, network might not be added
if (error.code === 4902) {
// Add the network
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [networkMetadata],
});
} else {
throw error;
}
}
await checkConnection();
};
useEffect(() => {
checkConnection();
if (window.ethereum) {
const handleChainChanged = () => {
checkConnection();
};
window.ethereum.on('chainChanged', handleChainChanged);
return () => {
window.ethereum?.removeListener('chainChanged', handleChainChanged);
};
}
}, []);
return { isConnected, isLoading, connect, chainId };
}