Last active
January 30, 2019 13:14
-
-
Save Jojoooo1/68f9593f8ab847e84afa535432e4d2e1 to your computer and use it in GitHub Desktop.
chaincode-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [..] | |
// 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