Skip to content

Instantly share code, notes, and snippets.

@sneljo1
Last active June 29, 2018 08:42
Show Gist options
  • Save sneljo1/8f5fc1941fb11fa5c6b5563e6a525dc0 to your computer and use it in GitHub Desktop.
Save sneljo1/8f5fc1941fb11fa5c6b5563e6a525dc0 to your computer and use it in GitHub Desktop.
async queryCar(stubHelper: StubHelper, args: string[]): Promise<any> {
const verifiedArgs = await Helpers.checkArgs<{ key: string }>(args[0], Yup.object()
.shape({
key: Yup.string().required(),
}));
const car = stubHelper.getStateAsObject(verifiedArgs.key); //get the car from chaincode state
if (!car) {
throw new ChaincodeError('Car does not exist');
}
return car;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment