Skip to content

Commit

Permalink
need to append / at the end for tokenURI, fix tests (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdang authored Apr 8, 2024
1 parent 6d4f471 commit 29653ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract ManifoldERC721Edition is CreatorExtension, ICreatorExtensionTokenURI, I
} else if (info.storageProtocol == StorageProtocol.IPFS) {
prefix = IPFS_PREFIX;
}
return string(abi.encodePacked(prefix, info.location, (index+1).toString()));
return string(abi.encodePacked(prefix, info.location, "/", (index+1).toString()));
}

/**
Expand Down
28 changes: 14 additions & 14 deletions packages/manifold/test/edition/ManifoldERC721Edition.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ contract ManifoldERC721EditionTest is Test {
example.mint(address(creatorCore1), 1, 0, new IManifoldERC721Edition.Recipient[](0));

// Create with arweave
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.ARWEAVE, "abcdefgh/", _emptyRecipients);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.ARWEAVE, "abcdefgh", _emptyRecipients);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
Expand All @@ -155,7 +155,7 @@ contract ManifoldERC721EditionTest is Test {
assertEq(example.tokenURI(address(creatorCore1), 1), "https://arweave.net/abcdefgh/1");

// Change to be IPFS based
example.setTokenURI(address(creatorCore1), 1, IManifoldERC721Edition.StorageProtocol.IPFS, "abcdefgh/");
example.setTokenURI(address(creatorCore1), 1, IManifoldERC721Edition.StorageProtocol.IPFS, "abcdefgh");
assertEq(example.tokenURI(address(creatorCore1), 1), "ipfs://abcdefgh/1");

vm.stopPrank();
Expand All @@ -172,10 +172,10 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", _emptyRecipients);
example.createSeries(address(creatorCore1), 2, 20, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2/", _emptyRecipients);
example.createSeries(address(creatorCore2), 3, 200, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2/", _emptyRecipients);
example.createSeries(address(creatorCore3), 4, 300, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2/", _emptyRecipients);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);
example.createSeries(address(creatorCore1), 2, 20, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2", _emptyRecipients);
example.createSeries(address(creatorCore2), 3, 200, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2", _emptyRecipients);
example.createSeries(address(creatorCore3), 4, 300, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2", _emptyRecipients);

// Get the edition info
ManifoldERC721Edition.EditionInfo memory edition = example.getEditionInfo(address(creatorCore1), 1);
Expand Down Expand Up @@ -248,7 +248,7 @@ contract ManifoldERC721EditionTest is Test {
// Prefix change test
vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.setTokenURI(address(creatorCore1), 0, IManifoldERC721Edition.StorageProtocol.INVALID, "");
example.setTokenURI(address(creatorCore1), 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1new/");
example.setTokenURI(address(creatorCore1), 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1new");
assertEq("http://creator1series1new/3", creatorCore1.tokenURI(13));
assertEq("http://creator1series1new/5", creatorCore1.tokenURI(15));

Expand All @@ -265,7 +265,7 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", _emptyRecipients);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.mint(address(creatorCore1), 1, 0, new IManifoldERC721Edition.Recipient[](0));
Expand All @@ -284,7 +284,7 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", _emptyRecipients);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
Expand Down Expand Up @@ -313,7 +313,7 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", _emptyRecipients);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
Expand All @@ -338,7 +338,7 @@ contract ManifoldERC721EditionTest is Test {
vm.startPrank(owner);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 0, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", _emptyRecipients);
example.createSeries(address(creatorCore1), 0, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 1, 0, IManifoldERC721Edition.StorageProtocol.NONE, "hi", _emptyRecipients);
Expand Down Expand Up @@ -374,10 +374,10 @@ contract ManifoldERC721EditionTest is Test {

// Mint count 0
vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 10, 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", recipients);
example.createSeries(address(creatorCore1), 10, 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", recipients);

recipients[0].count = 1;
example.createSeries(address(creatorCore1), 10, 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", recipients);
example.createSeries(address(creatorCore1), 10, 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", recipients);

// Too many recipients...
recipients = new IManifoldERC721Edition.Recipient[](11);
Expand All @@ -387,7 +387,7 @@ contract ManifoldERC721EditionTest is Test {
}

vm.expectRevert(IManifoldERC721Edition.TooManyRequested.selector);
example.createSeries(address(creatorCore1), 11, 2, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", recipients);
example.createSeries(address(creatorCore1), 11, 2, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", recipients);
vm.stopPrank();
}

Expand Down

0 comments on commit 29653ba

Please sign in to comment.