-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add univ3 svg generation test (#1292)
<!--- Please provide a general summary of your changes in the title above --> <!-- Give an estimate of the time you spent on this PR in terms of work days. Did you spend 0.5 days on this PR or rather 2 days? --> Time spent on this PR: 1d Adds Mock UniswapV3 contracts that allow querying a dynamically generated on-chain SVG representing a position. The values are mocked, and due to some issues, the base64 encoding of the image crashes with a stack underflow error (tbd). However, the encoding of the rest takes ~27M steps Also added a way to do library linking in the python kakarot scripts ## Pull request type <!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Resolves #<Issue number> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - - - <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1292) <!-- Reviewable:end -->
- Loading branch information
Showing
18 changed files
with
1,082 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
[submodule "solidity_contracts/lib/forge-std"] | ||
path = solidity_contracts/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
branch = v1.3.0 | ||
[submodule "solidity_contracts/lib/kakarot-lib"] | ||
path = solidity_contracts/lib/kakarot-lib | ||
url = https://github.com/kkrt-labs/kakarot-lib | ||
[submodule "solidity_contracts/lib/v3-core"] | ||
path = solidity_contracts/lib/v3-core | ||
url = https://github.com/Uniswap/v3-core | ||
[submodule "solidity_contracts/lib/openzeppelin"] | ||
path = solidity_contracts/lib/openzeppelin | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts | ||
[submodule "solidity_contracts/lib/base64-sol"] | ||
path = solidity_contracts/lib/base64-sol | ||
url = https://github.com/Brechtpd/base64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule base64-sol
added at
dcbf85
Submodule openzeppelin
added at
8e0296
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity =0.7.6; | ||
|
||
library HexStrings { | ||
bytes16 internal constant ALPHABET = "0123456789abcdef"; | ||
|
||
/// @notice Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. | ||
/// @dev Credit to Open Zeppelin under MIT license https://github.com/OpenZeppelin/openzeppelin-contracts/blob/243adff49ce1700e0ecb99fe522fb16cff1d1ddc/contracts/utils/Strings.sol#L55 | ||
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); | ||
} | ||
|
||
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); | ||
} | ||
} |
Oops, something went wrong.