mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-21 17:15:10 +00:00
ERC20: check for token initialized changed
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
This commit is contained in:
parent
194aff808d
commit
fc2494aebd
1 changed files with 2 additions and 2 deletions
|
|
@ -315,7 +315,7 @@ class TokenERC20Contract extends Contract {
|
||||||
|
|
||||||
//check contract options are not already set, client is not authorized to change them once intitialized
|
//check contract options are not already set, client is not authorized to change them once intitialized
|
||||||
const nameBytes = await ctx.stub.getState(nameKey);
|
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');
|
throw new Error('contract options are already set, client is not authorized to change them');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -476,7 +476,7 @@ class TokenERC20Contract extends Contract {
|
||||||
//Checks that contract options have been already initialized
|
//Checks that contract options have been already initialized
|
||||||
async CheckInitialized(ctx){
|
async CheckInitialized(ctx){
|
||||||
const nameBytes = await ctx.stub.getState(nameKey);
|
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');
|
throw new Error('contract options need to be set before calling any function, call Initialize() to initialize contract');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue