From fe86b9737762bd6b39a8493359d9dcb1b04bb503 Mon Sep 17 00:00:00 2001 From: Tabish Shaikh Date: Fri, 13 Jun 2025 18:28:49 +0530 Subject: [PATCH 1/5] fix: add missing approval --- src/ForeignController.sol | 4 ++++ src/MainnetController.sol | 4 +++- src/interfaces/ILayerZero.sol | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ForeignController.sol b/src/ForeignController.sol index b0a0bfd3..5cd31f26 100644 --- a/src/ForeignController.sol +++ b/src/ForeignController.sol @@ -249,6 +249,10 @@ contract ForeignController is AccessControl { amount ); + if (ILayerZero(oftAddress).approvalRequired()) { + _approve(ILayerZero(oftAddress).token(), oftAddress, amount); + } + bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(200_000, 0); SendParam memory sendParams = SendParam({ diff --git a/src/MainnetController.sol b/src/MainnetController.sol index 824c6975..fd0d3e2e 100644 --- a/src/MainnetController.sol +++ b/src/MainnetController.sol @@ -787,7 +787,9 @@ contract MainnetController is AccessControl { amount ); - _approve(ILayerZero(oftAddress).token(), oftAddress, amount); + if (ILayerZero(oftAddress).approvalRequired()) { + _approve(ILayerZero(oftAddress).token(), oftAddress, amount); + } bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(200_000, 0); diff --git a/src/interfaces/ILayerZero.sol b/src/interfaces/ILayerZero.sol index 630bf554..d7bcf3f1 100644 --- a/src/interfaces/ILayerZero.sol +++ b/src/interfaces/ILayerZero.sol @@ -68,4 +68,6 @@ interface ILayerZero { function token() external view returns (address); + function approvalRequired() external pure returns (bool); + } From 3c7e2469d91e92066594499d66fd87260df253c4 Mon Sep 17 00:00:00 2001 From: Tabish Shaikh Date: Mon, 30 Jun 2025 22:59:19 +0530 Subject: [PATCH 2/5] add comments --- src/ForeignController.sol | 2 ++ src/MainnetController.sol | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/ForeignController.sol b/src/ForeignController.sol index 8a2453c3..0c78ef90 100644 --- a/src/ForeignController.sol +++ b/src/ForeignController.sol @@ -249,6 +249,8 @@ contract ForeignController is AccessControl { amount ); + // NOTE: !! This is not fully integration tested !! + // ADD TESTS for this before using it in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); } diff --git a/src/MainnetController.sol b/src/MainnetController.sol index 3c7e450c..ec3a6681 100644 --- a/src/MainnetController.sol +++ b/src/MainnetController.sol @@ -787,6 +787,8 @@ contract MainnetController is AccessControl { amount ); + // NOTE: !! This is not fully integration tested !! + // ADD TESTS for this before using it in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); } From ab136b0c912e2f7af58036f13dadd673077a2131 Mon Sep 17 00:00:00 2001 From: Tabish Shaikh Date: Tue, 1 Jul 2025 14:56:00 +0530 Subject: [PATCH 3/5] fix: comments --- src/ForeignController.sol | 4 ++-- src/MainnetController.sol | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ForeignController.sol b/src/ForeignController.sol index 0c78ef90..a24ae620 100644 --- a/src/ForeignController.sol +++ b/src/ForeignController.sol @@ -249,8 +249,8 @@ contract ForeignController is AccessControl { amount ); - // NOTE: !! This is not fully integration tested !! - // ADD TESTS for this before using it in production. + // NOTE: Full integration testing of this logic is not possible without OFTs without + // approvalRequired == false. Add integration testing for this case before using in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); } diff --git a/src/MainnetController.sol b/src/MainnetController.sol index ec3a6681..96d134ed 100644 --- a/src/MainnetController.sol +++ b/src/MainnetController.sol @@ -787,8 +787,8 @@ contract MainnetController is AccessControl { amount ); - // NOTE: !! This is not fully integration tested !! - // ADD TESTS for this before using it in production. + // NOTE: Full integration testing of this logic is not possible without OFTs without + // approvalRequired == true. Add integration testing for this case before using in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); } From 4a66879eac3f061c86fb90d6edbf0cb693703e47 Mon Sep 17 00:00:00 2001 From: Tabish Shaikh Date: Tue, 1 Jul 2025 15:03:33 +0530 Subject: [PATCH 4/5] fix: comments --- src/ForeignController.sol | 5 +++-- src/MainnetController.sol | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ForeignController.sol b/src/ForeignController.sol index a24ae620..8ff0a6c7 100644 --- a/src/ForeignController.sol +++ b/src/ForeignController.sol @@ -249,8 +249,9 @@ contract ForeignController is AccessControl { amount ); - // NOTE: Full integration testing of this logic is not possible without OFTs without - // approvalRequired == false. Add integration testing for this case before using in production. + // NOTE: Full integration testing of this logic is not possible without OFTs with + // approvalRequired == false. Add integration testing for this case before + // using in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); } diff --git a/src/MainnetController.sol b/src/MainnetController.sol index 96d134ed..2da69c6c 100644 --- a/src/MainnetController.sol +++ b/src/MainnetController.sol @@ -787,8 +787,9 @@ contract MainnetController is AccessControl { amount ); - // NOTE: Full integration testing of this logic is not possible without OFTs without - // approvalRequired == true. Add integration testing for this case before using in production. + // NOTE: Full integration testing of this logic is not possible without OFTs with + // approvalRequired == true. Add integration testing for this case before + // using in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); } From 82bf8809a07890988c6460938ffffe00e77c4215 Mon Sep 17 00:00:00 2001 From: Tabish Shaikh Date: Tue, 1 Jul 2025 15:18:58 +0530 Subject: [PATCH 5/5] fix: comment --- src/ForeignController.sol | 2 +- src/MainnetController.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ForeignController.sol b/src/ForeignController.sol index 8ff0a6c7..36553347 100644 --- a/src/ForeignController.sol +++ b/src/ForeignController.sol @@ -250,7 +250,7 @@ contract ForeignController is AccessControl { ); // NOTE: Full integration testing of this logic is not possible without OFTs with - // approvalRequired == false. Add integration testing for this case before + // approvalRequired == true. Add integration testing for this case before // using in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount); diff --git a/src/MainnetController.sol b/src/MainnetController.sol index 2da69c6c..c1ec572d 100644 --- a/src/MainnetController.sol +++ b/src/MainnetController.sol @@ -788,7 +788,7 @@ contract MainnetController is AccessControl { ); // NOTE: Full integration testing of this logic is not possible without OFTs with - // approvalRequired == true. Add integration testing for this case before + // approvalRequired == false. Add integration testing for this case before // using in production. if (ILayerZero(oftAddress).approvalRequired()) { _approve(ILayerZero(oftAddress).token(), oftAddress, amount);