Skip to content

Commit

Permalink
prevent tokenID collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed Apr 26, 2024
1 parent 2007903 commit cc8c259
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/chatGPT-nft-minter/suave/ChatNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ contract ChatNFT {
event QueryResult(bytes result);
event NFTCreated(uint256 tokenId, address recipient, bytes signature);

function getTokenId(string[] memory prompts) public pure returns (uint256) {
return uint256(keccak256(abi.encode(prompts)));
function newTokenId(string[] memory prompts) private view returns (uint256) {
return uint256(keccak256(abi.encode(prompts, block.timestamp, msg.sender)));
}

/// Logs the query result.
Expand All @@ -44,7 +44,7 @@ contract ChatNFT {
// parse confidential inputs
bytes memory cInputs = Suave.confidentialInputs();
MintNFTConfidentialParams memory cParams = abi.decode(cInputs, (MintNFTConfidentialParams));
uint256 tokenId = getTokenId(cParams.prompts);
uint256 tokenId = newTokenId(cParams.prompts);

// query ChatGPT
ChatGPT chatGPT = new ChatGPT(cParams.openaiApiKey);
Expand Down

0 comments on commit cc8c259

Please sign in to comment.