From 2b518bf1a44ff82180b9adda57fbcc46ba059e05 Mon Sep 17 00:00:00 2001 From: dianakocsis Date: Thu, 19 Sep 2024 11:26:22 -0400 Subject: [PATCH] warnings --- src/libraries/Descriptor.sol | 30 ------------------------------ src/libraries/HexStrings.sol | 2 ++ src/libraries/SafeERC20Namer.sol | 6 +----- test/PositionDescriptor.t.sol | 1 - test/libraries/Descriptor.t.sol | 20 ++++++++++---------- test/mocks/MockERC721Permit.sol | 2 +- 6 files changed, 14 insertions(+), 47 deletions(-) diff --git a/src/libraries/Descriptor.sol b/src/libraries/Descriptor.sol index 54729d88..cb546f22 100644 --- a/src/libraries/Descriptor.sol +++ b/src/libraries/Descriptor.sol @@ -80,8 +80,6 @@ library Descriptor { } /// @notice Escapes double quotes in a string if they are present - /// @param symbol The string to escape - /// @return The string with double quotes escaped function escapeQuotes(string memory symbol) internal pure returns (string memory) { bytes memory symbolBytes = bytes(symbol); uint8 quotesCount = 0; @@ -339,11 +337,6 @@ library Descriptor { return uint256(x >= 0 ? x : -x); } - /// @notice Returns string that includes first 5 significant figures of a decimal number - /// @param sqrtRatioX96 a sqrt price - /// @param baseCurrencyDecimals The decimals of the base currency - /// @param quoteCurrencyDecimals The decimals of the quote currency - /// @return The decimal string function fixedPointToDecimalString(uint160 sqrtRatioX96, uint8 baseCurrencyDecimals, uint8 quoteCurrencyDecimals) internal pure @@ -455,9 +448,6 @@ library Descriptor { return generateDecimalString(params); } - /// @notice Converts an address to a string - /// @param addr The address to convert - /// @return The address as a string function addressToString(address addr) internal pure returns (string memory) { return (uint256(uint160(addr))).toHexString(20); } @@ -508,13 +498,6 @@ library Descriptor { } } - /// @notice Scales a number from one range to another - /// @param n The number to scale - /// @param inMn The minimum of the input range - /// @param inMx The maximum of the input range - /// @param outMn The minimum of the output range - /// @param outMx The maximum of the output range - /// @return The scaled number as a string function scale(uint256 n, uint256 inMn, uint256 inMx, uint256 outMn, uint256 outMx) private pure @@ -523,27 +506,14 @@ library Descriptor { return (n - inMn * (outMx - outMn) / (inMx - inMn) + outMn).toString(); } - /// @notice Converts a currency to a color in hex to be used in the SVG - /// @param currency The currency - /// @param offset The offset to slice the token hex - /// @return str The color hex as a string function currencyToColorHex(uint256 currency, uint256 offset) internal pure returns (string memory str) { return string((currency >> offset).toHexStringNoPrefix(3)); } - /// @notice Gets the coordinate for a circle - /// @param currency The currency ID - /// @param offset The offset to slice the token hex - /// @param tokenId The token ID - /// @return The coordinate function getCircleCoord(uint256 currency, uint256 offset, uint256 tokenId) internal pure returns (uint256) { return (sliceCurrencyHex(currency, offset) * tokenId) % 255; } - /// @notice Slices the currency ID hex - /// @param currency The currency ID - /// @param offset The offset to slice the token hex - /// @return The sliced hex function sliceCurrencyHex(uint256 currency, uint256 offset) internal pure returns (uint256) { return uint256(uint8(currency >> offset)); } diff --git a/src/libraries/HexStrings.sol b/src/libraries/HexStrings.sol index aa2f80c0..8d662eaf 100644 --- a/src/libraries/HexStrings.sol +++ b/src/libraries/HexStrings.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.24; +/// @title HexStrings +/// @notice Provides function for converting numbers to hexadecimal strings library HexStrings { bytes16 internal constant ALPHABET = "0123456789abcdef"; diff --git a/src/libraries/SafeERC20Namer.sol b/src/libraries/SafeERC20Namer.sol index 81ad361f..801c4d42 100644 --- a/src/libraries/SafeERC20Namer.sol +++ b/src/libraries/SafeERC20Namer.sol @@ -7,9 +7,6 @@ import "./AddressStringUtil.sol"; /// @notice produces token descriptors from inconsistent or absent ERC20 symbol implementations that can return string or bytes32 /// this library will always produce a string symbol to represent the token library SafeERC20Namer { - /// @notice converts a bytes32 to a string - /// @param x the bytes32 to convert - /// @return the string representation function bytes32ToString(bytes32 x) private pure returns (string memory) { bytes memory bytesString = new bytes(32); uint256 charCount = 0; @@ -27,8 +24,7 @@ library SafeERC20Namer { return string(bytesStringTrimmed); } - /// @notice uses a heuristic to produce a token symbol from the address - // the heuristic returns the first 6 hex of the address string in upper case + /// @notice produces a token symbol from the address - the first 6 hex of the address string in upper case /// @param token the token address /// @return the token symbol function addressToSymbol(address token) private pure returns (string memory) { diff --git a/test/PositionDescriptor.t.sol b/test/PositionDescriptor.t.sol index 81c7791d..8498a9a9 100644 --- a/test/PositionDescriptor.t.sol +++ b/test/PositionDescriptor.t.sol @@ -115,6 +115,5 @@ contract PositionDescriptorTest is Test, PosmTestSetup { // decode json bytes memory data = vm.parseJson(json); Token memory token = abi.decode(data, (Token)); - console2.log("token.image", token.image); } } diff --git a/test/libraries/Descriptor.t.sol b/test/libraries/Descriptor.t.sol index e3e45a63..a73f79f9 100644 --- a/test/libraries/Descriptor.t.sol +++ b/test/libraries/Descriptor.t.sol @@ -25,7 +25,7 @@ contract DescriptorTest is Test { assertEq(Descriptor.feeToPercentString(12300000), "1230%"); } - function test_addressToString_succeeds() public { + function test_addressToString_succeeds() public pure { assertEq(Descriptor.addressToString(address(0)), "0x0000000000000000000000000000000000000000"); assertEq(Descriptor.addressToString(address(1)), "0x0000000000000000000000000000000000000001"); assertEq( @@ -38,7 +38,7 @@ contract DescriptorTest is Test { ); } - function test_escapeQuotes_succeeds() public { + function test_escapeQuotes_succeeds() public pure { assertEq(Descriptor.escapeQuotes(""), ""); assertEq(Descriptor.escapeQuotes("a"), "a"); assertEq(Descriptor.escapeQuotes("abc"), "abc"); @@ -49,7 +49,7 @@ contract DescriptorTest is Test { assertEq(Descriptor.escapeQuotes("\"a\"b\"c\"\""), "\\\"a\\\"b\\\"c\\\"\\\""); } - function test_tickToDecimalString_withTickSpacing10() public { + function test_tickToDecimalString_withTickSpacing10() public pure { int24 tickSpacing = 10; int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing; int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing; @@ -63,7 +63,7 @@ contract DescriptorTest is Test { ); } - function test_tickToDecimalString_withTickSpacing60() public { + function test_tickToDecimalString_withTickSpacing60() public pure { int24 tickSpacing = 60; int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing; int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing; @@ -77,7 +77,7 @@ contract DescriptorTest is Test { ); } - function test_tickToDecimalString_withTickSpacing200() public { + function test_tickToDecimalString_withTickSpacing200() public pure { int24 tickSpacing = 200; int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing; int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing; @@ -91,30 +91,30 @@ contract DescriptorTest is Test { ); } - function test_tickToDecimalString_ratio_returnsInverseMediumNumbers() public { + function test_tickToDecimalString_ratio_returnsInverseMediumNumbers() public pure { int24 tickSpacing = 200; assertEq(Descriptor.tickToDecimalString(10, tickSpacing, 18, 18, false), "1.0010"); assertEq(Descriptor.tickToDecimalString(10, tickSpacing, 18, 18, true), "0.99900"); } - function test_tickToDecimalString_ratio_returnsInverseLargeNumbers() public { + function test_tickToDecimalString_ratio_returnsInverseLargeNumbers() public pure { int24 tickSpacing = 200; assertEq(Descriptor.tickToDecimalString(487272, tickSpacing, 18, 18, false), "1448400000000000000000"); assertEq(Descriptor.tickToDecimalString(487272, tickSpacing, 18, 18, true), "0.00000000000000000000069041"); } - function test_tickToDecimalString_ratio_returnsInverseSmallNumbers() public { + function test_tickToDecimalString_ratio_returnsInverseSmallNumbers() public pure { int24 tickSpacing = 200; assertEq(Descriptor.tickToDecimalString(-387272, tickSpacing, 18, 18, false), "0.000000000000000015200"); assertEq(Descriptor.tickToDecimalString(-387272, tickSpacing, 18, 18, true), "65791000000000000"); } - function test_tickToDecimalString_differentDecimals() public { + function test_tickToDecimalString_differentDecimals() public pure { int24 tickSpacing = 200; assertEq(Descriptor.tickToDecimalString(1000, tickSpacing, 18, 18, true), "0.90484"); assertEq(Descriptor.tickToDecimalString(1000, tickSpacing, 18, 10, true), "90484000"); assertEq(Descriptor.tickToDecimalString(1000, tickSpacing, 10, 18, true), "0.0000000090484"); } - function test_fixedPointToDecimalString_succeeds() public {} + function test_fixedPointToDecimalString_succeeds() public pure {} } diff --git a/test/mocks/MockERC721Permit.sol b/test/mocks/MockERC721Permit.sol index 75bd1c6b..bf379208 100644 --- a/test/mocks/MockERC721Permit.sol +++ b/test/mocks/MockERC721Permit.sol @@ -13,7 +13,7 @@ contract MockERC721Permit is ERC721Permit_v4 { _mint(msg.sender, tokenId); } - function tokenURI(uint256 id) public view override returns (string memory) { + function tokenURI(uint256) public pure override returns (string memory) { return "mock"; } }