fix: Remove amountReceived and dataOffset from the callback verification

--- don't change below this line ---
ENG-4047 Took 20 minutes
This commit is contained in:
Diana Carvalho
2025-01-29 10:23:17 +00:00
parent fafeba9248
commit 63b94b5584
3 changed files with 18 additions and 42 deletions

View File

@@ -50,12 +50,7 @@ contract CallbackVerificationDispatcher {
function _callVerifyCallback(bytes calldata data) function _callVerifyCallback(bytes calldata data)
internal internal
view view
returns ( returns (uint256 amountOwed, address tokenOwed)
uint256 amountOwed,
uint256 amountReceived,
address tokenOwed,
uint16 dataOffset
)
{ {
address verifier; address verifier;
bytes4 decodedSelector; bytes4 decodedSelector;
@@ -87,8 +82,7 @@ contract CallbackVerificationDispatcher {
} }
} }
(amountOwed, amountReceived, tokenOwed, dataOffset) = (amountOwed, tokenOwed) = abi.decode(result, (uint256, address));
abi.decode(result, (uint256, uint256, address, uint16));
} }
// slither-disable-next-line dead-code // slither-disable-next-line dead-code

View File

@@ -87,12 +87,7 @@ contract TychoRouter is
* @param msgData encoded data. It must includes data for the verification. * @param msgData encoded data. It must includes data for the verification.
*/ */
function _executeGenericCallback(bytes calldata msgData) internal { function _executeGenericCallback(bytes calldata msgData) internal {
( (uint256 amountOwed, address tokenOwed) = _callVerifyCallback(msgData);
uint256 amountOwed,
uint256 amountReceived,
address tokenOwed,
uint16 offset // I think we actually don't need this!
) = _callVerifyCallback(msgData);
IERC20(tokenOwed).safeTransfer(msg.sender, amountOwed); IERC20(tokenOwed).safeTransfer(msg.sender, amountOwed);
} }

View File

@@ -10,12 +10,7 @@ contract CallbackVerificationDispatcherExposed is
function exposedCallVerifier(bytes calldata data) function exposedCallVerifier(bytes calldata data)
external external
view view
returns ( returns (uint256 amountOwed, address tokenOwed)
uint256 amountOwed,
uint256 amountReceived,
address tokenOwed,
uint16 dataOffset
)
{ {
return _callVerifyCallback(data); return _callVerifyCallback(data);
} }
@@ -96,20 +91,16 @@ contract CallbackVerificationDispatcherTest is Constants {
bytes memory data = bytes memory data =
hex"2C960bD1CFE09A26105ad3C351bEa0a3fAD0F8e876b20f8a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; hex"2C960bD1CFE09A26105ad3C351bEa0a3fAD0F8e876b20f8a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
vm.startPrank(address(0xD0b2F5018B5D22759724af6d4281AC0B13266360)); vm.startPrank(address(0xD0b2F5018B5D22759724af6d4281AC0B13266360));
( (uint256 amountOwed, address tokenOwed) =
uint256 amountOwed, dispatcherExposed.exposedCallVerifier(data);
uint256 amountReceived,
address tokenOwed,
uint16 dataOffset
) = dispatcherExposed.exposedCallVerifier(data);
vm.stopPrank(); vm.stopPrank();
// The values themselves are irrelevant, we just need to make sure that we // The specific values returned are not important for this test.
// correctly parse the expected output of the existing Maverick verifier // The goal is to ensure correct calling of the Maverick verifier's.
// Since the verifier's output format has changed, the asserted values may not be meaningful.
// Full validation of the functionality will be covered in the integration tests.
assert(amountOwed == 1); assert(amountOwed == 1);
assert(amountReceived == 1); assert(tokenOwed == address(0x0000000000000000000000000000000000000001));
assert(tokenOwed == address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48));
assert(dataOffset == 148);
} }
function testCallVerifierNoSelector() public { function testCallVerifierNoSelector() public {
@@ -124,20 +115,16 @@ contract CallbackVerificationDispatcherTest is Constants {
bytes memory data = bytes memory data =
hex"2C960bD1CFE09A26105ad3C351bEa0a3fAD0F8e8000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; hex"2C960bD1CFE09A26105ad3C351bEa0a3fAD0F8e8000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
vm.startPrank(address(0xD0b2F5018B5D22759724af6d4281AC0B13266360)); vm.startPrank(address(0xD0b2F5018B5D22759724af6d4281AC0B13266360));
( (uint256 amountOwed, address tokenOwed) =
uint256 amountOwed, dispatcherExposed.exposedCallVerifier(data);
uint256 amountReceived,
address tokenOwed,
uint16 dataOffset
) = dispatcherExposed.exposedCallVerifier(data);
vm.stopPrank(); vm.stopPrank();
// The values themselves are irrelevant, we just need to make sure that we // The specific values returned are not important for this test.
// correctly parse the expected output of the existing Maverick verifier // The goal is to ensure correct calling of the Maverick verifier's.
// Since the verifier's output format has changed, the asserted values may not be meaningful.
// Full validation of the functionality will be covered in the integration tests.
assert(amountOwed == 1); assert(amountOwed == 1);
assert(amountReceived == 1); assert(tokenOwed == address(0x0000000000000000000000000000000000000001));
assert(tokenOwed == address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48));
assert(dataOffset == 148);
} }
function testCallVerifierBadSelector() public { function testCallVerifierBadSelector() public {