@@ -21,10 +21,8 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
21
21
/// @dev Account with proxy adming rights.
22
22
address private _proxyAdmin;
23
23
24
- /// @dev Holds the URI information of a SBT token.
25
- mapping (uint256 => string ) private _tokenUriImage;
26
24
/// @dev Holds the generic metadata and attribute information of a SBT token.
27
- mapping (uint256 => Metadata ) private _tokenMetadata ;
25
+ mapping (uint256 => SBTData ) private _sbtdata ;
28
26
29
27
modifier onlyMinter () {
30
28
require (_minter == _msgSender (), "Illegal access " );
@@ -33,12 +31,23 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
33
31
34
32
function _setTokenURI (
35
33
uint256 tokenId ,
36
- Metadata memory tokenMetadata ,
34
+ string memory name ,
35
+ string memory description ,
36
+ StringAttribute[] memory stringAttributes ,
37
+ NumberAttribute[] memory numberAttributes ,
37
38
string memory tokenUriImage
38
39
) private {
39
- _tokenMetadata[tokenId] = tokenMetadata;
40
- _tokenUriImage[tokenId] = tokenUriImage;
41
- emit SetSBTTokenURI (tokenId, abi.encode (tokenMetadata, tokenUriImage));
40
+ bytes memory stringAttributesEncoded = abi.encode (stringAttributes);
41
+ bytes memory numberAttributesEncoded = abi.encode (numberAttributes);
42
+ SBTData memory sbtData = SBTData ({
43
+ name: name,
44
+ image: tokenUriImage,
45
+ description: description,
46
+ stringAttributesEncoded: stringAttributesEncoded,
47
+ numberAttributesEncoded: numberAttributesEncoded
48
+ });
49
+ _sbtdata[tokenId] = sbtData;
50
+ emit SetSBTTokenURI (tokenId, abi.encode (sbtData, tokenUriImage));
42
51
}
43
52
44
53
function _beforeTokenTransfer (
@@ -75,27 +84,47 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
75
84
76
85
function setTokenURI (
77
86
uint256 tokenId ,
78
- Metadata memory tokenMetadata ,
87
+ string memory name ,
88
+ string memory description ,
89
+ StringAttribute[] memory stringAttributes ,
90
+ NumberAttribute[] memory numberAttributes ,
79
91
string memory tokenUriImage
80
92
) external override onlyMinter {
81
93
require (tokenId < currentIndex (), "Token not found " );
82
- _setTokenURI (tokenId, tokenMetadata, tokenUriImage);
94
+ _setTokenURI (
95
+ tokenId,
96
+ name,
97
+ description,
98
+ stringAttributes,
99
+ numberAttributes,
100
+ tokenUriImage
101
+ );
83
102
}
84
103
85
104
function mint (
86
105
address to ,
87
- Metadata memory tokenMetadata ,
106
+ string memory name ,
107
+ string memory description ,
108
+ StringAttribute[] memory stringAttributes ,
109
+ NumberAttribute[] memory numberAttributes ,
88
110
string memory tokenUriImage
89
111
) external override onlyMinter returns (uint256 tokenId_ ) {
90
112
uint256 currentId = currentIndex ();
91
113
_mint (to, currentId);
92
114
emit Minted (currentId, to);
93
- _setTokenURI (currentId, tokenMetadata, tokenUriImage);
115
+ _setTokenURI (
116
+ currentId,
117
+ name,
118
+ description,
119
+ stringAttributes,
120
+ numberAttributes,
121
+ tokenUriImage
122
+ );
94
123
return currentId;
95
124
}
96
125
97
126
function _tokenURI (uint256 tokenId ) private view returns (string memory ) {
98
- return _tokenUriImage [tokenId];
127
+ return string ( bytes ( abi.encode (_sbtdata [tokenId]))) ;
99
128
}
100
129
101
130
function tokenURI (
0 commit comments