From ef42c0a0940e23c0ad6db39803626b50eaaba8c4 Mon Sep 17 00:00:00 2001 From: Rajat Sharma Date: Tue, 14 Jun 2022 18:14:10 +0530 Subject: [PATCH] check for Intitialized changed Signed-off-by: Rajat Sharma --- token-erc-721/chaincode-javascript/lib/tokenERC721.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/token-erc-721/chaincode-javascript/lib/tokenERC721.js b/token-erc-721/chaincode-javascript/lib/tokenERC721.js index b87bf946..65dd9cd0 100644 --- a/token-erc-721/chaincode-javascript/lib/tokenERC721.js +++ b/token-erc-721/chaincode-javascript/lib/tokenERC721.js @@ -312,7 +312,7 @@ class TokenERC721Contract extends Contract { //check contract options are not already set, client is not authorized to change them once intitialized const nameBytes = await ctx.stub.getState(nameKey); - if (nameBytes !== undefined) { + if (!nameBytes || nameBytes.length !== 0) { throw new Error('contract options are already set, client is not authorized to change them'); } @@ -455,10 +455,10 @@ class TokenERC721Contract extends Contract { //Checks that contract options have been already initialized async CheckIntitialized(ctx){ const nameBytes = await ctx.stub.getState(nameKey); - if (nameBytes === undefined) { + if (!nameBytes || nameBytes.length === 0) { throw new Error('contract options need to be set before calling any function, call Initialize() to initialize contract'); } } } -module.exports = TokenERC721Contract; \ No newline at end of file +module.exports = TokenERC721Contract;