generated from PaulRBerg/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34997c6
commit 7f95435
Showing
4 changed files
with
69 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// _____ _ _ | ||
// |_ _| | | (_) | ||
// | | ___ _ __ __| | ___ _ __ _ _______ | ||
// | |/ _ \ '_ \ / _` |/ _ \ '__| |_ / _ \ | ||
// | | __/ | | | (_| | __/ | | |/ / __/ | ||
// \_/\___|_| |_|\__,_|\___|_| |_/___\___| | ||
// | ||
// Copyright (c) Tenderize Labs Ltd | ||
|
||
pragma solidity >=0.8.19; | ||
|
||
error StaticCallFailed(address to, bytes data, string message); | ||
|
||
function _staticcall(address target, bytes memory data) view returns (bytes memory) { | ||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool success, bytes memory returnData) = address(target).staticcall(data); | ||
|
||
if (!success) { | ||
if (returnData.length < 68) revert StaticCallFailed(address(target), data, ""); | ||
assembly { | ||
returnData := add(returnData, 0x04) | ||
} | ||
revert StaticCallFailed(address(target), data, abi.decode(returnData, (string))); | ||
} | ||
|
||
return returnData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// _____ _ _ | ||
// |_ _| | | (_) | ||
// | | ___ _ __ __| | ___ _ __ _ _______ | ||
// | |/ _ \ '_ \ / _` |/ _ \ '__| |_ / _ \ | ||
// | | __/ | | | (_| | __/ | | |/ / __/ | ||
// \_/\___|_| |_|\__,_|\___|_| |_/___\___| | ||
// | ||
// Copyright (c) Tenderize Labs Ltd | ||
|
||
pragma solidity >=0.8.19; | ||
|
||
function addressToString(address _addr) pure returns (string memory) { | ||
bytes32 value = bytes32(uint256(uint160(_addr))); | ||
bytes memory alphabet = "0123456789abcdef"; | ||
|
||
bytes memory str = new bytes(42); | ||
str[0] = "0"; | ||
str[1] = "x"; | ||
|
||
for (uint256 i = 0; i < 20; i++) { | ||
str[2 + i * 2] = alphabet[uint8(value[i + 12] >> 4)]; | ||
str[3 + i * 2] = alphabet[uint8(value[i + 12] & 0x0f)]; | ||
} | ||
|
||
return string(str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters