diff --git a/src/helpers/Logger.sol b/src/helpers/Logger.sol index b532de34..59839c0f 100644 --- a/src/helpers/Logger.sol +++ b/src/helpers/Logger.sol @@ -24,7 +24,7 @@ library Logger { } } - function logUint(uint intToLog) internal view { + function logUint(uint256 intToLog) internal view { if (block.chainid == 260) { console.logUint(intToLog); } diff --git a/src/libraries/JsmnSolLib.sol b/src/libraries/JsmnSolLib.sol index 8752e3b0..b70fe193 100644 --- a/src/libraries/JsmnSolLib.sol +++ b/src/libraries/JsmnSolLib.sol @@ -31,27 +31,27 @@ library JsmnSolLib { PRIMITIVE } - uint constant RETURN_SUCCESS = 0; - uint constant RETURN_ERROR_INVALID_JSON = 1; - uint constant RETURN_ERROR_PART = 2; - uint constant RETURN_ERROR_NO_MEM = 3; + uint256 constant RETURN_SUCCESS = 0; + uint256 constant RETURN_ERROR_INVALID_JSON = 1; + uint256 constant RETURN_ERROR_PART = 2; + uint256 constant RETURN_ERROR_NO_MEM = 3; struct Token { JsmnType jsmnType; - uint start; + uint256 start; bool startSet; - uint end; + uint256 end; bool endSet; uint8 size; } struct Parser { - uint pos; - uint toknext; - int toksuper; + uint256 pos; + uint256 toknext; + int256 toksuper; } - function init(uint length) internal pure returns (Parser memory, Token[] memory) { + function init(uint256 length) internal pure returns (Parser memory, Token[] memory) { Parser memory p = Parser(0, 0, -1); Token[] memory t = new Token[](length); return (p, t); @@ -68,7 +68,7 @@ library JsmnSolLib { return (true, token); } - function fillToken(Token memory token, JsmnType jsmnType, uint start, uint end) internal pure { + function fillToken(Token memory token, JsmnType jsmnType, uint256 start, uint256 end) internal pure { token.jsmnType = jsmnType; token.start = start; token.startSet = true; @@ -78,7 +78,7 @@ library JsmnSolLib { } function parseString(Parser memory parser, Token[] memory tokens, bytes memory s) internal pure returns (uint) { - uint start = parser.pos; + uint256 start = parser.pos; bool success; Token memory token; parser.pos++; @@ -124,7 +124,7 @@ library JsmnSolLib { function parsePrimitive(Parser memory parser, Token[] memory tokens, bytes memory s) internal pure returns (uint) { bool found = false; - uint start = parser.pos; + uint256 start = parser.pos; bool success; bytes1 c; Token memory token; @@ -155,16 +155,16 @@ library JsmnSolLib { return RETURN_SUCCESS; } - function parse(string memory json, uint numberElements) internal pure returns (uint, Token[] memory tokens, uint) { + function parse(string memory json, uint256 numberElements) internal pure returns (uint, Token[] memory tokens, uint) { bytes memory s = bytes(json); bool success; Parser memory parser; (parser, tokens) = init(numberElements); // Token memory token; - uint r; - uint count = parser.toknext; - uint i; + uint256 r; + uint256 count = parser.toknext; + uint256 i; Token memory token; for (; parser.pos < s.length; parser.pos++) { @@ -296,10 +296,10 @@ library JsmnSolLib { return (RETURN_SUCCESS, tokens, parser.toknext); } - function getBytes(string memory json, uint start, uint end) internal pure returns (string memory) { + function getBytes(string memory json, uint256 start, uint256 end) internal pure returns (string memory) { bytes memory s = bytes(json); bytes memory result = new bytes(end - start); - for (uint i = start; i < end; i++) { + for (uint256 i = start; i < end; i++) { result[i - start] = s[i]; } return string(result); @@ -311,12 +311,12 @@ library JsmnSolLib { } // parseInt(parseFloat*10^_b) - function parseInt(string memory _a, uint _b) internal pure returns (int) { + function parseInt(string memory _a, uint256 _b) internal pure returns (int) { bytes memory bresult = bytes(_a); - int mint = 0; + int256 mint = 0; bool decimals = false; bool negative = false; - for (uint i = 0; i < bresult.length; i++) { + for (uint256 i = 0; i < bresult.length; i++) { if ((i == 0) && (bresult[i] == "-")) { negative = true; } @@ -334,16 +334,16 @@ library JsmnSolLib { return mint; } - function uint2str(uint i) internal pure returns (string memory) { + function uint2str(uint256 i) internal pure returns (string memory) { if (i == 0) return "0"; - uint j = i; - uint len; + uint256 j = i; + uint256 len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); - uint k = len - 1; + uint256 k = len - 1; while (i != 0) { bstr[k--] = bytes1(uint8(48 + (i % 10))); i /= 10; @@ -362,9 +362,9 @@ library JsmnSolLib { function strCompare(string memory _a, string memory _b) internal pure returns (int) { bytes memory a = bytes(_a); bytes memory b = bytes(_b); - uint minLength = a.length; + uint256 minLength = a.length; if (b.length < minLength) minLength = b.length; - for (uint i = 0; i < minLength; i++) + for (uint256 i = 0; i < minLength; i++) if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; if (a.length < b.length) return -1; diff --git a/src/validators/WebAuthValidator.sol b/src/validators/WebAuthValidator.sol index c2e24c09..457ac76f 100644 --- a/src/validators/WebAuthValidator.sol +++ b/src/validators/WebAuthValidator.sol @@ -81,7 +81,7 @@ contract WebAuthValidator is VerifierCaller, IModuleValidator { // parse out the important fields (type, challenge, and origin): https://goo.gl/yabPex // TODO: test if the parse fails for more than 10 elements, otherwise can have a malicious header - (uint returnValue, JsmnSolLib.Token[] memory tokens, uint actualNum) = JsmnSolLib.parse(clientDataJSON, 20); + (uint256 returnValue, JsmnSolLib.Token[] memory tokens, uint256 actualNum) = JsmnSolLib.parse(clientDataJSON, 20); if (returnValue != 0) { return false; }