Skip to content

Commit 65785f5

Browse files
committed
Merge branch 'master' into data-structures
2 parents 635b48a + b98133f commit 65785f5

32 files changed

+680
-40
lines changed

abi/ERC2981.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"inputs": [
4+
{
5+
"internalType": "uint256",
6+
"name": "tokenId",
7+
"type": "uint256"
8+
},
9+
{
10+
"internalType": "uint256",
11+
"name": "salePrice",
12+
"type": "uint256"
13+
}
14+
],
15+
"name": "royaltyInfo",
16+
"outputs": [
17+
{
18+
"internalType": "address",
19+
"name": "",
20+
"type": "address"
21+
},
22+
{
23+
"internalType": "uint256",
24+
"name": "",
25+
"type": "uint256"
26+
}
27+
],
28+
"stateMutability": "view",
29+
"type": "function"
30+
},
31+
{
32+
"inputs": [
33+
{
34+
"internalType": "bytes4",
35+
"name": "interfaceId",
36+
"type": "bytes4"
37+
}
38+
],
39+
"name": "supportsInterface",
40+
"outputs": [
41+
{
42+
"internalType": "bool",
43+
"name": "",
44+
"type": "bool"
45+
}
46+
],
47+
"stateMutability": "view",
48+
"type": "function"
49+
}
50+
]

abi/ERC721MetadataInternal.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"name": "ERC721Base__TransferToZeroAddress",
5050
"type": "error"
5151
},
52+
{
53+
"inputs": [],
54+
"name": "ERC721Metadata__NonExistentToken",
55+
"type": "error"
56+
},
5257
{
5358
"anonymous": false,
5459
"inputs": [

abi/IERC2981.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"inputs": [
4+
{
5+
"internalType": "uint256",
6+
"name": "tokenId",
7+
"type": "uint256"
8+
},
9+
{
10+
"internalType": "uint256",
11+
"name": "salePrice",
12+
"type": "uint256"
13+
}
14+
],
15+
"name": "royaltyInfo",
16+
"outputs": [
17+
{
18+
"internalType": "address",
19+
"name": "receiever",
20+
"type": "address"
21+
},
22+
{
23+
"internalType": "uint256",
24+
"name": "royaltyAmount",
25+
"type": "uint256"
26+
}
27+
],
28+
"stateMutability": "view",
29+
"type": "function"
30+
},
31+
{
32+
"inputs": [
33+
{
34+
"internalType": "bytes4",
35+
"name": "interfaceId",
36+
"type": "bytes4"
37+
}
38+
],
39+
"name": "supportsInterface",
40+
"outputs": [
41+
{
42+
"internalType": "bool",
43+
"name": "",
44+
"type": "bool"
45+
}
46+
],
47+
"stateMutability": "view",
48+
"type": "function"
49+
}
50+
]

abi/IERC721MetadataInternal.json

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
[
2+
{
3+
"inputs": [],
4+
"name": "ERC721Base__BalanceQueryZeroAddress",
5+
"type": "error"
6+
},
7+
{
8+
"inputs": [],
9+
"name": "ERC721Base__ERC721ReceiverNotImplemented",
10+
"type": "error"
11+
},
12+
{
13+
"inputs": [],
14+
"name": "ERC721Base__InvalidOwner",
15+
"type": "error"
16+
},
17+
{
18+
"inputs": [],
19+
"name": "ERC721Base__MintToZeroAddress",
20+
"type": "error"
21+
},
22+
{
23+
"inputs": [],
24+
"name": "ERC721Base__NonExistentToken",
25+
"type": "error"
26+
},
27+
{
28+
"inputs": [],
29+
"name": "ERC721Base__NotOwnerOrApproved",
30+
"type": "error"
31+
},
32+
{
33+
"inputs": [],
34+
"name": "ERC721Base__NotTokenOwner",
35+
"type": "error"
36+
},
37+
{
38+
"inputs": [],
39+
"name": "ERC721Base__SelfApproval",
40+
"type": "error"
41+
},
42+
{
43+
"inputs": [],
44+
"name": "ERC721Base__TokenAlreadyMinted",
45+
"type": "error"
46+
},
47+
{
48+
"inputs": [],
49+
"name": "ERC721Base__TransferToZeroAddress",
50+
"type": "error"
51+
},
52+
{
53+
"inputs": [],
54+
"name": "ERC721Metadata__NonExistentToken",
55+
"type": "error"
56+
},
57+
{
58+
"anonymous": false,
59+
"inputs": [
60+
{
61+
"indexed": true,
62+
"internalType": "address",
63+
"name": "owner",
64+
"type": "address"
65+
},
66+
{
67+
"indexed": true,
68+
"internalType": "address",
69+
"name": "operator",
70+
"type": "address"
71+
},
72+
{
73+
"indexed": true,
74+
"internalType": "uint256",
75+
"name": "tokenId",
76+
"type": "uint256"
77+
}
78+
],
79+
"name": "Approval",
80+
"type": "event"
81+
},
82+
{
83+
"anonymous": false,
84+
"inputs": [
85+
{
86+
"indexed": true,
87+
"internalType": "address",
88+
"name": "owner",
89+
"type": "address"
90+
},
91+
{
92+
"indexed": true,
93+
"internalType": "address",
94+
"name": "operator",
95+
"type": "address"
96+
},
97+
{
98+
"indexed": false,
99+
"internalType": "bool",
100+
"name": "approved",
101+
"type": "bool"
102+
}
103+
],
104+
"name": "ApprovalForAll",
105+
"type": "event"
106+
},
107+
{
108+
"anonymous": false,
109+
"inputs": [
110+
{
111+
"indexed": true,
112+
"internalType": "address",
113+
"name": "from",
114+
"type": "address"
115+
},
116+
{
117+
"indexed": true,
118+
"internalType": "address",
119+
"name": "to",
120+
"type": "address"
121+
},
122+
{
123+
"indexed": true,
124+
"internalType": "uint256",
125+
"name": "tokenId",
126+
"type": "uint256"
127+
}
128+
],
129+
"name": "Transfer",
130+
"type": "event"
131+
}
132+
]

