Skip to content

Commit

Permalink
Remove default token uri to use LSP8TokenMetadataBaseURI
Browse files Browse the repository at this point in the history
  • Loading branch information
lykhonis committed Sep 4, 2023
1 parent a5c2795 commit 471634e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
18 changes: 0 additions & 18 deletions src/drops/LSP8DropsDigitalAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ import {DropsDigitalAsset} from "./DropsDigitalAsset.sol";

contract LSP8DropsDigitalAsset is LSP8CappedSupply, LSP8Enumerable, DropsDigitalAsset {
event Minted(address indexed recipient, bytes32[] tokenIds, uint256 totalPrice);
event DefaultTokenDataChanged(bytes defaultTokenData);

error TokenTypeNotEditable();

bytes32 private constant _LSP8_TOKEN_ID_TYPE_KEY =
0x715f248956de7ce65e94d9d836bfead479f7e70d69b718d47bfe7b00e05b4fe4;
uint256 private constant _LSP8_TOKEN_ID_TYPE_COUNTER = 2;

bytes32 private constant _LSP8_TOKEN_URI_DATA_KEY_PREFIX =
0x1339e76a390b7b9ec90100000000000000000000000000000000000000000000;

bytes public defaultTokenUri;
uint256 private _totalMintedTokens;

constructor(
Expand All @@ -43,11 +38,6 @@ contract LSP8DropsDigitalAsset is LSP8CappedSupply, LSP8Enumerable, DropsDigital
super._setData(_LSP8_TOKEN_ID_TYPE_KEY, bytes.concat(bytes32(_LSP8_TOKEN_ID_TYPE_COUNTER)));
}

function setDefaultTokenUri(bytes calldata newTokenUri) external onlyOwner {
defaultTokenUri = newTokenUri;
emit DefaultTokenDataChanged(newTokenUri);
}

function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
if (dataKey == _LSP8_TOKEN_ID_TYPE_KEY) {
revert TokenTypeNotEditable();
Expand All @@ -56,14 +46,6 @@ contract LSP8DropsDigitalAsset is LSP8CappedSupply, LSP8Enumerable, DropsDigital
}
}

function _getData(bytes32 dataKey) internal view override returns (bytes memory) {
bytes memory result = super._getData(dataKey);
if ((result.length == 0) && ((dataKey & _LSP8_TOKEN_URI_DATA_KEY_PREFIX) == _LSP8_TOKEN_URI_DATA_KEY_PREFIX)) {
return defaultTokenUri;
}
return result;
}

function _doMint(address recipient, uint256 amount, uint256 totalPrice) internal override {
// allocate tokens
bytes32[] memory tokenIds = new bytes32[](amount);
Expand Down
16 changes: 0 additions & 16 deletions test/drops/LSP8DropsDigitalAsset.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,11 @@ contract LSP8DropsDigitalAssetTest is Test {
emit ConfigurationChanged(block.timestamp + 1 days, 1 ether, 3, 0);
vm.prank(owner);
drop.configure(block.timestamp + 1 days, 1 ether, 3, 0);

vm.expectEmit(address(drop));
emit DefaultTokenDataChanged(new bytes(0));
vm.prank(owner);
drop.setDefaultTokenUri(new bytes(0));
}

function test_Revert_IfConfigureNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");
drop.configure(block.timestamp, 1 ether, 3, 0);
vm.expectRevert("Ownable: caller is not the owner");
drop.setDefaultTokenUri(new bytes(0));
}

function test_Mint() public {
Expand Down Expand Up @@ -258,13 +251,4 @@ contract LSP8DropsDigitalAssetTest is Test {
vm.expectRevert(abi.encodeWithSelector(DropsDigitalAsset.ClaimInvalidAmount.selector, 1 ether));
drop.claim(recipient, 1 ether);
}

function test_DefaultTokenUri() public {
vm.prank(owner);
drop.setDefaultTokenUri(bytes.concat(bytes4(0), "http://test/default"));

bytes32 tokenUriKey =
bytes32(bytes.concat(bytes10(keccak256(bytes("LSP8MetadataTokenURI"))), bytes2(0), bytes20(uint160(1))));
assertEq(bytes.concat(bytes4(0), "http://test/default"), drop.getData(tokenUriKey));
}
}

0 comments on commit 471634e

Please sign in to comment.