Skip to content

Commit b2e803d

Browse files
committed
style(format): forge fmt
1 parent 14285d0 commit b2e803d

11 files changed

+23
-21
lines changed

Diff for: src/lotteries/GuessTheNewNumber.sol

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pragma solidity ^0.8.13;
44
contract GuessTheNewNumber {
55
constructor() payable {
66
require(msg.value == 1 ether);
7-
87
}
98

109
function isComplete() public view returns (bool) {
@@ -19,4 +18,4 @@ contract GuessTheNewNumber {
1918
payable(msg.sender).transfer(2 ether);
2019
}
2120
}
22-
}
21+
}

Diff for: src/lotteries/GuessTheRandomNumber.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ contract GuessTheRandomNumber {
2020
payable(msg.sender).transfer(2 ether);
2121
}
2222
}
23-
}
23+
}

Diff for: src/lotteries/PredictTheBlockHash.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ contract PredictTheBlockHash {
3434
payable(msg.sender).transfer(2 ether);
3535
}
3636
}
37-
}
37+
}

Diff for: src/lotteries/PredictTheFuture.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ contract PredictTheFuture {
3434
payable(msg.sender).transfer(2 ether);
3535
}
3636
}
37-
}
37+
}

Diff for: src/math/TokenSale.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ contract TokenSale {
2727
balanceOf[msg.sender] -= numTokens;
2828
payable(msg.sender).transfer(numTokens * PRICE_PER_TOKEN);
2929
}
30-
}
30+
}

Diff for: test/lotteries/GuessTheNewNumber.t.sol

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {GuessTheNewNumber} from "../../src/lotteries/GuessTheNewNumber.sol";
66

77
contract GuessTheNewNumberTest is Test {
88
GuessTheNewNumber challenge;
9+
910
receive() external payable {}
1011

1112
function setUp() public {
@@ -17,12 +18,12 @@ contract GuessTheNewNumberTest is Test {
1718
// this call is from a Contract
1819
// which share same block infos.
1920
// so we can just calculate the answer to "guess".
20-
// we can deploy a proxy contract to do this
21+
// we can deploy a proxy contract to do this
2122
// if not within foundry test.
2223
uint8 answer = uint8(uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), block.timestamp))));
2324
vm.deal(address(this), 1 ether);
2425
challenge.guess{value: 1 ether}(answer);
25-
26+
2627
assertTrue(challenge.isComplete(), "not completed");
2728
}
2829
}

Diff for: test/lotteries/GuessTheRandomNumber.t.sol

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {GuessTheRandomNumber} from "../../src/lotteries/GuessTheRandomNumber.sol
66

77
contract GuessTheRandomNumberTest is Test {
88
GuessTheRandomNumber challenge;
9+
910
receive() external payable {}
1011

1112
function setUp() public {
@@ -15,14 +16,14 @@ contract GuessTheRandomNumberTest is Test {
1516

1617
function testReadingFromSlot() public {
1718
// we read answer from slot 0
18-
// because it's only "private" to other contracts
19+
// because it's only "private" to other contracts
1920
// or external calls through standard function invocations.
2021
bytes32 slot = bytes32(uint256(0));
2122
bytes32 value = vm.load(address(challenge), slot);
2223
uint8 answer = uint8(uint256(value));
2324
vm.deal(address(this), 1 ether);
2425
challenge.guess{value: 1 ether}(answer);
25-
26+
2627
assertTrue(challenge.isComplete(), "not completed");
2728
}
2829
}

Diff for: test/lotteries/GuessTheSecretNumber.t.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ contract GuessTheSecretNumberTest is Test {
1616

1717
function testBruteForce() public {
1818
bytes32 answerHash = 0xdb81b4d58595fbbbb592d3661a34cdca14d7ab379441400cbfa1b78bc447c365;
19-
20-
// uint8 can only hold 256 in maximum,
19+
20+
// uint8 can only hold 256 in maximum,
2121
// we can try hash all of them to get answer.
2222
for (uint8 i = 0; i < 255; i++) {
2323
if (keccak256(abi.encodePacked(i)) == answerHash) {
2424
challenge.guess{value: 1 ether}(i);
2525
break;
2626
}
2727
}
28-
28+
2929
assertTrue(challenge.isComplete(), "not completed");
3030
}
3131
}

Diff for: test/lotteries/PredictTheBlockHash.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {PredictTheBlockHash} from "../../src/lotteries/PredictTheBlockHash.sol";
66

77
contract PredictTheBlockHashTest is Test {
88
PredictTheBlockHash challenge;
9+
910
receive() external payable {}
1011

1112
function setUp() public {
@@ -23,4 +24,3 @@ contract PredictTheBlockHashTest is Test {
2324
assertTrue(challenge.isComplete(), "not completed");
2425
}
2526
}
26-

Diff for: test/lotteries/PredictTheFuture.t.sol

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {PredictTheFuture} from "../../src/lotteries/PredictTheFuture.sol";
66

77
contract PredictTheFutureTest is Test {
88
PredictTheFuture challenge;
9+
910
receive() external payable {}
1011

1112
function setUp() public {
@@ -19,20 +20,20 @@ contract PredictTheFutureTest is Test {
1920
vm.deal(address(this), 1 ether);
2021
uint8 answer = 0;
2122
Proxy proxy = new Proxy(challenge);
22-
uint blockNumber = block.number;
23+
uint256 blockNumber = block.number;
2324
proxy.lockInGuess{value: 1 ether}(answer);
24-
25+
2526
uint8 lastIndex = 0;
2627
for (uint8 i = 0; i < 256; i++) {
2728
vm.roll(blockNumber + 2 + i);
2829
try proxy.attack() {
2930
lastIndex = i + 1;
3031
break;
31-
} catch (bytes memory /*lowLevelData*/) {
32+
} catch (bytes memory) /*lowLevelData*/ {
3233
// This is executed in case revert() was used.
3334
}
3435
}
35-
36+
3637
assertTrue(challenge.isComplete(), "not completed");
3738
}
3839
}

Diff for: test/math/TokenSale.t.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {TokenSale} from "../../src/math/TokenSale.sol";
66

77
contract TokenSaleTest is Test {
88
TokenSale challenge;
9+
910
receive() external payable {}
1011

1112
function setUp() public {
@@ -21,10 +22,10 @@ contract TokenSaleTest is Test {
2122
unchecked {
2223
// max / ether ... * ether = max
2324
// so plus it with one will cause overflow
24-
uint256 numTokens = (type(uint256).max / 1 ether)+1;
25+
uint256 numTokens = (type(uint256).max / 1 ether) + 1;
2526
// we need to pay this `overflow` amount
2627
uint256 value = numTokens * 1 ether % type(uint256).max;
27-
// now we can get almost type(uint256).max tokens
28+
// now we can get almost type(uint256).max tokens
2829
// with only a few ether/wei.
2930
challenge.buy{value: value}(numTokens);
3031
}
@@ -33,4 +34,3 @@ contract TokenSaleTest is Test {
3334
assertTrue(challenge.isComplete(), "not completed");
3435
}
3536
}
36-

0 commit comments

Comments
 (0)