Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ exclude_lints = [
"asm-keccak256", # EIP-712 hashing
"erc20-unchecked-transfer", # Warning on ERC-721 transferFrom
"unused-import" # BuilderCodesTest imports for purpose of dependent tests
]
]

[fmt]
sort_imports = true
wrap_comments = true
single_line_statement_blocks = "single"
10 changes: 5 additions & 5 deletions src/BuilderCodes.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {Initializable} from "openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol";
import {ERC721Upgradeable, IERC721} from "openzeppelin-contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import {AccessControlUpgradeable} from "openzeppelin-contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {Ownable2StepUpgradeable} from "openzeppelin-contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {Initializable} from "openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "openzeppelin-contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {IERC4906} from "openzeppelin-contracts/interfaces/IERC4906.sol";
import {ERC721Upgradeable, IERC721} from "openzeppelin-contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import {IERC165} from "openzeppelin-contracts/interfaces/IERC165.sol";
import {LibString} from "solady/utils/LibString.sol";
import {LibBit} from "solady/utils/LibBit.sol";
import {IERC4906} from "openzeppelin-contracts/interfaces/IERC4906.sol";
import {EIP712} from "solady/utils/EIP712.sol";
import {LibBit} from "solady/utils/LibBit.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SignatureCheckerLib} from "solady/utils/SignatureCheckerLib.sol";

/// @notice Registry for builder codes
Expand Down
5 changes: 3 additions & 2 deletions test/integration/BuilderCodesAdminOperations.t.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../lib/BuilderCodesTest.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

import {BuilderCodesTest} from "../lib/BuilderCodesTest.sol";

