import * as yup from 'yup' ; import { Controller , ConvectorController , Invokable , Param , ClientFactory , FlatConvectorModel } from '@worldsibu/convector-core' ; import { Third } from './third-cc' ; import { SecondController , Second } from './second-cc' ; import { InChaincodeAdapter } from '../src/fabric-in-chaincode.controller-adapter' ; const adapter = new InChaincodeAdapter ( ) ; const secondCtrl = ClientFactory ( SecondController , adapter ) ; @ Controller ( 'first' ) export class FirstController extends ConvectorController { @ Invokable ( ) public async connectToSecond ( @ Param ( yup . string ( ) ) id , @ Param ( yup . string ( ) ) channel , @ Param ( yup . string ( ) ) chaincode ) { const second = await secondCtrl . $config ( { tx : this . tx , channel , chaincode } ) . get ( id ) ; await new Second ( { id : `second:${ id }` , ... second } ) . save ( ) ; return second ; } @ Invokable ( ) public async connectToThird ( @ Param ( yup . string ( ) ) id , @ Param ( yup . string ( ) ) channel , @ Param ( yup . string ( ) ) chaincode ) { const { result : third } = await adapter . rawInvoke ( 'third_get' , { tx : this . tx , channel , chaincode } , '1' ) ; await new Third ( { id : `third:${ id }` , ... third } ) . save ( ) ; return third ; } }