Skip to content

Commit

Permalink
feat: remove evm selector from CairoLib (#9)
Browse files Browse the repository at this point in the history
* feat: remove evm selector from CairoLib

* update error messages
  • Loading branch information
enitrat authored Oct 15, 2024
1 parent c2c7cb4 commit 8390f22
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/CairoLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8390f22

Please sign in to comment.