diff --git a/doc/TOOLCHAIN.md b/doc/TOOLCHAIN.md index f52d703..dbae595 100644 --- a/doc/TOOLCHAIN.md +++ b/doc/TOOLCHAIN.md @@ -95,7 +95,7 @@ OR - CCIPSender ```bash -npx surya graph src/CCIPSender.sol | dot -Tpng > surya_graph_CCIPSender.png +npx surya graph src/deployment/CCIPSender.sol | dot -Tpng > surya_graph_CCIPSender.png ``` #### Report diff --git a/doc/schema/CCIPSenderPayment.png b/doc/schema/CCIPSenderPayment.png index 5f5a22f..30920f0 100644 Binary files a/doc/schema/CCIPSenderPayment.png and b/doc/schema/CCIPSenderPayment.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_AuthorizationModule.sol.png b/doc/schema/surya/surya_graph/surya_graph_AuthorizationModule.sol.png index 4030f87..5f63474 100644 Binary files a/doc/schema/surya/surya_graph/surya_graph_AuthorizationModule.sol.png and b/doc/schema/surya/surya_graph/surya_graph_AuthorizationModule.sol.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPBaseReceiver.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPBaseReceiver.sol.png deleted file mode 100644 index fb16136..0000000 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPBaseReceiver.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPBaseSender.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPBaseSender.sol.png index 4713d4c..e32ee68 100644 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPBaseSender.sol.png and b/doc/schema/surya/surya_graph/surya_graph_CCIPBaseSender.sol.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPContractBalance.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPContractBalance.sol.png new file mode 100644 index 0000000..ff4070f Binary files /dev/null and b/doc/schema/surya/surya_graph/surya_graph_CCIPContractBalance.sol.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPReceiverDefensive.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPReceiverDefensive.sol.png deleted file mode 100644 index 8fa0c43..0000000 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPReceiverDefensive.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPReceiverInternal.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPReceiverInternal.sol.png deleted file mode 100644 index 296635a..0000000 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPReceiverInternal.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPRouterManage.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPRouterManage.sol.png index 371e144..6ec207f 100644 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPRouterManage.sol.png and b/doc/schema/surya/surya_graph/surya_graph_CCIPRouterManage.sol.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPSenderBuild.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPSenderBuild.sol.png index fe1c4eb..cc46bde 100644 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPSenderBuild.sol.png and b/doc/schema/surya/surya_graph/surya_graph_CCIPSenderBuild.sol.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPSenderPayment.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPSenderPayment.sol.png index 0a2cf9e..781f23f 100644 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPSenderPayment.sol.png and b/doc/schema/surya/surya_graph/surya_graph_CCIPSenderPayment.sol.png differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPSenderReceiver.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPSenderReceiver.sol.png deleted file mode 100644 index fa22439..0000000 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPSenderReceiver.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_graph/surya_graph_CCIPWithdraw.sol.png b/doc/schema/surya/surya_graph/surya_graph_CCIPWithdraw.sol.png deleted file mode 100644 index 81958d2..0000000 Binary files a/doc/schema/surya/surya_graph/surya_graph_CCIPWithdraw.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPBaseReceiver.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPBaseReceiver.sol.png deleted file mode 100644 index ac4a9f2..0000000 Binary files a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPBaseReceiver.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPContractBalance.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPContractBalance.sol.png new file mode 100644 index 0000000..fe0fdb8 Binary files /dev/null and b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPContractBalance.sol.png differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPReceiverDefensive.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPReceiverDefensive.sol.png deleted file mode 100644 index 2e8d3b0..0000000 Binary files a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPReceiverDefensive.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPReceiverInternal.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPReceiverInternal.sol.png deleted file mode 100644 index 191dbdd..0000000 Binary files a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPReceiverInternal.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSender.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSender.sol.png index adb1a5f..acc2bfb 100644 Binary files a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSender.sol.png and b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSender.sol.png differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSenderReceiver.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSenderReceiver.sol.png deleted file mode 100644 index acc05a5..0000000 Binary files a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPSenderReceiver.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPWithdraw.sol.png b/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPWithdraw.sol.png deleted file mode 100644 index 3bb4b2b..0000000 Binary files a/doc/schema/surya/surya_inheritance/surya_inheritance_CCIPWithdraw.sol.png and /dev/null differ diff --git a/doc/schema/surya/surya_report/surya_report_AuthorizationModule.sol.md b/doc/schema/surya/surya_report/surya_report_AuthorizationModule.sol.md index ea45e57..f1433ac 100644 --- a/doc/schema/surya/surya_report/surya_report_AuthorizationModule.sol.md +++ b/doc/schema/surya/surya_report/surya_report_AuthorizationModule.sol.md @@ -17,7 +17,6 @@ |||||| | **AuthorizationModule** | Implementation | AccessControl ||| | └ | hasRole | Public ❗️ | |NO❗️ | -| └ | supportsInterface | Public ❗️ | |NO❗️ | ### Legend diff --git a/doc/schema/surya/surya_report/surya_report_CCIPBaseReceiver.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPBaseReceiver.sol.md deleted file mode 100644 index 9f5a822..0000000 --- a/doc/schema/surya/surya_report/surya_report_CCIPBaseReceiver.sol.md +++ /dev/null @@ -1,30 +0,0 @@ -## Sūrya's Description Report - -### Files Description Table - - -| File Name | SHA-1 Hash | -|-------------|--------------| -| ./bridge/CCIPBaseReceiver.sol | [object Promise] | - - -### Contracts Description Table - - -| Contract | Type | Bases | | | -|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:| -| └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | -|||||| -| **CCIPBaseReceiver** | Implementation | CCIPAllowlistedChain, CCIPReceiverDefensive, CCIPRouterManage ||| -| └ | ccipReceive | External ❗️ | 🛑 | onlyRouter onlyAllowlisted | -| └ | processMessage | External ❗️ | 🛑 | onlySelf onlyAllowlisted | -| └ | _ccipReceive | Internal 🔒 | 🛑 | | -| └ | supportsInterface | Public ❗️ | |NO❗️ | - - -### Legend - -| Symbol | Meaning | -|:--------:|-----------| -| 🛑 | Function can modify state | -| 💵 | Function is payable | diff --git a/doc/schema/surya/surya_report/surya_report_CCIPBaseSender.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPBaseSender.sol.md index 985cdd1..55f7e40 100644 --- a/doc/schema/surya/surya_report/surya_report_CCIPBaseSender.sol.md +++ b/doc/schema/surya/surya_report/surya_report_CCIPBaseSender.sol.md @@ -16,9 +16,9 @@ | └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | |||||| | **CCIPBaseSender** | Implementation | CCIPAllowlistedChain, CCIPSenderBuild, CCIPRouterManage ||| -| └ | transferTokens | External ❗️ | 🛑 | onlyRole | -| └ | transferTokensBatch | External ❗️ | 🛑 | onlyRole | -| └ | buildEndSend | Internal 🔒 | 🛑 | | +| └ | transferTokens | External ❗️ | 🛑 | onlyRole onlyAllowlistedDestinationChain | +| └ | transferTokensBatch | External ❗️ | 🛑 | onlyRole onlyAllowlistedDestinationChain | +| └ | _buildEndSend | Internal 🔒 | 🛑 | | ### Legend diff --git a/doc/schema/surya/surya_report/surya_report_CCIPWithdraw.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPContractBalance.sol.md similarity index 64% rename from doc/schema/surya/surya_report/surya_report_CCIPWithdraw.sol.md rename to doc/schema/surya/surya_report/surya_report_CCIPContractBalance.sol.md index fb69813..5be613e 100644 --- a/doc/schema/surya/surya_report/surya_report_CCIPWithdraw.sol.md +++ b/doc/schema/surya/surya_report/surya_report_CCIPContractBalance.sol.md @@ -5,7 +5,7 @@ | File Name | SHA-1 Hash | |-------------|--------------| -| ./bridge/modules/wrapper/CCIPWithdraw.sol | [object Promise] | +| ./bridge/modules/wrapper/CCIPContractBalance.sol | [object Promise] | ### Contracts Description Table @@ -15,10 +15,10 @@ |:----------:|:-------------------:|:----------------:|:----------------:|:---------------:| | └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | |||||| -| **CCIPWithdraw** | Implementation | AuthorizationModule ||| -| └ | | External ❗️ | 💵 |NO❗️ | -| └ | withdrawToken | Public ❗️ | 🛑 | onlyRole | -| └ | withdrawNativeToken | Public ❗️ | 🛑 | onlyRole | +| **CCIPContractBalance** | Implementation | AuthorizationModule ||| +| └ | depositNativeTokens | Public ❗️ | 💵 | onlyRole | +| └ | withdrawTokens | Public ❗️ | 🛑 | onlyRole | +| └ | withdrawNativeTokens | Public ❗️ | 🛑 | onlyRole | ### Legend diff --git a/doc/schema/surya/surya_report/surya_report_CCIPReceiverDefensive.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPReceiverDefensive.sol.md deleted file mode 100644 index dc6bda1..0000000 --- a/doc/schema/surya/surya_report/surya_report_CCIPReceiverDefensive.sol.md +++ /dev/null @@ -1,31 +0,0 @@ -## Sūrya's Description Report - -### Files Description Table - - -| File Name | SHA-1 Hash | -|-------------|--------------| -| ./bridge/modules/wrapper/CCIPReceiverDefensive.sol | [object Promise] | - - -### Contracts Description Table - - -| Contract | Type | Bases | | | -|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:| -| └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | -|||||| -| **CCIPReceiverDefensive** | Implementation | CCIPReceiverInternal, AuthorizationModule ||| -| └ | getLastReceivedMessageDetails | Public ❗️ | |NO❗️ | -| └ | getFailedMessagesIds | External ❗️ | |NO❗️ | -| └ | retryFailedMessage | External ❗️ | 🛑 | onlyRole | -| └ | setSimRevert | Public ❗️ | 🛑 | onlyRole | -| └ | supportsInterface | Public ❗️ | |NO❗️ | - - -### Legend - -| Symbol | Meaning | -|:--------:|-----------| -| 🛑 | Function can modify state | -| 💵 | Function is payable | diff --git a/doc/schema/surya/surya_report/surya_report_CCIPReceiverInternal.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPReceiverInternal.sol.md deleted file mode 100644 index 7573bc1..0000000 --- a/doc/schema/surya/surya_report/surya_report_CCIPReceiverInternal.sol.md +++ /dev/null @@ -1,28 +0,0 @@ -## Sūrya's Description Report - -### Files Description Table - - -| File Name | SHA-1 Hash | -|-------------|--------------| -| ./bridge/modules/internal/CCIPReceiverInternal.sol | [object Promise] | - - -### Contracts Description Table - - -| Contract | Type | Bases | | | -|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:| -| └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | -|||||| -| **CCIPReceiverInternal** | Implementation | IAny2EVMMessageReceiver, IERC165 ||| -| └ | supportsInterface | Public ❗️ | |NO❗️ | -| └ | _ccipReceive | Internal 🔒 | 🛑 | | - - -### Legend - -| Symbol | Meaning | -|:--------:|-----------| -| 🛑 | Function can modify state | -| 💵 | Function is payable | diff --git a/doc/schema/surya/surya_report/surya_report_CCIPRouterManage.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPRouterManage.sol.md index f63c512..3c73087 100644 --- a/doc/schema/surya/surya_report/surya_report_CCIPRouterManage.sol.md +++ b/doc/schema/surya/surya_report/surya_report_CCIPRouterManage.sol.md @@ -19,6 +19,7 @@ | └ | | Public ❗️ | 🛑 |NO❗️ | | └ | getRouter | Public ❗️ | |NO❗️ | | └ | getSupportedTokens | External ❗️ | |NO❗️ | +| └ | getFee | Public ❗️ | |NO❗️ | ### Legend diff --git a/doc/schema/surya/surya_report/surya_report_CCIPSender.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPSender.sol.md index 7b07cfa..d90a0c3 100644 --- a/doc/schema/surya/surya_report/surya_report_CCIPSender.sol.md +++ b/doc/schema/surya/surya_report/surya_report_CCIPSender.sol.md @@ -15,7 +15,7 @@ |:----------:|:-------------------:|:----------------:|:----------------:|:---------------:| | └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | |||||| -| **CCIPSender** | Implementation | CCIPBaseSender, CCIPWithdraw, ERC2771Context ||| +| **CCIPSender** | Implementation | CCIPBaseSender, CCIPContractBalance, ERC2771Context ||| | └ | | Public ❗️ | 🛑 | CCIPRouterManage ERC2771Context | | └ | _msgSender | Internal 🔒 | | | | └ | _msgData | Internal 🔒 | | | diff --git a/doc/schema/surya/surya_report/surya_report_CCIPSenderBuild.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPSenderBuild.sol.md index a70e6a3..cfbc0f9 100644 --- a/doc/schema/surya/surya_report/surya_report_CCIPSenderBuild.sol.md +++ b/doc/schema/surya/surya_report/surya_report_CCIPSenderBuild.sol.md @@ -16,10 +16,10 @@ | └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | |||||| | **CCIPSenderBuild** | Implementation | CCIPSenderPayment ||| -| └ | _buildCCIPMessage | Internal 🔒 | | | -| └ | _buildCCIPTransferMessage | Internal 🔒 | | | -| └ | buildCCIPTransferMessage | Public ❗️ | |NO❗️ | | └ | buildTokenAmounts | Public ❗️ | |NO❗️ | +| └ | buildCCIPTransferMessage | Public ❗️ | |NO❗️ | +| └ | _buildCCIPMessage | Public ❗️ | |NO❗️ | +| └ | _buildCCIPTransferMessage | Public ❗️ | |NO❗️ | ### Legend diff --git a/doc/schema/surya/surya_report/surya_report_CCIPSenderPayment.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPSenderPayment.sol.md index f6d6485..feaa738 100644 --- a/doc/schema/surya/surya_report/surya_report_CCIPSenderPayment.sol.md +++ b/doc/schema/surya/surya_report/surya_report_CCIPSenderPayment.sol.md @@ -16,6 +16,8 @@ | └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | |||||| | **CCIPSenderPayment** | Implementation | AuthorizationModule ||| +| └ | setMessageGasLimit | Public ❗️ | 🛑 | onlyRole | +| └ | setMessageData | Public ❗️ | 🛑 | onlyRole | | └ | setFeePaymentMethod | Public ❗️ | 🛑 | onlyRole | | └ | isValidPaymentId | Internal 🔒 | | | | └ | changeStatusFeePaymentMethod | Public ❗️ | 🛑 | onlyRole | diff --git a/doc/schema/surya/surya_report/surya_report_CCIPSenderReceiver.sol.md b/doc/schema/surya/surya_report/surya_report_CCIPSenderReceiver.sol.md deleted file mode 100644 index 82f1653..0000000 --- a/doc/schema/surya/surya_report/surya_report_CCIPSenderReceiver.sol.md +++ /dev/null @@ -1,28 +0,0 @@ -## Sūrya's Description Report - -### Files Description Table - - -| File Name | SHA-1 Hash | -|-------------|--------------| -| ./deployment/CCIPSenderReceiver.sol | [object Promise] | - - -### Contracts Description Table - - -| Contract | Type | Bases | | | -|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:| -| └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** | -|||||| -| **CCIPSenderReceiver** | Implementation | CCIPBaseReceiver, CCIPBaseSender, CCIPWithdraw ||| -| └ | | Public ❗️ | 🛑 | CCIPRouterManage | -| └ | supportsInterface | Public ❗️ | |NO❗️ | - - -### Legend - -| Symbol | Meaning | -|:--------:|-----------| -| 🛑 | Function can modify state | -| 💵 | Function is payable | 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 08e1a5b..64a9dc6 100644 --- a/doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html +++ b/doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 diff --git a/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html b/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html index 5257b02..0c676b1 100644 --- a/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html +++ b/doc/test/coverage/bridge/CCIPBaseSender.sol.func.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 diff --git a/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html b/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html index d793b57..e57ee21 100644 --- a/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html +++ b/doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 @@ -194,15 +194,17 @@ 123 : : // transfer tokens to the contract 124 : 20 : 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 : 18 : bool result = IERC20(tokenAmounts[i].token).approve(address(router), tokenAmounts[i].amount); - 127 [ # + ]: 12 : if(!result){ - 128 : 0 : revert CCIPErrors.CCIP_BaseSender_FailApproval(); - 129 : : } - 130 : : } - 131 : : // Send CCIP Message - 132 : 8 : messageId = router.ccipSend(_destinationChainSelector, message); - 133 : : } - 134 : : } + 126 : 12 : 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); + 131 : : } else{ + 132 : 4 : messageId = router.ccipSend(_destinationChainSelector, message); + 133 : : } + 134 : : + 135 : : } + 136 : : } diff --git a/doc/test/coverage/bridge/index-sort-b.html b/doc/test/coverage/bridge/index-sort-b.html index 1f7c23d..a427a78 100644 --- a/doc/test/coverage/bridge/index-sort-b.html +++ b/doc/test/coverage/bridge/index-sort-b.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 @@ -84,10 +84,10 @@ CCIPBaseSender.sol -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 + 100.0 % + 21 / 21 100.0 % 3 / 3 50.0 % diff --git a/doc/test/coverage/bridge/index-sort-f.html b/doc/test/coverage/bridge/index-sort-f.html index 20aedc6..15eaed5 100644 --- a/doc/test/coverage/bridge/index-sort-f.html +++ b/doc/test/coverage/bridge/index-sort-f.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 @@ -84,10 +84,10 @@ CCIPBaseSender.sol -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 + 100.0 % + 21 / 21 100.0 % 3 / 3 50.0 % diff --git a/doc/test/coverage/bridge/index-sort-l.html b/doc/test/coverage/bridge/index-sort-l.html index 4f41964..df8caf3 100644 --- a/doc/test/coverage/bridge/index-sort-l.html +++ b/doc/test/coverage/bridge/index-sort-l.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 @@ -84,10 +84,10 @@ CCIPBaseSender.sol -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 + 100.0 % + 21 / 21 100.0 % 3 / 3 50.0 % diff --git a/doc/test/coverage/bridge/index.html b/doc/test/coverage/bridge/index.html index 6262644..05299db 100644 --- a/doc/test/coverage/bridge/index.html +++ b/doc/test/coverage/bridge/index.html @@ -31,13 +31,13 @@ lcov.info Lines: - 20 21 - 95.2 % + 21 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 3 @@ -84,10 +84,10 @@ CCIPBaseSender.sol -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 + 100.0 % + 21 / 21 100.0 % 3 / 3 50.0 % 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 6e0d82e..796dc1e 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 1 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 a86d74c..8ded0fe 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 1 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 b74eff1..6468b4b 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 1 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 783dfa8..b854890 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 @@ -31,17 +31,17 @@ lcov.info Lines: - 2 - 2 + 4 + 4 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 2 - 2 + 3 + 3 100.0 % @@ -69,11 +69,15 @@ Hit count Sort by hit count - CCIPRouterManage.getSupportedTokens + CCIPRouterManage.getFee + 1 + + + CCIPRouterManage.getSupportedTokens 2 - CCIPRouterManage.getRouter + CCIPRouterManage.getRouter 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 8386a3f..a0aeec3 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html @@ -31,17 +31,17 @@ lcov.info Lines: - 2 - 2 + 4 + 4 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 2 - 2 + 3 + 3 100.0 % @@ -69,11 +69,15 @@ Hit count Sort by hit count - CCIPRouterManage.getRouter + CCIPRouterManage.getFee + 1 + + + CCIPRouterManage.getRouter 3 - CCIPRouterManage.getSupportedTokens + CCIPRouterManage.getSupportedTokens 2 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 4a6b3a5..a77080c 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.gcov.html @@ -31,17 +31,17 @@ lcov.info Lines: - 2 - 2 + 4 + 4 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 2 - 2 + 3 + 3 100.0 % @@ -72,42 +72,49 @@ 1 : : // SPDX-License-Identifier: MIT 2 : : pragma solidity ^0.8.0; 3 : : import {IRouterClient} from "ccip/interfaces/IRouterClient.sol"; - 4 : : import "../libraries/CCIPErrors.sol"; - 5 : : - 6 : : /// @title CCIPReceiver - Base contract for CCIP applications that can receive messages. - 7 : : abstract contract CCIPRouterManage { - 8 : : address internal immutable i_router; - 9 : : - 10 : : constructor(address router) { - 11 : : if (router == address(0)){ - 12 : : revert CCIPErrors.CCIP_Router_Address_Zero_Not_Allowed(); - 13 : : } - 14 : : i_router = router; - 15 : : } - 16 : : - 17 : : /// @notice Return the current router - 18 : : /// @return i_router address - 19 : : function getRouter() public view returns (address) { - 20 : 39 : return address(i_router); - 21 : : } - 22 : : /** - 23 : : * @param chainSelector blockchain selector - 24 : : * @return tokens list of contract address for all supported tokens - 25 : : */ - 26 : : function getSupportedTokens( - 27 : : uint64 chainSelector - 28 : : ) external view returns (address[] memory tokens) { - 29 : 4 : tokens = IRouterClient(i_router).getSupportedTokens(chainSelector); - 30 : : } - 31 : : - 32 : : /// @dev only calls from the set router are accepted. - 33 : : modifier onlyRouter() { - 34 : : if (msg.sender != address(i_router)){ - 35 : : revert CCIPErrors.CCIP_Router_InvalidRouter(msg.sender); - 36 : : } - 37 : : _; - 38 : : } - 39 : : } + 4 : : import {Client} from "ccip/libraries/Client.sol"; + 5 : : import "../libraries/CCIPErrors.sol"; + 6 : : + 7 : : /// @title CCIPReceiver - Base contract for CCIP applications that can receive messages. + 8 : : abstract contract CCIPRouterManage { + 9 : : address internal immutable i_router; + 10 : : + 11 : : constructor(address router) { + 12 : : if (router == address(0)){ + 13 : : revert CCIPErrors.CCIP_Router_Address_Zero_Not_Allowed(); + 14 : : } + 15 : : i_router = router; + 16 : : } + 17 : : + 18 : : /// @notice Return the current router + 19 : : /// @return i_router address + 20 : : function getRouter() public view returns (address) { + 21 : 39 : return address(i_router); + 22 : : } + 23 : : /** + 24 : : * @param chainSelector blockchain selector + 25 : : * @return tokens list of contract address for all supported tokens + 26 : : */ + 27 : : function getSupportedTokens( + 28 : : uint64 chainSelector + 29 : : ) external view returns (address[] memory tokens) { + 30 : 4 : tokens = IRouterClient(i_router).getSupportedTokens(chainSelector); + 31 : : } + 32 : : + 33 : : function getFee(uint64 _destinationChainSelector, Client.EVM2AnyMessage memory message ) public view returns(uint256){ + 34 : : // external call + 35 : 3 : uint256 fees = IRouterClient(i_router).getFee(_destinationChainSelector, message); + 36 : 2 : return fees; + 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 : : } 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 9b0377d..f2536a6 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 @@ -31,17 +31,17 @@ lcov.info Lines: - 22 23 - 95.7 % + 23 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 5 - 5 + 6 + 6 100.0 % @@ -50,8 +50,8 @@ Branches: 10 - 12 - 83.3 % + 10 + 100.0 % @@ -69,23 +69,27 @@ Hit count Sort by hit count - CCIPSenderPayment.setGasLimit + CCIPSenderPayment.setMessageData 2 - CCIPSenderPayment._computeAndApproveFee - 10 + CCIPSenderPayment.setMessageGasLimit + 2 - CCIPSenderPayment.isValidPaymentId + CCIPSenderPayment._computeAndApproveFee 10 - CCIPSenderPayment.changeStatusFeePaymentMethod + CCIPSenderPayment.isValidPaymentId 11 - CCIPSenderPayment.setFeePaymentMethod + CCIPSenderPayment.changeStatusFeePaymentMethod + 12 + + + CCIPSenderPayment.setFeePaymentMethod 12 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 1b0105c..df3a2e7 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.func.html @@ -31,17 +31,17 @@ lcov.info Lines: - 22 23 - 95.7 % + 23 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 5 - 5 + 6 + 6 100.0 % @@ -50,8 +50,8 @@ Branches: 10 - 12 - 83.3 % + 10 + 100.0 % @@ -69,23 +69,27 @@ Hit count Sort by hit count - CCIPSenderPayment._computeAndApproveFee + CCIPSenderPayment._computeAndApproveFee 10 - CCIPSenderPayment.changeStatusFeePaymentMethod - 11 + CCIPSenderPayment.changeStatusFeePaymentMethod + 12 - CCIPSenderPayment.isValidPaymentId - 10 + CCIPSenderPayment.isValidPaymentId + 11 - CCIPSenderPayment.setFeePaymentMethod + CCIPSenderPayment.setFeePaymentMethod 12 - CCIPSenderPayment.setGasLimit + CCIPSenderPayment.setMessageData + 2 + + + CCIPSenderPayment.setMessageGasLimit 2 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 e88750b..db68a79 100644 --- a/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/configuration/CCIPSenderPayment.sol.gcov.html @@ -31,17 +31,17 @@ lcov.info Lines: - 22 23 - 95.7 % + 23 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 5 - 5 + 6 + 6 100.0 % @@ -50,8 +50,8 @@ Branches: 10 - 12 - 83.3 % + 10 + 100.0 % @@ -73,95 +73,110 @@ 2 : : pragma solidity ^0.8.20; 3 : : 4 : : import {IERC20} from "ccip-v08/vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; - 5 : : import {Client} from "ccip/libraries/Client.sol"; - 6 : : import {IRouterClient} from "ccip/interfaces/IRouterClient.sol"; - 7 : : import "../libraries/CCIPErrors.sol"; - 8 : : import "../security/AuthorizationModule.sol"; - 9 : : - 10 : : abstract contract CCIPSenderPayment is AuthorizationModule{ - 11 : : uint256 private paymentIdCounter = 1; - 12 : : struct FEE_PAYMENT_TOKEN { - 13 : : uint256 id; - 14 : : string label; - 15 : : bool isActivate; - 16 : : IERC20 tokenAddress; - 17 : : } - 18 : : event GasLimit(uint256 newGasLimit); - 19 : : mapping(uint256 => FEE_PAYMENT_TOKEN) public paymentTokens; - 20 : : // List of configured payment - 21 : : mapping(address => bool) public tokenPaymentConfigured; - 22 : : /** - 23 : : * @notice - 24 : : * @dev set to zero since no receiver contract - 25 : : */ - 26 : : uint256 public gasLimit = 0; - 27 : : function setGasLimit(uint256 gasLimit_) public onlyRole(BRIDGE_OPERATOR_ROLE){ - 28 : 2 : gasLimit = gasLimit_; - 29 : 2 : emit GasLimit(gasLimit_); - 30 : : } - 31 : : - 32 : : /** - 33 : : * @notice set the fee payment - 34 : : * @param tokenAddress_ Token address, ERC-20 - 35 : : * @param label_ token label, e.g. "USDC" - 36 : : */ - 37 : : function setFeePaymentMethod(IERC20 tokenAddress_, string calldata label_) public onlyRole(BRIDGE_OPERATOR_ROLE) { - 38 [ + + ]: 11 : if(tokenPaymentConfigured[address(tokenAddress_)]){ - 39 : 2 : revert CCIPErrors.CCIP_SenderPayment_TokenAlreadySet(); - 40 : : } - 41 : 20 : paymentTokens[paymentIdCounter] = FEE_PAYMENT_TOKEN({ - 42 : : id: paymentIdCounter, - 43 : : label: label_, - 44 : : isActivate: true, - 45 : : tokenAddress: tokenAddress_ - 46 : : }); - 47 : 20 : tokenPaymentConfigured[address(tokenAddress_)] = true; - 48 : 20 : ++paymentIdCounter; - 49 : : } - 50 : : - 51 : : /** - 52 : : * @param id paymentId + 5 : : import {SafeERC20} from "ccip-v08/vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.sol"; + 6 : : import {Client} from "ccip/libraries/Client.sol"; + 7 : : import {IRouterClient} from "ccip/interfaces/IRouterClient.sol"; + 8 : : import "../libraries/CCIPErrors.sol"; + 9 : : import "../security/AuthorizationModule.sol"; + 10 : : + 11 : : abstract contract CCIPSenderPayment is AuthorizationModule{ + 12 : : using SafeERC20 for IERC20; + 13 : : uint256 private paymentIdCounter = 1; + 14 : : struct FEE_PAYMENT_TOKEN { + 15 : : uint256 id; + 16 : : string label; + 17 : : bool isActivate; + 18 : : IERC20 tokenAddress; + 19 : : } + 20 : : event MessageGasLimit(uint256 newMessageGasLimit); + 21 : : event MessageData(string newMessageData); + 22 : : mapping(uint256 => FEE_PAYMENT_TOKEN) public paymentTokens; + 23 : : // List of configured payment + 24 : : mapping(address => bool) public tokenPaymentConfigured; + 25 : : /** + 26 : : * @notice + 27 : : * @dev set to zero since no receiver contract + 28 : : */ + 29 : : uint256 public messageGasLimit = 0; + 30 : : /** + 31 : : * @notice + 32 : : * @dev set to empty string since no data + 33 : : */ + 34 : : string public messageData = ""; + 35 : : + 36 : : function setMessageGasLimit(uint256 messageGasLimit_) public onlyRole(BRIDGE_OPERATOR_ROLE){ + 37 : 2 : messageGasLimit = messageGasLimit_; + 38 : 2 : emit MessageGasLimit(messageGasLimit_); + 39 : : } + 40 : : + 41 : : /** + 42 : : * @param messageData_ new data + 43 : : */ + 44 : : function setMessageData(string memory messageData_) public onlyRole(BRIDGE_OPERATOR_ROLE){ + 45 : 2 : messageData = messageData_; + 46 : 2 : emit MessageData(messageData_); + 47 : : } + 48 : : + 49 : : /** + 50 : : * @notice set the fee payment + 51 : : * @param tokenAddress_ Token address, ERC-20 + 52 : : * @param label_ token label, e.g. "USDC" 53 : : */ - 54 : : function isValidPaymentId(uint256 id) internal view returns(bool){ - 55 : 30 : return id < paymentIdCounter ? true:false; - 56 : : } - 57 : : /** - 58 : : * @notice set the fee payment - 59 : : * @param id token Id - 60 : : * @param newState boolean. True to activate, false to deactivate - 61 : : */ - 62 : : function changeStatusFeePaymentMethod(uint256 id, bool newState) public onlyRole(BRIDGE_OPERATOR_ROLE){ - 63 [ + + ]: 20 : if(!isValidPaymentId(id)){ - 64 : 2 : revert CCIPErrors.CCIP_SenderPayment_InvalidId(); - 65 : : } - 66 : 18 : paymentTokens[id].isActivate = newState; - 67 : : } - 68 : : - 69 : : function _computeAndApproveFee(uint64 _destinationChainSelector, Client.EVM2AnyMessage memory message, IRouterClient router, uint256 paymentMethodId ) internal returns(uint256){ - 70 : : // external call - 71 : 30 : uint256 fees = router.getFee(_destinationChainSelector, message); - 72 [ # + ]: 40 : if(address(paymentTokens[paymentMethodId].tokenAddress) != address(0)){ - 73 : : // ERC-20 token - 74 : : // External call - 75 : 15 : uint256 contractBalance = paymentTokens[paymentMethodId].tokenAddress.balanceOf(address(this)); - 76 [ + + ]: 10 : if (fees > contractBalance){ - 77 : 2 : revert CCIPErrors.CCIP_SenderPayment_ContractNotEnoughBalance(contractBalance, fees); - 78 : : } - 79 : : // External call - 80 : 12 : bool result = paymentTokens[paymentMethodId].tokenAddress.approve(address(router), fees); - 81 [ # + ]: 8 : if(!result){ - 82 : 0 : revert CCIPErrors.CCIP_SenderPayment_FailApproval(); - 83 : : } - 84 : : - 85 : : } else { // Native token - 86 : 10 : uint256 contractBalance = address(this).balance; - 87 [ + + ]: 10 : if (fees > contractBalance){ - 88 : 2 : revert CCIPErrors.CCIP_SenderPayment_ContractNotEnoughBalance(contractBalance, fees); - 89 : : } - 90 : : } - 91 : 16 : return fees; - 92 : : } - 93 : : } + 54 : : function setFeePaymentMethod(IERC20 tokenAddress_, string calldata label_) public onlyRole(BRIDGE_OPERATOR_ROLE) { + 55 [ + + ]: 11 : if(tokenPaymentConfigured[address(tokenAddress_)]){ + 56 : 2 : revert CCIPErrors.CCIP_SenderPayment_TokenAlreadySet(); + 57 : : } + 58 : 20 : paymentTokens[paymentIdCounter] = FEE_PAYMENT_TOKEN({ + 59 : : id: paymentIdCounter, + 60 : : label: label_, + 61 : : isActivate: true, + 62 : : tokenAddress: tokenAddress_ + 63 : : }); + 64 : 20 : tokenPaymentConfigured[address(tokenAddress_)] = true; + 65 : 20 : ++paymentIdCounter; + 66 : : } + 67 : : + 68 : : /** + 69 : : * @param id paymentId + 70 : : */ + 71 : : function isValidPaymentId(uint256 id) internal view returns(bool){ + 72 : 33 : return id < paymentIdCounter ? true:false; + 73 : : } + 74 : : /** + 75 : : * @notice set the fee payment + 76 : : * @param id token Id + 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)){ + 81 : 2 : revert CCIPErrors.CCIP_SenderPayment_InvalidId(); + 82 : : } + 83 : 20 : 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)){ + 92 : : // ERC-20 token + 93 : : // External call + 94 : 15 : uint256 contractBalance = paymentTokens[paymentMethodId].tokenAddress.balanceOf(address(this)); + 95 [ + + ]: 10 : if (fees > contractBalance){ + 96 : 2 : revert CCIPErrors.CCIP_SenderPayment_ContractNotEnoughBalance(contractBalance, fees); + 97 : : } + 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){ + 103 : 2 : revert CCIPErrors.CCIP_SenderPayment_ContractNotEnoughBalance(contractBalance, fees); + 104 : : } + 105 : : } + 106 : 16 : 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 d75246e..3ccac99 100644 --- a/doc/test/coverage/bridge/modules/configuration/index-sort-b.html +++ b/doc/test/coverage/bridge/modules/configuration/index-sort-b.html @@ -31,17 +31,17 @@ lcov.info Lines: - 28 - 29 - 96.6 % + 31 + 31 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 8 - 8 + 10 + 10 100.0 % @@ -50,8 +50,8 @@ Branches: 14 - 16 - 87.5 % + 14 + 100.0 % @@ -81,27 +81,15 @@ Functions Sort by function coverage Branches Sort by branch coverage - - CCIPSenderPayment.sol - -
95.7%95.7%
- - 95.7 % - 22 / 23 - 100.0 % - 5 / 5 - 83.3 % - 10 / 12 - CCIPRouterManage.sol
100.0%
100.0 % - 2 / 2 + 4 / 4 100.0 % - 2 / 2 + 3 / 3 - 0 / 0 @@ -117,6 +105,18 @@ 100.0 % 4 / 4 + + CCIPSenderPayment.sol + +
100.0%
+ + 100.0 % + 23 / 23 + 100.0 % + 6 / 6 + 100.0 % + 10 / 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 d77f286..cf6ef25 100644 --- a/doc/test/coverage/bridge/modules/configuration/index-sort-f.html +++ b/doc/test/coverage/bridge/modules/configuration/index-sort-f.html @@ -31,17 +31,17 @@ lcov.info Lines: - 28 - 29 - 96.6 % + 31 + 31 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 8 - 8 + 10 + 10 100.0 % @@ -50,8 +50,8 @@ Branches: 14 - 16 - 87.5 % + 14 + 100.0 % @@ -99,23 +99,23 @@
100.0%
100.0 % - 2 / 2 + 4 / 4 100.0 % - 2 / 2 + 3 / 3 - 0 / 0 CCIPSenderPayment.sol -
95.7%95.7%
+
100.0%
- 95.7 % - 22 / 23 100.0 % - 5 / 5 - 83.3 % - 10 / 12 + 23 / 23 + 100.0 % + 6 / 6 + 100.0 % + 10 / 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 baa926b..6e1d6e4 100644 --- a/doc/test/coverage/bridge/modules/configuration/index-sort-l.html +++ b/doc/test/coverage/bridge/modules/configuration/index-sort-l.html @@ -31,17 +31,17 @@ lcov.info Lines: - 28 - 29 - 96.6 % + 31 + 31 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 8 - 8 + 10 + 10 100.0 % @@ -50,8 +50,8 @@ Branches: 14 - 16 - 87.5 % + 14 + 100.0 % @@ -82,16 +82,16 @@ Branches Sort by branch coverage - CCIPSenderPayment.sol + CCIPAllowlistedChain.sol -
95.7%95.7%
+
100.0%
- 95.7 % - 22 / 23 100.0 % - 5 / 5 - 83.3 % - 10 / 12 + 4 / 4 + 100.0 % + 1 / 1 + 100.0 % + 4 / 4 CCIPRouterManage.sol @@ -99,23 +99,23 @@
100.0%
100.0 % - 2 / 2 + 4 / 4 100.0 % - 2 / 2 + 3 / 3 - 0 / 0 - CCIPAllowlistedChain.sol + CCIPSenderPayment.sol
100.0%
100.0 % - 4 / 4 + 23 / 23 100.0 % - 1 / 1 + 6 / 6 100.0 % - 4 / 4 + 10 / 10 diff --git a/doc/test/coverage/bridge/modules/configuration/index.html b/doc/test/coverage/bridge/modules/configuration/index.html index 588533f..50b0840 100644 --- a/doc/test/coverage/bridge/modules/configuration/index.html +++ b/doc/test/coverage/bridge/modules/configuration/index.html @@ -31,17 +31,17 @@ lcov.info Lines: - 28 - 29 - 96.6 % + 31 + 31 + 100.0 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: - 8 - 8 + 10 + 10 100.0 % @@ -50,8 +50,8 @@ Branches: 14 - 16 - 87.5 % + 14 + 100.0 % @@ -99,23 +99,23 @@
100.0%
100.0 % - 2 / 2 + 4 / 4 100.0 % - 2 / 2 + 3 / 3 - 0 / 0 CCIPSenderPayment.sol -
95.7%95.7%
+
100.0%
- 95.7 % - 22 / 23 100.0 % - 5 / 5 - 83.3 % - 10 / 12 + 23 / 23 + 100.0 % + 6 / 6 + 100.0 % + 10 / 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 5be8ee7..89d9187 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,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 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 f8314f4..faae6c8 100644 --- a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func.html +++ b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.func.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 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 4090bca..202b264 100644 --- a/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/security/AuthorizationModule.sol.gcov.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 @@ -121,10 +121,10 @@ 50 : : address account 51 : : ) public view virtual override(AccessControl) returns (bool) { 52 : : // The Default Admin has all roles - 53 [ + + ]: 146 : if (AccessControl.hasRole(DEFAULT_ADMIN_ROLE, account)) { - 54 : 134 : return true; + 53 [ + + ]: 152 : if (AccessControl.hasRole(DEFAULT_ADMIN_ROLE, account)) { + 54 : 138 : return true; 55 : : } - 56 : 18 : return AccessControl.hasRole(role, account); + 56 : 21 : return AccessControl.hasRole(role, account); 57 : : } 58 : : } 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 b205f70..3e158ec 100644 --- a/doc/test/coverage/bridge/modules/security/index-sort-b.html +++ b/doc/test/coverage/bridge/modules/security/index-sort-b.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 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 c337fb7..d2357a9 100644 --- a/doc/test/coverage/bridge/modules/security/index-sort-f.html +++ b/doc/test/coverage/bridge/modules/security/index-sort-f.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 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 d31322c..b0a1c49 100644 --- a/doc/test/coverage/bridge/modules/security/index-sort-l.html +++ b/doc/test/coverage/bridge/modules/security/index-sort-l.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 diff --git a/doc/test/coverage/bridge/modules/security/index.html b/doc/test/coverage/bridge/modules/security/index.html index 1ef9776..4a47e7a 100644 --- a/doc/test/coverage/bridge/modules/security/index.html +++ b/doc/test/coverage/bridge/modules/security/index.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 0 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 f7f7967..64207c5 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-17 17:59:19 + 2024-04-26 14:53:42 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 46f9094..6d98a33 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-17 17:59:19 + 2024-04-26 14:53:42 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 51b8857..2b43892 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-17 17:59:19 + 2024-04-26 14:53:42 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 4f162c5..4646f18 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,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 2 4 - 4 - 100.0 % + 50.0 % @@ -69,20 +69,20 @@ Hit count Sort by hit count - CCIPSenderBuild.buildCCIPTransferMessage - 6 + CCIPSenderBuild._buildCCIPMessage + 0 - CCIPSenderBuild.buildTokenAmounts - 10 + CCIPSenderBuild._buildCCIPTransferMessage + 0 - CCIPSenderBuild._buildCCIPMessage - 15 + CCIPSenderBuild.buildCCIPTransferMessage + 7 - CCIPSenderBuild._buildCCIPTransferMessage - 18 + CCIPSenderBuild.buildTokenAmounts + 11
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 fe4125a..ad0ebd2 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.func.html @@ -37,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 2 4 - 4 - 100.0 % + 50.0 % @@ -70,19 +70,19 @@ CCIPSenderBuild._buildCCIPMessage - 15 + 0 CCIPSenderBuild._buildCCIPTransferMessage - 18 + 0 CCIPSenderBuild.buildCCIPTransferMessage - 6 + 7 CCIPSenderBuild.buildTokenAmounts - 10 + 11
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 980e44e..c2d7f63 100644 --- a/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.gcov.html +++ b/doc/test/coverage/bridge/modules/wrapper/CCIPSenderBuild.sol.gcov.html @@ -37,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 2 4 - 4 - 100.0 % + 50.0 % @@ -78,22 +78,22 @@ 7 : : function buildTokenAmounts( 8 : : address[] memory _tokens, 9 : : uint256[] memory _amounts) public pure returns (Client.EVMTokenAmount[] memory tokenAmounts){ - 10 [ + + ]: 24 : if( _tokens.length == 0){ + 10 [ + + ]: 26 : if( _tokens.length == 0){ 11 : 2 : revert CCIPErrors.CCIP_SenderBuild_TokensIsEmpty(); 12 : : } - 13 [ + + ]: 22 : if(_tokens.length != _amounts.length){ + 13 [ + + ]: 24 : if(_tokens.length != _amounts.length){ 14 : 2 : revert CCIPErrors.CCIP_SenderBuild_LengthMismatch(); 15 : : } - 16 : 20 : tokenAmounts = new Client.EVMTokenAmount[](_tokens.length); - 17 : 56 : for(uint256 i = 0; i < _tokens.length; ++i ){ - 18 [ + + ]: 42 : if(_tokens[i] == address(0)){ + 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)){ 19 : 2 : revert CCIPErrors.CCIP_SenderBuild_Address_Zero_Not_Allowed(); 20 : : } - 21 : 39 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({ + 21 : 42 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({ 22 : : token: _tokens[i], 23 : : amount: _amounts[i] 24 : : }); - 25 : 26 : tokenAmounts[i] = tokenAmount; + 25 : 28 : 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 : 18 : return _buildCCIPTransferMessage(_receiver, _tokenAmounts,paymentMethodId ); + 39 : 21 : return _buildCCIPTransferMessage(_receiver, _tokenAmounts,paymentMethodId ); 40 : : } 41 : : 42 : : /// @notice Construct a CCIP message. @@ -121,8 +121,8 @@ 50 : : Client.EVMTokenAmount[] memory _tokenAmounts, 51 : : uint256 gasLimit_, 52 : : address feeToken_ - 53 : : ) internal pure returns (Client.EVM2AnyMessage memory) { - 54 : 45 : return Client.EVM2AnyMessage({ + 53 : : ) public pure returns (Client.EVM2AnyMessage memory) { + 54 : 48 : return Client.EVM2AnyMessage({ 55 : : receiver: abi.encode(_receiver), 56 : : data: abi.encode(_text), 57 : : tokenAmounts: _tokenAmounts, @@ -142,14 +142,14 @@ 71 : : address _receiver, 72 : : Client.EVMTokenAmount[] memory _tokenAmounts, 73 : : uint256 paymentMethodId - 74 : : ) internal view returns (Client.EVM2AnyMessage memory) { - 75 : 36 : address feeToken = address(0); - 76 [ + + ]: 18 : if(paymentTokens[paymentMethodId].isActivate){ - 77 : 30 : feeToken = address(paymentTokens[paymentMethodId].tokenAddress); + 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); 78 : : } else { 79 : 6 : revert CCIPErrors.CCIP_SenderBuild_InvalidFeeId(); 80 : : } - 81 : 45 : return _buildCCIPMessage(_receiver, "", _tokenAmounts, gasLimit, feeToken); + 81 : 48 : 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 3f13a4c..ee19c61 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index-sort-b.html +++ b/doc/test/coverage/bridge/modules/wrapper/index-sort-b.html @@ -37,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 5 7 - 7 - 100.0 % + 71.4 % @@ -100,8 +100,8 @@ 100.0 % 17 / 17 - 100.0 % - 4 / 4 + 50.0 % + 2 / 4 100.0 % 8 / 8 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 d2a5d90..182c611 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index-sort-f.html +++ b/doc/test/coverage/bridge/modules/wrapper/index-sort-f.html @@ -37,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 5 7 - 7 - 100.0 % + 71.4 % @@ -81,6 +81,18 @@ Functions Sort by function coverage Branches Sort by branch coverage + + CCIPSenderBuild.sol + +
100.0%
+ + 100.0 % + 17 / 17 + 50.0 % + 2 / 4 + 100.0 % + 8 / 8 + CCIPContractBalance.sol @@ -93,18 +105,6 @@ 62.5 % 10 / 16 - - CCIPSenderBuild.sol - -
100.0%
- - 100.0 % - 17 / 17 - 100.0 % - 4 / 4 - 100.0 % - 8 / 8 -
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 acafe05..d834213 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index-sort-l.html +++ b/doc/test/coverage/bridge/modules/wrapper/index-sort-l.html @@ -37,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 5 7 - 7 - 100.0 % + 71.4 % @@ -100,8 +100,8 @@ 100.0 % 17 / 17 - 100.0 % - 4 / 4 + 50.0 % + 2 / 4 100.0 % 8 / 8 diff --git a/doc/test/coverage/bridge/modules/wrapper/index.html b/doc/test/coverage/bridge/modules/wrapper/index.html index 1166d90..c7966c5 100644 --- a/doc/test/coverage/bridge/modules/wrapper/index.html +++ b/doc/test/coverage/bridge/modules/wrapper/index.html @@ -37,12 +37,12 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: + 5 7 - 7 - 100.0 % + 71.4 % @@ -100,8 +100,8 @@ 100.0 % 17 / 17 - 100.0 % - 4 / 4 + 50.0 % + 2 / 4 100.0 % 8 / 8 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 dc6f0bd..c06820c 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 @@ -74,11 +74,11 @@ CCIPSender._contextSuffixLength - 92 + 95 CCIPSender._msgSender - 92 + 95
diff --git a/doc/test/coverage/deployment/CCIPSender.sol.func.html b/doc/test/coverage/deployment/CCIPSender.sol.func.html index 21745ec..4390e48 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 @@ -70,7 +70,7 @@ CCIPSender._contextSuffixLength - 92 + 95 CCIPSender._msgData @@ -78,7 +78,7 @@ CCIPSender._msgSender - 92 + 95
diff --git a/doc/test/coverage/deployment/CCIPSender.sol.gcov.html b/doc/test/coverage/deployment/CCIPSender.sol.gcov.html index 7d8ce26..fefc0ff 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 @@ -99,7 +99,7 @@ 28 : : override(ERC2771Context, Context) 29 : : returns (address sender) 30 : : { - 31 : 276 : return ERC2771Context._msgSender(); + 31 : 285 : return ERC2771Context._msgSender(); 32 : : } 33 : : 34 : : /** @@ -120,7 +120,7 @@ 49 : : function _contextSuffixLength() internal view 50 : : override(ERC2771Context, Context) 51 : : returns (uint256) { - 52 : 276 : return ERC2771Context._contextSuffixLength(); + 52 : 285 : 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 d1b31c5..c3657fc 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 diff --git a/doc/test/coverage/deployment/index-sort-f.html b/doc/test/coverage/deployment/index-sort-f.html index 352114a..37c0e1f 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 diff --git a/doc/test/coverage/deployment/index-sort-l.html b/doc/test/coverage/deployment/index-sort-l.html index ee92f79..2cc66a4 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-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 diff --git a/doc/test/coverage/deployment/index.html b/doc/test/coverage/deployment/index.html index 01ec607..aaed680 100644 --- a/doc/test/coverage/deployment/index.html +++ b/doc/test/coverage/deployment/index.html @@ -37,7 +37,7 @@ Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 2 diff --git a/doc/test/coverage/index-sort-b.html b/doc/test/coverage/index-sort-b.html index efc1e57..fe58d02 100644 --- a/doc/test/coverage/index-sort-b.html +++ b/doc/test/coverage/index-sort-b.html @@ -31,18 +31,18 @@ lcov.info Lines: - 89 - 94 - 94.7 % + 93 + 96 + 96.9 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 20 - 22 - 90.9 % + 24 + 83.3 % @@ -50,8 +50,8 @@ Branches: 35 - 44 - 79.5 % + 42 + 83.3 % @@ -84,10 +84,10 @@ bridge -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 + 100.0 % + 21 / 21 100.0 % 3 / 3 50.0 % @@ -100,23 +100,11 @@ 94.7 % 36 / 38 - 100.0 % - 7 / 7 + 71.4 % + 5 / 7 75.0 % 18 / 24 - - bridge/modules/configuration - -
96.6%96.6%
- - 96.6 % - 28 / 29 - 100.0 % - 8 / 8 - 87.5 % - 14 / 16 - deployment @@ -141,6 +129,18 @@ 100.0 % 2 / 2 + + bridge/modules/configuration + +
100.0%
+ + 100.0 % + 31 / 31 + 100.0 % + 10 / 10 + 100.0 % + 14 / 14 +
diff --git a/doc/test/coverage/index-sort-f.html b/doc/test/coverage/index-sort-f.html index d032ba3..0c61e9b 100644 --- a/doc/test/coverage/index-sort-f.html +++ b/doc/test/coverage/index-sort-f.html @@ -31,18 +31,18 @@ lcov.info Lines: - 89 - 94 - 94.7 % + 93 + 96 + 96.9 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 20 - 22 - 90.9 % + 24 + 83.3 % @@ -50,8 +50,8 @@ Branches: 35 - 44 - 79.5 % + 42 + 83.3 % @@ -105,18 +105,6 @@ - 0 / 0 - - bridge - -
95.2%95.2%
- - 95.2 % - 20 / 21 - 100.0 % - 3 / 3 - 50.0 % - 1 / 2 - bridge/modules/wrapper @@ -124,22 +112,34 @@ 94.7 % 36 / 38 - 100.0 % - 7 / 7 + 71.4 % + 5 / 7 75.0 % 18 / 24 + + bridge + +
100.0%
+ + 100.0 % + 21 / 21 + 100.0 % + 3 / 3 + 50.0 % + 1 / 2 + bridge/modules/configuration -
96.6%96.6%
+
100.0%
- 96.6 % - 28 / 29 100.0 % - 8 / 8 - 87.5 % - 14 / 16 + 31 / 31 + 100.0 % + 10 / 10 + 100.0 % + 14 / 14 diff --git a/doc/test/coverage/index-sort-l.html b/doc/test/coverage/index-sort-l.html index d17dbf2..f6b6d12 100644 --- a/doc/test/coverage/index-sort-l.html +++ b/doc/test/coverage/index-sort-l.html @@ -31,18 +31,18 @@ lcov.info Lines: - 89 - 94 - 94.7 % + 93 + 96 + 96.9 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 20 - 22 - 90.9 % + 24 + 83.3 % @@ -50,8 +50,8 @@ Branches: 35 - 44 - 79.5 % + 42 + 83.3 % @@ -100,46 +100,46 @@ 94.7 % 36 / 38 - 100.0 % - 7 / 7 + 71.4 % + 5 / 7 75.0 % 18 / 24 - bridge + bridge/modules/security -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 100.0 % 3 / 3 - 50.0 % - 1 / 2 + 0.0 % + 0 / 1 + 100.0 % + 2 / 2 - bridge/modules/configuration + bridge -
96.6%96.6%
+
100.0%
- 96.6 % - 28 / 29 100.0 % - 8 / 8 - 87.5 % - 14 / 16 + 21 / 21 + 100.0 % + 3 / 3 + 50.0 % + 1 / 2 - bridge/modules/security + bridge/modules/configuration
100.0%
100.0 % - 3 / 3 - 0.0 % - 0 / 1 + 31 / 31 100.0 % - 2 / 2 + 10 / 10 + 100.0 % + 14 / 14 diff --git a/doc/test/coverage/index.html b/doc/test/coverage/index.html index 45ddecf..024b76c 100644 --- a/doc/test/coverage/index.html +++ b/doc/test/coverage/index.html @@ -31,18 +31,18 @@ lcov.info Lines: - 89 - 94 - 94.7 % + 93 + 96 + 96.9 % Date: - 2024-04-17 17:59:19 + 2024-04-26 14:53:42 Functions: 20 - 22 - 90.9 % + 24 + 83.3 % @@ -50,8 +50,8 @@ Branches: 35 - 44 - 79.5 % + 42 + 83.3 % @@ -84,10 +84,10 @@ bridge -
95.2%95.2%
+
100.0%
- 95.2 % - 20 / 21 + 100.0 % + 21 / 21 100.0 % 3 / 3 50.0 % @@ -96,14 +96,14 @@ bridge/modules/configuration -
96.6%96.6%
+
100.0%
- 96.6 % - 28 / 29 100.0 % - 8 / 8 - 87.5 % - 14 / 16 + 31 / 31 + 100.0 % + 10 / 10 + 100.0 % + 14 / 14 bridge/modules/security @@ -124,8 +124,8 @@ 94.7 % 36 / 38 - 100.0 % - 7 / 7 + 71.4 % + 5 / 7 75.0 % 18 / 24 diff --git a/doc/test/lcov.info b/doc/test/lcov.info index 2c53a14..814de52 100644 --- a/doc/test/lcov.info +++ b/doc/test/lcov.info @@ -47,19 +47,18 @@ DA:124,10 DA:124,10 DA:126,6 DA:126,6 -DA:126,6 -DA:127,6 -DA:127,6 -BRDA:127,0,0,- -BRDA:127,0,1,6 -DA:128,0 -DA:128,0 -DA:132,4 -DA:132,4 +DA:129,4 +DA:129,4 +BRDA:129,0,0,- +BRDA:129,0,1,2 +DA:130,2 +DA:130,2 +DA:132,2 +DA:132,2 FNF:3 FNH:3 LF:21 -LH:20 +LH:21 BRF:2 BRH:1 end_of_record @@ -88,117 +87,123 @@ BRH:4 end_of_record TN: SF:src/bridge/modules/configuration/CCIPRouterManage.sol -FN:19,CCIPRouterManage.getRouter +FN:20,CCIPRouterManage.getRouter FNDA:3,CCIPRouterManage.getRouter -DA:20,13 -DA:20,13 -DA:20,13 -FN:26,CCIPRouterManage.getSupportedTokens +DA:21,13 +DA:21,13 +DA:21,13 +FN:27,CCIPRouterManage.getSupportedTokens FNDA:2,CCIPRouterManage.getSupportedTokens -DA:29,2 -DA:29,2 -FNF:2 -FNH:2 -LF:2 -LH:2 +DA:30,2 +DA:30,2 +FN:33,CCIPRouterManage.getFee +FNDA:1,CCIPRouterManage.getFee +DA:35,1 +DA:35,1 +DA:35,1 +DA:36,1 +DA:36,1 +FNF:3 +FNH:3 +LF:4 +LH:4 BRF:0 BRH:0 end_of_record TN: SF:src/bridge/modules/configuration/CCIPSenderPayment.sol -FN:27,CCIPSenderPayment.setGasLimit -FNDA:2,CCIPSenderPayment.setGasLimit -DA:28,1 -DA:28,1 -DA:29,1 -DA:29,1 -FN:37,CCIPSenderPayment.setFeePaymentMethod +FN:36,CCIPSenderPayment.setMessageGasLimit +FNDA:2,CCIPSenderPayment.setMessageGasLimit +DA:37,1 +DA:37,1 +DA:38,1 +DA:38,1 +FN:44,CCIPSenderPayment.setMessageData +FNDA:2,CCIPSenderPayment.setMessageData +DA:45,1 +DA:45,1 +DA:46,1 +DA:46,1 +FN:54,CCIPSenderPayment.setFeePaymentMethod FNDA:12,CCIPSenderPayment.setFeePaymentMethod -DA:38,11 -BRDA:38,0,0,1 -BRDA:38,0,1,10 -DA:39,1 -DA:39,1 -DA:41,10 -DA:41,10 -DA:47,10 -DA:47,10 -DA:48,10 -DA:48,10 -FN:54,CCIPSenderPayment.isValidPaymentId -FNDA:10,CCIPSenderPayment.isValidPaymentId -DA:55,10 -DA:55,10 -DA:55,10 -FN:62,CCIPSenderPayment.changeStatusFeePaymentMethod -FNDA:11,CCIPSenderPayment.changeStatusFeePaymentMethod -DA:63,10 -DA:63,10 -BRDA:63,1,0,1 -BRDA:63,1,1,9 -DA:64,1 -DA:64,1 -DA:66,9 -DA:66,9 -FN:69,CCIPSenderPayment._computeAndApproveFee +DA:55,11 +BRDA:55,0,0,1 +BRDA:55,0,1,10 +DA:56,1 +DA:56,1 +DA:58,10 +DA:58,10 +DA:64,10 +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 +FN:79,CCIPSenderPayment.changeStatusFeePaymentMethod +FNDA:12,CCIPSenderPayment.changeStatusFeePaymentMethod +DA:80,11 +DA:80,11 +BRDA:80,1,0,1 +BRDA:80,1,1,10 +DA:81,1 +DA:81,1 +DA:83,10 +DA:83,10 +FN:88,CCIPSenderPayment._computeAndApproveFee FNDA:10,CCIPSenderPayment._computeAndApproveFee -DA:71,10 -DA:71,10 -DA:71,10 -DA:72,10 -DA:72,10 -DA:72,10 -DA:72,10 -BRDA:72,2,0,- -BRDA:72,2,1,4 -DA:75,5 -DA:75,5 -DA:75,5 -DA:76,5 -DA:76,5 -BRDA:76,3,0,1 -BRDA:76,3,1,4 -DA:77,1 -DA:77,1 -DA:80,4 -DA:80,4 -DA:80,4 -DA:81,4 -DA:81,4 -BRDA:81,4,0,- -BRDA:81,4,1,4 -DA:82,0 -DA:82,0 -DA:86,5 -DA:86,5 -DA:87,5 -DA:87,5 -BRDA:87,5,0,1 -BRDA:87,5,1,4 -DA:88,1 -DA:88,1 -DA:91,8 -DA:91,8 -FNF:5 -FNH:5 +DA:90,10 +DA:90,10 +DA:90,10 +DA:91,10 +DA:91,10 +DA:91,10 +DA:91,10 +BRDA:91,2,0,1 +BRDA:91,2,1,4 +DA:94,5 +DA:94,5 +DA:94,5 +DA:95,5 +DA:95,5 +BRDA:95,3,0,1 +BRDA:95,3,1,4 +DA:96,1 +DA:96,1 +DA:99,4 +DA:99,4 +DA:101,5 +DA:101,5 +DA:102,5 +DA:102,5 +BRDA:102,4,0,1 +BRDA:102,4,1,4 +DA:103,1 +DA:103,1 +DA:106,8 +DA:106,8 +FNF:6 +FNH:6 LF:23 -LH:22 -BRF:12 +LH:23 +BRF:10 BRH:10 end_of_record TN: SF:src/bridge/modules/security/AuthorizationModule.sol FN:48,AuthorizationModule.hasRole FNDA:0,AuthorizationModule.hasRole -DA:53,73 -DA:53,73 -BRDA:53,0,0,67 -BRDA:53,0,1,6 -DA:54,67 -DA:54,67 -DA:56,6 -DA:56,6 -DA:56,6 +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 FNF:1 FNH:0 LF:3 @@ -289,64 +294,64 @@ end_of_record TN: SF:src/bridge/modules/wrapper/CCIPSenderBuild.sol FN:7,CCIPSenderBuild.buildTokenAmounts -FNDA:10,CCIPSenderBuild.buildTokenAmounts -DA:10,12 -DA:10,12 +FNDA:11,CCIPSenderBuild.buildTokenAmounts +DA:10,13 +DA:10,13 BRDA:10,0,0,1 -BRDA:10,0,1,11 +BRDA:10,0,1,12 DA:11,1 DA:11,1 -DA:13,11 -DA:13,11 +DA:13,12 +DA:13,12 BRDA:13,1,0,1 -BRDA:13,1,1,10 +BRDA:13,1,1,11 DA:14,1 DA:14,1 -DA:16,10 -DA:16,10 -DA:17,10 -DA:17,10 -DA:17,23 -DA:17,13 -DA:18,14 -DA:18,14 -DA:18,14 +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 BRDA:18,2,0,1 -BRDA:18,2,1,13 +BRDA:18,2,1,14 DA:19,1 DA:19,1 -DA:21,13 -DA:21,13 -DA:21,13 -DA:25,13 -DA:25,13 +DA:21,14 +DA:21,14 +DA:21,14 +DA:25,14 +DA:25,14 FN:34,CCIPSenderBuild.buildCCIPTransferMessage -FNDA:6,CCIPSenderBuild.buildCCIPTransferMessage -DA:39,6 -DA:39,6 -DA:39,6 +FNDA:7,CCIPSenderBuild.buildCCIPTransferMessage +DA:39,7 +DA:39,7 +DA:39,7 FN:47,CCIPSenderBuild._buildCCIPMessage -FNDA:15,CCIPSenderBuild._buildCCIPMessage -DA:54,15 -DA:54,15 -DA:54,15 +FNDA:0,CCIPSenderBuild._buildCCIPMessage +DA:54,16 +DA:54,16 +DA:54,16 FN:70,CCIPSenderBuild._buildCCIPTransferMessage -FNDA:18,CCIPSenderBuild._buildCCIPTransferMessage -DA:75,18 -DA:75,18 +FNDA:0,CCIPSenderBuild._buildCCIPTransferMessage +DA:75,19 +DA:75,19 DA:75,0 -DA:76,18 -BRDA:76,3,0,15 +DA:76,19 +BRDA:76,3,0,16 BRDA:76,3,1,3 -DA:77,15 -DA:77,15 +DA:77,16 +DA:77,16 DA:79,3 DA:79,3 -DA:81,15 -DA:81,15 -DA:81,15 +DA:81,16 +DA:81,16 +DA:81,16 FNF:4 -FNH:4 +FNH:2 LF:17 LH:17 BRF:8 @@ -355,20 +360,20 @@ end_of_record TN: SF:src/deployment/CCIPSender.sol FN:25,CCIPSender._msgSender -FNDA:92,CCIPSender._msgSender -DA:31,92 -DA:31,92 -DA:31,92 +FNDA:95,CCIPSender._msgSender +DA:31,95 +DA:31,95 +DA:31,95 FN:37,CCIPSender._msgData FNDA:0,CCIPSender._msgData DA:43,0 DA:43,0 DA:43,0 FN:49,CCIPSender._contextSuffixLength -FNDA:92,CCIPSender._contextSuffixLength -DA:52,92 -DA:52,92 -DA:52,92 +FNDA:95,CCIPSender._contextSuffixLength +DA:52,95 +DA:52,95 +DA:52,95 FNF:3 FNH:2 LF:3 diff --git a/src/bridge/CCIPBaseSender.sol b/src/bridge/CCIPBaseSender.sol index addef18..4cf0c18 100644 --- a/src/bridge/CCIPBaseSender.sol +++ b/src/bridge/CCIPBaseSender.sol @@ -126,6 +126,11 @@ abstract contract CCIPBaseSender is CCIPAllowlistedChain, CCIPSenderBuild, CCIPR IERC20(tokenAmounts[i].token).safeIncreaseAllowance(address(router), tokenAmounts[i].amount); } // Send CCIP Message - messageId = router.ccipSend(_destinationChainSelector, message); + if(_paymentMethodId == 0){ // Native token + messageId = router.ccipSend{value: fees}(_destinationChainSelector, message); + } else{ + messageId = router.ccipSend(_destinationChainSelector, message); + } + } } \ No newline at end of file diff --git a/src/bridge/modules/configuration/CCIPRouterManage.sol b/src/bridge/modules/configuration/CCIPRouterManage.sol index 7fbd07c..57f2bac 100644 --- a/src/bridge/modules/configuration/CCIPRouterManage.sol +++ b/src/bridge/modules/configuration/CCIPRouterManage.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IRouterClient} from "ccip/interfaces/IRouterClient.sol"; +import {Client} from "ccip/libraries/Client.sol"; import "../libraries/CCIPErrors.sol"; /// @title CCIPReceiver - Base contract for CCIP applications that can receive messages. @@ -29,6 +30,12 @@ abstract contract CCIPRouterManage { tokens = IRouterClient(i_router).getSupportedTokens(chainSelector); } + function getFee(uint64 _destinationChainSelector, Client.EVM2AnyMessage memory message ) public view returns(uint256){ + // external call + uint256 fees = IRouterClient(i_router).getFee(_destinationChainSelector, message); + return fees; + } + /// @dev only calls from the set router are accepted. modifier onlyRouter() { if (msg.sender != address(i_router)){ diff --git a/src/bridge/modules/configuration/CCIPSenderPayment.sol b/src/bridge/modules/configuration/CCIPSenderPayment.sol index 5cdb25e..18c0b6a 100644 --- a/src/bridge/modules/configuration/CCIPSenderPayment.sol +++ b/src/bridge/modules/configuration/CCIPSenderPayment.sol @@ -17,7 +17,8 @@ abstract contract CCIPSenderPayment is AuthorizationModule{ bool isActivate; IERC20 tokenAddress; } - event GasLimit(uint256 newGasLimit); + event MessageGasLimit(uint256 newMessageGasLimit); + event MessageData(string newMessageData); mapping(uint256 => FEE_PAYMENT_TOKEN) public paymentTokens; // List of configured payment mapping(address => bool) public tokenPaymentConfigured; @@ -25,11 +26,25 @@ abstract contract CCIPSenderPayment is AuthorizationModule{ * @notice * @dev set to zero since no receiver contract */ - uint256 public gasLimit = 0; - function setGasLimit(uint256 gasLimit_) public onlyRole(BRIDGE_OPERATOR_ROLE){ - gasLimit = gasLimit_; - emit GasLimit(gasLimit_); - } + uint256 public messageGasLimit = 0; + /** + * @notice + * @dev set to empty string since no data + */ + string public messageData = ""; + + function setMessageGasLimit(uint256 messageGasLimit_) public onlyRole(BRIDGE_OPERATOR_ROLE){ + messageGasLimit = messageGasLimit_; + emit MessageGasLimit(messageGasLimit_); + } + + /** + * @param messageData_ new data + */ + function setMessageData(string memory messageData_) public onlyRole(BRIDGE_OPERATOR_ROLE){ + messageData = messageData_; + emit MessageData(messageData_); + } /** * @notice set the fee payment @@ -68,6 +83,8 @@ abstract contract CCIPSenderPayment is AuthorizationModule{ paymentTokens[id].isActivate = newState; } + + function _computeAndApproveFee(uint64 _destinationChainSelector, Client.EVM2AnyMessage memory message, IRouterClient router, uint256 paymentMethodId ) internal returns(uint256){ // external call uint256 fees = router.getFee(_destinationChainSelector, message); diff --git a/src/bridge/modules/wrapper/CCIPSenderBuild.sol b/src/bridge/modules/wrapper/CCIPSenderBuild.sol index 61cbcf1..6a6d61a 100644 --- a/src/bridge/modules/wrapper/CCIPSenderBuild.sol +++ b/src/bridge/modules/wrapper/CCIPSenderBuild.sol @@ -50,7 +50,7 @@ abstract contract CCIPSenderBuild is CCIPSenderPayment{ Client.EVMTokenAmount[] memory _tokenAmounts, uint256 gasLimit_, address feeToken_ - ) internal pure returns (Client.EVM2AnyMessage memory) { + ) public pure returns (Client.EVM2AnyMessage memory) { return Client.EVM2AnyMessage({ receiver: abi.encode(_receiver), data: abi.encode(_text), @@ -71,13 +71,13 @@ abstract contract CCIPSenderBuild is CCIPSenderPayment{ address _receiver, Client.EVMTokenAmount[] memory _tokenAmounts, uint256 paymentMethodId - ) internal view returns (Client.EVM2AnyMessage memory) { + ) public view returns (Client.EVM2AnyMessage memory) { address feeToken = address(0); if(paymentTokens[paymentMethodId].isActivate){ feeToken = address(paymentTokens[paymentMethodId].tokenAddress); } else { revert CCIPErrors.CCIP_SenderBuild_InvalidFeeId(); } - return _buildCCIPMessage(_receiver, "", _tokenAmounts, gasLimit, feeToken); + return _buildCCIPMessage(_receiver, messageData, _tokenAmounts, messageGasLimit, feeToken); } } \ No newline at end of file diff --git a/test/accessControl.sol b/test/accessControl.sol index 4dadeee..4bf70b8 100644 --- a/test/accessControl.sol +++ b/test/accessControl.sol @@ -32,11 +32,18 @@ contract baseTest is HelperContract { /*********** CCIPSender Payment ***********/ - function testCannotAttackerSetGasLimit() public{ + function testCannotAttackerSetMessageGasLimit() public{ vm.expectRevert( abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, ATTACKER, BRIDGE_OPERATOR_ROLE)); vm.prank(ATTACKER); - CCIPSENDER_CONTRACT.setGasLimit(1000); + CCIPSENDER_CONTRACT.setMessageGasLimit(1000); + } + + function testCannotAttackerSetMessageData() public{ + vm.expectRevert( + abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, ATTACKER, BRIDGE_OPERATOR_ROLE)); + vm.prank(ATTACKER); + CCIPSENDER_CONTRACT.setMessageData("2"); } function testCannotAttackerSetFeePaymentMethod() public{ diff --git a/test/base.sol b/test/base.sol index 002e8a9..4e9f051 100644 --- a/test/base.sol +++ b/test/base.sol @@ -9,6 +9,7 @@ import {Client} from "ccip/libraries/Client.sol"; contract baseTest is HelperContract { ERC20Mock private erc20; address private ROUTER = address(0x1); + event MessageData(string newMessageData); // Arrange function setUp() public { // Deploy CCIP Sender @@ -53,19 +54,31 @@ contract baseTest is HelperContract { resBool = CCIPSENDER_CONTRACT.allowlistedDestinationChains(AVALANCHE_SELECTOR); assertEq(resBool, false); } - event GasLimit(uint256 newGasLimit); + event MessageGasLimit(uint256 newMessageGasLimit); /*********** CCIPSender Payment ***********/ - function testAdminCanSetGasLimit() public{ - uint256 newGasLimit = 256; + function testAdminCanSetMessageGasLimit() public{ + uint256 newMessageGasLimit = 256; vm.expectEmit(false, false, false, true); - emit GasLimit( - newGasLimit + emit MessageGasLimit( + newMessageGasLimit ); vm.prank(CCIPSENDER_ADMIN); - CCIPSENDER_CONTRACT.setGasLimit(newGasLimit); - uint256 gasLimit = CCIPSENDER_CONTRACT.gasLimit(); - assertEq(gasLimit, newGasLimit); + CCIPSENDER_CONTRACT.setMessageGasLimit(newMessageGasLimit); + uint256 gasLimit = CCIPSENDER_CONTRACT.messageGasLimit(); + assertEq(gasLimit, newMessageGasLimit); + } + + function testAdminCanSetMessageData() public{ + string memory newMessageData = "test"; + vm.expectEmit(false, false, false, true); + emit MessageData( + newMessageData + ); + vm.prank(CCIPSENDER_ADMIN); + CCIPSENDER_CONTRACT.setMessageData(newMessageData); + string memory messageData = CCIPSENDER_CONTRACT.messageData(); + assertEq(messageData , newMessageData); } function testAdminCanSetFeePaymentMethod() public{ vm.prank(CCIPSENDER_ADMIN); diff --git a/test/nativeToken/routerTestNativeToken.sol b/test/nativeToken/routerTestNativeToken.sol index c09c3d7..0c24a11 100644 --- a/test/nativeToken/routerTestNativeToken.sol +++ b/test/nativeToken/routerTestNativeToken.sol @@ -8,6 +8,7 @@ import {IERC20} from "ccip-v08/vendor/openzeppelin-solidity/v4.8.3/contracts/tok import {ERC20Mock} from "openzeppelin-contracts/mocks/token/ERC20Mock.sol"; import {Client} from "ccip/libraries/Client.sol"; contract RouterTest is HelperContract { + uint256 NATIVE_TOKEN_SELECTION = 0; error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); @@ -41,6 +42,29 @@ contract RouterTest is HelperContract { assertEq(tokens[0], address(erc20)); } + function testCanGetFees() public { + // Arrange + uint256 value = 1000; + address[] memory _tokens = new address[](1); + uint256[] memory _amounts = new uint256[](1); + _tokens[0] = address(erc20); + _amounts[0] = value; + + vm.prank(CCIPSENDER_ADMIN); + CCIPSENDER_CONTRACT.changeStatusFeePaymentMethod(feePaymentId, true); + + Client.EVMTokenAmount[] memory tokenAmounts = CCIPSENDER_CONTRACT.buildTokenAmounts(_tokens, _amounts); + + // Act + Client.EVM2AnyMessage memory message = CCIPSENDER_CONTRACT.buildCCIPTransferMessage(RECEIVER_ADDRESS, tokenAmounts, NATIVE_TOKEN_SELECTION); + + // From router mock + uint64 chainSelector = 0; + uint256 fees = CCIPSENDER_CONTRACT.getFee(chainSelector, message); + + assertEq(fees,10); + } + function _configurefee() internal { vm.prank(CCIPSENDER_ADMIN); CCIPSENDER_CONTRACT.changeStatusFeePaymentMethod(feePaymentId, true); diff --git a/test/utils/router.sol b/test/utils/router.sol index 5432aae..e7f36d7 100644 --- a/test/utils/router.sol +++ b/test/utils/router.sol @@ -14,11 +14,14 @@ 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 InvalidMsgValue(); - constructor(address[] memory supportedTokens_){ + constructor(address[] memory supportedTokens_){ supportedTokens = supportedTokens_; } + // add this to be excluded from coverage report function test() public {} @@ -79,9 +82,15 @@ address[] supportedTokens; /// @dev Returns a mock message ID, which is not calculated from the message contents in the /// same way as the real message ID. function ccipSend( - uint64, // destinationChainSelector + uint64 destinationChainSelector, Client.EVM2AnyMessage calldata message ) external payable returns (bytes32) { + uint256 feeTokenAmount = getFee(destinationChainSelector, message); + if (message.feeToken == address(0)) { + if (msg.value < feeTokenAmount) revert InsufficientFeeTokenAmount(); + } else{ + if (msg.value > 0) revert InvalidMsgValue(); + } if (message.receiver.length != 32) revert InvalidAddress(message.receiver); uint256 decodedReceiver = abi.decode(message.receiver, (uint256)); // We want to disallow sending to address(0) and to precompiles, which exist on address(1) through address(9). @@ -129,7 +138,7 @@ address[] supportedTokens; } /// @notice Returns 10 - function getFee(uint64, Client.EVM2AnyMessage memory) external pure returns (uint256 fee) { + function getFee(uint64, Client.EVM2AnyMessage memory) public pure returns (uint256 fee) { return 10; }