Skip to content

Commit

Permalink
[chore] renaming functions and contracts (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonzwli authored Aug 22, 2023
1 parent 9d6d595 commit 22b4cc2
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 96 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ git checkout -b <your-branch-name>
npm test
```

7. Add and commit your changes, including a comprehensive commit message summarising your changes, then push changes to your fork. (e.g. Fixed formatting issue with ImmutableERC721PermissionedMintable.sol)
7. Add and commit your changes, including a comprehensive commit message summarising your changes, then push changes to your fork. (e.g. Fixed formatting issue with ImmutableERC721Simple.sol)

```
git add *
Expand Down
16 changes: 8 additions & 8 deletions contracts/token/erc721/abstract/ERC721Hybrid.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
ERC721Psi._safeMint(to, quantity);
}

function _batchMintByQuantity(Mint[] memory mints) internal {
function _mintBatchByQuantity(Mint[] memory mints) internal {
for (uint i = 0; i < mints.length; i++) {
Mint memory m = mints[i];
_mintByQuantity(m.to, m.quantity);
}
}

function _batchSafeMintByQuantity(Mint[] memory mints) internal {
function _safeMintBatchByQuantity(Mint[] memory mints) internal {
for (uint i = 0; i < mints.length; i++) {
Mint memory m = mints[i];
_safeMintByQuantity(m.to, m.quantity);
Expand Down Expand Up @@ -98,13 +98,13 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
_idMintTotalSupply++;
}

function _batchMintByID(address to, uint256[] memory tokenIds) internal {
function _mintBatchByID(address to, uint256[] memory tokenIds) internal {
for (uint i = 0; i < tokenIds.length; i++) {
_mintByID(to, tokenIds[i]);
}
}

function _batchSafeMintByID(address to, uint256[] memory tokenIds) internal {
function _safeMintBatchByID(address to, uint256[] memory tokenIds) internal {
for (uint i = 0; i < tokenIds.length; i++) {
_safeMintByID(to, tokenIds[i]);
}
Expand All @@ -115,17 +115,17 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err
uint256[] tokenIds;
}

function _batchMintByIDToMultiple(IDMint[] memory mints) internal {
function _mintBatchByIDToMultiple(IDMint[] memory mints) internal {
for (uint i = 0; i < mints.length; i++) {
IDMint memory m = mints[i];
_batchMintByID(m.to, m.tokenIds);
_mintBatchByID(m.to, m.tokenIds);
}
}

function _batchSafeMintByIDToMultiple(IDMint[] memory mints) internal {
function _safeMintBatchByIDToMultiple(IDMint[] memory mints) internal {
for (uint i = 0; i < mints.length; i++) {
IDMint memory m = mints[i];
_batchSafeMintByID(m.to, m.tokenIds);
_safeMintBatchByID(m.to, m.tokenIds);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { MintingAccessControl } from "../abstract/MintingAccessControl.sol";
import { ImmutableERC721HybridBase } from "../abstract/ImmutableERC721HybridBase.sol";

contract ImmutableERC721HybridPermissionedMintable is ImmutableERC721HybridBase {
contract ImmutableERC721 is ImmutableERC721HybridBase {

constructor(
address owner_,
Expand All @@ -21,11 +21,11 @@ contract ImmutableERC721HybridPermissionedMintable is ImmutableERC721HybridBase
ImmutableERC721HybridBase(owner_, name_, symbol_, baseURI_, contractURI_, royaltyAllowlist_, royaltyReceiver_, feeNumerator_)
{}

function mintByID(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) {
function mint(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) {
_mintByID(to, tokenId);
}

function safeMintByID(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) {
function safeMint(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) {
_safeMintByID(to, tokenId);
}

Expand All @@ -37,20 +37,20 @@ contract ImmutableERC721HybridPermissionedMintable is ImmutableERC721HybridBase
_safeMintByQuantity(to, quantity);
}

function batchMintByQuantity(Mint[] memory mints) external onlyRole(MINTER_ROLE) {
_batchMintByQuantity(mints);
function mintBatchByQuantity(Mint[] memory mints) external onlyRole(MINTER_ROLE) {
_mintBatchByQuantity(mints);
}

function batchSafeMintByQuantity(Mint[] memory mints) external onlyRole(MINTER_ROLE) {
_batchSafeMintByQuantity(mints);
function safeMintBatchByQuantity(Mint[] memory mints) external onlyRole(MINTER_ROLE) {
_safeMintBatchByQuantity(mints);
}

function batchMintByIDToMultiple(IDMint[] memory mints) external onlyRole(MINTER_ROLE) {
_batchMintByIDToMultiple(mints);
function mintBatch(IDMint[] memory mints) external onlyRole(MINTER_ROLE) {
_mintBatchByIDToMultiple(mints);
}

function batchSafeMintByIDToMultiple(IDMint[] memory mints) external onlyRole(MINTER_ROLE) {
_batchSafeMintByIDToMultiple(mints);
function safeMintBatch(IDMint[] memory mints) external onlyRole(MINTER_ROLE) {
_safeMintBatchByIDToMultiple(mints);
}

function safeTransferFromBatch(TransferRequest calldata tr) external {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../abstract/ImmutableERC721Base.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";

contract ImmutableERC721PermissionedMintable is ImmutableERC721Base {
contract ImmutableERC721Simple is ImmutableERC721Base {
/// ===== Constructor =====

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import { ethers } from "hardhat";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import {
ImmutableERC721PermissionedMintable,
ImmutableERC721Simple,
MockMarketplace,
MockFactory,
RoyaltyAllowlist,
Expand All @@ -19,7 +19,7 @@ import {
describe("Allowlisted ERC721 Transfers", function () {
this.timeout(300_000); // 5 min

let erc721: ImmutableERC721PermissionedMintable;
let erc721: ImmutableERC721Simple;
let walletFactory: MockWalletFactory;
let factory: MockFactory;
let royaltyAllowlist: RoyaltyAllowlist;
Expand Down Expand Up @@ -58,9 +58,7 @@ describe("Allowlisted ERC721 Transfers", function () {

it("Should not allow contracts that do not implement the IRoyaltyAllowlist to be set", async function () {
// Deploy another contract that implements IERC165, but not IRoyaltyAllowlist
const factory = await ethers.getContractFactory(
"ImmutableERC721PermissionedMintable"
);
const factory = await ethers.getContractFactory("ImmutableERC721Simple");
const erc721Two = await factory.deploy(
owner.address,
"",
Expand Down
20 changes: 9 additions & 11 deletions test/royalty-enforcement/HybridApproval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import { ethers } from "hardhat";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import {
ImmutableERC721HybridPermissionedMintable,
ImmutableERC721,
MockMarketplace,
MockFactory,
RoyaltyAllowlist,
Expand All @@ -17,7 +17,7 @@ import {
} from "../utils/DeployHybridFixtures";

describe("Royalty Checks with Hybrid ERC721", function () {
let erc721: ImmutableERC721HybridPermissionedMintable;
let erc721: ImmutableERC721;
let walletFactory: MockWalletFactory;
let factory: MockFactory;
let royaltyAllowlist: RoyaltyAllowlist;
Expand Down Expand Up @@ -56,9 +56,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {

it("Should not allow contracts that do not implement the IRoyaltyAllowlist to be set", async function () {
// Deploy another contract that implements IERC165, but not IRoyaltyAllowlist
const factory = await ethers.getContractFactory(
"ImmutableERC721HybridPermissionedMintable"
);
const factory = await ethers.getContractFactory("ImmutableERC721");
const erc721Two = await factory.deploy(
owner.address,
"",
Expand Down Expand Up @@ -206,7 +204,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
});

it("Should block transfers to a not allow listed address", async function () {
await erc721.connect(minter).mintByID(minter.address, 1);
await erc721.connect(minter).mint(minter.address, 1);
await expect(
erc721
.connect(minter)
Expand All @@ -220,7 +218,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
await royaltyAllowlist
.connect(registrar)
.addAddressToAllowlist([marketPlace.address]);
await erc721.connect(minter).mintByID(minter.address, 4);
await erc721.connect(minter).mint(minter.address, 4);
await erc721.connect(minter).setApprovalForAll(marketPlace.address, true);
expect(await erc721.balanceOf(accs[3].address)).to.be.equal(0);
await marketPlace.connect(minter).executeTransfer(accs[3].address, 4);
Expand Down Expand Up @@ -250,8 +248,8 @@ describe("Royalty Checks with Hybrid ERC721", function () {
saltThree
);
// Mint NFTs to the wallets
await erc721.connect(minter).mintByID(deployedAddr, 10);
await erc721.connect(minter).mintByID(deployedAddrTwo, 11);
await erc721.connect(minter).mint(deployedAddr, 10);
await erc721.connect(minter).mint(deployedAddrTwo, 11);

// Connect to wallets
const wallet = await ethers.getContractAt("MockWallet", deployedAddr);
Expand Down Expand Up @@ -315,7 +313,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
const { deployedAddr, salt, constructorByteCode } =
await disguidedEOAFixture(erc721.address, factory, "0x1234");
// Approve disguised EOA
await erc721.connect(minter).mintByID(minter.address, 1);
await erc721.connect(minter).mint(minter.address, 1);
await erc721.connect(minter).setApprovalForAll(deployedAddr, true);
// Deploy disguised EOA
await factory.connect(accs[5]).deploy(salt, constructorByteCode);
Expand Down Expand Up @@ -350,7 +348,7 @@ describe("Royalty Checks with Hybrid ERC721", function () {
accs[6].address
);
// Mint and transfer to receiver contract
await erc721.connect(minter).mintByID(minter.address, 1);
await erc721.connect(minter).mint(minter.address, 1);
// Fails as transfer 'to' is now allowlisted
await expect(
erc721
Expand Down
4 changes: 2 additions & 2 deletions test/royalty-enforcement/RoyaltyAllowlist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RegularAllowlistFixture,
} from "../utils/DeployRegularFixtures";
import {
ImmutableERC721PermissionedMintable,
ImmutableERC721Simple,
MockMarketplace,
RoyaltyAllowlist,
MockWalletFactory,
Expand All @@ -19,7 +19,7 @@ describe("Royalty Enforcement Test Cases", function () {
let owner: SignerWithAddress;
let registrar: SignerWithAddress;
let scWallet: SignerWithAddress;
let erc721: ImmutableERC721PermissionedMintable;
let erc721: ImmutableERC721Simple;
let walletFactory: MockWalletFactory;
let royaltyAllowlist: RoyaltyAllowlist;
let marketPlace: MockMarketplace;
Expand Down
10 changes: 5 additions & 5 deletions test/royalty-enforcement/RoyaltyMarketplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect } from "chai";
import { ethers } from "hardhat";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import {
ImmutableERC721PermissionedMintable__factory,
ImmutableERC721PermissionedMintable,
ImmutableERC721Simple__factory,
ImmutableERC721Simple,
RoyaltyAllowlist,
RoyaltyAllowlist__factory,
MockMarketplace__factory,
Expand All @@ -13,7 +13,7 @@ import {
describe("Marketplace Royalty Enforcement", function () {
this.timeout(300_000); // 5 min

let erc721: ImmutableERC721PermissionedMintable;
let erc721: ImmutableERC721Simple;
let royaltyAllowlist: RoyaltyAllowlist;
let mockMarketplace: MockMarketplace;
let owner: SignerWithAddress;
Expand Down Expand Up @@ -41,8 +41,8 @@ describe("Marketplace Royalty Enforcement", function () {

// Deploy ERC721 contract
const erc721PresetFactory = (await ethers.getContractFactory(
"ImmutableERC721PermissionedMintable"
)) as ImmutableERC721PermissionedMintable__factory;
"ImmutableERC721Simple"
)) as ImmutableERC721Simple__factory;

erc721 = await erc721PresetFactory.deploy(
owner.address,
Expand Down
Loading

0 comments on commit 22b4cc2

Please sign in to comment.