Skip to content

Commit bb3f0ae

Browse files
Krishang NadgaudaKrishang Nadgauda
authored andcommitted
run prettier
1 parent 91be227 commit bb3f0ae

File tree

3 files changed

+34
-36
lines changed

3 files changed

+34
-36
lines changed

contracts/lib/Strings2.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
pragma solidity ^0.8.0;
32

43
library Strings2 {
5-
64
///@dev converts bytes array to its ASCII hex string representation
75
/// TODO: Definitely more efficient way to do this by processing multiple (16?) bytes at once
86
/// but really a helper function for the tests, efficiency not key.
@@ -13,13 +11,13 @@ library Strings2 {
1311
hex_buffer[0] = "0";
1412
hex_buffer[1] = "x";
1513

16-
uint pos = 2;
14+
uint256 pos = 2;
1715
uint256 length = input.length;
18-
for (uint i = 0; i < length; ++i) {
19-
uint _byte = uint8(input[i]);
16+
for (uint256 i = 0; i < length; ++i) {
17+
uint256 _byte = uint8(input[i]);
2018
hex_buffer[pos++] = symbols[_byte >> 4];
2119
hex_buffer[pos++] = symbols[_byte & 0xf];
2220
}
2321
return string(hex_buffer);
2422
}
25-
}
23+
}

src/test/SignatureDrop.t.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import "@openzeppelin/contracts/utils/Strings.sol";
1111
import "contracts/lib/Strings2.sol";
1212

