This repository was archived by the owner on Nov 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Weave Design document
Jonas Snellinckx edited this page Jun 5, 2018
·
5 revisions
Args: {"function":"Car::createCar","Args":["CAR0"]}
// index.js
import shim = require('fabric-shim');
import { CarService } from './carservice';
const chaincode = new Weave()
.use('Car', new CarService())
shim.start(chaincode);
// carservice.js
export class CarService {
async createCar(stubHelper: StubHelper, args: string[]) {
const verifiedArgs = await Helpers.checkArgs<{ key: string }>(args[0], Yup.object()
.shape({
key: Yup.string().required(),
}));
const car = await stubHelper.getStateAsObject(verifiedArgs.key); //get the car from chaincode state
if (!car) {
throw new ChaincodeError('Car does not exist');
}
return car;
}
}// index.js
import shim = require('fabric-shim');
import { logger } from './logger';
const chaincode = new Weave()
.use('Car', new CarService())
.use(logger)
// logger.js
export const logger = (stubHelper: StubHelper, args: string[], fcn: string, done: any) => {
console.log("Executing function", fcn, "with args", args)
}