diff --git a/.gitmodules b/.gitmodules
index dd31873..2c70be7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,10 +3,7 @@
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solmate"]
path = lib/solmate
- url = https://github.com/rari-capital/solmate
-[submodule "lib/openzeppelin-contracts"]
- path = lib/openzeppelin-contracts
- url = https://github.com/OpenZeppelin/openzeppelin-contracts
+ url = https://github.com/axic/solmate
[submodule "lib/puretea"]
path = lib/puretea
url = https://github.com/axic/puretea
diff --git a/foundry.toml b/foundry.toml
index 639c068..9db8d8c 100644
--- a/foundry.toml
+++ b/foundry.toml
@@ -9,7 +9,6 @@ cbor_metadata = false
# See more config options https://github.com/gakonst/foundry/tree/master/config
remappings = [
- '@openzeppelin=lib/openzeppelin-contracts/',
'forge-std=lib/forge-std/src/',
]
diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts
deleted file mode 160000
index 83277ff..0000000
--- a/lib/openzeppelin-contracts
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 83277ff916ac4f58fec072b8f28a252c1245c2f1
diff --git a/lib/solmate b/lib/solmate
index eaaccf8..6fa069d 160000
--- a/lib/solmate
+++ b/lib/solmate
@@ -1 +1 @@
-Subproject commit eaaccf88ac5290299884437e1aee098a96583d54
+Subproject commit 6fa069dcdbf3b4f7d9017e81b36223091d3d79bd
diff --git a/src/HexString.sol b/src/HexString.sol
new file mode 100644
index 0000000..817e128
--- /dev/null
+++ b/src/HexString.sol
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+pragma solidity ^0.8.15;
+
+library HexString {
+ bytes16 constant ALPHABET = '0123456789abcdef';
+
+ function toHexStringNoPrefix(uint256 value, uint256 length) internal pure returns (string memory) {
+ bytes memory buffer = new bytes(2 * length);
+ for (uint256 i = buffer.length; i > 0; i--) {
+ buffer[i - 1] = ALPHABET[value & 0xf];
+ value >>= 4;
+ }
+ return string(buffer);
+ }
+
+ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
+ bytes memory buffer = new bytes(2 * length + 2);
+ buffer[0] = '0';
+ buffer[1] = 'x';
+ for (uint256 i = 2 * length + 1; i > 1; --i) {
+ buffer[i] = ALPHABET[value & 0xf];
+ value >>= 4;
+ }
+ require(value == 0, 'Strings: hex length insufficient');
+ return string(buffer);
+ }
+
+}
diff --git a/src/NFTSVG.sol b/src/NFTSVG.sol
index 2368cd6..45c4aef 100644
--- a/src/NFTSVG.sol
+++ b/src/NFTSVG.sol
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
-import '@openzeppelin/contracts/utils/Strings.sol';
+import './HexString.sol';
import './base64.sol';
+import "solmate/utils/LibString.sol";
+
/// @title NFTSVG
/// @notice Provides a function for generating an SVG associated with a Uniswap NFT
library NFTSVG {
- using Strings for uint256;
-
struct SVGParams {
string projectName;
string challengeName;
@@ -55,7 +55,7 @@ library NFTSVG {
generateSVGCardMantle(params.challengeName, params.challengeAddr, params.rank, params.participants),
generateSvgCurve(params.overRange, challengeSVG),
generateSVGPositionDataAndLocationCurve(
- params.tokenId.toString(),
+ LibString.toString(params.tokenId),
params.gasUsed,
params.gasOpti
),
@@ -196,9 +196,9 @@ library NFTSVG {
'',
string.concat(
"Rank #",
- Strings.toString(rank),
+ LibString.toString(rank),
"/",
- Strings.toString(participants)
+ LibString.toString(participants)
),
'',
''
@@ -228,8 +228,8 @@ library NFTSVG {
uint gasUsed,
uint gasOpti
) private pure returns (string memory svg) {
- string memory gasUsedStr = Strings.toString(gasUsed);
- string memory gasOptiStr = Strings.toString(gasOpti);
+ string memory gasUsedStr = LibString.toString(gasUsed);
+ string memory gasOptiStr = LibString.toString(gasOpti);
uint256 str1length = bytes(tokenId).length + 4;
uint256 str2length = bytes(gasUsedStr).length + 10;
uint256 str3length = bytes(gasOptiStr).length + 10;
@@ -237,21 +237,21 @@ library NFTSVG {
abi.encodePacked(
' ',
'',
'ID: ',
tokenId,
'',
' ',
'',
'Gas used: ',
gasUsedStr,
'',
' ',
'',
'Gas opti: ',
gasOptiStr,
@@ -278,16 +278,7 @@ library NFTSVG {
}
function tokenToColorHex(uint256 token, uint256 offset) internal pure returns (string memory str) {
- return string(toHexStringNoPrefix((token >> offset), 3));
- }
-
- function toHexStringNoPrefix(uint256 value, uint256 length) internal pure returns (string memory) {
- bytes memory buffer = new bytes(2 * length);
- for (uint256 i = buffer.length; i > 0; i--) {
- buffer[i - 1] = ALPHABET[value & 0xf];
- value >>= 4;
- }
- return string(buffer);
+ return string(HexString.toHexStringNoPrefix((token >> offset), 3));
}
function scale(
@@ -297,7 +288,7 @@ library NFTSVG {
uint256 outMn,
uint256 outMx
) internal pure returns (string memory) {
- return Strings.toString(((n - inMn) * (outMx - outMn)) / (inMx - inMn) + outMn);
+ return LibString.toString(((n - inMn) * (outMx - outMn)) / (inMx - inMn) + outMn);
}
function getCircleCoord(
@@ -311,18 +302,4 @@ library NFTSVG {
function sliceTokenHex(uint256 token, uint256 offset) internal pure returns (uint256) {
return uint256(uint8(token >> offset));
}
-
- function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
- bytes memory buffer = new bytes(2 * length + 2);
- buffer[0] = '0';
- buffer[1] = 'x';
- for (uint256 i = 2 * length + 1; i > 1; --i) {
- buffer[i] = ALPHABET[value & 0xf];
- value >>= 4;
- }
- require(value == 0, 'Strings: hex length insufficient');
- return string(buffer);
- }
-
- bytes16 constant ALPHABET = '0123456789abcdef';
}
diff --git a/src/OptimizorNFT.sol b/src/OptimizorNFT.sol
index afa4154..20d7f64 100644
--- a/src/OptimizorNFT.sol
+++ b/src/OptimizorNFT.sol
@@ -8,10 +8,11 @@ import "./NFTSVG.sol";
import "./IPurityChecker.sol";
import "./IAttribute.sol";
import "./TokenDetails.sol";
+import "./HexString.sol";
import "solmate/auth/Owned.sol";
import "solmate/tokens/ERC721.sol";
-import '@openzeppelin/contracts/utils/Strings.sol';
+import "solmate/utils/LibString.sol";
uint constant EPOCH = 256;
@@ -223,9 +224,9 @@ contract Optimizor is Owned, ERC721 {
for (uint i = 0; i < leaders.length; ++i) {
leadersStr = string.concat(
"\\n",
- Strings.toString(lIdx),
+ LibString.toString(lIdx),
". ",
- Strings.toHexString(uint(uint160(leaders[i])), 20),
+ HexString.toHexString(uint(uint160(leaders[i])), 20),
leadersStr
);
--lIdx;
@@ -279,8 +280,8 @@ contract Optimizor is Owned, ERC721 {
projectName: "Optimizor",
challengeName: name,
// TODO should \/ be details.owner or details.recordHolder?
- holderAddr: NFTSVG.toHexString(uint(uint160(address(details.owner))), 20),
- challengeAddr: NFTSVG.toHexString(uint(uint160(address(details.challenge))), 20),
+ holderAddr: HexString.toHexString(uint(uint160(address(details.owner))), 20),
+ challengeAddr: HexString.toHexString(uint(uint160(address(details.challenge))), 20),
gasUsed: details.gas,
gasOpti: gasOptiPercentage(tokenId, details),
overRange: int8(int256(uint256(keccak256(abi.encodePacked(tokenId))))) % 3,