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 250bb8c
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 78 deletions.
39 changes: 0 additions & 39 deletions artifacts/abi/drops/LSP8DropsDigitalAsset.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,19 +468,6 @@
"name": "Deactivated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes",
"name": "defaultTokenData",
"type": "bytes"
}
],
"name": "DefaultTokenDataChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -735,19 +722,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "defaultTokenUri",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -1031,19 +1005,6 @@
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "newTokenUri",
"type": "bytes"
}
],
"name": "setDefaultTokenUri",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "startTime",
Expand Down
2 changes: 1 addition & 1 deletion artifacts/bytecode/assets/lsp7/DigitalAssetDrop.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x60a060405234801561001057600080fd5b50604051610ca7380380610ca783398101604081905261002f916101a6565b600180556001600160a01b03831661007e5760405162461bcd60e51b815260206004820152600d60248201526c6173736574206973207a65726f60981b60448201526064015b60405180910390fd5b60008290036100be5760405162461bcd60e51b815260206004820152600c60248201526b726f6f74206973207a65726f60a01b6044820152606401610075565b6001600160a01b0381166101045760405162461bcd60e51b815260206004820152600d60248201526c6f776e6572206973207a65726f60981b6044820152606401610075565b6001600160a01b03831660805261011a82600255565b6101238161012b565b5050506101e9565b6000546001600160a01b0382811691161461018e57600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a3505b50565b6001600160a01b038116811461018e57600080fd5b6000806000606084860312156101bb57600080fd5b83516101c681610191565b6020850151604086015191945092506101de81610191565b809150509250925092565b608051610a8f61021860003960008181607c0152818161022c01528181610329015261042d0152610a8f6000f3fe608060405234801561001057600080fd5b50600436106100725760003560e01c8063c8edd8ab11610050578063c8edd8ab146100d5578063f05c55ac146100e8578063f2fde38b146100fb57600080fd5b806338d52e0f14610077578063715018a6146100ba5780638da5cb5b146100c4575b600080fd5b61009e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b6100c261010e565b005b6000546001600160a01b031661009e565b6100c26100e3366004610892565b610122565b6100c26100f6366004610926565b610298565b6100c2610109366004610926565b610496565b610116610523565b610120600061058c565b565b61012a610609565b61019c858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040516bffffffffffffffffffffffff193360601b166020820152603481018690528792506054019050604051602081830303815290604052610662565b816001600160a01b0316837f4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed026836040516101d891815260200190565b60405180910390a3604051633b06cddd60e11b81523060048201526001600160a01b038381166024830152604482018390526000606483015260a06084830152600260a483015261060f60f31b60c48301527f0000000000000000000000000000000000000000000000000000000000000000169063760d9bba9060e401600060405180830381600087803b15801561027057600080fd5b505af1158015610284573d6000803e3d6000fd5b5050505061029160018055565b5050505050565b6102a0610523565b6102a8610609565b6001600160a01b0381166102f8576040517f1a3b45fd0000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201526024015b60405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039c9190610941565b9050816001600160a01b03167feb44e1b23fad598a86840f12d9ab99216d186e1eeebb5ef8e3b3d152ba7cbc7e826040516103d991815260200190565b60405180910390a2604051633b06cddd60e11b81523060048201526001600160a01b038381166024830152604482018390526001606483015260a06084830152600260a483015261060f60f31b60c48301527f0000000000000000000000000000000000000000000000000000000000000000169063760d9bba9060e401600060405180830381600087803b15801561047157600080fd5b505af1158015610485573d6000803e3d6000fd5b505050505061049360018055565b50565b61049e610523565b6001600160a01b03811661051a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102ef565b6104938161058c565b336105366000546001600160a01b031690565b6001600160a01b0316146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102ef565b6000546001600160a01b0382811691161461049357600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60026001540361065b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102ef565b6002600155565b60025461069b576040517f5058901600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6106a482610762565b156106df5781816040517f331e2c3f0000000000000000000000000000000000000000000000000000000081526004016102ef92919061097e565b600082826040516020016106f49291906109b8565b60405160208183030381529060405280519060200120905061071984600254836107a3565b6107535782826040517f4a0e7b130000000000000000000000000000000000000000000000000000000081526004016102ef92919061097e565b61075c836107b9565b50505050565b600080610771610100846109f4565b9050600061078161010085610a08565b60009283526003602052604090922054600190921b9182169091149392505050565b6000826107b085846107f7565b14949350505050565b60006107c7610100836109f4565b905060006107d761010084610a08565b6000928352600360205260409092208054600190931b9092179091555050565b600081815b845181101561083c576108288286838151811061081b5761081b610a1c565b6020026020010151610844565b91508061083481610a32565b9150506107fc565b509392505050565b600081831061086057600082815260208490526040902061086f565b60008381526020839052604090205b9392505050565b80356001600160a01b038116811461088d57600080fd5b919050565b6000806000806000608086880312156108aa57600080fd5b853567ffffffffffffffff808211156108c257600080fd5b818801915088601f8301126108d657600080fd5b8135818111156108e557600080fd5b8960208260051b85010111156108fa57600080fd5b60209283019750955050860135925061091560408701610876565b949793965091946060013592915050565b60006020828403121561093857600080fd5b61086f82610876565b60006020828403121561095357600080fd5b5051919050565b60005b8381101561097557818101518382015260200161095d565b50506000910152565b82815260406020820152600082518060408401526109a381606085016020870161095a565b601f01601f1916919091016060019392505050565b828152600082516109d081602085016020870161095a565b919091016020019392505050565b634e487b7160e01b600052601260045260246000fd5b600082610a0357610a036109de565b500490565b600082610a1757610a176109de565b500690565b634e487b7160e01b600052603260045260246000fd5b600060018201610a5257634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212209eeb67118564fefc4116cca0036adbe0e8d575392b526387dfa7c9b798b66e1264736f6c63430008110033
0x60a060405234801561001057600080fd5b50604051610ca7380380610ca783398101604081905261002f916101a6565b600180556001600160a01b03831661007e5760405162461bcd60e51b815260206004820152600d60248201526c6173736574206973207a65726f60981b60448201526064015b60405180910390fd5b60008290036100be5760405162461bcd60e51b815260206004820152600c60248201526b726f6f74206973207a65726f60a01b6044820152606401610075565b6001600160a01b0381166101045760405162461bcd60e51b815260206004820152600d60248201526c6f776e6572206973207a65726f60981b6044820152606401610075565b6001600160a01b03831660805261011a82600255565b6101238161012b565b5050506101e9565b6000546001600160a01b0382811691161461018e57600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a3505b50565b6001600160a01b038116811461018e57600080fd5b6000806000606084860312156101bb57600080fd5b83516101c681610191565b6020850151604086015191945092506101de81610191565b809150509250925092565b608051610a8f61021860003960008181607c0152818161022c01528181610329015261042d0152610a8f6000f3fe608060405234801561001057600080fd5b50600436106100725760003560e01c8063c8edd8ab11610050578063c8edd8ab146100d5578063f05c55ac146100e8578063f2fde38b146100fb57600080fd5b806338d52e0f14610077578063715018a6146100ba5780638da5cb5b146100c4575b600080fd5b61009e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b6100c261010e565b005b6000546001600160a01b031661009e565b6100c26100e3366004610892565b610122565b6100c26100f6366004610926565b610298565b6100c2610109366004610926565b610496565b610116610523565b610120600061058c565b565b61012a610609565b61019c858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040516bffffffffffffffffffffffff193360601b166020820152603481018690528792506054019050604051602081830303815290604052610662565b816001600160a01b0316837f4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed026836040516101d891815260200190565b60405180910390a3604051633b06cddd60e11b81523060048201526001600160a01b038381166024830152604482018390526000606483015260a06084830152600260a483015261060f60f31b60c48301527f0000000000000000000000000000000000000000000000000000000000000000169063760d9bba9060e401600060405180830381600087803b15801561027057600080fd5b505af1158015610284573d6000803e3d6000fd5b5050505061029160018055565b5050505050565b6102a0610523565b6102a8610609565b6001600160a01b0381166102f8576040517f1a3b45fd0000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201526024015b60405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039c9190610941565b9050816001600160a01b03167feb44e1b23fad598a86840f12d9ab99216d186e1eeebb5ef8e3b3d152ba7cbc7e826040516103d991815260200190565b60405180910390a2604051633b06cddd60e11b81523060048201526001600160a01b038381166024830152604482018390526001606483015260a06084830152600260a483015261060f60f31b60c48301527f0000000000000000000000000000000000000000000000000000000000000000169063760d9bba9060e401600060405180830381600087803b15801561047157600080fd5b505af1158015610485573d6000803e3d6000fd5b505050505061049360018055565b50565b61049e610523565b6001600160a01b03811661051a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102ef565b6104938161058c565b336105366000546001600160a01b031690565b6001600160a01b0316146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102ef565b6000546001600160a01b0382811691161461049357600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60026001540361065b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102ef565b6002600155565b60025461069b576040517f5058901600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6106a482610762565b156106df5781816040517f331e2c3f0000000000000000000000000000000000000000000000000000000081526004016102ef92919061097e565b600082826040516020016106f49291906109b8565b60405160208183030381529060405280519060200120905061071984600254836107a3565b6107535782826040517f4a0e7b130000000000000000000000000000000000000000000000000000000081526004016102ef92919061097e565b61075c836107b9565b50505050565b600080610771610100846109f4565b9050600061078161010085610a08565b60009283526003602052604090922054600190921b9182169091149392505050565b6000826107b085846107f7565b14949350505050565b60006107c7610100836109f4565b905060006107d761010084610a08565b6000928352600360205260409092208054600190931b9092179091555050565b600081815b845181101561083c576108288286838151811061081b5761081b610a1c565b6020026020010151610844565b91508061083481610a32565b9150506107fc565b509392505050565b600081831061086057600082815260208490526040902061086f565b60008381526020839052604090205b9392505050565b80356001600160a01b038116811461088d57600080fd5b919050565b6000806000806000608086880312156108aa57600080fd5b853567ffffffffffffffff808211156108c257600080fd5b818801915088601f8301126108d657600080fd5b8135818111156108e557600080fd5b8960208260051b85010111156108fa57600080fd5b60209283019750955050860135925061091560408701610876565b949793965091946060013592915050565b60006020828403121561093857600080fd5b61086f82610876565b60006020828403121561095357600080fd5b5051919050565b60005b8381101561097557818101518382015260200161095d565b50506000910152565b82815260406020820152600082518060408401526109a381606085016020870161095a565b601f01601f1916919091016060019392505050565b828152600082516109d081602085016020870161095a565b919091016020019392505050565b634e487b7160e01b600052601260045260246000fd5b600082610a0357610a036109de565b500490565b600082610a1757610a176109de565b500690565b634e487b7160e01b600052603260045260246000fd5b600060018201610a5257634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220604f44aefb11001d5d752142ae0fa042be0c1e2c4fec71a27d4f38f3bdf2eea664736f6c63430008110033
2 changes: 1 addition & 1 deletion artifacts/bytecode/assets/lsp7/MintableDigitalAsset.bin

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion artifacts/bytecode/drops/LSP7DropsDigitalAsset.bin

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion artifacts/bytecode/drops/LSP8DropsDigitalAsset.bin

Large diffs are not rendered by default.

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 250bb8c

Please sign in to comment.