From 512906d4abd158e4a50cf2ce778870e0b9ed36ea Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Wed, 16 Oct 2024 21:58:39 +0200 Subject: [PATCH] replace JsmnSolLib.sol with compatible version --- packages/hardhat/contracts/JsmnSolLib.sol | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/hardhat/contracts/JsmnSolLib.sol b/packages/hardhat/contracts/JsmnSolLib.sol index 394d9a1..05be2f1 100644 --- a/packages/hardhat/contracts/JsmnSolLib.sol +++ b/packages/hardhat/contracts/JsmnSolLib.sol @@ -1,3 +1,6 @@ +// Reference: https://github.com/chrisdotn/jsmnSol/issues/18 + +// SPDX-License-Identifier: MIT /* Copyright (c) 2017 Christoph Niemann Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -112,8 +115,8 @@ library JsmnSolLib { function parsePrimitive(Parser memory parser, Token[] memory tokens, bytes memory s) internal pure returns (uint) { bool found = false; uint start = parser.pos; - bool success; bytes1 c; + bool success; Token memory token; for (; parser.pos < s.length; parser.pos++) { c = s[parser.pos]; @@ -207,7 +210,7 @@ library JsmnSolLib { if (i==0) { token = tokens[i]; if (token.startSet && !token.endSet) { - parser.toksuper = int256(i); + parser.toksuper = int128(uint128(i)); } } continue; @@ -301,7 +304,7 @@ library JsmnSolLib { // parseInt(parseFloat*10^_b) function parseInt(string memory _a, uint _b) internal pure returns (int) { bytes memory bresult = bytes(_a); - int8 mint = 0; + int mint = 0; bool decimals = false; bool negative = false; for (uint i=0; i 0) mint *= int8(uint8(10)**uint8(_b)); + if (_b > 0) mint *= int(10**_b); if (negative) mint *= -1; - return mint; }