Skip to content

Commit

Permalink
Mints Manager url update (#353)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description

* Updates the mints manager `setMetadataURIs` with the ability to notify for each token id a url update on the mints 1155 contract
* Adds a test that verifiers the desired metadata uris
* updates the deployment scripts to set the correct metadata uris

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Does this change the ABI/API?

- [ ] This changes the ABI/API

<!-- If so, please describe how and what potential impact this may have -->

## What tests did you add/modify to account for these changes

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New module / feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] i added a changeset to account for this change

## Reviewer Checklist:

- [ ] My review includes a symposis of the changes and potential issues
- [ ] The code style is enforced
- [ ] There are no risky / concerning changes / additions to the PR
  • Loading branch information
oveddan authored Apr 12, 2024
1 parent 5888fd2 commit b6fc3a4
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-chefs-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/protocol-deployments": patch
---

Deployed latest ZoraMintsManagerImpl to zora and zora-sepolia
5 changes: 5 additions & 0 deletions .changeset/shiny-ways-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/mints-contracts": patch
---

When updating token uris in the mints manager, it notifies the zors mints 1155 to emit an event for all token ids that were updated
34 changes: 32 additions & 2 deletions packages/1155-deployments/test/UpgradesTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ interface UUPSUpgradeable {
function upgradeToAndCall(address newImplementation, bytes memory data) external payable;
}

interface IOwnable2StepUpgradeable {
function owner() external view returns (address);
function pendingOwner() external view returns (address);
function acceptOwnership() external;
}

contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
using stdJson for string;

Expand Down Expand Up @@ -110,6 +116,29 @@ contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {
return tryReadMintsImpl() != address(0);
}

function determineMintsOwnershipNeeded() private view returns (UpgradeStatus memory) {
IOwnable2StepUpgradeable mintsManagerProxy = IOwnable2StepUpgradeable(getDeterminsticMintsManagerAddress());

if (address(mintsManagerProxy).code.length == 0) {
return UpgradeStatus("Accept Mints Ownership", false, address(0), address(0), "");
}

ChainConfig memory chainConfig = getChainConfig();

bool upgradeNeeded = chainConfig.factoryOwner != mintsManagerProxy.owner();

bytes memory upgradeCalldata;

if (upgradeNeeded) {
if (mintsManagerProxy.pendingOwner() != chainConfig.factoryOwner) {
revert("Mints pending owner is not the expected owner");
}
upgradeCalldata = abi.encodeWithSelector(IOwnable2StepUpgradeable.acceptOwnership.selector);
}

return UpgradeStatus("Accept Mints Ownership", upgradeNeeded, address(mintsManagerProxy), address(0), upgradeCalldata);
}

function determineMintsUpgrade() private view returns (UpgradeStatus memory) {
address mintsManagerProxy = getDeterminsticMintsManagerAddress();

Expand Down Expand Up @@ -333,10 +362,11 @@ contract UpgradesTest is ForkDeploymentConfig, DeploymentTestingUtils, Test {

ChainConfig memory chainConfig = getChainConfig();

UpgradeStatus[] memory upgradeStatuses = new UpgradeStatus[](3);
UpgradeStatus[] memory upgradeStatuses = new UpgradeStatus[](4);
upgradeStatuses[0] = determine1155Upgrade(deployment);
upgradeStatuses[1] = determinePreminterUpgrade(deployment);
upgradeStatuses[2] = determineMintsUpgrade();
upgradeStatuses[2] = determineMintsOwnershipNeeded();
upgradeStatuses[3] = determineMintsUpgrade();

bool upgradePerformed = performNeededUpgrades(chainConfig.factoryOwner, upgradeStatuses);

Expand Down
4 changes: 2 additions & 2 deletions packages/mints-deployments/addresses/7777777.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"MINTS_ETH_UNWRAPPER_AND_CALLER": "0xE9Db91DD126D81697B588F1C145d74283E5C8ccC",
"MINTS_MANAGER_IMPL": "0x212957295F3A40408E14531387915cDfB26A7DeB",
"MINTS_MANAGER_IMPL_VERSION": "0.1.0"
"MINTS_MANAGER_IMPL": "0x978685ad10B829F17e6c2C6E8EeABd7dFDdC1678",
"MINTS_MANAGER_IMPL_VERSION": "0.1.2"
}
4 changes: 2 additions & 2 deletions packages/mints-deployments/addresses/999999999.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"MINTS_ETH_UNWRAPPER_AND_CALLER": "0xE9Db91DD126D81697B588F1C145d74283E5C8ccC",
"MINTS_MANAGER_IMPL": "0x212957295F3A40408E14531387915cDfB26A7DeB",
"MINTS_MANAGER_IMPL_VERSION": "0.1.0"
"MINTS_MANAGER_IMPL": "0x978685ad10B829F17e6c2C6E8EeABd7dFDdC1678",
"MINTS_MANAGER_IMPL_VERSION": "0.1.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ const generateInitializationConfig = async ({
const initialEthTokenId = 1n;
const initialEthTokenPrice = parseEther("0.000777");

const metadataBaseURI = "https://zora.co/metadata/mints/";
const contractURI = "https://zora.co/metadata/mints/contract.json";
const metadataBaseURI = "https://zora.co/assets/mints/metadata/";
const contractURI = "https://zora.co/assets/mints/metadata/";

// this will initialize the mints contract with the owner, the initial token id, and the initial token price:
// and will be called when the proxy will be initially upgraded to the implementation:
Expand Down
7 changes: 6 additions & 1 deletion packages/mints/src/ZoraMintsManagerImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ contract ZoraMintsManagerImpl is
return "Zora Mints Manager";
}

