Skip to content

Commit

Permalink
First minter is now account that brings token on chain (#214)
Browse files Browse the repository at this point in the history
* Premint

* Add back mint fee getter (#198)

* add back mint fee getter

* add mint fee to interface

* * Updated script to deploy preminter to now deploy the proxy (#189)

* Extracted common deployment tasks to reusable helper functions
* Added script to upgrade preminter

* Premint - move premint state to its own contract (#188)

Renamed Premint folder to delegated mint

* fix: redeem minter tests

* fix: token transfer hook for single token transfers

* feat: add unit tests

* Seperate upgrade gate new contract (#204)

* wip

* wip

* fix tests

* chore: run lint & update natspec

* update storage layout

---------

Co-authored-by: Rohan Kulkarni <[email protected]>

* refactor: add helper to read uups implementation

* fix: param name casing

* refactor: use updated zora 1155 impl getter

* refactor: add helper to read uups implementation

* fix: zora 1155 impl var name

* chore: run lint

* chore: run lint

* refactor: implement first minter reward on adminMint

* chore: update runs

* refactor: remove mint fee amount deploy param

* chore: run lint

* chore: run lint

* chore: remove mint fee amount from chain configs

* chore: update fork test

* fix: use mint w rewards to gurantee mint fee amount

* Premint: updated documentation (#199)

Premint - update documentation

* move upgrade gate to initializer pattern (#209)

* move upgrade gate to initalizer pattern

* formatting

* refactor: only mint if specified quantity is greater than 0 (#212)

* refactor: only mint if specified quantity is greater than 0

* fix tests

---------

Co-authored-by: Dan Oved <[email protected]>

* Premint - factory proxy 777 deployments (#191)

* Can mine for a determinstic address for the proxy shim in a script, and have a test that shows we can determinstically deploy proxy to that address with that salt and deployer account

* wip on deploy via script. nneed to create web ui

* cleanup

* update test to work with new params :)

* deployment works now!. lets genericize stuff :)

* consolidated into one

* end to end scripting works :)

* renamed and refactored to be more usable

* Determinstic deployer scripts are more generic and can deploy and verify :)

* rename

* another rename :)

* Premint proxy deploy (#211)

* made premint executor ugparde scripts.  renamed executor to proxy

* deploy preminter impl with script, and updated the config for that chain

* Have premint proxy deploy scripts.  can deploy both now

* preminter proxy pushed

* Refactor deterministic add upgrade gate (#210)

* large refactor

* update scripts

* updates to test code

* test naming updates

* compiler run correctly

* update with new deterministic configs

* make node deps only for scripts

* Premint deploy determinstic fix tests (#213)

* fixed tests by just making it more dyanmic

* fix stack too deep error for coverage

* ignore deployment folder for coverage

* properly filter out deployment

---------

Co-authored-by: Iain Nash <[email protected]>

* update deps

* add back release command

* fix version publish

* fix contract version

* move wagmi cli to proper version

* more things in dev deps

* move all into deps

* update protocol rewards package (#226)

* fix build

* fix wagmi build

* make first minter on-chain gas sponsor

* fix tests

* prettier

* add changeset

* update changeset

* fix build

* first minter test fixes

---------

Co-authored-by: Dan Oved <[email protected]>
Co-authored-by: Rohan Kulkarni <[email protected]>
Co-authored-by: Rohan Kulkarni <[email protected]>
Co-authored-by: Isabella Smallcombe <[email protected]>
  • Loading branch information
5 people authored Sep 29, 2023
1 parent 11648bf commit b83e1b6
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 121 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-plants-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/zora-1155-contracts": patch
---

Add first minter payouts as chain sponsor
15 changes: 2 additions & 13 deletions .github/workflows/changesets-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@ jobs:
if: steps.check_pre.outputs.files_exists != 'true'
run: echo "pre.json does not exist, enter prerelease mode with 'yarn changeset pre enter {prereleaseName}'"; exit 1

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"

- name: Install project dependencies
run: yarn

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install node deps and founry
uses: ./.github/actions/setup_deps

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,8 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"

- name: Install project dependencies
run: yarn

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install node deps and founry
uses: ./.github/actions/setup_deps

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,8 @@ jobs:
with:
submodules: recursive

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"

- name: Install project dependencies
run: yarn

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install node deps and founry
uses: ./.github/actions/setup_deps

- name: Run Forge coverage
run: yarn run coverage
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"

- name: Install project dependencies
run: yarn
- name: Install node deps and founry
uses: ./.github/actions/setup_deps

- name: Run prettier
run: yarn run prettier:check
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ via_ir = true

[profile.fast_compilation]
optimizer_runs = 50
via_ir = false
solc_version = '0.8.17'

[rpc_endpoints]
Expand Down
2 changes: 1 addition & 1 deletion package/batchPublish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe("ZoraCreator1155Preminter", () => {
[collectorAccount]
);

const zoraMintFee = parseEther("0.0007777");
const zoraMintFee = parseEther("0.000777");

const valueToSend =
(BigInt(zoraMintFee) + createToken3Params.price) * quantityToMint;
Expand Down
2 changes: 1 addition & 1 deletion src/delegation/ZoraCreator1155PremintExecutorImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract ZoraCreator1155PremintExecutorImpl is Ownable2StepUpgradeable, UUPSUpgr
// pass the signature and the premint config to the token contract to create the token.
// The token contract will verify the signature and that the signer has permission to create a new token.
// and then create and setup the token using the given token config.
newTokenId = tokenContract.delegateSetupNewToken(premintConfig, signature);
newTokenId = tokenContract.delegateSetupNewToken(premintConfig, signature, msg.sender);

// if the executor would also like to mint:
if (quantityToMint != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IZoraCreator1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ interface IZoraCreator1155 is IZoraCreator1155TypesV1, IZoraCreator1155Errors, I
/// @param maxSupply maxSupply for the token, set to 0 for open edition
function setupNewToken(string memory tokenURI, uint256 maxSupply) external returns (uint256 tokenId);

function delegateSetupNewToken(PremintConfig calldata premintConfig, bytes calldata signature) external returns (uint256 newTokenId);
function delegateSetupNewToken(PremintConfig calldata premintConfig, bytes calldata signature, address sender) external returns (uint256 newTokenId);

function updateTokenURI(uint256 tokenId, string memory _newURI) external;

Expand Down
42 changes: 9 additions & 33 deletions src/nft/ZoraCreator1155Impl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,6 @@ contract ZoraCreator1155Impl is
uint256 quantity,
bytes memory data
) external nonReentrant onlyAdminOrRole(tokenId, PERMISSION_BIT_MINTER) {
// If this is the token's first mint:
if (firstMinters[tokenId] == address(0)) {
// Store the recipient address as the first minter
// Note: If the recipient is address(0) the tx will revert in the `_mint` call below
firstMinters[tokenId] = recipient;
}

// Mint the specified tokens
_mint(recipient, tokenId, quantity, data);
}
Expand Down Expand Up @@ -407,17 +400,14 @@ contract ZoraCreator1155Impl is
// Require admin from the minter to mint
_requireAdminOrRole(address(minter), tokenId, PERMISSION_BIT_MINTER);

// Get the token's first minter
address firstMinter = _handleFirstMinter(tokenId, minterArguments);

// Get value sent and handle mint fee
uint256 ethValueSent = _handleRewardsAndGetValueSent(
msg.value,
quantity,
getCreatorRewardRecipient(),
createReferrals[tokenId],
address(0),
firstMinter
firstMinters[tokenId]
);

// Execute commands returned from minter
Expand All @@ -442,17 +432,14 @@ contract ZoraCreator1155Impl is
// Require admin from the minter to mint
_requireAdminOrRole(address(minter), tokenId, PERMISSION_BIT_MINTER);

// Get the token's first minter
address firstMinter = _handleFirstMinter(tokenId, minterArguments);

// Get value sent and handle mint rewards
uint256 ethValueSent = _handleRewardsAndGetValueSent(
msg.value,
quantity,
getCreatorRewardRecipient(),
createReferrals[tokenId],
mintReferral,
firstMinter
firstMinters[tokenId]
);

// Execute commands returned from minter
Expand All @@ -461,23 +448,6 @@ contract ZoraCreator1155Impl is
emit Purchased(msg.sender, address(minter), tokenId, quantity, msg.value);
}

/// @dev Get and/or set the first minter a token
function _handleFirstMinter(uint256 tokenId, bytes calldata data) internal returns (address) {
// If this is the first mint for the token:
if (firstMinters[tokenId] == address(0)) {
// Decode the address of the reward recipient
// Assume the first argument is an address
address rewardRecipient = abi.decode(data, (address));

// Store the address to lookup for future mints
firstMinters[tokenId] = rewardRecipient;

return rewardRecipient;
}

return firstMinters[tokenId];
}

function mintFee() external pure returns (uint256) {
return TOTAL_REWARD_PER_MINT;
}
Expand Down Expand Up @@ -792,7 +762,11 @@ contract ZoraCreator1155Impl is
/// The signature must be created by an account with the PERMISSION_BIT_MINTER role on the contract.
/// @param premintConfig configuration of token to be created
/// @param signature EIP-712 Signature created on the premintConfig by an account with the PERMISSION_BIT_MINTER role on the contract.
function delegateSetupNewToken(PremintConfig calldata premintConfig, bytes calldata signature) public nonReentrant returns (uint256 newTokenId) {
function delegateSetupNewToken(
PremintConfig calldata premintConfig,
bytes calldata signature,
address sender
) public nonReentrant returns (uint256 newTokenId) {
// if a token has already been created for a premint config with this uid:
if (delegatedTokenId[premintConfig.uid] != 0) {
// return its token id
Expand All @@ -817,6 +791,8 @@ contract ZoraCreator1155Impl is

delegatedTokenId[premintConfig.uid] = newTokenId;

firstMinters[newTokenId] = sender;

// invoke setup actions for new token, to save contract size, first get them from an external lib
bytes[] memory tokenSetupActions = PremintTokenSetup.makeSetupNewTokenCalls(newTokenId, creator, premintConfig.tokenConfig);

Expand Down
Loading

0 comments on commit b83e1b6

Please sign in to comment.