From 8390f2278155471f2c55f30100230333c66f769e Mon Sep 17 00:00:00 2001 From: Mathieu <60658558+enitrat@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:52:54 +0200 Subject: [PATCH] feat: remove evm selector from CairoLib (#9) * feat: remove evm selector from CairoLib * update error messages --- src/CairoLib.sol | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/CairoLib.sol b/src/CairoLib.sol index af8f883..0fac625 100644 --- a/src/CairoLib.sol +++ b/src/CairoLib.sol @@ -16,11 +16,10 @@ library CairoLib { internal returns (bytes memory) { - bytes memory callData = - abi.encodeWithSignature("call_contract(uint256,uint256,uint256[])", contractAddress, functionSelector, data); + bytes memory callData = abi.encode(contractAddress, functionSelector, data); (bool success, bytes memory result) = CAIRO_PRECOMPILE_ADDRESS.call(callData); - require(success, string(abi.encodePacked("CairoLib: call_contract failed with: ", result))); + require(success, string(abi.encodePacked("CairoLib: cairo call failed with: ", result))); return result; } @@ -69,11 +68,10 @@ library CairoLib { internal returns (bytes memory) { - bytes memory callData = - abi.encodeWithSignature("call_contract(uint256,uint256,uint256[])", contractAddress, functionSelector, data); + bytes memory callData = abi.encode(contractAddress, functionSelector, data); (bool success, bytes memory result) = CAIRO_PRECOMPILE_ADDRESS.delegatecall(callData); - require(success, string(abi.encodePacked("CairoLib: call_contract failed with: ", result))); + require(success, string(abi.encodePacked("CairoLib: cairo call failed with: ", result))); return result; } @@ -130,11 +128,10 @@ library CairoLib { view returns (bytes memory) { - bytes memory callData = - abi.encodeWithSignature("call_contract(uint256,uint256,uint256[])", contractAddress, functionSelector, data); + bytes memory callData = abi.encode(contractAddress, functionSelector, data); (bool success, bytes memory result) = CAIRO_PRECOMPILE_ADDRESS.staticcall(callData); - require(success, string(abi.encodePacked("CairoLib: call_contract failed with: ", result))); + require(success, string(abi.encodePacked("CairoLib: cairo call failed with: ", result))); return result; }