Skip to content

Commit 0758be5

Browse files
authored
feat: add some important local settings (#14)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added Solidity language settings for VSCode across multiple projects. - **Refactor** - Updated `runs-on` configuration to `namespace-profile-btp-scs` in GitHub workflows for multiple projects. - Removed `timeout` property from Hardhat configuration files across various projects. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 4ea6c6d commit 0758be5

File tree

8 files changed

+72
-148
lines changed

8 files changed

+72
-148
lines changed

.github/workflows/pr-labels.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ permissions:
2323

2424
jobs:
2525
labels:
26-
runs-on: ubuntu-latest
26+
#runs-on: ubuntu-latest
27+
runs-on: namespace-profile-btp-scs
2728
steps:
2829
- uses: fuxingloh/multi-labeler@v4

.github/workflows/solidity.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ jobs:
4747
apk update
4848
apk add --no-cache cairo-dev jpeg-dev pango-dev giflib-dev build-base g++ pkgconfig
4949
50-
- name: Fetch semgrep rules
51-
uses: actions/checkout@v4
52-
with:
53-
repository: decurity/semgrep-smart-contracts
54-
path: rules
55-
56-
- run: semgrep ci --sarif --output=semgrep.sarif || true
57-
env:
58-
SEMGREP_RULES: rules/solidity/security rules/solidity/performance
59-
6050
- uses: crytic/slither-action@v0.4.0
6151
id: slither
6252
with:

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"[solidity]": {
3+
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
4+
},
5+
"solidity.formatter": "forge",
6+
"solidity.telemetry": false,
7+
"taskManager.exclude": "lib|install|tsc|hardhat"
8+
}

contracts/ExampleERC721a.sol

Lines changed: 23 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
pragma solidity ^0.8.24;
55

6-
import {IERC721A, ERC721A} from "erc721a/contracts/ERC721A.sol";
7-
import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
8-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
9-
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
10-
import {ERC721Whitelist} from "./extensions/ERC721Whitelist.sol";
6+
import { IERC721A, ERC721A } from "erc721a/contracts/ERC721A.sol";
7+
import { ERC2981 } from "@openzeppelin/contracts/token/common/ERC2981.sol";
8+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
9+
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
10+
import { ERC721Whitelist } from "./extensions/ERC721Whitelist.sol";
1111

1212
contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
1313
//////////////////////////////////////////////////////////////////
@@ -39,7 +39,10 @@ contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
3939
string memory symbol_,
4040
string memory baseTokenURI_,
4141
address payable wallet_
42-
) ERC721A(name_, symbol_) Ownable(msg.sender) {
42+
)
43+
ERC721A(name_, symbol_)
44+
Ownable(msg.sender)
45+
{
4346
_baseTokenURI = baseTokenURI_;
4447
_wallet = wallet_;
4548
}
@@ -56,14 +59,9 @@ contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
5659
return _baseTokenURI;
5760
}
5861

59-
function tokenURI(
60-
uint256 tokenId
61-
) public view virtual override returns (string memory) {
62+
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
6263
string memory tokenUri = super.tokenURI(tokenId);
63-
return
64-
bytes(tokenUri).length > 0
65-
? string(abi.encodePacked(tokenUri, ".json"))
66-
: "";
64+
return bytes(tokenUri).length > 0 ? string(abi.encodePacked(tokenUri, ".json")) : "";
6765
}
6866

