Skip to content

Commit 7bf26b4

Browse files
author
Yash Agrawal
committed
feat: update currentIndex and add nextIndex in SBT.sol
1 parent acc8e63 commit 7bf26b4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

contracts/SBT.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ contract SBT is ISBT, ERC721EnumerableUpgradeable {
8383
uint256 tokenId,
8484
bytes memory metadata
8585
) external override onlyMinter {
86-
require(tokenId < currentIndex(), "Token not found");
86+
require(tokenId <= currentIndex(), "Token not found");
8787
_setTokenURI(tokenId, metadata);
8888
}
8989

@@ -106,7 +106,7 @@ contract SBT is ISBT, ERC721EnumerableUpgradeable {
106106
}
107107

108108
function _tokenURI(uint256 tokenId) private view returns (string memory) {
109-
require(tokenId < currentIndex(), "Token not found");
109+
require(tokenId <= currentIndex(), "Token not found");
110110

111111
(
112112
string memory name,
@@ -229,13 +229,17 @@ contract SBT is ISBT, ERC721EnumerableUpgradeable {
229229
}
230230

231231
function currentIndex() public view override returns (uint256) {
232-
return super.totalSupply();
232+
return totalSupply();
233+
}
234+
235+
function nextIndex() public view override returns (uint256) {
236+
return currentIndex() + 1;
233237
}
234238

235239
function metadataOf(
236240
uint256 tokenId
237241
) public view override returns (bytes memory) {
238-
require(tokenId < currentIndex(), "Token not found");
242+
require(tokenId <= currentIndex(), "Token not found");
239243
return _sbtdata[tokenId];
240244
}
241245

contracts/interfaces/ISBT.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ interface ISBT {
112112
*/
113113
function currentIndex() external view returns (uint256);
114114

115+
/*
116+
* @dev get next id of token to be minted
117+
* @return uint256 next token id
118+
*/
119+
function nextIndex() external view returns (uint256);
120+
115121
/*
116122
* @dev get mapped metadata bytes of token id
117123
* @param tokenId the token id of the NFT

0 commit comments

Comments
 (0)