Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async Invoke(stub: ChaincodeStub): Promise {
const logger: LoggerInstance = Shim.newLogger('invoke');
const args: string[] = stub.getArgs();
const strArgs: string[] = stub.getStringArgs();
const {fcn, params} = stub.getFunctionAndParameters();
const FunctionsAndParameters: {fcn: string, params: string[]} = stub.getFunctionAndParameters();
if (fcn === 'ThrowError') {
const err: Error = new Error('Had a problem');
return shim.error(Buffer.from(err.message));
}
if (fcn === 'ThrowErrorShim') {
const err: Error = new Error('Had a problem');
return Shim.error(Buffer.from(err.message));
}
if (fcn === 'SuccessShim') {
return Shim.success();
}
await this.testAll(stub);
if (fcn === 'nopayload') {
return shim.success();
}
if (fcn === 'myReturnCode') {
let rc: number;
rc = ChaincodeStub.RESPONSE_CODE.OK;
rc = shim.RESPONSE_CODE.OK;