function setMetadataURIs(string memory newContractURI, string memory newBaseURI) external onlyOwner {
function setMetadataURIs(string calldata newContractURI, string calldata newBaseURI, uint256[] calldata tokenIdsToNotifyUpdate) external onlyOwner {
_setMetadataURIs(newContractURI, newBaseURI);

// iterate through tokenIdsToNotifyUpdate and notify the mints contract of the updated URIs
for (uint256 i = 0; i < tokenIdsToNotifyUpdate.length; i++) {
IUpdateableTokenURI(address(_getMintsManagerStorage().mints)).notifyUpdatedTokenURI(_uri(tokenIdsToNotifyUpdate[i]), tokenIdsToNotifyUpdate[i]);
}
}

function _setMetadataURIs(string memory newContractURI, string memory newBaseURI) internal {
Expand Down
34 changes: 31 additions & 3 deletions packages/mints/test/ZoraMintsManagerMetadata.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ contract ZoraMintsManagerMetadataTest is Test {
ZoraMintsManagerImpl zoraMintsManager;
IZoraMints1155 mints;

uint256[] tokenIds;

function setUp() public {
bytes memory mintsCreationCode = abi.encodePacked(type(ZoraMints1155).creationCode);
ZoraMintsManagerImpl managerImpl = new ZoraMintsManagerImpl(IZoraCreator1155PremintExecutorV2(address(0x123)));
Expand All @@ -41,6 +43,10 @@ contract ZoraMintsManagerMetadataTest is Test {
newBaseURI: "",
newContractURI: ""
});

tokenIds = new uint256[](2);
tokenIds[0] = 1;
tokenIds[1] = 5;
}

function testMetadataDeploysCorrectly() public {
Expand All @@ -49,7 +55,7 @@ contract ZoraMintsManagerMetadataTest is Test {
vm.expectEmit(true, true, true, true);
emit URIsUpdated({contractURI: "https://zora.co/mints/metadata/contract.json", baseURI: "https://zora.co/mints/metadata/"});
vm.prank(defaultOwner);
zoraMintsManager.setMetadataURIs("https://zora.co/mints/metadata/contract.json", "https://zora.co/mints/metadata/");
zoraMintsManager.setMetadataURIs("https://zora.co/mints/metadata/contract.json", "https://zora.co/mints/metadata/", tokenIds);
assertEq(zoraMintsManager.uri(1), "https://zora.co/mints/metadata/1");
assertEq(zoraMintsManager.contractURI(), "https://zora.co/mints/metadata/contract.json");
}
Expand All @@ -60,14 +66,14 @@ contract ZoraMintsManagerMetadataTest is Test {

function testMetadataCannotBeUpdatedNonOwner() public {
vm.expectRevert(abi.encodeWithSignature("OwnableUnauthorizedAccount(address)", address(0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496)));
zoraMintsManager.setMetadataURIs("https://zora.co/mints/metadata/contract.json", "https://zora.co/mints/metadata/");
zoraMintsManager.setMetadataURIs("https://zora.co/mints/metadata/contract.json", "https://zora.co/mints/metadata/", tokenIds);
}

function testZoraNFTEmitsContractURI() public {
vm.expectEmit(true, true, true, true);
emit ContractURIUpdated();
vm.prank(defaultOwner);
zoraMintsManager.setMetadataURIs("https://zora.co/mints/metadata/contract.json", "https://zora.co/mints/metadata/");
zoraMintsManager.setMetadataURIs("https://zora.co/mints/metadata/contract.json", "https://zora.co/mints/metadata/", tokenIds);
}

function testZoraNFTNotifiesNewTokenURI() public {
Expand All @@ -76,4 +82,26 @@ contract ZoraMintsManagerMetadataTest is Test {
emit URI("2", 2);
zoraMintsManager.createToken(2, TokenConfig({price: 0.01 ether, tokenAddress: address(0), redeemHandler: address(0)}), false);
}

function testMintsMetadataUpdate_zora() public {
string memory newContractURI = "https://zora.co/assets/mints/metadata";
string memory newBaseURI = "https://zora.co/assets/mints/metadata/";

tokenIds = new uint256[](1);

tokenIds[0] = 1;

bytes memory setNewUrlsCall = abi.encodeWithSelector(ZoraMintsManagerImpl.setMetadataURIs.selector, newContractURI, newBaseURI, tokenIds);

vm.startPrank(zoraMintsManager.owner());

(bool success, ) = address(zoraMintsManager).call(setNewUrlsCall);

assertTrue(success);
assertEq(ZoraMints1155(address(zoraMintsManager.zoraMints1155())).contractURI(), newContractURI);
assertEq(ZoraMints1155(address(zoraMintsManager.zoraMints1155())).uri(1), "https://zora.co/assets/mints/metadata/1");

console2.log("update urls call:");
console2.log(vm.toString(setNewUrlsCall));
}
}

0 comments on commit b6fc3a4

Please sign in to comment.