/// @notice Integration tests for BuilderCodes operations
contract BuilderCodesAdminOperationsTest is BuilderCodesTest {
Expand Down
4 changes: 2 additions & 2 deletions test/lib/BuilderCodesTest.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {Test} from "forge-std/Test.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {IERC721Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Test} from "forge-std/Test.sol";

import {BuilderCodes} from "../../src/BuilderCodes.sol";

Expand Down
4 changes: 1 addition & 3 deletions test/lib/mocks/MockAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ contract MockAccount is IERC1271 {
override
returns (bytes4 magicValue)
{
if (SignatureCheckerLib.isValidSignatureNow(owner, hash, signature)) {
return MAGICVALUE;
}
if (SignatureCheckerLib.isValidSignatureNow(owner, hash, signature)) return MAGICVALUE;
return bytes4(0);
}
}
1 change: 1 addition & 0 deletions test/unit/BuilderCodes/constructor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.29;

import {Test} from "forge-std/Test.sol";

import {BuilderCodes, Initializable} from "../../../src/BuilderCodes.sol";

/// @notice Unit tests for BuilderCodes constructor
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/contractURI.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.contractURI
contract ContractURITest is BuilderCodesTest {
Expand Down
7 changes: 2 additions & 5 deletions test/unit/BuilderCodes/initialize.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ contract InitializeTest is BuilderCodesTest {

// Verify URI prefix by checking contractURI format
string memory contractURI = freshContract.contractURI();
if (bytes(uriPrefix).length > 0) {
assertEq(contractURI, string.concat(uriPrefix, "contractURI.json"));
} else {
assertEq(contractURI, "");
}
if (bytes(uriPrefix).length > 0) assertEq(contractURI, string.concat(uriPrefix, "contractURI.json"));
else assertEq(contractURI, "");
}
}
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/isRegistered.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.isRegistered
contract IsRegisteredTest is BuilderCodesTest {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/payoutAddress.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.payoutAddress (both overloads)
contract PayoutAddressTest is BuilderCodesTest {
Expand Down
15 changes: 10 additions & 5 deletions test/unit/BuilderCodes/safeTransferFrom.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.safeTransferFrom
contract SafeTransferFromTest is BuilderCodesTest {
/// @notice Test that safeTransferFrom(from, to, tokenId) reverts when the token owner doesn't have the transfer role
/// @notice Test that safeTransferFrom(from, to, tokenId) reverts when the token owner doesn't have the transfer
/// role
///
/// @param from The from address
/// @param to The to address
Expand Down Expand Up @@ -45,7 +46,8 @@ contract SafeTransferFromTest is BuilderCodesTest {
assertEq(builderCodes.balanceOf(to), 0);
}

/// @notice Test that safeTransferFrom(from, to, tokenId) reverts when the approved address doesn't have the transfer role
/// @notice Test that safeTransferFrom(from, to, tokenId) reverts when the approved address doesn't have the
/// transfer role
///
/// @param from The from address
/// @param to The to address
Expand Down Expand Up @@ -87,7 +89,8 @@ contract SafeTransferFromTest is BuilderCodesTest {
assertEq(builderCodes.balanceOf(to), 0);
}

/// @notice Test that safeTransferFrom(from, to, tokenId, data) reverts when the token owner doesn't have the transfer role
/// @notice Test that safeTransferFrom(from, to, tokenId, data) reverts when the token owner doesn't have the
/// transfer role
///
/// @param from The from address
/// @param to The to address
Expand Down Expand Up @@ -127,7 +130,8 @@ contract SafeTransferFromTest is BuilderCodesTest {
assertEq(builderCodes.balanceOf(to), 0);
}

/// @notice Test that safeTransferFrom(from, to, tokenId, data) reverts when the approved address doesn't have the transfer role
/// @notice Test that safeTransferFrom(from, to, tokenId, data) reverts when the approved address doesn't have the
/// transfer role
///
/// @param from The from address
/// @param to The to address
Expand Down Expand Up @@ -292,7 +296,8 @@ contract SafeTransferFromTest is BuilderCodesTest {
assertEq(builderCodes.balanceOf(to), 1);
}

/// @notice Test that safeTransferFrom(from, to, tokenId, data) succeeds when the approved address has the transfer role
/// @notice Test that safeTransferFrom(from, to, tokenId, data) succeeds when the approved address has the transfer
/// role
///
/// @param from The from address
/// @param to The to address
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/toCode.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.toCode
contract ToCodeTest is BuilderCodesTest {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/toTokenId.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.toTokenId
contract ToTokenIdTest is BuilderCodesTest {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/tokenURI.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest, IERC721Errors} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest, IERC721Errors} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.tokenURI
contract TokenURITest is BuilderCodesTest {
Expand Down
21 changes: 6 additions & 15 deletions test/unit/BuilderCodes/updateBaseURI.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ contract UpdateBaseURITest is BuilderCodesTest {
builderCodes.updateBaseURI(uriPrefix);

string memory tokenURI = builderCodes.tokenURI(tokenId);
if (bytes(uriPrefix).length > 0) {
assertEq(tokenURI, string.concat(uriPrefix, validCode));
} else {
assertEq(tokenURI, "");
}
if (bytes(uriPrefix).length > 0) assertEq(tokenURI, string.concat(uriPrefix, validCode));
else assertEq(tokenURI, "");
}

/// @notice Test that updateBaseURI successfully updates the code URI
Expand All @@ -75,11 +72,8 @@ contract UpdateBaseURITest is BuilderCodesTest {
builderCodes.updateBaseURI(uriPrefix);

string memory codeURI = builderCodes.codeURI(validCode);
if (bytes(uriPrefix).length > 0) {
assertEq(codeURI, string.concat(uriPrefix, validCode));
} else {
assertEq(codeURI, "");
}
if (bytes(uriPrefix).length > 0) assertEq(codeURI, string.concat(uriPrefix, validCode));
else assertEq(codeURI, "");
}

/// @notice Test that updateBaseURI successfully updates the contract URI
Expand All @@ -90,11 +84,8 @@ contract UpdateBaseURITest is BuilderCodesTest {
builderCodes.updateBaseURI(uriPrefix);

string memory contractURI = builderCodes.contractURI();
if (bytes(uriPrefix).length > 0) {
assertEq(contractURI, string.concat(uriPrefix, "contractURI.json"));
} else {
assertEq(contractURI, "");
}
if (bytes(uriPrefix).length > 0) assertEq(contractURI, string.concat(uriPrefix, "contractURI.json"));
else assertEq(contractURI, "");
}

/// @notice Test that updateBaseURI emits the ERC4906 BatchMetadataUpdate event
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BuilderCodes/updatePayoutAddress.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest, IERC721Errors} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest, IERC721Errors} from "../../lib/BuilderCodesTest.sol";

/// @notice Unit tests for BuilderCodes.updatePayoutAddress
contract UpdatePayoutAddressTest is BuilderCodesTest {
Expand Down
7 changes: 4 additions & 3 deletions test/unit/BuilderCodes/upgradeToAndCall.t.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {IERC1967} from "@openzeppelin/contracts/interfaces/IERC1967.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC1967} from "@openzeppelin/contracts/interfaces/IERC1967.sol";

import {BuilderCodes} from "../../../src/BuilderCodes.sol";
import {BuilderCodesTest} from "../../lib/BuilderCodesTest.sol";
import {MockBuilderCodesV2} from "../../lib/mocks/MockBuilderCodesV2.sol";

/// @notice Unit tests for BuilderCodes.upgradeToAndCall
Expand Down