abi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solidstate/abi",
3-
"version": "0.0.43",
3+
"version": "0.0.47",
44
"author": "Nick Barry",
55
"license": "MIT",
66
"description": "ABIs for SolidState contracts",

contracts/interfaces/IERC2981.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.8;
4+
5+
import { IERC165 } from './IERC165.sol';
6+
import { IERC2981Internal } from './IERC2981Internal.sol';
7+
8+
/**
9+
* @title ERC2981 interface
10+
* @dev see https://eips.ethereum.org/EIPS/eip-2981
11+
*/
12+
interface IERC2981 is IERC2981Internal, IERC165 {
13+
/**
14+
* @notice called with the sale price to determine how much royalty is owed and to whom
15+
* @param tokenId the ERC721 or ERC1155 token id to query for royalty information
16+
* @param salePrice the sale price of the given asset
17+
* @return receiever rightful recipient of royalty
18+
* @return royaltyAmount amount of royalty owed
19+
*/
20+
function royaltyInfo(uint256 tokenId, uint256 salePrice)
21+
external
22+
view
23+
returns (address receiever, uint256 royaltyAmount);
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.8;
4+
5+
/**
6+
* @title ERC2981 interface
7+
*/
8+
interface IERC2981Internal {
9+
10+
}

contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solidstate/contracts",
3-
"version": "0.0.43",
3+
"version": "0.0.47",
44
"author": "Nick Barry",
55
"license": "MIT",
66
"description": "Solidity library for flexible smart contract development",

contracts/token/ERC721/metadata/ERC721Metadata.sol

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,37 @@
22

33
pragma solidity ^0.8.8;
44

5-
import { UintUtils } from '../../../utils/UintUtils.sol';
6-
import { ERC721BaseInternal, ERC721BaseStorage } from '../base/ERC721Base.sol';
7-
import { ERC721MetadataStorage } from './ERC721MetadataStorage.sol';
85
import { ERC721MetadataInternal } from './ERC721MetadataInternal.sol';
96
import { IERC721Metadata } from './IERC721Metadata.sol';
107

118
/**
129
* @title ERC721 metadata extensions
1310
*/
1411
abstract contract ERC721Metadata is IERC721Metadata, ERC721MetadataInternal {
15-
using ERC721BaseStorage for ERC721BaseStorage.Layout;
16-
using UintUtils for uint256;
17-
1812
/**
1913
* @notice inheritdoc IERC721Metadata
2014
*/
21-
function name() public view virtual returns (string memory) {
22-
return ERC721MetadataStorage.layout().name;
15+
function name() external view virtual returns (string memory) {
16+
return _name();
2317
}
2418

2519
/**
2620
* @notice inheritdoc IERC721Metadata
2721
*/
28-
function symbol() public view virtual returns (string memory) {
29-
return ERC721MetadataStorage.layout().symbol;
22+
function symbol() external view virtual returns (string memory) {
23+
return _symbol();
3024
}
3125

3226
/**
3327
* @notice inheritdoc IERC721Metadata
3428
*/
3529
function tokenURI(uint256 tokenId)
36-
public
30+
external
3731
view
3832
virtual
3933
returns (string memory)
4034
{
41-
if (!ERC721BaseStorage.layout().exists(tokenId))
42-
revert ERC721Metadata__NonExistentToken();
43-
44-
ERC721MetadataStorage.Layout storage l = ERC721MetadataStorage.layout();
45-
46-
string memory tokenIdURI = l.tokenURIs[tokenId];
47-
string memory baseURI = l.baseURI;
48-
49-
if (bytes(baseURI).length == 0) {
50-
return tokenIdURI;
51-
} else if (bytes(tokenIdURI).length > 0) {
52-
return string(abi.encodePacked(baseURI, tokenIdURI));
53-
} else {
54-
return string(abi.encodePacked(baseURI, tokenId.toString()));
55-
}
35+
return _tokenURI(tokenId);
5636
}
5737

5838
/**

0 commit comments

Comments
 (0)