Skip to content

Commit 4b4cad5

Browse files
committed
more revert tests for claim
1 parent bdd6e69 commit 4b4cad5

File tree

6 files changed

+45594
-9337
lines changed

6 files changed

+45594
-9337
lines changed

contracts/lib/Strings2.sol

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
pragma solidity ^0.8.0;
3+
4+
library Strings2 {
5+
6+
///@dev converts bytes array to its ASCII hex string representation
7+
/// TODO: Definitely more efficient way to do this by processing multiple (16?) bytes at once
8+
/// but really a helper function for the tests, efficiency not key.
9+
function toHexString(bytes memory input) public pure returns (string memory) {
10+
require(input.length < type(uint256).max / 2 - 1);
11+
bytes16 symbols = "0123456789abcdef";
12+
bytes memory hex_buffer = new bytes(2 * input.length + 2);
13+
hex_buffer[0] = "0";
14+
hex_buffer[1] = "x";
15+
16+
uint pos = 2;
17+
uint256 length = input.length;
18+
for (uint i = 0; i < length; ++i) {
19+
uint _byte = uint8(input[i]);
20+
hex_buffer[pos++] = symbols[_byte >> 4];
21+
hex_buffer[pos++] = symbols[_byte & 0xf];
22+
}
23+
return string(hex_buffer);
24+
}
25+
}

0 commit comments

Comments
 (0)