diff --git a/.gitmodules b/.gitmodules index 74b93fd..565506a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "lib/chainlink-local"] + path = lib/chainlink-local + url = https://github.com/smartcontractkit/chainlink-local diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cab4e2..04f67e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ Please follow conventions. + + +## 1.0.1 - 20240429 + +In the version 1.0.0, when fees are paid in native tokens, the function ccipSend from the CCIP router was called without the `value`argument. + +Old version + +**new version** + +```solidity +if(_paymentMethodId == 0){ // Native token +messageId = router.ccipSend{value: fees}(_destinationChainSelector, message); +} else{ + messageId = router.ccipSend(_destinationChainSelector, message); +} +``` + + + ## 1.0.0 - 20240423 - 🎉 First release ! diff --git a/doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html b/doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html index 64a9dc6..ad2eb62 100644 --- a/doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 @@ -74,11 +74,11 @@ CCIPBaseSender._buildEndSend - 12 + 13 CCIPBaseSender.transferTokens - 12 + 13
diff --git a/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html b/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html index 0c676b1..7883507 100644 --- a/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html +++ b/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 @@ -70,11 +70,11 @@ CCIPBaseSender._buildEndSend - 12 + 13 CCIPBaseSender.transferTokens - 12 + 13 CCIPBaseSender.transferTokensBatch diff --git a/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html b/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html index e57ee21..004aa44 100644 --- a/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html +++ b/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 @@ -120,18 +120,18 @@ 49 : : onlyAllowlistedDestinationChain(_destinationChainSelector) 50 : : returns (bytes32 messageId) 51 : : { - 52 : 20 : Client.EVMTokenAmount[] - 53 : 20 : memory tokenAmounts = new Client.EVMTokenAmount[](1); - 54 : 30 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({ + 52 : 22 : Client.EVMTokenAmount[] + 53 : 22 : memory tokenAmounts = new Client.EVMTokenAmount[](1); + 54 : 33 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({ 55 : : token: _token, 56 : : amount: _amount 57 : : }); - 58 : 20 : tokenAmounts[0] = tokenAmount; - 59 : 20 : uint256 fees; + 58 : 22 : tokenAmounts[0] = tokenAmount; + 59 : 22 : uint256 fees; 60 : : - 61 : 20 : (fees, messageId) = _buildEndSend(_destinationChainSelector, _receiver, _paymentMethodId, tokenAmounts); + 61 : 22 : (fees, messageId) = _buildEndSend(_destinationChainSelector, _receiver, _paymentMethodId, tokenAmounts); 62 : : - 63 : 4 : emit TokenSingleTransferred( + 63 : 6 : emit TokenSingleTransferred( 64 : : messageId, 65 : : _destinationChainSelector, 66 : : _receiver, @@ -185,20 +185,20 @@ 114 : : */ 115 : : function _buildEndSend(uint64 _destinationChainSelector, address _receiver, uint256 _paymentMethodId, Client.EVMTokenAmount[] memory tokenAmounts) internal returns(uint256 fees, bytes32 messageId){ 116 : : // Build the CCIP Message - 117 : 36 : Client.EVM2AnyMessage memory message = CCIPSenderBuild._buildCCIPTransferMessage(_receiver, tokenAmounts, _paymentMethodId ); + 117 : 39 : Client.EVM2AnyMessage memory message = CCIPSenderBuild._buildCCIPTransferMessage(_receiver, tokenAmounts, _paymentMethodId ); 118 : : // Initialize a router client instance to interact with cross-chain router - 119 : 30 : IRouterClient router = IRouterClient(CCIPRouterManage.getRouter()); + 119 : 33 : IRouterClient router = IRouterClient(CCIPRouterManage.getRouter()); 120 : : // CCIP Fees Management - 121 : 20 : fees = CCIPSenderPayment._computeAndApproveFee(_destinationChainSelector, message, router, _paymentMethodId); - 122 : 36 : for(uint256 i = 0; i < tokenAmounts.length; ++i){ + 121 : 22 : fees = CCIPSenderPayment._computeAndApproveFee(_destinationChainSelector, message, router, _paymentMethodId); + 122 : 41 : for(uint256 i = 0; i < tokenAmounts.length; ++i){ 123 : : // transfer tokens to the contract - 124 : 20 : IERC20(tokenAmounts[i].token).safeTransferFrom(_msgSender(), address(this), tokenAmounts[i].amount); + 124 : 22 : IERC20(tokenAmounts[i].token).safeTransferFrom(_msgSender(), address(this), tokenAmounts[i].amount); 125 : : // approve the Router to spend tokens on contract's behalf. It will spend the amount of the given token - 126 : 12 : IERC20(tokenAmounts[i].token).safeIncreaseAllowance(address(router), tokenAmounts[i].amount); + 126 : 14 : IERC20(tokenAmounts[i].token).safeIncreaseAllowance(address(router), tokenAmounts[i].amount); 127 : : } 128 : : // Send CCIP Message - 129 [ # + ]: 8 : if(_paymentMethodId == 0){ // Native token - 130 : 4 : messageId = router.ccipSend{value: fees}(_destinationChainSelector, message); + 129 [ # + ]: 10 : if(_paymentMethodId == 0){ // Native token + 130 : 6 : messageId = router.ccipSend{value: fees}(_destinationChainSelector, message); 131 : : } else{ 132 : 4 : messageId = router.ccipSend(_destinationChainSelector, message); 133 : : } diff --git a/doc/test/coverage/bridge/index-sort-b.html b/doc/test/coverage/bridge/index-sort-b.html index a427a78..aedba2a 100644 --- a/doc/test/coverage/bridge/index-sort-b.html +++ b/doc/test/coverage/bridge/index-sort-b.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/index-sort-f.html b/doc/test/coverage/bridge/index-sort-f.html index 15eaed5..d48beb9 100644 --- a/doc/test/coverage/bridge/index-sort-f.html +++ b/doc/test/coverage/bridge/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/index-sort-l.html b/doc/test/coverage/bridge/index-sort-l.html index df8caf3..e9b9df6 100644 --- a/doc/test/coverage/bridge/index-sort-l.html +++ b/doc/test/coverage/bridge/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/index.html b/doc/test/coverage/bridge/index.html index 05299db..a4368d4 100644 --- a/doc/test/coverage/bridge/index.html +++ b/doc/test/coverage/bridge/index.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func-sort-c.html b/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func-sort-c.html index 796dc1e..1b8bd42 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 1 @@ -70,7 +70,7 @@ CCIPAllowlistedChain.setAllowlistChain - 17 + 18
diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func.html b/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func.html index 8ded0fe..c8b4a5f 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 1 @@ -70,7 +70,7 @@ CCIPAllowlistedChain.setAllowlistChain - 17 + 18
diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.gcov.html b/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.gcov.html index 6468b4b..5700f56 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 1 @@ -111,11 +111,11 @@ 40 : : bool allowedSourceChain, 41 : : bool allowedDestinationChain 42 : : ) external onlyRole(BRIDGE_ALLOWLISTED_CHAIN_MANAGER_ROLE) { - 43 [ + + ]: 30 : if(allowlistedSourceChains[_chainSelector] != allowedSourceChain){ + 43 [ + + ]: 32 : if(allowlistedSourceChains[_chainSelector] != allowedSourceChain){ 44 : 6 : allowlistedSourceChains[_chainSelector] = allowedSourceChain; 45 : : } - 46 [ + + ]: 30 : if( allowlistedDestinationChains[_chainSelector] != allowedDestinationChain){ - 47 : 30 : allowlistedDestinationChains[_chainSelector] = allowedDestinationChain; + 46 [ + + ]: 32 : if( allowlistedDestinationChains[_chainSelector] != allowedDestinationChain){ + 47 : 32 : allowlistedDestinationChains[_chainSelector] = allowedDestinationChain; 48 : : } 49 : : } 50 : : } diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func-sort-c.html b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func-sort-c.html index b854890..2d3c697 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html index a0aeec3..77e4307 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.gcov.html b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.gcov.html index a77080c..d6a2946 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 @@ -89,7 +89,7 @@ 18 : : /// @notice Return the current router 19 : : /// @return i_router address 20 : : function getRouter() public view returns (address) { - 21 : 39 : return address(i_router); + 21 : 42 : return address(i_router); 22 : : } 23 : : /** 24 : : * @param chainSelector blockchain selector @@ -108,13 +108,14 @@ 37 : : } 38 : : 39 : : /// @dev only calls from the set router are accepted. - 40 : : modifier onlyRouter() { - 41 : : if (msg.sender != address(i_router)){ - 42 : : revert CCIPErrors.CCIP_Router_InvalidRouter(msg.sender); - 43 : : } - 44 : : _; - 45 : : } - 46 : : } + 40 : : /// Only useful with a receiver contract + 41 : : modifier onlyRouter() { + 42 : : if (msg.sender != address(i_router)){ + 43 : : revert CCIPErrors.CCIP_Router_InvalidRouter(msg.sender); + 44 : : } + 45 : : _; + 46 : : } + 47 : : } diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func-sort-c.html b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func-sort-c.html index f2536a6..a58995a 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 6 @@ -78,20 +78,20 @@ CCIPSenderPayment._computeAndApproveFee - 10 - - - CCIPSenderPayment.isValidPaymentId 11 - CCIPSenderPayment.changeStatusFeePaymentMethod + CCIPSenderPayment.isValidPaymentId 12 CCIPSenderPayment.setFeePaymentMethod 12 + + CCIPSenderPayment.changeStatusFeePaymentMethod + 13 +
diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func.html b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func.html index df3a2e7..b5ec4ba 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 6 @@ -70,15 +70,15 @@ CCIPSenderPayment._computeAndApproveFee - 10 + 11 CCIPSenderPayment.changeStatusFeePaymentMethod - 12 + 13 CCIPSenderPayment.isValidPaymentId - 11 + 12 CCIPSenderPayment.setFeePaymentMethod diff --git a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.gcov.html b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.gcov.html index db68a79..f9b0431 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 6 @@ -140,7 +140,7 @@ 69 : : * @param id paymentId 70 : : */ 71 : : function isValidPaymentId(uint256 id) internal view returns(bool){ - 72 : 33 : return id < paymentIdCounter ? true:false; + 72 : 36 : return id < paymentIdCounter ? true:false; 73 : : } 74 : : /** 75 : : * @notice set the fee payment @@ -148,18 +148,18 @@ 77 : : * @param newState boolean. True to activate, false to deactivate 78 : : */ 79 : : function changeStatusFeePaymentMethod(uint256 id, bool newState) public onlyRole(BRIDGE_OPERATOR_ROLE){ - 80 [ + + ]: 22 : if(!isValidPaymentId(id)){ + 80 [ + + ]: 24 : if(!isValidPaymentId(id)){ 81 : 2 : revert CCIPErrors.CCIP_SenderPayment_InvalidId(); 82 : : } - 83 : 20 : paymentTokens[id].isActivate = newState; + 83 : 22 : paymentTokens[id].isActivate = newState; 84 : : } 85 : : 86 : : 87 : : 88 : : function _computeAndApproveFee(uint64 _destinationChainSelector, Client.EVM2AnyMessage memory message, IRouterClient router, uint256 paymentMethodId ) internal returns(uint256){ 89 : : // external call - 90 : 30 : uint256 fees = router.getFee(_destinationChainSelector, message); - 91 [ + + ]: 40 : if(address(paymentTokens[paymentMethodId].tokenAddress) != address(0)){ + 90 : 33 : uint256 fees = router.getFee(_destinationChainSelector, message); + 91 [ + + ]: 44 : if(address(paymentTokens[paymentMethodId].tokenAddress) != address(0)){ 92 : : // ERC-20 token 93 : : // External call 94 : 15 : uint256 contractBalance = paymentTokens[paymentMethodId].tokenAddress.balanceOf(address(this)); @@ -169,12 +169,12 @@ 98 : : // External call 99 : 8 : paymentTokens[paymentMethodId].tokenAddress.safeIncreaseAllowance(address(router), fees); 100 : : } else { // Native token - 101 : 10 : uint256 contractBalance = address(this).balance; - 102 [ + + ]: 10 : if (fees > contractBalance){ + 101 : 12 : uint256 contractBalance = address(this).balance; + 102 [ + + ]: 12 : if (fees > contractBalance){ 103 : 2 : revert CCIPErrors.CCIP_SenderPayment_ContractNotEnoughBalance(contractBalance, fees); 104 : : } 105 : : } - 106 : 16 : return fees; + 106 : 18 : return fees; 107 : : } 108 : : } diff --git a/doc/test/coverage/bridge/modules/configuration/index-sort-b.html b/doc/test/coverage/bridge/modules/configuration/index-sort-b.html index 3ccac99..42b5757 100644 --- a/doc/test/coverage/bridge/modules/configuration/index-sort-b.html +++ b/doc/test/coverage/bridge/modules/configuration/index-sort-b.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 10 diff --git a/doc/test/coverage/bridge/modules/configuration/index-sort-f.html b/doc/test/coverage/bridge/modules/configuration/index-sort-f.html index cf6ef25..32d77c1 100644 --- a/doc/test/coverage/bridge/modules/configuration/index-sort-f.html +++ b/doc/test/coverage/bridge/modules/configuration/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 10 diff --git a/doc/test/coverage/bridge/modules/configuration/index-sort-l.html b/doc/test/coverage/bridge/modules/configuration/index-sort-l.html index 6e1d6e4..b6a5b1e 100644 --- a/doc/test/coverage/bridge/modules/configuration/index-sort-l.html +++ b/doc/test/coverage/bridge/modules/configuration/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 10 diff --git a/doc/test/coverage/bridge/modules/configuration/index.html b/doc/test/coverage/bridge/modules/configuration/index.html index 50b0840..40f4066 100644 --- a/doc/test/coverage/bridge/modules/configuration/index.html +++ b/doc/test/coverage/bridge/modules/configuration/index.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 10 diff --git a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func-sort-c.html b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func-sort-c.html index 89d9187..d48310f 100644 --- a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func-sort-c.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -69,8 +69,8 @@ Hit count Sort by hit count - AuthorizationModule.hasRole - 0 + AuthorizationModule.hasRole + 1
diff --git a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func.html b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func.html index faae6c8..a690799 100644 --- a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func.html +++ b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -69,8 +69,8 @@ Hit count Sort by hit count - AuthorizationModule.hasRole - 0 + AuthorizationModule.hasRole + 1
diff --git a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.gcov.html b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.gcov.html index 202b264..5e2047f 100644 --- a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.gcov.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -77,56 +77,47 @@ 6 : : 7 : : 8 : : abstract contract AuthorizationModule is AccessControl{ - 9 : : // MintModule - 10 : : bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE"); - 11 : : // PauseModule - 12 : : bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); - 13 : : + 9 : : /** + 10 : : * @notice Manage the failed message and transfer tokens if necessary. + 11 : : * @dev used by CCCIP Receiver Defensive + 12 : : */ + 13 : : bytes32 public constant BRIDGE_MESSAGE_MANAGER = keccak256("BRIDGE_MESSAGE_MANAGER"); 14 : : - 15 : : bytes32 public constant ROUTER_ROLE = keccak256("ROUTEUR_ROLE"); - 16 : : - 17 : : /** Confirmed **/ - 18 : : /** - 19 : : * @notice Manage the failed message and transfer tokens if necessary. - 20 : : * @dev used by CCCIP Receiver Defensive - 21 : : */ - 22 : : bytes32 public constant BRIDGE_MESSAGE_MANAGER = keccak256("BRIDGE_MESSAGE_MANAGER"); - 23 : : - 24 : : /** - 25 : : * @notice Can manage the different chain allowed by our bridge - 26 : : */ - 27 : : bytes32 public constant BRIDGE_ALLOWLISTED_CHAIN_MANAGER_ROLE = keccak256("BRIDGE_ALLOWLISTED_CHAIN_MANAGER_ROLE"); - 28 : : - 29 : : /** - 30 : : * @notice This role can transfers tokens through the bridge - 31 : : */ - 32 : : bytes32 public constant BRIDGE_USER_ROLE = keccak256("BRIDGE_USER_ROLE"); - 33 : : - 34 : : /** - 35 : : * @notice This role can transfers tokens through the bridge - 36 : : */ - 37 : : bytes32 public constant BRIDGE_OPERATOR_ROLE = keccak256("BRIDGE_OPERATOR_ROLE"); - 38 : : - 39 : : - 40 : : /** - 41 : : * @notice This role can deposit native tokens - 42 : : */ - 43 : : bytes32 public constant BRIDGE_DEPOSITOR_ROLE = keccak256("BRIDGE_DEPOSITOR_ROLE"); - 44 : : - 45 : : /* - 46 : : * @dev Returns `true` if `account` has been granted `role`. - 47 : : */ - 48 : : function hasRole( - 49 : : bytes32 role, - 50 : : address account - 51 : : ) public view virtual override(AccessControl) returns (bool) { - 52 : : // The Default Admin has all roles - 53 [ + + ]: 152 : if (AccessControl.hasRole(DEFAULT_ADMIN_ROLE, account)) { - 54 : 138 : return true; - 55 : : } - 56 : 21 : return AccessControl.hasRole(role, account); - 57 : : } - 58 : : } + 15 : : /** + 16 : : * @notice Can manage the different chain allowed by our bridge + 17 : : */ + 18 : : bytes32 public constant BRIDGE_ALLOWLISTED_CHAIN_MANAGER_ROLE = keccak256("BRIDGE_ALLOWLISTED_CHAIN_MANAGER_ROLE"); + 19 : : + 20 : : /** + 21 : : * @notice This role can transfers tokens through the bridge + 22 : : */ + 23 : : bytes32 public constant BRIDGE_USER_ROLE = keccak256("BRIDGE_USER_ROLE"); + 24 : : + 25 : : /** + 26 : : * @notice This role can transfers tokens through the bridge + 27 : : */ + 28 : : bytes32 public constant BRIDGE_OPERATOR_ROLE = keccak256("BRIDGE_OPERATOR_ROLE"); + 29 : : + 30 : : + 31 : : /** + 32 : : * @notice This role can deposit native tokens + 33 : : */ + 34 : : bytes32 public constant BRIDGE_DEPOSITOR_ROLE = keccak256("BRIDGE_DEPOSITOR_ROLE"); + 35 : : + 36 : : /* + 37 : : * @dev Returns `true` if `account` has been granted `role`. + 38 : : */ + 39 : : function hasRole( + 40 : : bytes32 role, + 41 : : address account + 42 : : ) public view virtual override(AccessControl) returns (bool) { + 43 : : // The Default Admin has all roles + 44 [ + + ]: 164 : if (AccessControl.hasRole(DEFAULT_ADMIN_ROLE, account)) { + 45 : 144 : return true; + 46 : : } + 47 : 30 : return AccessControl.hasRole(role, account); + 48 : : } + 49 : : } diff --git a/doc/test/coverage/bridge/modules/security/index-sort-b.html b/doc/test/coverage/bridge/modules/security/index-sort-b.html index 3e158ec..c4dc4a4 100644 --- a/doc/test/coverage/bridge/modules/security/index-sort-b.html +++ b/doc/test/coverage/bridge/modules/security/index-sort-b.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -88,8 +88,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/coverage/bridge/modules/security/index-sort-f.html b/doc/test/coverage/bridge/modules/security/index-sort-f.html index d2357a9..eb294bd 100644 --- a/doc/test/coverage/bridge/modules/security/index-sort-f.html +++ b/doc/test/coverage/bridge/modules/security/index-sort-f.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -88,8 +88,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/coverage/bridge/modules/security/index-sort-l.html b/doc/test/coverage/bridge/modules/security/index-sort-l.html index b0a1c49..70e9ccc 100644 --- a/doc/test/coverage/bridge/modules/security/index-sort-l.html +++ b/doc/test/coverage/bridge/modules/security/index-sort-l.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -88,8 +88,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/coverage/bridge/modules/security/index.html b/doc/test/coverage/bridge/modules/security/index.html index 4a47e7a..f0ef09d 100644 --- a/doc/test/coverage/bridge/modules/security/index.html +++ b/doc/test/coverage/bridge/modules/security/index.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 0 1 - 0.0 % + 1 + 100.0 % @@ -88,8 +88,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func-sort-c.html b/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func-sort-c.html index 64207c5..ef2360c 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func.html b/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func.html index 6d98a33..89d4db4 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.gcov.html b/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.gcov.html index 2b43892..712a418 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPContractBalance.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 3 diff --git a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func-sort-c.html b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func-sort-c.html index 4646f18..9914c19 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 @@ -78,11 +78,11 @@ CCIPSenderBuild.buildCCIPTransferMessage - 7 + 8 CCIPSenderBuild.buildTokenAmounts - 11 + 12
diff --git a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func.html b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func.html index ad0ebd2..01cb78c 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 @@ -78,11 +78,11 @@ CCIPSenderBuild.buildCCIPTransferMessage - 7 + 8 CCIPSenderBuild.buildTokenAmounts - 11 + 12
diff --git a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.gcov.html b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.gcov.html index c2d7f63..2b0027d 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 @@ -78,22 +78,22 @@ 7 : : function buildTokenAmounts( 8 : : address[] memory _tokens, 9 : : uint256[] memory _amounts) public pure returns (Client.EVMTokenAmount[] memory tokenAmounts){ - 10 [ + + ]: 26 : if( _tokens.length == 0){ + 10 [ + + ]: 28 : if( _tokens.length == 0){ 11 : 2 : revert CCIPErrors.CCIP_SenderBuild_TokensIsEmpty(); 12 : : } - 13 [ + + ]: 24 : if(_tokens.length != _amounts.length){ + 13 [ + + ]: 26 : if(_tokens.length != _amounts.length){ 14 : 2 : revert CCIPErrors.CCIP_SenderBuild_LengthMismatch(); 15 : : } - 16 : 22 : tokenAmounts = new Client.EVMTokenAmount[](_tokens.length); - 17 : 61 : for(uint256 i = 0; i < _tokens.length; ++i ){ - 18 [ + + ]: 45 : if(_tokens[i] == address(0)){ + 16 : 24 : tokenAmounts = new Client.EVMTokenAmount[](_tokens.length); + 17 : 66 : for(uint256 i = 0; i < _tokens.length; ++i ){ + 18 [ + + ]: 48 : if(_tokens[i] == address(0)){ 19 : 2 : revert CCIPErrors.CCIP_SenderBuild_Address_Zero_Not_Allowed(); 20 : : } - 21 : 42 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({ + 21 : 45 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({ 22 : : token: _tokens[i], 23 : : amount: _amounts[i] 24 : : }); - 25 : 28 : tokenAmounts[i] = tokenAmount; + 25 : 30 : tokenAmounts[i] = tokenAmount; 26 : : } 27 : : } 28 : : @@ -107,7 +107,7 @@ 36 : : Client.EVMTokenAmount[] memory _tokenAmounts, 37 : : uint256 paymentMethodId 38 : : ) public view returns (Client.EVM2AnyMessage memory) { - 39 : 21 : return _buildCCIPTransferMessage(_receiver, _tokenAmounts,paymentMethodId ); + 39 : 24 : return _buildCCIPTransferMessage(_receiver, _tokenAmounts,paymentMethodId ); 40 : : } 41 : : 42 : : /// @notice Construct a CCIP message. @@ -122,7 +122,7 @@ 51 : : uint256 gasLimit_, 52 : : address feeToken_ 53 : : ) public pure returns (Client.EVM2AnyMessage memory) { - 54 : 48 : return Client.EVM2AnyMessage({ + 54 : 54 : return Client.EVM2AnyMessage({ 55 : : receiver: abi.encode(_receiver), 56 : : data: abi.encode(_text), 57 : : tokenAmounts: _tokenAmounts, @@ -143,13 +143,13 @@ 72 : : Client.EVMTokenAmount[] memory _tokenAmounts, 73 : : uint256 paymentMethodId 74 : : ) public view returns (Client.EVM2AnyMessage memory) { - 75 : 38 : address feeToken = address(0); - 76 [ + + ]: 19 : if(paymentTokens[paymentMethodId].isActivate){ - 77 : 32 : feeToken = address(paymentTokens[paymentMethodId].tokenAddress); + 75 : 42 : address feeToken = address(0); + 76 [ + + ]: 21 : if(paymentTokens[paymentMethodId].isActivate){ + 77 : 36 : feeToken = address(paymentTokens[paymentMethodId].tokenAddress); 78 : : } else { 79 : 6 : revert CCIPErrors.CCIP_SenderBuild_InvalidFeeId(); 80 : : } - 81 : 48 : return _buildCCIPMessage(_receiver, messageData, _tokenAmounts, messageGasLimit, feeToken); + 81 : 54 : return _buildCCIPMessage(_receiver, messageData, _tokenAmounts, messageGasLimit, feeToken); 82 : : } 83 : : } diff --git a/doc/test/coverage/bridge/modules/wrapper/index-sort-b.html b/doc/test/coverage/bridge/modules/wrapper/index-sort-b.html index ee19c61..905323b 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index-sort-b.html +++ b/doc/test/coverage/bridge/modules/wrapper/index-sort-b.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 5 diff --git a/doc/test/coverage/bridge/modules/wrapper/index-sort-f.html b/doc/test/coverage/bridge/modules/wrapper/index-sort-f.html index 182c611..62927f2 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index-sort-f.html +++ b/doc/test/coverage/bridge/modules/wrapper/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 5 diff --git a/doc/test/coverage/bridge/modules/wrapper/index-sort-l.html b/doc/test/coverage/bridge/modules/wrapper/index-sort-l.html index d834213..d3e4a6e 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index-sort-l.html +++ b/doc/test/coverage/bridge/modules/wrapper/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 5 diff --git a/doc/test/coverage/bridge/modules/wrapper/index.html b/doc/test/coverage/bridge/modules/wrapper/index.html index c7966c5..600df8a 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index.html +++ b/doc/test/coverage/bridge/modules/wrapper/index.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 5 diff --git a/doc/test/coverage/deployment/CCIPSender.sol.func-sort-c.html b/doc/test/coverage/deployment/CCIPSender.sol.func-sort-c.html index c06820c..355399c 100644 --- a/doc/test/coverage/deployment/CCIPSender.sol.func-sort-c.html +++ b/doc/test/coverage/deployment/CCIPSender.sol.func-sort-c.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 @@ -74,11 +74,11 @@ CCIPSender._contextSuffixLength - 95 + 101 CCIPSender._msgSender - 95 + 101
diff --git a/doc/test/coverage/deployment/CCIPSender.sol.func.html b/doc/test/coverage/deployment/CCIPSender.sol.func.html index 4390e48..60a3086 100644 --- a/doc/test/coverage/deployment/CCIPSender.sol.func.html +++ b/doc/test/coverage/deployment/CCIPSender.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 @@ -70,7 +70,7 @@ CCIPSender._contextSuffixLength - 95 + 101 CCIPSender._msgData @@ -78,7 +78,7 @@ CCIPSender._msgSender - 95 + 101
diff --git a/doc/test/coverage/deployment/CCIPSender.sol.gcov.html b/doc/test/coverage/deployment/CCIPSender.sol.gcov.html index fefc0ff..a47915f 100644 --- a/doc/test/coverage/deployment/CCIPSender.sol.gcov.html +++ b/doc/test/coverage/deployment/CCIPSender.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 @@ -99,7 +99,7 @@ 28 : : override(ERC2771Context, Context) 29 : : returns (address sender) 30 : : { - 31 : 285 : return ERC2771Context._msgSender(); + 31 : 303 : return ERC2771Context._msgSender(); 32 : : } 33 : : 34 : : /** @@ -120,7 +120,7 @@ 49 : : function _contextSuffixLength() internal view 50 : : override(ERC2771Context, Context) 51 : : returns (uint256) { - 52 : 285 : return ERC2771Context._contextSuffixLength(); + 52 : 303 : return ERC2771Context._contextSuffixLength(); 53 : : } 54 : : } diff --git a/doc/test/coverage/deployment/index-sort-b.html b/doc/test/coverage/deployment/index-sort-b.html index c3657fc..3089611 100644 --- a/doc/test/coverage/deployment/index-sort-b.html +++ b/doc/test/coverage/deployment/index-sort-b.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 diff --git a/doc/test/coverage/deployment/index-sort-f.html b/doc/test/coverage/deployment/index-sort-f.html index 37c0e1f..78d5f20 100644 --- a/doc/test/coverage/deployment/index-sort-f.html +++ b/doc/test/coverage/deployment/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 diff --git a/doc/test/coverage/deployment/index-sort-l.html b/doc/test/coverage/deployment/index-sort-l.html index 2cc66a4..d1817d9 100644 --- a/doc/test/coverage/deployment/index-sort-l.html +++ b/doc/test/coverage/deployment/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 diff --git a/doc/test/coverage/deployment/index.html b/doc/test/coverage/deployment/index.html index aaed680..640fb5b 100644 --- a/doc/test/coverage/deployment/index.html +++ b/doc/test/coverage/deployment/index.html @@ -37,7 +37,7 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: 2 diff --git a/doc/test/coverage/index-sort-b.html b/doc/test/coverage/index-sort-b.html index fe58d02..96162e2 100644 --- a/doc/test/coverage/index-sort-b.html +++ b/doc/test/coverage/index-sort-b.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 20 + 21 24 - 83.3 % + 87.5 % @@ -124,8 +124,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/coverage/index-sort-f.html b/doc/test/coverage/index-sort-f.html index 0c61e9b..b4a7d56 100644 --- a/doc/test/coverage/index-sort-f.html +++ b/doc/test/coverage/index-sort-f.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 20 + 21 24 - 83.3 % + 87.5 % @@ -81,18 +81,6 @@ Functions Sort by function coverage Branches Sort by branch coverage - - bridge/modules/security - -
100.0%
- - 100.0 % - 3 / 3 - 0.0 % - 0 / 1 - 100.0 % - 2 / 2 - deployment @@ -117,6 +105,18 @@ 75.0 % 18 / 24 + + bridge/modules/security + +
100.0%
+ + 100.0 % + 3 / 3 + 100.0 % + 1 / 1 + 100.0 % + 2 / 2 + bridge diff --git a/doc/test/coverage/index-sort-l.html b/doc/test/coverage/index-sort-l.html index f6b6d12..06c4236 100644 --- a/doc/test/coverage/index-sort-l.html +++ b/doc/test/coverage/index-sort-l.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 20 + 21 24 - 83.3 % + 87.5 % @@ -112,8 +112,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/coverage/index.html b/doc/test/coverage/index.html index 024b76c..1fee93b 100644 --- a/doc/test/coverage/index.html +++ b/doc/test/coverage/index.html @@ -37,12 +37,12 @@ Date: - 2024-04-26 14:53:42 + 2024-04-30 10:51:06 Functions: - 20 + 21 24 - 83.3 % + 87.5 % @@ -112,8 +112,8 @@ 100.0 % 3 / 3 - 0.0 % - 0 / 1 + 100.0 % + 1 / 1 100.0 % 2 / 2 diff --git a/doc/test/lcov.info b/doc/test/lcov.info index 814de52..e6b764f 100644 --- a/doc/test/lcov.info +++ b/doc/test/lcov.info @@ -1,22 +1,22 @@ TN: SF:src/bridge/CCIPBaseSender.sol FN:40,CCIPBaseSender.transferTokens -FNDA:12,CCIPBaseSender.transferTokens -DA:52,10 -DA:52,10 -DA:53,10 -DA:53,10 -DA:54,10 -DA:54,10 -DA:54,10 -DA:58,10 -DA:58,10 -DA:59,10 -DA:59,10 -DA:61,10 -DA:61,10 -DA:63,2 -DA:63,2 +FNDA:13,CCIPBaseSender.transferTokens +DA:52,11 +DA:52,11 +DA:53,11 +DA:53,11 +DA:54,11 +DA:54,11 +DA:54,11 +DA:58,11 +DA:58,11 +DA:59,11 +DA:59,11 +DA:61,11 +DA:61,11 +DA:63,3 +DA:63,3 FN:80,CCIPBaseSender.transferTokensBatch FNDA:2,CCIPBaseSender.transferTokensBatch DA:92,2 @@ -30,29 +30,29 @@ DA:95,2 DA:97,2 DA:97,2 FN:115,CCIPBaseSender._buildEndSend -FNDA:12,CCIPBaseSender._buildEndSend -DA:117,12 -DA:117,12 -DA:117,12 -DA:119,10 -DA:119,10 -DA:119,10 -DA:121,10 -DA:121,10 -DA:122,8 -DA:122,8 -DA:122,14 -DA:122,6 -DA:124,10 -DA:124,10 -DA:126,6 -DA:126,6 -DA:129,4 -DA:129,4 +FNDA:13,CCIPBaseSender._buildEndSend +DA:117,13 +DA:117,13 +DA:117,13 +DA:119,11 +DA:119,11 +DA:119,11 +DA:121,11 +DA:121,11 +DA:122,9 +DA:122,9 +DA:122,16 +DA:122,7 +DA:124,11 +DA:124,11 +DA:126,7 +DA:126,7 +DA:129,5 +DA:129,5 BRDA:129,0,0,- -BRDA:129,0,1,2 -DA:130,2 -DA:130,2 +BRDA:129,0,1,3 +DA:130,3 +DA:130,3 DA:132,2 DA:132,2 FNF:3 @@ -65,19 +65,19 @@ end_of_record TN: SF:src/bridge/modules/configuration/CCIPAllowlistedChain.sol FN:38,CCIPAllowlistedChain.setAllowlistChain -FNDA:17,CCIPAllowlistedChain.setAllowlistChain -DA:43,15 -DA:43,15 +FNDA:18,CCIPAllowlistedChain.setAllowlistChain +DA:43,16 +DA:43,16 BRDA:43,0,0,3 -BRDA:43,0,1,15 +BRDA:43,0,1,16 DA:44,3 DA:44,3 -DA:46,15 -DA:46,15 -BRDA:46,1,0,15 -BRDA:46,1,1,15 -DA:47,15 -DA:47,15 +DA:46,16 +DA:46,16 +BRDA:46,1,0,16 +BRDA:46,1,1,16 +DA:47,16 +DA:47,16 FNF:1 FNH:1 LF:4 @@ -89,9 +89,9 @@ TN: SF:src/bridge/modules/configuration/CCIPRouterManage.sol FN:20,CCIPRouterManage.getRouter FNDA:3,CCIPRouterManage.getRouter -DA:21,13 -DA:21,13 -DA:21,13 +DA:21,14 +DA:21,14 +DA:21,14 FN:27,CCIPRouterManage.getSupportedTokens FNDA:2,CCIPRouterManage.getSupportedTokens DA:30,2 @@ -138,29 +138,29 @@ DA:64,10 DA:65,10 DA:65,10 FN:71,CCIPSenderPayment.isValidPaymentId -FNDA:11,CCIPSenderPayment.isValidPaymentId -DA:72,11 -DA:72,11 -DA:72,11 +FNDA:12,CCIPSenderPayment.isValidPaymentId +DA:72,12 +DA:72,12 +DA:72,12 FN:79,CCIPSenderPayment.changeStatusFeePaymentMethod -FNDA:12,CCIPSenderPayment.changeStatusFeePaymentMethod -DA:80,11 -DA:80,11 +FNDA:13,CCIPSenderPayment.changeStatusFeePaymentMethod +DA:80,12 +DA:80,12 BRDA:80,1,0,1 -BRDA:80,1,1,10 +BRDA:80,1,1,11 DA:81,1 DA:81,1 -DA:83,10 -DA:83,10 +DA:83,11 +DA:83,11 FN:88,CCIPSenderPayment._computeAndApproveFee -FNDA:10,CCIPSenderPayment._computeAndApproveFee -DA:90,10 -DA:90,10 -DA:90,10 -DA:91,10 -DA:91,10 -DA:91,10 -DA:91,10 +FNDA:11,CCIPSenderPayment._computeAndApproveFee +DA:90,11 +DA:90,11 +DA:90,11 +DA:91,11 +DA:91,11 +DA:91,11 +DA:91,11 BRDA:91,2,0,1 BRDA:91,2,1,4 DA:94,5 @@ -174,16 +174,16 @@ DA:96,1 DA:96,1 DA:99,4 DA:99,4 -DA:101,5 -DA:101,5 -DA:102,5 -DA:102,5 +DA:101,6 +DA:101,6 +DA:102,6 +DA:102,6 BRDA:102,4,0,1 -BRDA:102,4,1,4 +BRDA:102,4,1,5 DA:103,1 DA:103,1 -DA:106,8 -DA:106,8 +DA:106,9 +DA:106,9 FNF:6 FNH:6 LF:23 @@ -193,19 +193,19 @@ BRH:10 end_of_record TN: SF:src/bridge/modules/security/AuthorizationModule.sol -FN:48,AuthorizationModule.hasRole -FNDA:0,AuthorizationModule.hasRole -DA:53,76 -DA:53,76 -BRDA:53,0,0,69 -BRDA:53,0,1,7 -DA:54,69 -DA:54,69 -DA:56,7 -DA:56,7 -DA:56,7 +FN:39,AuthorizationModule.hasRole +FNDA:1,AuthorizationModule.hasRole +DA:44,82 +DA:44,82 +BRDA:44,0,0,72 +BRDA:44,0,1,10 +DA:45,72 +DA:45,72 +DA:47,10 +DA:47,10 +DA:47,10 FNF:1 -FNH:0 +FNH:1 LF:3 LH:3 BRF:2 @@ -294,62 +294,62 @@ end_of_record TN: SF:src/bridge/modules/wrapper/CCIPSenderBuild.sol FN:7,CCIPSenderBuild.buildTokenAmounts -FNDA:11,CCIPSenderBuild.buildTokenAmounts -DA:10,13 -DA:10,13 +FNDA:12,CCIPSenderBuild.buildTokenAmounts +DA:10,14 +DA:10,14 BRDA:10,0,0,1 -BRDA:10,0,1,12 +BRDA:10,0,1,13 DA:11,1 DA:11,1 -DA:13,12 -DA:13,12 +DA:13,13 +DA:13,13 BRDA:13,1,0,1 -BRDA:13,1,1,11 +BRDA:13,1,1,12 DA:14,1 DA:14,1 -DA:16,11 -DA:16,11 -DA:17,11 -DA:17,11 -DA:17,25 -DA:17,14 -DA:18,15 -DA:18,15 -DA:18,15 +DA:16,12 +DA:16,12 +DA:17,12 +DA:17,12 +DA:17,27 +DA:17,15 +DA:18,16 +DA:18,16 +DA:18,16 BRDA:18,2,0,1 -BRDA:18,2,1,14 +BRDA:18,2,1,15 DA:19,1 DA:19,1 -DA:21,14 -DA:21,14 -DA:21,14 -DA:25,14 -DA:25,14 +DA:21,15 +DA:21,15 +DA:21,15 +DA:25,15 +DA:25,15 FN:34,CCIPSenderBuild.buildCCIPTransferMessage -FNDA:7,CCIPSenderBuild.buildCCIPTransferMessage -DA:39,7 -DA:39,7 -DA:39,7 +FNDA:8,CCIPSenderBuild.buildCCIPTransferMessage +DA:39,8 +DA:39,8 +DA:39,8 FN:47,CCIPSenderBuild._buildCCIPMessage FNDA:0,CCIPSenderBuild._buildCCIPMessage -DA:54,16 -DA:54,16 -DA:54,16 +DA:54,18 +DA:54,18 +DA:54,18 FN:70,CCIPSenderBuild._buildCCIPTransferMessage FNDA:0,CCIPSenderBuild._buildCCIPTransferMessage -DA:75,19 -DA:75,19 +DA:75,21 +DA:75,21 DA:75,0 -DA:76,19 -BRDA:76,3,0,16 +DA:76,21 +BRDA:76,3,0,18 BRDA:76,3,1,3 -DA:77,16 -DA:77,16 +DA:77,18 +DA:77,18 DA:79,3 DA:79,3 -DA:81,16 -DA:81,16 -DA:81,16 +DA:81,18 +DA:81,18 +DA:81,18 FNF:4 FNH:2 LF:17 @@ -360,20 +360,20 @@ end_of_record TN: SF:src/deployment/CCIPSender.sol FN:25,CCIPSender._msgSender -FNDA:95,CCIPSender._msgSender -DA:31,95 -DA:31,95 -DA:31,95 +FNDA:101,CCIPSender._msgSender +DA:31,101 +DA:31,101 +DA:31,101 FN:37,CCIPSender._msgData FNDA:0,CCIPSender._msgData DA:43,0 DA:43,0 DA:43,0 FN:49,CCIPSender._contextSuffixLength -FNDA:95,CCIPSender._contextSuffixLength -DA:52,95 -DA:52,95 -DA:52,95 +FNDA:101,CCIPSender._contextSuffixLength +DA:52,101 +DA:52,101 +DA:52,101 FNF:3 FNH:2 LF:3 diff --git a/lib/chainlink-local b/lib/chainlink-local new file mode 160000 index 0000000..82524a2 --- /dev/null +++ b/lib/chainlink-local @@ -0,0 +1 @@ +Subproject commit 82524a2fef2e95fa9fcd2372324c225e48767a5f diff --git a/remappings.txt b/remappings.txt index f7bdb73..79b389c 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,5 +1,6 @@ openzeppelin-contracts/=lib/openzeppelin-contracts/contracts ccip/=lib/ccip/contracts/src/v0.8/ccip +chainlink-local/=lib/chainlink-local/ ccip-v08/=lib/ccip/contracts/src/v0.8/ ds-test/=lib/forge-std/lib/ds-test/src/ erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/ diff --git a/src/bridge/modules/configuration/CCIPRouterManage.sol b/src/bridge/modules/configuration/CCIPRouterManage.sol index 57f2bac..4f2499d 100644 --- a/src/bridge/modules/configuration/CCIPRouterManage.sol +++ b/src/bridge/modules/configuration/CCIPRouterManage.sol @@ -37,6 +37,7 @@ abstract contract CCIPRouterManage { } /// @dev only calls from the set router are accepted. + /// Only useful with a receiver contract modifier onlyRouter() { if (msg.sender != address(i_router)){ revert CCIPErrors.CCIP_Router_InvalidRouter(msg.sender); diff --git a/src/bridge/modules/security/AuthorizationModule.sol b/src/bridge/modules/security/AuthorizationModule.sol index 8fc5bb4..df560b6 100644 --- a/src/bridge/modules/security/AuthorizationModule.sol +++ b/src/bridge/modules/security/AuthorizationModule.sol @@ -6,15 +6,6 @@ import "openzeppelin-contracts/access/AccessControl.sol"; abstract contract AuthorizationModule is AccessControl{ - // MintModule - bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE"); - // PauseModule - bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); - - - bytes32 public constant ROUTER_ROLE = keccak256("ROUTEUR_ROLE"); - - /** Confirmed **/ /** * @notice Manage the failed message and transfer tokens if necessary. * @dev used by CCCIP Receiver Defensive diff --git a/test/HelperContract.sol b/test/HelperContract.sol index c0be82c..7e5595f 100644 --- a/test/HelperContract.sol +++ b/test/HelperContract.sol @@ -15,7 +15,7 @@ abstract contract HelperContract is Test, AuthorizationModule{ CCIPSender CCIPSENDER_CONTRACT; // EOA to perform tests address constant ZERO_ADDRESS = address(0); - address constant DEFAULT_ADMIN_ADDRESS = address(1); + //address constant DEFAULT_ADMIN_ADDRESS = address(1); // Operator address constant DEBT_VAULT_OPERATOR_ADDRESS = address(2); address constant DEBT_VAULT_DEPOSIT_OPERATOR_ADDRESS = address(3); @@ -28,11 +28,12 @@ abstract contract HelperContract is Test, AuthorizationModule{ address constant TOKEN_PAYMENT_ADMIN = address(8); address constant CCIPSENDER_ADMIN = address(0x9); address constant RECEIVER_ADDRESS = address(0xA); + address constant SENDER_ADDRESS = address(0xB); uint64 AVALANCHE_SELECTOR = 6433500567565415381; IERC20 AVALANCHE_USDC = IERC20(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E); + // role string - string constant DEFAULT_ADMIN_ROLE_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000"; diff --git a/test/simulator/Simulator.sol b/test/simulator/Simulator.sol new file mode 100644 index 0000000..34adde6 --- /dev/null +++ b/test/simulator/Simulator.sol @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import {Test, console2} from "forge-std/Test.sol"; +import {CCIPLocalSimulator,BurnMintERC677Helper} from "chainlink-local/src/ccip/CCIPLocalSimulator.sol"; +import {IRouterClient as IRouterClientSimulator} from "chainlink-local/src/ccip/CCIPLocalSimulator.sol"; +import {WETH9} from "chainlink-local/src/shared/WETH9.sol"; +import {LinkToken} from "chainlink-local/src/shared/LinkToken.sol"; +import {Client} from "ccip/libraries/Client.sol"; +import "src/deployment/CCIPSender.sol"; +import "../HelperContract.sol"; +contract SimulatorTest is Test, HelperContract { + uint256 feePaymentId = 0; + // CCIP Simulator + CCIPLocalSimulator public ccipLocalSimulator; + uint64 chainSelector; + BurnMintERC677Helper ccipBnM; + IRouterClientSimulator sourceRouter; + + function setUp() public { + uint64 chainSelector_; + IRouterClientSimulator sourceRouter_; + IRouterClientSimulator destinationRouter_; + WETH9 wrappedNative_; + LinkToken linkToken_; + BurnMintERC677Helper ccipBnM_; + BurnMintERC677Helper ccipLnM_; + // CCIP local simulator + ccipLocalSimulator = new CCIPLocalSimulator(); + ( + chainSelector_, + sourceRouter_, + destinationRouter_, + wrappedNative_, + linkToken_, + ccipBnM_, + ccipLnM_ + + ) = ccipLocalSimulator.configuration(); + + // Sender + + // Deploy CCIP Sender + CCIPSENDER_CONTRACT = new CCIPSender( + CCIPSENDER_ADMIN, + address(sourceRouter_), + ZERO_ADDRESS + ); + + chainSelector = chainSelector_; + ccipBnM = ccipBnM_; + sourceRouter = sourceRouter_; + } + + + function _configureAllowListedChain() internal { + vm.prank(CCIPSENDER_ADMIN); + CCIPSENDER_CONTRACT.setAllowlistChain(AVALANCHE_SELECTOR, false, true); + } + + function _configurefee() internal { + vm.prank(CCIPSENDER_ADMIN); + CCIPSENDER_CONTRACT.changeStatusFeePaymentMethod(feePaymentId, true); + } + + function testCanPayInNativeTokensWithSimulator() external { + vm.prank(CCIPSENDER_ADMIN); + CCIPSENDER_CONTRACT.grantRole(BRIDGE_USER_ROLE, SENDER_ADDRESS); + resBool = CCIPSENDER_CONTRACT.hasRole(BRIDGE_USER_ROLE, SENDER_ADDRESS); + assertEq(resBool, true); + vm.prank(SENDER_ADDRESS); + ccipBnM.drip(SENDER_ADDRESS); + uint256 value = 1000; + + vm.prank(SENDER_ADDRESS); + ccipBnM.increaseApproval(address(CCIPSENDER_CONTRACT), value); + assertEq(ccipBnM.allowance(SENDER_ADDRESS, address(CCIPSENDER_CONTRACT)), value); + + uint256 balanceOfSenderBefore = ccipBnM.balanceOf(SENDER_ADDRESS); + uint256 balanceOfReceiverBefore = ccipBnM.balanceOf(RECEIVER_ADDRESS); + + _configureAllowListedChain(); + _configurefee(); + vm.prank(SENDER_ADDRESS); + bytes32 messageId = CCIPSENDER_CONTRACT.transferTokens(AVALANCHE_SELECTOR, RECEIVER_ADDRESS, address(ccipBnM), value, feePaymentId); + + uint256 balanceOfSenderAfter = ccipBnM.balanceOf(SENDER_ADDRESS); + uint256 balanceOfReceiverAfter = ccipBnM.balanceOf(RECEIVER_ADDRESS); + assertEq(balanceOfSenderAfter, balanceOfSenderBefore - value); + assertEq(balanceOfReceiverAfter, balanceOfReceiverBefore + value); + + // Check messageId + // Arrange + address[] memory _tokens = new address[](1); + uint256[] memory _amounts = new uint256[](1); + _tokens[0] = address(ccipBnM); + _amounts[0] = value; + + // Assert messageId + Client.EVMTokenAmount[] memory tokenAmounts = CCIPSENDER_CONTRACT.buildTokenAmounts(_tokens, _amounts); + + bytes32 mockMsgId = keccak256(abi.encode(CCIPSENDER_CONTRACT.buildCCIPTransferMessage(RECEIVER_ADDRESS, tokenAmounts, 0))); + assertEq(messageId, mockMsgId); + } +} \ No newline at end of file diff --git a/test/utils/router.sol b/test/utils/router.sol index e7f36d7..ffba95b 100644 --- a/test/utils/router.sol +++ b/test/utils/router.sol @@ -14,7 +14,7 @@ import {IERC20} from "ccip-v08/vendor/openzeppelin-solidity/v4.8.3/contracts/tok import {ERC165Checker} from "ccip-v08/vendor/openzeppelin-solidity/v4.8.3/contracts/utils/introspection/ERC165Checker.sol"; contract MockCCIPRouter is IRouter, IRouterClient, HelperContract { - //error InsufficientFeeTokenAmount(); + //error InsufficientFeeTokenAmount(); // error InvalidMsgValue(); constructor(address[] memory supportedTokens_){ @@ -22,8 +22,8 @@ contract MockCCIPRouter is IRouter, IRouterClient, HelperContract { } - // add this to be excluded from coverage report - function test() public {} +// add this to be excluded from coverage report +function test() public {} ////Token address address[] supportedTokens;