Skip to content

Instantly share code, notes, and snippets.

@Jojoooo1
Last active January 30, 2019 13:14
Show Gist options
  • Save Jojoooo1/68f9593f8ab847e84afa535432e4d2e1 to your computer and use it in GitHub Desktop.
Save Jojoooo1/68f9593f8ab847e84afa535432e4d2e1 to your computer and use it in GitHub Desktop.
chaincode-2.js
// [..]
// 2. Mandatory Invoke function
async Invoke(stub) {
console.info('########################################');
console.info(`Transaction ID: ${stub.getTxID()}`);
console.info(util.format('Args: %j', stub.getArgs()));
const ret = stub.getFunctionAndParameters();
console.info(ret);
const method = this[ret.fcn];
// Verifies if method exist
if (!method) {
return shim.error(`funcao com nome "${ret.fcn}" nao encontrado`);
}
try {
const payload = await method(stub, ret.params, this);
return shim.success(payload);
} catch (err) {
console.log(err.stack);
return shim.error(err.message ? err.message : 'Por favor tente novamente mais tarde');
}
}
// [..]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment