- 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.
60 lines
1.9 KiB
Solidity
60 lines
1.9 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
/**
|
|
* @title CREATE2 Factory
|
|
* @notice Factory for deploying contracts at deterministic addresses using CREATE2
|
|
* @dev Based on the canonical CREATE2 factory pattern
|
|
*/
|
|
contract CREATE2Factory {
|
|
event Deployed(address addr, uint256 salt);
|
|
|
|
/**
|
|
* @notice Deploy a contract using CREATE2
|
|
* @param bytecode Contract bytecode
|
|
* @param salt Salt for deterministic address generation
|
|
* @return addr Deployed contract address
|
|
*/
|
|
function deploy(bytes memory bytecode, uint256 salt) public returns (address addr) {
|
|
assembly {
|
|
addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
|
|
if iszero(extcodesize(addr)) {
|
|
revert(0, 0)
|
|
}
|
|
}
|
|
emit Deployed(addr, salt);
|
|
}
|
|
|
|
/**
|
|
* @notice Compute the address that will be created with CREATE2
|
|
* @param bytecode Contract bytecode
|
|
* @param salt Salt for deterministic address generation
|
|
* @return addr Predicted contract address
|
|
*/
|
|
function computeAddress(bytes memory bytecode, uint256 salt) public view returns (address addr) {
|
|
bytes32 hash = keccak256(
|
|
abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(bytecode))
|
|
);
|
|
addr = address(uint160(uint256(hash)));
|
|
}
|
|
|
|
/**
|
|
* @notice Compute the address that will be created with CREATE2 (with deployer)
|
|
* @param deployer Deployer address
|
|
* @param bytecode Contract bytecode
|
|
* @param salt Salt for deterministic address generation
|
|
* @return addr Predicted contract address
|
|
*/
|
|
function computeAddressWithDeployer(
|
|
address deployer,
|
|
bytes memory bytecode,
|
|
uint256 salt
|
|
) public pure returns (address addr) {
|
|
bytes32 hash = keccak256(
|
|
abi.encodePacked(bytes1(0xff), deployer, salt, keccak256(bytecode))
|
|
);
|
|
addr = address(uint160(uint256(hash)));
|
|
}
|
|
}
|
|
|