1313
contract SignatureDropTest is BaseTest {
14-
1514
using StringsUpgradeable for uint256;
1615
using Strings2 for bytes;
1716

@@ -71,7 +70,7 @@ contract SignatureDropTest is BaseTest {
7170
assertEq(nextTokenIdToMintBefore + amountToLazyMint, sigdrop.nextTokenIdToMint());
7271
assertEq(nextTokenIdToMintBefore + amountToLazyMint, batchId);
7372

74-
for(uint256 i = 0; i < amountToLazyMint; i += 1) {
73+
for (uint256 i = 0; i < amountToLazyMint; i += 1) {
7574
string memory uri = sigdrop.tokenURI(i);
7675
console.log(uri);
7776
assertEq(uri, string(abi.encodePacked(baseURI, i.toString())));
@@ -96,7 +95,7 @@ contract SignatureDropTest is BaseTest {
9695
assertEq(nextTokenIdToMintBefore + amountToLazyMint, sigdrop.nextTokenIdToMint());
9796
assertEq(nextTokenIdToMintBefore + amountToLazyMint, batchId);
9897

99-
for(uint256 i = 0; i < amountToLazyMint; i += 1) {
98+
for (uint256 i = 0; i < amountToLazyMint; i += 1) {
10099
string memory uri = sigdrop.tokenURI(1);
101100
assertEq(uri, string(abi.encodePacked(baseURI, "0")));
102101
}
@@ -150,7 +149,6 @@ contract SignatureDropTest is BaseTest {
150149
* note: Fuzz testing state changes; lazy mint a batch of tokens with no encrypted base URI.
151150
*/
152151
function test_fuzz_lazyMint_noEncryptedURI(uint256 x) public {
153-
154152
vm.assume(x > 0);
155153

156154
uint256 amountToLazyMint = x;
@@ -166,10 +164,10 @@ contract SignatureDropTest is BaseTest {
166164
assertEq(nextTokenIdToMintBefore + amountToLazyMint, batchId);
167165

168166
string memory uri = sigdrop.tokenURI(0);
169-
assertEq(uri, string(abi.encodePacked(baseURI, uint(0).toString())));
167+
assertEq(uri, string(abi.encodePacked(baseURI, uint256(0).toString())));
170168

171-
uri = sigdrop.tokenURI(x-1);
172-
assertEq(uri, string(abi.encodePacked(baseURI, uint(x-1).toString())));
169+
uri = sigdrop.tokenURI(x - 1);
170+
assertEq(uri, string(abi.encodePacked(baseURI, uint256(x - 1).toString())));
173171

174172
/**
175173
* note: this loop takes too long to run with fuzz tests.
@@ -204,7 +202,7 @@ contract SignatureDropTest is BaseTest {
204202
string memory uri = sigdrop.tokenURI(0);
205203
assertEq(uri, string(abi.encodePacked(baseURI, "0")));
206204

207-
uri = sigdrop.tokenURI(x-1);
205+
uri = sigdrop.tokenURI(x - 1);
208206
assertEq(uri, string(abi.encodePacked(baseURI, "0")));
209207

210208
/**
@@ -251,15 +249,15 @@ contract SignatureDropTest is BaseTest {
251249
bytes memory encryptedURI = sigdrop.encryptDecrypt(secretURI, key);
252250
sigdrop.lazyMint(amountToLazyMint, placeholderURI, encryptedURI);
253251

254-
for(uint256 i = 0; i < amountToLazyMint; i += 1) {
252+
for (uint256 i = 0; i < amountToLazyMint; i += 1) {
255253
string memory uri = sigdrop.tokenURI(i);
256254
assertEq(uri, string(abi.encodePacked(placeholderURI, "0")));
257255
}
258256

259257
string memory revealedURI = sigdrop.reveal(0, key);
260258
assertEq(revealedURI, string(secretURI));
261259

262-
for(uint256 i = 0; i < amountToLazyMint; i += 1) {
260+
for (uint256 i = 0; i < amountToLazyMint; i += 1) {
263261
string memory uri = sigdrop.tokenURI(i);
264262
assertEq(uri, string(abi.encodePacked(secretURI, i.toString())));
265263
}
@@ -382,7 +380,6 @@ contract SignatureDropTest is BaseTest {
382380

383381
// Test with ERC20 currency
384382
{
385-
386383
uint256 totalSupplyBefore = sigdrop.totalSupply();
387384

388385
bytes memory encodedRequest = abi.encode(
@@ -648,7 +645,10 @@ contract SignatureDropTest is BaseTest {
648645
address owner = sigdrop.ownerOf(0);
649646
assertEq(deployerSigner, owner);
650647

651-
assertEq(currencyBalBefore - mintrequest.pricePerToken * mintrequest.quantity, erc20.balanceOf(deployerSigner));
648+
assertEq(
649+
currencyBalBefore - mintrequest.pricePerToken * mintrequest.quantity,
650+
erc20.balanceOf(deployerSigner)
651+
);
652652

653653
vm.expectRevert(abi.encodeWithSignature("OwnerQueryForNonexistentToken()"));
654654
owner = sigdrop.ownerOf(1);

src/test/scripts/merkleTree.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
const { MerkleTree } = require('merkletreejs')
2-
const SHA256 = require('crypto-js/sha256')
1+
const { MerkleTree } = require("merkletreejs");
2+
const SHA256 = require("crypto-js/sha256");
33

4-
const tree = async (leaves) => {
5-
// console.log("leaves: ", leaves);
4+
const tree = async leaves => {
5+
// console.log("leaves: ", leaves);
66

7-
const leaves = ['a', 'b', 'c'].map(x => SHA256(x))
8-
const tree = new MerkleTree(leaves, SHA256)
9-
const root = tree.getRoot().toString('hex')
10-
const leaf = SHA256('a')
11-
const proof = tree.getProof(leaf)
12-
console.log(tree.verify(proof, leaf, root)) // true
13-
// return proof
7+
const leaves = ["a", "b", "c"].map(x => SHA256(x));
8+
const tree = new MerkleTree(leaves, SHA256);
9+
const root = tree.getRoot().toString("hex");
10+
const leaf = SHA256("a");
11+
const proof = tree.getProof(leaf);
12+
console.log(tree.verify(proof, leaf, root)); // true
13+
// return proof
1414

15-
const badLeaves = ['a', 'x', 'c'].map(x => SHA256(x))
16-
const badTree = new MerkleTree(badLeaves, SHA256)
17-
const badLeaf = SHA256('x')
18-
const badProof = tree.getProof(badLeaf)
19-
console.log(tree.verify(badProof, leaf, root)) // false
20-
}
15+
const badLeaves = ["a", "x", "c"].map(x => SHA256(x));
16+
const badTree = new MerkleTree(badLeaves, SHA256);
17+
const badLeaf = SHA256("x");
18+
const badProof = tree.getProof(badLeaf);
19+
console.log(tree.verify(badProof, leaf, root)); // false
20+
};
2121

22-
tree();
22+
tree();

0 commit comments

Comments
 (0)