diff --git a/.gitmodules b/.gitmodules index 383ada2..22def45 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "lib/aave-delivery-infrastructure"] path = lib/aave-delivery-infrastructure url = https://github.com/bgd-labs/aave-delivery-infrastructure - branch = feat/phase-3 + branch = fix/add-old-interface-gg diff --git a/lib/aave-delivery-infrastructure b/lib/aave-delivery-infrastructure index 73e6be6..be3f0b9 160000 --- a/lib/aave-delivery-infrastructure +++ b/lib/aave-delivery-infrastructure @@ -1 +1 @@ -Subproject commit 73e6be6e73a6ba99338e15cfe7556533abbf2117 +Subproject commit be3f0b98880204c90d7c336353fcdaff947b6881 diff --git a/scripts/ccc/DeployCCC.s.sol b/scripts/ccc/DeployCCC.s.sol new file mode 100644 index 0000000..905065e --- /dev/null +++ b/scripts/ccc/DeployCCC.s.sol @@ -0,0 +1,211 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {BaseDeployerScript, Addresses} from '../BaseDeployerScript.sol'; +import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; +import {TransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; +import 'adi-scripts/CCC/DeployCrossChainController.sol'; + +abstract contract BaseCCCNetworkDeployment is BaseDeployerScript, BaseCCCDeploy { + function _execute(Addresses memory addresses) internal override { + addresses.crossChainControllerImpl = _deployCCCImpl(); + address crossChainController; + // if address is 0 means that ccc will not be emergency consumer + if (CL_EMERGENCY_ORACLE() == address(0)) { + crossChainController = TransparentProxyFactory(addresses.proxyFactory).createDeterministic( + addresses.crossChainControllerImpl, + addresses.proxyAdmin, + abi.encodeWithSelector( + CrossChainController.initialize.selector, + addresses.owner, + addresses.guardian, + new ICrossChainController.ConfirmationInput[](0), + new ICrossChainController.ReceiverBridgeAdapterConfigInput[](0), + new ICrossChainController.ForwarderBridgeAdapterConfigInput[](0), + new address[](0), + new ICrossChainController.OptimalBandwidthByChain[](0) + ), + keccak256(abi.encode(SALT())) + ); + } else { + crossChainController = TransparentProxyFactory(addresses.proxyFactory).createDeterministic( + addresses.crossChainControllerImpl, + addresses.proxyAdmin, + abi.encodeWithSelector( + ICrossChainControllerWithEmergencyMode.initialize.selector, + addresses.owner, + addresses.guardian, + CL_EMERGENCY_ORACLE(), + new ICrossChainController.ConfirmationInput[](0), + new ICrossChainController.ReceiverBridgeAdapterConfigInput[](0), + new ICrossChainController.ForwarderBridgeAdapterConfigInput[](0), + new address[](0), + new ICrossChainController.OptimalBandwidthByChain[](0) + ), + keccak256(abi.encode(SALT())) + ); + + addresses.clEmergencyOracle = CL_EMERGENCY_ORACLE(); + } + + addresses.crossChainController = crossChainController; + } +} + +contract Ethereum is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ETHEREUM; + } +} + +contract Polygon is BaseCCCNetworkDeployment { + function CL_EMERGENCY_ORACLE() internal pure override returns (address) { + return 0xDAFA1989A504c48Ee20a582f2891eeB25E2fA23F; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.POLYGON; + } +} + +contract Avalanche is BaseCCCNetworkDeployment { + function CL_EMERGENCY_ORACLE() internal pure override returns (address) { + return 0x41185495Bc8297a65DC46f94001DC7233775EbEe; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.AVALANCHE; + } +} + +contract Arbitrum is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ARBITRUM; + } +} + +contract Optimism is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.OPTIMISM; + } +} + +contract Metis is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.METIS; + } +} + +contract Binance is BaseCCCNetworkDeployment { + function CL_EMERGENCY_ORACLE() internal pure override returns (address) { + return 0xcabb46FfB38c93348Df16558DF156e9f68F9F7F1; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.BNB; + } +} + +contract Base is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.BASE; + } +} + +contract Gnosis is BaseCCCNetworkDeployment { + function CL_EMERGENCY_ORACLE() internal pure override returns (address) { + return 0xF937ffAeA1363e4Fa260760bDFA2aA8Fc911F84D; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.GNOSIS; + } +} + +contract Zkevm is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.POLYGON_ZK_EVM; + } +} + +contract Scroll is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.SCROLL; + } +} + +contract Celo is BaseCCCNetworkDeployment { + function CL_EMERGENCY_ORACLE() internal pure override returns (address) { + return 0x91b21900E91CD302EBeD05E45D8f270ddAED944d; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.CELO; + } +} + +contract Ethereum_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ETHEREUM_SEPOLIA; + } +} + +contract Polygon_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.POLYGON_AMOY; + } +} + +contract Avalanche_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.AVALANCHE_FUJI; + } +} + +contract Arbitrum_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ARBITRUM_SEPOLIA; + } +} + +contract Optimism_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.OPTIMISM_SEPOLIA; + } +} + +contract Metis_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.METIS_TESTNET; + } +} + +contract Binance_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.BNB_TESTNET; + } +} + +contract Base_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.BASE_SEPOLIA; + } +} + +contract Gnosis_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.GNOSIS_CHIADO; + } +} + +contract Scroll_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.SCROLL_SEPOLIA; + } +} + +contract Celo_testnet is BaseCCCNetworkDeployment { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.CELO_ALFAJORES; + } +} diff --git a/scripts/ccc/Remove_CCF_Approved_Senders.s.sol b/scripts/ccc/Remove_CCF_Approved_Senders.s.sol new file mode 100644 index 0000000..d95f579 --- /dev/null +++ b/scripts/ccc/Remove_CCF_Approved_Senders.s.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {ICrossChainForwarder} from 'adi/interfaces/ICrossChainForwarder.sol'; +import '../BaseDeployerScript.sol'; + +/** + * @notice This script needs to be implemented from where the senders are known + */ +abstract contract BaseRemoveCCFApprovedSenders is BaseDeployerScript { + function getSendersToRemove() public virtual returns (address[] memory); + + function _execute(Addresses memory addresses) internal override { + ICrossChainForwarder(addresses.crossChainController).removeSenders(getSendersToRemove()); + } +} diff --git a/scripts/ccc/Remove_CCF_Sender_Adapters.s.sol b/scripts/ccc/Remove_CCF_Sender_Adapters.s.sol new file mode 100644 index 0000000..bbda41e --- /dev/null +++ b/scripts/ccc/Remove_CCF_Sender_Adapters.s.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseDeployerScript.sol'; +import {ICrossChainForwarder} from 'adi/interfaces/ICrossChainForwarder.sol'; +import {ICrossChainReceiver} from 'adi/interfaces/ICrossChainReceiver.sol'; + +abstract contract BaseDisableCCFAdapter is BaseDeployerScript { + function getBridgeAdaptersToDisable() + public + pure + virtual + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory); + + function _execute(Addresses memory addresses) internal override { + ICrossChainForwarder(addresses.crossChainController).disableBridgeAdapters( + getBridgeAdaptersToDisable() + ); + } +} + +contract Ethereum_testnet is BaseDisableCCFAdapter { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ETHEREUM_SEPOLIA; + } + + function getBridgeAdaptersToDisable() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + ICrossChainForwarder.BridgeAdapterToDisable[] + memory adapters = new ICrossChainForwarder.BridgeAdapterToDisable[](1); + adapters[0].bridgeAdapter = 0xc3f2AB225a94c3c8315e52D3b2B86a2af260c804; + adapters[0].chainIds = new uint256[](1); + adapters[0].chainIds[0] = TestNetChainIds.SCROLL_SEPOLIA; + return adapters; + } +} + +abstract contract BaseDisableCCRAdapter is BaseDeployerScript { + function getBridgeAdaptersToDisable() + public + pure + virtual + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory); + + function _execute(Addresses memory addresses) internal override { + ICrossChainReceiver(addresses.crossChainController).disallowReceiverBridgeAdapters( + getBridgeAdaptersToDisable() + ); + } +} + +contract Scroll_testnet is BaseDisableCCRAdapter { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.SCROLL_SEPOLIA; + } + + function getBridgeAdaptersToDisable() + public + pure + override + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory adapters = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); + adapters[0].bridgeAdapter = 0x18536013913f763bc199A5b20c1d170b6058373e; + adapters[0].chainIds = new uint256[](1); + adapters[0].chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + return adapters; + } +} diff --git a/scripts/ccc/Set_CCF_Approved_Senders.s.sol b/scripts/ccc/Set_CCF_Approved_Senders.s.sol new file mode 100644 index 0000000..b232131 --- /dev/null +++ b/scripts/ccc/Set_CCF_Approved_Senders.s.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {ICrossChainForwarder} from 'adi/interfaces/ICrossChainForwarder.sol'; +import '../BaseDeployerScript.sol'; + +/** + * @notice This script needs to be implemented from where the senders are known + */ +abstract contract BaseSetCCFApprovedSenders is BaseDeployerScript { + function getSendersToApprove() public virtual returns (address[] memory); + + function _execute(Addresses memory addresses) internal override { + ICrossChainForwarder(addresses.crossChainController).approveSenders(getSendersToApprove()); + } +} diff --git a/scripts/ccc/Set_CCF_Sender_Adapters..ssol b/scripts/ccc/Set_CCF_Sender_Adapters..ssol new file mode 100644 index 0000000..1234990 --- /dev/null +++ b/scripts/ccc/Set_CCF_Sender_Adapters..ssol @@ -0,0 +1,457 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {ICrossChainForwarder} from 'adi/interfaces/ICrossChainForwarder.sol'; +import '../BaseDeployerScript.sol'; + +abstract contract BaseCCFSenderAdapters is BaseDeployerScript { + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view virtual returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory); + + function _execute(Addresses memory addresses) internal override { + ICrossChainForwarder(addresses.crossChainController).enableBridgeAdapters( + getBridgeAdaptersToEnable(addresses) + ); + } +} + +contract Ethereum is BaseCCFSenderAdapters { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ETHEREUM; + } + + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 23 + ); + + // polygon path + Addresses memory addressesPolygon = _getAddresses(ChainIds.POLYGON); + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.polAdapter, + destinationBridgeAdapter: addressesPolygon.polAdapter, + destinationChainId: addressesPolygon.chainId + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: addressesPolygon.ccipAdapter, + destinationChainId: addressesPolygon.chainId + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesPolygon.lzAdapter, + destinationChainId: addressesPolygon.chainId + }); + bridgeAdaptersToEnable[3] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesPolygon.hlAdapter, + destinationChainId: addressesPolygon.chainId + }); + + // avalanche path + Addresses memory addressesAvax = _getAddresses(ChainIds.AVALANCHE); + bridgeAdaptersToEnable[4] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: addressesAvax.ccipAdapter, + destinationChainId: addressesAvax.chainId + }); + bridgeAdaptersToEnable[5] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesAvax.lzAdapter, + destinationChainId: addressesAvax.chainId + }); + bridgeAdaptersToEnable[6] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesAvax.hlAdapter, + destinationChainId: addressesAvax.chainId + }); + + // binance path + Addresses memory addressesBNB = _getAddresses(ChainIds.BNB); + bridgeAdaptersToEnable[7] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesBNB.lzAdapter, + destinationChainId: addressesBNB.chainId + }); + bridgeAdaptersToEnable[8] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesBNB.hlAdapter, + destinationChainId: addressesBNB.chainId + }); + bridgeAdaptersToEnable[9] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: addressesBNB.ccipAdapter, + destinationChainId: addressesBNB.chainId + }); + + // optimism + Addresses memory addressesOp = _getAddresses(ChainIds.OPTIMISM); + bridgeAdaptersToEnable[10] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.opAdapter, + destinationBridgeAdapter: addressesOp.opAdapter, + destinationChainId: addressesOp.chainId + }); + // arbitrum + Addresses memory addressesArb = _getAddresses(ChainIds.ARBITRUM); + bridgeAdaptersToEnable[11] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.arbAdapter, + destinationBridgeAdapter: addressesArb.arbAdapter, + destinationChainId: addressesArb.chainId + }); + // metis + Addresses memory addressesMetis = _getAddresses(ChainIds.METIS); + bridgeAdaptersToEnable[12] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.metisAdapter, + destinationBridgeAdapter: addressesMetis.metisAdapter, + destinationChainId: addressesMetis.chainId + }); + //base + Addresses memory addressesBase = _getAddresses(ChainIds.BASE); + bridgeAdaptersToEnable[13] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.baseAdapter, + destinationBridgeAdapter: addressesBase.baseAdapter, + destinationChainId: addressesBase.chainId + }); + + // same chain path + bridgeAdaptersToEnable[14] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.sameChainAdapter, + destinationBridgeAdapter: addresses.sameChainAdapter, + destinationChainId: addresses.chainId + }); + + // gnosis + Addresses memory addressesGnosis = _getAddresses(ChainIds.GNOSIS); + bridgeAdaptersToEnable[15] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.gnosisAdapter, + destinationBridgeAdapter: addressesGnosis.gnosisAdapter, + destinationChainId: addressesGnosis.chainId + }); + bridgeAdaptersToEnable[16] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesGnosis.lzAdapter, + destinationChainId: addressesGnosis.chainId + }); + bridgeAdaptersToEnable[17] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesGnosis.hlAdapter, + destinationChainId: addressesGnosis.chainId + }); + + // ZkEVM + Addresses memory addressesZkEVM = _getAddresses(ChainIds.POLYGON_ZK_EVM); + bridgeAdaptersToEnable[18] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.zkevmAdapter, + destinationBridgeAdapter: addressesZkEVM.zkevmAdapter, + destinationChainId: addressesZkEVM.chainId + }); + + // Scroll + Addresses memory addressesScroll = _getAddresses(ChainIds.SCROLL); + bridgeAdaptersToEnable[19] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.scrollAdapter, + destinationBridgeAdapter: addressesScroll.scrollAdapter, + destinationChainId: addressesScroll.chainId + }); + + // Celo + Addresses memory addressesCelo = _getAddresses(ChainIds.CELO); + bridgeAdaptersToEnable[20] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.wormholeAdapter, + destinationBridgeAdapter: addressesCelo.wormholeAdapter, + destinationChainId: addressesCelo.chainId + }); + bridgeAdaptersToEnable[21] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesCelo.lzAdapter, + destinationChainId: addressesCelo.chainId + }); + bridgeAdaptersToEnable[22] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesCelo.hlAdapter, + destinationChainId: addressesCelo.chainId + }); + + return bridgeAdaptersToEnable; + } +} + +contract Polygon is BaseCCFSenderAdapters { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.POLYGON; + } + + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 4 + ); + + // ethereum path + Addresses memory ethereumAddresses = _getAddresses(ChainIds.ETHEREUM); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: ethereumAddresses.ccipAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: ethereumAddresses.lzAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: ethereumAddresses.hlAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[3] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.polAdapter, + destinationBridgeAdapter: ethereumAddresses.polAdapter, + destinationChainId: ethereumAddresses.chainId + }); + return bridgeAdaptersToEnable; + } +} + +contract Avalanche is BaseCCFSenderAdapters { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.AVALANCHE; + } + + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 3 + ); + + // ethereum path + Addresses memory ethereumAddresses = _getAddresses(ChainIds.ETHEREUM); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: ethereumAddresses.ccipAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: ethereumAddresses.lzAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: ethereumAddresses.hlAdapter, + destinationChainId: ethereumAddresses.chainId + }); + + return bridgeAdaptersToEnable; + } +} + +contract Ethereum_testnet is BaseCCFSenderAdapters { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ETHEREUM_SEPOLIA; + } + + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 16 + ); + + // polygon path + Addresses memory addressesPolygon = _getAddresses(TestNetChainIds.POLYGON_AMOY); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: addressesPolygon.ccipAdapter, + destinationChainId: addressesPolygon.chainId + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesPolygon.lzAdapter, + destinationChainId: addressesPolygon.chainId + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesPolygon.hlAdapter, + destinationChainId: addressesPolygon.chainId + }); + + // avalanche path + Addresses memory addressesAvax = _getAddresses(TestNetChainIds.AVALANCHE_FUJI); + + bridgeAdaptersToEnable[3] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: addressesAvax.ccipAdapter, + destinationChainId: addressesAvax.chainId + }); + bridgeAdaptersToEnable[4] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesAvax.lzAdapter, + destinationChainId: addressesAvax.chainId + }); + bridgeAdaptersToEnable[5] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesAvax.hlAdapter, + destinationChainId: addressesAvax.chainId + }); + + // binance path + Addresses memory addressesBNB = _getAddresses(TestNetChainIds.BNB_TESTNET); + + bridgeAdaptersToEnable[6] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: addressesBNB.lzAdapter, + destinationChainId: addressesBNB.chainId + }); + bridgeAdaptersToEnable[7] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: addressesBNB.hlAdapter, + destinationChainId: addressesBNB.chainId + }); + + // gnosis path + Addresses memory addressesGnosis = _getAddresses(TestNetChainIds.GNOSIS_CHIADO); + + bridgeAdaptersToEnable[8] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.gnosisAdapter, + destinationBridgeAdapter: addressesGnosis.gnosisAdapter, + destinationChainId: addressesGnosis.chainId + }); + + // rollups + Addresses memory addressesOp = _getAddresses(TestNetChainIds.OPTIMISM_SEPOLIA); + bridgeAdaptersToEnable[9] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.opAdapter, + destinationBridgeAdapter: addressesOp.opAdapter, + destinationChainId: addressesOp.chainId + }); + + Addresses memory addressesArb = _getAddresses(TestNetChainIds.ARBITRUM_SEPOLIA); + bridgeAdaptersToEnable[10] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.arbAdapter, + destinationBridgeAdapter: addressesArb.arbAdapter, + destinationChainId: addressesArb.chainId + }); + + Addresses memory addressesMetis = _getAddresses(TestNetChainIds.METIS_TESTNET); + bridgeAdaptersToEnable[11] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.metisAdapter, + destinationBridgeAdapter: addressesMetis.metisAdapter, + destinationChainId: addressesMetis.chainId + }); + Addresses memory addressesBase = _getAddresses(TestNetChainIds.BASE_SEPOLIA); + bridgeAdaptersToEnable[12] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.baseAdapter, + destinationBridgeAdapter: addressesBase.baseAdapter, + destinationChainId: addressesBase.chainId + }); + + // same chain path + bridgeAdaptersToEnable[13] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.sameChainAdapter, + destinationBridgeAdapter: addresses.sameChainAdapter, + destinationChainId: addresses.chainId + }); + + Addresses memory addressesScrollSepolia = _getAddresses(TestNetChainIds.SCROLL_SEPOLIA); + + bridgeAdaptersToEnable[14] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.scrollAdapter, + destinationBridgeAdapter: addressesScrollSepolia.scrollAdapter, + destinationChainId: addressesScrollSepolia.chainId + }); + + // Celo + Addresses memory addressesCelo = _getAddresses(TestNetChainIds.CELO_ALFAJORES); + bridgeAdaptersToEnable[15] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.wormholeAdapter, + destinationBridgeAdapter: addressesCelo.wormholeAdapter, + destinationChainId: addressesCelo.chainId + }); + return bridgeAdaptersToEnable; + } +} + +contract Polygon_testnet is BaseCCFSenderAdapters { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.POLYGON_AMOY; + } + + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 1 + ); + + // ethereum path + Addresses memory ethereumAddresses = _getAddresses(TestNetChainIds.ETHEREUM_SEPOLIA); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: ethereumAddresses.ccipAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: ethereumAddresses.lzAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: ethereumAddresses.hlAdapter, + destinationChainId: ethereumAddresses.chainId + }); + + return bridgeAdaptersToEnable; + } +} + +contract Avalanche_testnet is BaseCCFSenderAdapters { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.AVALANCHE_FUJI; + } + + function getBridgeAdaptersToEnable( + Addresses memory addresses + ) public view override returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 3 + ); + + // ethereum path + Addresses memory ethereumAddresses = _getAddresses(TestNetChainIds.ETHEREUM_SEPOLIA); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.ccipAdapter, + destinationBridgeAdapter: ethereumAddresses.ccipAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.lzAdapter, + destinationBridgeAdapter: ethereumAddresses.lzAdapter, + destinationChainId: ethereumAddresses.chainId + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: addresses.hlAdapter, + destinationBridgeAdapter: ethereumAddresses.hlAdapter, + destinationChainId: ethereumAddresses.chainId + }); + + return bridgeAdaptersToEnable; + } +} diff --git a/scripts/ccc/Set_CCR_Confirmations.s.sol b/scripts/ccc/Set_CCR_Confirmations.s.sol new file mode 100644 index 0000000..0d636aa --- /dev/null +++ b/scripts/ccc/Set_CCR_Confirmations.s.sol @@ -0,0 +1,478 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {CrossChainController, ICrossChainController} from 'adi/CrossChainController.sol'; +import {ICrossChainReceiver} from 'adi/interfaces/ICrossChainReceiver.sol'; +import '../BaseDeployerScript.sol'; + +abstract contract BaseSetCCRConfirmations is BaseDeployerScript { + struct ConfirmationsByChain { + uint8 confirmations; + uint256 chainId; + } + + function getConfirmationsByChainIds() public virtual returns (ConfirmationsByChain[] memory); + + function _execute(Addresses memory addresses) internal override { + ConfirmationsByChain[] memory confirmationsByChain = getConfirmationsByChainIds(); + ICrossChainReceiver.ConfirmationInput[] + memory confirmationsInput = new ICrossChainReceiver.ConfirmationInput[]( + confirmationsByChain.length + ); + + for (uint256 i = 0; i < confirmationsByChain.length; i++) { + confirmationsInput[i] = ICrossChainReceiver.ConfirmationInput({ + chainId: confirmationsByChain[i].chainId, + requiredConfirmations: confirmationsByChain[i].confirmations + }); + } + + ICrossChainReceiver(addresses.crossChainController).updateConfirmations(confirmationsInput); + } +} + +contract Ethereum is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ETHEREUM; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](2); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.POLYGON, confirmations: 3}); + chainIds[1] = ConfirmationsByChain({chainId: ChainIds.AVALANCHE, confirmations: 2}); + + return chainIds; + } +} + +contract Polygon is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.POLYGON; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 3}); + + return chainIds; + } +} + +contract Avalanche is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.AVALANCHE; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); + + return chainIds; + } +} + +contract Optimism is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.OPTIMISM; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + +contract Arbitrum is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ARBITRUM; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + +contract Metis is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.METIS; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + +contract Binance is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.BNB; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); + + return chainIds; + } +} + +contract Base is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.BASE; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + +contract Gnosis is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.GNOSIS; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); + + return chainIds; + } +} + +contract Zkevm is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.POLYGON_ZK_EVM; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + +contract Scroll is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.SCROLL; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 1}); + + return chainIds; + } +} + +contract Celo is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.CELO; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({chainId: ChainIds.ETHEREUM, confirmations: 2}); + + return chainIds; + } +} + +contract Ethereum_testnet is Ethereum { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.ETHEREUM_SEPOLIA; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](2); + chainIds[0] = ConfirmationsByChain({chainId: TestNetChainIds.POLYGON_AMOY, confirmations: 1}); + chainIds[1] = ConfirmationsByChain({chainId: TestNetChainIds.AVALANCHE_FUJI, confirmations: 1}); + + return chainIds; + } +} + +contract Polygon_testnet is Polygon { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.POLYGON_AMOY; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Avalanche_testnet is Avalanche { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.AVALANCHE_FUJI; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Optimism_testnet is Optimism { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.OPTIMISM_SEPOLIA; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Arbitrum_testnet is Arbitrum { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.ARBITRUM_SEPOLIA; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Metis_testnet is Metis { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.METIS_TESTNET; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Binance_testnet is Binance { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.BNB_TESTNET; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 2 + }); + + return chainIds; + } +} + +contract Base_testnet is Base { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.BASE_SEPOLIA; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Gnosis_testnet is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.GNOSIS_CHIADO; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 3 + }); + + return chainIds; + } +} + +contract Scroll_testnet is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.SCROLL_SEPOLIA; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} + +contract Celo_testnet is BaseSetCCRConfirmations { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.CELO_ALFAJORES; + } + + function getConfirmationsByChainIds() + public + virtual + override + returns (ConfirmationsByChain[] memory) + { + ConfirmationsByChain[] memory chainIds = new ConfirmationsByChain[](1); + chainIds[0] = ConfirmationsByChain({ + chainId: TestNetChainIds.ETHEREUM_SEPOLIA, + confirmations: 1 + }); + + return chainIds; + } +} diff --git a/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol b/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol new file mode 100644 index 0000000..39b8d40 --- /dev/null +++ b/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol @@ -0,0 +1,522 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseDeployerScript.sol'; +import {ICrossChainReceiver} from 'adi/interfaces/ICrossChainReceiver.sol'; + +abstract contract BaseSetCCRAdapters is BaseDeployerScript { + function getChainIds() public virtual returns (uint256[] memory); + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public view virtual returns (address[] memory); + + function _execute(Addresses memory addresses) internal override { + uint256[] memory chainIds = getChainIds(); + address[] memory receiverBridgeAdaptersToAllow = getReceiverBridgeAdaptersToAllow(addresses); + + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]( + receiverBridgeAdaptersToAllow.length + ); + for (uint256 i = 0; i < receiverBridgeAdaptersToAllow.length; i++) { + bridgeAdapterConfig[i] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ + bridgeAdapter: receiverBridgeAdaptersToAllow[i], + chainIds: chainIds + }); + } + + ICrossChainReceiver(addresses.crossChainController).allowReceiverBridgeAdapters( + bridgeAdapterConfig + ); + } +} + +contract Ethereum is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ETHEREUM; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](2); + chainIds[0] = ChainIds.POLYGON; + chainIds[1] = ChainIds.AVALANCHE; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure virtual override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.hlAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.polAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Polygon is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.POLYGON; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure virtual override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.hlAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.polAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Avalanche is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.AVALANCHE; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure virtual override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](3); + receiverBridgeAdaptersToAllow[0] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.hlAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Optimism is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.OPTIMISM; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.opAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Arbitrum is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.ARBITRUM; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.arbAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Metis is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.METIS; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.metisAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Binance is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.BNB; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](3); + receiverBridgeAdaptersToAllow[0] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.hlAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.ccipAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Base is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.BASE; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.baseAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Gnosis is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.GNOSIS; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.hlAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.gnosisAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.ccipAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Zkevm is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.POLYGON_ZK_EVM; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.zkevmAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Scroll is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.SCROLL; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.zkevmAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Celo is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return ChainIds.CELO; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = ChainIds.ETHEREUM; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.hlAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.wormholeAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.ccipAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Ethereum_testnet is Ethereum { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ETHEREUM_SEPOLIA; + } + + function getChainIds() public pure override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](3); + chainIds[0] = TestNetChainIds.POLYGON_AMOY; + chainIds[1] = TestNetChainIds.AVALANCHE_FUJI; + chainIds[2] = TestNetChainIds.BNB_TESTNET; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.hlAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.polAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Polygon_testnet is Polygon { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.POLYGON_AMOY; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.polAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.hlAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Avalanche_testnet is Avalanche { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.AVALANCHE_FUJI; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](4); + receiverBridgeAdaptersToAllow[0] = addresses.polAdapter; + receiverBridgeAdaptersToAllow[1] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.lzAdapter; + receiverBridgeAdaptersToAllow[3] = addresses.hlAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Optimism_testnet is Optimism { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.OPTIMISM_SEPOLIA; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } +} + +contract Arbitrum_testnet is Arbitrum { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.ARBITRUM_SEPOLIA; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } +} + +contract Metis_testnet is Metis { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.METIS_TESTNET; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } +} + +contract Binance_testnet is Binance { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.BNB_TESTNET; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } +} + +contract Base_testnet is Base { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.BASE_SEPOLIA; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } +} + +contract Gnosis_testnet is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.GNOSIS_CHIADO; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.gnosisAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Scroll_testnet is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.SCROLL_SEPOLIA; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.scrollAdapter; + + return receiverBridgeAdaptersToAllow; + } +} + +contract Celo_testnet is BaseSetCCRAdapters { + function TRANSACTION_NETWORK() internal pure virtual override returns (uint256) { + return TestNetChainIds.CELO_ALFAJORES; + } + + function getChainIds() public pure virtual override returns (uint256[] memory) { + uint256[] memory chainIds = new uint256[](1); + chainIds[0] = TestNetChainIds.ETHEREUM_SEPOLIA; + + return chainIds; + } + + function getReceiverBridgeAdaptersToAllow( + Addresses memory addresses + ) public pure override returns (address[] memory) { + address[] memory receiverBridgeAdaptersToAllow = new address[](1); + receiverBridgeAdaptersToAllow[0] = addresses.wormholeAdapter; + + return receiverBridgeAdaptersToAllow; + } +}