module worldsibu import { ChaincodeStub } from 'fabric-shim' ; import { BaseStorage , InvalidIdError } from '@worldsibu/convector-core' ; import { StubHelper , Transform } from '@theledger/fabric-chaincode-utils' ; Transform . isObject = data => data !== null && typeof data === 'object' ; export class StubStorage extends BaseStorage { public stubHelper : StubHelper ; constructor ( stub ) { super ( ) ; this . stubHelper = new StubHelper ( stub ) ; } public async query ( query , storageOptions ? ) { return await this . stubHelper . getQueryResultAsList ( query , storageOptions ) ; } see https public async get ( id , storageOptions ? ) { InvalidIdError . test ( id ) ; return await this . stubHelper . getStateAsObject ( id , storageOptions ) ; } public async set ( id , content , storageOptions ? ) { InvalidIdError . test ( id ) ; return await this . stubHelper . putState ( id , JSON . stringify ( content ) , storageOptions ) ; } public async delete ( id , storageOptions = { } ) { InvalidIdError . test ( id ) ; if ( storageOptions . privateCollection ) { return await this . stubHelper . getStub ( ) . deletePrivateData ( storageOptions . privateCollection , id ) ; } return await this . stubHelper . getStub ( ) . deleteState ( id ) ; } public async history ( id ) { InvalidIdError . test ( id ) ; return await this . stubHelper . getHistoryForKeyAsList ( id ) ; } }