6967
//////////////////////////////////////////////////////////////////
@@ -78,10 +76,7 @@ contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
7876
function gift(address[] calldata recipients_) external onlyOwner {
7977
require(_totalMinted() > 0, "Reserves not taken yet");
8078
uint256 recipients = recipients_.length;
81-
require(
82-
_totalMinted() + recipients <= MAX_SUPPLY,
83-
"Excedes max supply"
84-
);
79+
require(_totalMinted() + recipients <= MAX_SUPPLY, "Excedes max supply");
8580
for (uint256 i = 0; i < recipients; i++) {
8681
_safeMint(recipients_[i], 1);
8782
}
@@ -91,31 +86,16 @@ contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
9186
// WHITELIST SALE //
9287
//////////////////////////////////////////////////////////////////
9388

94-
function setWhitelistMerkleRoot(
95-
bytes32 whitelistMerkleRoot_
96-
) external onlyOwner {
89+
function setWhitelistMerkleRoot(bytes32 whitelistMerkleRoot_) external onlyOwner {
9790
_setWhitelistMerkleRoot(whitelistMerkleRoot_);
9891
}
9992

100-
function whitelistMint(
101-
uint256 count,
102-
uint256 allowance,
103-
bytes32[] calldata proof
104-
) public payable nonReentrant {
93+
function whitelistMint(uint256 count, uint256 allowance, bytes32[] calldata proof) public payable nonReentrant {
10594
require(_totalMinted() > 0, "Reserves not taken yet");
10695
require(_totalMinted() + count <= MAX_SUPPLY, "Exceeds max supply");
107-
require(
108-
_validateWhitelistMerkleProof(allowance, proof),
109-
"Invalid Merkle Tree proof supplied"
110-
);
111-
require(
112-
_addressToMinted[_msgSender()] + count <= allowance,
113-
"Exceeds whitelist allowance"
114-
);
115-
require(
116-
count * PRICE_IN_WEI_WHITELIST == msg.value,
117-
"Invalid funds provided"
118-
);
96+
require(_validateWhitelistMerkleProof(allowance, proof), "Invalid Merkle Tree proof supplied");
97+
require(_addressToMinted[_msgSender()] + count <= allowance, "Exceeds whitelist allowance");
98+
require(count * PRICE_IN_WEI_WHITELIST == msg.value, "Invalid funds provided");
11999
_addressToMinted[_msgSender()] += count;
120100
_safeMint(_msgSender(), count);
121101
}
@@ -130,15 +110,12 @@ contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
130110
}
131111

132112
function publicMint(uint256 count) public payable nonReentrant {
133-
require(_whitelistMerkleRoot == 0, "Public sale not active");
113+
require(_whiteListMerkleRoot == 0, "Public sale not active");
134114
require(_publicSaleOpen, "Public sale not active");
135115
require(_totalMinted() > 0, "Reserves not taken yet");
136116
require(_totalMinted() + count <= MAX_SUPPLY, "Exceeds max supply");
137117
require(count < MAX_PER_TX, "Exceeds max per transaction");
138-
require(
139-
count * PRICE_IN_WEI_PUBLIC == msg.value,
140-
"Invalid funds provided"
141-
);
118+
require(count * PRICE_IN_WEI_PUBLIC == msg.value, "Invalid funds provided");
142119
_safeMint(_msgSender(), count);
143120
}
144121

@@ -162,15 +139,9 @@ contract ExampleERC721a is ERC721A, ERC721Whitelist, Ownable, ReentrancyGuard {
162139
// ERC165 //
163140
//////////////////////////////////////////////////////////////////
164141

165-
function supportsInterface(
166-
bytes4 interfaceId
167-
) public view virtual override(ERC721A) returns (bool) {
168-
return
169-
interfaceId == type(Ownable).interfaceId ||
170-
interfaceId == type(IERC721A).interfaceId ||
171-
interfaceId == type(ERC721Whitelist).interfaceId ||
172-
ERC721A.supportsInterface(interfaceId) ||
173-
interfaceId == type(ERC2981).interfaceId ||
174-
super.supportsInterface(interfaceId);
142+
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721A) returns (bool) {
143+
return interfaceId == type(Ownable).interfaceId || interfaceId == type(IERC721A).interfaceId
144+
|| interfaceId == type(ERC721Whitelist).interfaceId || ERC721A.supportsInterface(interfaceId)
145+
|| interfaceId == type(ERC2981).interfaceId || super.supportsInterface(interfaceId);
175146
}
176147
}

contracts/extensions/ERC721Whitelist.sol

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,37 @@
1010
*/
1111
pragma solidity ^0.8.24;
1212

13-
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
14-
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
15-
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
13+
import { Context } from "@openzeppelin/contracts/utils/Context.sol";
14+
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
15+
import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
1616

1717
abstract contract ERC721Whitelist is Context {
18-
bytes32 public _whitelistMerkleRoot;
18+
bytes32 public _whiteListMerkleRoot;
1919

20-
function _setWhitelistMerkleRoot(bytes32 whitelistMerkleRoot_) internal {
21-
_whitelistMerkleRoot = whitelistMerkleRoot_;
20+
function _setWhitelistMerkleRoot(bytes32 whiteListMerkleRoot_) internal {
21+
_whiteListMerkleRoot = whiteListMerkleRoot_;
2222
}
2323

24-
function _leaf(
25-
address account,
26-
string memory allowance
27-
) internal pure returns (bytes32) {
28-
return keccak256(abi.encode(account, allowance));
29-
}
24+
function _leaf(address account, string memory allowance) internal pure returns (bytes32) {
25+
return keccak256(abi.encode(account, allowance));
26+
}
3027

31-
function _validateWhitelistMerkleProof(
32-
uint256 allowance,
33-
bytes32[] calldata proof
34-
) internal view returns (bool) {
35-
bytes32 leaf = _leaf(_msgSender(), Strings.toString(allowance));
36-
return MerkleProof.verify(proof, _whitelistMerkleRoot, leaf);
37-
}
28+
function _validateWhitelistMerkleProof(uint256 allowance, bytes32[] calldata proof) internal view returns (bool) {
29+
bytes32 leaf = _leaf(_msgSender(), Strings.toString(allowance));
30+
return MerkleProof.verify(proof, _whiteListMerkleRoot, leaf);
31+
}
3832

39-
function _verify(
40-
bytes32 leaf,
41-
bytes32[] memory proof
42-
) internal view returns (bool) {
43-
require(_whitelistMerkleRoot != 0, "Whitelist merkle root not set");
44-
return MerkleProof.verify(proof, _whitelistMerkleRoot, leaf);
33+
function _verify(bytes32 leaf, bytes32[] memory proof) internal view returns (bool) {
34+
require(_whiteListMerkleRoot != 0, "Whitelist merkle root not set");
35+
return MerkleProof.verify(proof, _whiteListMerkleRoot, leaf);
4536
}
4637

47-
function getAllowance(
48-
string memory allowance,
49-
bytes32[] calldata proof
50-
) public view returns (string memory) {
51-
require(
52-
_verify(_leaf(msg.sender, allowance), proof),
53-
"Invalid Merkle Tree proof supplied."
54-
);
38+
function getAllowance(string memory allowance, bytes32[] calldata proof) public view returns (string memory) {
39+
require(_verify(_leaf(msg.sender, allowance), proof), "Invalid Merkle Tree proof supplied.");
5540
return allowance;
5641
}
5742

58-
5943
function _disableWhitelistMerkleRoot() internal {
60-
delete _whitelistMerkleRoot;
44+
delete _whiteListMerkleRoot;
6145
}
6246
}

foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828
gas_reports = ["*"]
2929
fuzz = { runs = 1_000 }
3030
auto_detect_solc = false
31-
extra_output_files = [ "metadata" ]
31+
extra_output_files = [ "metadata" ]
32+
viaIR = true

hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const config: HardhatUserConfig = {
77
solidity: {
88
version: "0.8.24",
99
settings: {
10+
viaIR: true,
1011
optimizer: {
1112
enabled: true,
1213
runs: 10_000,
@@ -18,7 +19,6 @@ const config: HardhatUserConfig = {
1819
btp: {
1920
url: process.env.BTP_RPC_URL || "",
2021
gasPrice: process.env.BTP_GAS_PRICE ? parseInt(process.env.BTP_GAS_PRICE) : "auto",
21-
timeout: 100_000,
2222
},
2323
},
2424
etherscan: {

test/ExampleERC721a.t.sol

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,14 @@ contract ExampleERC721Test is Test {
1212
address proxyRegistryAddress = address(0);
1313
address payable wallet = payable(address(3));
1414

15-
string baseURLPlaceholder =
16-
"ipfs://bafybeifc23vyo52i6dtlba7u7kmbcpc5oxfcwjaz3oisagq3kq7i2dbo6q/";
17-
string baseTokenURI =
18-
"ipfs://bafybeifc23vyo52i6dtlba7u7kmbcpc5oxfcwjaz3oisagq3kq7i2dbo6q/1.json";
19-
string baseURLRevealed =
20-
"ipfs://bafybeihxsckb6gl6yzyn4sjwyspf2lldlhmxo7usqebkdvol2l6uehryei/";
21-
string revealedTokenURI =
22-
"ipfs://bafybeihxsckb6gl6yzyn4sjwyspf2lldlhmxo7usqebkdvol2l6uehryei/1.json";
15+
string baseURLPlaceholder = "ipfs://bafybeifc23vyo52i6dtlba7u7kmbcpc5oxfcwjaz3oisagq3kq7i2dbo6q/";
16+
string baseTokenURI = "ipfs://bafybeifc23vyo52i6dtlba7u7kmbcpc5oxfcwjaz3oisagq3kq7i2dbo6q/1.json";
17+
string baseURLRevealed = "ipfs://bafybeihxsckb6gl6yzyn4sjwyspf2lldlhmxo7usqebkdvol2l6uehryei/";
18+
string revealedTokenURI = "ipfs://bafybeihxsckb6gl6yzyn4sjwyspf2lldlhmxo7usqebkdvol2l6uehryei/1.json";
2319

2420
function setUp() public {
2521
vm.startPrank(owner);
26-
exampleERC721 = new ExampleERC721a(
27-
"Example Token",
28-
"EXT",
29-
baseURLPlaceholder,
30-
wallet
31-
);
22+
exampleERC721 = new ExampleERC721a("Example Token", "EXT", baseURLPlaceholder, wallet);
3223
vm.stopPrank();
3324
}
3425

@@ -52,39 +43,24 @@ contract ExampleERC721Test is Test {
5243
address[] memory giftedAddress = new address[](1);
5344
giftedAddress[0] = 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65;
5445
exampleERC721.gift(giftedAddress);
55-
assertEq(
56-
exampleERC721.balanceOf(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65),
57-
1
58-
);
46+
assertEq(exampleERC721.balanceOf(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65), 1);
5947
}
6048

6149
function testWhitelistMint() public {
6250
vm.prank(owner);
6351
exampleERC721.collectReserves();
6452

6553
vm.prank(owner);
66-
exampleERC721.setWhitelistMerkleRoot(
67-
0xab0ad1fd11f066c49fc6a47ba91cb9e6acf73026b82a0907c282efbadefd10c2
68-
);
54+
exampleERC721.setWhitelistMerkleRoot(0xab0ad1fd11f066c49fc6a47ba91cb9e6acf73026b82a0907c282efbadefd10c2);
6955
bytes32[] memory proofOne = new bytes32[](1);
70-
proofOne[
71-
0
72-
] = 0xe49914a3a1644dc92d0362120e4111d4373036cf861e3da9358d6fadafdb64cc;
56+
proofOne[0] = 0xe49914a3a1644dc92d0362120e4111d4373036cf861e3da9358d6fadafdb64cc;
7357
uint256 count = 2;
7458
uint256 allowance = 2;
75-
vm.deal(
76-
0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65,
77-
exampleERC721.PRICE_IN_WEI_WHITELIST() * count
78-
);
59+
vm.deal(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65, exampleERC721.PRICE_IN_WEI_WHITELIST() * count);
7960
vm.startPrank(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65);
80-
exampleERC721.whitelistMint{
81-
value: exampleERC721.PRICE_IN_WEI_WHITELIST() * count
82-
}(count, allowance, proofOne);
83-
84-
assertEq(
85-
exampleERC721.balanceOf(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65),
86-
count
87-
);
61+
exampleERC721.whitelistMint{ value: exampleERC721.PRICE_IN_WEI_WHITELIST() * count }(count, allowance, proofOne);
62+
63+
assertEq(exampleERC721.balanceOf(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65), count);
8864
vm.stopPrank();
8965
}
9066

@@ -93,19 +69,12 @@ contract ExampleERC721Test is Test {
9369
exampleERC721.collectReserves();
9470

9571
vm.prank(owner);
96-
exampleERC721.setWhitelistMerkleRoot(
97-
0xbc56477505b21fd7409dbc693cf9a006e29ec44e460308c25437bb647c3effb3
98-
);
72+
exampleERC721.setWhitelistMerkleRoot(0xbc56477505b21fd7409dbc693cf9a006e29ec44e460308c25437bb647c3effb3);
9973
bytes32[] memory invalidProof = new bytes32[](1); // Use an invalid proof here
100-
invalidProof[
101-
0
102-
] = 0xf2e82b3a90979175611bdde3e3ad666497bf331847d930e33a91a3602a44875b;
74+
invalidProof[0] = 0xf2e82b3a90979175611bdde3e3ad666497bf331847d930e33a91a3602a44875b;
10375
uint256 count = 1;
10476
uint256 allowance = 2;
105-
vm.deal(
106-
0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc,
107-
exampleERC721.PRICE_IN_WEI_WHITELIST() * count
108-
);
77+
vm.deal(0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc, exampleERC721.PRICE_IN_WEI_WHITELIST() * count);
10978
vm.expectRevert("Invalid Merkle Tree proof supplied");
11079
vm.prank(0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc);
11180
exampleERC721.whitelistMint(count, allowance, invalidProof);
@@ -119,7 +88,7 @@ contract ExampleERC721Test is Test {
11988
address buyer = address(1);
12089
vm.deal(buyer, exampleERC721.PRICE_IN_WEI_PUBLIC());
12190
vm.startPrank(buyer);
122-
exampleERC721.publicMint{value: exampleERC721.PRICE_IN_WEI_PUBLIC()}(1);
91+
exampleERC721.publicMint{ value: exampleERC721.PRICE_IN_WEI_PUBLIC() }(1);
12392
assertEq(exampleERC721.balanceOf(buyer), 1);
12493
vm.stopPrank();
12594
}
@@ -132,7 +101,7 @@ contract ExampleERC721Test is Test {
132101
address buyer = address(1);
133102
vm.deal(buyer, exampleERC721.PRICE_IN_WEI_PUBLIC());
134103
vm.startPrank(buyer);
135-
exampleERC721.publicMint{value: exampleERC721.PRICE_IN_WEI_PUBLIC()}(1);
104+
exampleERC721.publicMint{ value: exampleERC721.PRICE_IN_WEI_PUBLIC() }(1);
136105
assertEq(exampleERC721.tokenURI(1), baseTokenURI);
137106
assertEq(exampleERC721.balanceOf(buyer), 1);
138107
vm.stopPrank();

0 commit comments

Comments
 (0)